diff options
Diffstat (limited to 'fs/xfs/xfs_dir2_node.c')
-rw-r--r-- | fs/xfs/xfs_dir2_node.c | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c index 40e4a2e27765..062e4a99209c 100644 --- a/fs/xfs/xfs_dir2_node.c +++ b/fs/xfs/xfs_dir2_node.c | |||
@@ -223,9 +223,9 @@ xfs_dir2_leafn_add( | |||
223 | compact = be16_to_cpu(leaf->hdr.stale) > 1; | 223 | compact = be16_to_cpu(leaf->hdr.stale) > 1; |
224 | } else | 224 | } else |
225 | compact = 0; | 225 | compact = 0; |
226 | ASSERT(index == 0 || INT_GET(leaf->ents[index - 1].hashval, ARCH_CONVERT) <= args->hashval); | 226 | ASSERT(index == 0 || be32_to_cpu(leaf->ents[index - 1].hashval) <= args->hashval); |
227 | ASSERT(index == be16_to_cpu(leaf->hdr.count) || | 227 | ASSERT(index == be16_to_cpu(leaf->hdr.count) || |
228 | INT_GET(leaf->ents[index].hashval, ARCH_CONVERT) >= args->hashval); | 228 | be32_to_cpu(leaf->ents[index].hashval) >= args->hashval); |
229 | 229 | ||
230 | if (args->justcheck) | 230 | if (args->justcheck) |
231 | return 0; | 231 | return 0; |
@@ -271,7 +271,7 @@ xfs_dir2_leafn_add( | |||
271 | */ | 271 | */ |
272 | for (lowstale = index - 1; | 272 | for (lowstale = index - 1; |
273 | lowstale >= 0 && | 273 | lowstale >= 0 && |
274 | INT_GET(leaf->ents[lowstale].address, ARCH_CONVERT) != | 274 | be32_to_cpu(leaf->ents[lowstale].address) != |
275 | XFS_DIR2_NULL_DATAPTR; | 275 | XFS_DIR2_NULL_DATAPTR; |
276 | lowstale--) | 276 | lowstale--) |
277 | continue; | 277 | continue; |
@@ -282,7 +282,7 @@ xfs_dir2_leafn_add( | |||
282 | */ | 282 | */ |
283 | for (highstale = index; | 283 | for (highstale = index; |
284 | highstale < be16_to_cpu(leaf->hdr.count) && | 284 | highstale < be16_to_cpu(leaf->hdr.count) && |
285 | INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) != | 285 | be32_to_cpu(leaf->ents[highstale].address) != |
286 | XFS_DIR2_NULL_DATAPTR && | 286 | XFS_DIR2_NULL_DATAPTR && |
287 | (lowstale < 0 || | 287 | (lowstale < 0 || |
288 | index - lowstale - 1 >= highstale - index); | 288 | index - lowstale - 1 >= highstale - index); |
@@ -296,7 +296,7 @@ xfs_dir2_leafn_add( | |||
296 | if (lowstale >= 0 && | 296 | if (lowstale >= 0 && |
297 | (highstale == be16_to_cpu(leaf->hdr.count) || | 297 | (highstale == be16_to_cpu(leaf->hdr.count) || |
298 | index - lowstale - 1 < highstale - index)) { | 298 | index - lowstale - 1 < highstale - index)) { |
299 | ASSERT(INT_GET(leaf->ents[lowstale].address, ARCH_CONVERT) == | 299 | ASSERT(be32_to_cpu(leaf->ents[lowstale].address) == |
300 | XFS_DIR2_NULL_DATAPTR); | 300 | XFS_DIR2_NULL_DATAPTR); |
301 | ASSERT(index - lowstale - 1 >= 0); | 301 | ASSERT(index - lowstale - 1 >= 0); |
302 | if (index - lowstale - 1 > 0) | 302 | if (index - lowstale - 1 > 0) |
@@ -312,7 +312,7 @@ xfs_dir2_leafn_add( | |||
312 | * Shift entries down toward the stale slot. | 312 | * Shift entries down toward the stale slot. |
313 | */ | 313 | */ |
314 | else { | 314 | else { |
315 | ASSERT(INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) == | 315 | ASSERT(be32_to_cpu(leaf->ents[highstale].address) == |
316 | XFS_DIR2_NULL_DATAPTR); | 316 | XFS_DIR2_NULL_DATAPTR); |
317 | ASSERT(highstale - index >= 0); | 317 | ASSERT(highstale - index >= 0); |
318 | if (highstale - index > 0) | 318 | if (highstale - index > 0) |
@@ -328,8 +328,9 @@ xfs_dir2_leafn_add( | |||
328 | /* | 328 | /* |
329 | * Insert the new entry, log everything. | 329 | * Insert the new entry, log everything. |
330 | */ | 330 | */ |
331 | INT_SET(lep->hashval, ARCH_CONVERT, args->hashval); | 331 | lep->hashval = cpu_to_be32(args->hashval); |
332 | INT_SET(lep->address, ARCH_CONVERT, XFS_DIR2_DB_OFF_TO_DATAPTR(mp, args->blkno, args->index)); | 332 | lep->address = cpu_to_be32(XFS_DIR2_DB_OFF_TO_DATAPTR(mp, |
333 | args->blkno, args->index)); | ||
333 | xfs_dir2_leaf_log_header(tp, bp); | 334 | xfs_dir2_leaf_log_header(tp, bp); |
334 | xfs_dir2_leaf_log_ents(tp, bp, lfloglow, lfloghigh); | 335 | xfs_dir2_leaf_log_ents(tp, bp, lfloglow, lfloghigh); |
335 | xfs_dir2_leafn_check(dp, bp); | 336 | xfs_dir2_leafn_check(dp, bp); |
@@ -356,10 +357,10 @@ xfs_dir2_leafn_check( | |||
356 | ASSERT(be16_to_cpu(leaf->hdr.count) <= XFS_DIR2_MAX_LEAF_ENTS(mp)); | 357 | ASSERT(be16_to_cpu(leaf->hdr.count) <= XFS_DIR2_MAX_LEAF_ENTS(mp)); |
357 | for (i = stale = 0; i < be16_to_cpu(leaf->hdr.count); i++) { | 358 | for (i = stale = 0; i < be16_to_cpu(leaf->hdr.count); i++) { |
358 | if (i + 1 < be16_to_cpu(leaf->hdr.count)) { | 359 | if (i + 1 < be16_to_cpu(leaf->hdr.count)) { |
359 | ASSERT(INT_GET(leaf->ents[i].hashval, ARCH_CONVERT) <= | 360 | ASSERT(be32_to_cpu(leaf->ents[i].hashval) <= |
360 | INT_GET(leaf->ents[i + 1].hashval, ARCH_CONVERT)); | 361 | be32_to_cpu(leaf->ents[i + 1].hashval)); |
361 | } | 362 | } |
362 | if (INT_GET(leaf->ents[i].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) | 363 | if (be32_to_cpu(leaf->ents[i].address) == XFS_DIR2_NULL_DATAPTR) |
363 | stale++; | 364 | stale++; |
364 | } | 365 | } |
365 | ASSERT(be16_to_cpu(leaf->hdr.stale) == stale); | 366 | ASSERT(be16_to_cpu(leaf->hdr.stale) == stale); |
@@ -383,7 +384,7 @@ xfs_dir2_leafn_lasthash( | |||
383 | *count = be16_to_cpu(leaf->hdr.count); | 384 | *count = be16_to_cpu(leaf->hdr.count); |
384 | if (!leaf->hdr.count) | 385 | if (!leaf->hdr.count) |
385 | return 0; | 386 | return 0; |
386 | return INT_GET(leaf->ents[be16_to_cpu(leaf->hdr.count) - 1].hashval, ARCH_CONVERT); | 387 | return be32_to_cpu(leaf->ents[be16_to_cpu(leaf->hdr.count) - 1].hashval); |
387 | } | 388 | } |
388 | 389 | ||
389 | /* | 390 | /* |
@@ -456,17 +457,17 @@ xfs_dir2_leafn_lookup_int( | |||
456 | * Loop over leaf entries with the right hash value. | 457 | * Loop over leaf entries with the right hash value. |
457 | */ | 458 | */ |
458 | for (lep = &leaf->ents[index]; | 459 | for (lep = &leaf->ents[index]; |
459 | index < be16_to_cpu(leaf->hdr.count) && INT_GET(lep->hashval, ARCH_CONVERT) == args->hashval; | 460 | index < be16_to_cpu(leaf->hdr.count) && be32_to_cpu(lep->hashval) == args->hashval; |
460 | lep++, index++) { | 461 | lep++, index++) { |
461 | /* | 462 | /* |
462 | * Skip stale leaf entries. | 463 | * Skip stale leaf entries. |
463 | */ | 464 | */ |
464 | if (INT_GET(lep->address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) | 465 | if (be32_to_cpu(lep->address) == XFS_DIR2_NULL_DATAPTR) |
465 | continue; | 466 | continue; |
466 | /* | 467 | /* |
467 | * Pull the data block number from the entry. | 468 | * Pull the data block number from the entry. |
468 | */ | 469 | */ |
469 | newdb = XFS_DIR2_DATAPTR_TO_DB(mp, INT_GET(lep->address, ARCH_CONVERT)); | 470 | newdb = XFS_DIR2_DATAPTR_TO_DB(mp, be32_to_cpu(lep->address)); |
470 | /* | 471 | /* |
471 | * For addname, we're looking for a place to put the new entry. | 472 | * For addname, we're looking for a place to put the new entry. |
472 | * We want to use a data block with an entry of equal | 473 | * We want to use a data block with an entry of equal |
@@ -572,7 +573,7 @@ xfs_dir2_leafn_lookup_int( | |||
572 | */ | 573 | */ |
573 | dep = (xfs_dir2_data_entry_t *) | 574 | dep = (xfs_dir2_data_entry_t *) |
574 | ((char *)curbp->data + | 575 | ((char *)curbp->data + |
575 | XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(lep->address, ARCH_CONVERT))); | 576 | XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(lep->address))); |
576 | /* | 577 | /* |
577 | * Compare the entry, return it if it matches. | 578 | * Compare the entry, return it if it matches. |
578 | */ | 579 | */ |
@@ -672,7 +673,7 @@ xfs_dir2_leafn_moveents( | |||
672 | int i; /* temp leaf index */ | 673 | int i; /* temp leaf index */ |
673 | 674 | ||
674 | for (i = start_s, stale = 0; i < start_s + count; i++) { | 675 | for (i = start_s, stale = 0; i < start_s + count; i++) { |
675 | if (INT_GET(leaf_s->ents[i].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) | 676 | if (be32_to_cpu(leaf_s->ents[i].address) == XFS_DIR2_NULL_DATAPTR) |
676 | stale++; | 677 | stale++; |
677 | } | 678 | } |
678 | } else | 679 | } else |
@@ -723,9 +724,9 @@ xfs_dir2_leafn_order( | |||
723 | ASSERT(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 724 | ASSERT(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); |
724 | if (be16_to_cpu(leaf1->hdr.count) > 0 && | 725 | if (be16_to_cpu(leaf1->hdr.count) > 0 && |
725 | be16_to_cpu(leaf2->hdr.count) > 0 && | 726 | be16_to_cpu(leaf2->hdr.count) > 0 && |
726 | (INT_GET(leaf2->ents[0].hashval, ARCH_CONVERT) < INT_GET(leaf1->ents[0].hashval, ARCH_CONVERT) || | 727 | (be32_to_cpu(leaf2->ents[0].hashval) < be32_to_cpu(leaf1->ents[0].hashval) || |
727 | INT_GET(leaf2->ents[be16_to_cpu(leaf2->hdr.count) - 1].hashval, ARCH_CONVERT) < | 728 | be32_to_cpu(leaf2->ents[be16_to_cpu(leaf2->hdr.count) - 1].hashval) < |
728 | INT_GET(leaf1->ents[be16_to_cpu(leaf1->hdr.count) - 1].hashval, ARCH_CONVERT))) | 729 | be32_to_cpu(leaf1->ents[be16_to_cpu(leaf1->hdr.count) - 1].hashval))) |
729 | return 1; | 730 | return 1; |
730 | return 0; | 731 | return 0; |
731 | } | 732 | } |
@@ -781,9 +782,9 @@ xfs_dir2_leafn_rebalance( | |||
781 | xfs_dahash_t midhash; /* middle entry hash value */ | 782 | xfs_dahash_t midhash; /* middle entry hash value */ |
782 | 783 | ||
783 | if (mid >= be16_to_cpu(leaf1->hdr.count)) | 784 | if (mid >= be16_to_cpu(leaf1->hdr.count)) |
784 | midhash = INT_GET(leaf2->ents[mid - be16_to_cpu(leaf1->hdr.count)].hashval, ARCH_CONVERT); | 785 | midhash = be32_to_cpu(leaf2->ents[mid - be16_to_cpu(leaf1->hdr.count)].hashval); |
785 | else | 786 | else |
786 | midhash = INT_GET(leaf1->ents[mid].hashval, ARCH_CONVERT); | 787 | midhash = be32_to_cpu(leaf1->ents[mid].hashval); |
787 | isleft = args->hashval <= midhash; | 788 | isleft = args->hashval <= midhash; |
788 | } | 789 | } |
789 | /* | 790 | /* |
@@ -875,9 +876,9 @@ xfs_dir2_leafn_remove( | |||
875 | /* | 876 | /* |
876 | * Extract the data block and offset from the entry. | 877 | * Extract the data block and offset from the entry. |
877 | */ | 878 | */ |
878 | db = XFS_DIR2_DATAPTR_TO_DB(mp, INT_GET(lep->address, ARCH_CONVERT)); | 879 | db = XFS_DIR2_DATAPTR_TO_DB(mp, be32_to_cpu(lep->address)); |
879 | ASSERT(dblk->blkno == db); | 880 | ASSERT(dblk->blkno == db); |
880 | off = XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(lep->address, ARCH_CONVERT)); | 881 | off = XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(lep->address)); |
881 | ASSERT(dblk->index == off); | 882 | ASSERT(dblk->index == off); |
882 | /* | 883 | /* |
883 | * Kill the leaf entry by marking it stale. | 884 | * Kill the leaf entry by marking it stale. |
@@ -885,7 +886,7 @@ xfs_dir2_leafn_remove( | |||
885 | */ | 886 | */ |
886 | be16_add(&leaf->hdr.stale, 1); | 887 | be16_add(&leaf->hdr.stale, 1); |
887 | xfs_dir2_leaf_log_header(tp, bp); | 888 | xfs_dir2_leaf_log_header(tp, bp); |
888 | INT_SET(lep->address, ARCH_CONVERT, XFS_DIR2_NULL_DATAPTR); | 889 | lep->address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR); |
889 | xfs_dir2_leaf_log_ents(tp, bp, index, index); | 890 | xfs_dir2_leaf_log_ents(tp, bp, index, index); |
890 | /* | 891 | /* |
891 | * Make the data entry free. Keep track of the longest freespace | 892 | * Make the data entry free. Keep track of the longest freespace |
@@ -1269,14 +1270,14 @@ xfs_dir2_leafn_unbalance( | |||
1269 | /* | 1270 | /* |
1270 | * Move the entries from drop to the appropriate end of save. | 1271 | * Move the entries from drop to the appropriate end of save. |
1271 | */ | 1272 | */ |
1272 | drop_blk->hashval = INT_GET(drop_leaf->ents[be16_to_cpu(drop_leaf->hdr.count) - 1].hashval, ARCH_CONVERT); | 1273 | drop_blk->hashval = be32_to_cpu(drop_leaf->ents[be16_to_cpu(drop_leaf->hdr.count) - 1].hashval); |
1273 | if (xfs_dir2_leafn_order(save_blk->bp, drop_blk->bp)) | 1274 | if (xfs_dir2_leafn_order(save_blk->bp, drop_blk->bp)) |
1274 | xfs_dir2_leafn_moveents(args, drop_blk->bp, 0, save_blk->bp, 0, | 1275 | xfs_dir2_leafn_moveents(args, drop_blk->bp, 0, save_blk->bp, 0, |
1275 | be16_to_cpu(drop_leaf->hdr.count)); | 1276 | be16_to_cpu(drop_leaf->hdr.count)); |
1276 | else | 1277 | else |
1277 | xfs_dir2_leafn_moveents(args, drop_blk->bp, 0, save_blk->bp, | 1278 | xfs_dir2_leafn_moveents(args, drop_blk->bp, 0, save_blk->bp, |
1278 | be16_to_cpu(save_leaf->hdr.count), be16_to_cpu(drop_leaf->hdr.count)); | 1279 | be16_to_cpu(save_leaf->hdr.count), be16_to_cpu(drop_leaf->hdr.count)); |
1279 | save_blk->hashval = INT_GET(save_leaf->ents[be16_to_cpu(save_leaf->hdr.count) - 1].hashval, ARCH_CONVERT); | 1280 | save_blk->hashval = be32_to_cpu(save_leaf->ents[be16_to_cpu(save_leaf->hdr.count) - 1].hashval); |
1280 | xfs_dir2_leafn_check(args->dp, save_blk->bp); | 1281 | xfs_dir2_leafn_check(args->dp, save_blk->bp); |
1281 | } | 1282 | } |
1282 | 1283 | ||
@@ -1903,7 +1904,7 @@ xfs_dir2_node_replace( | |||
1903 | ASSERT(be32_to_cpu(data->hdr.magic) == XFS_DIR2_DATA_MAGIC); | 1904 | ASSERT(be32_to_cpu(data->hdr.magic) == XFS_DIR2_DATA_MAGIC); |
1904 | dep = (xfs_dir2_data_entry_t *) | 1905 | dep = (xfs_dir2_data_entry_t *) |
1905 | ((char *)data + | 1906 | ((char *)data + |
1906 | XFS_DIR2_DATAPTR_TO_OFF(state->mp, INT_GET(lep->address, ARCH_CONVERT))); | 1907 | XFS_DIR2_DATAPTR_TO_OFF(state->mp, be32_to_cpu(lep->address))); |
1907 | ASSERT(inum != INT_GET(dep->inumber, ARCH_CONVERT)); | 1908 | ASSERT(inum != INT_GET(dep->inumber, ARCH_CONVERT)); |
1908 | /* | 1909 | /* |
1909 | * Fill in the new inode number and log the entry. | 1910 | * Fill in the new inode number and log the entry. |