Commit 169d6227 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Lachlan McIlroy

[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: default avatarChristoph Hellwig <hch@infradead.org>
Signed-off-by: default avatarTim Shimmin <tes@sgi.com>
Signed-off-by: default avatarDavid Chinner <david@fromorbit.com>
Signed-off-by: default avatarLachlan McIlroy <lachlan@sgi.com>
parent cdcf4333
...@@ -570,6 +570,13 @@ xfs_btree_init_cursor( ...@@ -570,6 +570,13 @@ xfs_btree_init_cursor(
cur->bc_private.a.agbp = agbp; cur->bc_private.a.agbp = agbp;
cur->bc_private.a.agno = agno; cur->bc_private.a.agno = agno;
break; break;
case XFS_BTNUM_INO:
/*
* Inode allocation btree fields.
*/
cur->bc_private.a.agbp = agbp;
cur->bc_private.a.agno = agno;
break;
case XFS_BTNUM_BMAP: case XFS_BTNUM_BMAP:
/* /*
* Bmap btree fields. * Bmap btree fields.
...@@ -582,13 +589,6 @@ xfs_btree_init_cursor( ...@@ -582,13 +589,6 @@ xfs_btree_init_cursor(
cur->bc_private.b.flags = 0; cur->bc_private.b.flags = 0;
cur->bc_private.b.whichfork = whichfork; cur->bc_private.b.whichfork = whichfork;
break; break;
case XFS_BTNUM_INO:
/*
* Inode allocation btree fields.
*/
cur->bc_private.i.agbp = agbp;
cur->bc_private.i.agno = agno;
break;
default: default:
ASSERT(0); ASSERT(0);
} }
...@@ -863,12 +863,12 @@ xfs_btree_readahead_core( ...@@ -863,12 +863,12 @@ xfs_btree_readahead_core(
case XFS_BTNUM_INO: case XFS_BTNUM_INO:
i = XFS_BUF_TO_INOBT_BLOCK(cur->bc_bufs[lev]); i = XFS_BUF_TO_INOBT_BLOCK(cur->bc_bufs[lev]);
if ((lr & XFS_BTCUR_LEFTRA) && be32_to_cpu(i->bb_leftsib) != NULLAGBLOCK) { if ((lr & XFS_BTCUR_LEFTRA) && be32_to_cpu(i->bb_leftsib) != NULLAGBLOCK) {
xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.i.agno, xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.a.agno,
be32_to_cpu(i->bb_leftsib), 1); be32_to_cpu(i->bb_leftsib), 1);
rval++; rval++;
} }
if ((lr & XFS_BTCUR_RIGHTRA) && be32_to_cpu(i->bb_rightsib) != NULLAGBLOCK) { if ((lr & XFS_BTCUR_RIGHTRA) && be32_to_cpu(i->bb_rightsib) != NULLAGBLOCK) {
xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.i.agno, xfs_btree_reada_bufs(cur->bc_mp, cur->bc_private.a.agno,
be32_to_cpu(i->bb_rightsib), 1); be32_to_cpu(i->bb_rightsib), 1);
rval++; rval++;
} }
......
...@@ -158,8 +158,8 @@ typedef struct xfs_btree_cur ...@@ -158,8 +158,8 @@ typedef struct xfs_btree_cur
__uint8_t bc_blocklog; /* log2(blocksize) of btree blocks */ __uint8_t bc_blocklog; /* log2(blocksize) of btree blocks */
xfs_btnum_t bc_btnum; /* identifies which btree type */ xfs_btnum_t bc_btnum; /* identifies which btree type */
union { union {
struct { /* needed for BNO, CNT */ struct { /* needed for BNO, CNT, INO */
struct xfs_buf *agbp; /* agf buffer pointer */ struct xfs_buf *agbp; /* agf/agi buffer pointer */
xfs_agnumber_t agno; /* ag number */ xfs_agnumber_t agno; /* ag number */
} a; } a;
struct { /* needed for BMAP */ struct { /* needed for BMAP */
...@@ -172,10 +172,6 @@ typedef struct xfs_btree_cur ...@@ -172,10 +172,6 @@ typedef struct xfs_btree_cur
char flags; /* flags */ char flags; /* flags */
#define XFS_BTCUR_BPRV_WASDEL 1 /* was delayed */ #define XFS_BTCUR_BPRV_WASDEL 1 /* was delayed */
} b; } b;
struct { /* needed for INO */
struct xfs_buf *agbp; /* agi buffer pointer */
xfs_agnumber_t agno; /* ag number */
} i;
} bc_private; /* per-btree type data */ } bc_private; /* per-btree type data */
} xfs_btree_cur_t; } xfs_btree_cur_t;
......
...@@ -181,7 +181,7 @@ xfs_inobt_delrec( ...@@ -181,7 +181,7 @@ xfs_inobt_delrec(
* then we can get rid of this level. * then we can get rid of this level.
*/ */
if (numrecs == 1 && level > 0) { if (numrecs == 1 && level > 0) {
agbp = cur->bc_private.i.agbp; agbp = cur->bc_private.a.agbp;
agi = XFS_BUF_TO_AGI(agbp); agi = XFS_BUF_TO_AGI(agbp);
/* /*
* pp is still set to the first pointer in the block. * pp is still set to the first pointer in the block.
...@@ -194,7 +194,7 @@ xfs_inobt_delrec( ...@@ -194,7 +194,7 @@ xfs_inobt_delrec(
* Free the block. * Free the block.
*/ */
if ((error = xfs_free_extent(cur->bc_tp, if ((error = xfs_free_extent(cur->bc_tp,
XFS_AGB_TO_FSB(mp, cur->bc_private.i.agno, bno), 1))) XFS_AGB_TO_FSB(mp, cur->bc_private.a.agno, bno), 1)))
return error; return error;
xfs_trans_binval(cur->bc_tp, bp); xfs_trans_binval(cur->bc_tp, bp);
xfs_ialloc_log_agi(cur->bc_tp, agbp, xfs_ialloc_log_agi(cur->bc_tp, agbp,
...@@ -379,7 +379,7 @@ xfs_inobt_delrec( ...@@ -379,7 +379,7 @@ xfs_inobt_delrec(
rrecs = be16_to_cpu(right->bb_numrecs); rrecs = be16_to_cpu(right->bb_numrecs);
rbp = bp; rbp = bp;
if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, if ((error = xfs_btree_read_bufs(mp, cur->bc_tp,
cur->bc_private.i.agno, lbno, 0, &lbp, cur->bc_private.a.agno, lbno, 0, &lbp,
XFS_INO_BTREE_REF))) XFS_INO_BTREE_REF)))
return error; return error;
left = XFS_BUF_TO_INOBT_BLOCK(lbp); left = XFS_BUF_TO_INOBT_BLOCK(lbp);
...@@ -401,7 +401,7 @@ xfs_inobt_delrec( ...@@ -401,7 +401,7 @@ xfs_inobt_delrec(
lrecs = be16_to_cpu(left->bb_numrecs); lrecs = be16_to_cpu(left->bb_numrecs);
lbp = bp; lbp = bp;
if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, if ((error = xfs_btree_read_bufs(mp, cur->bc_tp,
cur->bc_private.i.agno, rbno, 0, &rbp, cur->bc_private.a.agno, rbno, 0, &rbp,
XFS_INO_BTREE_REF))) XFS_INO_BTREE_REF)))
return error; return error;
right = XFS_BUF_TO_INOBT_BLOCK(rbp); right = XFS_BUF_TO_INOBT_BLOCK(rbp);
...@@ -484,7 +484,7 @@ xfs_inobt_delrec( ...@@ -484,7 +484,7 @@ xfs_inobt_delrec(
xfs_buf_t *rrbp; xfs_buf_t *rrbp;
if ((error = xfs_btree_read_bufs(mp, cur->bc_tp, if ((error = xfs_btree_read_bufs(mp, cur->bc_tp,
cur->bc_private.i.agno, be32_to_cpu(left->bb_rightsib), 0, cur->bc_private.a.agno, be32_to_cpu(left->bb_rightsib), 0,
&rrbp, XFS_INO_BTREE_REF))) &rrbp, XFS_INO_BTREE_REF)))
return error; return error;
rrblock = XFS_BUF_TO_INOBT_BLOCK(rrbp); rrblock = XFS_BUF_TO_INOBT_BLOCK(rrbp);
...@@ -497,7 +497,7 @@ xfs_inobt_delrec( ...@@ -497,7 +497,7 @@ xfs_inobt_delrec(
* Free the deleting block. * Free the deleting block.
*/ */
if ((error = xfs_free_extent(cur->bc_tp, XFS_AGB_TO_FSB(mp, if ((error = xfs_free_extent(cur->bc_tp, XFS_AGB_TO_FSB(mp,
cur->bc_private.i.agno, rbno), 1))) cur->bc_private.a.agno, rbno), 1)))
return error; return error;
xfs_trans_binval(cur->bc_tp, rbp); xfs_trans_binval(cur->bc_tp, rbp);
/* /*
...@@ -854,7 +854,7 @@ xfs_inobt_lookup( ...@@ -854,7 +854,7 @@ xfs_inobt_lookup(
{ {
xfs_agi_t *agi; /* a.g. inode header */ xfs_agi_t *agi; /* a.g. inode header */
agi = XFS_BUF_TO_AGI(cur->bc_private.i.agbp); agi = XFS_BUF_TO_AGI(cur->bc_private.a.agbp);
agno = be32_to_cpu(agi->agi_seqno); agno = be32_to_cpu(agi->agi_seqno);
agbno = be32_to_cpu(agi->agi_root); agbno = be32_to_cpu(agi->agi_root);
} }
...@@ -1089,7 +1089,7 @@ xfs_inobt_lshift( ...@@ -1089,7 +1089,7 @@ xfs_inobt_lshift(
* Set up the left neighbor as "left". * Set up the left neighbor as "left".
*/ */
if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp,
cur->bc_private.i.agno, be32_to_cpu(right->bb_leftsib), cur->bc_private.a.agno, be32_to_cpu(right->bb_leftsib),
0, &lbp, XFS_INO_BTREE_REF))) 0, &lbp, XFS_INO_BTREE_REF)))
return error; return error;
left = XFS_BUF_TO_INOBT_BLOCK(lbp); left = XFS_BUF_TO_INOBT_BLOCK(lbp);
...@@ -1207,10 +1207,10 @@ xfs_inobt_newroot( ...@@ -1207,10 +1207,10 @@ xfs_inobt_newroot(
/* /*
* Get a block & a buffer. * Get a block & a buffer.
*/ */
agi = XFS_BUF_TO_AGI(cur->bc_private.i.agbp); agi = XFS_BUF_TO_AGI(cur->bc_private.a.agbp);
args.tp = cur->bc_tp; args.tp = cur->bc_tp;
args.mp = cur->bc_mp; args.mp = cur->bc_mp;
args.fsbno = XFS_AGB_TO_FSB(args.mp, cur->bc_private.i.agno, args.fsbno = XFS_AGB_TO_FSB(args.mp, cur->bc_private.a.agno,
be32_to_cpu(agi->agi_root)); be32_to_cpu(agi->agi_root));
args.mod = args.minleft = args.alignment = args.total = args.wasdel = args.mod = args.minleft = args.alignment = args.total = args.wasdel =
args.isfl = args.userdata = args.minalignslop = 0; args.isfl = args.userdata = args.minalignslop = 0;
...@@ -1233,7 +1233,7 @@ xfs_inobt_newroot( ...@@ -1233,7 +1233,7 @@ xfs_inobt_newroot(
*/ */
agi->agi_root = cpu_to_be32(args.agbno); agi->agi_root = cpu_to_be32(args.agbno);
be32_add_cpu(&agi->agi_level, 1); be32_add_cpu(&agi->agi_level, 1);
xfs_ialloc_log_agi(args.tp, cur->bc_private.i.agbp, xfs_ialloc_log_agi(args.tp, cur->bc_private.a.agbp,
XFS_AGI_ROOT | XFS_AGI_LEVEL); XFS_AGI_ROOT | XFS_AGI_LEVEL);
/* /*
* At the previous root level there are now two blocks: the old * At the previous root level there are now two blocks: the old
...@@ -1376,7 +1376,7 @@ xfs_inobt_rshift( ...@@ -1376,7 +1376,7 @@ xfs_inobt_rshift(
* Set up the right neighbor as "right". * Set up the right neighbor as "right".
*/ */
if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp,
cur->bc_private.i.agno, be32_to_cpu(left->bb_rightsib), cur->bc_private.a.agno, be32_to_cpu(left->bb_rightsib),
0, &rbp, XFS_INO_BTREE_REF))) 0, &rbp, XFS_INO_BTREE_REF)))
return error; return error;
right = XFS_BUF_TO_INOBT_BLOCK(rbp); right = XFS_BUF_TO_INOBT_BLOCK(rbp);
...@@ -1492,7 +1492,7 @@ xfs_inobt_split( ...@@ -1492,7 +1492,7 @@ xfs_inobt_split(
* Allocate the new block. * Allocate the new block.
* If we can't do it, we're toast. Give up. * If we can't do it, we're toast. Give up.
*/ */
args.fsbno = XFS_AGB_TO_FSB(args.mp, cur->bc_private.i.agno, lbno); args.fsbno = XFS_AGB_TO_FSB(args.mp, cur->bc_private.a.agno, lbno);
args.mod = args.minleft = args.alignment = args.total = args.wasdel = args.mod = args.minleft = args.alignment = args.total = args.wasdel =
args.isfl = args.userdata = args.minalignslop = 0; args.isfl = args.userdata = args.minalignslop = 0;
args.minlen = args.maxlen = args.prod = 1; args.minlen = args.maxlen = args.prod = 1;
...@@ -1725,7 +1725,7 @@ xfs_inobt_decrement( ...@@ -1725,7 +1725,7 @@ xfs_inobt_decrement(
agbno = be32_to_cpu(*XFS_INOBT_PTR_ADDR(block, cur->bc_ptrs[lev], cur)); agbno = be32_to_cpu(*XFS_INOBT_PTR_ADDR(block, cur->bc_ptrs[lev], cur));
if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp,
cur->bc_private.i.agno, agbno, 0, &bp, cur->bc_private.a.agno, agbno, 0, &bp,
XFS_INO_BTREE_REF))) XFS_INO_BTREE_REF)))
return error; return error;
lev--; lev--;
...@@ -1897,7 +1897,7 @@ xfs_inobt_increment( ...@@ -1897,7 +1897,7 @@ xfs_inobt_increment(
agbno = be32_to_cpu(*XFS_INOBT_PTR_ADDR(block, cur->bc_ptrs[lev], cur)); agbno = be32_to_cpu(*XFS_INOBT_PTR_ADDR(block, cur->bc_ptrs[lev], cur));
if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp, if ((error = xfs_btree_read_bufs(cur->bc_mp, cur->bc_tp,
cur->bc_private.i.agno, agbno, 0, &bp, cur->bc_private.a.agno, agbno, 0, &bp,
XFS_INO_BTREE_REF))) XFS_INO_BTREE_REF)))
return error; return error;
lev--; lev--;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment