aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/xfs_attr.c10
-rw-r--r--fs/xfs/xfs_attr_leaf.c4
-rw-r--r--fs/xfs/xfs_da_btree.c139
-rw-r--r--fs/xfs/xfs_da_btree.h4
-rw-r--r--fs/xfs/xfs_dir.c8
-rw-r--r--fs/xfs/xfs_dir_leaf.c6
6 files changed, 86 insertions, 85 deletions
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c
index 5d61c628d0db..093fac476bda 100644
--- a/fs/xfs/xfs_attr.c
+++ b/fs/xfs/xfs_attr.c
@@ -1825,8 +1825,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
1825 return(XFS_ERROR(EFSCORRUPTED)); 1825 return(XFS_ERROR(EFSCORRUPTED));
1826 } 1826 }
1827 btree = node->btree; 1827 btree = node->btree;
1828 for (i = 0; 1828 for (i = 0; i < be16_to_cpu(node->hdr.count);
1829 i < INT_GET(node->hdr.count, ARCH_CONVERT);
1830 btree++, i++) { 1829 btree++, i++) {
1831 if (cursor->hashval 1830 if (cursor->hashval
1832 <= be32_to_cpu(btree->hashval)) { 1831 <= be32_to_cpu(btree->hashval)) {
@@ -1836,7 +1835,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
1836 break; 1835 break;
1837 } 1836 }
1838 } 1837 }
1839 if (i == INT_GET(node->hdr.count, ARCH_CONVERT)) { 1838 if (i == be16_to_cpu(node->hdr.count)) {
1840 xfs_da_brelse(NULL, bp); 1839 xfs_da_brelse(NULL, bp);
1841 return(0); 1840 return(0);
1842 } 1841 }
@@ -2226,9 +2225,10 @@ xfs_attr_trace_l_cn(char *where, struct xfs_attr_list_context *context,
2226 : 0, 2225 : 0,
2227 (__psunsigned_t)context->dupcnt, 2226 (__psunsigned_t)context->dupcnt,
2228 (__psunsigned_t)context->flags, 2227 (__psunsigned_t)context->flags,
2229 (__psunsigned_t)INT_GET(node->hdr.count, ARCH_CONVERT), 2228 (__psunsigned_t)be16_to_cpu(node->hdr.count),
2230 (__psunsigned_t)be32_to_cpu(node->btree[0].hashval), 2229 (__psunsigned_t)be32_to_cpu(node->btree[0].hashval),
2231 (__psunsigned_t)be32_to_cpu(node->btree[INT_GET(node->hdr.count, ARCH_CONVERT)-1].hashval)); 2230 (__psunsigned_t)be32_to_cpu(node->btree[
2231 be16_to_cpu(node->hdr.count)-1].hashval));
2232} 2232}
2233 2233
2234/* 2234/*
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c
index 70594bceffec..717682747bd2 100644
--- a/fs/xfs/xfs_attr_leaf.c
+++ b/fs/xfs/xfs_attr_leaf.c
@@ -870,7 +870,7 @@ xfs_attr_leaf_to_node(xfs_da_args_t *args)
870 node->btree[0].hashval = 870 node->btree[0].hashval =
871 leaf->entries[be16_to_cpu(leaf->hdr.count)-1 ].hashval; 871 leaf->entries[be16_to_cpu(leaf->hdr.count)-1 ].hashval;
872 node->btree[0].before = cpu_to_be32(blkno); 872 node->btree[0].before = cpu_to_be32(blkno);
873 INT_SET(node->hdr.count, ARCH_CONVERT, 1); 873 node->hdr.count = cpu_to_be16(1);
874 xfs_da_log_buf(args->trans, bp1, 0, XFS_LBSIZE(dp->i_mount) - 1); 874 xfs_da_log_buf(args->trans, bp1, 0, XFS_LBSIZE(dp->i_mount) - 1);
875 error = 0; 875 error = 0;
876out: 876out:
@@ -2804,7 +2804,7 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp,
2804 node = bp->data; 2804 node = bp->data;
2805 ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC); 2805 ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
2806 parent_blkno = xfs_da_blkno(bp); /* save for re-read later */ 2806 parent_blkno = xfs_da_blkno(bp); /* save for re-read later */
2807 count = INT_GET(node->hdr.count, ARCH_CONVERT); 2807 count = be16_to_cpu(node->hdr.count);
2808 if (!count) { 2808 if (!count) {
2809 xfs_da_brelse(*trans, bp); 2809 xfs_da_brelse(*trans, bp);
2810 return(0); 2810 return(0);
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c
index d32670c09f39..4bae3a76c678 100644
--- a/fs/xfs/xfs_da_btree.c
+++ b/fs/xfs/xfs_da_btree.c
@@ -129,7 +129,7 @@ xfs_da_node_create(xfs_da_args_t *args, xfs_dablk_t blkno, int level,
129 node->hdr.info.magic = cpu_to_be16(XFS_DA_NODE_MAGIC); 129 node->hdr.info.magic = cpu_to_be16(XFS_DA_NODE_MAGIC);
130 node->hdr.info.pad = 0; 130 node->hdr.info.pad = 0;
131 node->hdr.count = 0; 131 node->hdr.count = 0;
132 INT_SET(node->hdr.level, ARCH_CONVERT, level); 132 node->hdr.level = cpu_to_be16(level);
133 133
134 xfs_da_log_buf(tp, bp, 134 xfs_da_log_buf(tp, bp,
135 XFS_DA_LOGRANGE(node, &node->hdr, sizeof(node->hdr))); 135 XFS_DA_LOGRANGE(node, &node->hdr, sizeof(node->hdr)));
@@ -360,7 +360,7 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
360 node = bp->data; 360 node = bp->data;
361 oldroot = blk1->bp->data; 361 oldroot = blk1->bp->data;
362 if (be16_to_cpu(oldroot->hdr.info.magic) == XFS_DA_NODE_MAGIC) { 362 if (be16_to_cpu(oldroot->hdr.info.magic) == XFS_DA_NODE_MAGIC) {
363 size = (int)((char *)&oldroot->btree[INT_GET(oldroot->hdr.count, ARCH_CONVERT)] - 363 size = (int)((char *)&oldroot->btree[be16_to_cpu(oldroot->hdr.count)] -
364 (char *)oldroot); 364 (char *)oldroot);
365 } else { 365 } else {
366 ASSERT(XFS_DIR_IS_V2(mp)); 366 ASSERT(XFS_DIR_IS_V2(mp));
@@ -381,7 +381,7 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
381 error = xfs_da_node_create(args, 381 error = xfs_da_node_create(args,
382 args->whichfork == XFS_DATA_FORK && 382 args->whichfork == XFS_DATA_FORK &&
383 XFS_DIR_IS_V2(mp) ? mp->m_dirleafblk : 0, 383 XFS_DIR_IS_V2(mp) ? mp->m_dirleafblk : 0,
384 INT_GET(node->hdr.level, ARCH_CONVERT) + 1, &bp, args->whichfork); 384 be16_to_cpu(node->hdr.level) + 1, &bp, args->whichfork);
385 if (error) 385 if (error)
386 return(error); 386 return(error);
387 node = bp->data; 387 node = bp->data;
@@ -389,7 +389,7 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
389 node->btree[0].before = cpu_to_be32(blk1->blkno); 389 node->btree[0].before = cpu_to_be32(blk1->blkno);
390 node->btree[1].hashval = cpu_to_be32(blk2->hashval); 390 node->btree[1].hashval = cpu_to_be32(blk2->hashval);
391 node->btree[1].before = cpu_to_be32(blk2->blkno); 391 node->btree[1].before = cpu_to_be32(blk2->blkno);
392 INT_SET(node->hdr.count, ARCH_CONVERT, 2); 392 node->hdr.count = cpu_to_be16(2);
393 393
394#ifdef DEBUG 394#ifdef DEBUG
395 if (be16_to_cpu(oldroot->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC) { 395 if (be16_to_cpu(oldroot->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC) {
@@ -435,7 +435,7 @@ xfs_da_node_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
435 /* 435 /*
436 * Do we have to split the node? 436 * Do we have to split the node?
437 */ 437 */
438 if ((INT_GET(node->hdr.count, ARCH_CONVERT) + newcount) > state->node_ents) { 438 if ((be16_to_cpu(node->hdr.count) + newcount) > state->node_ents) {
439 /* 439 /*
440 * Allocate a new node, add to the doubly linked chain of 440 * Allocate a new node, add to the doubly linked chain of
441 * nodes, then move some of our excess entries into it. 441 * nodes, then move some of our excess entries into it.
@@ -472,7 +472,7 @@ xfs_da_node_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
472 * If we had double-split op below us, then add the extra block too. 472 * If we had double-split op below us, then add the extra block too.
473 */ 473 */
474 node = oldblk->bp->data; 474 node = oldblk->bp->data;
475 if (oldblk->index <= INT_GET(node->hdr.count, ARCH_CONVERT)) { 475 if (oldblk->index <= be16_to_cpu(node->hdr.count)) {
476 oldblk->index++; 476 oldblk->index++;
477 xfs_da_node_add(state, oldblk, addblk); 477 xfs_da_node_add(state, oldblk, addblk);
478 if (useextra) { 478 if (useextra) {
@@ -516,17 +516,17 @@ xfs_da_node_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
516 * Figure out how many entries need to move, and in which direction. 516 * Figure out how many entries need to move, and in which direction.
517 * Swap the nodes around if that makes it simpler. 517 * Swap the nodes around if that makes it simpler.
518 */ 518 */
519 if ((INT_GET(node1->hdr.count, ARCH_CONVERT) > 0) && (INT_GET(node2->hdr.count, ARCH_CONVERT) > 0) && 519 if ((be16_to_cpu(node1->hdr.count) > 0) && (be16_to_cpu(node2->hdr.count) > 0) &&
520 ((be32_to_cpu(node2->btree[0].hashval) < be32_to_cpu(node1->btree[0].hashval)) || 520 ((be32_to_cpu(node2->btree[0].hashval) < be32_to_cpu(node1->btree[0].hashval)) ||
521 (be32_to_cpu(node2->btree[INT_GET(node2->hdr.count, ARCH_CONVERT)-1].hashval) < 521 (be32_to_cpu(node2->btree[be16_to_cpu(node2->hdr.count)-1].hashval) <
522 be32_to_cpu(node1->btree[INT_GET(node1->hdr.count, ARCH_CONVERT)-1].hashval)))) { 522 be32_to_cpu(node1->btree[be16_to_cpu(node1->hdr.count)-1].hashval)))) {
523 tmpnode = node1; 523 tmpnode = node1;
524 node1 = node2; 524 node1 = node2;
525 node2 = tmpnode; 525 node2 = tmpnode;
526 } 526 }
527 ASSERT(be16_to_cpu(node1->hdr.info.magic) == XFS_DA_NODE_MAGIC); 527 ASSERT(be16_to_cpu(node1->hdr.info.magic) == XFS_DA_NODE_MAGIC);
528 ASSERT(be16_to_cpu(node2->hdr.info.magic) == XFS_DA_NODE_MAGIC); 528 ASSERT(be16_to_cpu(node2->hdr.info.magic) == XFS_DA_NODE_MAGIC);
529 count = (INT_GET(node1->hdr.count, ARCH_CONVERT) - INT_GET(node2->hdr.count, ARCH_CONVERT)) / 2; 529 count = (be16_to_cpu(node1->hdr.count) - be16_to_cpu(node2->hdr.count)) / 2;
530 if (count == 0) 530 if (count == 0)
531 return; 531 return;
532 tp = state->args->trans; 532 tp = state->args->trans;
@@ -537,7 +537,7 @@ xfs_da_node_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
537 /* 537 /*
538 * Move elements in node2 up to make a hole. 538 * Move elements in node2 up to make a hole.
539 */ 539 */
540 if ((tmp = INT_GET(node2->hdr.count, ARCH_CONVERT)) > 0) { 540 if ((tmp = be16_to_cpu(node2->hdr.count)) > 0) {
541 tmp *= (uint)sizeof(xfs_da_node_entry_t); 541 tmp *= (uint)sizeof(xfs_da_node_entry_t);
542 btree_s = &node2->btree[0]; 542 btree_s = &node2->btree[0];
543 btree_d = &node2->btree[count]; 543 btree_d = &node2->btree[count];
@@ -548,13 +548,12 @@ xfs_da_node_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
548 * Move the req'd B-tree elements from high in node1 to 548 * Move the req'd B-tree elements from high in node1 to
549 * low in node2. 549 * low in node2.
550 */ 550 */
551 INT_MOD(node2->hdr.count, ARCH_CONVERT, count); 551 be16_add(&node2->hdr.count, count);
552 tmp = count * (uint)sizeof(xfs_da_node_entry_t); 552 tmp = count * (uint)sizeof(xfs_da_node_entry_t);
553 btree_s = &node1->btree[INT_GET(node1->hdr.count, ARCH_CONVERT) - count]; 553 btree_s = &node1->btree[be16_to_cpu(node1->hdr.count) - count];
554 btree_d = &node2->btree[0]; 554 btree_d = &node2->btree[0];
555 memcpy(btree_d, btree_s, tmp); 555 memcpy(btree_d, btree_s, tmp);
556 INT_MOD(node1->hdr.count, ARCH_CONVERT, -(count)); 556 be16_add(&node1->hdr.count, -count);
557
558 } else { 557 } else {
559 /* 558 /*
560 * Move the req'd B-tree elements from low in node2 to 559 * Move the req'd B-tree elements from low in node2 to
@@ -563,21 +562,21 @@ xfs_da_node_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
563 count = -count; 562 count = -count;
564 tmp = count * (uint)sizeof(xfs_da_node_entry_t); 563 tmp = count * (uint)sizeof(xfs_da_node_entry_t);
565 btree_s = &node2->btree[0]; 564 btree_s = &node2->btree[0];
566 btree_d = &node1->btree[INT_GET(node1->hdr.count, ARCH_CONVERT)]; 565 btree_d = &node1->btree[be16_to_cpu(node1->hdr.count)];
567 memcpy(btree_d, btree_s, tmp); 566 memcpy(btree_d, btree_s, tmp);
568 INT_MOD(node1->hdr.count, ARCH_CONVERT, count); 567 be16_add(&node1->hdr.count, count);
569 xfs_da_log_buf(tp, blk1->bp, 568 xfs_da_log_buf(tp, blk1->bp,
570 XFS_DA_LOGRANGE(node1, btree_d, tmp)); 569 XFS_DA_LOGRANGE(node1, btree_d, tmp));
571 570
572 /* 571 /*
573 * Move elements in node2 down to fill the hole. 572 * Move elements in node2 down to fill the hole.
574 */ 573 */
575 tmp = INT_GET(node2->hdr.count, ARCH_CONVERT) - count; 574 tmp = be16_to_cpu(node2->hdr.count) - count;
576 tmp *= (uint)sizeof(xfs_da_node_entry_t); 575 tmp *= (uint)sizeof(xfs_da_node_entry_t);
577 btree_s = &node2->btree[count]; 576 btree_s = &node2->btree[count];
578 btree_d = &node2->btree[0]; 577 btree_d = &node2->btree[0];
579 memmove(btree_d, btree_s, tmp); 578 memmove(btree_d, btree_s, tmp);
580 INT_MOD(node2->hdr.count, ARCH_CONVERT, -(count)); 579 be16_add(&node2->hdr.count, -count);
581 } 580 }
582 581
583 /* 582 /*
@@ -588,7 +587,7 @@ xfs_da_node_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
588 xfs_da_log_buf(tp, blk2->bp, 587 xfs_da_log_buf(tp, blk2->bp,
589 XFS_DA_LOGRANGE(node2, &node2->hdr, 588 XFS_DA_LOGRANGE(node2, &node2->hdr,
590 sizeof(node2->hdr) + 589 sizeof(node2->hdr) +
591 sizeof(node2->btree[0]) * INT_GET(node2->hdr.count, ARCH_CONVERT))); 590 sizeof(node2->btree[0]) * be16_to_cpu(node2->hdr.count)));
592 591
593 /* 592 /*
594 * Record the last hashval from each block for upward propagation. 593 * Record the last hashval from each block for upward propagation.
@@ -596,15 +595,15 @@ xfs_da_node_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
596 */ 595 */
597 node1 = blk1->bp->data; 596 node1 = blk1->bp->data;
598 node2 = blk2->bp->data; 597 node2 = blk2->bp->data;
599 blk1->hashval = be32_to_cpu(node1->btree[ INT_GET(node1->hdr.count, ARCH_CONVERT)-1 ].hashval); 598 blk1->hashval = be32_to_cpu(node1->btree[be16_to_cpu(node1->hdr.count)-1].hashval);
600 blk2->hashval = be32_to_cpu(node2->btree[ INT_GET(node2->hdr.count, ARCH_CONVERT)-1 ].hashval); 599 blk2->hashval = be32_to_cpu(node2->btree[be16_to_cpu(node2->hdr.count)-1].hashval);
601 600
602 /* 601 /*
603 * Adjust the expected index for insertion. 602 * Adjust the expected index for insertion.
604 */ 603 */
605 if (blk1->index >= INT_GET(node1->hdr.count, ARCH_CONVERT)) { 604 if (blk1->index >= be16_to_cpu(node1->hdr.count)) {
606 blk2->index = blk1->index - INT_GET(node1->hdr.count, ARCH_CONVERT); 605 blk2->index = blk1->index - be16_to_cpu(node1->hdr.count);
607 blk1->index = INT_GET(node1->hdr.count, ARCH_CONVERT) + 1; /* make it invalid */ 606 blk1->index = be16_to_cpu(node1->hdr.count) + 1; /* make it invalid */
608 } 607 }
609} 608}
610 609
@@ -623,7 +622,7 @@ xfs_da_node_add(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
623 node = oldblk->bp->data; 622 node = oldblk->bp->data;
624 mp = state->mp; 623 mp = state->mp;
625 ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC); 624 ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
626 ASSERT((oldblk->index >= 0) && (oldblk->index <= INT_GET(node->hdr.count, ARCH_CONVERT))); 625 ASSERT((oldblk->index >= 0) && (oldblk->index <= be16_to_cpu(node->hdr.count)));
627 ASSERT(newblk->blkno != 0); 626 ASSERT(newblk->blkno != 0);
628 if (state->args->whichfork == XFS_DATA_FORK && XFS_DIR_IS_V2(mp)) 627 if (state->args->whichfork == XFS_DATA_FORK && XFS_DIR_IS_V2(mp))
629 ASSERT(newblk->blkno >= mp->m_dirleafblk && 628 ASSERT(newblk->blkno >= mp->m_dirleafblk &&
@@ -634,22 +633,22 @@ xfs_da_node_add(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
634 */ 633 */
635 tmp = 0; 634 tmp = 0;
636 btree = &node->btree[ oldblk->index ]; 635 btree = &node->btree[ oldblk->index ];
637 if (oldblk->index < INT_GET(node->hdr.count, ARCH_CONVERT)) { 636 if (oldblk->index < be16_to_cpu(node->hdr.count)) {
638 tmp = (INT_GET(node->hdr.count, ARCH_CONVERT) - oldblk->index) * (uint)sizeof(*btree); 637 tmp = (be16_to_cpu(node->hdr.count) - oldblk->index) * (uint)sizeof(*btree);
639 memmove(btree + 1, btree, tmp); 638 memmove(btree + 1, btree, tmp);
640 } 639 }
641 btree->hashval = cpu_to_be32(newblk->hashval); 640 btree->hashval = cpu_to_be32(newblk->hashval);
642 btree->before = cpu_to_be32(newblk->blkno); 641 btree->before = cpu_to_be32(newblk->blkno);
643 xfs_da_log_buf(state->args->trans, oldblk->bp, 642 xfs_da_log_buf(state->args->trans, oldblk->bp,
644 XFS_DA_LOGRANGE(node, btree, tmp + sizeof(*btree))); 643 XFS_DA_LOGRANGE(node, btree, tmp + sizeof(*btree)));
645 INT_MOD(node->hdr.count, ARCH_CONVERT, +1); 644 be16_add(&node->hdr.count, 1);
646 xfs_da_log_buf(state->args->trans, oldblk->bp, 645 xfs_da_log_buf(state->args->trans, oldblk->bp,
647 XFS_DA_LOGRANGE(node, &node->hdr, sizeof(node->hdr))); 646 XFS_DA_LOGRANGE(node, &node->hdr, sizeof(node->hdr)));
648 647
649 /* 648 /*
650 * Copy the last hash value from the oldblk to propagate upwards. 649 * Copy the last hash value from the oldblk to propagate upwards.
651 */ 650 */
652 oldblk->hashval = be32_to_cpu(node->btree[ INT_GET(node->hdr.count, ARCH_CONVERT)-1 ].hashval); 651 oldblk->hashval = be32_to_cpu(node->btree[be16_to_cpu(node->hdr.count)-1 ].hashval);
653} 652}
654 653
655/*======================================================================== 654/*========================================================================
@@ -775,7 +774,7 @@ xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk)
775 /* 774 /*
776 * If the root has more than one child, then don't do anything. 775 * If the root has more than one child, then don't do anything.
777 */ 776 */
778 if (INT_GET(oldroot->hdr.count, ARCH_CONVERT) > 1) 777 if (be16_to_cpu(oldroot->hdr.count) > 1)
779 return(0); 778 return(0);
780 779
781 /* 780 /*
@@ -790,7 +789,7 @@ xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk)
790 return(error); 789 return(error);
791 ASSERT(bp != NULL); 790 ASSERT(bp != NULL);
792 blkinfo = bp->data; 791 blkinfo = bp->data;
793 if (INT_GET(oldroot->hdr.level, ARCH_CONVERT) == 1) { 792 if (be16_to_cpu(oldroot->hdr.level) == 1) {
794 ASSERT(be16_to_cpu(blkinfo->magic) == XFS_DIRX_LEAF_MAGIC(state->mp) || 793 ASSERT(be16_to_cpu(blkinfo->magic) == XFS_DIRX_LEAF_MAGIC(state->mp) ||
795 be16_to_cpu(blkinfo->magic) == XFS_ATTR_LEAF_MAGIC); 794 be16_to_cpu(blkinfo->magic) == XFS_ATTR_LEAF_MAGIC);
796 } else { 795 } else {
@@ -832,7 +831,7 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action)
832 info = blk->bp->data; 831 info = blk->bp->data;
833 ASSERT(be16_to_cpu(info->magic) == XFS_DA_NODE_MAGIC); 832 ASSERT(be16_to_cpu(info->magic) == XFS_DA_NODE_MAGIC);
834 node = (xfs_da_intnode_t *)info; 833 node = (xfs_da_intnode_t *)info;
835 count = INT_GET(node->hdr.count, ARCH_CONVERT); 834 count = be16_to_cpu(node->hdr.count);
836 if (count > (state->node_ents >> 1)) { 835 if (count > (state->node_ents >> 1)) {
837 *action = 0; /* blk over 50%, don't try to join */ 836 *action = 0; /* blk over 50%, don't try to join */
838 return(0); /* blk over 50%, don't try to join */ 837 return(0); /* blk over 50%, don't try to join */
@@ -888,10 +887,10 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action)
888 node = (xfs_da_intnode_t *)info; 887 node = (xfs_da_intnode_t *)info;
889 count = state->node_ents; 888 count = state->node_ents;
890 count -= state->node_ents >> 2; 889 count -= state->node_ents >> 2;
891 count -= INT_GET(node->hdr.count, ARCH_CONVERT); 890 count -= be16_to_cpu(node->hdr.count);
892 node = bp->data; 891 node = bp->data;
893 ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC); 892 ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
894 count -= INT_GET(node->hdr.count, ARCH_CONVERT); 893 count -= be16_to_cpu(node->hdr.count);
895 xfs_da_brelse(state->args->trans, bp); 894 xfs_da_brelse(state->args->trans, bp);
896 if (count >= 0) 895 if (count >= 0)
897 break; /* fits with at least 25% to spare */ 896 break; /* fits with at least 25% to spare */
@@ -981,7 +980,7 @@ xfs_da_fixhashpath(xfs_da_state_t *state, xfs_da_state_path_t *path)
981 xfs_da_log_buf(state->args->trans, blk->bp, 980 xfs_da_log_buf(state->args->trans, blk->bp,
982 XFS_DA_LOGRANGE(node, btree, sizeof(*btree))); 981 XFS_DA_LOGRANGE(node, btree, sizeof(*btree)));
983 982
984 lasthash = be32_to_cpu(node->btree[ INT_GET(node->hdr.count, ARCH_CONVERT)-1 ].hashval); 983 lasthash = be32_to_cpu(node->btree[be16_to_cpu(node->hdr.count)-1].hashval);
985 } 984 }
986} 985}
987 986
@@ -996,25 +995,25 @@ xfs_da_node_remove(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk)
996 int tmp; 995 int tmp;
997 996
998 node = drop_blk->bp->data; 997 node = drop_blk->bp->data;
999 ASSERT(drop_blk->index < INT_GET(node->hdr.count, ARCH_CONVERT)); 998 ASSERT(drop_blk->index < be16_to_cpu(node->hdr.count));
1000 ASSERT(drop_blk->index >= 0); 999 ASSERT(drop_blk->index >= 0);
1001 1000
1002 /* 1001 /*
1003 * Copy over the offending entry, or just zero it out. 1002 * Copy over the offending entry, or just zero it out.
1004 */ 1003 */
1005 btree = &node->btree[drop_blk->index]; 1004 btree = &node->btree[drop_blk->index];
1006 if (drop_blk->index < (INT_GET(node->hdr.count, ARCH_CONVERT)-1)) { 1005 if (drop_blk->index < (be16_to_cpu(node->hdr.count)-1)) {
1007 tmp = INT_GET(node->hdr.count, ARCH_CONVERT) - drop_blk->index - 1; 1006 tmp = be16_to_cpu(node->hdr.count) - drop_blk->index - 1;
1008 tmp *= (uint)sizeof(xfs_da_node_entry_t); 1007 tmp *= (uint)sizeof(xfs_da_node_entry_t);
1009 memmove(btree, btree + 1, tmp); 1008 memmove(btree, btree + 1, tmp);
1010 xfs_da_log_buf(state->args->trans, drop_blk->bp, 1009 xfs_da_log_buf(state->args->trans, drop_blk->bp,
1011 XFS_DA_LOGRANGE(node, btree, tmp)); 1010 XFS_DA_LOGRANGE(node, btree, tmp));
1012 btree = &node->btree[ INT_GET(node->hdr.count, ARCH_CONVERT)-1 ]; 1011 btree = &node->btree[be16_to_cpu(node->hdr.count)-1];
1013 } 1012 }
1014 memset((char *)btree, 0, sizeof(xfs_da_node_entry_t)); 1013 memset((char *)btree, 0, sizeof(xfs_da_node_entry_t));
1015 xfs_da_log_buf(state->args->trans, drop_blk->bp, 1014 xfs_da_log_buf(state->args->trans, drop_blk->bp,
1016 XFS_DA_LOGRANGE(node, btree, sizeof(*btree))); 1015 XFS_DA_LOGRANGE(node, btree, sizeof(*btree)));
1017 INT_MOD(node->hdr.count, ARCH_CONVERT, -1); 1016 be16_add(&node->hdr.count, -1);
1018 xfs_da_log_buf(state->args->trans, drop_blk->bp, 1017 xfs_da_log_buf(state->args->trans, drop_blk->bp,
1019 XFS_DA_LOGRANGE(node, &node->hdr, sizeof(node->hdr))); 1018 XFS_DA_LOGRANGE(node, &node->hdr, sizeof(node->hdr)));
1020 1019
@@ -1049,31 +1048,31 @@ xfs_da_node_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1049 * elements in the remaining block up to make a hole. 1048 * elements in the remaining block up to make a hole.
1050 */ 1049 */
1051 if ((be32_to_cpu(drop_node->btree[0].hashval) < be32_to_cpu(save_node->btree[ 0 ].hashval)) || 1050 if ((be32_to_cpu(drop_node->btree[0].hashval) < be32_to_cpu(save_node->btree[ 0 ].hashval)) ||
1052 (be32_to_cpu(drop_node->btree[INT_GET(drop_node->hdr.count, ARCH_CONVERT)-1].hashval) < 1051 (be32_to_cpu(drop_node->btree[be16_to_cpu(drop_node->hdr.count)-1].hashval) <
1053 be32_to_cpu(save_node->btree[INT_GET(save_node->hdr.count, ARCH_CONVERT)-1 ].hashval))) 1052 be32_to_cpu(save_node->btree[be16_to_cpu(save_node->hdr.count)-1].hashval)))
1054 { 1053 {
1055 btree = &save_node->btree[ INT_GET(drop_node->hdr.count, ARCH_CONVERT) ]; 1054 btree = &save_node->btree[be16_to_cpu(drop_node->hdr.count)];
1056 tmp = INT_GET(save_node->hdr.count, ARCH_CONVERT) * (uint)sizeof(xfs_da_node_entry_t); 1055 tmp = be16_to_cpu(save_node->hdr.count) * (uint)sizeof(xfs_da_node_entry_t);
1057 memmove(btree, &save_node->btree[0], tmp); 1056 memmove(btree, &save_node->btree[0], tmp);
1058 btree = &save_node->btree[0]; 1057 btree = &save_node->btree[0];
1059 xfs_da_log_buf(tp, save_blk->bp, 1058 xfs_da_log_buf(tp, save_blk->bp,
1060 XFS_DA_LOGRANGE(save_node, btree, 1059 XFS_DA_LOGRANGE(save_node, btree,
1061 (INT_GET(save_node->hdr.count, ARCH_CONVERT) + INT_GET(drop_node->hdr.count, ARCH_CONVERT)) * 1060 (be16_to_cpu(save_node->hdr.count) + be16_to_cpu(drop_node->hdr.count)) *
1062 sizeof(xfs_da_node_entry_t))); 1061 sizeof(xfs_da_node_entry_t)));
1063 } else { 1062 } else {
1064 btree = &save_node->btree[ INT_GET(save_node->hdr.count, ARCH_CONVERT) ]; 1063 btree = &save_node->btree[be16_to_cpu(save_node->hdr.count)];
1065 xfs_da_log_buf(tp, save_blk->bp, 1064 xfs_da_log_buf(tp, save_blk->bp,
1066 XFS_DA_LOGRANGE(save_node, btree, 1065 XFS_DA_LOGRANGE(save_node, btree,
1067 INT_GET(drop_node->hdr.count, ARCH_CONVERT) * 1066 be16_to_cpu(drop_node->hdr.count) *
1068 sizeof(xfs_da_node_entry_t))); 1067 sizeof(xfs_da_node_entry_t)));
1069 } 1068 }
1070 1069
1071 /* 1070 /*
1072 * Move all the B-tree elements from drop_blk to save_blk. 1071 * Move all the B-tree elements from drop_blk to save_blk.
1073 */ 1072 */
1074 tmp = INT_GET(drop_node->hdr.count, ARCH_CONVERT) * (uint)sizeof(xfs_da_node_entry_t); 1073 tmp = be16_to_cpu(drop_node->hdr.count) * (uint)sizeof(xfs_da_node_entry_t);
1075 memcpy(btree, &drop_node->btree[0], tmp); 1074 memcpy(btree, &drop_node->btree[0], tmp);
1076 INT_MOD(save_node->hdr.count, ARCH_CONVERT, INT_GET(drop_node->hdr.count, ARCH_CONVERT)); 1075 be16_add(&save_node->hdr.count, be16_to_cpu(drop_node->hdr.count));
1077 1076
1078 xfs_da_log_buf(tp, save_blk->bp, 1077 xfs_da_log_buf(tp, save_blk->bp,
1079 XFS_DA_LOGRANGE(save_node, &save_node->hdr, 1078 XFS_DA_LOGRANGE(save_node, &save_node->hdr,
@@ -1082,7 +1081,7 @@ xfs_da_node_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1082 /* 1081 /*
1083 * Save the last hashval in the remaining block for upward propagation. 1082 * Save the last hashval in the remaining block for upward propagation.
1084 */ 1083 */
1085 save_blk->hashval = be32_to_cpu(save_node->btree[ INT_GET(save_node->hdr.count, ARCH_CONVERT)-1 ].hashval); 1084 save_blk->hashval = be32_to_cpu(save_node->btree[be16_to_cpu(save_node->hdr.count)-1].hashval);
1086} 1085}
1087 1086
1088/*======================================================================== 1087/*========================================================================
@@ -1147,12 +1146,12 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result)
1147 blk->magic = be16_to_cpu(curr->magic); 1146 blk->magic = be16_to_cpu(curr->magic);
1148 if (blk->magic == XFS_DA_NODE_MAGIC) { 1147 if (blk->magic == XFS_DA_NODE_MAGIC) {
1149 node = blk->bp->data; 1148 node = blk->bp->data;
1150 blk->hashval = be32_to_cpu(node->btree[INT_GET(node->hdr.count, ARCH_CONVERT)-1].hashval); 1149 blk->hashval = be32_to_cpu(node->btree[be16_to_cpu(node->hdr.count)-1].hashval);
1151 1150
1152 /* 1151 /*
1153 * Binary search. (note: small blocks will skip loop) 1152 * Binary search. (note: small blocks will skip loop)
1154 */ 1153 */
1155 max = INT_GET(node->hdr.count, ARCH_CONVERT); 1154 max = be16_to_cpu(node->hdr.count);
1156 probe = span = max / 2; 1155 probe = span = max / 2;
1157 hashval = args->hashval; 1156 hashval = args->hashval;
1158 for (btree = &node->btree[probe]; span > 4; 1157 for (btree = &node->btree[probe]; span > 4;
@@ -1358,11 +1357,11 @@ xfs_da_node_order(xfs_dabuf_t *node1_bp, xfs_dabuf_t *node2_bp)
1358 node2 = node2_bp->data; 1357 node2 = node2_bp->data;
1359 ASSERT((be16_to_cpu(node1->hdr.info.magic) == XFS_DA_NODE_MAGIC) && 1358 ASSERT((be16_to_cpu(node1->hdr.info.magic) == XFS_DA_NODE_MAGIC) &&
1360 (be16_to_cpu(node2->hdr.info.magic) == XFS_DA_NODE_MAGIC)); 1359 (be16_to_cpu(node2->hdr.info.magic) == XFS_DA_NODE_MAGIC));
1361 if ((INT_GET(node1->hdr.count, ARCH_CONVERT) > 0) && (INT_GET(node2->hdr.count, ARCH_CONVERT) > 0) && 1360 if ((be16_to_cpu(node1->hdr.count) > 0) && (be16_to_cpu(node2->hdr.count) > 0) &&
1362 ((be32_to_cpu(node2->btree[0].hashval) < 1361 ((be32_to_cpu(node2->btree[0].hashval) <
1363 be32_to_cpu(node1->btree[0].hashval)) || 1362 be32_to_cpu(node1->btree[0].hashval)) ||
1364 (be32_to_cpu(node2->btree[INT_GET(node2->hdr.count, ARCH_CONVERT)-1].hashval) < 1363 (be32_to_cpu(node2->btree[be16_to_cpu(node2->hdr.count)-1].hashval) <
1365 be32_to_cpu(node1->btree[INT_GET(node1->hdr.count, ARCH_CONVERT)-1].hashval)))) { 1364 be32_to_cpu(node1->btree[be16_to_cpu(node1->hdr.count)-1].hashval)))) {
1366 return(1); 1365 return(1);
1367 } 1366 }
1368 return(0); 1367 return(0);
@@ -1379,10 +1378,10 @@ xfs_da_node_lasthash(xfs_dabuf_t *bp, int *count)
1379 node = bp->data; 1378 node = bp->data;
1380 ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC); 1379 ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
1381 if (count) 1380 if (count)
1382 *count = INT_GET(node->hdr.count, ARCH_CONVERT); 1381 *count = be16_to_cpu(node->hdr.count);
1383 if (!node->hdr.count) 1382 if (!node->hdr.count)
1384 return(0); 1383 return(0);
1385 return be32_to_cpu(node->btree[INT_GET(node->hdr.count, ARCH_CONVERT)-1].hashval); 1384 return be32_to_cpu(node->btree[be16_to_cpu(node->hdr.count)-1].hashval);
1386} 1385}
1387 1386
1388/* 1387/*
@@ -1491,7 +1490,7 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path,
1491 ASSERT(blk->bp != NULL); 1490 ASSERT(blk->bp != NULL);
1492 node = blk->bp->data; 1491 node = blk->bp->data;
1493 ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC); 1492 ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
1494 if (forward && (blk->index < INT_GET(node->hdr.count, ARCH_CONVERT)-1)) { 1493 if (forward && (blk->index < be16_to_cpu(node->hdr.count)-1)) {
1495 blk->index++; 1494 blk->index++;
1496 blkno = be32_to_cpu(node->btree[blk->index].before); 1495 blkno = be32_to_cpu(node->btree[blk->index].before);
1497 break; 1496 break;
@@ -1535,11 +1534,11 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path,
1535 blk->magic = be16_to_cpu(info->magic); 1534 blk->magic = be16_to_cpu(info->magic);
1536 if (blk->magic == XFS_DA_NODE_MAGIC) { 1535 if (blk->magic == XFS_DA_NODE_MAGIC) {
1537 node = (xfs_da_intnode_t *)info; 1536 node = (xfs_da_intnode_t *)info;
1538 blk->hashval = be32_to_cpu(node->btree[INT_GET(node->hdr.count, ARCH_CONVERT)-1].hashval); 1537 blk->hashval = be32_to_cpu(node->btree[be16_to_cpu(node->hdr.count)-1].hashval);
1539 if (forward) 1538 if (forward)
1540 blk->index = 0; 1539 blk->index = 0;
1541 else 1540 else
1542 blk->index = INT_GET(node->hdr.count, ARCH_CONVERT)-1; 1541 blk->index = be16_to_cpu(node->hdr.count)-1;
1543 blkno = be32_to_cpu(node->btree[blk->index].before); 1542 blkno = be32_to_cpu(node->btree[blk->index].before);
1544 } else { 1543 } else {
1545 ASSERT(level == path->active-1); 1544 ASSERT(level == path->active-1);
@@ -1795,8 +1794,8 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1795 } else { 1794 } else {
1796 ASSERT(be16_to_cpu(dead_info->magic) == XFS_DA_NODE_MAGIC); 1795 ASSERT(be16_to_cpu(dead_info->magic) == XFS_DA_NODE_MAGIC);
1797 dead_node = (xfs_da_intnode_t *)dead_info; 1796 dead_node = (xfs_da_intnode_t *)dead_info;
1798 dead_level = INT_GET(dead_node->hdr.level, ARCH_CONVERT); 1797 dead_level = be16_to_cpu(dead_node->hdr.level);
1799 dead_hash = be32_to_cpu(dead_node->btree[INT_GET(dead_node->hdr.count, ARCH_CONVERT) - 1].hashval); 1798 dead_hash = be32_to_cpu(dead_node->btree[be16_to_cpu(dead_node->hdr.count) - 1].hashval);
1800 } 1799 }
1801 sib_buf = par_buf = NULL; 1800 sib_buf = par_buf = NULL;
1802 /* 1801 /*
@@ -1854,19 +1853,19 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1854 par_node = par_buf->data; 1853 par_node = par_buf->data;
1855 if (unlikely( 1854 if (unlikely(
1856 be16_to_cpu(par_node->hdr.info.magic) != XFS_DA_NODE_MAGIC || 1855 be16_to_cpu(par_node->hdr.info.magic) != XFS_DA_NODE_MAGIC ||
1857 (level >= 0 && level != INT_GET(par_node->hdr.level, ARCH_CONVERT) + 1))) { 1856 (level >= 0 && level != be16_to_cpu(par_node->hdr.level) + 1))) {
1858 XFS_ERROR_REPORT("xfs_da_swap_lastblock(4)", 1857 XFS_ERROR_REPORT("xfs_da_swap_lastblock(4)",
1859 XFS_ERRLEVEL_LOW, mp); 1858 XFS_ERRLEVEL_LOW, mp);
1860 error = XFS_ERROR(EFSCORRUPTED); 1859 error = XFS_ERROR(EFSCORRUPTED);
1861 goto done; 1860 goto done;
1862 } 1861 }
1863 level = INT_GET(par_node->hdr.level, ARCH_CONVERT); 1862 level = be16_to_cpu(par_node->hdr.level);
1864 for (entno = 0; 1863 for (entno = 0;
1865 entno < INT_GET(par_node->hdr.count, ARCH_CONVERT) && 1864 entno < be16_to_cpu(par_node->hdr.count) &&
1866 be32_to_cpu(par_node->btree[entno].hashval) < dead_hash; 1865 be32_to_cpu(par_node->btree[entno].hashval) < dead_hash;
1867 entno++) 1866 entno++)
1868 continue; 1867 continue;
1869 if (unlikely(entno == INT_GET(par_node->hdr.count, ARCH_CONVERT))) { 1868 if (unlikely(entno == be16_to_cpu(par_node->hdr.count))) {
1870 XFS_ERROR_REPORT("xfs_da_swap_lastblock(5)", 1869 XFS_ERROR_REPORT("xfs_da_swap_lastblock(5)",
1871 XFS_ERRLEVEL_LOW, mp); 1870 XFS_ERRLEVEL_LOW, mp);
1872 error = XFS_ERROR(EFSCORRUPTED); 1871 error = XFS_ERROR(EFSCORRUPTED);
@@ -1884,11 +1883,11 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1884 */ 1883 */
1885 for (;;) { 1884 for (;;) {
1886 for (; 1885 for (;
1887 entno < INT_GET(par_node->hdr.count, ARCH_CONVERT) && 1886 entno < be16_to_cpu(par_node->hdr.count) &&
1888 be32_to_cpu(par_node->btree[entno].before) != last_blkno; 1887 be32_to_cpu(par_node->btree[entno].before) != last_blkno;
1889 entno++) 1888 entno++)
1890 continue; 1889 continue;
1891 if (entno < INT_GET(par_node->hdr.count, ARCH_CONVERT)) 1890 if (entno < be16_to_cpu(par_node->hdr.count))
1892 break; 1891 break;
1893 par_blkno = be32_to_cpu(par_node->hdr.info.forw); 1892 par_blkno = be32_to_cpu(par_node->hdr.info.forw);
1894 xfs_da_brelse(tp, par_buf); 1893 xfs_da_brelse(tp, par_buf);
@@ -1903,7 +1902,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1903 goto done; 1902 goto done;
1904 par_node = par_buf->data; 1903 par_node = par_buf->data;
1905 if (unlikely( 1904 if (unlikely(
1906 INT_GET(par_node->hdr.level, ARCH_CONVERT) != level || 1905 be16_to_cpu(par_node->hdr.level) != level ||
1907 be16_to_cpu(par_node->hdr.info.magic) != XFS_DA_NODE_MAGIC)) { 1906 be16_to_cpu(par_node->hdr.info.magic) != XFS_DA_NODE_MAGIC)) {
1908 XFS_ERROR_REPORT("xfs_da_swap_lastblock(7)", 1907 XFS_ERROR_REPORT("xfs_da_swap_lastblock(7)",
1909 XFS_ERRLEVEL_LOW, mp); 1908 XFS_ERRLEVEL_LOW, mp);
diff --git a/fs/xfs/xfs_da_btree.h b/fs/xfs/xfs_da_btree.h
index 6343c3a4dbae..243a730d5ec8 100644
--- a/fs/xfs/xfs_da_btree.h
+++ b/fs/xfs/xfs_da_btree.h
@@ -65,8 +65,8 @@ typedef struct xfs_da_blkinfo {
65typedef struct xfs_da_intnode { 65typedef struct xfs_da_intnode {
66 struct xfs_da_node_hdr { /* constant-structure header block */ 66 struct xfs_da_node_hdr { /* constant-structure header block */
67 xfs_da_blkinfo_t info; /* block type, links, etc. */ 67 xfs_da_blkinfo_t info; /* block type, links, etc. */
68 __uint16_t count; /* count of active entries */ 68 __be16 count; /* count of active entries */
69 __uint16_t level; /* level above leaves (leaf == 0) */ 69 __be16 level; /* level above leaves (leaf == 0) */
70 } hdr; 70 } hdr;
71 struct xfs_da_node_entry { 71 struct xfs_da_node_entry {
72 __be32 hashval; /* hash value for this descendant */ 72 __be32 hashval; /* hash value for this descendant */
diff --git a/fs/xfs/xfs_dir.c b/fs/xfs/xfs_dir.c
index 8d1975a541b1..9cc702a839a3 100644
--- a/fs/xfs/xfs_dir.c
+++ b/fs/xfs/xfs_dir.c
@@ -953,13 +953,13 @@ xfs_dir_node_getdents(xfs_trans_t *trans, xfs_inode_t *dp, uio_t *uio,
953 break; 953 break;
954 btree = &node->btree[0]; 954 btree = &node->btree[0];
955 xfs_dir_trace_g_dun("node: node detail", dp, uio, node); 955 xfs_dir_trace_g_dun("node: node detail", dp, uio, node);
956 for (i = 0; i < INT_GET(node->hdr.count, ARCH_CONVERT); btree++, i++) { 956 for (i = 0; i < be16_to_cpu(node->hdr.count); btree++, i++) {
957 if (be32_to_cpu(btree->hashval) >= cookhash) { 957 if (be32_to_cpu(btree->hashval) >= cookhash) {
958 bno = be32_to_cpu(btree->before); 958 bno = be32_to_cpu(btree->before);
959 break; 959 break;
960 } 960 }
961 } 961 }
962 if (i == INT_GET(node->hdr.count, ARCH_CONVERT)) { 962 if (i == be16_to_cpu(node->hdr.count)) {
963 xfs_da_brelse(trans, bp); 963 xfs_da_brelse(trans, bp);
964 xfs_dir_trace_g_du("node: hash beyond EOF", 964 xfs_dir_trace_g_du("node: hash beyond EOF",
965 dp, uio); 965 dp, uio);
@@ -1118,7 +1118,7 @@ void
1118xfs_dir_trace_g_dun(char *where, xfs_inode_t *dp, uio_t *uio, 1118xfs_dir_trace_g_dun(char *where, xfs_inode_t *dp, uio_t *uio,
1119 xfs_da_intnode_t *node) 1119 xfs_da_intnode_t *node)
1120{ 1120{
1121 int last = INT_GET(node->hdr.count, ARCH_CONVERT) - 1; 1121 int last = be16_to_cpu(node->hdr.count) - 1;
1122 1122
1123 xfs_dir_trace_enter(XFS_DIR_KTRACE_G_DUN, where, 1123 xfs_dir_trace_enter(XFS_DIR_KTRACE_G_DUN, where,
1124 (void *)dp, (void *)dp->i_mount, 1124 (void *)dp, (void *)dp->i_mount,
@@ -1127,7 +1127,7 @@ xfs_dir_trace_g_dun(char *where, xfs_inode_t *dp, uio_t *uio,
1127 (void *)(unsigned long)uio->uio_resid, 1127 (void *)(unsigned long)uio->uio_resid,
1128 (void *)(unsigned long)be32_to_cpu(node->hdr.info.forw), 1128 (void *)(unsigned long)be32_to_cpu(node->hdr.info.forw),
1129 (void *)(unsigned long) 1129 (void *)(unsigned long)
1130 INT_GET(node->hdr.count, ARCH_CONVERT), 1130 be16_to_cpu(node->hdr.count),
1131 (void *)(unsigned long) 1131 (void *)(unsigned long)
1132 be32_to_cpu(node->btree[0].hashval), 1132 be32_to_cpu(node->btree[0].hashval),
1133 (void *)(unsigned long) 1133 (void *)(unsigned long)
diff --git a/fs/xfs/xfs_dir_leaf.c b/fs/xfs/xfs_dir_leaf.c
index 3c58834fa6a7..ac9ac700acf7 100644
--- a/fs/xfs/xfs_dir_leaf.c
+++ b/fs/xfs/xfs_dir_leaf.c
@@ -743,10 +743,12 @@ xfs_dir_leaf_to_node(xfs_da_args_t *args)
743 node = bp1->data; 743 node = bp1->data;
744 leaf = bp2->data; 744 leaf = bp2->data;
745 ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); 745 ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
746 INT_SET(node->btree[0].hashval, ARCH_CONVERT, INT_GET(leaf->entries[ INT_GET(leaf->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT)); 746 node->btree[0].hashval = cpu_to_be32(
747 INT_GET(leaf->entries[
748 INT_GET(leaf->hdr.count, ARCH_CONVERT)-1].hashval, ARCH_CONVERT));
747 xfs_da_buf_done(bp2); 749 xfs_da_buf_done(bp2);
748 node->btree[0].before = cpu_to_be32(blkno); 750 node->btree[0].before = cpu_to_be32(blkno);
749 INT_SET(node->hdr.count, ARCH_CONVERT, 1); 751 node->hdr.count = cpu_to_be16(1);
750 xfs_da_log_buf(args->trans, bp1, 752 xfs_da_log_buf(args->trans, bp1,
751 XFS_DA_LOGRANGE(node, &node->btree[0], sizeof(node->btree[0]))); 753 XFS_DA_LOGRANGE(node, &node->btree[0], sizeof(node->btree[0])));
752 xfs_da_buf_done(bp1); 754 xfs_da_buf_done(bp1);