diff options
author | Christoph Hellwig <hch@infradead.org> | 2008-08-13 02:25:27 -0400 |
---|---|---|
committer | Lachlan McIlroy <lachlan@redback.melbourne.sgi.com> | 2008-08-13 02:25:27 -0400 |
commit | 169d6227a71da125913c69c381643a8ae89da62d (patch) | |
tree | dfd2fbd343e7be583c5e767f897140de7ccc482c /fs/xfs | |
parent | cdcf43335cbb2380e533441e007e0c4ec42634d5 (diff) |
[XFS] Use the same btree_cur union member for alloc and inobt trees.
The alloc and inobt btree use the same agbp/agno pair in the btree_cur
union. Make them use the same bc_private.a union member so that code for
these two short form btree implementations can be shared.
SGI-PV: 981498
SGI-Modid: xfs-linux-melb:xfs-kern:31788a
Signed-off-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Tim Shimmin <tes@sgi.com>
Signed-off-by: David Chinner <david@fromorbit.com>
Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/xfs_btree.c | 18 | ||||
-rw-r--r-- | fs/xfs/xfs_btree.h | 8 | ||||
-rw-r--r-- | fs/xfs/xfs_ialloc_btree.c | 30 |
3 files changed, 26 insertions, 30 deletions
diff --git a/fs/xfs/xfs_btree.c b/fs/xfs/xfs_btree.c index 2b0d454e92ec..cc593a84c345 100644 --- a/fs/xfs/xfs_btree.c +++ b/fs/xfs/xfs_btree.c | |||
@@ -570,6 +570,13 @@ xfs_btree_init_cursor( | |||
570 | cur->bc_private.a.agbp = agbp; | 570 | cur->bc_private.a.agbp = agbp; |
571 | cur->bc_private.a.agno = agno; | 571 | cur->bc_private.a.agno = agno; |
572 | break; | 572 | break; |
573 | case XFS_BTNUM_INO: | ||
574 | /* | ||
575 | * Inode allocation btree fields. | ||
576 | */ | ||
577 | cur->bc_private.a.agbp = agbp; | ||
578 | cur->bc_private.a.agno = agno; | ||
579 | break; | ||
573 | case XFS_BTNUM_BMAP: | 580 | case XFS_BTNUM_BMAP: |
574 | /* | 581 | /* |
575 | * Bmap btree fields. | 582 | * Bmap btree fields. |
@@ -582,13 +589,6 @@ xfs_btree_init_cursor( | |||
582 | cur->bc_private.b.flags = 0; | 589 | cur->bc_private.b.flags = 0; |
583 | cur->bc_private.b.whichfork = whichfork; | 590 | cur->bc_private.b.whichfork = whichfork; |
584 | break; | 591 | break; |
585 | case XFS_BTNUM_INO: | ||
586 | /* | ||
587 | * Inode allocation btree fields. | ||
588 | */ | ||
589 | cur->bc_private.i.agbp = agbp; | ||
590 | cur->bc_private.i.agno = agno; | ||
591 | break; | ||
592 | default: | 592 | default: |
593 | ASSERT(0); | 593 | ASSERT(0); |
594 | } | 594 | } |
@@ -863,12 +863,12 @@ xfs_btree_readahead_core( | |||
863 | case XFS_BTNUM_INO: | 863 | case XFS_BTNUM_INO: |
864 | i = XFS_BUF_TO_INOBT_BLOCK(cur->bc_bufs[lev]); | 864 | i = XFS_BUF_TO_INOBT_BLOCK(cur->bc_bufs[lev]); |
865 | if ((lr & XFS_BTCUR_LEFTRA) && be32_to_cpu(i->bb_leftsib) != NULLAGBLOCK) { | 865 | if ((lr & XFS_BTCUR_LEFTRA) && be32_to_cpu(i->bb_leftsib) != NULLAGBLOCK) { |
866 | xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.i.agno, | 866 | xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.a.agno, |
867 | be32_to_cpu(i->bb_leftsib), 1); | 867 | be32_to_cpu(i->bb_leftsib), 1); |
868 | rval++; | 868 | rval++; |
869 | } | 869 | } |
870 | if ((lr & XFS_BTCUR_RIGHTRA) && be32_to_cpu(i->bb_rightsib) != NULLAGBLOCK) { | 870 | if ((lr & XFS_BTCUR_RIGHTRA) && be32_to_cpu(i->bb_rightsib) != NULLAGBLOCK) { |
871 | xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.i.agno, | 871 | xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.a.agno, |
872 | be32_to_cpu(i->bb_rightsib), 1); | 872 | be32_to_cpu(i->bb_rightsib), 1); |
873 | rval++; | 873 | rval++; |
874 | } | 874 | } |
diff --git a/fs/xfs/xfs_btree.h b/fs/xfs/xfs_btree.h index 7440b78f9cec..1f528a2a3754 100644 --- a/fs/xfs/xfs_btree.h +++ b/fs/xfs/xfs_btree.h | |||
@@ -158,8 +158,8 @@ typedef struct xfs_btree_cur | |||
158 | __uint8_t bc_blocklog; /* log2(blocksize) of btree blocks */ | 158 | __uint8_t bc_blocklog; /* log2(blocksize) of btree blocks */ |
159 | xfs_btnum_t bc_btnum; /* identifies which btree type */ | 159 | xfs_btnum_t bc_btnum; /* identifies which btree type */ |
160 | union { | 160 | union { |
161 | struct { /* needed for BNO, CNT */ | 161 | struct { /* needed for BNO, CNT, INO */ |
162 | struct xfs_buf *agbp; /* agf buffer pointer */ | 162 | struct xfs_buf *agbp; /* agf/agi buffer pointer */ |
163 | xfs_agnumber_t agno; /* ag number */ | 163 | xfs_agnumber_t agno; /* ag number */ |
164 | } a; | 164 | } a; |
165 | struct { /* needed for BMAP */ | 165 | struct { /* needed for BMAP */ |
@@ -172,10 +172,6 @@ typedef struct xfs_btree_cur | |||
172 | char flags; /* flags */ | 172 | char flags; /* flags */ |
173 | #define XFS_BTCUR_BPRV_WASDEL 1 /* was delayed */ | 173 | #define XFS_BTCUR_BPRV_WASDEL 1 /* was delayed */ |
174 | } b; | 174 | } b; |
175 | struct { /* needed for INO */ | ||
176 | struct xfs_buf *agbp; /* agi buffer pointer */ | ||
177 | xfs_agnumber_t agno; /* ag number */ | ||
178 | } i; | ||
179 | } bc_private; /* per-btree type data */ | 175 | } bc_private; /* per-btree type data */ |
180 | } xfs_btree_cur_t; | 176 | } xfs_btree_cur_t; |
181 | 177 | ||
diff --git a/fs/xfs/xfs_ialloc_btree.c b/fs/xfs/xfs_ialloc_btree.c index e5310c90e50f..83502f3edef0 100644 --- a/fs/xfs/xfs_ialloc_btree.c +++ b/fs/xfs/xfs_ialloc_btree.c | |||
@@ -181,7 +181,7 @@ xfs_inobt_delrec( | |||
181 | * then we can get rid of this level. | 181 | * then we can get rid of this level. |
182 | */ | 182 | */ |
183 | if (numrecs == 1 && level > 0) { | 183 | if (numrecs == 1 && level > 0) { |
184 | agbp = cur->bc_private.i.agbp; | 184 | agbp = cur->bc_private.a.agbp; |
185 | agi = XFS_BUF_TO_AGI(agbp); | 185 | agi = XFS_BUF_TO_AGI(agbp); |
186 | /* | 186 | /* |
187 | * pp is still set to the first pointer in the block. | 187 | * pp is still set to the first pointer in the block. |
@@ -194,7 +194,7 @@ xfs_inobt_delrec( | |||
194 | * Free the block. | 194 | * Free the block. |
195 | */ | 195 | */ |
196 | if ((error = xfs_free_extent(cur->bc_tp, | 196 | if ((error = xfs_free_extent(cur->bc_tp, |
197 | XFS_AGB_TO_FSB(mp, cur->bc_private.i.agno, bno), 1))) | 197 | XFS_AGB_TO_FSB(mp, cur->bc_private.a.agno, bno), 1))) |
198 | return error; | 198 | return error; |
199 | xfs_trans_binval(cur->bc_tp, bp); | 199 | xfs_trans_binval(cur->bc_tp, bp); |
200 | xfs_ialloc_log_agi(cur->bc_tp, agbp, | 200 | xfs_ialloc_log_agi(cur->bc_tp, agbp, |
@@ -379,7 +379,7 @@ xfs_inobt_delrec( | |||
379 | rrecs = be16_to_cpu(right->bb_numrecs); | 379 | rrecs = be16_to_cpu(right->bb_numrecs); |
380 | rbp = bp; | 380 | rbp = bp; |
381 | if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, | 381 | if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, |
382 | cur->bc_private.i.agno, lbno, 0, &lbp, | 382 | cur->bc_private.a.agno, lbno, 0, &lbp, |
383 | XFS_INO_BTREE_REF))) | 383 | XFS_INO_BTREE_REF))) |
384 | return error; | 384 | return error; |
385 | left = XFS_BUF_TO_INOBT_BLOCK(lbp); | 385 | left = XFS_BUF_TO_INOBT_BLOCK(lbp); |
@@ -401,7 +401,7 @@ xfs_inobt_delrec( | |||
401 | lrecs = be16_to_cpu(left->bb_numrecs); | 401 | lrecs = be16_to_cpu(left->bb_numrecs); |
402 | lbp = bp; | 402 | lbp = bp; |
403 | if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, | 403 | if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, |
404 | cur->bc_private.i.agno, rbno, 0, &rbp, | 404 | cur->bc_private.a.agno, rbno, 0, &rbp, |
405 | XFS_INO_BTREE_REF))) | 405 | XFS_INO_BTREE_REF))) |
406 | return error; | 406 | return error; |
407 | right = XFS_BUF_TO_INOBT_BLOCK(rbp); | 407 | right = XFS_BUF_TO_INOBT_BLOCK(rbp); |
@@ -484,7 +484,7 @@ xfs_inobt_delrec( | |||
484 | xfs_buf_t *rrbp; | 484 | xfs_buf_t *rrbp; |
485 | 485 | ||
486 | if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, | 486 | if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, |
487 | cur->bc_private.i.agno, be32_to_cpu(left->bb_rightsib), 0, | 487 | cur->bc_private.a.agno, be32_to_cpu(left->bb_rightsib), 0, |
488 | &rrbp, XFS_INO_BTREE_REF))) | 488 | &rrbp, XFS_INO_BTREE_REF))) |
489 | return error; | 489 | return error; |
490 | rrblock = XFS_BUF_TO_INOBT_BLOCK(rrbp); | 490 | rrblock = XFS_BUF_TO_INOBT_BLOCK(rrbp); |
@@ -497,7 +497,7 @@ xfs_inobt_delrec( | |||
497 | * Free the deleting block. | 497 | * Free the deleting block. |
498 | */ | 498 | */ |
499 | if ((error = xfs_free_extent(cur->bc_tp, XFS_AGB_TO_FSB(mp, | 499 | if ((error = xfs_free_extent(cur->bc_tp, XFS_AGB_TO_FSB(mp, |
500 | cur->bc_private.i.agno, rbno), 1))) | 500 | cur->bc_private.a.agno, rbno), 1))) |
501 | return error; | 501 | return error; |
502 | xfs_trans_binval(cur->bc_tp, rbp); | 502 | xfs_trans_binval(cur->bc_tp, rbp); |
503 | /* | 503 | /* |
@@ -854,7 +854,7 @@ xfs_inobt_lookup( | |||
854 | { | 854 | { |
855 | xfs_agi_t *agi; /* a.g. inode header */ | 855 | xfs_agi_t *agi; /* a.g. inode header */ |
856 | 856 | ||
857 | agi = XFS_BUF_TO_AGI(cur->bc_private.i.agbp); | 857 | agi = XFS_BUF_TO_AGI(cur->bc_private.a.agbp); |
858 | agno = be32_to_cpu(agi->agi_seqno); | 858 | agno = be32_to_cpu(agi->agi_seqno); |
859 | agbno = be32_to_cpu(agi->agi_root); | 859 | agbno = be32_to_cpu(agi->agi_root); |
860 | } | 860 | } |
@@ -1089,7 +1089,7 @@ xfs_inobt_lshift( | |||
1089 | * Set up the left neighbor as "left". | 1089 | * Set up the left neighbor as "left". |
1090 | */ | 1090 | */ |
1091 | if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, | 1091 | if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, |
1092 | cur->bc_private.i.agno, be32_to_cpu(right->bb_leftsib), | 1092 | cur->bc_private.a.agno, be32_to_cpu(right->bb_leftsib), |
1093 | 0, &lbp, XFS_INO_BTREE_REF))) | 1093 | 0, &lbp, XFS_INO_BTREE_REF))) |
1094 | return error; | 1094 | return error; |
1095 | left = XFS_BUF_TO_INOBT_BLOCK(lbp); | 1095 | left = XFS_BUF_TO_INOBT_BLOCK(lbp); |
@@ -1207,10 +1207,10 @@ xfs_inobt_newroot( | |||
1207 | /* | 1207 | /* |
1208 | * Get a block & a buffer. | 1208 | * Get a block & a buffer. |
1209 | */ | 1209 | */ |
1210 | agi = XFS_BUF_TO_AGI(cur->bc_private.i.agbp); | 1210 | agi = XFS_BUF_TO_AGI(cur->bc_private.a.agbp); |
1211 | args.tp = cur->bc_tp; | 1211 | args.tp = cur->bc_tp; |
1212 | args.mp = cur->bc_mp; | 1212 | args.mp = cur->bc_mp; |
1213 | args.fsbno = XFS_AGB_TO_FSB(args.mp, cur->bc_private.i.agno, | 1213 | args.fsbno = XFS_AGB_TO_FSB(args.mp, cur->bc_private.a.agno, |
1214 | be32_to_cpu(agi->agi_root)); | 1214 | be32_to_cpu(agi->agi_root)); |
1215 | args.mod = args.minleft = args.alignment = args.total = args.wasdel = | 1215 | args.mod = args.minleft = args.alignment = args.total = args.wasdel = |
1216 | args.isfl = args.userdata = args.minalignslop = 0; | 1216 | args.isfl = args.userdata = args.minalignslop = 0; |
@@ -1233,7 +1233,7 @@ xfs_inobt_newroot( | |||
1233 | */ | 1233 | */ |
1234 | agi->agi_root = cpu_to_be32(args.agbno); | 1234 | agi->agi_root = cpu_to_be32(args.agbno); |
1235 | be32_add_cpu(&agi->agi_level, 1); | 1235 | be32_add_cpu(&agi->agi_level, 1); |
1236 | xfs_ialloc_log_agi(args.tp, cur->bc_private.i.agbp, | 1236 | xfs_ialloc_log_agi(args.tp, cur->bc_private.a.agbp, |
1237 | XFS_AGI_ROOT | XFS_AGI_LEVEL); | 1237 | XFS_AGI_ROOT | XFS_AGI_LEVEL); |
1238 | /* | 1238 | /* |
1239 | * At the previous root level there are now two blocks: the old | 1239 | * At the previous root level there are now two blocks: the old |
@@ -1376,7 +1376,7 @@ xfs_inobt_rshift( | |||
1376 | * Set up the right neighbor as "right". | 1376 | * Set up the right neighbor as "right". |
1377 | */ | 1377 | */ |
1378 | if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, | 1378 | if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, |
1379 | cur->bc_private.i.agno, be32_to_cpu(left->bb_rightsib), | 1379 | cur->bc_private.a.agno, be32_to_cpu(left->bb_rightsib), |
1380 | 0, &rbp, XFS_INO_BTREE_REF))) | 1380 | 0, &rbp, XFS_INO_BTREE_REF))) |
1381 | return error; | 1381 | return error; |
1382 | right = XFS_BUF_TO_INOBT_BLOCK(rbp); | 1382 | right = XFS_BUF_TO_INOBT_BLOCK(rbp); |
@@ -1492,7 +1492,7 @@ xfs_inobt_split( | |||
1492 | * Allocate the new block. | 1492 | * Allocate the new block. |
1493 | * If we can't do it, we're toast. Give up. | 1493 | * If we can't do it, we're toast. Give up. |
1494 | */ | 1494 | */ |
1495 | args.fsbno = XFS_AGB_TO_FSB(args.mp, cur->bc_private.i.agno, lbno); | 1495 | args.fsbno = XFS_AGB_TO_FSB(args.mp, cur->bc_private.a.agno, lbno); |
1496 | args.mod = args.minleft = args.alignment = args.total = args.wasdel = | 1496 | args.mod = args.minleft = args.alignment = args.total = args.wasdel = |
1497 | args.isfl = args.userdata = args.minalignslop = 0; | 1497 | args.isfl = args.userdata = args.minalignslop = 0; |
1498 | args.minlen = args.maxlen = args.prod = 1; | 1498 | args.minlen = args.maxlen = args.prod = 1; |
@@ -1725,7 +1725,7 @@ xfs_inobt_decrement( | |||
1725 | 1725 | ||
1726 | agbno = be32_to_cpu(*XFS_INOBT_PTR_ADDR(block, cur->bc_ptrs[lev], cur)); | 1726 | agbno = be32_to_cpu(*XFS_INOBT_PTR_ADDR(block, cur->bc_ptrs[lev], cur)); |
1727 | if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, | 1727 | if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, |
1728 | cur->bc_private.i.agno, agbno, 0, &bp, | 1728 | cur->bc_private.a.agno, agbno, 0, &bp, |
1729 | XFS_INO_BTREE_REF))) | 1729 | XFS_INO_BTREE_REF))) |
1730 | return error; | 1730 | return error; |
1731 | lev--; | 1731 | lev--; |
@@ -1897,7 +1897,7 @@ xfs_inobt_increment( | |||
1897 | 1897 | ||
1898 | agbno = be32_to_cpu(*XFS_INOBT_PTR_ADDR(block, cur->bc_ptrs[lev], cur)); | 1898 | agbno = be32_to_cpu(*XFS_INOBT_PTR_ADDR(block, cur->bc_ptrs[lev], cur)); |
1899 | if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, | 1899 | if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, |
1900 | cur->bc_private.i.agno, agbno, 0, &bp, | 1900 | cur->bc_private.a.agno, agbno, 0, &bp, |
1901 | XFS_INO_BTREE_REF))) | 1901 | XFS_INO_BTREE_REF))) |
1902 | return error; | 1902 | return error; |
1903 | lev--; | 1903 | lev--; |