aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_da_btree.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_da_btree.c')
-rw-r--r--fs/xfs/xfs_da_btree.c411
1 files changed, 201 insertions, 210 deletions
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c
index 473671fa5c13..8988b9051175 100644
--- a/fs/xfs/xfs_da_btree.c
+++ b/fs/xfs/xfs_da_btree.c
@@ -126,10 +126,10 @@ xfs_da_node_create(xfs_da_args_t *args, xfs_dablk_t blkno, int level,
126 node = bp->data; 126 node = bp->data;
127 node->hdr.info.forw = 0; 127 node->hdr.info.forw = 0;
128 node->hdr.info.back = 0; 128 node->hdr.info.back = 0;
129 INT_SET(node->hdr.info.magic, ARCH_CONVERT, 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)));
@@ -290,28 +290,28 @@ xfs_da_split(xfs_da_state_t *state)
290 290
291 node = oldblk->bp->data; 291 node = oldblk->bp->data;
292 if (node->hdr.info.forw) { 292 if (node->hdr.info.forw) {
293 if (INT_GET(node->hdr.info.forw, ARCH_CONVERT) == addblk->blkno) { 293 if (be32_to_cpu(node->hdr.info.forw) == addblk->blkno) {
294 bp = addblk->bp; 294 bp = addblk->bp;
295 } else { 295 } else {
296 ASSERT(state->extravalid); 296 ASSERT(state->extravalid);
297 bp = state->extrablk.bp; 297 bp = state->extrablk.bp;
298 } 298 }
299 node = bp->data; 299 node = bp->data;
300 INT_SET(node->hdr.info.back, ARCH_CONVERT, oldblk->blkno); 300 node->hdr.info.back = cpu_to_be32(oldblk->blkno);
301 xfs_da_log_buf(state->args->trans, bp, 301 xfs_da_log_buf(state->args->trans, bp,
302 XFS_DA_LOGRANGE(node, &node->hdr.info, 302 XFS_DA_LOGRANGE(node, &node->hdr.info,
303 sizeof(node->hdr.info))); 303 sizeof(node->hdr.info)));
304 } 304 }
305 node = oldblk->bp->data; 305 node = oldblk->bp->data;
306 if (INT_GET(node->hdr.info.back, ARCH_CONVERT)) { 306 if (node->hdr.info.back) {
307 if (INT_GET(node->hdr.info.back, ARCH_CONVERT) == addblk->blkno) { 307 if (be32_to_cpu(node->hdr.info.back) == addblk->blkno) {
308 bp = addblk->bp; 308 bp = addblk->bp;
309 } else { 309 } else {
310 ASSERT(state->extravalid); 310 ASSERT(state->extravalid);
311 bp = state->extrablk.bp; 311 bp = state->extrablk.bp;
312 } 312 }
313 node = bp->data; 313 node = bp->data;
314 INT_SET(node->hdr.info.forw, ARCH_CONVERT, oldblk->blkno); 314 node->hdr.info.forw = cpu_to_be32(oldblk->blkno);
315 xfs_da_log_buf(state->args->trans, bp, 315 xfs_da_log_buf(state->args->trans, bp,
316 XFS_DA_LOGRANGE(node, &node->hdr.info, 316 XFS_DA_LOGRANGE(node, &node->hdr.info,
317 sizeof(node->hdr.info))); 317 sizeof(node->hdr.info)));
@@ -359,14 +359,14 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
359 ASSERT(bp != NULL); 359 ASSERT(bp != NULL);
360 node = bp->data; 360 node = bp->data;
361 oldroot = blk1->bp->data; 361 oldroot = blk1->bp->data;
362 if (INT_GET(oldroot->hdr.info.magic, ARCH_CONVERT) == 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));
367 ASSERT(INT_GET(oldroot->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); 367 ASSERT(be16_to_cpu(oldroot->hdr.info.magic) == 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);
@@ -381,18 +381,18 @@ 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;
388 INT_SET(node->btree[0].hashval, ARCH_CONVERT, blk1->hashval); 388 node->btree[0].hashval = cpu_to_be32(blk1->hashval);
389 INT_SET(node->btree[0].before, ARCH_CONVERT, blk1->blkno); 389 node->btree[0].before = cpu_to_be32(blk1->blkno);
390 INT_SET(node->btree[1].hashval, ARCH_CONVERT, blk2->hashval); 390 node->btree[1].hashval = cpu_to_be32(blk2->hashval);
391 INT_SET(node->btree[1].before, ARCH_CONVERT, 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 (INT_GET(oldroot->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC) { 395 if (be16_to_cpu(oldroot->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC) {
396 ASSERT(blk1->blkno >= mp->m_dirleafblk && 396 ASSERT(blk1->blkno >= mp->m_dirleafblk &&
397 blk1->blkno < mp->m_dirfreeblk); 397 blk1->blkno < mp->m_dirfreeblk);
398 ASSERT(blk2->blkno >= mp->m_dirleafblk && 398 ASSERT(blk2->blkno >= mp->m_dirleafblk &&
@@ -424,7 +424,7 @@ xfs_da_node_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
424 int useextra; 424 int useextra;
425 425
426 node = oldblk->bp->data; 426 node = oldblk->bp->data;
427 ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); 427 ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
428 428
429 /* 429 /*
430 * With V2 the extra block is data or freespace. 430 * With V2 the extra block is data or freespace.
@@ -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 ((INT_GET(node2->btree[ 0 ].hashval, ARCH_CONVERT) < INT_GET(node1->btree[ 0 ].hashval, ARCH_CONVERT)) || 520 ((be32_to_cpu(node2->btree[0].hashval) < be32_to_cpu(node1->btree[0].hashval)) ||
521 (INT_GET(node2->btree[ INT_GET(node2->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT) < 521 (be32_to_cpu(node2->btree[be16_to_cpu(node2->hdr.count)-1].hashval) <
522 INT_GET(node1->btree[ INT_GET(node1->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT)))) { 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(INT_GET(node1->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); 527 ASSERT(be16_to_cpu(node1->hdr.info.magic) == XFS_DA_NODE_MAGIC);
528 ASSERT(INT_GET(node2->hdr.info.magic, ARCH_CONVERT) == 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 = INT_GET(node1->btree[ INT_GET(node1->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT); 598 blk1->hashval = be32_to_cpu(node1->btree[be16_to_cpu(node1->hdr.count)-1].hashval);
600 blk2->hashval = INT_GET(node2->btree[ INT_GET(node2->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT); 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
@@ -622,8 +621,8 @@ xfs_da_node_add(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
622 621
623 node = oldblk->bp->data; 622 node = oldblk->bp->data;
624 mp = state->mp; 623 mp = state->mp;
625 ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT) == 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 INT_SET(btree->hashval, ARCH_CONVERT, newblk->hashval); 640 btree->hashval = cpu_to_be32(newblk->hashval);
642 INT_SET(btree->before, ARCH_CONVERT, 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 = INT_GET(node->btree[ INT_GET(node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT); 651 oldblk->hashval = be32_to_cpu(node->btree[be16_to_cpu(node->hdr.count)-1 ].hashval);
653} 652}
654 653
655/*======================================================================== 654/*========================================================================
@@ -768,21 +767,21 @@ xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk)
768 ASSERT(args != NULL); 767 ASSERT(args != NULL);
769 ASSERT(root_blk->magic == XFS_DA_NODE_MAGIC); 768 ASSERT(root_blk->magic == XFS_DA_NODE_MAGIC);
770 oldroot = root_blk->bp->data; 769 oldroot = root_blk->bp->data;
771 ASSERT(INT_GET(oldroot->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); 770 ASSERT(be16_to_cpu(oldroot->hdr.info.magic) == XFS_DA_NODE_MAGIC);
772 ASSERT(!oldroot->hdr.info.forw); 771 ASSERT(!oldroot->hdr.info.forw);
773 ASSERT(!oldroot->hdr.info.back); 772 ASSERT(!oldroot->hdr.info.back);
774 773
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 /*
782 * Read in the (only) child block, then copy those bytes into 781 * Read in the (only) child block, then copy those bytes into
783 * the root block's buffer and free the original child block. 782 * the root block's buffer and free the original child block.
784 */ 783 */
785 child = INT_GET(oldroot->btree[ 0 ].before, ARCH_CONVERT); 784 child = be32_to_cpu(oldroot->btree[0].before);
786 ASSERT(child != 0); 785 ASSERT(child != 0);
787 error = xfs_da_read_buf(args->trans, args->dp, child, -1, &bp, 786 error = xfs_da_read_buf(args->trans, args->dp, child, -1, &bp,
788 args->whichfork); 787 args->whichfork);
@@ -790,11 +789,11 @@ 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(INT_GET(blkinfo->magic, ARCH_CONVERT) == XFS_DIRX_LEAF_MAGIC(state->mp) || 793 ASSERT(be16_to_cpu(blkinfo->magic) == XFS_DIRX_LEAF_MAGIC(state->mp) ||
795 INT_GET(blkinfo->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC); 794 be16_to_cpu(blkinfo->magic) == XFS_ATTR_LEAF_MAGIC);
796 } else { 795 } else {
797 ASSERT(INT_GET(blkinfo->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); 796 ASSERT(be16_to_cpu(blkinfo->magic) == XFS_DA_NODE_MAGIC);
798 } 797 }
799 ASSERT(!blkinfo->forw); 798 ASSERT(!blkinfo->forw);
800 ASSERT(!blkinfo->back); 799 ASSERT(!blkinfo->back);
@@ -830,9 +829,9 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action)
830 */ 829 */
831 blk = &state->path.blk[ state->path.active-1 ]; 830 blk = &state->path.blk[ state->path.active-1 ];
832 info = blk->bp->data; 831 info = blk->bp->data;
833 ASSERT(INT_GET(info->magic, ARCH_CONVERT) == 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 */
@@ -841,7 +840,7 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action)
841 /* 840 /*
842 * Check for the degenerate case of the block being empty. 841 * Check for the degenerate case of the block being empty.
843 * If the block is empty, we'll simply delete it, no need to 842 * If the block is empty, we'll simply delete it, no need to
844 * coalesce it with a sibling block. We choose (aribtrarily) 843 * coalesce it with a sibling block. We choose (arbitrarily)
845 * to merge with the forward block unless it is NULL. 844 * to merge with the forward block unless it is NULL.
846 */ 845 */
847 if (count == 0) { 846 if (count == 0) {
@@ -849,7 +848,7 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action)
849 * Make altpath point to the block we want to keep and 848 * Make altpath point to the block we want to keep and
850 * path point to the block we want to drop (this one). 849 * path point to the block we want to drop (this one).
851 */ 850 */
852 forward = info->forw; 851 forward = (info->forw != 0);
853 memcpy(&state->altpath, &state->path, sizeof(state->path)); 852 memcpy(&state->altpath, &state->path, sizeof(state->path));
854 error = xfs_da_path_shift(state, &state->altpath, forward, 853 error = xfs_da_path_shift(state, &state->altpath, forward,
855 0, &retval); 854 0, &retval);
@@ -871,13 +870,12 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action)
871 * to shrink a directory over time. 870 * to shrink a directory over time.
872 */ 871 */
873 /* start with smaller blk num */ 872 /* start with smaller blk num */
874 forward = (INT_GET(info->forw, ARCH_CONVERT) 873 forward = (be32_to_cpu(info->forw) < be32_to_cpu(info->back));
875 < INT_GET(info->back, ARCH_CONVERT));
876 for (i = 0; i < 2; forward = !forward, i++) { 874 for (i = 0; i < 2; forward = !forward, i++) {
877 if (forward) 875 if (forward)
878 blkno = INT_GET(info->forw, ARCH_CONVERT); 876 blkno = be32_to_cpu(info->forw);
879 else 877 else
880 blkno = INT_GET(info->back, ARCH_CONVERT); 878 blkno = be32_to_cpu(info->back);
881 if (blkno == 0) 879 if (blkno == 0)
882 continue; 880 continue;
883 error = xfs_da_read_buf(state->args->trans, state->args->dp, 881 error = xfs_da_read_buf(state->args->trans, state->args->dp,
@@ -889,10 +887,10 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action)
889 node = (xfs_da_intnode_t *)info; 887 node = (xfs_da_intnode_t *)info;
890 count = state->node_ents; 888 count = state->node_ents;
891 count -= state->node_ents >> 2; 889 count -= state->node_ents >> 2;
892 count -= INT_GET(node->hdr.count, ARCH_CONVERT); 890 count -= be16_to_cpu(node->hdr.count);
893 node = bp->data; 891 node = bp->data;
894 ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); 892 ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
895 count -= INT_GET(node->hdr.count, ARCH_CONVERT); 893 count -= be16_to_cpu(node->hdr.count);
896 xfs_da_brelse(state->args->trans, bp); 894 xfs_da_brelse(state->args->trans, bp);
897 if (count >= 0) 895 if (count >= 0)
898 break; /* fits with at least 25% to spare */ 896 break; /* fits with at least 25% to spare */
@@ -973,16 +971,16 @@ xfs_da_fixhashpath(xfs_da_state_t *state, xfs_da_state_path_t *path)
973 } 971 }
974 for (blk--, level--; level >= 0; blk--, level--) { 972 for (blk--, level--; level >= 0; blk--, level--) {
975 node = blk->bp->data; 973 node = blk->bp->data;
976 ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); 974 ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
977 btree = &node->btree[ blk->index ]; 975 btree = &node->btree[ blk->index ];
978 if (INT_GET(btree->hashval, ARCH_CONVERT) == lasthash) 976 if (be32_to_cpu(btree->hashval) == lasthash)
979 break; 977 break;
980 blk->hashval = lasthash; 978 blk->hashval = lasthash;
981 INT_SET(btree->hashval, ARCH_CONVERT, lasthash); 979 btree->hashval = cpu_to_be32(lasthash);
982 xfs_da_log_buf(state->args->trans, blk->bp, 980 xfs_da_log_buf(state->args->trans, blk->bp,
983 XFS_DA_LOGRANGE(node, btree, sizeof(*btree))); 981 XFS_DA_LOGRANGE(node, btree, sizeof(*btree)));
984 982
985 lasthash = INT_GET(node->btree[ INT_GET(node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT); 983 lasthash = be32_to_cpu(node->btree[be16_to_cpu(node->hdr.count)-1].hashval);
986 } 984 }
987} 985}
988 986
@@ -997,25 +995,25 @@ xfs_da_node_remove(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk)
997 int tmp; 995 int tmp;
998 996
999 node = drop_blk->bp->data; 997 node = drop_blk->bp->data;
1000 ASSERT(drop_blk->index < INT_GET(node->hdr.count, ARCH_CONVERT)); 998 ASSERT(drop_blk->index < be16_to_cpu(node->hdr.count));
1001 ASSERT(drop_blk->index >= 0); 999 ASSERT(drop_blk->index >= 0);
1002 1000
1003 /* 1001 /*
1004 * Copy over the offending entry, or just zero it out. 1002 * Copy over the offending entry, or just zero it out.
1005 */ 1003 */
1006 btree = &node->btree[drop_blk->index]; 1004 btree = &node->btree[drop_blk->index];
1007 if (drop_blk->index < (INT_GET(node->hdr.count, ARCH_CONVERT)-1)) { 1005 if (drop_blk->index < (be16_to_cpu(node->hdr.count)-1)) {
1008 tmp = INT_GET(node->hdr.count, ARCH_CONVERT) - drop_blk->index - 1; 1006 tmp = be16_to_cpu(node->hdr.count) - drop_blk->index - 1;
1009 tmp *= (uint)sizeof(xfs_da_node_entry_t); 1007 tmp *= (uint)sizeof(xfs_da_node_entry_t);
1010 memmove(btree, btree + 1, tmp); 1008 memmove(btree, btree + 1, tmp);
1011 xfs_da_log_buf(state->args->trans, drop_blk->bp, 1009 xfs_da_log_buf(state->args->trans, drop_blk->bp,
1012 XFS_DA_LOGRANGE(node, btree, tmp)); 1010 XFS_DA_LOGRANGE(node, btree, tmp));
1013 btree = &node->btree[ INT_GET(node->hdr.count, ARCH_CONVERT)-1 ]; 1011 btree = &node->btree[be16_to_cpu(node->hdr.count)-1];
1014 } 1012 }
1015 memset((char *)btree, 0, sizeof(xfs_da_node_entry_t)); 1013 memset((char *)btree, 0, sizeof(xfs_da_node_entry_t));
1016 xfs_da_log_buf(state->args->trans, drop_blk->bp, 1014 xfs_da_log_buf(state->args->trans, drop_blk->bp,
1017 XFS_DA_LOGRANGE(node, btree, sizeof(*btree))); 1015 XFS_DA_LOGRANGE(node, btree, sizeof(*btree)));
1018 INT_MOD(node->hdr.count, ARCH_CONVERT, -1); 1016 be16_add(&node->hdr.count, -1);
1019 xfs_da_log_buf(state->args->trans, drop_blk->bp, 1017 xfs_da_log_buf(state->args->trans, drop_blk->bp,
1020 XFS_DA_LOGRANGE(node, &node->hdr, sizeof(node->hdr))); 1018 XFS_DA_LOGRANGE(node, &node->hdr, sizeof(node->hdr)));
1021 1019
@@ -1023,7 +1021,7 @@ xfs_da_node_remove(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk)
1023 * Copy the last hash value from the block to propagate upwards. 1021 * Copy the last hash value from the block to propagate upwards.
1024 */ 1022 */
1025 btree--; 1023 btree--;
1026 drop_blk->hashval = INT_GET(btree->hashval, ARCH_CONVERT); 1024 drop_blk->hashval = be32_to_cpu(btree->hashval);
1027} 1025}
1028 1026
1029/* 1027/*
@@ -1041,40 +1039,40 @@ xfs_da_node_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1041 1039
1042 drop_node = drop_blk->bp->data; 1040 drop_node = drop_blk->bp->data;
1043 save_node = save_blk->bp->data; 1041 save_node = save_blk->bp->data;
1044 ASSERT(INT_GET(drop_node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); 1042 ASSERT(be16_to_cpu(drop_node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
1045 ASSERT(INT_GET(save_node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); 1043 ASSERT(be16_to_cpu(save_node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
1046 tp = state->args->trans; 1044 tp = state->args->trans;
1047 1045
1048 /* 1046 /*
1049 * If the dying block has lower hashvals, then move all the 1047 * If the dying block has lower hashvals, then move all the
1050 * elements in the remaining block up to make a hole. 1048 * elements in the remaining block up to make a hole.
1051 */ 1049 */
1052 if ((INT_GET(drop_node->btree[ 0 ].hashval, ARCH_CONVERT) < INT_GET(save_node->btree[ 0 ].hashval, ARCH_CONVERT)) || 1050 if ((be32_to_cpu(drop_node->btree[0].hashval) < be32_to_cpu(save_node->btree[ 0 ].hashval)) ||
1053 (INT_GET(drop_node->btree[ INT_GET(drop_node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT) < 1051 (be32_to_cpu(drop_node->btree[be16_to_cpu(drop_node->hdr.count)-1].hashval) <
1054 INT_GET(save_node->btree[ INT_GET(save_node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT))) 1052 be32_to_cpu(save_node->btree[be16_to_cpu(save_node->hdr.count)-1].hashval)))
1055 { 1053 {
1056 btree = &save_node->btree[ INT_GET(drop_node->hdr.count, ARCH_CONVERT) ]; 1054 btree = &save_node->btree[be16_to_cpu(drop_node->hdr.count)];
1057 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);
1058 memmove(btree, &save_node->btree[0], tmp); 1056 memmove(btree, &save_node->btree[0], tmp);
1059 btree = &save_node->btree[0]; 1057 btree = &save_node->btree[0];
1060 xfs_da_log_buf(tp, save_blk->bp, 1058 xfs_da_log_buf(tp, save_blk->bp,
1061 XFS_DA_LOGRANGE(save_node, btree, 1059 XFS_DA_LOGRANGE(save_node, btree,
1062 (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)) *
1063 sizeof(xfs_da_node_entry_t))); 1061 sizeof(xfs_da_node_entry_t)));
1064 } else { 1062 } else {
1065 btree = &save_node->btree[ INT_GET(save_node->hdr.count, ARCH_CONVERT) ]; 1063 btree = &save_node->btree[be16_to_cpu(save_node->hdr.count)];
1066 xfs_da_log_buf(tp, save_blk->bp, 1064 xfs_da_log_buf(tp, save_blk->bp,
1067 XFS_DA_LOGRANGE(save_node, btree, 1065 XFS_DA_LOGRANGE(save_node, btree,
1068 INT_GET(drop_node->hdr.count, ARCH_CONVERT) * 1066 be16_to_cpu(drop_node->hdr.count) *
1069 sizeof(xfs_da_node_entry_t))); 1067 sizeof(xfs_da_node_entry_t)));
1070 } 1068 }
1071 1069
1072 /* 1070 /*
1073 * 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.
1074 */ 1072 */
1075 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);
1076 memcpy(btree, &drop_node->btree[0], tmp); 1074 memcpy(btree, &drop_node->btree[0], tmp);
1077 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));
1078 1076
1079 xfs_da_log_buf(tp, save_blk->bp, 1077 xfs_da_log_buf(tp, save_blk->bp,
1080 XFS_DA_LOGRANGE(save_node, &save_node->hdr, 1078 XFS_DA_LOGRANGE(save_node, &save_node->hdr,
@@ -1083,7 +1081,7 @@ xfs_da_node_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1083 /* 1081 /*
1084 * Save the last hashval in the remaining block for upward propagation. 1082 * Save the last hashval in the remaining block for upward propagation.
1085 */ 1083 */
1086 save_blk->hashval = INT_GET(save_node->btree[ INT_GET(save_node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT); 1084 save_blk->hashval = be32_to_cpu(save_node->btree[be16_to_cpu(save_node->hdr.count)-1].hashval);
1087} 1085}
1088 1086
1089/*======================================================================== 1087/*========================================================================
@@ -1138,46 +1136,46 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result)
1138 return(error); 1136 return(error);
1139 } 1137 }
1140 curr = blk->bp->data; 1138 curr = blk->bp->data;
1141 ASSERT(INT_GET(curr->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC || 1139 ASSERT(be16_to_cpu(curr->magic) == XFS_DA_NODE_MAGIC ||
1142 INT_GET(curr->magic, ARCH_CONVERT) == XFS_DIRX_LEAF_MAGIC(state->mp) || 1140 be16_to_cpu(curr->magic) == XFS_DIRX_LEAF_MAGIC(state->mp) ||
1143 INT_GET(curr->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC); 1141 be16_to_cpu(curr->magic) == XFS_ATTR_LEAF_MAGIC);
1144 1142
1145 /* 1143 /*
1146 * Search an intermediate node for a match. 1144 * Search an intermediate node for a match.
1147 */ 1145 */
1148 blk->magic = INT_GET(curr->magic, ARCH_CONVERT); 1146 blk->magic = be16_to_cpu(curr->magic);
1149 if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC) { 1147 if (blk->magic == XFS_DA_NODE_MAGIC) {
1150 node = blk->bp->data; 1148 node = blk->bp->data;
1151 blk->hashval = INT_GET(node->btree[ INT_GET(node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT); 1149 blk->hashval = be32_to_cpu(node->btree[be16_to_cpu(node->hdr.count)-1].hashval);
1152 1150
1153 /* 1151 /*
1154 * Binary search. (note: small blocks will skip loop) 1152 * Binary search. (note: small blocks will skip loop)
1155 */ 1153 */
1156 max = INT_GET(node->hdr.count, ARCH_CONVERT); 1154 max = be16_to_cpu(node->hdr.count);
1157 probe = span = max / 2; 1155 probe = span = max / 2;
1158 hashval = args->hashval; 1156 hashval = args->hashval;
1159 for (btree = &node->btree[probe]; span > 4; 1157 for (btree = &node->btree[probe]; span > 4;
1160 btree = &node->btree[probe]) { 1158 btree = &node->btree[probe]) {
1161 span /= 2; 1159 span /= 2;
1162 if (INT_GET(btree->hashval, ARCH_CONVERT) < hashval) 1160 if (be32_to_cpu(btree->hashval) < hashval)
1163 probe += span; 1161 probe += span;
1164 else if (INT_GET(btree->hashval, ARCH_CONVERT) > hashval) 1162 else if (be32_to_cpu(btree->hashval) > hashval)
1165 probe -= span; 1163 probe -= span;
1166 else 1164 else
1167 break; 1165 break;
1168 } 1166 }
1169 ASSERT((probe >= 0) && (probe < max)); 1167 ASSERT((probe >= 0) && (probe < max));
1170 ASSERT((span <= 4) || (INT_GET(btree->hashval, ARCH_CONVERT) == hashval)); 1168 ASSERT((span <= 4) || (be32_to_cpu(btree->hashval) == hashval));
1171 1169
1172 /* 1170 /*
1173 * Since we may have duplicate hashval's, find the first 1171 * Since we may have duplicate hashval's, find the first
1174 * matching hashval in the node. 1172 * matching hashval in the node.
1175 */ 1173 */
1176 while ((probe > 0) && (INT_GET(btree->hashval, ARCH_CONVERT) >= hashval)) { 1174 while ((probe > 0) && (be32_to_cpu(btree->hashval) >= hashval)) {
1177 btree--; 1175 btree--;
1178 probe--; 1176 probe--;
1179 } 1177 }
1180 while ((probe < max) && (INT_GET(btree->hashval, ARCH_CONVERT) < hashval)) { 1178 while ((probe < max) && (be32_to_cpu(btree->hashval) < hashval)) {
1181 btree++; 1179 btree++;
1182 probe++; 1180 probe++;
1183 } 1181 }
@@ -1187,21 +1185,21 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result)
1187 */ 1185 */
1188 if (probe == max) { 1186 if (probe == max) {
1189 blk->index = max-1; 1187 blk->index = max-1;
1190 blkno = INT_GET(node->btree[ max-1 ].before, ARCH_CONVERT); 1188 blkno = be32_to_cpu(node->btree[max-1].before);
1191 } else { 1189 } else {
1192 blk->index = probe; 1190 blk->index = probe;
1193 blkno = INT_GET(btree->before, ARCH_CONVERT); 1191 blkno = be32_to_cpu(btree->before);
1194 } 1192 }
1195 } 1193 }
1196 else if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC) { 1194 else if (be16_to_cpu(curr->magic) == XFS_ATTR_LEAF_MAGIC) {
1197 blk->hashval = xfs_attr_leaf_lasthash(blk->bp, NULL); 1195 blk->hashval = xfs_attr_leaf_lasthash(blk->bp, NULL);
1198 break; 1196 break;
1199 } 1197 }
1200 else if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC) { 1198 else if (be16_to_cpu(curr->magic) == XFS_DIR_LEAF_MAGIC) {
1201 blk->hashval = xfs_dir_leaf_lasthash(blk->bp, NULL); 1199 blk->hashval = xfs_dir_leaf_lasthash(blk->bp, NULL);
1202 break; 1200 break;
1203 } 1201 }
1204 else if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC) { 1202 else if (be16_to_cpu(curr->magic) == XFS_DIR2_LEAFN_MAGIC) {
1205 blk->hashval = xfs_dir2_leafn_lasthash(blk->bp, NULL); 1203 blk->hashval = xfs_dir2_leafn_lasthash(blk->bp, NULL);
1206 break; 1204 break;
1207 } 1205 }
@@ -1274,8 +1272,8 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk,
1274 ASSERT(old_blk->magic == XFS_DA_NODE_MAGIC || 1272 ASSERT(old_blk->magic == XFS_DA_NODE_MAGIC ||
1275 old_blk->magic == XFS_DIRX_LEAF_MAGIC(state->mp) || 1273 old_blk->magic == XFS_DIRX_LEAF_MAGIC(state->mp) ||
1276 old_blk->magic == XFS_ATTR_LEAF_MAGIC); 1274 old_blk->magic == XFS_ATTR_LEAF_MAGIC);
1277 ASSERT(old_blk->magic == INT_GET(old_info->magic, ARCH_CONVERT)); 1275 ASSERT(old_blk->magic == be16_to_cpu(old_info->magic));
1278 ASSERT(new_blk->magic == INT_GET(new_info->magic, ARCH_CONVERT)); 1276 ASSERT(new_blk->magic == be16_to_cpu(new_info->magic));
1279 ASSERT(old_blk->magic == new_blk->magic); 1277 ASSERT(old_blk->magic == new_blk->magic);
1280 1278
1281 switch (old_blk->magic) { 1279 switch (old_blk->magic) {
@@ -1302,47 +1300,44 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk,
1302 /* 1300 /*
1303 * Link new block in before existing block. 1301 * Link new block in before existing block.
1304 */ 1302 */
1305 INT_SET(new_info->forw, ARCH_CONVERT, old_blk->blkno); 1303 new_info->forw = cpu_to_be32(old_blk->blkno);
1306 new_info->back = old_info->back; /* INT_: direct copy */ 1304 new_info->back = old_info->back;
1307 if (INT_GET(old_info->back, ARCH_CONVERT)) { 1305 if (old_info->back) {
1308 error = xfs_da_read_buf(args->trans, args->dp, 1306 error = xfs_da_read_buf(args->trans, args->dp,
1309 INT_GET(old_info->back, 1307 be32_to_cpu(old_info->back),
1310 ARCH_CONVERT), -1, &bp, 1308 -1, &bp, args->whichfork);
1311 args->whichfork);
1312 if (error) 1309 if (error)
1313 return(error); 1310 return(error);
1314 ASSERT(bp != NULL); 1311 ASSERT(bp != NULL);
1315 tmp_info = bp->data; 1312 tmp_info = bp->data;
1316 ASSERT(INT_GET(tmp_info->magic, ARCH_CONVERT) == INT_GET(old_info->magic, ARCH_CONVERT)); 1313 ASSERT(be16_to_cpu(tmp_info->magic) == be16_to_cpu(old_info->magic));
1317 ASSERT(INT_GET(tmp_info->forw, ARCH_CONVERT) == old_blk->blkno); 1314 ASSERT(be32_to_cpu(tmp_info->forw) == old_blk->blkno);
1318 INT_SET(tmp_info->forw, ARCH_CONVERT, new_blk->blkno); 1315 tmp_info->forw = cpu_to_be32(new_blk->blkno);
1319 xfs_da_log_buf(args->trans, bp, 0, sizeof(*tmp_info)-1); 1316 xfs_da_log_buf(args->trans, bp, 0, sizeof(*tmp_info)-1);
1320 xfs_da_buf_done(bp); 1317 xfs_da_buf_done(bp);
1321 } 1318 }
1322 INT_SET(old_info->back, ARCH_CONVERT, new_blk->blkno); 1319 old_info->back = cpu_to_be32(new_blk->blkno);
1323 } else { 1320 } else {
1324 /* 1321 /*
1325 * Link new block in after existing block. 1322 * Link new block in after existing block.
1326 */ 1323 */
1327 new_info->forw = old_info->forw; /* INT_: direct copy */ 1324 new_info->forw = old_info->forw;
1328 INT_SET(new_info->back, ARCH_CONVERT, old_blk->blkno); 1325 new_info->back = cpu_to_be32(old_blk->blkno);
1329 if (INT_GET(old_info->forw, ARCH_CONVERT)) { 1326 if (old_info->forw) {
1330 error = xfs_da_read_buf(args->trans, args->dp, 1327 error = xfs_da_read_buf(args->trans, args->dp,
1331 INT_GET(old_info->forw, ARCH_CONVERT), -1, &bp, 1328 be32_to_cpu(old_info->forw),
1332 args->whichfork); 1329 -1, &bp, args->whichfork);
1333 if (error) 1330 if (error)
1334 return(error); 1331 return(error);
1335 ASSERT(bp != NULL); 1332 ASSERT(bp != NULL);
1336 tmp_info = bp->data; 1333 tmp_info = bp->data;
1337 ASSERT(INT_GET(tmp_info->magic, ARCH_CONVERT) 1334 ASSERT(tmp_info->magic == old_info->magic);
1338 == INT_GET(old_info->magic, ARCH_CONVERT)); 1335 ASSERT(be32_to_cpu(tmp_info->back) == old_blk->blkno);
1339 ASSERT(INT_GET(tmp_info->back, ARCH_CONVERT) 1336 tmp_info->back = cpu_to_be32(new_blk->blkno);
1340 == old_blk->blkno);
1341 INT_SET(tmp_info->back, ARCH_CONVERT, new_blk->blkno);
1342 xfs_da_log_buf(args->trans, bp, 0, sizeof(*tmp_info)-1); 1337 xfs_da_log_buf(args->trans, bp, 0, sizeof(*tmp_info)-1);
1343 xfs_da_buf_done(bp); 1338 xfs_da_buf_done(bp);
1344 } 1339 }
1345 INT_SET(old_info->forw, ARCH_CONVERT, new_blk->blkno); 1340 old_info->forw = cpu_to_be32(new_blk->blkno);
1346 } 1341 }
1347 1342
1348 xfs_da_log_buf(args->trans, old_blk->bp, 0, sizeof(*tmp_info) - 1); 1343 xfs_da_log_buf(args->trans, old_blk->bp, 0, sizeof(*tmp_info) - 1);
@@ -1360,13 +1355,13 @@ xfs_da_node_order(xfs_dabuf_t *node1_bp, xfs_dabuf_t *node2_bp)
1360 1355
1361 node1 = node1_bp->data; 1356 node1 = node1_bp->data;
1362 node2 = node2_bp->data; 1357 node2 = node2_bp->data;
1363 ASSERT((INT_GET(node1->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC) && 1358 ASSERT((be16_to_cpu(node1->hdr.info.magic) == XFS_DA_NODE_MAGIC) &&
1364 (INT_GET(node2->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC)); 1359 (be16_to_cpu(node2->hdr.info.magic) == XFS_DA_NODE_MAGIC));
1365 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) &&
1366 ((INT_GET(node2->btree[ 0 ].hashval, ARCH_CONVERT) < 1361 ((be32_to_cpu(node2->btree[0].hashval) <
1367 INT_GET(node1->btree[ 0 ].hashval, ARCH_CONVERT)) || 1362 be32_to_cpu(node1->btree[0].hashval)) ||
1368 (INT_GET(node2->btree[ INT_GET(node2->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT) < 1363 (be32_to_cpu(node2->btree[be16_to_cpu(node2->hdr.count)-1].hashval) <
1369 INT_GET(node1->btree[ INT_GET(node1->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT)))) { 1364 be32_to_cpu(node1->btree[be16_to_cpu(node1->hdr.count)-1].hashval)))) {
1370 return(1); 1365 return(1);
1371 } 1366 }
1372 return(0); 1367 return(0);
@@ -1381,12 +1376,12 @@ xfs_da_node_lasthash(xfs_dabuf_t *bp, int *count)
1381 xfs_da_intnode_t *node; 1376 xfs_da_intnode_t *node;
1382 1377
1383 node = bp->data; 1378 node = bp->data;
1384 ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); 1379 ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
1385 if (count) 1380 if (count)
1386 *count = INT_GET(node->hdr.count, ARCH_CONVERT); 1381 *count = be16_to_cpu(node->hdr.count);
1387 if (!node->hdr.count) 1382 if (!node->hdr.count)
1388 return(0); 1383 return(0);
1389 return(INT_GET(node->btree[ INT_GET(node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT)); 1384 return be32_to_cpu(node->btree[be16_to_cpu(node->hdr.count)-1].hashval);
1390} 1385}
1391 1386
1392/* 1387/*
@@ -1411,50 +1406,47 @@ xfs_da_blk_unlink(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1411 ASSERT(save_blk->magic == XFS_DA_NODE_MAGIC || 1406 ASSERT(save_blk->magic == XFS_DA_NODE_MAGIC ||
1412 save_blk->magic == XFS_DIRX_LEAF_MAGIC(state->mp) || 1407 save_blk->magic == XFS_DIRX_LEAF_MAGIC(state->mp) ||
1413 save_blk->magic == XFS_ATTR_LEAF_MAGIC); 1408 save_blk->magic == XFS_ATTR_LEAF_MAGIC);
1414 ASSERT(save_blk->magic == INT_GET(save_info->magic, ARCH_CONVERT)); 1409 ASSERT(save_blk->magic == be16_to_cpu(save_info->magic));
1415 ASSERT(drop_blk->magic == INT_GET(drop_info->magic, ARCH_CONVERT)); 1410 ASSERT(drop_blk->magic == be16_to_cpu(drop_info->magic));
1416 ASSERT(save_blk->magic == drop_blk->magic); 1411 ASSERT(save_blk->magic == drop_blk->magic);
1417 ASSERT((INT_GET(save_info->forw, ARCH_CONVERT) == drop_blk->blkno) || 1412 ASSERT((be32_to_cpu(save_info->forw) == drop_blk->blkno) ||
1418 (INT_GET(save_info->back, ARCH_CONVERT) == drop_blk->blkno)); 1413 (be32_to_cpu(save_info->back) == drop_blk->blkno));
1419 ASSERT((INT_GET(drop_info->forw, ARCH_CONVERT) == save_blk->blkno) || 1414 ASSERT((be32_to_cpu(drop_info->forw) == save_blk->blkno) ||
1420 (INT_GET(drop_info->back, ARCH_CONVERT) == save_blk->blkno)); 1415 (be32_to_cpu(drop_info->back) == save_blk->blkno));
1421 1416
1422 /* 1417 /*
1423 * Unlink the leaf block from the doubly linked chain of leaves. 1418 * Unlink the leaf block from the doubly linked chain of leaves.
1424 */ 1419 */
1425 if (INT_GET(save_info->back, ARCH_CONVERT) == drop_blk->blkno) { 1420 if (be32_to_cpu(save_info->back) == drop_blk->blkno) {
1426 save_info->back = drop_info->back; /* INT_: direct copy */ 1421 save_info->back = drop_info->back;
1427 if (INT_GET(drop_info->back, ARCH_CONVERT)) { 1422 if (drop_info->back) {
1428 error = xfs_da_read_buf(args->trans, args->dp, 1423 error = xfs_da_read_buf(args->trans, args->dp,
1429 INT_GET(drop_info->back, 1424 be32_to_cpu(drop_info->back),
1430 ARCH_CONVERT), -1, &bp, 1425 -1, &bp, args->whichfork);
1431 args->whichfork);
1432 if (error) 1426 if (error)
1433 return(error); 1427 return(error);
1434 ASSERT(bp != NULL); 1428 ASSERT(bp != NULL);
1435 tmp_info = bp->data; 1429 tmp_info = bp->data;
1436 ASSERT(INT_GET(tmp_info->magic, ARCH_CONVERT) == INT_GET(save_info->magic, ARCH_CONVERT)); 1430 ASSERT(tmp_info->magic == save_info->magic);
1437 ASSERT(INT_GET(tmp_info->forw, ARCH_CONVERT) == drop_blk->blkno); 1431 ASSERT(be32_to_cpu(tmp_info->forw) == drop_blk->blkno);
1438 INT_SET(tmp_info->forw, ARCH_CONVERT, save_blk->blkno); 1432 tmp_info->forw = cpu_to_be32(save_blk->blkno);
1439 xfs_da_log_buf(args->trans, bp, 0, 1433 xfs_da_log_buf(args->trans, bp, 0,
1440 sizeof(*tmp_info) - 1); 1434 sizeof(*tmp_info) - 1);
1441 xfs_da_buf_done(bp); 1435 xfs_da_buf_done(bp);
1442 } 1436 }
1443 } else { 1437 } else {
1444 save_info->forw = drop_info->forw; /* INT_: direct copy */ 1438 save_info->forw = drop_info->forw;
1445 if (INT_GET(drop_info->forw, ARCH_CONVERT)) { 1439 if (drop_info->forw) {
1446 error = xfs_da_read_buf(args->trans, args->dp, 1440 error = xfs_da_read_buf(args->trans, args->dp,
1447 INT_GET(drop_info->forw, ARCH_CONVERT), -1, &bp, 1441 be32_to_cpu(drop_info->forw),
1448 args->whichfork); 1442 -1, &bp, args->whichfork);
1449 if (error) 1443 if (error)
1450 return(error); 1444 return(error);
1451 ASSERT(bp != NULL); 1445 ASSERT(bp != NULL);
1452 tmp_info = bp->data; 1446 tmp_info = bp->data;
1453 ASSERT(INT_GET(tmp_info->magic, ARCH_CONVERT) 1447 ASSERT(tmp_info->magic == save_info->magic);
1454 == INT_GET(save_info->magic, ARCH_CONVERT)); 1448 ASSERT(be32_to_cpu(tmp_info->back) == drop_blk->blkno);
1455 ASSERT(INT_GET(tmp_info->back, ARCH_CONVERT) 1449 tmp_info->back = cpu_to_be32(save_blk->blkno);
1456 == drop_blk->blkno);
1457 INT_SET(tmp_info->back, ARCH_CONVERT, save_blk->blkno);
1458 xfs_da_log_buf(args->trans, bp, 0, 1450 xfs_da_log_buf(args->trans, bp, 0,
1459 sizeof(*tmp_info) - 1); 1451 sizeof(*tmp_info) - 1);
1460 xfs_da_buf_done(bp); 1452 xfs_da_buf_done(bp);
@@ -1497,14 +1489,14 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path,
1497 for (blk = &path->blk[level]; level >= 0; blk--, level--) { 1489 for (blk = &path->blk[level]; level >= 0; blk--, level--) {
1498 ASSERT(blk->bp != NULL); 1490 ASSERT(blk->bp != NULL);
1499 node = blk->bp->data; 1491 node = blk->bp->data;
1500 ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); 1492 ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
1501 if (forward && (blk->index < INT_GET(node->hdr.count, ARCH_CONVERT)-1)) { 1493 if (forward && (blk->index < be16_to_cpu(node->hdr.count)-1)) {
1502 blk->index++; 1494 blk->index++;
1503 blkno = INT_GET(node->btree[ blk->index ].before, ARCH_CONVERT); 1495 blkno = be32_to_cpu(node->btree[blk->index].before);
1504 break; 1496 break;
1505 } else if (!forward && (blk->index > 0)) { 1497 } else if (!forward && (blk->index > 0)) {
1506 blk->index--; 1498 blk->index--;
1507 blkno = INT_GET(node->btree[ blk->index ].before, ARCH_CONVERT); 1499 blkno = be32_to_cpu(node->btree[blk->index].before);
1508 break; 1500 break;
1509 } 1501 }
1510 } 1502 }
@@ -1536,18 +1528,18 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path,
1536 return(error); 1528 return(error);
1537 ASSERT(blk->bp != NULL); 1529 ASSERT(blk->bp != NULL);
1538 info = blk->bp->data; 1530 info = blk->bp->data;
1539 ASSERT(INT_GET(info->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC || 1531 ASSERT(be16_to_cpu(info->magic) == XFS_DA_NODE_MAGIC ||
1540 INT_GET(info->magic, ARCH_CONVERT) == XFS_DIRX_LEAF_MAGIC(state->mp) || 1532 be16_to_cpu(info->magic) == XFS_DIRX_LEAF_MAGIC(state->mp) ||
1541 INT_GET(info->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC); 1533 be16_to_cpu(info->magic) == XFS_ATTR_LEAF_MAGIC);
1542 blk->magic = INT_GET(info->magic, ARCH_CONVERT); 1534 blk->magic = be16_to_cpu(info->magic);
1543 if (INT_GET(info->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC) { 1535 if (blk->magic == XFS_DA_NODE_MAGIC) {
1544 node = (xfs_da_intnode_t *)info; 1536 node = (xfs_da_intnode_t *)info;
1545 blk->hashval = INT_GET(node->btree[ INT_GET(node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT); 1537 blk->hashval = be32_to_cpu(node->btree[be16_to_cpu(node->hdr.count)-1].hashval);
1546 if (forward) 1538 if (forward)
1547 blk->index = 0; 1539 blk->index = 0;
1548 else 1540 else
1549 blk->index = INT_GET(node->hdr.count, ARCH_CONVERT)-1; 1541 blk->index = be16_to_cpu(node->hdr.count)-1;
1550 blkno = INT_GET(node->btree[ blk->index ].before, ARCH_CONVERT); 1542 blkno = be32_to_cpu(node->btree[blk->index].before);
1551 } else { 1543 } else {
1552 ASSERT(level == path->active-1); 1544 ASSERT(level == path->active-1);
1553 blk->index = 0; 1545 blk->index = 0;
@@ -1788,40 +1780,40 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1788 /* 1780 /*
1789 * Get values from the moved block. 1781 * Get values from the moved block.
1790 */ 1782 */
1791 if (INT_GET(dead_info->magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC) { 1783 if (be16_to_cpu(dead_info->magic) == XFS_DIR_LEAF_MAGIC) {
1792 ASSERT(XFS_DIR_IS_V1(mp)); 1784 ASSERT(XFS_DIR_IS_V1(mp));
1793 dead_leaf = (xfs_dir_leafblock_t *)dead_info; 1785 dead_leaf = (xfs_dir_leafblock_t *)dead_info;
1794 dead_level = 0; 1786 dead_level = 0;
1795 dead_hash = 1787 dead_hash =
1796 INT_GET(dead_leaf->entries[INT_GET(dead_leaf->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT); 1788 INT_GET(dead_leaf->entries[INT_GET(dead_leaf->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT);
1797 } else if (INT_GET(dead_info->magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC) { 1789 } else if (be16_to_cpu(dead_info->magic) == XFS_DIR2_LEAFN_MAGIC) {
1798 ASSERT(XFS_DIR_IS_V2(mp)); 1790 ASSERT(XFS_DIR_IS_V2(mp));
1799 dead_leaf2 = (xfs_dir2_leaf_t *)dead_info; 1791 dead_leaf2 = (xfs_dir2_leaf_t *)dead_info;
1800 dead_level = 0; 1792 dead_level = 0;
1801 dead_hash = INT_GET(dead_leaf2->ents[INT_GET(dead_leaf2->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT); 1793 dead_hash = be32_to_cpu(dead_leaf2->ents[be16_to_cpu(dead_leaf2->hdr.count) - 1].hashval);
1802 } else { 1794 } else {
1803 ASSERT(INT_GET(dead_info->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); 1795 ASSERT(be16_to_cpu(dead_info->magic) == XFS_DA_NODE_MAGIC);
1804 dead_node = (xfs_da_intnode_t *)dead_info; 1796 dead_node = (xfs_da_intnode_t *)dead_info;
1805 dead_level = INT_GET(dead_node->hdr.level, ARCH_CONVERT); 1797 dead_level = be16_to_cpu(dead_node->hdr.level);
1806 dead_hash = INT_GET(dead_node->btree[INT_GET(dead_node->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT); 1798 dead_hash = be32_to_cpu(dead_node->btree[be16_to_cpu(dead_node->hdr.count) - 1].hashval);
1807 } 1799 }
1808 sib_buf = par_buf = NULL; 1800 sib_buf = par_buf = NULL;
1809 /* 1801 /*
1810 * If the moved block has a left sibling, fix up the pointers. 1802 * If the moved block has a left sibling, fix up the pointers.
1811 */ 1803 */
1812 if ((sib_blkno = INT_GET(dead_info->back, ARCH_CONVERT))) { 1804 if ((sib_blkno = be32_to_cpu(dead_info->back))) {
1813 if ((error = xfs_da_read_buf(tp, ip, sib_blkno, -1, &sib_buf, w))) 1805 if ((error = xfs_da_read_buf(tp, ip, sib_blkno, -1, &sib_buf, w)))
1814 goto done; 1806 goto done;
1815 sib_info = sib_buf->data; 1807 sib_info = sib_buf->data;
1816 if (unlikely( 1808 if (unlikely(
1817 INT_GET(sib_info->forw, ARCH_CONVERT) != last_blkno || 1809 be32_to_cpu(sib_info->forw) != last_blkno ||
1818 INT_GET(sib_info->magic, ARCH_CONVERT) != INT_GET(dead_info->magic, ARCH_CONVERT))) { 1810 sib_info->magic != dead_info->magic)) {
1819 XFS_ERROR_REPORT("xfs_da_swap_lastblock(2)", 1811 XFS_ERROR_REPORT("xfs_da_swap_lastblock(2)",
1820 XFS_ERRLEVEL_LOW, mp); 1812 XFS_ERRLEVEL_LOW, mp);
1821 error = XFS_ERROR(EFSCORRUPTED); 1813 error = XFS_ERROR(EFSCORRUPTED);
1822 goto done; 1814 goto done;
1823 } 1815 }
1824 INT_SET(sib_info->forw, ARCH_CONVERT, dead_blkno); 1816 sib_info->forw = cpu_to_be32(dead_blkno);
1825 xfs_da_log_buf(tp, sib_buf, 1817 xfs_da_log_buf(tp, sib_buf,
1826 XFS_DA_LOGRANGE(sib_info, &sib_info->forw, 1818 XFS_DA_LOGRANGE(sib_info, &sib_info->forw,
1827 sizeof(sib_info->forw))); 1819 sizeof(sib_info->forw)));
@@ -1831,20 +1823,19 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1831 /* 1823 /*
1832 * If the moved block has a right sibling, fix up the pointers. 1824 * If the moved block has a right sibling, fix up the pointers.
1833 */ 1825 */
1834 if ((sib_blkno = INT_GET(dead_info->forw, ARCH_CONVERT))) { 1826 if ((sib_blkno = be32_to_cpu(dead_info->forw))) {
1835 if ((error = xfs_da_read_buf(tp, ip, sib_blkno, -1, &sib_buf, w))) 1827 if ((error = xfs_da_read_buf(tp, ip, sib_blkno, -1, &sib_buf, w)))
1836 goto done; 1828 goto done;
1837 sib_info = sib_buf->data; 1829 sib_info = sib_buf->data;
1838 if (unlikely( 1830 if (unlikely(
1839 INT_GET(sib_info->back, ARCH_CONVERT) != last_blkno 1831 be32_to_cpu(sib_info->back) != last_blkno ||
1840 || INT_GET(sib_info->magic, ARCH_CONVERT) 1832 sib_info->magic != dead_info->magic)) {
1841 != INT_GET(dead_info->magic, ARCH_CONVERT))) {
1842 XFS_ERROR_REPORT("xfs_da_swap_lastblock(3)", 1833 XFS_ERROR_REPORT("xfs_da_swap_lastblock(3)",
1843 XFS_ERRLEVEL_LOW, mp); 1834 XFS_ERRLEVEL_LOW, mp);
1844 error = XFS_ERROR(EFSCORRUPTED); 1835 error = XFS_ERROR(EFSCORRUPTED);
1845 goto done; 1836 goto done;
1846 } 1837 }
1847 INT_SET(sib_info->back, ARCH_CONVERT, dead_blkno); 1838 sib_info->back = cpu_to_be32(dead_blkno);
1848 xfs_da_log_buf(tp, sib_buf, 1839 xfs_da_log_buf(tp, sib_buf,
1849 XFS_DA_LOGRANGE(sib_info, &sib_info->back, 1840 XFS_DA_LOGRANGE(sib_info, &sib_info->back,
1850 sizeof(sib_info->back))); 1841 sizeof(sib_info->back)));
@@ -1861,26 +1852,26 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1861 goto done; 1852 goto done;
1862 par_node = par_buf->data; 1853 par_node = par_buf->data;
1863 if (unlikely( 1854 if (unlikely(
1864 INT_GET(par_node->hdr.info.magic, ARCH_CONVERT) != XFS_DA_NODE_MAGIC || 1855 be16_to_cpu(par_node->hdr.info.magic) != XFS_DA_NODE_MAGIC ||
1865 (level >= 0 && level != INT_GET(par_node->hdr.level, ARCH_CONVERT) + 1))) { 1856 (level >= 0 && level != be16_to_cpu(par_node->hdr.level) + 1))) {
1866 XFS_ERROR_REPORT("xfs_da_swap_lastblock(4)", 1857 XFS_ERROR_REPORT("xfs_da_swap_lastblock(4)",
1867 XFS_ERRLEVEL_LOW, mp); 1858 XFS_ERRLEVEL_LOW, mp);
1868 error = XFS_ERROR(EFSCORRUPTED); 1859 error = XFS_ERROR(EFSCORRUPTED);
1869 goto done; 1860 goto done;
1870 } 1861 }
1871 level = INT_GET(par_node->hdr.level, ARCH_CONVERT); 1862 level = be16_to_cpu(par_node->hdr.level);
1872 for (entno = 0; 1863 for (entno = 0;
1873 entno < INT_GET(par_node->hdr.count, ARCH_CONVERT) && 1864 entno < be16_to_cpu(par_node->hdr.count) &&
1874 INT_GET(par_node->btree[entno].hashval, ARCH_CONVERT) < dead_hash; 1865 be32_to_cpu(par_node->btree[entno].hashval) < dead_hash;
1875 entno++) 1866 entno++)
1876 continue; 1867 continue;
1877 if (unlikely(entno == INT_GET(par_node->hdr.count, ARCH_CONVERT))) { 1868 if (unlikely(entno == be16_to_cpu(par_node->hdr.count))) {
1878 XFS_ERROR_REPORT("xfs_da_swap_lastblock(5)", 1869 XFS_ERROR_REPORT("xfs_da_swap_lastblock(5)",
1879 XFS_ERRLEVEL_LOW, mp); 1870 XFS_ERRLEVEL_LOW, mp);
1880 error = XFS_ERROR(EFSCORRUPTED); 1871 error = XFS_ERROR(EFSCORRUPTED);
1881 goto done; 1872 goto done;
1882 } 1873 }
1883 par_blkno = INT_GET(par_node->btree[entno].before, ARCH_CONVERT); 1874 par_blkno = be32_to_cpu(par_node->btree[entno].before);
1884 if (level == dead_level + 1) 1875 if (level == dead_level + 1)
1885 break; 1876 break;
1886 xfs_da_brelse(tp, par_buf); 1877 xfs_da_brelse(tp, par_buf);
@@ -1892,13 +1883,13 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1892 */ 1883 */
1893 for (;;) { 1884 for (;;) {
1894 for (; 1885 for (;
1895 entno < INT_GET(par_node->hdr.count, ARCH_CONVERT) && 1886 entno < be16_to_cpu(par_node->hdr.count) &&
1896 INT_GET(par_node->btree[entno].before, ARCH_CONVERT) != last_blkno; 1887 be32_to_cpu(par_node->btree[entno].before) != last_blkno;
1897 entno++) 1888 entno++)
1898 continue; 1889 continue;
1899 if (entno < INT_GET(par_node->hdr.count, ARCH_CONVERT)) 1890 if (entno < be16_to_cpu(par_node->hdr.count))
1900 break; 1891 break;
1901 par_blkno = INT_GET(par_node->hdr.info.forw, ARCH_CONVERT); 1892 par_blkno = be32_to_cpu(par_node->hdr.info.forw);
1902 xfs_da_brelse(tp, par_buf); 1893 xfs_da_brelse(tp, par_buf);
1903 par_buf = NULL; 1894 par_buf = NULL;
1904 if (unlikely(par_blkno == 0)) { 1895 if (unlikely(par_blkno == 0)) {
@@ -1911,8 +1902,8 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1911 goto done; 1902 goto done;
1912 par_node = par_buf->data; 1903 par_node = par_buf->data;
1913 if (unlikely( 1904 if (unlikely(
1914 INT_GET(par_node->hdr.level, ARCH_CONVERT) != level || 1905 be16_to_cpu(par_node->hdr.level) != level ||
1915 INT_GET(par_node->hdr.info.magic, ARCH_CONVERT) != XFS_DA_NODE_MAGIC)) { 1906 be16_to_cpu(par_node->hdr.info.magic) != XFS_DA_NODE_MAGIC)) {
1916 XFS_ERROR_REPORT("xfs_da_swap_lastblock(7)", 1907 XFS_ERROR_REPORT("xfs_da_swap_lastblock(7)",
1917 XFS_ERRLEVEL_LOW, mp); 1908 XFS_ERRLEVEL_LOW, mp);
1918 error = XFS_ERROR(EFSCORRUPTED); 1909 error = XFS_ERROR(EFSCORRUPTED);
@@ -1923,7 +1914,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
1923 /* 1914 /*
1924 * Update the parent entry pointing to the moved block. 1915 * Update the parent entry pointing to the moved block.
1925 */ 1916 */
1926 INT_SET(par_node->btree[entno].before, ARCH_CONVERT, dead_blkno); 1917 par_node->btree[entno].before = cpu_to_be32(dead_blkno);
1927 xfs_da_log_buf(tp, par_buf, 1918 xfs_da_log_buf(tp, par_buf,
1928 XFS_DA_LOGRANGE(par_node, &par_node->btree[entno].before, 1919 XFS_DA_LOGRANGE(par_node, &par_node->btree[entno].before,
1929 sizeof(par_node->btree[entno].before))); 1920 sizeof(par_node->btree[entno].before)));
@@ -2203,8 +2194,8 @@ xfs_da_do_buf(
2203 info = rbp->data; 2194 info = rbp->data;
2204 data = rbp->data; 2195 data = rbp->data;
2205 free = rbp->data; 2196 free = rbp->data;
2206 magic = INT_GET(info->magic, ARCH_CONVERT); 2197 magic = be16_to_cpu(info->magic);
2207 magic1 = INT_GET(data->hdr.magic, ARCH_CONVERT); 2198 magic1 = be32_to_cpu(data->hdr.magic);
2208 if (unlikely( 2199 if (unlikely(
2209 XFS_TEST_ERROR((magic != XFS_DA_NODE_MAGIC) && 2200 XFS_TEST_ERROR((magic != XFS_DA_NODE_MAGIC) &&
2210 (magic != XFS_DIR_LEAF_MAGIC) && 2201 (magic != XFS_DIR_LEAF_MAGIC) &&
@@ -2213,7 +2204,7 @@ xfs_da_do_buf(
2213 (magic != XFS_DIR2_LEAFN_MAGIC) && 2204 (magic != XFS_DIR2_LEAFN_MAGIC) &&
2214 (magic1 != XFS_DIR2_BLOCK_MAGIC) && 2205 (magic1 != XFS_DIR2_BLOCK_MAGIC) &&
2215 (magic1 != XFS_DIR2_DATA_MAGIC) && 2206 (magic1 != XFS_DIR2_DATA_MAGIC) &&
2216 (INT_GET(free->hdr.magic, ARCH_CONVERT) != XFS_DIR2_FREE_MAGIC), 2207 (be32_to_cpu(free->hdr.magic) != XFS_DIR2_FREE_MAGIC),
2217 mp, XFS_ERRTAG_DA_READ_BUF, 2208 mp, XFS_ERRTAG_DA_READ_BUF,
2218 XFS_RANDOM_DA_READ_BUF))) { 2209 XFS_RANDOM_DA_READ_BUF))) {
2219 xfs_buftrace("DA READ ERROR", rbp->bps[0]); 2210 xfs_buftrace("DA READ ERROR", rbp->bps[0]);