diff options
author | Nathan Scott <nathans@sgi.com> | 2006-03-17 01:27:37 -0500 |
---|---|---|
committer | Nathan Scott <nathans@sgi.com> | 2006-03-17 01:27:37 -0500 |
commit | ad354eb34eb354eedc483d1e89e17710165bd2db (patch) | |
tree | aa7977517a3f516c81cf162bd62d7f84749a3138 /fs/xfs | |
parent | afbcb3f91903bcd34d470efe64b3738257178667 (diff) |
[XFS] endianess annotations for xfs_dir2_data_unused_t
SGI-PV: 943272
SGI-Modid: xfs-linux-melb:xfs-kern:25489a
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nathan Scott <nathans@sgi.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/xfs_dir2_block.c | 27 | ||||
-rw-r--r-- | fs/xfs/xfs_dir2_data.c | 68 | ||||
-rw-r--r-- | fs/xfs/xfs_dir2_data.h | 8 | ||||
-rw-r--r-- | fs/xfs/xfs_dir2_leaf.c | 12 | ||||
-rw-r--r-- | fs/xfs/xfs_dir2_sf.c | 4 |
5 files changed, 58 insertions, 61 deletions
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c index f70640c6b703..8b8aed77acd1 100644 --- a/fs/xfs/xfs_dir2_block.c +++ b/fs/xfs/xfs_dir2_block.c | |||
@@ -130,7 +130,7 @@ xfs_dir2_block_addname( | |||
130 | * the space before the first leaf entry needs to be free so it | 130 | * the space before the first leaf entry needs to be free so it |
131 | * can be expanded to hold the pointer to the new entry. | 131 | * can be expanded to hold the pointer to the new entry. |
132 | */ | 132 | */ |
133 | if (INT_GET(enddup->freetag, ARCH_CONVERT) != XFS_DIR2_DATA_FREE_TAG) | 133 | if (be16_to_cpu(enddup->freetag) != XFS_DIR2_DATA_FREE_TAG) |
134 | dup = enddup = NULL; | 134 | dup = enddup = NULL; |
135 | /* | 135 | /* |
136 | * Check out the biggest freespace and see if it's the same one. | 136 | * Check out the biggest freespace and see if it's the same one. |
@@ -143,7 +143,7 @@ xfs_dir2_block_addname( | |||
143 | * It is the biggest freespace, is it too small | 143 | * It is the biggest freespace, is it too small |
144 | * to hold the new leaf too? | 144 | * to hold the new leaf too? |
145 | */ | 145 | */ |
146 | if (INT_GET(dup->length, ARCH_CONVERT) < len + (uint)sizeof(*blp)) { | 146 | if (be16_to_cpu(dup->length) < len + (uint)sizeof(*blp)) { |
147 | /* | 147 | /* |
148 | * Yes, we use the second-largest | 148 | * Yes, we use the second-largest |
149 | * entry instead if it works. | 149 | * entry instead if it works. |
@@ -160,7 +160,7 @@ xfs_dir2_block_addname( | |||
160 | * Not the same free entry, | 160 | * Not the same free entry, |
161 | * just check its length. | 161 | * just check its length. |
162 | */ | 162 | */ |
163 | if (INT_GET(dup->length, ARCH_CONVERT) < len) { | 163 | if (be16_to_cpu(dup->length) < len) { |
164 | dup = NULL; | 164 | dup = NULL; |
165 | } | 165 | } |
166 | } | 166 | } |
@@ -192,8 +192,8 @@ xfs_dir2_block_addname( | |||
192 | * If it's not free then the data will go where the | 192 | * If it's not free then the data will go where the |
193 | * leaf data starts now, if it works at all. | 193 | * leaf data starts now, if it works at all. |
194 | */ | 194 | */ |
195 | if (INT_GET(dup->freetag, ARCH_CONVERT) == XFS_DIR2_DATA_FREE_TAG) { | 195 | if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) { |
196 | if (INT_GET(dup->length, ARCH_CONVERT) + (INT_GET(btp->stale, ARCH_CONVERT) - 1) * | 196 | if (be16_to_cpu(dup->length) + (INT_GET(btp->stale, ARCH_CONVERT) - 1) * |
197 | (uint)sizeof(*blp) < len) | 197 | (uint)sizeof(*blp) < len) |
198 | dup = NULL; | 198 | dup = NULL; |
199 | } else if ((INT_GET(btp->stale, ARCH_CONVERT) - 1) * (uint)sizeof(*blp) < len) | 199 | } else if ((INT_GET(btp->stale, ARCH_CONVERT) - 1) * (uint)sizeof(*blp) < len) |
@@ -310,7 +310,7 @@ xfs_dir2_block_addname( | |||
310 | */ | 310 | */ |
311 | xfs_dir2_data_use_free(tp, bp, enddup, | 311 | xfs_dir2_data_use_free(tp, bp, enddup, |
312 | (xfs_dir2_data_aoff_t) | 312 | (xfs_dir2_data_aoff_t) |
313 | ((char *)enddup - (char *)block + INT_GET(enddup->length, ARCH_CONVERT) - | 313 | ((char *)enddup - (char *)block + be16_to_cpu(enddup->length) - |
314 | sizeof(*blp)), | 314 | sizeof(*blp)), |
315 | (xfs_dir2_data_aoff_t)sizeof(*blp), | 315 | (xfs_dir2_data_aoff_t)sizeof(*blp), |
316 | &needlog, &needscan); | 316 | &needlog, &needscan); |
@@ -484,8 +484,8 @@ xfs_dir2_block_getdents( | |||
484 | /* | 484 | /* |
485 | * Unused, skip it. | 485 | * Unused, skip it. |
486 | */ | 486 | */ |
487 | if (INT_GET(dup->freetag, ARCH_CONVERT) == XFS_DIR2_DATA_FREE_TAG) { | 487 | if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) { |
488 | ptr += INT_GET(dup->length, ARCH_CONVERT); | 488 | ptr += be16_to_cpu(dup->length); |
489 | continue; | 489 | continue; |
490 | } | 490 | } |
491 | 491 | ||
@@ -948,7 +948,8 @@ xfs_dir2_leaf_to_block( | |||
948 | /* | 948 | /* |
949 | * If it's not free or is too short we can't do it. | 949 | * If it's not free or is too short we can't do it. |
950 | */ | 950 | */ |
951 | if (INT_GET(dup->freetag, ARCH_CONVERT) != XFS_DIR2_DATA_FREE_TAG || INT_GET(dup->length, ARCH_CONVERT) < size) { | 951 | if (be16_to_cpu(dup->freetag) != XFS_DIR2_DATA_FREE_TAG || |
952 | be16_to_cpu(dup->length) < size) { | ||
952 | error = 0; | 953 | error = 0; |
953 | goto out; | 954 | goto out; |
954 | } | 955 | } |
@@ -1122,7 +1123,7 @@ xfs_dir2_sf_to_block( | |||
1122 | */ | 1123 | */ |
1123 | xfs_dir2_data_use_free(tp, bp, dup, | 1124 | xfs_dir2_data_use_free(tp, bp, dup, |
1124 | (xfs_dir2_data_aoff_t)((char *)dup - (char *)block), | 1125 | (xfs_dir2_data_aoff_t)((char *)dup - (char *)block), |
1125 | INT_GET(dup->length, ARCH_CONVERT), &needlog, &needscan); | 1126 | be16_to_cpu(dup->length), &needlog, &needscan); |
1126 | /* | 1127 | /* |
1127 | * Create entry for . | 1128 | * Create entry for . |
1128 | */ | 1129 | */ |
@@ -1175,15 +1176,15 @@ xfs_dir2_sf_to_block( | |||
1175 | if (offset < newoffset) { | 1176 | if (offset < newoffset) { |
1176 | dup = (xfs_dir2_data_unused_t *) | 1177 | dup = (xfs_dir2_data_unused_t *) |
1177 | ((char *)block + offset); | 1178 | ((char *)block + offset); |
1178 | INT_SET(dup->freetag, ARCH_CONVERT, XFS_DIR2_DATA_FREE_TAG); | 1179 | dup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); |
1179 | INT_SET(dup->length, ARCH_CONVERT, newoffset - offset); | 1180 | dup->length = cpu_to_be16(newoffset - offset); |
1180 | INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT, | 1181 | INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT, |
1181 | (xfs_dir2_data_off_t) | 1182 | (xfs_dir2_data_off_t) |
1182 | ((char *)dup - (char *)block)); | 1183 | ((char *)dup - (char *)block)); |
1183 | xfs_dir2_data_log_unused(tp, bp, dup); | 1184 | xfs_dir2_data_log_unused(tp, bp, dup); |
1184 | (void)xfs_dir2_data_freeinsert((xfs_dir2_data_t *)block, | 1185 | (void)xfs_dir2_data_freeinsert((xfs_dir2_data_t *)block, |
1185 | dup, &dummy); | 1186 | dup, &dummy); |
1186 | offset += INT_GET(dup->length, ARCH_CONVERT); | 1187 | offset += be16_to_cpu(dup->length); |
1187 | continue; | 1188 | continue; |
1188 | } | 1189 | } |
1189 | /* | 1190 | /* |
diff --git a/fs/xfs/xfs_dir2_data.c b/fs/xfs/xfs_dir2_data.c index fd6b7c03018a..48b4906c8e80 100644 --- a/fs/xfs/xfs_dir2_data.c +++ b/fs/xfs/xfs_dir2_data.c | |||
@@ -108,7 +108,7 @@ xfs_dir2_data_check( | |||
108 | * If we find it, account for that, else make sure it | 108 | * If we find it, account for that, else make sure it |
109 | * doesn't need to be there. | 109 | * doesn't need to be there. |
110 | */ | 110 | */ |
111 | if (INT_GET(dup->freetag, ARCH_CONVERT) == XFS_DIR2_DATA_FREE_TAG) { | 111 | if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) { |
112 | ASSERT(lastfree == 0); | 112 | ASSERT(lastfree == 0); |
113 | ASSERT(INT_GET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT) == | 113 | ASSERT(INT_GET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT) == |
114 | (char *)dup - (char *)d); | 114 | (char *)dup - (char *)d); |
@@ -118,10 +118,10 @@ xfs_dir2_data_check( | |||
118 | ASSERT((freeseen & (1 << i)) == 0); | 118 | ASSERT((freeseen & (1 << i)) == 0); |
119 | freeseen |= 1 << i; | 119 | freeseen |= 1 << i; |
120 | } else { | 120 | } else { |
121 | ASSERT(INT_GET(dup->length, ARCH_CONVERT) <= | 121 | ASSERT(be16_to_cpu(dup->length) <= |
122 | be16_to_cpu(bf[2].length)); | 122 | be16_to_cpu(bf[2].length)); |
123 | } | 123 | } |
124 | p += INT_GET(dup->length, ARCH_CONVERT); | 124 | p += be16_to_cpu(dup->length); |
125 | lastfree = 1; | 125 | lastfree = 1; |
126 | continue; | 126 | continue; |
127 | } | 127 | } |
@@ -205,12 +205,12 @@ xfs_dir2_data_freefind( | |||
205 | ASSERT(seenzero == 0); | 205 | ASSERT(seenzero == 0); |
206 | if (be16_to_cpu(dfp->offset) == off) { | 206 | if (be16_to_cpu(dfp->offset) == off) { |
207 | matched = 1; | 207 | matched = 1; |
208 | ASSERT(be16_to_cpu(dfp->length) == INT_GET(dup->length, ARCH_CONVERT)); | 208 | ASSERT(dfp->length == dup->length); |
209 | } else if (off < be16_to_cpu(dfp->offset)) | 209 | } else if (off < be16_to_cpu(dfp->offset)) |
210 | ASSERT(off + INT_GET(dup->length, ARCH_CONVERT) <= be16_to_cpu(dfp->offset)); | 210 | ASSERT(off + be16_to_cpu(dup->length) <= be16_to_cpu(dfp->offset)); |
211 | else | 211 | else |
212 | ASSERT(be16_to_cpu(dfp->offset) + be16_to_cpu(dfp->length) <= off); | 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)); | 213 | ASSERT(matched || be16_to_cpu(dfp->length) >= be16_to_cpu(dup->length)); |
214 | if (dfp > &d->hdr.bestfree[0]) | 214 | if (dfp > &d->hdr.bestfree[0]) |
215 | ASSERT(be16_to_cpu(dfp[-1].length) >= be16_to_cpu(dfp[0].length)); | 215 | ASSERT(be16_to_cpu(dfp[-1].length) >= be16_to_cpu(dfp[0].length)); |
216 | } | 216 | } |
@@ -219,7 +219,7 @@ xfs_dir2_data_freefind( | |||
219 | * If this is smaller than the smallest bestfree entry, | 219 | * If this is smaller than the smallest bestfree entry, |
220 | * it can't be there since they're sorted. | 220 | * it can't be there since they're sorted. |
221 | */ | 221 | */ |
222 | if (INT_GET(dup->length, ARCH_CONVERT) < | 222 | if (be16_to_cpu(dup->length) < |
223 | be16_to_cpu(d->hdr.bestfree[XFS_DIR2_DATA_FD_COUNT - 1].length)) | 223 | be16_to_cpu(d->hdr.bestfree[XFS_DIR2_DATA_FD_COUNT - 1].length)) |
224 | return NULL; | 224 | return NULL; |
225 | /* | 225 | /* |
@@ -364,11 +364,11 @@ xfs_dir2_data_freescan( | |||
364 | /* | 364 | /* |
365 | * If it's a free entry, insert it. | 365 | * If it's a free entry, insert it. |
366 | */ | 366 | */ |
367 | if (INT_GET(dup->freetag, ARCH_CONVERT) == XFS_DIR2_DATA_FREE_TAG) { | 367 | if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) { |
368 | ASSERT((char *)dup - (char *)d == | 368 | ASSERT((char *)dup - (char *)d == |
369 | INT_GET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT)); | 369 | INT_GET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT)); |
370 | xfs_dir2_data_freeinsert(d, dup, loghead); | 370 | xfs_dir2_data_freeinsert(d, dup, loghead); |
371 | p += INT_GET(dup->length, ARCH_CONVERT); | 371 | p += be16_to_cpu(dup->length); |
372 | } | 372 | } |
373 | /* | 373 | /* |
374 | * For active entries, check their tags and skip them. | 374 | * For active entries, check their tags and skip them. |
@@ -428,11 +428,11 @@ xfs_dir2_data_init( | |||
428 | * Set up an unused entry for the block's body. | 428 | * Set up an unused entry for the block's body. |
429 | */ | 429 | */ |
430 | dup = &d->u[0].unused; | 430 | dup = &d->u[0].unused; |
431 | INT_SET(dup->freetag, ARCH_CONVERT, XFS_DIR2_DATA_FREE_TAG); | 431 | dup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); |
432 | 432 | ||
433 | t=mp->m_dirblksize - (uint)sizeof(d->hdr); | 433 | t=mp->m_dirblksize - (uint)sizeof(d->hdr); |
434 | d->hdr.bestfree[0].length = cpu_to_be16(t); | 434 | d->hdr.bestfree[0].length = cpu_to_be16(t); |
435 | INT_SET(dup->length, ARCH_CONVERT, t); | 435 | dup->length = cpu_to_be16(t); |
436 | INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT, | 436 | INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT, |
437 | (xfs_dir2_data_off_t)((char *)dup - (char *)d)); | 437 | (xfs_dir2_data_off_t)((char *)dup - (char *)d)); |
438 | /* | 438 | /* |
@@ -554,7 +554,7 @@ xfs_dir2_data_make_free( | |||
554 | 554 | ||
555 | tagp = (xfs_dir2_data_off_t *)((char *)d + offset) - 1; | 555 | tagp = (xfs_dir2_data_off_t *)((char *)d + offset) - 1; |
556 | prevdup = (xfs_dir2_data_unused_t *)((char *)d + INT_GET(*tagp, ARCH_CONVERT)); | 556 | prevdup = (xfs_dir2_data_unused_t *)((char *)d + INT_GET(*tagp, ARCH_CONVERT)); |
557 | if (INT_GET(prevdup->freetag, ARCH_CONVERT) != XFS_DIR2_DATA_FREE_TAG) | 557 | if (be16_to_cpu(prevdup->freetag) != XFS_DIR2_DATA_FREE_TAG) |
558 | prevdup = NULL; | 558 | prevdup = NULL; |
559 | } else | 559 | } else |
560 | prevdup = NULL; | 560 | prevdup = NULL; |
@@ -565,7 +565,7 @@ xfs_dir2_data_make_free( | |||
565 | if ((char *)d + offset + len < endptr) { | 565 | if ((char *)d + offset + len < endptr) { |
566 | postdup = | 566 | postdup = |
567 | (xfs_dir2_data_unused_t *)((char *)d + offset + len); | 567 | (xfs_dir2_data_unused_t *)((char *)d + offset + len); |
568 | if (INT_GET(postdup->freetag, ARCH_CONVERT) != XFS_DIR2_DATA_FREE_TAG) | 568 | if (be16_to_cpu(postdup->freetag) != XFS_DIR2_DATA_FREE_TAG) |
569 | postdup = NULL; | 569 | postdup = NULL; |
570 | } else | 570 | } else |
571 | postdup = NULL; | 571 | postdup = NULL; |
@@ -593,7 +593,7 @@ xfs_dir2_data_make_free( | |||
593 | /* | 593 | /* |
594 | * Fix up the new big freespace. | 594 | * Fix up the new big freespace. |
595 | */ | 595 | */ |
596 | INT_MOD(prevdup->length, ARCH_CONVERT, len + INT_GET(postdup->length, ARCH_CONVERT)); | 596 | be16_add(&prevdup->length, len + be16_to_cpu(postdup->length)); |
597 | INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(prevdup), ARCH_CONVERT, | 597 | INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(prevdup), ARCH_CONVERT, |
598 | (xfs_dir2_data_off_t)((char *)prevdup - (char *)d)); | 598 | (xfs_dir2_data_off_t)((char *)prevdup - (char *)d)); |
599 | xfs_dir2_data_log_unused(tp, bp, prevdup); | 599 | xfs_dir2_data_log_unused(tp, bp, prevdup); |
@@ -617,7 +617,7 @@ xfs_dir2_data_make_free( | |||
617 | */ | 617 | */ |
618 | dfp = xfs_dir2_data_freeinsert(d, prevdup, needlogp); | 618 | dfp = xfs_dir2_data_freeinsert(d, prevdup, needlogp); |
619 | ASSERT(dfp == &d->hdr.bestfree[0]); | 619 | ASSERT(dfp == &d->hdr.bestfree[0]); |
620 | ASSERT(be16_to_cpu(dfp->length) == INT_GET(prevdup->length, ARCH_CONVERT)); | 620 | ASSERT(dfp->length == prevdup->length); |
621 | ASSERT(!dfp[1].length); | 621 | ASSERT(!dfp[1].length); |
622 | ASSERT(!dfp[2].length); | 622 | ASSERT(!dfp[2].length); |
623 | } | 623 | } |
@@ -627,7 +627,7 @@ xfs_dir2_data_make_free( | |||
627 | */ | 627 | */ |
628 | else if (prevdup) { | 628 | else if (prevdup) { |
629 | dfp = xfs_dir2_data_freefind(d, prevdup); | 629 | dfp = xfs_dir2_data_freefind(d, prevdup); |
630 | INT_MOD(prevdup->length, ARCH_CONVERT, len); | 630 | be16_add(&prevdup->length, len); |
631 | INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(prevdup), ARCH_CONVERT, | 631 | INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(prevdup), ARCH_CONVERT, |
632 | (xfs_dir2_data_off_t)((char *)prevdup - (char *)d)); | 632 | (xfs_dir2_data_off_t)((char *)prevdup - (char *)d)); |
633 | xfs_dir2_data_log_unused(tp, bp, prevdup); | 633 | xfs_dir2_data_log_unused(tp, bp, prevdup); |
@@ -644,7 +644,7 @@ xfs_dir2_data_make_free( | |||
644 | * Otherwise we need a scan if the new entry is big enough. | 644 | * Otherwise we need a scan if the new entry is big enough. |
645 | */ | 645 | */ |
646 | else { | 646 | else { |
647 | needscan = INT_GET(prevdup->length, ARCH_CONVERT) > | 647 | needscan = be16_to_cpu(prevdup->length) > |
648 | be16_to_cpu(d->hdr.bestfree[2].length); | 648 | be16_to_cpu(d->hdr.bestfree[2].length); |
649 | } | 649 | } |
650 | } | 650 | } |
@@ -654,8 +654,8 @@ xfs_dir2_data_make_free( | |||
654 | else if (postdup) { | 654 | else if (postdup) { |
655 | dfp = xfs_dir2_data_freefind(d, postdup); | 655 | dfp = xfs_dir2_data_freefind(d, postdup); |
656 | newdup = (xfs_dir2_data_unused_t *)((char *)d + offset); | 656 | newdup = (xfs_dir2_data_unused_t *)((char *)d + offset); |
657 | INT_SET(newdup->freetag, ARCH_CONVERT, XFS_DIR2_DATA_FREE_TAG); | 657 | newdup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); |
658 | INT_SET(newdup->length, ARCH_CONVERT, len + INT_GET(postdup->length, ARCH_CONVERT)); | 658 | newdup->length = cpu_to_be16(len + be16_to_cpu(postdup->length)); |
659 | INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup), ARCH_CONVERT, | 659 | INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup), ARCH_CONVERT, |
660 | (xfs_dir2_data_off_t)((char *)newdup - (char *)d)); | 660 | (xfs_dir2_data_off_t)((char *)newdup - (char *)d)); |
661 | xfs_dir2_data_log_unused(tp, bp, newdup); | 661 | xfs_dir2_data_log_unused(tp, bp, newdup); |
@@ -672,7 +672,7 @@ xfs_dir2_data_make_free( | |||
672 | * Otherwise we need a scan if the new entry is big enough. | 672 | * Otherwise we need a scan if the new entry is big enough. |
673 | */ | 673 | */ |
674 | else { | 674 | else { |
675 | needscan = INT_GET(newdup->length, ARCH_CONVERT) > | 675 | needscan = be16_to_cpu(newdup->length) > |
676 | be16_to_cpu(d->hdr.bestfree[2].length); | 676 | be16_to_cpu(d->hdr.bestfree[2].length); |
677 | } | 677 | } |
678 | } | 678 | } |
@@ -681,8 +681,8 @@ xfs_dir2_data_make_free( | |||
681 | */ | 681 | */ |
682 | else { | 682 | else { |
683 | newdup = (xfs_dir2_data_unused_t *)((char *)d + offset); | 683 | newdup = (xfs_dir2_data_unused_t *)((char *)d + offset); |
684 | INT_SET(newdup->freetag, ARCH_CONVERT, XFS_DIR2_DATA_FREE_TAG); | 684 | newdup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); |
685 | INT_SET(newdup->length, ARCH_CONVERT, len); | 685 | newdup->length = cpu_to_be16(len); |
686 | INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup), ARCH_CONVERT, | 686 | INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup), ARCH_CONVERT, |
687 | (xfs_dir2_data_off_t)((char *)newdup - (char *)d)); | 687 | (xfs_dir2_data_off_t)((char *)newdup - (char *)d)); |
688 | xfs_dir2_data_log_unused(tp, bp, newdup); | 688 | xfs_dir2_data_log_unused(tp, bp, newdup); |
@@ -716,15 +716,15 @@ xfs_dir2_data_use_free( | |||
716 | d = bp->data; | 716 | d = bp->data; |
717 | ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC || | 717 | ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC || |
718 | be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); | 718 | be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC); |
719 | ASSERT(INT_GET(dup->freetag, ARCH_CONVERT) == XFS_DIR2_DATA_FREE_TAG); | 719 | ASSERT(be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG); |
720 | ASSERT(offset >= (char *)dup - (char *)d); | 720 | ASSERT(offset >= (char *)dup - (char *)d); |
721 | ASSERT(offset + len <= (char *)dup + INT_GET(dup->length, ARCH_CONVERT) - (char *)d); | 721 | ASSERT(offset + len <= (char *)dup + be16_to_cpu(dup->length) - (char *)d); |
722 | ASSERT((char *)dup - (char *)d == INT_GET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT)); | 722 | ASSERT((char *)dup - (char *)d == INT_GET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT)); |
723 | /* | 723 | /* |
724 | * Look up the entry in the bestfree table. | 724 | * Look up the entry in the bestfree table. |
725 | */ | 725 | */ |
726 | dfp = xfs_dir2_data_freefind(d, dup); | 726 | dfp = xfs_dir2_data_freefind(d, dup); |
727 | oldlen = INT_GET(dup->length, ARCH_CONVERT); | 727 | oldlen = be16_to_cpu(dup->length); |
728 | ASSERT(dfp || oldlen <= be16_to_cpu(d->hdr.bestfree[2].length)); | 728 | ASSERT(dfp || oldlen <= be16_to_cpu(d->hdr.bestfree[2].length)); |
729 | /* | 729 | /* |
730 | * Check for alignment with front and back of the entry. | 730 | * Check for alignment with front and back of the entry. |
@@ -750,8 +750,8 @@ xfs_dir2_data_use_free( | |||
750 | */ | 750 | */ |
751 | else if (matchfront) { | 751 | else if (matchfront) { |
752 | newdup = (xfs_dir2_data_unused_t *)((char *)d + offset + len); | 752 | newdup = (xfs_dir2_data_unused_t *)((char *)d + offset + len); |
753 | INT_SET(newdup->freetag, ARCH_CONVERT, XFS_DIR2_DATA_FREE_TAG); | 753 | newdup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); |
754 | INT_SET(newdup->length, ARCH_CONVERT, oldlen - len); | 754 | newdup->length = cpu_to_be16(oldlen - len); |
755 | INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup), ARCH_CONVERT, | 755 | INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup), ARCH_CONVERT, |
756 | (xfs_dir2_data_off_t)((char *)newdup - (char *)d)); | 756 | (xfs_dir2_data_off_t)((char *)newdup - (char *)d)); |
757 | xfs_dir2_data_log_unused(tp, bp, newdup); | 757 | xfs_dir2_data_log_unused(tp, bp, newdup); |
@@ -762,7 +762,7 @@ xfs_dir2_data_use_free( | |||
762 | xfs_dir2_data_freeremove(d, dfp, needlogp); | 762 | xfs_dir2_data_freeremove(d, dfp, needlogp); |
763 | dfp = xfs_dir2_data_freeinsert(d, newdup, needlogp); | 763 | dfp = xfs_dir2_data_freeinsert(d, newdup, needlogp); |
764 | ASSERT(dfp != NULL); | 764 | ASSERT(dfp != NULL); |
765 | ASSERT(be16_to_cpu(dfp->length) == INT_GET(newdup->length, ARCH_CONVERT)); | 765 | ASSERT(dfp->length == newdup->length); |
766 | ASSERT(be16_to_cpu(dfp->offset) == (char *)newdup - (char *)d); | 766 | ASSERT(be16_to_cpu(dfp->offset) == (char *)newdup - (char *)d); |
767 | /* | 767 | /* |
768 | * If we got inserted at the last slot, | 768 | * If we got inserted at the last slot, |
@@ -778,8 +778,7 @@ xfs_dir2_data_use_free( | |||
778 | */ | 778 | */ |
779 | else if (matchback) { | 779 | else if (matchback) { |
780 | newdup = dup; | 780 | newdup = dup; |
781 | INT_SET(newdup->length, ARCH_CONVERT, (xfs_dir2_data_off_t) | 781 | newdup->length = cpu_to_be16(((char *)d + offset) - (char *)newdup); |
782 | (((char *)d + offset) - (char *)newdup)); | ||
783 | INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup), ARCH_CONVERT, | 782 | INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup), ARCH_CONVERT, |
784 | (xfs_dir2_data_off_t)((char *)newdup - (char *)d)); | 783 | (xfs_dir2_data_off_t)((char *)newdup - (char *)d)); |
785 | xfs_dir2_data_log_unused(tp, bp, newdup); | 784 | xfs_dir2_data_log_unused(tp, bp, newdup); |
@@ -790,7 +789,7 @@ xfs_dir2_data_use_free( | |||
790 | xfs_dir2_data_freeremove(d, dfp, needlogp); | 789 | xfs_dir2_data_freeremove(d, dfp, needlogp); |
791 | dfp = xfs_dir2_data_freeinsert(d, newdup, needlogp); | 790 | dfp = xfs_dir2_data_freeinsert(d, newdup, needlogp); |
792 | ASSERT(dfp != NULL); | 791 | ASSERT(dfp != NULL); |
793 | ASSERT(be16_to_cpu(dfp->length) == INT_GET(newdup->length, ARCH_CONVERT)); | 792 | ASSERT(dfp->length == newdup->length); |
794 | ASSERT(be16_to_cpu(dfp->offset) == (char *)newdup - (char *)d); | 793 | ASSERT(be16_to_cpu(dfp->offset) == (char *)newdup - (char *)d); |
795 | /* | 794 | /* |
796 | * If we got inserted at the last slot, | 795 | * If we got inserted at the last slot, |
@@ -806,14 +805,13 @@ xfs_dir2_data_use_free( | |||
806 | */ | 805 | */ |
807 | else { | 806 | else { |
808 | newdup = dup; | 807 | newdup = dup; |
809 | INT_SET(newdup->length, ARCH_CONVERT, (xfs_dir2_data_off_t) | 808 | newdup->length = cpu_to_be16(((char *)d + offset) - (char *)newdup); |
810 | (((char *)d + offset) - (char *)newdup)); | ||
811 | INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup), ARCH_CONVERT, | 809 | INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup), ARCH_CONVERT, |
812 | (xfs_dir2_data_off_t)((char *)newdup - (char *)d)); | 810 | (xfs_dir2_data_off_t)((char *)newdup - (char *)d)); |
813 | xfs_dir2_data_log_unused(tp, bp, newdup); | 811 | xfs_dir2_data_log_unused(tp, bp, newdup); |
814 | newdup2 = (xfs_dir2_data_unused_t *)((char *)d + offset + len); | 812 | newdup2 = (xfs_dir2_data_unused_t *)((char *)d + offset + len); |
815 | INT_SET(newdup2->freetag, ARCH_CONVERT, XFS_DIR2_DATA_FREE_TAG); | 813 | newdup2->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); |
816 | INT_SET(newdup2->length, ARCH_CONVERT, oldlen - len - INT_GET(newdup->length, ARCH_CONVERT)); | 814 | newdup2->length = cpu_to_be16(oldlen - len - be16_to_cpu(newdup->length)); |
817 | INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup2), ARCH_CONVERT, | 815 | INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup2), ARCH_CONVERT, |
818 | (xfs_dir2_data_off_t)((char *)newdup2 - (char *)d)); | 816 | (xfs_dir2_data_off_t)((char *)newdup2 - (char *)d)); |
819 | xfs_dir2_data_log_unused(tp, bp, newdup2); | 817 | xfs_dir2_data_log_unused(tp, bp, newdup2); |
diff --git a/fs/xfs/xfs_dir2_data.h b/fs/xfs/xfs_dir2_data.h index dd8b86523635..28adddb48e88 100644 --- a/fs/xfs/xfs_dir2_data.h +++ b/fs/xfs/xfs_dir2_data.h | |||
@@ -97,10 +97,10 @@ typedef struct xfs_dir2_data_entry { | |||
97 | * Tag appears as the last 2 bytes. | 97 | * Tag appears as the last 2 bytes. |
98 | */ | 98 | */ |
99 | typedef struct xfs_dir2_data_unused { | 99 | typedef struct xfs_dir2_data_unused { |
100 | __uint16_t freetag; /* XFS_DIR2_DATA_FREE_TAG */ | 100 | __be16 freetag; /* XFS_DIR2_DATA_FREE_TAG */ |
101 | xfs_dir2_data_off_t length; /* total free length */ | 101 | __be16 length; /* total free length */ |
102 | /* variable offset */ | 102 | /* variable offset */ |
103 | xfs_dir2_data_off_t tag; /* starting offset of us */ | 103 | __be16 tag; /* starting offset of us */ |
104 | } xfs_dir2_data_unused_t; | 104 | } xfs_dir2_data_unused_t; |
105 | 105 | ||
106 | typedef union { | 106 | typedef union { |
@@ -151,7 +151,7 @@ static inline xfs_dir2_data_off_t * | |||
151 | xfs_dir2_data_unused_tag_p(xfs_dir2_data_unused_t *dup) | 151 | xfs_dir2_data_unused_tag_p(xfs_dir2_data_unused_t *dup) |
152 | { | 152 | { |
153 | return (xfs_dir2_data_off_t *) \ | 153 | return (xfs_dir2_data_off_t *) \ |
154 | ((char *)(dup) + INT_GET((dup)->length, ARCH_CONVERT) \ | 154 | ((char *)(dup) + be16_to_cpu((dup)->length) \ |
155 | - (uint)sizeof(xfs_dir2_data_off_t)); | 155 | - (uint)sizeof(xfs_dir2_data_off_t)); |
156 | } | 156 | } |
157 | 157 | ||
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c index 9abecd207c4e..cbd371d9e98d 100644 --- a/fs/xfs/xfs_dir2_leaf.c +++ b/fs/xfs/xfs_dir2_leaf.c | |||
@@ -395,7 +395,7 @@ xfs_dir2_leaf_addname( | |||
395 | */ | 395 | */ |
396 | dup = (xfs_dir2_data_unused_t *) | 396 | dup = (xfs_dir2_data_unused_t *) |
397 | ((char *)data + be16_to_cpu(data->hdr.bestfree[0].offset)); | 397 | ((char *)data + be16_to_cpu(data->hdr.bestfree[0].offset)); |
398 | ASSERT(INT_GET(dup->length, ARCH_CONVERT) >= length); | 398 | ASSERT(be16_to_cpu(dup->length) >= length); |
399 | needscan = needlog = 0; | 399 | needscan = needlog = 0; |
400 | /* | 400 | /* |
401 | * Mark the initial part of our freespace in use for the new entry. | 401 | * Mark the initial part of our freespace in use for the new entry. |
@@ -1047,11 +1047,10 @@ xfs_dir2_leaf_getdents( | |||
1047 | while ((char *)ptr - (char *)data < byteoff) { | 1047 | while ((char *)ptr - (char *)data < byteoff) { |
1048 | dup = (xfs_dir2_data_unused_t *)ptr; | 1048 | dup = (xfs_dir2_data_unused_t *)ptr; |
1049 | 1049 | ||
1050 | if (INT_GET(dup->freetag, ARCH_CONVERT) | 1050 | if (be16_to_cpu(dup->freetag) |
1051 | == XFS_DIR2_DATA_FREE_TAG) { | 1051 | == XFS_DIR2_DATA_FREE_TAG) { |
1052 | 1052 | ||
1053 | length = INT_GET(dup->length, | 1053 | length = be16_to_cpu(dup->length); |
1054 | ARCH_CONVERT); | ||
1055 | ptr += length; | 1054 | ptr += length; |
1056 | continue; | 1055 | continue; |
1057 | } | 1056 | } |
@@ -1080,9 +1079,8 @@ xfs_dir2_leaf_getdents( | |||
1080 | /* | 1079 | /* |
1081 | * No, it's unused, skip over it. | 1080 | * No, it's unused, skip over it. |
1082 | */ | 1081 | */ |
1083 | if (INT_GET(dup->freetag, ARCH_CONVERT) | 1082 | if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) { |
1084 | == XFS_DIR2_DATA_FREE_TAG) { | 1083 | length = be16_to_cpu(dup->length); |
1085 | length = INT_GET(dup->length, ARCH_CONVERT); | ||
1086 | ptr += length; | 1084 | ptr += length; |
1087 | curoff += length; | 1085 | curoff += length; |
1088 | continue; | 1086 | continue; |
diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c index ec8e7476c8b7..3a571d8cf1f3 100644 --- a/fs/xfs/xfs_dir2_sf.c +++ b/fs/xfs/xfs_dir2_sf.c | |||
@@ -220,8 +220,8 @@ xfs_dir2_block_to_sf( | |||
220 | * If it's unused, just skip over it. | 220 | * If it's unused, just skip over it. |
221 | */ | 221 | */ |
222 | dup = (xfs_dir2_data_unused_t *)ptr; | 222 | dup = (xfs_dir2_data_unused_t *)ptr; |
223 | if (INT_GET(dup->freetag, ARCH_CONVERT) == XFS_DIR2_DATA_FREE_TAG) { | 223 | if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) { |
224 | ptr += INT_GET(dup->length, ARCH_CONVERT); | 224 | ptr += be16_to_cpu(dup->length); |
225 | continue; | 225 | continue; |
226 | } | 226 | } |
227 | dep = (xfs_dir2_data_entry_t *)ptr; | 227 | dep = (xfs_dir2_data_entry_t *)ptr; |