diff options
author | Christoph Hellwig <hch@sgi.com> | 2005-11-01 23:11:25 -0500 |
---|---|---|
committer | Nathan Scott <nathans@sgi.com> | 2005-11-01 23:11:25 -0500 |
commit | 16259e7d952e26e949cc2c8c68b74f34b293935d (patch) | |
tree | a016791ecb67761236d32b9915efa9a92f6f3767 /fs/xfs/xfs_bmap_btree.c | |
parent | e2ed81fbbb7c76e0a1b3e2f1b5a7414f4d66a559 (diff) |
[XFS] Endianess annotations for various allocator data structures
SGI-PV: 943272
SGI-Modid: xfs-linux:xfs-kern:201006a
Signed-off-by: Christoph Hellwig <hch@sgi.com>
Signed-off-by: Nathan Scott <nathans@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_bmap_btree.c')
-rw-r--r-- | fs/xfs/xfs_bmap_btree.c | 230 |
1 files changed, 115 insertions, 115 deletions
diff --git a/fs/xfs/xfs_bmap_btree.c b/fs/xfs/xfs_bmap_btree.c index 3bf70eca1638..3f1383d160e8 100644 --- a/fs/xfs/xfs_bmap_btree.c +++ b/fs/xfs/xfs_bmap_btree.c | |||
@@ -366,7 +366,7 @@ xfs_bmbt_delrec( | |||
366 | return 0; | 366 | return 0; |
367 | } | 367 | } |
368 | block = xfs_bmbt_get_block(cur, level, &bp); | 368 | block = xfs_bmbt_get_block(cur, level, &bp); |
369 | numrecs = INT_GET(block->bb_numrecs, ARCH_CONVERT); | 369 | numrecs = be16_to_cpu(block->bb_numrecs); |
370 | #ifdef DEBUG | 370 | #ifdef DEBUG |
371 | if ((error = xfs_btree_check_lblock(cur, block, level, bp))) { | 371 | if ((error = xfs_btree_check_lblock(cur, block, level, bp))) { |
372 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 372 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
@@ -411,7 +411,7 @@ xfs_bmbt_delrec( | |||
411 | } | 411 | } |
412 | } | 412 | } |
413 | numrecs--; | 413 | numrecs--; |
414 | INT_SET(block->bb_numrecs, ARCH_CONVERT, numrecs); | 414 | block->bb_numrecs = cpu_to_be16(numrecs); |
415 | xfs_bmbt_log_block(cur, bp, XFS_BB_NUMRECS); | 415 | xfs_bmbt_log_block(cur, bp, XFS_BB_NUMRECS); |
416 | /* | 416 | /* |
417 | * We're at the root level. | 417 | * We're at the root level. |
@@ -447,8 +447,8 @@ xfs_bmbt_delrec( | |||
447 | *stat = 1; | 447 | *stat = 1; |
448 | return 0; | 448 | return 0; |
449 | } | 449 | } |
450 | rbno = INT_GET(block->bb_rightsib, ARCH_CONVERT); | 450 | rbno = be64_to_cpu(block->bb_rightsib); |
451 | lbno = INT_GET(block->bb_leftsib, ARCH_CONVERT); | 451 | lbno = be64_to_cpu(block->bb_leftsib); |
452 | /* | 452 | /* |
453 | * One child of root, need to get a chance to copy its contents | 453 | * One child of root, need to get a chance to copy its contents |
454 | * into the root and delete it. Can't go up to next level, | 454 | * into the root and delete it. Can't go up to next level, |
@@ -492,15 +492,15 @@ xfs_bmbt_delrec( | |||
492 | goto error0; | 492 | goto error0; |
493 | } | 493 | } |
494 | #endif | 494 | #endif |
495 | bno = INT_GET(right->bb_leftsib, ARCH_CONVERT); | 495 | bno = be64_to_cpu(right->bb_leftsib); |
496 | if (INT_GET(right->bb_numrecs, ARCH_CONVERT) - 1 >= | 496 | if (be16_to_cpu(right->bb_numrecs) - 1 >= |
497 | XFS_BMAP_BLOCK_IMINRECS(level, cur)) { | 497 | XFS_BMAP_BLOCK_IMINRECS(level, cur)) { |
498 | if ((error = xfs_bmbt_lshift(tcur, level, &i))) { | 498 | if ((error = xfs_bmbt_lshift(tcur, level, &i))) { |
499 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 499 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
500 | goto error0; | 500 | goto error0; |
501 | } | 501 | } |
502 | if (i) { | 502 | if (i) { |
503 | ASSERT(INT_GET(block->bb_numrecs, ARCH_CONVERT) >= | 503 | ASSERT(be16_to_cpu(block->bb_numrecs) >= |
504 | XFS_BMAP_BLOCK_IMINRECS(level, tcur)); | 504 | XFS_BMAP_BLOCK_IMINRECS(level, tcur)); |
505 | xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR); | 505 | xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR); |
506 | tcur = NULL; | 506 | tcur = NULL; |
@@ -517,7 +517,7 @@ xfs_bmbt_delrec( | |||
517 | return 0; | 517 | return 0; |
518 | } | 518 | } |
519 | } | 519 | } |
520 | rrecs = INT_GET(right->bb_numrecs, ARCH_CONVERT); | 520 | rrecs = be16_to_cpu(right->bb_numrecs); |
521 | if (lbno != NULLFSBLOCK) { | 521 | if (lbno != NULLFSBLOCK) { |
522 | i = xfs_btree_firstrec(tcur, level); | 522 | i = xfs_btree_firstrec(tcur, level); |
523 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); | 523 | XFS_WANT_CORRUPTED_GOTO(i == 1, error0); |
@@ -548,15 +548,15 @@ xfs_bmbt_delrec( | |||
548 | goto error0; | 548 | goto error0; |
549 | } | 549 | } |
550 | #endif | 550 | #endif |
551 | bno = INT_GET(left->bb_rightsib, ARCH_CONVERT); | 551 | bno = be64_to_cpu(left->bb_rightsib); |
552 | if (INT_GET(left->bb_numrecs, ARCH_CONVERT) - 1 >= | 552 | if (be16_to_cpu(left->bb_numrecs) - 1 >= |
553 | XFS_BMAP_BLOCK_IMINRECS(level, cur)) { | 553 | XFS_BMAP_BLOCK_IMINRECS(level, cur)) { |
554 | if ((error = xfs_bmbt_rshift(tcur, level, &i))) { | 554 | if ((error = xfs_bmbt_rshift(tcur, level, &i))) { |
555 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 555 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
556 | goto error0; | 556 | goto error0; |
557 | } | 557 | } |
558 | if (i) { | 558 | if (i) { |
559 | ASSERT(INT_GET(block->bb_numrecs, ARCH_CONVERT) >= | 559 | ASSERT(be16_to_cpu(block->bb_numrecs) >= |
560 | XFS_BMAP_BLOCK_IMINRECS(level, tcur)); | 560 | XFS_BMAP_BLOCK_IMINRECS(level, tcur)); |
561 | xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR); | 561 | xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR); |
562 | tcur = NULL; | 562 | tcur = NULL; |
@@ -567,14 +567,14 @@ xfs_bmbt_delrec( | |||
567 | return 0; | 567 | return 0; |
568 | } | 568 | } |
569 | } | 569 | } |
570 | lrecs = INT_GET(left->bb_numrecs, ARCH_CONVERT); | 570 | lrecs = be16_to_cpu(left->bb_numrecs); |
571 | } | 571 | } |
572 | xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR); | 572 | xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR); |
573 | tcur = NULL; | 573 | tcur = NULL; |
574 | mp = cur->bc_mp; | 574 | mp = cur->bc_mp; |
575 | ASSERT(bno != NULLFSBLOCK); | 575 | ASSERT(bno != NULLFSBLOCK); |
576 | if (lbno != NULLFSBLOCK && | 576 | if (lbno != NULLFSBLOCK && |
577 | lrecs + INT_GET(block->bb_numrecs, ARCH_CONVERT) <= XFS_BMAP_BLOCK_IMAXRECS(level, cur)) { | 577 | lrecs + be16_to_cpu(block->bb_numrecs) <= XFS_BMAP_BLOCK_IMAXRECS(level, cur)) { |
578 | rbno = bno; | 578 | rbno = bno; |
579 | right = block; | 579 | right = block; |
580 | rbp = bp; | 580 | rbp = bp; |
@@ -589,7 +589,7 @@ xfs_bmbt_delrec( | |||
589 | goto error0; | 589 | goto error0; |
590 | } | 590 | } |
591 | } else if (rbno != NULLFSBLOCK && | 591 | } else if (rbno != NULLFSBLOCK && |
592 | rrecs + INT_GET(block->bb_numrecs, ARCH_CONVERT) <= | 592 | rrecs + be16_to_cpu(block->bb_numrecs) <= |
593 | XFS_BMAP_BLOCK_IMAXRECS(level, cur)) { | 593 | XFS_BMAP_BLOCK_IMAXRECS(level, cur)) { |
594 | lbno = bno; | 594 | lbno = bno; |
595 | left = block; | 595 | left = block; |
@@ -604,7 +604,7 @@ xfs_bmbt_delrec( | |||
604 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 604 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
605 | goto error0; | 605 | goto error0; |
606 | } | 606 | } |
607 | lrecs = INT_GET(left->bb_numrecs, ARCH_CONVERT); | 607 | lrecs = be16_to_cpu(left->bb_numrecs); |
608 | } else { | 608 | } else { |
609 | if (level > 0 && (error = xfs_bmbt_decrement(cur, level, &i))) { | 609 | if (level > 0 && (error = xfs_bmbt_decrement(cur, level, &i))) { |
610 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 610 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
@@ -614,8 +614,8 @@ xfs_bmbt_delrec( | |||
614 | *stat = 1; | 614 | *stat = 1; |
615 | return 0; | 615 | return 0; |
616 | } | 616 | } |
617 | numlrecs = INT_GET(left->bb_numrecs, ARCH_CONVERT); | 617 | numlrecs = be16_to_cpu(left->bb_numrecs); |
618 | numrrecs = INT_GET(right->bb_numrecs, ARCH_CONVERT); | 618 | numrrecs = be16_to_cpu(right->bb_numrecs); |
619 | if (level > 0) { | 619 | if (level > 0) { |
620 | lkp = XFS_BMAP_KEY_IADDR(left, numlrecs + 1, cur); | 620 | lkp = XFS_BMAP_KEY_IADDR(left, numlrecs + 1, cur); |
621 | lpp = XFS_BMAP_PTR_IADDR(left, numlrecs + 1, cur); | 621 | lpp = XFS_BMAP_PTR_IADDR(left, numlrecs + 1, cur); |
@@ -639,12 +639,12 @@ xfs_bmbt_delrec( | |||
639 | memcpy(lrp, rrp, numrrecs * sizeof(*lrp)); | 639 | memcpy(lrp, rrp, numrrecs * sizeof(*lrp)); |
640 | xfs_bmbt_log_recs(cur, lbp, numlrecs + 1, numlrecs + numrrecs); | 640 | xfs_bmbt_log_recs(cur, lbp, numlrecs + 1, numlrecs + numrrecs); |
641 | } | 641 | } |
642 | INT_MOD(left->bb_numrecs, ARCH_CONVERT, numrrecs); | 642 | be16_add(&left->bb_numrecs, numrrecs); |
643 | left->bb_rightsib = right->bb_rightsib; /* INT_: direct copy */ | 643 | left->bb_rightsib = right->bb_rightsib; |
644 | xfs_bmbt_log_block(cur, lbp, XFS_BB_RIGHTSIB | XFS_BB_NUMRECS); | 644 | xfs_bmbt_log_block(cur, lbp, XFS_BB_RIGHTSIB | XFS_BB_NUMRECS); |
645 | if (INT_GET(left->bb_rightsib, ARCH_CONVERT) != NULLDFSBNO) { | 645 | if (be64_to_cpu(left->bb_rightsib) != NULLDFSBNO) { |
646 | if ((error = xfs_btree_read_bufl(mp, cur->bc_tp, | 646 | if ((error = xfs_btree_read_bufl(mp, cur->bc_tp, |
647 | INT_GET(left->bb_rightsib, ARCH_CONVERT), | 647 | be64_to_cpu(left->bb_rightsib), |
648 | 0, &rrbp, XFS_BMAP_BTREE_REF))) { | 648 | 0, &rrbp, XFS_BMAP_BTREE_REF))) { |
649 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 649 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
650 | goto error0; | 650 | goto error0; |
@@ -654,7 +654,7 @@ xfs_bmbt_delrec( | |||
654 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 654 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
655 | goto error0; | 655 | goto error0; |
656 | } | 656 | } |
657 | INT_SET(rrblock->bb_leftsib, ARCH_CONVERT, lbno); | 657 | rrblock->bb_leftsib = cpu_to_be64(lbno); |
658 | xfs_bmbt_log_block(cur, rrbp, XFS_BB_LEFTSIB); | 658 | xfs_bmbt_log_block(cur, rrbp, XFS_BB_LEFTSIB); |
659 | } | 659 | } |
660 | xfs_bmap_add_free(XFS_DADDR_TO_FSB(mp, XFS_BUF_ADDR(rbp)), 1, | 660 | xfs_bmap_add_free(XFS_DADDR_TO_FSB(mp, XFS_BUF_ADDR(rbp)), 1, |
@@ -711,7 +711,7 @@ xfs_bmbt_get_rec( | |||
711 | if ((error = xfs_btree_check_lblock(cur, block, 0, bp))) | 711 | if ((error = xfs_btree_check_lblock(cur, block, 0, bp))) |
712 | return error; | 712 | return error; |
713 | #endif | 713 | #endif |
714 | if (ptr > INT_GET(block->bb_numrecs, ARCH_CONVERT) || ptr <= 0) { | 714 | if (ptr > be16_to_cpu(block->bb_numrecs) || ptr <= 0) { |
715 | *stat = 0; | 715 | *stat = 0; |
716 | return 0; | 716 | return 0; |
717 | } | 717 | } |
@@ -772,7 +772,7 @@ xfs_bmbt_insrec( | |||
772 | } | 772 | } |
773 | XFS_STATS_INC(xs_bmbt_insrec); | 773 | XFS_STATS_INC(xs_bmbt_insrec); |
774 | block = xfs_bmbt_get_block(cur, level, &bp); | 774 | block = xfs_bmbt_get_block(cur, level, &bp); |
775 | numrecs = INT_GET(block->bb_numrecs, ARCH_CONVERT); | 775 | numrecs = be16_to_cpu(block->bb_numrecs); |
776 | #ifdef DEBUG | 776 | #ifdef DEBUG |
777 | if ((error = xfs_btree_check_lblock(cur, block, level, bp))) { | 777 | if ((error = xfs_btree_check_lblock(cur, block, level, bp))) { |
778 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 778 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
@@ -854,7 +854,7 @@ xfs_bmbt_insrec( | |||
854 | } | 854 | } |
855 | } | 855 | } |
856 | } | 856 | } |
857 | numrecs = INT_GET(block->bb_numrecs, ARCH_CONVERT); | 857 | numrecs = be16_to_cpu(block->bb_numrecs); |
858 | if (level > 0) { | 858 | if (level > 0) { |
859 | kp = XFS_BMAP_KEY_IADDR(block, 1, cur); | 859 | kp = XFS_BMAP_KEY_IADDR(block, 1, cur); |
860 | pp = XFS_BMAP_PTR_IADDR(block, 1, cur); | 860 | pp = XFS_BMAP_PTR_IADDR(block, 1, cur); |
@@ -881,7 +881,7 @@ xfs_bmbt_insrec( | |||
881 | kp[ptr - 1] = key; | 881 | kp[ptr - 1] = key; |
882 | INT_SET(pp[ptr - 1], ARCH_CONVERT, *bnop); | 882 | INT_SET(pp[ptr - 1], ARCH_CONVERT, *bnop); |
883 | numrecs++; | 883 | numrecs++; |
884 | INT_SET(block->bb_numrecs, ARCH_CONVERT, numrecs); | 884 | block->bb_numrecs = cpu_to_be16(numrecs); |
885 | xfs_bmbt_log_keys(cur, bp, ptr, numrecs); | 885 | xfs_bmbt_log_keys(cur, bp, ptr, numrecs); |
886 | xfs_bmbt_log_ptrs(cur, bp, ptr, numrecs); | 886 | xfs_bmbt_log_ptrs(cur, bp, ptr, numrecs); |
887 | } else { | 887 | } else { |
@@ -890,7 +890,7 @@ xfs_bmbt_insrec( | |||
890 | (numrecs - ptr + 1) * sizeof(*rp)); | 890 | (numrecs - ptr + 1) * sizeof(*rp)); |
891 | rp[ptr - 1] = *recp; | 891 | rp[ptr - 1] = *recp; |
892 | numrecs++; | 892 | numrecs++; |
893 | INT_SET(block->bb_numrecs, ARCH_CONVERT, numrecs); | 893 | block->bb_numrecs = cpu_to_be16(numrecs); |
894 | xfs_bmbt_log_recs(cur, bp, ptr, numrecs); | 894 | xfs_bmbt_log_recs(cur, bp, ptr, numrecs); |
895 | } | 895 | } |
896 | xfs_bmbt_log_block(cur, bp, XFS_BB_NUMRECS); | 896 | xfs_bmbt_log_block(cur, bp, XFS_BB_NUMRECS); |
@@ -955,7 +955,7 @@ xfs_bmbt_killroot( | |||
955 | /* | 955 | /* |
956 | * Give up if the root has multiple children. | 956 | * Give up if the root has multiple children. |
957 | */ | 957 | */ |
958 | if (INT_GET(block->bb_numrecs, ARCH_CONVERT) != 1) { | 958 | if (be16_to_cpu(block->bb_numrecs) != 1) { |
959 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 959 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
960 | return 0; | 960 | return 0; |
961 | } | 961 | } |
@@ -966,37 +966,37 @@ xfs_bmbt_killroot( | |||
966 | */ | 966 | */ |
967 | cbp = cur->bc_bufs[level - 1]; | 967 | cbp = cur->bc_bufs[level - 1]; |
968 | cblock = XFS_BUF_TO_BMBT_BLOCK(cbp); | 968 | cblock = XFS_BUF_TO_BMBT_BLOCK(cbp); |
969 | if (INT_GET(cblock->bb_numrecs, ARCH_CONVERT) > XFS_BMAP_BLOCK_DMAXRECS(level, cur)) { | 969 | if (be16_to_cpu(cblock->bb_numrecs) > XFS_BMAP_BLOCK_DMAXRECS(level, cur)) { |
970 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 970 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
971 | return 0; | 971 | return 0; |
972 | } | 972 | } |
973 | ASSERT(INT_GET(cblock->bb_leftsib, ARCH_CONVERT) == NULLDFSBNO); | 973 | ASSERT(be64_to_cpu(cblock->bb_leftsib) == NULLDFSBNO); |
974 | ASSERT(INT_GET(cblock->bb_rightsib, ARCH_CONVERT) == NULLDFSBNO); | 974 | ASSERT(be64_to_cpu(cblock->bb_rightsib) == NULLDFSBNO); |
975 | ip = cur->bc_private.b.ip; | 975 | ip = cur->bc_private.b.ip; |
976 | ifp = XFS_IFORK_PTR(ip, cur->bc_private.b.whichfork); | 976 | ifp = XFS_IFORK_PTR(ip, cur->bc_private.b.whichfork); |
977 | ASSERT(XFS_BMAP_BLOCK_IMAXRECS(level, cur) == | 977 | ASSERT(XFS_BMAP_BLOCK_IMAXRECS(level, cur) == |
978 | XFS_BMAP_BROOT_MAXRECS(ifp->if_broot_bytes)); | 978 | XFS_BMAP_BROOT_MAXRECS(ifp->if_broot_bytes)); |
979 | i = (int)(INT_GET(cblock->bb_numrecs, ARCH_CONVERT) - XFS_BMAP_BLOCK_IMAXRECS(level, cur)); | 979 | i = (int)(be16_to_cpu(cblock->bb_numrecs) - XFS_BMAP_BLOCK_IMAXRECS(level, cur)); |
980 | if (i) { | 980 | if (i) { |
981 | xfs_iroot_realloc(ip, i, cur->bc_private.b.whichfork); | 981 | xfs_iroot_realloc(ip, i, cur->bc_private.b.whichfork); |
982 | block = ifp->if_broot; | 982 | block = ifp->if_broot; |
983 | } | 983 | } |
984 | INT_MOD(block->bb_numrecs, ARCH_CONVERT, i); | 984 | be16_add(&block->bb_numrecs, i); |
985 | ASSERT(INT_GET(block->bb_numrecs, ARCH_CONVERT) == INT_GET(cblock->bb_numrecs, ARCH_CONVERT)); | 985 | ASSERT(block->bb_numrecs == cblock->bb_numrecs); |
986 | kp = XFS_BMAP_KEY_IADDR(block, 1, cur); | 986 | kp = XFS_BMAP_KEY_IADDR(block, 1, cur); |
987 | ckp = XFS_BMAP_KEY_IADDR(cblock, 1, cur); | 987 | ckp = XFS_BMAP_KEY_IADDR(cblock, 1, cur); |
988 | memcpy(kp, ckp, INT_GET(block->bb_numrecs, ARCH_CONVERT) * sizeof(*kp)); | 988 | memcpy(kp, ckp, be16_to_cpu(block->bb_numrecs) * sizeof(*kp)); |
989 | pp = XFS_BMAP_PTR_IADDR(block, 1, cur); | 989 | pp = XFS_BMAP_PTR_IADDR(block, 1, cur); |
990 | cpp = XFS_BMAP_PTR_IADDR(cblock, 1, cur); | 990 | cpp = XFS_BMAP_PTR_IADDR(cblock, 1, cur); |
991 | #ifdef DEBUG | 991 | #ifdef DEBUG |
992 | for (i = 0; i < INT_GET(cblock->bb_numrecs, ARCH_CONVERT); i++) { | 992 | for (i = 0; i < be16_to_cpu(cblock->bb_numrecs); i++) { |
993 | if ((error = xfs_btree_check_lptr(cur, INT_GET(cpp[i], ARCH_CONVERT), level - 1))) { | 993 | if ((error = xfs_btree_check_lptr(cur, INT_GET(cpp[i], ARCH_CONVERT), level - 1))) { |
994 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 994 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
995 | return error; | 995 | return error; |
996 | } | 996 | } |
997 | } | 997 | } |
998 | #endif | 998 | #endif |
999 | memcpy(pp, cpp, INT_GET(block->bb_numrecs, ARCH_CONVERT) * sizeof(*pp)); | 999 | memcpy(pp, cpp, be16_to_cpu(block->bb_numrecs) * sizeof(*pp)); |
1000 | xfs_bmap_add_free(XFS_DADDR_TO_FSB(cur->bc_mp, XFS_BUF_ADDR(cbp)), 1, | 1000 | xfs_bmap_add_free(XFS_DADDR_TO_FSB(cur->bc_mp, XFS_BUF_ADDR(cbp)), 1, |
1001 | cur->bc_private.b.flist, cur->bc_mp); | 1001 | cur->bc_private.b.flist, cur->bc_mp); |
1002 | ip->i_d.di_nblocks--; | 1002 | ip->i_d.di_nblocks--; |
@@ -1004,7 +1004,7 @@ xfs_bmbt_killroot( | |||
1004 | XFS_TRANS_DQ_BCOUNT, -1L); | 1004 | XFS_TRANS_DQ_BCOUNT, -1L); |
1005 | xfs_trans_binval(cur->bc_tp, cbp); | 1005 | xfs_trans_binval(cur->bc_tp, cbp); |
1006 | cur->bc_bufs[level - 1] = NULL; | 1006 | cur->bc_bufs[level - 1] = NULL; |
1007 | INT_MOD(block->bb_level, ARCH_CONVERT, -1); | 1007 | be16_add(&block->bb_level, -1); |
1008 | xfs_trans_log_inode(cur->bc_tp, ip, | 1008 | xfs_trans_log_inode(cur->bc_tp, ip, |
1009 | XFS_ILOG_CORE | XFS_ILOG_FBROOT(cur->bc_private.b.whichfork)); | 1009 | XFS_ILOG_CORE | XFS_ILOG_FBROOT(cur->bc_private.b.whichfork)); |
1010 | cur->bc_nlevels--; | 1010 | cur->bc_nlevels--; |
@@ -1160,7 +1160,7 @@ xfs_bmbt_lookup( | |||
1160 | else | 1160 | else |
1161 | krbase = XFS_BMAP_REC_IADDR(block, 1, cur); | 1161 | krbase = XFS_BMAP_REC_IADDR(block, 1, cur); |
1162 | low = 1; | 1162 | low = 1; |
1163 | if (!(high = INT_GET(block->bb_numrecs, ARCH_CONVERT))) { | 1163 | if (!(high = be16_to_cpu(block->bb_numrecs))) { |
1164 | ASSERT(level == 0); | 1164 | ASSERT(level == 0); |
1165 | cur->bc_ptrs[0] = dir != XFS_LOOKUP_LE; | 1165 | cur->bc_ptrs[0] = dir != XFS_LOOKUP_LE; |
1166 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 1166 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
@@ -1207,8 +1207,8 @@ xfs_bmbt_lookup( | |||
1207 | * If ge search and we went off the end of the block, but it's | 1207 | * If ge search and we went off the end of the block, but it's |
1208 | * not the last block, we're in the wrong block. | 1208 | * not the last block, we're in the wrong block. |
1209 | */ | 1209 | */ |
1210 | if (dir == XFS_LOOKUP_GE && keyno > INT_GET(block->bb_numrecs, ARCH_CONVERT) && | 1210 | if (dir == XFS_LOOKUP_GE && keyno > be16_to_cpu(block->bb_numrecs) && |
1211 | INT_GET(block->bb_rightsib, ARCH_CONVERT) != NULLDFSBNO) { | 1211 | be64_to_cpu(block->bb_rightsib) != NULLDFSBNO) { |
1212 | cur->bc_ptrs[0] = keyno; | 1212 | cur->bc_ptrs[0] = keyno; |
1213 | if ((error = xfs_bmbt_increment(cur, 0, &i))) { | 1213 | if ((error = xfs_bmbt_increment(cur, 0, &i))) { |
1214 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1214 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
@@ -1223,7 +1223,7 @@ xfs_bmbt_lookup( | |||
1223 | else if (dir == XFS_LOOKUP_LE && diff > 0) | 1223 | else if (dir == XFS_LOOKUP_LE && diff > 0) |
1224 | keyno--; | 1224 | keyno--; |
1225 | cur->bc_ptrs[0] = keyno; | 1225 | cur->bc_ptrs[0] = keyno; |
1226 | if (keyno == 0 || keyno > INT_GET(block->bb_numrecs, ARCH_CONVERT)) { | 1226 | if (keyno == 0 || keyno > be16_to_cpu(block->bb_numrecs)) { |
1227 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 1227 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
1228 | *stat = 0; | 1228 | *stat = 0; |
1229 | } else { | 1229 | } else { |
@@ -1280,7 +1280,7 @@ xfs_bmbt_lshift( | |||
1280 | return error; | 1280 | return error; |
1281 | } | 1281 | } |
1282 | #endif | 1282 | #endif |
1283 | if (INT_GET(right->bb_leftsib, ARCH_CONVERT) == NULLDFSBNO) { | 1283 | if (be64_to_cpu(right->bb_leftsib) == NULLDFSBNO) { |
1284 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 1284 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
1285 | *stat = 0; | 1285 | *stat = 0; |
1286 | return 0; | 1286 | return 0; |
@@ -1291,7 +1291,7 @@ xfs_bmbt_lshift( | |||
1291 | return 0; | 1291 | return 0; |
1292 | } | 1292 | } |
1293 | mp = cur->bc_mp; | 1293 | mp = cur->bc_mp; |
1294 | if ((error = xfs_btree_read_bufl(mp, cur->bc_tp, INT_GET(right->bb_leftsib, ARCH_CONVERT), 0, | 1294 | if ((error = xfs_btree_read_bufl(mp, cur->bc_tp, be64_to_cpu(right->bb_leftsib), 0, |
1295 | &lbp, XFS_BMAP_BTREE_REF))) { | 1295 | &lbp, XFS_BMAP_BTREE_REF))) { |
1296 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1296 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
1297 | return error; | 1297 | return error; |
@@ -1301,12 +1301,12 @@ xfs_bmbt_lshift( | |||
1301 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1301 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
1302 | return error; | 1302 | return error; |
1303 | } | 1303 | } |
1304 | if (INT_GET(left->bb_numrecs, ARCH_CONVERT) == XFS_BMAP_BLOCK_IMAXRECS(level, cur)) { | 1304 | if (be16_to_cpu(left->bb_numrecs) == XFS_BMAP_BLOCK_IMAXRECS(level, cur)) { |
1305 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 1305 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
1306 | *stat = 0; | 1306 | *stat = 0; |
1307 | return 0; | 1307 | return 0; |
1308 | } | 1308 | } |
1309 | lrecs = INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1; | 1309 | lrecs = be16_to_cpu(left->bb_numrecs) + 1; |
1310 | if (level > 0) { | 1310 | if (level > 0) { |
1311 | lkp = XFS_BMAP_KEY_IADDR(left, lrecs, cur); | 1311 | lkp = XFS_BMAP_KEY_IADDR(left, lrecs, cur); |
1312 | rkp = XFS_BMAP_KEY_IADDR(right, 1, cur); | 1312 | rkp = XFS_BMAP_KEY_IADDR(right, 1, cur); |
@@ -1328,7 +1328,7 @@ xfs_bmbt_lshift( | |||
1328 | *lrp = *rrp; | 1328 | *lrp = *rrp; |
1329 | xfs_bmbt_log_recs(cur, lbp, lrecs, lrecs); | 1329 | xfs_bmbt_log_recs(cur, lbp, lrecs, lrecs); |
1330 | } | 1330 | } |
1331 | INT_SET(left->bb_numrecs, ARCH_CONVERT, lrecs); | 1331 | left->bb_numrecs = cpu_to_be16(lrecs); |
1332 | xfs_bmbt_log_block(cur, lbp, XFS_BB_NUMRECS); | 1332 | xfs_bmbt_log_block(cur, lbp, XFS_BB_NUMRECS); |
1333 | #ifdef DEBUG | 1333 | #ifdef DEBUG |
1334 | if (level > 0) | 1334 | if (level > 0) |
@@ -1336,8 +1336,8 @@ xfs_bmbt_lshift( | |||
1336 | else | 1336 | else |
1337 | xfs_btree_check_rec(XFS_BTNUM_BMAP, lrp - 1, lrp); | 1337 | xfs_btree_check_rec(XFS_BTNUM_BMAP, lrp - 1, lrp); |
1338 | #endif | 1338 | #endif |
1339 | rrecs = INT_GET(right->bb_numrecs, ARCH_CONVERT) - 1; | 1339 | rrecs = be16_to_cpu(right->bb_numrecs) - 1; |
1340 | INT_SET(right->bb_numrecs, ARCH_CONVERT, rrecs); | 1340 | right->bb_numrecs = cpu_to_be16(rrecs); |
1341 | xfs_bmbt_log_block(cur, rbp, XFS_BB_NUMRECS); | 1341 | xfs_bmbt_log_block(cur, rbp, XFS_BB_NUMRECS); |
1342 | if (level > 0) { | 1342 | if (level > 0) { |
1343 | #ifdef DEBUG | 1343 | #ifdef DEBUG |
@@ -1414,18 +1414,18 @@ xfs_bmbt_rshift( | |||
1414 | return error; | 1414 | return error; |
1415 | } | 1415 | } |
1416 | #endif | 1416 | #endif |
1417 | if (INT_GET(left->bb_rightsib, ARCH_CONVERT) == NULLDFSBNO) { | 1417 | if (be64_to_cpu(left->bb_rightsib) == NULLDFSBNO) { |
1418 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 1418 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
1419 | *stat = 0; | 1419 | *stat = 0; |
1420 | return 0; | 1420 | return 0; |
1421 | } | 1421 | } |
1422 | if (cur->bc_ptrs[level] >= INT_GET(left->bb_numrecs, ARCH_CONVERT)) { | 1422 | if (cur->bc_ptrs[level] >= be16_to_cpu(left->bb_numrecs)) { |
1423 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 1423 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
1424 | *stat = 0; | 1424 | *stat = 0; |
1425 | return 0; | 1425 | return 0; |
1426 | } | 1426 | } |
1427 | mp = cur->bc_mp; | 1427 | mp = cur->bc_mp; |
1428 | if ((error = xfs_btree_read_bufl(mp, cur->bc_tp, INT_GET(left->bb_rightsib, ARCH_CONVERT), 0, | 1428 | if ((error = xfs_btree_read_bufl(mp, cur->bc_tp, be64_to_cpu(left->bb_rightsib), 0, |
1429 | &rbp, XFS_BMAP_BTREE_REF))) { | 1429 | &rbp, XFS_BMAP_BTREE_REF))) { |
1430 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1430 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
1431 | return error; | 1431 | return error; |
@@ -1435,26 +1435,26 @@ xfs_bmbt_rshift( | |||
1435 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1435 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
1436 | return error; | 1436 | return error; |
1437 | } | 1437 | } |
1438 | if (INT_GET(right->bb_numrecs, ARCH_CONVERT) == XFS_BMAP_BLOCK_IMAXRECS(level, cur)) { | 1438 | if (be16_to_cpu(right->bb_numrecs) == XFS_BMAP_BLOCK_IMAXRECS(level, cur)) { |
1439 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 1439 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
1440 | *stat = 0; | 1440 | *stat = 0; |
1441 | return 0; | 1441 | return 0; |
1442 | } | 1442 | } |
1443 | if (level > 0) { | 1443 | if (level > 0) { |
1444 | lkp = XFS_BMAP_KEY_IADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT), cur); | 1444 | lkp = XFS_BMAP_KEY_IADDR(left, be16_to_cpu(left->bb_numrecs), cur); |
1445 | lpp = XFS_BMAP_PTR_IADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT), cur); | 1445 | lpp = XFS_BMAP_PTR_IADDR(left, be16_to_cpu(left->bb_numrecs), cur); |
1446 | rkp = XFS_BMAP_KEY_IADDR(right, 1, cur); | 1446 | rkp = XFS_BMAP_KEY_IADDR(right, 1, cur); |
1447 | rpp = XFS_BMAP_PTR_IADDR(right, 1, cur); | 1447 | rpp = XFS_BMAP_PTR_IADDR(right, 1, cur); |
1448 | #ifdef DEBUG | 1448 | #ifdef DEBUG |
1449 | for (i = INT_GET(right->bb_numrecs, ARCH_CONVERT) - 1; i >= 0; i--) { | 1449 | for (i = be16_to_cpu(right->bb_numrecs) - 1; i >= 0; i--) { |
1450 | if ((error = xfs_btree_check_lptr(cur, INT_GET(rpp[i], ARCH_CONVERT), level))) { | 1450 | if ((error = xfs_btree_check_lptr(cur, INT_GET(rpp[i], ARCH_CONVERT), level))) { |
1451 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1451 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
1452 | return error; | 1452 | return error; |
1453 | } | 1453 | } |
1454 | } | 1454 | } |
1455 | #endif | 1455 | #endif |
1456 | memmove(rkp + 1, rkp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rkp)); | 1456 | memmove(rkp + 1, rkp, be16_to_cpu(right->bb_numrecs) * sizeof(*rkp)); |
1457 | memmove(rpp + 1, rpp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rpp)); | 1457 | memmove(rpp + 1, rpp, be16_to_cpu(right->bb_numrecs) * sizeof(*rpp)); |
1458 | #ifdef DEBUG | 1458 | #ifdef DEBUG |
1459 | if ((error = xfs_btree_check_lptr(cur, INT_GET(*lpp, ARCH_CONVERT), level))) { | 1459 | if ((error = xfs_btree_check_lptr(cur, INT_GET(*lpp, ARCH_CONVERT), level))) { |
1460 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1460 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
@@ -1463,21 +1463,21 @@ xfs_bmbt_rshift( | |||
1463 | #endif | 1463 | #endif |
1464 | *rkp = *lkp; | 1464 | *rkp = *lkp; |
1465 | *rpp = *lpp; /* INT_: direct copy */ | 1465 | *rpp = *lpp; /* INT_: direct copy */ |
1466 | xfs_bmbt_log_keys(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1); | 1466 | xfs_bmbt_log_keys(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1); |
1467 | xfs_bmbt_log_ptrs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1); | 1467 | xfs_bmbt_log_ptrs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1); |
1468 | } else { | 1468 | } else { |
1469 | lrp = XFS_BMAP_REC_IADDR(left, INT_GET(left->bb_numrecs, ARCH_CONVERT), cur); | 1469 | lrp = XFS_BMAP_REC_IADDR(left, be16_to_cpu(left->bb_numrecs), cur); |
1470 | rrp = XFS_BMAP_REC_IADDR(right, 1, cur); | 1470 | rrp = XFS_BMAP_REC_IADDR(right, 1, cur); |
1471 | memmove(rrp + 1, rrp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rrp)); | 1471 | memmove(rrp + 1, rrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp)); |
1472 | *rrp = *lrp; | 1472 | *rrp = *lrp; |
1473 | xfs_bmbt_log_recs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1); | 1473 | xfs_bmbt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs) + 1); |
1474 | INT_SET(key.br_startoff, ARCH_CONVERT, | 1474 | INT_SET(key.br_startoff, ARCH_CONVERT, |
1475 | xfs_bmbt_disk_get_startoff(rrp)); | 1475 | xfs_bmbt_disk_get_startoff(rrp)); |
1476 | rkp = &key; | 1476 | rkp = &key; |
1477 | } | 1477 | } |
1478 | INT_MOD(left->bb_numrecs, ARCH_CONVERT, -1); | 1478 | be16_add(&left->bb_numrecs, -1); |
1479 | xfs_bmbt_log_block(cur, lbp, XFS_BB_NUMRECS); | 1479 | xfs_bmbt_log_block(cur, lbp, XFS_BB_NUMRECS); |
1480 | INT_MOD(right->bb_numrecs, ARCH_CONVERT, +1); | 1480 | be16_add(&right->bb_numrecs, 1); |
1481 | #ifdef DEBUG | 1481 | #ifdef DEBUG |
1482 | if (level > 0) | 1482 | if (level > 0) |
1483 | xfs_btree_check_key(XFS_BTNUM_BMAP, rkp, rkp + 1); | 1483 | xfs_btree_check_key(XFS_BTNUM_BMAP, rkp, rkp + 1); |
@@ -1608,47 +1608,47 @@ xfs_bmbt_split( | |||
1608 | return error; | 1608 | return error; |
1609 | } | 1609 | } |
1610 | #endif | 1610 | #endif |
1611 | INT_SET(right->bb_magic, ARCH_CONVERT, XFS_BMAP_MAGIC); | 1611 | right->bb_magic = cpu_to_be32(XFS_BMAP_MAGIC); |
1612 | right->bb_level = left->bb_level; /* INT_: direct copy */ | 1612 | right->bb_level = left->bb_level; |
1613 | INT_SET(right->bb_numrecs, ARCH_CONVERT, (__uint16_t)(INT_GET(left->bb_numrecs, ARCH_CONVERT) / 2)); | 1613 | right->bb_numrecs = cpu_to_be16(be16_to_cpu(left->bb_numrecs) / 2); |
1614 | if ((INT_GET(left->bb_numrecs, ARCH_CONVERT) & 1) && | 1614 | if ((be16_to_cpu(left->bb_numrecs) & 1) && |
1615 | cur->bc_ptrs[level] <= INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1) | 1615 | cur->bc_ptrs[level] <= be16_to_cpu(right->bb_numrecs) + 1) |
1616 | INT_MOD(right->bb_numrecs, ARCH_CONVERT, +1); | 1616 | be16_add(&right->bb_numrecs, 1); |
1617 | i = INT_GET(left->bb_numrecs, ARCH_CONVERT) - INT_GET(right->bb_numrecs, ARCH_CONVERT) + 1; | 1617 | i = be16_to_cpu(left->bb_numrecs) - be16_to_cpu(right->bb_numrecs) + 1; |
1618 | if (level > 0) { | 1618 | if (level > 0) { |
1619 | lkp = XFS_BMAP_KEY_IADDR(left, i, cur); | 1619 | lkp = XFS_BMAP_KEY_IADDR(left, i, cur); |
1620 | lpp = XFS_BMAP_PTR_IADDR(left, i, cur); | 1620 | lpp = XFS_BMAP_PTR_IADDR(left, i, cur); |
1621 | rkp = XFS_BMAP_KEY_IADDR(right, 1, cur); | 1621 | rkp = XFS_BMAP_KEY_IADDR(right, 1, cur); |
1622 | rpp = XFS_BMAP_PTR_IADDR(right, 1, cur); | 1622 | rpp = XFS_BMAP_PTR_IADDR(right, 1, cur); |
1623 | #ifdef DEBUG | 1623 | #ifdef DEBUG |
1624 | for (i = 0; i < INT_GET(right->bb_numrecs, ARCH_CONVERT); i++) { | 1624 | for (i = 0; i < be16_to_cpu(right->bb_numrecs); i++) { |
1625 | if ((error = xfs_btree_check_lptr(cur, INT_GET(lpp[i], ARCH_CONVERT), level))) { | 1625 | if ((error = xfs_btree_check_lptr(cur, INT_GET(lpp[i], ARCH_CONVERT), level))) { |
1626 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1626 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
1627 | return error; | 1627 | return error; |
1628 | } | 1628 | } |
1629 | } | 1629 | } |
1630 | #endif | 1630 | #endif |
1631 | memcpy(rkp, lkp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rkp)); | 1631 | memcpy(rkp, lkp, be16_to_cpu(right->bb_numrecs) * sizeof(*rkp)); |
1632 | memcpy(rpp, lpp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rpp)); | 1632 | memcpy(rpp, lpp, be16_to_cpu(right->bb_numrecs) * sizeof(*rpp)); |
1633 | xfs_bmbt_log_keys(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); | 1633 | xfs_bmbt_log_keys(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); |
1634 | xfs_bmbt_log_ptrs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); | 1634 | xfs_bmbt_log_ptrs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); |
1635 | keyp->br_startoff = INT_GET(rkp->br_startoff, ARCH_CONVERT); | 1635 | keyp->br_startoff = INT_GET(rkp->br_startoff, ARCH_CONVERT); |
1636 | } else { | 1636 | } else { |
1637 | lrp = XFS_BMAP_REC_IADDR(left, i, cur); | 1637 | lrp = XFS_BMAP_REC_IADDR(left, i, cur); |
1638 | rrp = XFS_BMAP_REC_IADDR(right, 1, cur); | 1638 | rrp = XFS_BMAP_REC_IADDR(right, 1, cur); |
1639 | memcpy(rrp, lrp, INT_GET(right->bb_numrecs, ARCH_CONVERT) * sizeof(*rrp)); | 1639 | memcpy(rrp, lrp, be16_to_cpu(right->bb_numrecs) * sizeof(*rrp)); |
1640 | xfs_bmbt_log_recs(cur, rbp, 1, INT_GET(right->bb_numrecs, ARCH_CONVERT)); | 1640 | xfs_bmbt_log_recs(cur, rbp, 1, be16_to_cpu(right->bb_numrecs)); |
1641 | keyp->br_startoff = xfs_bmbt_disk_get_startoff(rrp); | 1641 | keyp->br_startoff = xfs_bmbt_disk_get_startoff(rrp); |
1642 | } | 1642 | } |
1643 | INT_MOD(left->bb_numrecs, ARCH_CONVERT, -(INT_GET(right->bb_numrecs, ARCH_CONVERT))); | 1643 | be16_add(&left->bb_numrecs, -(be16_to_cpu(right->bb_numrecs))); |
1644 | right->bb_rightsib = left->bb_rightsib; /* INT_: direct copy */ | 1644 | right->bb_rightsib = left->bb_rightsib; |
1645 | INT_SET(left->bb_rightsib, ARCH_CONVERT, args.fsbno); | 1645 | left->bb_rightsib = cpu_to_be64(args.fsbno); |
1646 | INT_SET(right->bb_leftsib, ARCH_CONVERT, lbno); | 1646 | right->bb_leftsib = cpu_to_be64(lbno); |
1647 | xfs_bmbt_log_block(cur, rbp, XFS_BB_ALL_BITS); | 1647 | xfs_bmbt_log_block(cur, rbp, XFS_BB_ALL_BITS); |
1648 | xfs_bmbt_log_block(cur, lbp, XFS_BB_NUMRECS | XFS_BB_RIGHTSIB); | 1648 | xfs_bmbt_log_block(cur, lbp, XFS_BB_NUMRECS | XFS_BB_RIGHTSIB); |
1649 | if (INT_GET(right->bb_rightsib, ARCH_CONVERT) != NULLDFSBNO) { | 1649 | if (be64_to_cpu(right->bb_rightsib) != NULLDFSBNO) { |
1650 | if ((error = xfs_btree_read_bufl(args.mp, args.tp, | 1650 | if ((error = xfs_btree_read_bufl(args.mp, args.tp, |
1651 | INT_GET(right->bb_rightsib, ARCH_CONVERT), 0, &rrbp, | 1651 | be64_to_cpu(right->bb_rightsib), 0, &rrbp, |
1652 | XFS_BMAP_BTREE_REF))) { | 1652 | XFS_BMAP_BTREE_REF))) { |
1653 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1653 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
1654 | return error; | 1654 | return error; |
@@ -1658,12 +1658,12 @@ xfs_bmbt_split( | |||
1658 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1658 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
1659 | return error; | 1659 | return error; |
1660 | } | 1660 | } |
1661 | INT_SET(rrblock->bb_leftsib, ARCH_CONVERT, args.fsbno); | 1661 | rrblock->bb_leftsib = cpu_to_be64(args.fsbno); |
1662 | xfs_bmbt_log_block(cur, rrbp, XFS_BB_LEFTSIB); | 1662 | xfs_bmbt_log_block(cur, rrbp, XFS_BB_LEFTSIB); |
1663 | } | 1663 | } |
1664 | if (cur->bc_ptrs[level] > INT_GET(left->bb_numrecs, ARCH_CONVERT) + 1) { | 1664 | if (cur->bc_ptrs[level] > be16_to_cpu(left->bb_numrecs) + 1) { |
1665 | xfs_btree_setbuf(cur, level, rbp); | 1665 | xfs_btree_setbuf(cur, level, rbp); |
1666 | cur->bc_ptrs[level] -= INT_GET(left->bb_numrecs, ARCH_CONVERT); | 1666 | cur->bc_ptrs[level] -= be16_to_cpu(left->bb_numrecs); |
1667 | } | 1667 | } |
1668 | if (level + 1 < cur->bc_nlevels) { | 1668 | if (level + 1 < cur->bc_nlevels) { |
1669 | if ((error = xfs_btree_dup_cursor(cur, curp))) { | 1669 | if ((error = xfs_btree_dup_cursor(cur, curp))) { |
@@ -1735,18 +1735,18 @@ xfs_bmdr_to_bmbt( | |||
1735 | xfs_bmbt_key_t *tkp; | 1735 | xfs_bmbt_key_t *tkp; |
1736 | xfs_bmbt_ptr_t *tpp; | 1736 | xfs_bmbt_ptr_t *tpp; |
1737 | 1737 | ||
1738 | INT_SET(rblock->bb_magic, ARCH_CONVERT, XFS_BMAP_MAGIC); | 1738 | rblock->bb_magic = cpu_to_be32(XFS_BMAP_MAGIC); |
1739 | rblock->bb_level = dblock->bb_level; /* both in on-disk format */ | 1739 | rblock->bb_level = dblock->bb_level; |
1740 | ASSERT(INT_GET(rblock->bb_level, ARCH_CONVERT) > 0); | 1740 | ASSERT(be16_to_cpu(rblock->bb_level) > 0); |
1741 | rblock->bb_numrecs = dblock->bb_numrecs;/* both in on-disk format */ | 1741 | rblock->bb_numrecs = dblock->bb_numrecs; |
1742 | INT_SET(rblock->bb_leftsib, ARCH_CONVERT, NULLDFSBNO); | 1742 | rblock->bb_leftsib = cpu_to_be64(NULLDFSBNO); |
1743 | INT_SET(rblock->bb_rightsib, ARCH_CONVERT, NULLDFSBNO); | 1743 | rblock->bb_rightsib = cpu_to_be64(NULLDFSBNO); |
1744 | dmxr = (int)XFS_BTREE_BLOCK_MAXRECS(dblocklen, xfs_bmdr, 0); | 1744 | dmxr = (int)XFS_BTREE_BLOCK_MAXRECS(dblocklen, xfs_bmdr, 0); |
1745 | fkp = XFS_BTREE_KEY_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); | 1745 | fkp = XFS_BTREE_KEY_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); |
1746 | tkp = XFS_BMAP_BROOT_KEY_ADDR(rblock, 1, rblocklen); | 1746 | tkp = XFS_BMAP_BROOT_KEY_ADDR(rblock, 1, rblocklen); |
1747 | fpp = XFS_BTREE_PTR_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); | 1747 | fpp = XFS_BTREE_PTR_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); |
1748 | tpp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, rblocklen); | 1748 | tpp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, rblocklen); |
1749 | dmxr = INT_GET(dblock->bb_numrecs, ARCH_CONVERT); | 1749 | dmxr = be16_to_cpu(dblock->bb_numrecs); |
1750 | memcpy(tkp, fkp, sizeof(*fkp) * dmxr); | 1750 | memcpy(tkp, fkp, sizeof(*fkp) * dmxr); |
1751 | memcpy(tpp, fpp, sizeof(*fpp) * dmxr); /* INT_: direct copy */ | 1751 | memcpy(tpp, fpp, sizeof(*fpp) * dmxr); /* INT_: direct copy */ |
1752 | } | 1752 | } |
@@ -1789,7 +1789,7 @@ xfs_bmbt_decrement( | |||
1789 | return error; | 1789 | return error; |
1790 | } | 1790 | } |
1791 | #endif | 1791 | #endif |
1792 | if (INT_GET(block->bb_leftsib, ARCH_CONVERT) == NULLDFSBNO) { | 1792 | if (be64_to_cpu(block->bb_leftsib) == NULLDFSBNO) { |
1793 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 1793 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
1794 | *stat = 0; | 1794 | *stat = 0; |
1795 | return 0; | 1795 | return 0; |
@@ -1821,7 +1821,7 @@ xfs_bmbt_decrement( | |||
1821 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 1821 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
1822 | return error; | 1822 | return error; |
1823 | } | 1823 | } |
1824 | cur->bc_ptrs[lev] = INT_GET(block->bb_numrecs, ARCH_CONVERT); | 1824 | cur->bc_ptrs[lev] = be16_to_cpu(block->bb_numrecs); |
1825 | } | 1825 | } |
1826 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 1826 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
1827 | *stat = 1; | 1827 | *stat = 1; |
@@ -2107,12 +2107,12 @@ xfs_bmbt_increment( | |||
2107 | return error; | 2107 | return error; |
2108 | } | 2108 | } |
2109 | #endif | 2109 | #endif |
2110 | if (++cur->bc_ptrs[level] <= INT_GET(block->bb_numrecs, ARCH_CONVERT)) { | 2110 | if (++cur->bc_ptrs[level] <= be16_to_cpu(block->bb_numrecs)) { |
2111 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 2111 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
2112 | *stat = 1; | 2112 | *stat = 1; |
2113 | return 0; | 2113 | return 0; |
2114 | } | 2114 | } |
2115 | if (INT_GET(block->bb_rightsib, ARCH_CONVERT) == NULLDFSBNO) { | 2115 | if (be64_to_cpu(block->bb_rightsib) == NULLDFSBNO) { |
2116 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 2116 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
2117 | *stat = 0; | 2117 | *stat = 0; |
2118 | return 0; | 2118 | return 0; |
@@ -2125,7 +2125,7 @@ xfs_bmbt_increment( | |||
2125 | return error; | 2125 | return error; |
2126 | } | 2126 | } |
2127 | #endif | 2127 | #endif |
2128 | if (++cur->bc_ptrs[lev] <= INT_GET(block->bb_numrecs, ARCH_CONVERT)) | 2128 | if (++cur->bc_ptrs[lev] <= be16_to_cpu(block->bb_numrecs)) |
2129 | break; | 2129 | break; |
2130 | if (lev < cur->bc_nlevels - 1) | 2130 | if (lev < cur->bc_nlevels - 1) |
2131 | xfs_btree_readahead(cur, lev, XFS_BTCUR_RIGHTRA); | 2131 | xfs_btree_readahead(cur, lev, XFS_BTCUR_RIGHTRA); |
@@ -2387,23 +2387,23 @@ xfs_bmbt_newroot( | |||
2387 | bp = xfs_btree_get_bufl(args.mp, cur->bc_tp, args.fsbno, 0); | 2387 | bp = xfs_btree_get_bufl(args.mp, cur->bc_tp, args.fsbno, 0); |
2388 | cblock = XFS_BUF_TO_BMBT_BLOCK(bp); | 2388 | cblock = XFS_BUF_TO_BMBT_BLOCK(bp); |
2389 | *cblock = *block; | 2389 | *cblock = *block; |
2390 | INT_MOD(block->bb_level, ARCH_CONVERT, +1); | 2390 | be16_add(&block->bb_level, 1); |
2391 | INT_SET(block->bb_numrecs, ARCH_CONVERT, 1); | 2391 | block->bb_numrecs = cpu_to_be16(1); |
2392 | cur->bc_nlevels++; | 2392 | cur->bc_nlevels++; |
2393 | cur->bc_ptrs[level + 1] = 1; | 2393 | cur->bc_ptrs[level + 1] = 1; |
2394 | kp = XFS_BMAP_KEY_IADDR(block, 1, cur); | 2394 | kp = XFS_BMAP_KEY_IADDR(block, 1, cur); |
2395 | ckp = XFS_BMAP_KEY_IADDR(cblock, 1, cur); | 2395 | ckp = XFS_BMAP_KEY_IADDR(cblock, 1, cur); |
2396 | memcpy(ckp, kp, INT_GET(cblock->bb_numrecs, ARCH_CONVERT) * sizeof(*kp)); | 2396 | memcpy(ckp, kp, be16_to_cpu(cblock->bb_numrecs) * sizeof(*kp)); |
2397 | cpp = XFS_BMAP_PTR_IADDR(cblock, 1, cur); | 2397 | cpp = XFS_BMAP_PTR_IADDR(cblock, 1, cur); |
2398 | #ifdef DEBUG | 2398 | #ifdef DEBUG |
2399 | for (i = 0; i < INT_GET(cblock->bb_numrecs, ARCH_CONVERT); i++) { | 2399 | for (i = 0; i < be16_to_cpu(cblock->bb_numrecs); i++) { |
2400 | if ((error = xfs_btree_check_lptr(cur, INT_GET(pp[i], ARCH_CONVERT), level))) { | 2400 | if ((error = xfs_btree_check_lptr(cur, INT_GET(pp[i], ARCH_CONVERT), level))) { |
2401 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); | 2401 | XFS_BMBT_TRACE_CURSOR(cur, ERROR); |
2402 | return error; | 2402 | return error; |
2403 | } | 2403 | } |
2404 | } | 2404 | } |
2405 | #endif | 2405 | #endif |
2406 | memcpy(cpp, pp, INT_GET(cblock->bb_numrecs, ARCH_CONVERT) * sizeof(*pp)); | 2406 | memcpy(cpp, pp, be16_to_cpu(cblock->bb_numrecs) * sizeof(*pp)); |
2407 | #ifdef DEBUG | 2407 | #ifdef DEBUG |
2408 | if ((error = xfs_btree_check_lptr(cur, (xfs_bmbt_ptr_t)args.fsbno, | 2408 | if ((error = xfs_btree_check_lptr(cur, (xfs_bmbt_ptr_t)args.fsbno, |
2409 | level))) { | 2409 | level))) { |
@@ -2412,7 +2412,7 @@ xfs_bmbt_newroot( | |||
2412 | } | 2412 | } |
2413 | #endif | 2413 | #endif |
2414 | INT_SET(*pp, ARCH_CONVERT, args.fsbno); | 2414 | INT_SET(*pp, ARCH_CONVERT, args.fsbno); |
2415 | xfs_iroot_realloc(cur->bc_private.b.ip, 1 - INT_GET(cblock->bb_numrecs, ARCH_CONVERT), | 2415 | xfs_iroot_realloc(cur->bc_private.b.ip, 1 - be16_to_cpu(cblock->bb_numrecs), |
2416 | cur->bc_private.b.whichfork); | 2416 | cur->bc_private.b.whichfork); |
2417 | xfs_btree_setbuf(cur, level, bp); | 2417 | xfs_btree_setbuf(cur, level, bp); |
2418 | /* | 2418 | /* |
@@ -2420,8 +2420,8 @@ xfs_bmbt_newroot( | |||
2420 | * the root is at the right level. | 2420 | * the root is at the right level. |
2421 | */ | 2421 | */ |
2422 | xfs_bmbt_log_block(cur, bp, XFS_BB_ALL_BITS); | 2422 | xfs_bmbt_log_block(cur, bp, XFS_BB_ALL_BITS); |
2423 | xfs_bmbt_log_keys(cur, bp, 1, INT_GET(cblock->bb_numrecs, ARCH_CONVERT)); | 2423 | xfs_bmbt_log_keys(cur, bp, 1, be16_to_cpu(cblock->bb_numrecs)); |
2424 | xfs_bmbt_log_ptrs(cur, bp, 1, INT_GET(cblock->bb_numrecs, ARCH_CONVERT)); | 2424 | xfs_bmbt_log_ptrs(cur, bp, 1, be16_to_cpu(cblock->bb_numrecs)); |
2425 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); | 2425 | XFS_BMBT_TRACE_CURSOR(cur, EXIT); |
2426 | *logflags |= | 2426 | *logflags |= |
2427 | XFS_ILOG_CORE | XFS_ILOG_FBROOT(cur->bc_private.b.whichfork); | 2427 | XFS_ILOG_CORE | XFS_ILOG_FBROOT(cur->bc_private.b.whichfork); |
@@ -2689,18 +2689,18 @@ xfs_bmbt_to_bmdr( | |||
2689 | xfs_bmbt_key_t *tkp; | 2689 | xfs_bmbt_key_t *tkp; |
2690 | xfs_bmbt_ptr_t *tpp; | 2690 | xfs_bmbt_ptr_t *tpp; |
2691 | 2691 | ||
2692 | ASSERT(INT_GET(rblock->bb_magic, ARCH_CONVERT) == XFS_BMAP_MAGIC); | 2692 | ASSERT(be32_to_cpu(rblock->bb_magic) == XFS_BMAP_MAGIC); |
2693 | ASSERT(INT_GET(rblock->bb_leftsib, ARCH_CONVERT) == NULLDFSBNO); | 2693 | ASSERT(be64_to_cpu(rblock->bb_leftsib) == NULLDFSBNO); |
2694 | ASSERT(INT_GET(rblock->bb_rightsib, ARCH_CONVERT) == NULLDFSBNO); | 2694 | ASSERT(be64_to_cpu(rblock->bb_rightsib) == NULLDFSBNO); |
2695 | ASSERT(INT_GET(rblock->bb_level, ARCH_CONVERT) > 0); | 2695 | ASSERT(be16_to_cpu(rblock->bb_level) > 0); |
2696 | dblock->bb_level = rblock->bb_level; /* both in on-disk format */ | 2696 | dblock->bb_level = rblock->bb_level; |
2697 | dblock->bb_numrecs = rblock->bb_numrecs;/* both in on-disk format */ | 2697 | dblock->bb_numrecs = rblock->bb_numrecs; |
2698 | dmxr = (int)XFS_BTREE_BLOCK_MAXRECS(dblocklen, xfs_bmdr, 0); | 2698 | dmxr = (int)XFS_BTREE_BLOCK_MAXRECS(dblocklen, xfs_bmdr, 0); |
2699 | fkp = XFS_BMAP_BROOT_KEY_ADDR(rblock, 1, rblocklen); | 2699 | fkp = XFS_BMAP_BROOT_KEY_ADDR(rblock, 1, rblocklen); |
2700 | tkp = XFS_BTREE_KEY_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); | 2700 | tkp = XFS_BTREE_KEY_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); |
2701 | fpp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, rblocklen); | 2701 | fpp = XFS_BMAP_BROOT_PTR_ADDR(rblock, 1, rblocklen); |
2702 | tpp = XFS_BTREE_PTR_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); | 2702 | tpp = XFS_BTREE_PTR_ADDR(dblocklen, xfs_bmdr, dblock, 1, dmxr); |
2703 | dmxr = INT_GET(dblock->bb_numrecs, ARCH_CONVERT); | 2703 | dmxr = be16_to_cpu(dblock->bb_numrecs); |
2704 | memcpy(tkp, fkp, sizeof(*fkp) * dmxr); | 2704 | memcpy(tkp, fkp, sizeof(*fkp) * dmxr); |
2705 | memcpy(tpp, fpp, sizeof(*fpp) * dmxr); /* INT_: direct copy */ | 2705 | memcpy(tpp, fpp, sizeof(*fpp) * dmxr); /* INT_: direct copy */ |
2706 | } | 2706 | } |