aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_btree.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@sgi.com>2005-11-01 23:11:25 -0500
committerNathan Scott <nathans@sgi.com>2005-11-01 23:11:25 -0500
commit16259e7d952e26e949cc2c8c68b74f34b293935d (patch)
treea016791ecb67761236d32b9915efa9a92f6f3767 /fs/xfs/xfs_btree.c
parente2ed81fbbb7c76e0a1b3e2f1b5a7414f4d66a559 (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_btree.c')
-rw-r--r--fs/xfs/xfs_btree.c104
1 files changed, 54 insertions, 50 deletions
diff --git a/fs/xfs/xfs_btree.c b/fs/xfs/xfs_btree.c
index 9de5a1f312c..52d5d095fc3 100644
--- a/fs/xfs/xfs_btree.c
+++ b/fs/xfs/xfs_btree.c
@@ -90,11 +90,14 @@ xfs_btree_maxrecs(
90 switch (cur->bc_btnum) { 90 switch (cur->bc_btnum) {
91 case XFS_BTNUM_BNO: 91 case XFS_BTNUM_BNO:
92 case XFS_BTNUM_CNT: 92 case XFS_BTNUM_CNT:
93 return (int)XFS_ALLOC_BLOCK_MAXRECS(INT_GET(block->bb_h.bb_level, ARCH_CONVERT), cur); 93 return (int)XFS_ALLOC_BLOCK_MAXRECS(
94 be16_to_cpu(block->bb_h.bb_level), cur);
94 case XFS_BTNUM_BMAP: 95 case XFS_BTNUM_BMAP:
95 return (int)XFS_BMAP_BLOCK_IMAXRECS(INT_GET(block->bb_h.bb_level, ARCH_CONVERT), cur); 96 return (int)XFS_BMAP_BLOCK_IMAXRECS(
97 be16_to_cpu(block->bb_h.bb_level), cur);
96 case XFS_BTNUM_INO: 98 case XFS_BTNUM_INO:
97 return (int)XFS_INOBT_BLOCK_MAXRECS(INT_GET(block->bb_h.bb_level, ARCH_CONVERT), cur); 99 return (int)XFS_INOBT_BLOCK_MAXRECS(
100 be16_to_cpu(block->bb_h.bb_level), cur);
98 default: 101 default:
99 ASSERT(0); 102 ASSERT(0);
100 return 0; 103 return 0;
@@ -140,7 +143,7 @@ xfs_btree_check_key(
140 143
141 k1 = ak1; 144 k1 = ak1;
142 k2 = ak2; 145 k2 = ak2;
143 ASSERT(INT_GET(k1->ar_startblock, ARCH_CONVERT) < INT_GET(k2->ar_startblock, ARCH_CONVERT)); 146 ASSERT(be32_to_cpu(k1->ar_startblock) < be32_to_cpu(k2->ar_startblock));
144 break; 147 break;
145 } 148 }
146 case XFS_BTNUM_CNT: { 149 case XFS_BTNUM_CNT: {
@@ -149,9 +152,9 @@ xfs_btree_check_key(
149 152
150 k1 = ak1; 153 k1 = ak1;
151 k2 = ak2; 154 k2 = ak2;
152 ASSERT(INT_GET(k1->ar_blockcount, ARCH_CONVERT) < INT_GET(k2->ar_blockcount, ARCH_CONVERT) || 155 ASSERT(be32_to_cpu(k1->ar_blockcount) < be32_to_cpu(k2->ar_blockcount) ||
153 (INT_GET(k1->ar_blockcount, ARCH_CONVERT) == INT_GET(k2->ar_blockcount, ARCH_CONVERT) && 156 (k1->ar_blockcount == k2->ar_blockcount &&
154 INT_GET(k1->ar_startblock, ARCH_CONVERT) < INT_GET(k2->ar_startblock, ARCH_CONVERT))); 157 be32_to_cpu(k1->ar_startblock) < be32_to_cpu(k2->ar_startblock)));
155 break; 158 break;
156 } 159 }
157 case XFS_BTNUM_BMAP: { 160 case XFS_BTNUM_BMAP: {
@@ -194,16 +197,16 @@ xfs_btree_check_lblock(
194 197
195 mp = cur->bc_mp; 198 mp = cur->bc_mp;
196 lblock_ok = 199 lblock_ok =
197 INT_GET(block->bb_magic, ARCH_CONVERT) == xfs_magics[cur->bc_btnum] && 200 be32_to_cpu(block->bb_magic) == xfs_magics[cur->bc_btnum] &&
198 INT_GET(block->bb_level, ARCH_CONVERT) == level && 201 be16_to_cpu(block->bb_level) == level &&
199 INT_GET(block->bb_numrecs, ARCH_CONVERT) <= 202 be16_to_cpu(block->bb_numrecs) <=
200 xfs_btree_maxrecs(cur, (xfs_btree_block_t *)block) && 203 xfs_btree_maxrecs(cur, (xfs_btree_block_t *)block) &&
201 block->bb_leftsib && 204 block->bb_leftsib &&
202 (INT_GET(block->bb_leftsib, ARCH_CONVERT) == NULLDFSBNO || 205 (be64_to_cpu(block->bb_leftsib) == NULLDFSBNO ||
203 XFS_FSB_SANITY_CHECK(mp, INT_GET(block->bb_leftsib, ARCH_CONVERT))) && 206 XFS_FSB_SANITY_CHECK(mp, be64_to_cpu(block->bb_leftsib))) &&
204 block->bb_rightsib && 207 block->bb_rightsib &&
205 (INT_GET(block->bb_rightsib, ARCH_CONVERT) == NULLDFSBNO || 208 (be64_to_cpu(block->bb_rightsib) == NULLDFSBNO ||
206 XFS_FSB_SANITY_CHECK(mp, INT_GET(block->bb_rightsib, ARCH_CONVERT))); 209 XFS_FSB_SANITY_CHECK(mp, be64_to_cpu(block->bb_rightsib)));
207 if (unlikely(XFS_TEST_ERROR(!lblock_ok, mp, XFS_ERRTAG_BTREE_CHECK_LBLOCK, 210 if (unlikely(XFS_TEST_ERROR(!lblock_ok, mp, XFS_ERRTAG_BTREE_CHECK_LBLOCK,
208 XFS_RANDOM_BTREE_CHECK_LBLOCK))) { 211 XFS_RANDOM_BTREE_CHECK_LBLOCK))) {
209 if (bp) 212 if (bp)
@@ -251,8 +254,9 @@ xfs_btree_check_rec(
251 254
252 r1 = ar1; 255 r1 = ar1;
253 r2 = ar2; 256 r2 = ar2;
254 ASSERT(INT_GET(r1->ar_startblock, ARCH_CONVERT) + INT_GET(r1->ar_blockcount, ARCH_CONVERT) <= 257 ASSERT(be32_to_cpu(r1->ar_startblock) +
255 INT_GET(r2->ar_startblock, ARCH_CONVERT)); 258 be32_to_cpu(r1->ar_blockcount) <=
259 be32_to_cpu(r2->ar_startblock));
256 break; 260 break;
257 } 261 }
258 case XFS_BTNUM_CNT: { 262 case XFS_BTNUM_CNT: {
@@ -261,9 +265,9 @@ xfs_btree_check_rec(
261 265
262 r1 = ar1; 266 r1 = ar1;
263 r2 = ar2; 267 r2 = ar2;
264 ASSERT(INT_GET(r1->ar_blockcount, ARCH_CONVERT) < INT_GET(r2->ar_blockcount, ARCH_CONVERT) || 268 ASSERT(be32_to_cpu(r1->ar_blockcount) < be32_to_cpu(r2->ar_blockcount) ||
265 (INT_GET(r1->ar_blockcount, ARCH_CONVERT) == INT_GET(r2->ar_blockcount, ARCH_CONVERT) && 269 (r1->ar_blockcount == r2->ar_blockcount &&
266 INT_GET(r1->ar_startblock, ARCH_CONVERT) < INT_GET(r2->ar_startblock, ARCH_CONVERT))); 270 be32_to_cpu(r1->ar_startblock) < be32_to_cpu(r2->ar_startblock)));
267 break; 271 break;
268 } 272 }
269 case XFS_BTNUM_BMAP: { 273 case XFS_BTNUM_BMAP: {
@@ -311,17 +315,17 @@ xfs_btree_check_sblock(
311 315
312 agbp = cur->bc_private.a.agbp; 316 agbp = cur->bc_private.a.agbp;
313 agf = XFS_BUF_TO_AGF(agbp); 317 agf = XFS_BUF_TO_AGF(agbp);
314 agflen = INT_GET(agf->agf_length, ARCH_CONVERT); 318 agflen = be32_to_cpu(agf->agf_length);
315 sblock_ok = 319 sblock_ok =
316 INT_GET(block->bb_magic, ARCH_CONVERT) == xfs_magics[cur->bc_btnum] && 320 be32_to_cpu(block->bb_magic) == xfs_magics[cur->bc_btnum] &&
317 INT_GET(block->bb_level, ARCH_CONVERT) == level && 321 be16_to_cpu(block->bb_level) == level &&
318 INT_GET(block->bb_numrecs, ARCH_CONVERT) <= 322 be16_to_cpu(block->bb_numrecs) <=
319 xfs_btree_maxrecs(cur, (xfs_btree_block_t *)block) && 323 xfs_btree_maxrecs(cur, (xfs_btree_block_t *)block) &&
320 (INT_GET(block->bb_leftsib, ARCH_CONVERT) == NULLAGBLOCK || 324 (be32_to_cpu(block->bb_leftsib) == NULLAGBLOCK ||
321 INT_GET(block->bb_leftsib, ARCH_CONVERT) < agflen) && 325 be32_to_cpu(block->bb_leftsib) < agflen) &&
322 block->bb_leftsib && 326 block->bb_leftsib &&
323 (INT_GET(block->bb_rightsib, ARCH_CONVERT) == NULLAGBLOCK || 327 (be32_to_cpu(block->bb_rightsib) == NULLAGBLOCK ||
324 INT_GET(block->bb_rightsib, ARCH_CONVERT) < agflen) && 328 be32_to_cpu(block->bb_rightsib) < agflen) &&
325 block->bb_rightsib; 329 block->bb_rightsib;
326 if (unlikely(XFS_TEST_ERROR(!sblock_ok, cur->bc_mp, 330 if (unlikely(XFS_TEST_ERROR(!sblock_ok, cur->bc_mp,
327 XFS_ERRTAG_BTREE_CHECK_SBLOCK, 331 XFS_ERRTAG_BTREE_CHECK_SBLOCK,
@@ -352,7 +356,7 @@ xfs_btree_check_sptr(
352 XFS_WANT_CORRUPTED_RETURN( 356 XFS_WANT_CORRUPTED_RETURN(
353 level > 0 && 357 level > 0 &&
354 ptr != NULLAGBLOCK && ptr != 0 && 358 ptr != NULLAGBLOCK && ptr != 0 &&
355 ptr < INT_GET(agf->agf_length, ARCH_CONVERT)); 359 ptr < be32_to_cpu(agf->agf_length));
356 return 0; 360 return 0;
357} 361}
358 362
@@ -591,15 +595,15 @@ xfs_btree_init_cursor(
591 case XFS_BTNUM_BNO: 595 case XFS_BTNUM_BNO:
592 case XFS_BTNUM_CNT: 596 case XFS_BTNUM_CNT:
593 agf = XFS_BUF_TO_AGF(agbp); 597 agf = XFS_BUF_TO_AGF(agbp);
594 nlevels = INT_GET(agf->agf_levels[btnum], ARCH_CONVERT); 598 nlevels = be32_to_cpu(agf->agf_levels[btnum]);
595 break; 599 break;
596 case XFS_BTNUM_BMAP: 600 case XFS_BTNUM_BMAP:
597 ifp = XFS_IFORK_PTR(ip, whichfork); 601 ifp = XFS_IFORK_PTR(ip, whichfork);
598 nlevels = INT_GET(ifp->if_broot->bb_level, ARCH_CONVERT) + 1; 602 nlevels = be16_to_cpu(ifp->if_broot->bb_level) + 1;
599 break; 603 break;
600 case XFS_BTNUM_INO: 604 case XFS_BTNUM_INO:
601 agi = XFS_BUF_TO_AGI(agbp); 605 agi = XFS_BUF_TO_AGI(agbp);
602 nlevels = INT_GET(agi->agi_level, ARCH_CONVERT); 606 nlevels = be32_to_cpu(agi->agi_level);
603 break; 607 break;
604 default: 608 default:
605 ASSERT(0); 609 ASSERT(0);
@@ -663,9 +667,9 @@ xfs_btree_islastblock(
663 block = xfs_btree_get_block(cur, level, &bp); 667 block = xfs_btree_get_block(cur, level, &bp);
664 xfs_btree_check_block(cur, block, level, bp); 668 xfs_btree_check_block(cur, block, level, bp);
665 if (XFS_BTREE_LONG_PTRS(cur->bc_btnum)) 669 if (XFS_BTREE_LONG_PTRS(cur->bc_btnum))
666 return INT_GET(block->bb_u.l.bb_rightsib, ARCH_CONVERT) == NULLDFSBNO; 670 return be64_to_cpu(block->bb_u.l.bb_rightsib) == NULLDFSBNO;
667 else 671 else
668 return INT_GET(block->bb_u.s.bb_rightsib, ARCH_CONVERT) == NULLAGBLOCK; 672 return be32_to_cpu(block->bb_u.s.bb_rightsib) == NULLAGBLOCK;
669} 673}
670 674
671/* 675/*
@@ -693,7 +697,7 @@ xfs_btree_lastrec(
693 /* 697 /*
694 * Set the ptr value to numrecs, that's the last record/key. 698 * Set the ptr value to numrecs, that's the last record/key.
695 */ 699 */
696 cur->bc_ptrs[level] = INT_GET(block->bb_h.bb_numrecs, ARCH_CONVERT); 700 cur->bc_ptrs[level] = be16_to_cpu(block->bb_h.bb_numrecs);
697 return 1; 701 return 1;
698} 702}
699 703
@@ -863,38 +867,38 @@ xfs_btree_readahead_core(
863 case XFS_BTNUM_BNO: 867 case XFS_BTNUM_BNO:
864 case XFS_BTNUM_CNT: 868 case XFS_BTNUM_CNT:
865 a = XFS_BUF_TO_ALLOC_BLOCK(cur->bc_bufs[lev]); 869 a = XFS_BUF_TO_ALLOC_BLOCK(cur->bc_bufs[lev]);
866 if ((lr & XFS_BTCUR_LEFTRA) && INT_GET(a->bb_leftsib, ARCH_CONVERT) != NULLAGBLOCK) { 870 if ((lr & XFS_BTCUR_LEFTRA) && be32_to_cpu(a->bb_leftsib) != NULLAGBLOCK) {
867 xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.a.agno, 871 xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.a.agno,
868 INT_GET(a->bb_leftsib, ARCH_CONVERT), 1); 872 be32_to_cpu(a->bb_leftsib), 1);
869 rval++; 873 rval++;
870 } 874 }
871 if ((lr & XFS_BTCUR_RIGHTRA) && INT_GET(a->bb_rightsib, ARCH_CONVERT) != NULLAGBLOCK) { 875 if ((lr & XFS_BTCUR_RIGHTRA) && be32_to_cpu(a->bb_rightsib) != NULLAGBLOCK) {
872 xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.a.agno, 876 xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.a.agno,
873 INT_GET(a->bb_rightsib, ARCH_CONVERT), 1); 877 be32_to_cpu(a->bb_rightsib), 1);
874 rval++; 878 rval++;
875 } 879 }
876 break; 880 break;
877 case XFS_BTNUM_BMAP: 881 case XFS_BTNUM_BMAP:
878 b = XFS_BUF_TO_BMBT_BLOCK(cur->bc_bufs[lev]); 882 b = XFS_BUF_TO_BMBT_BLOCK(cur->bc_bufs[lev]);
879 if ((lr & XFS_BTCUR_LEFTRA) && INT_GET(b->bb_leftsib, ARCH_CONVERT) != NULLDFSBNO) { 883 if ((lr & XFS_BTCUR_LEFTRA) && be64_to_cpu(b->bb_leftsib) != NULLDFSBNO) {
880 xfs_btree_reada_bufl(cur->bc_mp, INT_GET(b->bb_leftsib, ARCH_CONVERT), 1); 884 xfs_btree_reada_bufl(cur->bc_mp, be64_to_cpu(b->bb_leftsib), 1);
881 rval++; 885 rval++;
882 } 886 }
883 if ((lr & XFS_BTCUR_RIGHTRA) && INT_GET(b->bb_rightsib, ARCH_CONVERT) != NULLDFSBNO) { 887 if ((lr & XFS_BTCUR_RIGHTRA) && be64_to_cpu(b->bb_rightsib) != NULLDFSBNO) {
884 xfs_btree_reada_bufl(cur->bc_mp, INT_GET(b->bb_rightsib, ARCH_CONVERT), 1); 888 xfs_btree_reada_bufl(cur->bc_mp, be64_to_cpu(b->bb_rightsib), 1);
885 rval++; 889 rval++;
886 } 890 }
887 break; 891 break;
888 case XFS_BTNUM_INO: 892 case XFS_BTNUM_INO:
889 i = XFS_BUF_TO_INOBT_BLOCK(cur->bc_bufs[lev]); 893 i = XFS_BUF_TO_INOBT_BLOCK(cur->bc_bufs[lev]);
890 if ((lr & XFS_BTCUR_LEFTRA) && INT_GET(i->bb_leftsib, ARCH_CONVERT) != NULLAGBLOCK) { 894 if ((lr & XFS_BTCUR_LEFTRA) && be32_to_cpu(i->bb_leftsib) != NULLAGBLOCK) {
891 xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.i.agno, 895 xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.i.agno,
892 INT_GET(i->bb_leftsib, ARCH_CONVERT), 1); 896 be32_to_cpu(i->bb_leftsib), 1);
893 rval++; 897 rval++;
894 } 898 }
895 if ((lr & XFS_BTCUR_RIGHTRA) && INT_GET(i->bb_rightsib, ARCH_CONVERT) != NULLAGBLOCK) { 899 if ((lr & XFS_BTCUR_RIGHTRA) && be32_to_cpu(i->bb_rightsib) != NULLAGBLOCK) {
896 xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.i.agno, 900 xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.i.agno,
897 INT_GET(i->bb_rightsib, ARCH_CONVERT), 1); 901 be32_to_cpu(i->bb_rightsib), 1);
898 rval++; 902 rval++;
899 } 903 }
900 break; 904 break;
@@ -926,14 +930,14 @@ xfs_btree_setbuf(
926 return; 930 return;
927 b = XFS_BUF_TO_BLOCK(bp); 931 b = XFS_BUF_TO_BLOCK(bp);
928 if (XFS_BTREE_LONG_PTRS(cur->bc_btnum)) { 932 if (XFS_BTREE_LONG_PTRS(cur->bc_btnum)) {
929 if (INT_GET(b->bb_u.l.bb_leftsib, ARCH_CONVERT) == NULLDFSBNO) 933 if (be64_to_cpu(b->bb_u.l.bb_leftsib) == NULLDFSBNO)
930 cur->bc_ra[lev] |= XFS_BTCUR_LEFTRA; 934 cur->bc_ra[lev] |= XFS_BTCUR_LEFTRA;
931 if (INT_GET(b->bb_u.l.bb_rightsib, ARCH_CONVERT) == NULLDFSBNO) 935 if (be64_to_cpu(b->bb_u.l.bb_rightsib) == NULLDFSBNO)
932 cur->bc_ra[lev] |= XFS_BTCUR_RIGHTRA; 936 cur->bc_ra[lev] |= XFS_BTCUR_RIGHTRA;
933 } else { 937 } else {
934 if (INT_GET(b->bb_u.s.bb_leftsib, ARCH_CONVERT) == NULLAGBLOCK) 938 if (be32_to_cpu(b->bb_u.s.bb_leftsib) == NULLAGBLOCK)
935 cur->bc_ra[lev] |= XFS_BTCUR_LEFTRA; 939 cur->bc_ra[lev] |= XFS_BTCUR_LEFTRA;
936 if (INT_GET(b->bb_u.s.bb_rightsib, ARCH_CONVERT) == NULLAGBLOCK) 940 if (be32_to_cpu(b->bb_u.s.bb_rightsib) == NULLAGBLOCK)
937 cur->bc_ra[lev] |= XFS_BTCUR_RIGHTRA; 941 cur->bc_ra[lev] |= XFS_BTCUR_RIGHTRA;
938 } 942 }
939} 943}