Commit 70e73f59755867383edf563d5a5cbea614c0fd49
1 parent
9cea236492
Exists in
master
and in
4 other branches
[XFS] endianess annotations for xfs_dir2_data_hdr structure.
SGI-PV: 943272 SGI-Modid: xfs-linux-melb:xfs-kern:25484a Signed-off-by: Nathan Scott <nathans@sgi.com>
Showing 6 changed files with 99 additions and 93 deletions Side-by-side Diff
fs/xfs/xfs_da_btree.c
... | ... | @@ -2204,7 +2204,7 @@ |
2204 | 2204 | data = rbp->data; |
2205 | 2205 | free = rbp->data; |
2206 | 2206 | magic = INT_GET(info->magic, ARCH_CONVERT); |
2207 | - magic1 = INT_GET(data->hdr.magic, ARCH_CONVERT); | |
2207 | + magic1 = be32_to_cpu(data->hdr.magic); | |
2208 | 2208 | if (unlikely( |
2209 | 2209 | XFS_TEST_ERROR((magic != XFS_DA_NODE_MAGIC) && |
2210 | 2210 | (magic != XFS_DIR_LEAF_MAGIC) && |
fs/xfs/xfs_dir2_block.c
... | ... | @@ -100,8 +100,7 @@ |
100 | 100 | /* |
101 | 101 | * Check the magic number, corrupted if wrong. |
102 | 102 | */ |
103 | - if (unlikely(INT_GET(block->hdr.magic, ARCH_CONVERT) | |
104 | - != XFS_DIR2_BLOCK_MAGIC)) { | |
103 | + if (unlikely(be32_to_cpu(block->hdr.magic) != XFS_DIR2_BLOCK_MAGIC)) { | |
105 | 104 | XFS_CORRUPTION_ERROR("xfs_dir2_block_addname", |
106 | 105 | XFS_ERRLEVEL_LOW, mp, block); |
107 | 106 | xfs_da_brelse(tp, bp); |
... | ... | @@ -138,7 +137,7 @@ |
138 | 137 | */ |
139 | 138 | else { |
140 | 139 | dup = (xfs_dir2_data_unused_t *) |
141 | - ((char *)block + INT_GET(bf[0].offset, ARCH_CONVERT)); | |
140 | + ((char *)block + be16_to_cpu(bf[0].offset)); | |
142 | 141 | if (dup == enddup) { |
143 | 142 | /* |
144 | 143 | * It is the biggest freespace, is it too small |
145 | 144 | |
... | ... | @@ -149,10 +148,10 @@ |
149 | 148 | * Yes, we use the second-largest |
150 | 149 | * entry instead if it works. |
151 | 150 | */ |
152 | - if (INT_GET(bf[1].length, ARCH_CONVERT) >= len) | |
151 | + if (be16_to_cpu(bf[1].length) >= len) | |
153 | 152 | dup = (xfs_dir2_data_unused_t *) |
154 | 153 | ((char *)block + |
155 | - INT_GET(bf[1].offset, ARCH_CONVERT)); | |
154 | + be16_to_cpu(bf[1].offset)); | |
156 | 155 | else |
157 | 156 | dup = NULL; |
158 | 157 | } |
159 | 158 | |
... | ... | @@ -172,9 +171,9 @@ |
172 | 171 | * If there are stale entries we'll use one for the leaf. |
173 | 172 | * Is the biggest entry enough to avoid compaction? |
174 | 173 | */ |
175 | - else if (INT_GET(bf[0].length, ARCH_CONVERT) >= len) { | |
174 | + else if (be16_to_cpu(bf[0].length) >= len) { | |
176 | 175 | dup = (xfs_dir2_data_unused_t *) |
177 | - ((char *)block + INT_GET(bf[0].offset, ARCH_CONVERT)); | |
176 | + ((char *)block + be16_to_cpu(bf[0].offset)); | |
178 | 177 | compact = 0; |
179 | 178 | } |
180 | 179 | /* |
... | ... | @@ -935,7 +934,7 @@ |
935 | 934 | goto out; |
936 | 935 | } |
937 | 936 | block = dbp->data; |
938 | - ASSERT(INT_GET(block->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC); | |
937 | + ASSERT(be32_to_cpu(block->hdr.magic) == XFS_DIR2_DATA_MAGIC); | |
939 | 938 | /* |
940 | 939 | * Size of the "leaf" area in the block. |
941 | 940 | */ |
... | ... | @@ -956,7 +955,7 @@ |
956 | 955 | /* |
957 | 956 | * Start converting it to block form. |
958 | 957 | */ |
959 | - INT_SET(block->hdr.magic, ARCH_CONVERT, XFS_DIR2_BLOCK_MAGIC); | |
958 | + block->hdr.magic = cpu_to_be32(XFS_DIR2_BLOCK_MAGIC); | |
960 | 959 | needlog = 1; |
961 | 960 | needscan = 0; |
962 | 961 | /* |
... | ... | @@ -1095,7 +1094,7 @@ |
1095 | 1094 | return error; |
1096 | 1095 | } |
1097 | 1096 | block = bp->data; |
1098 | - INT_SET(block->hdr.magic, ARCH_CONVERT, XFS_DIR2_BLOCK_MAGIC); | |
1097 | + block->hdr.magic = cpu_to_be32(XFS_DIR2_BLOCK_MAGIC); | |
1099 | 1098 | /* |
1100 | 1099 | * Compute size of block "tail" area. |
1101 | 1100 | */ |
fs/xfs/xfs_dir2_data.c
... | ... | @@ -70,11 +70,11 @@ |
70 | 70 | |
71 | 71 | mp = dp->i_mount; |
72 | 72 | d = bp->data; |
73 | - ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC || | |
74 | - INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC); | |
73 | + ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC || | |
74 | + be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); | |
75 | 75 | bf = d->hdr.bestfree; |
76 | 76 | p = (char *)d->u; |
77 | - if (INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC) { | |
77 | + if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) { | |
78 | 78 | btp = XFS_DIR2_BLOCK_TAIL_P(mp, (xfs_dir2_block_t *)d); |
79 | 79 | lep = XFS_DIR2_BLOCK_LEAF_P(btp); |
80 | 80 | endp = (char *)lep; |
... | ... | @@ -96,8 +96,8 @@ |
96 | 96 | ASSERT(!bf[2].offset); |
97 | 97 | freeseen |= 1 << 2; |
98 | 98 | } |
99 | - ASSERT(INT_GET(bf[0].length, ARCH_CONVERT) >= INT_GET(bf[1].length, ARCH_CONVERT)); | |
100 | - ASSERT(INT_GET(bf[1].length, ARCH_CONVERT) >= INT_GET(bf[2].length, ARCH_CONVERT)); | |
99 | + ASSERT(be16_to_cpu(bf[0].length) >= be16_to_cpu(bf[1].length)); | |
100 | + ASSERT(be16_to_cpu(bf[1].length) >= be16_to_cpu(bf[2].length)); | |
101 | 101 | /* |
102 | 102 | * Loop over the data/unused entries. |
103 | 103 | */ |
... | ... | @@ -117,8 +117,10 @@ |
117 | 117 | i = (int)(dfp - bf); |
118 | 118 | ASSERT((freeseen & (1 << i)) == 0); |
119 | 119 | freeseen |= 1 << i; |
120 | - } else | |
121 | - ASSERT(INT_GET(dup->length, ARCH_CONVERT) <= INT_GET(bf[2].length, ARCH_CONVERT)); | |
120 | + } else { | |
121 | + ASSERT(INT_GET(dup->length, ARCH_CONVERT) <= | |
122 | + be16_to_cpu(bf[2].length)); | |
123 | + } | |
122 | 124 | p += INT_GET(dup->length, ARCH_CONVERT); |
123 | 125 | lastfree = 1; |
124 | 126 | continue; |
... | ... | @@ -136,7 +138,7 @@ |
136 | 138 | (char *)dep - (char *)d); |
137 | 139 | count++; |
138 | 140 | lastfree = 0; |
139 | - if (INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC) { | |
141 | + if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) { | |
140 | 142 | addr = XFS_DIR2_DB_OFF_TO_DATAPTR(mp, mp->m_dirdatablk, |
141 | 143 | (xfs_dir2_data_aoff_t) |
142 | 144 | ((char *)dep - (char *)d)); |
... | ... | @@ -154,7 +156,7 @@ |
154 | 156 | * Need to have seen all the entries and all the bestfree slots. |
155 | 157 | */ |
156 | 158 | ASSERT(freeseen == 7); |
157 | - if (INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC) { | |
159 | + if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) { | |
158 | 160 | for (i = stale = 0; i < INT_GET(btp->count, ARCH_CONVERT); i++) { |
159 | 161 | if (INT_GET(lep[i].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) |
160 | 162 | stale++; |
... | ... | @@ -190,8 +192,8 @@ |
190 | 192 | * Check order, non-overlapping entries, and if we find the |
191 | 193 | * one we're looking for it has to be exact. |
192 | 194 | */ |
193 | - ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC || | |
194 | - INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC); | |
195 | + ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC || | |
196 | + be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); | |
195 | 197 | for (dfp = &d->hdr.bestfree[0], seenzero = matched = 0; |
196 | 198 | dfp < &d->hdr.bestfree[XFS_DIR2_DATA_FD_COUNT]; |
197 | 199 | dfp++) { |
198 | 200 | |
199 | 201 | |
200 | 202 | |
201 | 203 | |
... | ... | @@ -201,23 +203,24 @@ |
201 | 203 | continue; |
202 | 204 | } |
203 | 205 | ASSERT(seenzero == 0); |
204 | - if (INT_GET(dfp->offset, ARCH_CONVERT) == off) { | |
206 | + if (be16_to_cpu(dfp->offset) == off) { | |
205 | 207 | matched = 1; |
206 | - ASSERT(INT_GET(dfp->length, ARCH_CONVERT) == INT_GET(dup->length, ARCH_CONVERT)); | |
207 | - } else if (off < INT_GET(dfp->offset, ARCH_CONVERT)) | |
208 | - ASSERT(off + INT_GET(dup->length, ARCH_CONVERT) <= INT_GET(dfp->offset, ARCH_CONVERT)); | |
208 | + ASSERT(be16_to_cpu(dfp->length) == INT_GET(dup->length, ARCH_CONVERT)); | |
209 | + } else if (off < be16_to_cpu(dfp->offset)) | |
210 | + ASSERT(off + INT_GET(dup->length, ARCH_CONVERT) <= be16_to_cpu(dfp->offset)); | |
209 | 211 | else |
210 | - ASSERT(INT_GET(dfp->offset, ARCH_CONVERT) + INT_GET(dfp->length, ARCH_CONVERT) <= off); | |
211 | - ASSERT(matched || INT_GET(dfp->length, ARCH_CONVERT) >= INT_GET(dup->length, ARCH_CONVERT)); | |
212 | + ASSERT(be16_to_cpu(dfp->offset) + be16_to_cpu(dfp->length) <= off); | |
213 | + ASSERT(matched || be16_to_cpu(dfp->length) >= INT_GET(dup->length, ARCH_CONVERT)); | |
212 | 214 | if (dfp > &d->hdr.bestfree[0]) |
213 | - ASSERT(INT_GET(dfp[-1].length, ARCH_CONVERT) >= INT_GET(dfp[0].length, ARCH_CONVERT)); | |
215 | + ASSERT(be16_to_cpu(dfp[-1].length) >= be16_to_cpu(dfp[0].length)); | |
214 | 216 | } |
215 | 217 | #endif |
216 | 218 | /* |
217 | 219 | * If this is smaller than the smallest bestfree entry, |
218 | 220 | * it can't be there since they're sorted. |
219 | 221 | */ |
220 | - if (INT_GET(dup->length, ARCH_CONVERT) < INT_GET(d->hdr.bestfree[XFS_DIR2_DATA_FD_COUNT - 1].length, ARCH_CONVERT)) | |
222 | + if (INT_GET(dup->length, ARCH_CONVERT) < | |
223 | + be16_to_cpu(d->hdr.bestfree[XFS_DIR2_DATA_FD_COUNT - 1].length)) | |
221 | 224 | return NULL; |
222 | 225 | /* |
223 | 226 | * Look at the three bestfree entries for our guy. |
... | ... | @@ -227,7 +230,7 @@ |
227 | 230 | dfp++) { |
228 | 231 | if (!dfp->offset) |
229 | 232 | return NULL; |
230 | - if (INT_GET(dfp->offset, ARCH_CONVERT) == off) | |
233 | + if (be16_to_cpu(dfp->offset) == off) | |
231 | 234 | return dfp; |
232 | 235 | } |
233 | 236 | /* |
234 | 237 | |
235 | 238 | |
236 | 239 | |
237 | 240 | |
... | ... | @@ -249,29 +252,29 @@ |
249 | 252 | xfs_dir2_data_free_t new; /* new bestfree entry */ |
250 | 253 | |
251 | 254 | #ifdef __KERNEL__ |
252 | - ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC || | |
253 | - INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC); | |
255 | + ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC || | |
256 | + be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); | |
254 | 257 | #endif |
255 | 258 | dfp = d->hdr.bestfree; |
256 | - INT_COPY(new.length, dup->length, ARCH_CONVERT); | |
257 | - INT_SET(new.offset, ARCH_CONVERT, (xfs_dir2_data_off_t)((char *)dup - (char *)d)); | |
259 | + new.length = dup->length; | |
260 | + new.offset = cpu_to_be16((char *)dup - (char *)d); | |
258 | 261 | /* |
259 | 262 | * Insert at position 0, 1, or 2; or not at all. |
260 | 263 | */ |
261 | - if (INT_GET(new.length, ARCH_CONVERT) > INT_GET(dfp[0].length, ARCH_CONVERT)) { | |
264 | + if (be16_to_cpu(new.length) > be16_to_cpu(dfp[0].length)) { | |
262 | 265 | dfp[2] = dfp[1]; |
263 | 266 | dfp[1] = dfp[0]; |
264 | 267 | dfp[0] = new; |
265 | 268 | *loghead = 1; |
266 | 269 | return &dfp[0]; |
267 | 270 | } |
268 | - if (INT_GET(new.length, ARCH_CONVERT) > INT_GET(dfp[1].length, ARCH_CONVERT)) { | |
271 | + if (be16_to_cpu(new.length) > be16_to_cpu(dfp[1].length)) { | |
269 | 272 | dfp[2] = dfp[1]; |
270 | 273 | dfp[1] = new; |
271 | 274 | *loghead = 1; |
272 | 275 | return &dfp[1]; |
273 | 276 | } |
274 | - if (INT_GET(new.length, ARCH_CONVERT) > INT_GET(dfp[2].length, ARCH_CONVERT)) { | |
277 | + if (be16_to_cpu(new.length) > be16_to_cpu(dfp[2].length)) { | |
275 | 278 | dfp[2] = new; |
276 | 279 | *loghead = 1; |
277 | 280 | return &dfp[2]; |
... | ... | @@ -289,8 +292,8 @@ |
289 | 292 | int *loghead) /* out: log data header */ |
290 | 293 | { |
291 | 294 | #ifdef __KERNEL__ |
292 | - ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC || | |
293 | - INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC); | |
295 | + ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC || | |
296 | + be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); | |
294 | 297 | #endif |
295 | 298 | /* |
296 | 299 | * It's the first entry, slide the next 2 up. |
... | ... | @@ -334,8 +337,8 @@ |
334 | 337 | char *p; /* current entry pointer */ |
335 | 338 | |
336 | 339 | #ifdef __KERNEL__ |
337 | - ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC || | |
338 | - INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC); | |
340 | + ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC || | |
341 | + be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); | |
339 | 342 | #endif |
340 | 343 | /* |
341 | 344 | * Start by clearing the table. |
... | ... | @@ -348,7 +351,7 @@ |
348 | 351 | p = (char *)d->u; |
349 | 352 | if (aendp) |
350 | 353 | endp = aendp; |
351 | - else if (INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC) { | |
354 | + else if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) { | |
352 | 355 | btp = XFS_DIR2_BLOCK_TAIL_P(mp, (xfs_dir2_block_t *)d); |
353 | 356 | endp = (char *)XFS_DIR2_BLOCK_LEAF_P(btp); |
354 | 357 | } else |
... | ... | @@ -415,8 +418,8 @@ |
415 | 418 | * Initialize the header. |
416 | 419 | */ |
417 | 420 | d = bp->data; |
418 | - INT_SET(d->hdr.magic, ARCH_CONVERT, XFS_DIR2_DATA_MAGIC); | |
419 | - INT_SET(d->hdr.bestfree[0].offset, ARCH_CONVERT, (xfs_dir2_data_off_t)sizeof(d->hdr)); | |
421 | + d->hdr.magic = cpu_to_be32(XFS_DIR2_DATA_MAGIC); | |
422 | + d->hdr.bestfree[0].offset = cpu_to_be16(sizeof(d->hdr)); | |
420 | 423 | for (i = 1; i < XFS_DIR2_DATA_FD_COUNT; i++) { |
421 | 424 | d->hdr.bestfree[i].length = 0; |
422 | 425 | d->hdr.bestfree[i].offset = 0; |
... | ... | @@ -428,7 +431,7 @@ |
428 | 431 | INT_SET(dup->freetag, ARCH_CONVERT, XFS_DIR2_DATA_FREE_TAG); |
429 | 432 | |
430 | 433 | t=mp->m_dirblksize - (uint)sizeof(d->hdr); |
431 | - INT_SET(d->hdr.bestfree[0].length, ARCH_CONVERT, t); | |
434 | + d->hdr.bestfree[0].length = cpu_to_be16(t); | |
432 | 435 | INT_SET(dup->length, ARCH_CONVERT, t); |
433 | 436 | INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT, |
434 | 437 | (xfs_dir2_data_off_t)((char *)dup - (char *)d)); |
... | ... | @@ -453,8 +456,8 @@ |
453 | 456 | xfs_dir2_data_t *d; /* data block pointer */ |
454 | 457 | |
455 | 458 | d = bp->data; |
456 | - ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC || | |
457 | - INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC); | |
459 | + ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC || | |
460 | + be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); | |
458 | 461 | xfs_da_log_buf(tp, bp, (uint)((char *)dep - (char *)d), |
459 | 462 | (uint)((char *)(XFS_DIR2_DATA_ENTRY_TAG_P(dep) + 1) - |
460 | 463 | (char *)d - 1)); |
... | ... | @@ -471,8 +474,8 @@ |
471 | 474 | xfs_dir2_data_t *d; /* data block pointer */ |
472 | 475 | |
473 | 476 | d = bp->data; |
474 | - ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC || | |
475 | - INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC); | |
477 | + ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC || | |
478 | + be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); | |
476 | 479 | xfs_da_log_buf(tp, bp, (uint)((char *)&d->hdr - (char *)d), |
477 | 480 | (uint)(sizeof(d->hdr) - 1)); |
478 | 481 | } |
... | ... | @@ -489,8 +492,8 @@ |
489 | 492 | xfs_dir2_data_t *d; /* data block pointer */ |
490 | 493 | |
491 | 494 | d = bp->data; |
492 | - ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC || | |
493 | - INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC); | |
495 | + ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC || | |
496 | + be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); | |
494 | 497 | /* |
495 | 498 | * Log the first part of the unused entry. |
496 | 499 | */ |
497 | 500 | |
... | ... | @@ -533,12 +536,12 @@ |
533 | 536 | /* |
534 | 537 | * Figure out where the end of the data area is. |
535 | 538 | */ |
536 | - if (INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC) | |
539 | + if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC) | |
537 | 540 | endptr = (char *)d + mp->m_dirblksize; |
538 | 541 | else { |
539 | 542 | xfs_dir2_block_tail_t *btp; /* block tail */ |
540 | 543 | |
541 | - ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC); | |
544 | + ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); | |
542 | 545 | btp = XFS_DIR2_BLOCK_TAIL_P(mp, (xfs_dir2_block_t *)d); |
543 | 546 | endptr = (char *)XFS_DIR2_BLOCK_LEAF_P(btp); |
544 | 547 | } |
... | ... | @@ -586,7 +589,7 @@ |
586 | 589 | * since the third bestfree is there, there might be more |
587 | 590 | * entries. |
588 | 591 | */ |
589 | - needscan = d->hdr.bestfree[2].length; | |
592 | + needscan = (d->hdr.bestfree[2].length != 0); | |
590 | 593 | /* |
591 | 594 | * Fix up the new big freespace. |
592 | 595 | */ |
... | ... | @@ -614,7 +617,7 @@ |
614 | 617 | */ |
615 | 618 | dfp = xfs_dir2_data_freeinsert(d, prevdup, needlogp); |
616 | 619 | ASSERT(dfp == &d->hdr.bestfree[0]); |
617 | - ASSERT(INT_GET(dfp->length, ARCH_CONVERT) == INT_GET(prevdup->length, ARCH_CONVERT)); | |
620 | + ASSERT(be16_to_cpu(dfp->length) == INT_GET(prevdup->length, ARCH_CONVERT)); | |
618 | 621 | ASSERT(!dfp[1].length); |
619 | 622 | ASSERT(!dfp[2].length); |
620 | 623 | } |
... | ... | @@ -640,8 +643,10 @@ |
640 | 643 | /* |
641 | 644 | * Otherwise we need a scan if the new entry is big enough. |
642 | 645 | */ |
643 | - else | |
644 | - needscan = INT_GET(prevdup->length, ARCH_CONVERT) > INT_GET(d->hdr.bestfree[2].length, ARCH_CONVERT); | |
646 | + else { | |
647 | + needscan = INT_GET(prevdup->length, ARCH_CONVERT) > | |
648 | + be16_to_cpu(d->hdr.bestfree[2].length); | |
649 | + } | |
645 | 650 | } |
646 | 651 | /* |
647 | 652 | * The following entry is free, merge with it. |
... | ... | @@ -666,8 +671,10 @@ |
666 | 671 | /* |
667 | 672 | * Otherwise we need a scan if the new entry is big enough. |
668 | 673 | */ |
669 | - else | |
670 | - needscan = INT_GET(newdup->length, ARCH_CONVERT) > INT_GET(d->hdr.bestfree[2].length, ARCH_CONVERT); | |
674 | + else { | |
675 | + needscan = INT_GET(newdup->length, ARCH_CONVERT) > | |
676 | + be16_to_cpu(d->hdr.bestfree[2].length); | |
677 | + } | |
671 | 678 | } |
672 | 679 | /* |
673 | 680 | * Neither neighbor is free. Make a new entry. |
... | ... | @@ -707,8 +714,8 @@ |
707 | 714 | int oldlen; /* old unused entry's length */ |
708 | 715 | |
709 | 716 | d = bp->data; |
710 | - ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC || | |
711 | - INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC); | |
717 | + ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC || | |
718 | + be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); | |
712 | 719 | ASSERT(INT_GET(dup->freetag, ARCH_CONVERT) == XFS_DIR2_DATA_FREE_TAG); |
713 | 720 | ASSERT(offset >= (char *)dup - (char *)d); |
714 | 721 | ASSERT(offset + len <= (char *)dup + INT_GET(dup->length, ARCH_CONVERT) - (char *)d); |
... | ... | @@ -718,7 +725,7 @@ |
718 | 725 | */ |
719 | 726 | dfp = xfs_dir2_data_freefind(d, dup); |
720 | 727 | oldlen = INT_GET(dup->length, ARCH_CONVERT); |
721 | - ASSERT(dfp || oldlen <= INT_GET(d->hdr.bestfree[2].length, ARCH_CONVERT)); | |
728 | + ASSERT(dfp || oldlen <= be16_to_cpu(d->hdr.bestfree[2].length)); | |
722 | 729 | /* |
723 | 730 | * Check for alignment with front and back of the entry. |
724 | 731 | */ |
... | ... | @@ -732,7 +739,7 @@ |
732 | 739 | */ |
733 | 740 | if (matchfront && matchback) { |
734 | 741 | if (dfp) { |
735 | - needscan = d->hdr.bestfree[2].offset; | |
742 | + needscan = (d->hdr.bestfree[2].offset != 0); | |
736 | 743 | if (!needscan) |
737 | 744 | xfs_dir2_data_freeremove(d, dfp, needlogp); |
738 | 745 | } |
... | ... | @@ -755,8 +762,8 @@ |
755 | 762 | xfs_dir2_data_freeremove(d, dfp, needlogp); |
756 | 763 | dfp = xfs_dir2_data_freeinsert(d, newdup, needlogp); |
757 | 764 | ASSERT(dfp != NULL); |
758 | - ASSERT(INT_GET(dfp->length, ARCH_CONVERT) == INT_GET(newdup->length, ARCH_CONVERT)); | |
759 | - ASSERT(INT_GET(dfp->offset, ARCH_CONVERT) == (char *)newdup - (char *)d); | |
765 | + ASSERT(be16_to_cpu(dfp->length) == INT_GET(newdup->length, ARCH_CONVERT)); | |
766 | + ASSERT(be16_to_cpu(dfp->offset) == (char *)newdup - (char *)d); | |
760 | 767 | /* |
761 | 768 | * If we got inserted at the last slot, |
762 | 769 | * that means we don't know if there was a better |
... | ... | @@ -783,8 +790,8 @@ |
783 | 790 | xfs_dir2_data_freeremove(d, dfp, needlogp); |
784 | 791 | dfp = xfs_dir2_data_freeinsert(d, newdup, needlogp); |
785 | 792 | ASSERT(dfp != NULL); |
786 | - ASSERT(INT_GET(dfp->length, ARCH_CONVERT) == INT_GET(newdup->length, ARCH_CONVERT)); | |
787 | - ASSERT(INT_GET(dfp->offset, ARCH_CONVERT) == (char *)newdup - (char *)d); | |
793 | + ASSERT(be16_to_cpu(dfp->length) == INT_GET(newdup->length, ARCH_CONVERT)); | |
794 | + ASSERT(be16_to_cpu(dfp->offset) == (char *)newdup - (char *)d); | |
788 | 795 | /* |
789 | 796 | * If we got inserted at the last slot, |
790 | 797 | * that means we don't know if there was a better |
... | ... | @@ -819,7 +826,7 @@ |
819 | 826 | * the 2 new will work. |
820 | 827 | */ |
821 | 828 | if (dfp) { |
822 | - needscan = d->hdr.bestfree[2].length; | |
829 | + needscan = (d->hdr.bestfree[2].length != 0); | |
823 | 830 | if (!needscan) { |
824 | 831 | xfs_dir2_data_freeremove(d, dfp, needlogp); |
825 | 832 | (void)xfs_dir2_data_freeinsert(d, newdup, |
fs/xfs/xfs_dir2_data.h
... | ... | @@ -65,8 +65,8 @@ |
65 | 65 | * The freespace will be formatted as a xfs_dir2_data_unused_t. |
66 | 66 | */ |
67 | 67 | typedef struct xfs_dir2_data_free { |
68 | - xfs_dir2_data_off_t offset; /* start of freespace */ | |
69 | - xfs_dir2_data_off_t length; /* length of freespace */ | |
68 | + __be16 offset; /* start of freespace */ | |
69 | + __be16 length; /* length of freespace */ | |
70 | 70 | } xfs_dir2_data_free_t; |
71 | 71 | |
72 | 72 | /* |
... | ... | @@ -75,7 +75,7 @@ |
75 | 75 | * The code knows that XFS_DIR2_DATA_FD_COUNT is 3. |
76 | 76 | */ |
77 | 77 | typedef struct xfs_dir2_data_hdr { |
78 | - __uint32_t magic; /* XFS_DIR2_DATA_MAGIC */ | |
78 | + __be32 magic; /* XFS_DIR2_DATA_MAGIC */ | |
79 | 79 | /* or XFS_DIR2_BLOCK_MAGIC */ |
80 | 80 | xfs_dir2_data_free_t bestfree[XFS_DIR2_DATA_FD_COUNT]; |
81 | 81 | } xfs_dir2_data_hdr_t; |
fs/xfs/xfs_dir2_leaf.c
... | ... | @@ -133,7 +133,7 @@ |
133 | 133 | /* |
134 | 134 | * Fix up the block header, make it a data block. |
135 | 135 | */ |
136 | - INT_SET(block->hdr.magic, ARCH_CONVERT, XFS_DIR2_DATA_MAGIC); | |
136 | + block->hdr.magic = cpu_to_be32(XFS_DIR2_DATA_MAGIC); | |
137 | 137 | if (needscan) |
138 | 138 | xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)block, &needlog, |
139 | 139 | NULL); |
... | ... | @@ -143,7 +143,7 @@ |
143 | 143 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); |
144 | 144 | INT_SET(ltp->bestcount, ARCH_CONVERT, 1); |
145 | 145 | bestsp = XFS_DIR2_LEAF_BESTS_P(ltp); |
146 | - INT_COPY(bestsp[0], block->hdr.bestfree[0].length, ARCH_CONVERT); | |
146 | + bestsp[0] = block->hdr.bestfree[0].length; | |
147 | 147 | /* |
148 | 148 | * Log the data header and leaf bests table. |
149 | 149 | */ |
... | ... | @@ -372,7 +372,7 @@ |
372 | 372 | else |
373 | 373 | xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block); |
374 | 374 | data = dbp->data; |
375 | - INT_COPY(bestsp[use_block], data->hdr.bestfree[0].length, ARCH_CONVERT); | |
375 | + bestsp[use_block] = data->hdr.bestfree[0].length; | |
376 | 376 | grown = 1; |
377 | 377 | } |
378 | 378 | /* |
... | ... | @@ -394,7 +394,7 @@ |
394 | 394 | * Point to the biggest freespace in our data block. |
395 | 395 | */ |
396 | 396 | dup = (xfs_dir2_data_unused_t *) |
397 | - ((char *)data + INT_GET(data->hdr.bestfree[0].offset, ARCH_CONVERT)); | |
397 | + ((char *)data + be16_to_cpu(data->hdr.bestfree[0].offset)); | |
398 | 398 | ASSERT(INT_GET(dup->length, ARCH_CONVERT) >= length); |
399 | 399 | needscan = needlog = 0; |
400 | 400 | /* |
... | ... | @@ -427,8 +427,8 @@ |
427 | 427 | * If the bests table needs to be changed, do it. |
428 | 428 | * Log the change unless we've already done that. |
429 | 429 | */ |
430 | - if (INT_GET(bestsp[use_block], ARCH_CONVERT) != INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT)) { | |
431 | - INT_COPY(bestsp[use_block], data->hdr.bestfree[0].length, ARCH_CONVERT); | |
430 | + if (INT_GET(bestsp[use_block], ARCH_CONVERT) != be16_to_cpu(data->hdr.bestfree[0].length)) { | |
431 | + bestsp[use_block] = data->hdr.bestfree[0].length; | |
432 | 432 | if (!grown) |
433 | 433 | xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block); |
434 | 434 | } |
... | ... | @@ -1477,7 +1477,7 @@ |
1477 | 1477 | dep = (xfs_dir2_data_entry_t *) |
1478 | 1478 | ((char *)data + XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(lep->address, ARCH_CONVERT))); |
1479 | 1479 | needscan = needlog = 0; |
1480 | - oldbest = INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT); | |
1480 | + oldbest = be16_to_cpu(data->hdr.bestfree[0].length); | |
1481 | 1481 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); |
1482 | 1482 | bestsp = XFS_DIR2_LEAF_BESTS_P(ltp); |
1483 | 1483 | ASSERT(INT_GET(bestsp[db], ARCH_CONVERT) == oldbest); |
1484 | 1484 | |
... | ... | @@ -1506,15 +1506,15 @@ |
1506 | 1506 | * If the longest freespace in the data block has changed, |
1507 | 1507 | * put the new value in the bests table and log that. |
1508 | 1508 | */ |
1509 | - if (INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT) != oldbest) { | |
1510 | - INT_COPY(bestsp[db], data->hdr.bestfree[0].length, ARCH_CONVERT); | |
1509 | + if (be16_to_cpu(data->hdr.bestfree[0].length) != oldbest) { | |
1510 | + bestsp[db] = data->hdr.bestfree[0].length; | |
1511 | 1511 | xfs_dir2_leaf_log_bests(tp, lbp, db, db); |
1512 | 1512 | } |
1513 | 1513 | xfs_dir2_data_check(dp, dbp); |
1514 | 1514 | /* |
1515 | 1515 | * If the data block is now empty then get rid of the data block. |
1516 | 1516 | */ |
1517 | - if (INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT) == | |
1517 | + if (be16_to_cpu(data->hdr.bestfree[0].length) == | |
1518 | 1518 | mp->m_dirblksize - (uint)sizeof(data->hdr)) { |
1519 | 1519 | ASSERT(db != mp->m_dirdatablk); |
1520 | 1520 | if ((error = xfs_dir2_shrink_inode(args, db, dbp))) { |
... | ... | @@ -1708,7 +1708,7 @@ |
1708 | 1708 | } |
1709 | 1709 | #ifdef DEBUG |
1710 | 1710 | data = dbp->data; |
1711 | - ASSERT(INT_GET(data->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC); | |
1711 | + ASSERT(be32_to_cpu(data->hdr.magic) == XFS_DIR2_DATA_MAGIC); | |
1712 | 1712 | #endif |
1713 | 1713 | /* this seems to be an error |
1714 | 1714 | * data is only valid if DEBUG is defined? |
... | ... | @@ -1717,7 +1717,7 @@ |
1717 | 1717 | |
1718 | 1718 | leaf = lbp->data; |
1719 | 1719 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); |
1720 | - ASSERT(INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT) == | |
1720 | + ASSERT(be16_to_cpu(data->hdr.bestfree[0].length) == | |
1721 | 1721 | mp->m_dirblksize - (uint)sizeof(data->hdr)); |
1722 | 1722 | ASSERT(db == INT_GET(ltp->bestcount, ARCH_CONVERT) - 1); |
1723 | 1723 | /* |
fs/xfs/xfs_dir2_node.c
... | ... | @@ -894,7 +894,7 @@ |
894 | 894 | dbp = dblk->bp; |
895 | 895 | data = dbp->data; |
896 | 896 | dep = (xfs_dir2_data_entry_t *)((char *)data + off); |
897 | - longest = INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT); | |
897 | + longest = be16_to_cpu(data->hdr.bestfree[0].length); | |
898 | 898 | needlog = needscan = 0; |
899 | 899 | xfs_dir2_data_make_free(tp, dbp, off, |
900 | 900 | XFS_DIR2_DATA_ENTSIZE(dep->namelen), &needlog, &needscan); |
... | ... | @@ -911,7 +911,7 @@ |
911 | 911 | * If the longest data block freespace changes, need to update |
912 | 912 | * the corresponding freeblock entry. |
913 | 913 | */ |
914 | - if (longest < INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT)) { | |
914 | + if (longest < be16_to_cpu(data->hdr.bestfree[0].length)) { | |
915 | 915 | int error; /* error return value */ |
916 | 916 | xfs_dabuf_t *fbp; /* freeblock buffer */ |
917 | 917 | xfs_dir2_db_t fdb; /* freeblock block number */ |
... | ... | @@ -937,7 +937,7 @@ |
937 | 937 | * Calculate which entry we need to fix. |
938 | 938 | */ |
939 | 939 | findex = XFS_DIR2_DB_TO_FDINDEX(mp, db); |
940 | - longest = INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT); | |
940 | + longest = be16_to_cpu(data->hdr.bestfree[0].length); | |
941 | 941 | /* |
942 | 942 | * If the data block is now empty we can get rid of it |
943 | 943 | * (usually). |
... | ... | @@ -1649,7 +1649,7 @@ |
1649 | 1649 | * change again. |
1650 | 1650 | */ |
1651 | 1651 | data = dbp->data; |
1652 | - INT_COPY(free->bests[findex], data->hdr.bestfree[0].length, ARCH_CONVERT); | |
1652 | + free->bests[findex] = data->hdr.bestfree[0].length; | |
1653 | 1653 | logfree = 1; |
1654 | 1654 | } |
1655 | 1655 | /* |
1656 | 1656 | |
... | ... | @@ -1677,12 +1677,12 @@ |
1677 | 1677 | data = dbp->data; |
1678 | 1678 | logfree = 0; |
1679 | 1679 | } |
1680 | - ASSERT(INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT) >= length); | |
1680 | + ASSERT(be16_to_cpu(data->hdr.bestfree[0].length) >= length); | |
1681 | 1681 | /* |
1682 | 1682 | * Point to the existing unused space. |
1683 | 1683 | */ |
1684 | 1684 | dup = (xfs_dir2_data_unused_t *) |
1685 | - ((char *)data + INT_GET(data->hdr.bestfree[0].offset, ARCH_CONVERT)); | |
1685 | + ((char *)data + be16_to_cpu(data->hdr.bestfree[0].offset)); | |
1686 | 1686 | needscan = needlog = 0; |
1687 | 1687 | /* |
1688 | 1688 | * Mark the first part of the unused space, inuse for us. |
... | ... | @@ -1713,8 +1713,8 @@ |
1713 | 1713 | /* |
1714 | 1714 | * If the freespace entry is now wrong, update it. |
1715 | 1715 | */ |
1716 | - if (INT_GET(free->bests[findex], ARCH_CONVERT) != INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT)) { | |
1717 | - INT_COPY(free->bests[findex], data->hdr.bestfree[0].length, ARCH_CONVERT); | |
1716 | + if (INT_GET(free->bests[findex], ARCH_CONVERT) != be16_to_cpu(data->hdr.bestfree[0].length)) { | |
1717 | + free->bests[findex] = data->hdr.bestfree[0].length; | |
1718 | 1718 | logfree = 1; |
1719 | 1719 | } |
1720 | 1720 | /* |
... | ... | @@ -1900,7 +1900,7 @@ |
1900 | 1900 | * Point to the data entry. |
1901 | 1901 | */ |
1902 | 1902 | data = state->extrablk.bp->data; |
1903 | - ASSERT(INT_GET(data->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC); | |
1903 | + ASSERT(be32_to_cpu(data->hdr.magic) == XFS_DIR2_DATA_MAGIC); | |
1904 | 1904 | dep = (xfs_dir2_data_entry_t *) |
1905 | 1905 | ((char *)data + |
1906 | 1906 | XFS_DIR2_DATAPTR_TO_OFF(state->mp, INT_GET(lep->address, ARCH_CONVERT))); |