diff options
Diffstat (limited to 'fs/xfs/xfs_dir2_block.c')
-rw-r--r-- | fs/xfs/xfs_dir2_block.c | 52 |
1 files changed, 28 insertions, 24 deletions
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c index 1dd1a7694e4b..fa372b2b433d 100644 --- a/fs/xfs/xfs_dir2_block.c +++ b/fs/xfs/xfs_dir2_block.c | |||
@@ -246,7 +246,7 @@ xfs_dir2_block_addname( | |||
246 | highstale = lfloghigh = -1; | 246 | highstale = lfloghigh = -1; |
247 | fromidx >= 0; | 247 | fromidx >= 0; |
248 | fromidx--) { | 248 | fromidx--) { |
249 | if (INT_GET(blp[fromidx].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) { | 249 | if (be32_to_cpu(blp[fromidx].address) == XFS_DIR2_NULL_DATAPTR) { |
250 | if (highstale == -1) | 250 | if (highstale == -1) |
251 | highstale = toidx; | 251 | highstale = toidx; |
252 | else { | 252 | else { |
@@ -291,14 +291,14 @@ xfs_dir2_block_addname( | |||
291 | */ | 291 | */ |
292 | for (low = 0, high = be32_to_cpu(btp->count) - 1; low <= high; ) { | 292 | for (low = 0, high = be32_to_cpu(btp->count) - 1; low <= high; ) { |
293 | mid = (low + high) >> 1; | 293 | mid = (low + high) >> 1; |
294 | if ((hash = INT_GET(blp[mid].hashval, ARCH_CONVERT)) == args->hashval) | 294 | if ((hash = be32_to_cpu(blp[mid].hashval)) == args->hashval) |
295 | break; | 295 | break; |
296 | if (hash < args->hashval) | 296 | if (hash < args->hashval) |
297 | low = mid + 1; | 297 | low = mid + 1; |
298 | else | 298 | else |
299 | high = mid - 1; | 299 | high = mid - 1; |
300 | } | 300 | } |
301 | while (mid >= 0 && INT_GET(blp[mid].hashval, ARCH_CONVERT) >= args->hashval) { | 301 | while (mid >= 0 && be32_to_cpu(blp[mid].hashval) >= args->hashval) { |
302 | mid--; | 302 | mid--; |
303 | } | 303 | } |
304 | /* | 304 | /* |
@@ -345,12 +345,12 @@ xfs_dir2_block_addname( | |||
345 | else { | 345 | else { |
346 | for (lowstale = mid; | 346 | for (lowstale = mid; |
347 | lowstale >= 0 && | 347 | lowstale >= 0 && |
348 | INT_GET(blp[lowstale].address, ARCH_CONVERT) != XFS_DIR2_NULL_DATAPTR; | 348 | be32_to_cpu(blp[lowstale].address) != XFS_DIR2_NULL_DATAPTR; |
349 | lowstale--) | 349 | lowstale--) |
350 | continue; | 350 | continue; |
351 | for (highstale = mid + 1; | 351 | for (highstale = mid + 1; |
352 | highstale < be32_to_cpu(btp->count) && | 352 | highstale < be32_to_cpu(btp->count) && |
353 | INT_GET(blp[highstale].address, ARCH_CONVERT) != XFS_DIR2_NULL_DATAPTR && | 353 | be32_to_cpu(blp[highstale].address) != XFS_DIR2_NULL_DATAPTR && |
354 | (lowstale < 0 || mid - lowstale > highstale - mid); | 354 | (lowstale < 0 || mid - lowstale > highstale - mid); |
355 | highstale++) | 355 | highstale++) |
356 | continue; | 356 | continue; |
@@ -387,8 +387,9 @@ xfs_dir2_block_addname( | |||
387 | /* | 387 | /* |
388 | * Fill in the leaf entry. | 388 | * Fill in the leaf entry. |
389 | */ | 389 | */ |
390 | INT_SET(blp[mid].hashval, ARCH_CONVERT, args->hashval); | 390 | blp[mid].hashval = cpu_to_be32(args->hashval); |
391 | INT_SET(blp[mid].address, ARCH_CONVERT, XFS_DIR2_BYTE_TO_DATAPTR(mp, (char *)dep - (char *)block)); | 391 | blp[mid].address = cpu_to_be32(XFS_DIR2_BYTE_TO_DATAPTR(mp, |
392 | (char *)dep - (char *)block)); | ||
392 | xfs_dir2_block_log_leaf(tp, bp, lfloglow, lfloghigh); | 393 | xfs_dir2_block_log_leaf(tp, bp, lfloglow, lfloghigh); |
393 | /* | 394 | /* |
394 | * Mark space for the data entry used. | 395 | * Mark space for the data entry used. |
@@ -621,7 +622,7 @@ xfs_dir2_block_lookup( | |||
621 | * Get the offset from the leaf entry, to point to the data. | 622 | * Get the offset from the leaf entry, to point to the data. |
622 | */ | 623 | */ |
623 | dep = (xfs_dir2_data_entry_t *) | 624 | dep = (xfs_dir2_data_entry_t *) |
624 | ((char *)block + XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(blp[ent].address, ARCH_CONVERT))); | 625 | ((char *)block + XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(blp[ent].address))); |
625 | /* | 626 | /* |
626 | * Fill in inode number, release the block. | 627 | * Fill in inode number, release the block. |
627 | */ | 628 | */ |
@@ -676,7 +677,7 @@ xfs_dir2_block_lookup_int( | |||
676 | for (low = 0, high = be32_to_cpu(btp->count) - 1; ; ) { | 677 | for (low = 0, high = be32_to_cpu(btp->count) - 1; ; ) { |
677 | ASSERT(low <= high); | 678 | ASSERT(low <= high); |
678 | mid = (low + high) >> 1; | 679 | mid = (low + high) >> 1; |
679 | if ((hash = INT_GET(blp[mid].hashval, ARCH_CONVERT)) == args->hashval) | 680 | if ((hash = be32_to_cpu(blp[mid].hashval)) == args->hashval) |
680 | break; | 681 | break; |
681 | if (hash < args->hashval) | 682 | if (hash < args->hashval) |
682 | low = mid + 1; | 683 | low = mid + 1; |
@@ -691,7 +692,7 @@ xfs_dir2_block_lookup_int( | |||
691 | /* | 692 | /* |
692 | * Back up to the first one with the right hash value. | 693 | * Back up to the first one with the right hash value. |
693 | */ | 694 | */ |
694 | while (mid > 0 && INT_GET(blp[mid - 1].hashval, ARCH_CONVERT) == args->hashval) { | 695 | while (mid > 0 && be32_to_cpu(blp[mid - 1].hashval) == args->hashval) { |
695 | mid--; | 696 | mid--; |
696 | } | 697 | } |
697 | /* | 698 | /* |
@@ -699,7 +700,7 @@ xfs_dir2_block_lookup_int( | |||
699 | * right hash value looking for our name. | 700 | * right hash value looking for our name. |
700 | */ | 701 | */ |
701 | do { | 702 | do { |
702 | if ((addr = INT_GET(blp[mid].address, ARCH_CONVERT)) == XFS_DIR2_NULL_DATAPTR) | 703 | if ((addr = be32_to_cpu(blp[mid].address)) == XFS_DIR2_NULL_DATAPTR) |
703 | continue; | 704 | continue; |
704 | /* | 705 | /* |
705 | * Get pointer to the entry from the leaf. | 706 | * Get pointer to the entry from the leaf. |
@@ -716,7 +717,7 @@ xfs_dir2_block_lookup_int( | |||
716 | *entno = mid; | 717 | *entno = mid; |
717 | return 0; | 718 | return 0; |
718 | } | 719 | } |
719 | } while (++mid < be32_to_cpu(btp->count) && INT_GET(blp[mid].hashval, ARCH_CONVERT) == hash); | 720 | } while (++mid < be32_to_cpu(btp->count) && be32_to_cpu(blp[mid].hashval) == hash); |
720 | /* | 721 | /* |
721 | * No match, release the buffer and return ENOENT. | 722 | * No match, release the buffer and return ENOENT. |
722 | */ | 723 | */ |
@@ -766,7 +767,7 @@ xfs_dir2_block_removename( | |||
766 | * Point to the data entry using the leaf entry. | 767 | * Point to the data entry using the leaf entry. |
767 | */ | 768 | */ |
768 | dep = (xfs_dir2_data_entry_t *) | 769 | dep = (xfs_dir2_data_entry_t *) |
769 | ((char *)block + XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(blp[ent].address, ARCH_CONVERT))); | 770 | ((char *)block + XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(blp[ent].address))); |
770 | /* | 771 | /* |
771 | * Mark the data entry's space free. | 772 | * Mark the data entry's space free. |
772 | */ | 773 | */ |
@@ -782,7 +783,7 @@ xfs_dir2_block_removename( | |||
782 | /* | 783 | /* |
783 | * Remove the leaf entry by marking it stale. | 784 | * Remove the leaf entry by marking it stale. |
784 | */ | 785 | */ |
785 | INT_SET(blp[ent].address, ARCH_CONVERT, XFS_DIR2_NULL_DATAPTR); | 786 | blp[ent].address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR); |
786 | xfs_dir2_block_log_leaf(tp, bp, ent, ent); | 787 | xfs_dir2_block_log_leaf(tp, bp, ent, ent); |
787 | /* | 788 | /* |
788 | * Fix up bestfree, log the header if necessary. | 789 | * Fix up bestfree, log the header if necessary. |
@@ -842,7 +843,7 @@ xfs_dir2_block_replace( | |||
842 | * Point to the data entry we need to change. | 843 | * Point to the data entry we need to change. |
843 | */ | 844 | */ |
844 | dep = (xfs_dir2_data_entry_t *) | 845 | dep = (xfs_dir2_data_entry_t *) |
845 | ((char *)block + XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(blp[ent].address, ARCH_CONVERT))); | 846 | ((char *)block + XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(blp[ent].address))); |
846 | ASSERT(INT_GET(dep->inumber, ARCH_CONVERT) != args->inumber); | 847 | ASSERT(INT_GET(dep->inumber, ARCH_CONVERT) != args->inumber); |
847 | /* | 848 | /* |
848 | * Change the inode number to the new value. | 849 | * Change the inode number to the new value. |
@@ -867,8 +868,8 @@ xfs_dir2_block_sort( | |||
867 | 868 | ||
868 | la = a; | 869 | la = a; |
869 | lb = b; | 870 | lb = b; |
870 | return INT_GET(la->hashval, ARCH_CONVERT) < INT_GET(lb->hashval, ARCH_CONVERT) ? -1 : | 871 | return be32_to_cpu(la->hashval) < be32_to_cpu(lb->hashval) ? -1 : |
871 | (INT_GET(la->hashval, ARCH_CONVERT) > INT_GET(lb->hashval, ARCH_CONVERT) ? 1 : 0); | 872 | (be32_to_cpu(la->hashval) > be32_to_cpu(lb->hashval) ? 1 : 0); |
872 | } | 873 | } |
873 | 874 | ||
874 | /* | 875 | /* |
@@ -976,7 +977,7 @@ xfs_dir2_leaf_to_block( | |||
976 | */ | 977 | */ |
977 | lep = XFS_DIR2_BLOCK_LEAF_P(btp); | 978 | lep = XFS_DIR2_BLOCK_LEAF_P(btp); |
978 | for (from = to = 0; from < be16_to_cpu(leaf->hdr.count); from++) { | 979 | for (from = to = 0; from < be16_to_cpu(leaf->hdr.count); from++) { |
979 | if (INT_GET(leaf->ents[from].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) | 980 | if (be32_to_cpu(leaf->ents[from].address) == XFS_DIR2_NULL_DATAPTR) |
980 | continue; | 981 | continue; |
981 | lep[to++] = leaf->ents[from]; | 982 | lep[to++] = leaf->ents[from]; |
982 | } | 983 | } |
@@ -1135,8 +1136,9 @@ xfs_dir2_sf_to_block( | |||
1135 | tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep); | 1136 | tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep); |
1136 | INT_SET(*tagp, ARCH_CONVERT, (xfs_dir2_data_off_t)((char *)dep - (char *)block)); | 1137 | INT_SET(*tagp, ARCH_CONVERT, (xfs_dir2_data_off_t)((char *)dep - (char *)block)); |
1137 | xfs_dir2_data_log_entry(tp, bp, dep); | 1138 | xfs_dir2_data_log_entry(tp, bp, dep); |
1138 | INT_SET(blp[0].hashval, ARCH_CONVERT, xfs_dir_hash_dot); | 1139 | blp[0].hashval = cpu_to_be32(xfs_dir_hash_dot); |
1139 | INT_SET(blp[0].address, ARCH_CONVERT, XFS_DIR2_BYTE_TO_DATAPTR(mp, (char *)dep - (char *)block)); | 1140 | blp[0].address = cpu_to_be32(XFS_DIR2_BYTE_TO_DATAPTR(mp, |
1141 | (char *)dep - (char *)block)); | ||
1140 | /* | 1142 | /* |
1141 | * Create entry for .. | 1143 | * Create entry for .. |
1142 | */ | 1144 | */ |
@@ -1148,8 +1150,9 @@ xfs_dir2_sf_to_block( | |||
1148 | tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep); | 1150 | tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep); |
1149 | INT_SET(*tagp, ARCH_CONVERT, (xfs_dir2_data_off_t)((char *)dep - (char *)block)); | 1151 | INT_SET(*tagp, ARCH_CONVERT, (xfs_dir2_data_off_t)((char *)dep - (char *)block)); |
1150 | xfs_dir2_data_log_entry(tp, bp, dep); | 1152 | xfs_dir2_data_log_entry(tp, bp, dep); |
1151 | INT_SET(blp[1].hashval, ARCH_CONVERT, xfs_dir_hash_dotdot); | 1153 | blp[1].hashval = cpu_to_be32(xfs_dir_hash_dotdot); |
1152 | INT_SET(blp[1].address, ARCH_CONVERT, XFS_DIR2_BYTE_TO_DATAPTR(mp, (char *)dep - (char *)block)); | 1154 | blp[1].address = cpu_to_be32(XFS_DIR2_BYTE_TO_DATAPTR(mp, |
1155 | (char *)dep - (char *)block)); | ||
1153 | offset = XFS_DIR2_DATA_FIRST_OFFSET; | 1156 | offset = XFS_DIR2_DATA_FIRST_OFFSET; |
1154 | /* | 1157 | /* |
1155 | * Loop over existing entries, stuff them in. | 1158 | * Loop over existing entries, stuff them in. |
@@ -1197,8 +1200,9 @@ xfs_dir2_sf_to_block( | |||
1197 | tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep); | 1200 | tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep); |
1198 | INT_SET(*tagp, ARCH_CONVERT, (xfs_dir2_data_off_t)((char *)dep - (char *)block)); | 1201 | INT_SET(*tagp, ARCH_CONVERT, (xfs_dir2_data_off_t)((char *)dep - (char *)block)); |
1199 | xfs_dir2_data_log_entry(tp, bp, dep); | 1202 | xfs_dir2_data_log_entry(tp, bp, dep); |
1200 | INT_SET(blp[2 + i].hashval, ARCH_CONVERT, xfs_da_hashname((char *)sfep->name, sfep->namelen)); | 1203 | blp[2 + i].hashval = cpu_to_be32(xfs_da_hashname( |
1201 | INT_SET(blp[2 + i].address, ARCH_CONVERT, XFS_DIR2_BYTE_TO_DATAPTR(mp, | 1204 | (char *)sfep->name, sfep->namelen)); |
1205 | blp[2 + i].address = cpu_to_be32(XFS_DIR2_BYTE_TO_DATAPTR(mp, | ||
1202 | (char *)dep - (char *)block)); | 1206 | (char *)dep - (char *)block)); |
1203 | offset = (int)((char *)(tagp + 1) - (char *)block); | 1207 | offset = (int)((char *)(tagp + 1) - (char *)block); |
1204 | if (++i == INT_GET(sfp->hdr.count, ARCH_CONVERT)) | 1208 | if (++i == INT_GET(sfp->hdr.count, ARCH_CONVERT)) |