aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_dir2_data.c
diff options
context:
space:
mode:
authorNathan Scott <nathans@sgi.com>2006-03-17 01:27:37 -0500
committerNathan Scott <nathans@sgi.com>2006-03-17 01:27:37 -0500
commitad354eb34eb354eedc483d1e89e17710165bd2db (patch)
treeaa7977517a3f516c81cf162bd62d7f84749a3138 /fs/xfs/xfs_dir2_data.c
parentafbcb3f91903bcd34d470efe64b3738257178667 (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/xfs_dir2_data.c')
-rw-r--r--fs/xfs/xfs_dir2_data.c68
1 files changed, 33 insertions, 35 deletions
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);