diff options
Diffstat (limited to 'fs/xfs/xfs_dir2_leaf.c')
-rw-r--r-- | fs/xfs/xfs_dir2_leaf.c | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c index 0d366ab4db17..752fc67354ea 100644 --- a/fs/xfs/xfs_dir2_leaf.c +++ b/fs/xfs/xfs_dir2_leaf.c | |||
@@ -222,11 +222,11 @@ xfs_dir2_leaf_addname( | |||
222 | * in a data block, improving the lookup of those entries. | 222 | * in a data block, improving the lookup of those entries. |
223 | */ | 223 | */ |
224 | for (use_block = -1, lep = &leaf->ents[index]; | 224 | for (use_block = -1, lep = &leaf->ents[index]; |
225 | index < be16_to_cpu(leaf->hdr.count) && INT_GET(lep->hashval, ARCH_CONVERT) == args->hashval; | 225 | index < be16_to_cpu(leaf->hdr.count) && be32_to_cpu(lep->hashval) == args->hashval; |
226 | index++, lep++) { | 226 | index++, lep++) { |
227 | if (INT_GET(lep->address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) | 227 | if (be32_to_cpu(lep->address) == XFS_DIR2_NULL_DATAPTR) |
228 | continue; | 228 | continue; |
229 | i = XFS_DIR2_DATAPTR_TO_DB(mp, INT_GET(lep->address, ARCH_CONVERT)); | 229 | i = XFS_DIR2_DATAPTR_TO_DB(mp, be32_to_cpu(lep->address)); |
230 | ASSERT(i < be32_to_cpu(ltp->bestcount)); | 230 | ASSERT(i < be32_to_cpu(ltp->bestcount)); |
231 | ASSERT(be16_to_cpu(bestsp[i]) != NULLDATAOFF); | 231 | ASSERT(be16_to_cpu(bestsp[i]) != NULLDATAOFF); |
232 | if (be16_to_cpu(bestsp[i]) >= length) { | 232 | if (be16_to_cpu(bestsp[i]) >= length) { |
@@ -468,7 +468,7 @@ xfs_dir2_leaf_addname( | |||
468 | */ | 468 | */ |
469 | for (lowstale = index - 1; | 469 | for (lowstale = index - 1; |
470 | lowstale >= 0 && | 470 | lowstale >= 0 && |
471 | INT_GET(leaf->ents[lowstale].address, ARCH_CONVERT) != | 471 | be32_to_cpu(leaf->ents[lowstale].address) != |
472 | XFS_DIR2_NULL_DATAPTR; | 472 | XFS_DIR2_NULL_DATAPTR; |
473 | lowstale--) | 473 | lowstale--) |
474 | continue; | 474 | continue; |
@@ -479,7 +479,7 @@ xfs_dir2_leaf_addname( | |||
479 | */ | 479 | */ |
480 | for (highstale = index; | 480 | for (highstale = index; |
481 | highstale < be16_to_cpu(leaf->hdr.count) && | 481 | highstale < be16_to_cpu(leaf->hdr.count) && |
482 | INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) != | 482 | be32_to_cpu(leaf->ents[highstale].address) != |
483 | XFS_DIR2_NULL_DATAPTR && | 483 | XFS_DIR2_NULL_DATAPTR && |
484 | (lowstale < 0 || | 484 | (lowstale < 0 || |
485 | index - lowstale - 1 >= highstale - index); | 485 | index - lowstale - 1 >= highstale - index); |
@@ -493,7 +493,7 @@ xfs_dir2_leaf_addname( | |||
493 | (highstale == be16_to_cpu(leaf->hdr.count) || | 493 | (highstale == be16_to_cpu(leaf->hdr.count) || |
494 | index - lowstale - 1 < highstale - index)) { | 494 | index - lowstale - 1 < highstale - index)) { |
495 | ASSERT(index - lowstale - 1 >= 0); | 495 | ASSERT(index - lowstale - 1 >= 0); |
496 | ASSERT(INT_GET(leaf->ents[lowstale].address, ARCH_CONVERT) == | 496 | ASSERT(be32_to_cpu(leaf->ents[lowstale].address) == |
497 | XFS_DIR2_NULL_DATAPTR); | 497 | XFS_DIR2_NULL_DATAPTR); |
498 | /* | 498 | /* |
499 | * Copy entries up to cover the stale entry | 499 | * Copy entries up to cover the stale entry |
@@ -512,7 +512,7 @@ xfs_dir2_leaf_addname( | |||
512 | */ | 512 | */ |
513 | else { | 513 | else { |
514 | ASSERT(highstale - index >= 0); | 514 | ASSERT(highstale - index >= 0); |
515 | ASSERT(INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) == | 515 | ASSERT(be32_to_cpu(leaf->ents[highstale].address) == |
516 | XFS_DIR2_NULL_DATAPTR); | 516 | XFS_DIR2_NULL_DATAPTR); |
517 | /* | 517 | /* |
518 | * Copy entries down to copver the stale entry | 518 | * Copy entries down to copver the stale entry |
@@ -531,8 +531,9 @@ xfs_dir2_leaf_addname( | |||
531 | /* | 531 | /* |
532 | * Fill in the new leaf entry. | 532 | * Fill in the new leaf entry. |
533 | */ | 533 | */ |
534 | INT_SET(lep->hashval, ARCH_CONVERT, args->hashval); | 534 | lep->hashval = cpu_to_be32(args->hashval); |
535 | INT_SET(lep->address, ARCH_CONVERT, XFS_DIR2_DB_OFF_TO_DATAPTR(mp, use_block, INT_GET(*tagp, ARCH_CONVERT))); | 535 | lep->address = cpu_to_be32(XFS_DIR2_DB_OFF_TO_DATAPTR(mp, use_block, |
536 | INT_GET(*tagp, ARCH_CONVERT))); | ||
536 | /* | 537 | /* |
537 | * Log the leaf fields and give up the buffers. | 538 | * Log the leaf fields and give up the buffers. |
538 | */ | 539 | */ |
@@ -581,9 +582,9 @@ xfs_dir2_leaf_check( | |||
581 | */ | 582 | */ |
582 | for (i = stale = 0; i < be16_to_cpu(leaf->hdr.count); i++) { | 583 | for (i = stale = 0; i < be16_to_cpu(leaf->hdr.count); i++) { |
583 | if (i + 1 < be16_to_cpu(leaf->hdr.count)) | 584 | if (i + 1 < be16_to_cpu(leaf->hdr.count)) |
584 | ASSERT(INT_GET(leaf->ents[i].hashval, ARCH_CONVERT) <= | 585 | ASSERT(be32_to_cpu(leaf->ents[i].hashval) <= |
585 | INT_GET(leaf->ents[i + 1].hashval, ARCH_CONVERT)); | 586 | be32_to_cpu(leaf->ents[i + 1].hashval)); |
586 | if (INT_GET(leaf->ents[i].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) | 587 | if (be32_to_cpu(leaf->ents[i].address) == XFS_DIR2_NULL_DATAPTR) |
587 | stale++; | 588 | stale++; |
588 | } | 589 | } |
589 | ASSERT(be16_to_cpu(leaf->hdr.stale) == stale); | 590 | ASSERT(be16_to_cpu(leaf->hdr.stale) == stale); |
@@ -612,7 +613,7 @@ xfs_dir2_leaf_compact( | |||
612 | * Compress out the stale entries in place. | 613 | * Compress out the stale entries in place. |
613 | */ | 614 | */ |
614 | for (from = to = 0, loglow = -1; from < be16_to_cpu(leaf->hdr.count); from++) { | 615 | for (from = to = 0, loglow = -1; from < be16_to_cpu(leaf->hdr.count); from++) { |
615 | if (INT_GET(leaf->ents[from].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) | 616 | if (be32_to_cpu(leaf->ents[from].address) == XFS_DIR2_NULL_DATAPTR) |
616 | continue; | 617 | continue; |
617 | /* | 618 | /* |
618 | * Only actually copy the entries that are different. | 619 | * Only actually copy the entries that are different. |
@@ -669,7 +670,7 @@ xfs_dir2_leaf_compact_x1( | |||
669 | */ | 670 | */ |
670 | for (lowstale = index - 1; | 671 | for (lowstale = index - 1; |
671 | lowstale >= 0 && | 672 | lowstale >= 0 && |
672 | INT_GET(leaf->ents[lowstale].address, ARCH_CONVERT) != XFS_DIR2_NULL_DATAPTR; | 673 | be32_to_cpu(leaf->ents[lowstale].address) != XFS_DIR2_NULL_DATAPTR; |
673 | lowstale--) | 674 | lowstale--) |
674 | continue; | 675 | continue; |
675 | /* | 676 | /* |
@@ -678,7 +679,7 @@ xfs_dir2_leaf_compact_x1( | |||
678 | */ | 679 | */ |
679 | for (highstale = index; | 680 | for (highstale = index; |
680 | highstale < be16_to_cpu(leaf->hdr.count) && | 681 | highstale < be16_to_cpu(leaf->hdr.count) && |
681 | INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) != XFS_DIR2_NULL_DATAPTR && | 682 | be32_to_cpu(leaf->ents[highstale].address) != XFS_DIR2_NULL_DATAPTR && |
682 | (lowstale < 0 || index - lowstale > highstale - index); | 683 | (lowstale < 0 || index - lowstale > highstale - index); |
683 | highstale++) | 684 | highstale++) |
684 | continue; | 685 | continue; |
@@ -702,7 +703,7 @@ xfs_dir2_leaf_compact_x1( | |||
702 | if (index == from) | 703 | if (index == from) |
703 | newindex = to; | 704 | newindex = to; |
704 | if (from != keepstale && | 705 | if (from != keepstale && |
705 | INT_GET(leaf->ents[from].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) { | 706 | be32_to_cpu(leaf->ents[from].address) == XFS_DIR2_NULL_DATAPTR) { |
706 | if (from == to) | 707 | if (from == to) |
707 | *lowlogp = to; | 708 | *lowlogp = to; |
708 | continue; | 709 | continue; |
@@ -1314,7 +1315,7 @@ xfs_dir2_leaf_lookup( | |||
1314 | */ | 1315 | */ |
1315 | dep = (xfs_dir2_data_entry_t *) | 1316 | dep = (xfs_dir2_data_entry_t *) |
1316 | ((char *)dbp->data + | 1317 | ((char *)dbp->data + |
1317 | XFS_DIR2_DATAPTR_TO_OFF(dp->i_mount, INT_GET(lep->address, ARCH_CONVERT))); | 1318 | XFS_DIR2_DATAPTR_TO_OFF(dp->i_mount, be32_to_cpu(lep->address))); |
1318 | /* | 1319 | /* |
1319 | * Return the found inode number. | 1320 | * Return the found inode number. |
1320 | */ | 1321 | */ |
@@ -1373,17 +1374,17 @@ xfs_dir2_leaf_lookup_int( | |||
1373 | * looking to match the name. | 1374 | * looking to match the name. |
1374 | */ | 1375 | */ |
1375 | for (lep = &leaf->ents[index], dbp = NULL, curdb = -1; | 1376 | for (lep = &leaf->ents[index], dbp = NULL, curdb = -1; |
1376 | index < be16_to_cpu(leaf->hdr.count) && INT_GET(lep->hashval, ARCH_CONVERT) == args->hashval; | 1377 | index < be16_to_cpu(leaf->hdr.count) && be32_to_cpu(lep->hashval) == args->hashval; |
1377 | lep++, index++) { | 1378 | lep++, index++) { |
1378 | /* | 1379 | /* |
1379 | * Skip over stale leaf entries. | 1380 | * Skip over stale leaf entries. |
1380 | */ | 1381 | */ |
1381 | if (INT_GET(lep->address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) | 1382 | if (be32_to_cpu(lep->address) == XFS_DIR2_NULL_DATAPTR) |
1382 | continue; | 1383 | continue; |
1383 | /* | 1384 | /* |
1384 | * Get the new data block number. | 1385 | * Get the new data block number. |
1385 | */ | 1386 | */ |
1386 | newdb = XFS_DIR2_DATAPTR_TO_DB(mp, INT_GET(lep->address, ARCH_CONVERT)); | 1387 | newdb = XFS_DIR2_DATAPTR_TO_DB(mp, be32_to_cpu(lep->address)); |
1387 | /* | 1388 | /* |
1388 | * If it's not the same as the old data block number, | 1389 | * If it's not the same as the old data block number, |
1389 | * need to pitch the old one and read the new one. | 1390 | * need to pitch the old one and read the new one. |
@@ -1406,7 +1407,7 @@ xfs_dir2_leaf_lookup_int( | |||
1406 | */ | 1407 | */ |
1407 | dep = (xfs_dir2_data_entry_t *) | 1408 | dep = (xfs_dir2_data_entry_t *) |
1408 | ((char *)dbp->data + | 1409 | ((char *)dbp->data + |
1409 | XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(lep->address, ARCH_CONVERT))); | 1410 | XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(lep->address))); |
1410 | /* | 1411 | /* |
1411 | * If it matches then return it. | 1412 | * If it matches then return it. |
1412 | */ | 1413 | */ |
@@ -1471,9 +1472,9 @@ xfs_dir2_leaf_removename( | |||
1471 | * Point to the leaf entry, use that to point to the data entry. | 1472 | * Point to the leaf entry, use that to point to the data entry. |
1472 | */ | 1473 | */ |
1473 | lep = &leaf->ents[index]; | 1474 | lep = &leaf->ents[index]; |
1474 | db = XFS_DIR2_DATAPTR_TO_DB(mp, INT_GET(lep->address, ARCH_CONVERT)); | 1475 | db = XFS_DIR2_DATAPTR_TO_DB(mp, be32_to_cpu(lep->address)); |
1475 | dep = (xfs_dir2_data_entry_t *) | 1476 | dep = (xfs_dir2_data_entry_t *) |
1476 | ((char *)data + XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(lep->address, ARCH_CONVERT))); | 1477 | ((char *)data + XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(lep->address))); |
1477 | needscan = needlog = 0; | 1478 | needscan = needlog = 0; |
1478 | oldbest = be16_to_cpu(data->hdr.bestfree[0].length); | 1479 | oldbest = be16_to_cpu(data->hdr.bestfree[0].length); |
1479 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); | 1480 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); |
@@ -1490,7 +1491,7 @@ xfs_dir2_leaf_removename( | |||
1490 | */ | 1491 | */ |
1491 | be16_add(&leaf->hdr.stale, 1); | 1492 | be16_add(&leaf->hdr.stale, 1); |
1492 | xfs_dir2_leaf_log_header(tp, lbp); | 1493 | xfs_dir2_leaf_log_header(tp, lbp); |
1493 | INT_SET(lep->address, ARCH_CONVERT, XFS_DIR2_NULL_DATAPTR); | 1494 | lep->address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR); |
1494 | xfs_dir2_leaf_log_ents(tp, lbp, index, index); | 1495 | xfs_dir2_leaf_log_ents(tp, lbp, index, index); |
1495 | /* | 1496 | /* |
1496 | * Scan the freespace in the data block again if necessary, | 1497 | * Scan the freespace in the data block again if necessary, |
@@ -1604,7 +1605,7 @@ xfs_dir2_leaf_replace( | |||
1604 | */ | 1605 | */ |
1605 | dep = (xfs_dir2_data_entry_t *) | 1606 | dep = (xfs_dir2_data_entry_t *) |
1606 | ((char *)dbp->data + | 1607 | ((char *)dbp->data + |
1607 | XFS_DIR2_DATAPTR_TO_OFF(dp->i_mount, INT_GET(lep->address, ARCH_CONVERT))); | 1608 | XFS_DIR2_DATAPTR_TO_OFF(dp->i_mount, be32_to_cpu(lep->address))); |
1608 | ASSERT(args->inumber != INT_GET(dep->inumber, ARCH_CONVERT)); | 1609 | ASSERT(args->inumber != INT_GET(dep->inumber, ARCH_CONVERT)); |
1609 | /* | 1610 | /* |
1610 | * Put the new inode number in, log it. | 1611 | * Put the new inode number in, log it. |
@@ -1649,7 +1650,7 @@ xfs_dir2_leaf_search_hash( | |||
1649 | hashwant = args->hashval; | 1650 | hashwant = args->hashval; |
1650 | low <= high; ) { | 1651 | low <= high; ) { |
1651 | mid = (low + high) >> 1; | 1652 | mid = (low + high) >> 1; |
1652 | if ((hash = INT_GET(lep[mid].hashval, ARCH_CONVERT)) == hashwant) | 1653 | if ((hash = be32_to_cpu(lep[mid].hashval)) == hashwant) |
1653 | break; | 1654 | break; |
1654 | if (hash < hashwant) | 1655 | if (hash < hashwant) |
1655 | low = mid + 1; | 1656 | low = mid + 1; |
@@ -1660,7 +1661,7 @@ xfs_dir2_leaf_search_hash( | |||
1660 | * Found one, back up through all the equal hash values. | 1661 | * Found one, back up through all the equal hash values. |
1661 | */ | 1662 | */ |
1662 | if (hash == hashwant) { | 1663 | if (hash == hashwant) { |
1663 | while (mid > 0 && INT_GET(lep[mid - 1].hashval, ARCH_CONVERT) == hashwant) { | 1664 | while (mid > 0 && be32_to_cpu(lep[mid - 1].hashval) == hashwant) { |
1664 | mid--; | 1665 | mid--; |
1665 | } | 1666 | } |
1666 | } | 1667 | } |