aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/xfs/xfs_da_btree.c4
-rw-r--r--fs/xfs/xfs_dir2_block.c6
-rw-r--r--fs/xfs/xfs_dir2_leaf.c74
-rw-r--r--fs/xfs/xfs_dir2_leaf.h4
-rw-r--r--fs/xfs/xfs_dir2_node.c112
5 files changed, 100 insertions, 100 deletions
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c
index 2f4acb9d9b9c..c443cbaaaa92 100644
--- a/fs/xfs/xfs_da_btree.c
+++ b/fs/xfs/xfs_da_btree.c
@@ -366,7 +366,7 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
366 ASSERT(XFS_DIR_IS_V2(mp)); 366 ASSERT(XFS_DIR_IS_V2(mp));
367 ASSERT(INT_GET(oldroot->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); 367 ASSERT(INT_GET(oldroot->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
368 leaf = (xfs_dir2_leaf_t *)oldroot; 368 leaf = (xfs_dir2_leaf_t *)oldroot;
369 size = (int)((char *)&leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT)] - 369 size = (int)((char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] -
370 (char *)leaf); 370 (char *)leaf);
371 } 371 }
372 memcpy(node, oldroot, size); 372 memcpy(node, oldroot, size);
@@ -1798,7 +1798,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1798 ASSERT(XFS_DIR_IS_V2(mp)); 1798 ASSERT(XFS_DIR_IS_V2(mp));
1799 dead_leaf2 = (xfs_dir2_leaf_t *)dead_info; 1799 dead_leaf2 = (xfs_dir2_leaf_t *)dead_info;
1800 dead_level = 0; 1800 dead_level = 0;
1801 dead_hash = INT_GET(dead_leaf2->ents[INT_GET(dead_leaf2->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT); 1801 dead_hash = INT_GET(dead_leaf2->ents[be16_to_cpu(dead_leaf2->hdr.count) - 1].hashval, ARCH_CONVERT);
1802 } else { 1802 } else {
1803 ASSERT(INT_GET(dead_info->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); 1803 ASSERT(INT_GET(dead_info->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC);
1804 dead_node = (xfs_da_intnode_t *)dead_info; 1804 dead_node = (xfs_da_intnode_t *)dead_info;
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c
index 6f3b99dfe55c..1dd1a7694e4b 100644
--- a/fs/xfs/xfs_dir2_block.c
+++ b/fs/xfs/xfs_dir2_block.c
@@ -939,7 +939,7 @@ xfs_dir2_leaf_to_block(
939 * Size of the "leaf" area in the block. 939 * Size of the "leaf" area in the block.
940 */ 940 */
941 size = (uint)sizeof(block->tail) + 941 size = (uint)sizeof(block->tail) +
942 (uint)sizeof(*lep) * (INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT)); 942 (uint)sizeof(*lep) * (be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale));
943 /* 943 /*
944 * Look at the last data entry. 944 * Look at the last data entry.
945 */ 945 */
@@ -968,14 +968,14 @@ xfs_dir2_leaf_to_block(
968 * Initialize the block tail. 968 * Initialize the block tail.
969 */ 969 */
970 btp = XFS_DIR2_BLOCK_TAIL_P(mp, block); 970 btp = XFS_DIR2_BLOCK_TAIL_P(mp, block);
971 btp->count = cpu_to_be32(INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT)); 971 btp->count = cpu_to_be32(be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale));
972 btp->stale = 0; 972 btp->stale = 0;
973 xfs_dir2_block_log_tail(tp, dbp); 973 xfs_dir2_block_log_tail(tp, dbp);
974 /* 974 /*
975 * Initialize the block leaf area. We compact out stale entries. 975 * Initialize the block leaf area. We compact out stale entries.
976 */ 976 */
977 lep = XFS_DIR2_BLOCK_LEAF_P(btp); 977 lep = XFS_DIR2_BLOCK_LEAF_P(btp);
978 for (from = to = 0; from < INT_GET(leaf->hdr.count, ARCH_CONVERT); from++) { 978 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) 979 if (INT_GET(leaf->ents[from].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR)
980 continue; 980 continue;
981 lep[to++] = leaf->ents[from]; 981 lep[to++] = leaf->ents[from];
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c
index 63e81dc2737e..0d366ab4db17 100644
--- a/fs/xfs/xfs_dir2_leaf.c
+++ b/fs/xfs/xfs_dir2_leaf.c
@@ -111,14 +111,14 @@ xfs_dir2_block_to_leaf(
111 /* 111 /*
112 * Set the counts in the leaf header. 112 * Set the counts in the leaf header.
113 */ 113 */
114 leaf->hdr.count = btp->count; 114 leaf->hdr.count = cpu_to_be16(be32_to_cpu(btp->count));
115 leaf->hdr.stale = btp->stale; 115 leaf->hdr.stale = cpu_to_be16(be32_to_cpu(btp->stale));
116 /* 116 /*
117 * Could compact these but I think we always do the conversion 117 * Could compact these but I think we always do the conversion
118 * after squeezing out stale entries. 118 * after squeezing out stale entries.
119 */ 119 */
120 memcpy(leaf->ents, blp, be32_to_cpu(btp->count) * sizeof(xfs_dir2_leaf_entry_t)); 120 memcpy(leaf->ents, blp, be32_to_cpu(btp->count) * sizeof(xfs_dir2_leaf_entry_t));
121 xfs_dir2_leaf_log_ents(tp, lbp, 0, INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1); 121 xfs_dir2_leaf_log_ents(tp, lbp, 0, be16_to_cpu(leaf->hdr.count) - 1);
122 needscan = 0; 122 needscan = 0;
123 needlog = 1; 123 needlog = 1;
124 /* 124 /*
@@ -222,7 +222,7 @@ 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 < INT_GET(leaf->hdr.count, ARCH_CONVERT) && INT_GET(lep->hashval, ARCH_CONVERT) == args->hashval; 225 index < be16_to_cpu(leaf->hdr.count) && INT_GET(lep->hashval, ARCH_CONVERT) == args->hashval;
226 index++, lep++) { 226 index++, lep++) {
227 if (INT_GET(lep->address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) 227 if (INT_GET(lep->address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR)
228 continue; 228 continue;
@@ -266,15 +266,15 @@ xfs_dir2_leaf_addname(
266 * If we don't have enough free bytes but we can make enough 266 * If we don't have enough free bytes but we can make enough
267 * by compacting out stale entries, we'll do that. 267 * by compacting out stale entries, we'll do that.
268 */ 268 */
269 if ((char *)bestsp - (char *)&leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT)] < needbytes && 269 if ((char *)bestsp - (char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] < needbytes &&
270 INT_GET(leaf->hdr.stale, ARCH_CONVERT) > 1) { 270 be16_to_cpu(leaf->hdr.stale) > 1) {
271 compact = 1; 271 compact = 1;
272 } 272 }
273 /* 273 /*
274 * Otherwise if we don't have enough free bytes we need to 274 * Otherwise if we don't have enough free bytes we need to
275 * convert to node form. 275 * convert to node form.
276 */ 276 */
277 else if ((char *)bestsp - (char *)&leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT)] < 277 else if ((char *)bestsp - (char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] <
278 needbytes) { 278 needbytes) {
279 /* 279 /*
280 * Just checking or no space reservation, give up. 280 * Just checking or no space reservation, give up.
@@ -330,8 +330,8 @@ xfs_dir2_leaf_addname(
330 * There are stale entries, so we'll need log-low and log-high 330 * There are stale entries, so we'll need log-low and log-high
331 * impossibly bad values later. 331 * impossibly bad values later.
332 */ 332 */
333 else if (INT_GET(leaf->hdr.stale, ARCH_CONVERT)) { 333 else if (be16_to_cpu(leaf->hdr.stale)) {
334 lfloglow = INT_GET(leaf->hdr.count, ARCH_CONVERT); 334 lfloglow = be16_to_cpu(leaf->hdr.count);
335 lfloghigh = -1; 335 lfloghigh = -1;
336 } 336 }
337 /* 337 /*
@@ -440,15 +440,15 @@ xfs_dir2_leaf_addname(
440 /* 440 /*
441 * lep is still good as the index leaf entry. 441 * lep is still good as the index leaf entry.
442 */ 442 */
443 if (index < INT_GET(leaf->hdr.count, ARCH_CONVERT)) 443 if (index < be16_to_cpu(leaf->hdr.count))
444 memmove(lep + 1, lep, 444 memmove(lep + 1, lep,
445 (INT_GET(leaf->hdr.count, ARCH_CONVERT) - index) * sizeof(*lep)); 445 (be16_to_cpu(leaf->hdr.count) - index) * sizeof(*lep));
446 /* 446 /*
447 * Record low and high logging indices for the leaf. 447 * Record low and high logging indices for the leaf.
448 */ 448 */
449 lfloglow = index; 449 lfloglow = index;
450 lfloghigh = INT_GET(leaf->hdr.count, ARCH_CONVERT); 450 lfloghigh = be16_to_cpu(leaf->hdr.count);
451 INT_MOD(leaf->hdr.count, ARCH_CONVERT, +1); 451 be16_add(&leaf->hdr.count, 1);
452 } 452 }
453 /* 453 /*
454 * There are stale entries. 454 * There are stale entries.
@@ -478,7 +478,7 @@ xfs_dir2_leaf_addname(
478 * lowstale entry would be better. 478 * lowstale entry would be better.
479 */ 479 */
480 for (highstale = index; 480 for (highstale = index;
481 highstale < INT_GET(leaf->hdr.count, ARCH_CONVERT) && 481 highstale < be16_to_cpu(leaf->hdr.count) &&
482 INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) != 482 INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) !=
483 XFS_DIR2_NULL_DATAPTR && 483 XFS_DIR2_NULL_DATAPTR &&
484 (lowstale < 0 || 484 (lowstale < 0 ||
@@ -490,7 +490,7 @@ xfs_dir2_leaf_addname(
490 * If the low one is better, use it. 490 * If the low one is better, use it.
491 */ 491 */
492 if (lowstale >= 0 && 492 if (lowstale >= 0 &&
493 (highstale == INT_GET(leaf->hdr.count, ARCH_CONVERT) || 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(INT_GET(leaf->ents[lowstale].address, ARCH_CONVERT) ==
@@ -526,7 +526,7 @@ xfs_dir2_leaf_addname(
526 lfloglow = MIN(index, lfloglow); 526 lfloglow = MIN(index, lfloglow);
527 lfloghigh = MAX(highstale, lfloghigh); 527 lfloghigh = MAX(highstale, lfloghigh);
528 } 528 }
529 INT_MOD(leaf->hdr.stale, ARCH_CONVERT, -1); 529 be16_add(&leaf->hdr.stale, -1);
530 } 530 }
531 /* 531 /*
532 * Fill in the new leaf entry. 532 * Fill in the new leaf entry.
@@ -569,24 +569,24 @@ xfs_dir2_leaf_check(
569 * Should factor in the size of the bests table as well. 569 * Should factor in the size of the bests table as well.
570 * We can deduce a value for that from di_size. 570 * We can deduce a value for that from di_size.
571 */ 571 */
572 ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) <= XFS_DIR2_MAX_LEAF_ENTS(mp)); 572 ASSERT(be16_to_cpu(leaf->hdr.count) <= XFS_DIR2_MAX_LEAF_ENTS(mp));
573 ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); 573 ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf);
574 /* 574 /*
575 * Leaves and bests don't overlap. 575 * Leaves and bests don't overlap.
576 */ 576 */
577 ASSERT((char *)&leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT)] <= 577 ASSERT((char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] <=
578 (char *)XFS_DIR2_LEAF_BESTS_P(ltp)); 578 (char *)XFS_DIR2_LEAF_BESTS_P(ltp));
579 /* 579 /*
580 * Check hash value order, count stale entries. 580 * Check hash value order, count stale entries.
581 */ 581 */
582 for (i = stale = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT); i++) { 582 for (i = stale = 0; i < be16_to_cpu(leaf->hdr.count); i++) {
583 if (i + 1 < INT_GET(leaf->hdr.count, ARCH_CONVERT)) 583 if (i + 1 < be16_to_cpu(leaf->hdr.count))
584 ASSERT(INT_GET(leaf->ents[i].hashval, ARCH_CONVERT) <= 584 ASSERT(INT_GET(leaf->ents[i].hashval, ARCH_CONVERT) <=
585 INT_GET(leaf->ents[i + 1].hashval, ARCH_CONVERT)); 585 INT_GET(leaf->ents[i + 1].hashval, ARCH_CONVERT));
586 if (INT_GET(leaf->ents[i].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) 586 if (INT_GET(leaf->ents[i].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR)
587 stale++; 587 stale++;
588 } 588 }
589 ASSERT(INT_GET(leaf->hdr.stale, ARCH_CONVERT) == stale); 589 ASSERT(be16_to_cpu(leaf->hdr.stale) == stale);
590} 590}
591#endif /* DEBUG */ 591#endif /* DEBUG */
592 592
@@ -611,7 +611,7 @@ xfs_dir2_leaf_compact(
611 /* 611 /*
612 * Compress out the stale entries in place. 612 * Compress out the stale entries in place.
613 */ 613 */
614 for (from = to = 0, loglow = -1; from < INT_GET(leaf->hdr.count, ARCH_CONVERT); from++) { 614 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) 615 if (INT_GET(leaf->ents[from].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR)
616 continue; 616 continue;
617 /* 617 /*
@@ -627,8 +627,8 @@ xfs_dir2_leaf_compact(
627 /* 627 /*
628 * Update and log the header, log the leaf entries. 628 * Update and log the header, log the leaf entries.
629 */ 629 */
630 ASSERT(INT_GET(leaf->hdr.stale, ARCH_CONVERT) == from - to); 630 ASSERT(be16_to_cpu(leaf->hdr.stale) == from - to);
631 INT_MOD(leaf->hdr.count, ARCH_CONVERT, -(INT_GET(leaf->hdr.stale, ARCH_CONVERT))); 631 be16_add(&leaf->hdr.count, -(be16_to_cpu(leaf->hdr.stale)));
632 leaf->hdr.stale = 0; 632 leaf->hdr.stale = 0;
633 xfs_dir2_leaf_log_header(args->trans, bp); 633 xfs_dir2_leaf_log_header(args->trans, bp);
634 if (loglow != -1) 634 if (loglow != -1)
@@ -662,7 +662,7 @@ xfs_dir2_leaf_compact_x1(
662 int to; /* destination copy index */ 662 int to; /* destination copy index */
663 663
664 leaf = bp->data; 664 leaf = bp->data;
665 ASSERT(INT_GET(leaf->hdr.stale, ARCH_CONVERT) > 1); 665 ASSERT(be16_to_cpu(leaf->hdr.stale) > 1);
666 index = *indexp; 666 index = *indexp;
667 /* 667 /*
668 * Find the first stale entry before our index, if any. 668 * Find the first stale entry before our index, if any.
@@ -677,7 +677,7 @@ xfs_dir2_leaf_compact_x1(
677 * Stop if the answer would be worse than lowstale. 677 * Stop if the answer would be worse than lowstale.
678 */ 678 */
679 for (highstale = index; 679 for (highstale = index;
680 highstale < INT_GET(leaf->hdr.count, ARCH_CONVERT) && 680 highstale < be16_to_cpu(leaf->hdr.count) &&
681 INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) != XFS_DIR2_NULL_DATAPTR && 681 INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) != XFS_DIR2_NULL_DATAPTR &&
682 (lowstale < 0 || index - lowstale > highstale - index); 682 (lowstale < 0 || index - lowstale > highstale - index);
683 highstale++) 683 highstale++)
@@ -686,7 +686,7 @@ xfs_dir2_leaf_compact_x1(
686 * Pick the better of lowstale and highstale. 686 * Pick the better of lowstale and highstale.
687 */ 687 */
688 if (lowstale >= 0 && 688 if (lowstale >= 0 &&
689 (highstale == INT_GET(leaf->hdr.count, ARCH_CONVERT) || 689 (highstale == be16_to_cpu(leaf->hdr.count) ||
690 index - lowstale <= highstale - index)) 690 index - lowstale <= highstale - index))
691 keepstale = lowstale; 691 keepstale = lowstale;
692 else 692 else
@@ -695,7 +695,7 @@ xfs_dir2_leaf_compact_x1(
695 * Copy the entries in place, removing all the stale entries 695 * Copy the entries in place, removing all the stale entries
696 * except keepstale. 696 * except keepstale.
697 */ 697 */
698 for (from = to = 0; from < INT_GET(leaf->hdr.count, ARCH_CONVERT); from++) { 698 for (from = to = 0; from < be16_to_cpu(leaf->hdr.count); from++) {
699 /* 699 /*
700 * Notice the new value of index. 700 * Notice the new value of index.
701 */ 701 */
@@ -730,8 +730,8 @@ xfs_dir2_leaf_compact_x1(
730 /* 730 /*
731 * Adjust the leaf header values. 731 * Adjust the leaf header values.
732 */ 732 */
733 INT_MOD(leaf->hdr.count, ARCH_CONVERT, -(from - to)); 733 be16_add(&leaf->hdr.count, -(from - to));
734 INT_SET(leaf->hdr.stale, ARCH_CONVERT, 1); 734 leaf->hdr.stale = cpu_to_be16(1);
735 /* 735 /*
736 * Remember the low/high stale value only in the "right" 736 * Remember the low/high stale value only in the "right"
737 * direction. 737 * direction.
@@ -739,8 +739,8 @@ xfs_dir2_leaf_compact_x1(
739 if (lowstale >= newindex) 739 if (lowstale >= newindex)
740 lowstale = -1; 740 lowstale = -1;
741 else 741 else
742 highstale = INT_GET(leaf->hdr.count, ARCH_CONVERT); 742 highstale = be16_to_cpu(leaf->hdr.count);
743 *highlogp = INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1; 743 *highlogp = be16_to_cpu(leaf->hdr.count) - 1;
744 *lowstalep = lowstale; 744 *lowstalep = lowstale;
745 *highstalep = highstale; 745 *highstalep = highstale;
746} 746}
@@ -1373,7 +1373,7 @@ xfs_dir2_leaf_lookup_int(
1373 * looking to match the name. 1373 * looking to match the name.
1374 */ 1374 */
1375 for (lep = &leaf->ents[index], dbp = NULL, curdb = -1; 1375 for (lep = &leaf->ents[index], dbp = NULL, curdb = -1;
1376 index < INT_GET(leaf->hdr.count, ARCH_CONVERT) && INT_GET(lep->hashval, ARCH_CONVERT) == args->hashval; 1376 index < be16_to_cpu(leaf->hdr.count) && INT_GET(lep->hashval, ARCH_CONVERT) == args->hashval;
1377 lep++, index++) { 1377 lep++, index++) {
1378 /* 1378 /*
1379 * Skip over stale leaf entries. 1379 * Skip over stale leaf entries.
@@ -1488,7 +1488,7 @@ xfs_dir2_leaf_removename(
1488 /* 1488 /*
1489 * We just mark the leaf entry stale by putting a null in it. 1489 * We just mark the leaf entry stale by putting a null in it.
1490 */ 1490 */
1491 INT_MOD(leaf->hdr.stale, ARCH_CONVERT, +1); 1491 be16_add(&leaf->hdr.stale, 1);
1492 xfs_dir2_leaf_log_header(tp, lbp); 1492 xfs_dir2_leaf_log_header(tp, lbp);
1493 INT_SET(lep->address, ARCH_CONVERT, XFS_DIR2_NULL_DATAPTR); 1493 INT_SET(lep->address, ARCH_CONVERT, XFS_DIR2_NULL_DATAPTR);
1494 xfs_dir2_leaf_log_ents(tp, lbp, index, index); 1494 xfs_dir2_leaf_log_ents(tp, lbp, index, index);
@@ -1645,7 +1645,7 @@ xfs_dir2_leaf_search_hash(
1645 * Note, the table cannot be empty, so we have to go through the loop. 1645 * Note, the table cannot be empty, so we have to go through the loop.
1646 * Binary search the leaf entries looking for our hash value. 1646 * Binary search the leaf entries looking for our hash value.
1647 */ 1647 */
1648 for (lep = leaf->ents, low = 0, high = INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1, 1648 for (lep = leaf->ents, low = 0, high = be16_to_cpu(leaf->hdr.count) - 1,
1649 hashwant = args->hashval; 1649 hashwant = args->hashval;
1650 low <= high; ) { 1650 low <= high; ) {
1651 mid = (low + high) >> 1; 1651 mid = (low + high) >> 1;
@@ -1821,7 +1821,7 @@ xfs_dir2_node_to_leaf(
1821 * If not, release the buffer and give up. 1821 * If not, release the buffer and give up.
1822 */ 1822 */
1823 if ((uint)sizeof(leaf->hdr) + 1823 if ((uint)sizeof(leaf->hdr) +
1824 (INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT)) * (uint)sizeof(leaf->ents[0]) + 1824 (be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale)) * (uint)sizeof(leaf->ents[0]) +
1825 be32_to_cpu(free->hdr.nvalid) * (uint)sizeof(leaf->bests[0]) + 1825 be32_to_cpu(free->hdr.nvalid) * (uint)sizeof(leaf->bests[0]) +
1826 (uint)sizeof(leaf->tail) > 1826 (uint)sizeof(leaf->tail) >
1827 mp->m_dirblksize) { 1827 mp->m_dirblksize) {
@@ -1832,7 +1832,7 @@ xfs_dir2_node_to_leaf(
1832 * If the leaf has any stale entries in it, compress them out. 1832 * If the leaf has any stale entries in it, compress them out.
1833 * The compact routine will log the header. 1833 * The compact routine will log the header.
1834 */ 1834 */
1835 if (INT_GET(leaf->hdr.stale, ARCH_CONVERT)) 1835 if (be16_to_cpu(leaf->hdr.stale))
1836 xfs_dir2_leaf_compact(args, lbp); 1836 xfs_dir2_leaf_compact(args, lbp);
1837 else 1837 else
1838 xfs_dir2_leaf_log_header(tp, lbp); 1838 xfs_dir2_leaf_log_header(tp, lbp);
diff --git a/fs/xfs/xfs_dir2_leaf.h b/fs/xfs/xfs_dir2_leaf.h
index fcd3b7dea0f6..a1db51b845b9 100644
--- a/fs/xfs/xfs_dir2_leaf.h
+++ b/fs/xfs/xfs_dir2_leaf.h
@@ -46,8 +46,8 @@ typedef __uint32_t xfs_dir2_dataptr_t;
46 */ 46 */
47typedef struct xfs_dir2_leaf_hdr { 47typedef struct xfs_dir2_leaf_hdr {
48 xfs_da_blkinfo_t info; /* header for da routines */ 48 xfs_da_blkinfo_t info; /* header for da routines */
49 __uint16_t count; /* count of entries */ 49 __be16 count; /* count of entries */
50 __uint16_t stale; /* count of stale entries */ 50 __be16 stale; /* count of stale entries */
51} xfs_dir2_leaf_hdr_t; 51} xfs_dir2_leaf_hdr_t;
52 52
53/* 53/*
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c
index c32894cb6223..40e4a2e27765 100644
--- a/fs/xfs/xfs_dir2_node.c
+++ b/fs/xfs/xfs_dir2_node.c
@@ -217,14 +217,14 @@ xfs_dir2_leafn_add(
217 * a compact. 217 * a compact.
218 */ 218 */
219 219
220 if (INT_GET(leaf->hdr.count, ARCH_CONVERT) == XFS_DIR2_MAX_LEAF_ENTS(mp)) { 220 if (be16_to_cpu(leaf->hdr.count) == XFS_DIR2_MAX_LEAF_ENTS(mp)) {
221 if (!leaf->hdr.stale) 221 if (!leaf->hdr.stale)
222 return XFS_ERROR(ENOSPC); 222 return XFS_ERROR(ENOSPC);
223 compact = INT_GET(leaf->hdr.stale, ARCH_CONVERT) > 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 || INT_GET(leaf->ents[index - 1].hashval, ARCH_CONVERT) <= args->hashval);
227 ASSERT(index == INT_GET(leaf->hdr.count, ARCH_CONVERT) || 227 ASSERT(index == be16_to_cpu(leaf->hdr.count) ||
228 INT_GET(leaf->ents[index].hashval, ARCH_CONVERT) >= args->hashval); 228 INT_GET(leaf->ents[index].hashval, ARCH_CONVERT) >= args->hashval);
229 229
230 if (args->justcheck) 230 if (args->justcheck)
@@ -242,7 +242,7 @@ xfs_dir2_leafn_add(
242 * Set impossible logging indices for this case. 242 * Set impossible logging indices for this case.
243 */ 243 */
244 else if (leaf->hdr.stale) { 244 else if (leaf->hdr.stale) {
245 lfloglow = INT_GET(leaf->hdr.count, ARCH_CONVERT); 245 lfloglow = be16_to_cpu(leaf->hdr.count);
246 lfloghigh = -1; 246 lfloghigh = -1;
247 } 247 }
248 /* 248 /*
@@ -250,12 +250,12 @@ xfs_dir2_leafn_add(
250 */ 250 */
251 if (!leaf->hdr.stale) { 251 if (!leaf->hdr.stale) {
252 lep = &leaf->ents[index]; 252 lep = &leaf->ents[index];
253 if (index < INT_GET(leaf->hdr.count, ARCH_CONVERT)) 253 if (index < be16_to_cpu(leaf->hdr.count))
254 memmove(lep + 1, lep, 254 memmove(lep + 1, lep,
255 (INT_GET(leaf->hdr.count, ARCH_CONVERT) - index) * sizeof(*lep)); 255 (be16_to_cpu(leaf->hdr.count) - index) * sizeof(*lep));
256 lfloglow = index; 256 lfloglow = index;
257 lfloghigh = INT_GET(leaf->hdr.count, ARCH_CONVERT); 257 lfloghigh = be16_to_cpu(leaf->hdr.count);
258 INT_MOD(leaf->hdr.count, ARCH_CONVERT, +1); 258 be16_add(&leaf->hdr.count, 1);
259 } 259 }
260 /* 260 /*
261 * There are stale entries. We'll use one for the new entry. 261 * There are stale entries. We'll use one for the new entry.
@@ -281,7 +281,7 @@ xfs_dir2_leafn_add(
281 * lowstale already found. 281 * lowstale already found.
282 */ 282 */
283 for (highstale = index; 283 for (highstale = index;
284 highstale < INT_GET(leaf->hdr.count, ARCH_CONVERT) && 284 highstale < be16_to_cpu(leaf->hdr.count) &&
285 INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) != 285 INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) !=
286 XFS_DIR2_NULL_DATAPTR && 286 XFS_DIR2_NULL_DATAPTR &&
287 (lowstale < 0 || 287 (lowstale < 0 ||
@@ -294,7 +294,7 @@ xfs_dir2_leafn_add(
294 * Shift entries up toward the stale slot. 294 * Shift entries up toward the stale slot.
295 */ 295 */
296 if (lowstale >= 0 && 296 if (lowstale >= 0 &&
297 (highstale == INT_GET(leaf->hdr.count, ARCH_CONVERT) || 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(INT_GET(leaf->ents[lowstale].address, ARCH_CONVERT) ==
300 XFS_DIR2_NULL_DATAPTR); 300 XFS_DIR2_NULL_DATAPTR);
@@ -323,7 +323,7 @@ xfs_dir2_leafn_add(
323 lfloglow = MIN(index, lfloglow); 323 lfloglow = MIN(index, lfloglow);
324 lfloghigh = MAX(highstale, lfloghigh); 324 lfloghigh = MAX(highstale, lfloghigh);
325 } 325 }
326 INT_MOD(leaf->hdr.stale, ARCH_CONVERT, -1); 326 be16_add(&leaf->hdr.stale, -1);
327 } 327 }
328 /* 328 /*
329 * Insert the new entry, log everything. 329 * Insert the new entry, log everything.
@@ -353,16 +353,16 @@ xfs_dir2_leafn_check(
353 leaf = bp->data; 353 leaf = bp->data;
354 mp = dp->i_mount; 354 mp = dp->i_mount;
355 ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); 355 ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
356 ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) <= XFS_DIR2_MAX_LEAF_ENTS(mp)); 356 ASSERT(be16_to_cpu(leaf->hdr.count) <= XFS_DIR2_MAX_LEAF_ENTS(mp));
357 for (i = stale = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT); i++) { 357 for (i = stale = 0; i < be16_to_cpu(leaf->hdr.count); i++) {
358 if (i + 1 < INT_GET(leaf->hdr.count, ARCH_CONVERT)) { 358 if (i + 1 < be16_to_cpu(leaf->hdr.count)) {
359 ASSERT(INT_GET(leaf->ents[i].hashval, ARCH_CONVERT) <= 359 ASSERT(INT_GET(leaf->ents[i].hashval, ARCH_CONVERT) <=
360 INT_GET(leaf->ents[i + 1].hashval, ARCH_CONVERT)); 360 INT_GET(leaf->ents[i + 1].hashval, ARCH_CONVERT));
361 } 361 }
362 if (INT_GET(leaf->ents[i].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) 362 if (INT_GET(leaf->ents[i].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR)
363 stale++; 363 stale++;
364 } 364 }
365 ASSERT(INT_GET(leaf->hdr.stale, ARCH_CONVERT) == stale); 365 ASSERT(be16_to_cpu(leaf->hdr.stale) == stale);
366} 366}
367#endif /* DEBUG */ 367#endif /* DEBUG */
368 368
@@ -380,10 +380,10 @@ xfs_dir2_leafn_lasthash(
380 leaf = bp->data; 380 leaf = bp->data;
381 ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); 381 ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
382 if (count) 382 if (count)
383 *count = INT_GET(leaf->hdr.count, ARCH_CONVERT); 383 *count = be16_to_cpu(leaf->hdr.count);
384 if (!leaf->hdr.count) 384 if (!leaf->hdr.count)
385 return 0; 385 return 0;
386 return INT_GET(leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT); 386 return INT_GET(leaf->ents[be16_to_cpu(leaf->hdr.count) - 1].hashval, ARCH_CONVERT);
387} 387}
388 388
389/* 389/*
@@ -421,7 +421,7 @@ xfs_dir2_leafn_lookup_int(
421 leaf = bp->data; 421 leaf = bp->data;
422 ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); 422 ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
423#ifdef __KERNEL__ 423#ifdef __KERNEL__
424 ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) > 0); 424 ASSERT(be16_to_cpu(leaf->hdr.count) > 0);
425#endif 425#endif
426 xfs_dir2_leafn_check(dp, bp); 426 xfs_dir2_leafn_check(dp, bp);
427 /* 427 /*
@@ -456,7 +456,7 @@ xfs_dir2_leafn_lookup_int(
456 * Loop over leaf entries with the right hash value. 456 * Loop over leaf entries with the right hash value.
457 */ 457 */
458 for (lep = &leaf->ents[index]; 458 for (lep = &leaf->ents[index];
459 index < INT_GET(leaf->hdr.count, ARCH_CONVERT) && INT_GET(lep->hashval, ARCH_CONVERT) == args->hashval; 459 index < be16_to_cpu(leaf->hdr.count) && INT_GET(lep->hashval, ARCH_CONVERT) == args->hashval;
460 lep++, index++) { 460 lep++, index++) {
461 /* 461 /*
462 * Skip stale leaf entries. 462 * Skip stale leaf entries.
@@ -619,7 +619,7 @@ xfs_dir2_leafn_lookup_int(
619 * Return the final index, that will be the insertion point. 619 * Return the final index, that will be the insertion point.
620 */ 620 */
621 *indexp = index; 621 *indexp = index;
622 ASSERT(index == INT_GET(leaf->hdr.count, ARCH_CONVERT) || args->oknoent); 622 ASSERT(index == be16_to_cpu(leaf->hdr.count) || args->oknoent);
623 return XFS_ERROR(ENOENT); 623 return XFS_ERROR(ENOENT);
624} 624}
625 625
@@ -657,12 +657,12 @@ xfs_dir2_leafn_moveents(
657 * destination leaf entries, open up a hole in the destination 657 * destination leaf entries, open up a hole in the destination
658 * to hold the new entries. 658 * to hold the new entries.
659 */ 659 */
660 if (start_d < INT_GET(leaf_d->hdr.count, ARCH_CONVERT)) { 660 if (start_d < be16_to_cpu(leaf_d->hdr.count)) {
661 memmove(&leaf_d->ents[start_d + count], &leaf_d->ents[start_d], 661 memmove(&leaf_d->ents[start_d + count], &leaf_d->ents[start_d],
662 (INT_GET(leaf_d->hdr.count, ARCH_CONVERT) - start_d) * 662 (be16_to_cpu(leaf_d->hdr.count) - start_d) *
663 sizeof(xfs_dir2_leaf_entry_t)); 663 sizeof(xfs_dir2_leaf_entry_t));
664 xfs_dir2_leaf_log_ents(tp, bp_d, start_d + count, 664 xfs_dir2_leaf_log_ents(tp, bp_d, start_d + count,
665 count + INT_GET(leaf_d->hdr.count, ARCH_CONVERT) - 1); 665 count + be16_to_cpu(leaf_d->hdr.count) - 1);
666 } 666 }
667 /* 667 /*
668 * If the source has stale leaves, count the ones in the copy range 668 * If the source has stale leaves, count the ones in the copy range
@@ -687,7 +687,7 @@ xfs_dir2_leafn_moveents(
687 * If there are source entries after the ones we copied, 687 * If there are source entries after the ones we copied,
688 * delete the ones we copied by sliding the next ones down. 688 * delete the ones we copied by sliding the next ones down.
689 */ 689 */
690 if (start_s + count < INT_GET(leaf_s->hdr.count, ARCH_CONVERT)) { 690 if (start_s + count < be16_to_cpu(leaf_s->hdr.count)) {
691 memmove(&leaf_s->ents[start_s], &leaf_s->ents[start_s + count], 691 memmove(&leaf_s->ents[start_s], &leaf_s->ents[start_s + count],
692 count * sizeof(xfs_dir2_leaf_entry_t)); 692 count * sizeof(xfs_dir2_leaf_entry_t));
693 xfs_dir2_leaf_log_ents(tp, bp_s, start_s, start_s + count - 1); 693 xfs_dir2_leaf_log_ents(tp, bp_s, start_s, start_s + count - 1);
@@ -695,10 +695,10 @@ xfs_dir2_leafn_moveents(
695 /* 695 /*
696 * Update the headers and log them. 696 * Update the headers and log them.
697 */ 697 */
698 INT_MOD(leaf_s->hdr.count, ARCH_CONVERT, -(count)); 698 be16_add(&leaf_s->hdr.count, -(count));
699 INT_MOD(leaf_s->hdr.stale, ARCH_CONVERT, -(stale)); 699 be16_add(&leaf_s->hdr.stale, -(stale));
700 INT_MOD(leaf_d->hdr.count, ARCH_CONVERT, count); 700 be16_add(&leaf_d->hdr.count, count);
701 INT_MOD(leaf_d->hdr.stale, ARCH_CONVERT, stale); 701 be16_add(&leaf_d->hdr.stale, stale);
702 xfs_dir2_leaf_log_header(tp, bp_s); 702 xfs_dir2_leaf_log_header(tp, bp_s);
703 xfs_dir2_leaf_log_header(tp, bp_d); 703 xfs_dir2_leaf_log_header(tp, bp_d);
704 xfs_dir2_leafn_check(args->dp, bp_s); 704 xfs_dir2_leafn_check(args->dp, bp_s);
@@ -721,11 +721,11 @@ xfs_dir2_leafn_order(
721 leaf2 = leaf2_bp->data; 721 leaf2 = leaf2_bp->data;
722 ASSERT(INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); 722 ASSERT(INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
723 ASSERT(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); 723 ASSERT(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
724 if (INT_GET(leaf1->hdr.count, ARCH_CONVERT) > 0 && 724 if (be16_to_cpu(leaf1->hdr.count) > 0 &&
725 INT_GET(leaf2->hdr.count, ARCH_CONVERT) > 0 && 725 be16_to_cpu(leaf2->hdr.count) > 0 &&
726 (INT_GET(leaf2->ents[0].hashval, ARCH_CONVERT) < INT_GET(leaf1->ents[0].hashval, ARCH_CONVERT) || 726 (INT_GET(leaf2->ents[0].hashval, ARCH_CONVERT) < INT_GET(leaf1->ents[0].hashval, ARCH_CONVERT) ||
727 INT_GET(leaf2->ents[INT_GET(leaf2->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT) < 727 INT_GET(leaf2->ents[be16_to_cpu(leaf2->hdr.count) - 1].hashval, ARCH_CONVERT) <
728 INT_GET(leaf1->ents[INT_GET(leaf1->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT))) 728 INT_GET(leaf1->ents[be16_to_cpu(leaf1->hdr.count) - 1].hashval, ARCH_CONVERT)))
729 return 1; 729 return 1;
730 return 0; 730 return 0;
731} 731}
@@ -768,9 +768,9 @@ xfs_dir2_leafn_rebalance(
768 } 768 }
769 leaf1 = blk1->bp->data; 769 leaf1 = blk1->bp->data;
770 leaf2 = blk2->bp->data; 770 leaf2 = blk2->bp->data;
771 oldsum = INT_GET(leaf1->hdr.count, ARCH_CONVERT) + INT_GET(leaf2->hdr.count, ARCH_CONVERT); 771 oldsum = be16_to_cpu(leaf1->hdr.count) + be16_to_cpu(leaf2->hdr.count);
772#ifdef DEBUG 772#ifdef DEBUG
773 oldstale = INT_GET(leaf1->hdr.stale, ARCH_CONVERT) + INT_GET(leaf2->hdr.stale, ARCH_CONVERT); 773 oldstale = be16_to_cpu(leaf1->hdr.stale) + be16_to_cpu(leaf2->hdr.stale);
774#endif 774#endif
775 mid = oldsum >> 1; 775 mid = oldsum >> 1;
776 /* 776 /*
@@ -780,8 +780,8 @@ xfs_dir2_leafn_rebalance(
780 if (oldsum & 1) { 780 if (oldsum & 1) {
781 xfs_dahash_t midhash; /* middle entry hash value */ 781 xfs_dahash_t midhash; /* middle entry hash value */
782 782
783 if (mid >= INT_GET(leaf1->hdr.count, ARCH_CONVERT)) 783 if (mid >= be16_to_cpu(leaf1->hdr.count))
784 midhash = INT_GET(leaf2->ents[mid - INT_GET(leaf1->hdr.count, ARCH_CONVERT)].hashval, ARCH_CONVERT); 784 midhash = INT_GET(leaf2->ents[mid - be16_to_cpu(leaf1->hdr.count)].hashval, ARCH_CONVERT);
785 else 785 else
786 midhash = INT_GET(leaf1->ents[mid].hashval, ARCH_CONVERT); 786 midhash = INT_GET(leaf1->ents[mid].hashval, ARCH_CONVERT);
787 isleft = args->hashval <= midhash; 787 isleft = args->hashval <= midhash;
@@ -797,30 +797,30 @@ xfs_dir2_leafn_rebalance(
797 * Calculate moved entry count. Positive means left-to-right, 797 * Calculate moved entry count. Positive means left-to-right,
798 * negative means right-to-left. Then move the entries. 798 * negative means right-to-left. Then move the entries.
799 */ 799 */
800 count = INT_GET(leaf1->hdr.count, ARCH_CONVERT) - mid + (isleft == 0); 800 count = be16_to_cpu(leaf1->hdr.count) - mid + (isleft == 0);
801 if (count > 0) 801 if (count > 0)
802 xfs_dir2_leafn_moveents(args, blk1->bp, 802 xfs_dir2_leafn_moveents(args, blk1->bp,
803 INT_GET(leaf1->hdr.count, ARCH_CONVERT) - count, blk2->bp, 0, count); 803 be16_to_cpu(leaf1->hdr.count) - count, blk2->bp, 0, count);
804 else if (count < 0) 804 else if (count < 0)
805 xfs_dir2_leafn_moveents(args, blk2->bp, 0, blk1->bp, 805 xfs_dir2_leafn_moveents(args, blk2->bp, 0, blk1->bp,
806 INT_GET(leaf1->hdr.count, ARCH_CONVERT), count); 806 be16_to_cpu(leaf1->hdr.count), count);
807 ASSERT(INT_GET(leaf1->hdr.count, ARCH_CONVERT) + INT_GET(leaf2->hdr.count, ARCH_CONVERT) == oldsum); 807 ASSERT(be16_to_cpu(leaf1->hdr.count) + be16_to_cpu(leaf2->hdr.count) == oldsum);
808 ASSERT(INT_GET(leaf1->hdr.stale, ARCH_CONVERT) + INT_GET(leaf2->hdr.stale, ARCH_CONVERT) == oldstale); 808 ASSERT(be16_to_cpu(leaf1->hdr.stale) + be16_to_cpu(leaf2->hdr.stale) == oldstale);
809 /* 809 /*
810 * Mark whether we're inserting into the old or new leaf. 810 * Mark whether we're inserting into the old or new leaf.
811 */ 811 */
812 if (INT_GET(leaf1->hdr.count, ARCH_CONVERT) < INT_GET(leaf2->hdr.count, ARCH_CONVERT)) 812 if (be16_to_cpu(leaf1->hdr.count) < be16_to_cpu(leaf2->hdr.count))
813 state->inleaf = swap; 813 state->inleaf = swap;
814 else if (INT_GET(leaf1->hdr.count, ARCH_CONVERT) > INT_GET(leaf2->hdr.count, ARCH_CONVERT)) 814 else if (be16_to_cpu(leaf1->hdr.count) > be16_to_cpu(leaf2->hdr.count))
815 state->inleaf = !swap; 815 state->inleaf = !swap;
816 else 816 else
817 state->inleaf = 817 state->inleaf =
818 swap ^ (blk1->index <= INT_GET(leaf1->hdr.count, ARCH_CONVERT)); 818 swap ^ (blk1->index <= be16_to_cpu(leaf1->hdr.count));
819 /* 819 /*
820 * Adjust the expected index for insertion. 820 * Adjust the expected index for insertion.
821 */ 821 */
822 if (!state->inleaf) 822 if (!state->inleaf)
823 blk2->index = blk1->index - INT_GET(leaf1->hdr.count, ARCH_CONVERT); 823 blk2->index = blk1->index - be16_to_cpu(leaf1->hdr.count);
824 824
825 /* 825 /*
826 * Finally sanity check just to make sure we are not returning a negative index 826 * Finally sanity check just to make sure we are not returning a negative index
@@ -883,7 +883,7 @@ xfs_dir2_leafn_remove(
883 * Kill the leaf entry by marking it stale. 883 * Kill the leaf entry by marking it stale.
884 * Log the leaf block changes. 884 * Log the leaf block changes.
885 */ 885 */
886 INT_MOD(leaf->hdr.stale, ARCH_CONVERT, +1); 886 be16_add(&leaf->hdr.stale, 1);
887 xfs_dir2_leaf_log_header(tp, bp); 887 xfs_dir2_leaf_log_header(tp, bp);
888 INT_SET(lep->address, ARCH_CONVERT, XFS_DIR2_NULL_DATAPTR); 888 INT_SET(lep->address, ARCH_CONVERT, XFS_DIR2_NULL_DATAPTR);
889 xfs_dir2_leaf_log_ents(tp, bp, index, index); 889 xfs_dir2_leaf_log_ents(tp, bp, index, index);
@@ -1039,7 +1039,7 @@ xfs_dir2_leafn_remove(
1039 *rval = 1039 *rval =
1040 ((uint)sizeof(leaf->hdr) + 1040 ((uint)sizeof(leaf->hdr) +
1041 (uint)sizeof(leaf->ents[0]) * 1041 (uint)sizeof(leaf->ents[0]) *
1042 (INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT))) < 1042 (be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale))) <
1043 mp->m_dir_magicpct; 1043 mp->m_dir_magicpct;
1044 return 0; 1044 return 0;
1045} 1045}
@@ -1140,7 +1140,7 @@ xfs_dir2_leafn_toosmall(
1140 info = blk->bp->data; 1140 info = blk->bp->data;
1141 ASSERT(INT_GET(info->magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); 1141 ASSERT(INT_GET(info->magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
1142 leaf = (xfs_dir2_leaf_t *)info; 1142 leaf = (xfs_dir2_leaf_t *)info;
1143 count = INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT); 1143 count = be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale);
1144 bytes = (uint)sizeof(leaf->hdr) + count * (uint)sizeof(leaf->ents[0]); 1144 bytes = (uint)sizeof(leaf->hdr) + count * (uint)sizeof(leaf->ents[0]);
1145 if (bytes > (state->blocksize >> 1)) { 1145 if (bytes > (state->blocksize >> 1)) {
1146 /* 1146 /*
@@ -1194,11 +1194,11 @@ xfs_dir2_leafn_toosmall(
1194 * Count bytes in the two blocks combined. 1194 * Count bytes in the two blocks combined.
1195 */ 1195 */
1196 leaf = (xfs_dir2_leaf_t *)info; 1196 leaf = (xfs_dir2_leaf_t *)info;
1197 count = INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT); 1197 count = be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale);
1198 bytes = state->blocksize - (state->blocksize >> 2); 1198 bytes = state->blocksize - (state->blocksize >> 2);
1199 leaf = bp->data; 1199 leaf = bp->data;
1200 ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); 1200 ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
1201 count += INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT); 1201 count += be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale);
1202 bytes -= count * (uint)sizeof(leaf->ents[0]); 1202 bytes -= count * (uint)sizeof(leaf->ents[0]);
1203 /* 1203 /*
1204 * Fits with at least 25% to spare. 1204 * Fits with at least 25% to spare.
@@ -1262,21 +1262,21 @@ xfs_dir2_leafn_unbalance(
1262 * If there are any stale leaf entries, take this opportunity 1262 * If there are any stale leaf entries, take this opportunity
1263 * to purge them. 1263 * to purge them.
1264 */ 1264 */
1265 if (INT_GET(drop_leaf->hdr.stale, ARCH_CONVERT)) 1265 if (drop_leaf->hdr.stale)
1266 xfs_dir2_leaf_compact(args, drop_blk->bp); 1266 xfs_dir2_leaf_compact(args, drop_blk->bp);
1267 if (INT_GET(save_leaf->hdr.stale, ARCH_CONVERT)) 1267 if (save_leaf->hdr.stale)
1268 xfs_dir2_leaf_compact(args, save_blk->bp); 1268 xfs_dir2_leaf_compact(args, save_blk->bp);
1269 /* 1269 /*
1270 * Move the entries from drop to the appropriate end of save. 1270 * Move the entries from drop to the appropriate end of save.
1271 */ 1271 */
1272 drop_blk->hashval = INT_GET(drop_leaf->ents[INT_GET(drop_leaf->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT); 1272 drop_blk->hashval = INT_GET(drop_leaf->ents[be16_to_cpu(drop_leaf->hdr.count) - 1].hashval, ARCH_CONVERT);
1273 if (xfs_dir2_leafn_order(save_blk->bp, drop_blk->bp)) 1273 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, 1274 xfs_dir2_leafn_moveents(args, drop_blk->bp, 0, save_blk->bp, 0,
1275 INT_GET(drop_leaf->hdr.count, ARCH_CONVERT)); 1275 be16_to_cpu(drop_leaf->hdr.count));
1276 else 1276 else
1277 xfs_dir2_leafn_moveents(args, drop_blk->bp, 0, save_blk->bp, 1277 xfs_dir2_leafn_moveents(args, drop_blk->bp, 0, save_blk->bp,
1278 INT_GET(save_leaf->hdr.count, ARCH_CONVERT), INT_GET(drop_leaf->hdr.count, ARCH_CONVERT)); 1278 be16_to_cpu(save_leaf->hdr.count), be16_to_cpu(drop_leaf->hdr.count));
1279 save_blk->hashval = INT_GET(save_leaf->ents[INT_GET(save_leaf->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT); 1279 save_blk->hashval = INT_GET(save_leaf->ents[be16_to_cpu(save_leaf->hdr.count) - 1].hashval, ARCH_CONVERT);
1280 xfs_dir2_leafn_check(args->dp, save_blk->bp); 1280 xfs_dir2_leafn_check(args->dp, save_blk->bp);
1281} 1281}
1282 1282