Commit 7dda6e86 authored by Dave Chinner's avatar Dave Chinner Committed by Dave Chinner

xfs: convert directory segment limits to xfs_da_geometry

Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent 30028030
...@@ -598,7 +598,7 @@ xfs_da3_root_split( ...@@ -598,7 +598,7 @@ xfs_da3_root_split(
* Set up the new root node. * Set up the new root node.
*/ */
error = xfs_da3_node_create(args, error = xfs_da3_node_create(args,
(args->whichfork == XFS_DATA_FORK) ? mp->m_dirleafblk : 0, (args->whichfork == XFS_DATA_FORK) ? args->geo->leafblk : 0,
level + 1, &bp, args->whichfork); level + 1, &bp, args->whichfork);
if (error) if (error)
return error; return error;
...@@ -616,10 +616,10 @@ xfs_da3_root_split( ...@@ -616,10 +616,10 @@ xfs_da3_root_split(
#ifdef DEBUG #ifdef DEBUG
if (oldroot->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) || if (oldroot->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) ||
oldroot->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC)) { oldroot->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC)) {
ASSERT(blk1->blkno >= mp->m_dirleafblk && ASSERT(blk1->blkno >= args->geo->leafblk &&
blk1->blkno < mp->m_dirfreeblk); blk1->blkno < args->geo->freeblk);
ASSERT(blk2->blkno >= mp->m_dirleafblk && ASSERT(blk2->blkno >= args->geo->leafblk &&
blk2->blkno < mp->m_dirfreeblk); blk2->blkno < args->geo->freeblk);
} }
#endif #endif
...@@ -894,8 +894,8 @@ xfs_da3_node_add( ...@@ -894,8 +894,8 @@ xfs_da3_node_add(
ASSERT(oldblk->index >= 0 && oldblk->index <= nodehdr.count); ASSERT(oldblk->index >= 0 && oldblk->index <= nodehdr.count);
ASSERT(newblk->blkno != 0); ASSERT(newblk->blkno != 0);
if (state->args->whichfork == XFS_DATA_FORK) if (state->args->whichfork == XFS_DATA_FORK)
ASSERT(newblk->blkno >= state->mp->m_dirleafblk && ASSERT(newblk->blkno >= state->args->geo->leafblk &&
newblk->blkno < state->mp->m_dirfreeblk); newblk->blkno < state->args->geo->freeblk);
/* /*
* We may need to make some room before we insert the new node. * We may need to make some room before we insert the new node.
...@@ -1472,7 +1472,7 @@ xfs_da3_node_lookup_int( ...@@ -1472,7 +1472,7 @@ xfs_da3_node_lookup_int(
* Descend thru the B-tree searching each level for the right * Descend thru the B-tree searching each level for the right
* node to use, until the right hashval is found. * node to use, until the right hashval is found.
*/ */
blkno = (args->whichfork == XFS_DATA_FORK)? state->mp->m_dirleafblk : 0; blkno = (args->whichfork == XFS_DATA_FORK)? args->geo->leafblk : 0;
for (blk = &state->path.blk[0], state->path.active = 1; for (blk = &state->path.blk[0], state->path.active = 1;
state->path.active <= XFS_DA_NODE_MAXDEPTH; state->path.active <= XFS_DA_NODE_MAXDEPTH;
blk++, state->path.active++) { blk++, state->path.active++) {
...@@ -2096,7 +2096,7 @@ xfs_da_grow_inode( ...@@ -2096,7 +2096,7 @@ xfs_da_grow_inode(
trace_xfs_da_grow_inode(args); trace_xfs_da_grow_inode(args);
if (args->whichfork == XFS_DATA_FORK) { if (args->whichfork == XFS_DATA_FORK) {
bno = args->dp->i_mount->m_dirleafblk; bno = args->geo->leafblk;
count = args->dp->i_mount->m_dirblkfsbs; count = args->dp->i_mount->m_dirblkfsbs;
} else { } else {
bno = 0; bno = 0;
...@@ -2158,7 +2158,7 @@ xfs_da3_swap_lastblock( ...@@ -2158,7 +2158,7 @@ xfs_da3_swap_lastblock(
w = args->whichfork; w = args->whichfork;
ASSERT(w == XFS_DATA_FORK); ASSERT(w == XFS_DATA_FORK);
mp = dp->i_mount; mp = dp->i_mount;
lastoff = mp->m_dirfreeblk; lastoff = args->geo->freeblk;
error = xfs_bmap_last_before(tp, dp, &lastoff, w); error = xfs_bmap_last_before(tp, dp, &lastoff, w);
if (error) if (error)
return error; return error;
...@@ -2247,7 +2247,7 @@ xfs_da3_swap_lastblock( ...@@ -2247,7 +2247,7 @@ xfs_da3_swap_lastblock(
sizeof(sib_info->back))); sizeof(sib_info->back)));
sib_buf = NULL; sib_buf = NULL;
} }
par_blkno = mp->m_dirleafblk; par_blkno = args->geo->leafblk;
level = -1; level = -1;
/* /*
* Walk down the tree looking for the parent of the moved block. * Walk down the tree looking for the parent of the moved block.
......
...@@ -147,9 +147,6 @@ xfs_da_mount( ...@@ -147,9 +147,6 @@ xfs_da_mount(
/* XXX: these are to be removed as code is converted to use geo */ /* XXX: these are to be removed as code is converted to use geo */
mp->m_dirblksize = mp->m_dir_geo->blksize; mp->m_dirblksize = mp->m_dir_geo->blksize;
mp->m_dirblkfsbs = mp->m_dir_geo->fsbcount; mp->m_dirblkfsbs = mp->m_dir_geo->fsbcount;
mp->m_dirdatablk = mp->m_dir_geo->datablk;
mp->m_dirleafblk = mp->m_dir_geo->leafblk;
mp->m_dirfreeblk = mp->m_dir_geo->freeblk;
mp->m_dir_node_ents = mp->m_dir_geo->node_ents; mp->m_dir_node_ents = mp->m_dir_geo->node_ents;
mp->m_dir_magicpct = mp->m_dir_geo->magicpct; mp->m_dir_magicpct = mp->m_dir_geo->magicpct;
mp->m_attr_node_ents = mp->m_attr_geo->node_ents; mp->m_attr_node_ents = mp->m_attr_geo->node_ents;
...@@ -690,7 +687,7 @@ xfs_dir2_isleaf( ...@@ -690,7 +687,7 @@ xfs_dir2_isleaf(
mp = dp->i_mount; mp = dp->i_mount;
if ((rval = xfs_bmap_last_offset(dp, &last, XFS_DATA_FORK))) if ((rval = xfs_bmap_last_offset(dp, &last, XFS_DATA_FORK)))
return rval; return rval;
*vp = last == mp->m_dirleafblk + (1 << mp->m_sb.sb_dirblklog); *vp = last == mp->m_dir_geo->leafblk + (1 << mp->m_sb.sb_dirblklog);
return 0; return 0;
} }
...@@ -763,7 +760,7 @@ xfs_dir2_shrink_inode( ...@@ -763,7 +760,7 @@ xfs_dir2_shrink_inode(
*/ */
return error; return error;
} }
if (db == mp->m_dirdatablk) if (db == args->geo->datablk)
ASSERT(bno == 0); ASSERT(bno == 0);
else else
ASSERT(bno > 0); ASSERT(bno > 0);
......
...@@ -136,7 +136,7 @@ xfs_dir3_block_read( ...@@ -136,7 +136,7 @@ xfs_dir3_block_read(
struct xfs_mount *mp = dp->i_mount; struct xfs_mount *mp = dp->i_mount;
int err; int err;
err = xfs_da_read_buf(tp, dp, mp->m_dirdatablk, -1, bpp, err = xfs_da_read_buf(tp, dp, mp->m_dir_geo->datablk, -1, bpp,
XFS_DATA_FORK, &xfs_dir3_block_buf_ops); XFS_DATA_FORK, &xfs_dir3_block_buf_ops);
if (!err && tp) if (!err && tp)
xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_BLOCK_BUF); xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_BLOCK_BUF);
...@@ -969,7 +969,7 @@ xfs_dir2_leaf_to_block( ...@@ -969,7 +969,7 @@ xfs_dir2_leaf_to_block(
* Read the data block if we don't already have it, give up if it fails. * Read the data block if we don't already have it, give up if it fails.
*/ */
if (!dbp) { if (!dbp) {
error = xfs_dir3_data_read(tp, dp, mp->m_dirdatablk, -1, &dbp); error = xfs_dir3_data_read(tp, dp, args->geo->datablk, -1, &dbp);
if (error) if (error)
return error; return error;
} }
...@@ -1034,7 +1034,7 @@ xfs_dir2_leaf_to_block( ...@@ -1034,7 +1034,7 @@ xfs_dir2_leaf_to_block(
/* /*
* Pitch the old leaf block. * Pitch the old leaf block.
*/ */
error = xfs_da_shrink_inode(args, mp->m_dirleafblk, lbp); error = xfs_da_shrink_inode(args, args->geo->leafblk, lbp);
if (error) if (error)
return error; return error;
......
...@@ -63,8 +63,10 @@ __xfs_dir3_data_check( ...@@ -63,8 +63,10 @@ __xfs_dir3_data_check(
int stale; /* count of stale leaves */ int stale; /* count of stale leaves */
struct xfs_name name; struct xfs_name name;
const struct xfs_dir_ops *ops; const struct xfs_dir_ops *ops;
struct xfs_da_geometry *geo;
mp = bp->b_target->bt_mount; mp = bp->b_target->bt_mount;
geo = mp->m_dir_geo;
/* /*
* We can be passed a null dp here from a verifier, so we need to go the * We can be passed a null dp here from a verifier, so we need to go the
...@@ -172,10 +174,9 @@ __xfs_dir3_data_check( ...@@ -172,10 +174,9 @@ __xfs_dir3_data_check(
lastfree = 0; lastfree = 0;
if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) || if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) ||
hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)) { hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)) {
addr = xfs_dir2_db_off_to_dataptr(mp->m_dir_geo, addr = xfs_dir2_db_off_to_dataptr(geo, geo->datablk,
mp->m_dirdatablk, (xfs_dir2_data_aoff_t)
(xfs_dir2_data_aoff_t) ((char *)dep - (char *)hdr));
((char *)dep - (char *)hdr));
name.name = dep->name; name.name = dep->name;
name.len = dep->namelen; name.len = dep->namelen;
hash = mp->m_dirnameops->hashname(&name); hash = mp->m_dirnameops->hashname(&name);
......
...@@ -641,7 +641,7 @@ xfs_dir2_leaf_addname( ...@@ -641,7 +641,7 @@ xfs_dir2_leaf_addname(
tp = args->trans; tp = args->trans;
mp = dp->i_mount; mp = dp->i_mount;
error = xfs_dir3_leaf_read(tp, dp, mp->m_dirleafblk, -1, &lbp); error = xfs_dir3_leaf_read(tp, dp, args->geo->leafblk, -1, &lbp);
if (error) if (error)
return error; return error;
...@@ -1232,7 +1232,7 @@ xfs_dir2_leaf_lookup_int( ...@@ -1232,7 +1232,7 @@ xfs_dir2_leaf_lookup_int(
tp = args->trans; tp = args->trans;
mp = dp->i_mount; mp = dp->i_mount;
error = xfs_dir3_leaf_read(tp, dp, mp->m_dirleafblk, -1, &lbp); error = xfs_dir3_leaf_read(tp, dp, args->geo->leafblk, -1, &lbp);
if (error) if (error)
return error; return error;
...@@ -1429,7 +1429,7 @@ xfs_dir2_leaf_removename( ...@@ -1429,7 +1429,7 @@ xfs_dir2_leaf_removename(
*/ */
if (be16_to_cpu(bf[0].length) == if (be16_to_cpu(bf[0].length) ==
mp->m_dirblksize - dp->d_ops->data_entry_offset) { mp->m_dirblksize - dp->d_ops->data_entry_offset) {
ASSERT(db != mp->m_dirdatablk); ASSERT(db != args->geo->datablk);
if ((error = xfs_dir2_shrink_inode(args, db, dbp))) { if ((error = xfs_dir2_shrink_inode(args, db, dbp))) {
/* /*
* Nope, can't get rid of it because it caused * Nope, can't get rid of it because it caused
...@@ -1470,7 +1470,7 @@ xfs_dir2_leaf_removename( ...@@ -1470,7 +1470,7 @@ xfs_dir2_leaf_removename(
/* /*
* If the data block was not the first one, drop it. * If the data block was not the first one, drop it.
*/ */
else if (db != mp->m_dirdatablk) else if (db != args->geo->datablk)
dbp = NULL; dbp = NULL;
xfs_dir3_leaf_check(dp, lbp); xfs_dir3_leaf_check(dp, lbp);
...@@ -1722,7 +1722,7 @@ xfs_dir2_node_to_leaf( ...@@ -1722,7 +1722,7 @@ xfs_dir2_node_to_leaf(
* that may have been left behind during no-space-reservation * that may have been left behind during no-space-reservation
* operations. * operations.
*/ */
while (fo > mp->m_dirfreeblk) { while (fo > args->geo->freeblk) {
if ((error = xfs_dir2_node_trim_free(args, fo, &rval))) { if ((error = xfs_dir2_node_trim_free(args, fo, &rval))) {
return error; return error;
} }
...@@ -1752,7 +1752,7 @@ xfs_dir2_node_to_leaf( ...@@ -1752,7 +1752,7 @@ xfs_dir2_node_to_leaf(
/* /*
* Read the freespace block. * Read the freespace block.
*/ */
error = xfs_dir2_free_read(tp, dp, mp->m_dirfreeblk, &fbp); error = xfs_dir2_free_read(tp, dp, args->geo->freeblk, &fbp);
if (error) if (error)
return error; return error;
free = fbp->b_addr; free = fbp->b_addr;
......
...@@ -111,18 +111,18 @@ xfs_dir2_sf_getdents( ...@@ -111,18 +111,18 @@ xfs_dir2_sf_getdents(
/* /*
* If the block number in the offset is out of range, we're done. * If the block number in the offset is out of range, we're done.
*/ */
if (xfs_dir2_dataptr_to_db(geo, ctx->pos) > mp->m_dirdatablk) if (xfs_dir2_dataptr_to_db(geo, ctx->pos) > geo->datablk)
return 0; return 0;
/* /*
* Precalculate offsets for . and .. as we will always need them. * Precalculate offsets for . and .. as we will always need them.
* *
* XXX(hch): the second argument is sometimes 0 and sometimes * XXX(hch): the second argument is sometimes 0 and sometimes
* mp->m_dirdatablk. * geo->datablk
*/ */
dot_offset = xfs_dir2_db_off_to_dataptr(geo, mp->m_dirdatablk, dot_offset = xfs_dir2_db_off_to_dataptr(geo, geo->datablk,
dp->d_ops->data_dot_offset); dp->d_ops->data_dot_offset);
dotdot_offset = xfs_dir2_db_off_to_dataptr(geo, mp->m_dirdatablk, dotdot_offset = xfs_dir2_db_off_to_dataptr(geo, geo->datablk,
dp->d_ops->data_dotdot_offset); dp->d_ops->data_dotdot_offset);
/* /*
...@@ -151,7 +151,7 @@ xfs_dir2_sf_getdents( ...@@ -151,7 +151,7 @@ xfs_dir2_sf_getdents(
for (i = 0; i < sfp->count; i++) { for (i = 0; i < sfp->count; i++) {
__uint8_t filetype; __uint8_t filetype;
off = xfs_dir2_db_off_to_dataptr(geo, mp->m_dirdatablk, off = xfs_dir2_db_off_to_dataptr(geo, geo->datablk,
xfs_dir2_sf_get_offset(sfep)); xfs_dir2_sf_get_offset(sfep));
if (ctx->pos > off) { if (ctx->pos > off) {
...@@ -168,7 +168,7 @@ xfs_dir2_sf_getdents( ...@@ -168,7 +168,7 @@ xfs_dir2_sf_getdents(
sfep = dp->d_ops->sf_nextentry(sfp, sfep); sfep = dp->d_ops->sf_nextentry(sfp, sfep);
} }
ctx->pos = xfs_dir2_db_off_to_dataptr(geo, mp->m_dirdatablk + 1, 0) & ctx->pos = xfs_dir2_db_off_to_dataptr(geo, geo->datablk + 1, 0) &
0x7fffffff; 0x7fffffff;
return 0; return 0;
} }
...@@ -199,7 +199,7 @@ xfs_dir2_block_getdents( ...@@ -199,7 +199,7 @@ xfs_dir2_block_getdents(
/* /*
* If the block number in the offset is out of range, we're done. * If the block number in the offset is out of range, we're done.
*/ */
if (xfs_dir2_dataptr_to_db(geo, ctx->pos) > mp->m_dirdatablk) if (xfs_dir2_dataptr_to_db(geo, ctx->pos) > geo->datablk)
return 0; return 0;
error = xfs_dir3_block_read(NULL, dp, &bp); error = xfs_dir3_block_read(NULL, dp, &bp);
...@@ -248,7 +248,7 @@ xfs_dir2_block_getdents( ...@@ -248,7 +248,7 @@ xfs_dir2_block_getdents(
if ((char *)dep - (char *)hdr < wantoff) if ((char *)dep - (char *)hdr < wantoff)
continue; continue;
cook = xfs_dir2_db_off_to_dataptr(geo, mp->m_dirdatablk, cook = xfs_dir2_db_off_to_dataptr(geo, geo->datablk,
(char *)dep - (char *)hdr); (char *)dep - (char *)hdr);
ctx->pos = cook & 0x7fffffff; ctx->pos = cook & 0x7fffffff;
...@@ -268,7 +268,7 @@ xfs_dir2_block_getdents( ...@@ -268,7 +268,7 @@ xfs_dir2_block_getdents(
* Reached the end of the block. * Reached the end of the block.
* Set the offset to a non-existent block 1 and return. * Set the offset to a non-existent block 1 and return.
*/ */
ctx->pos = xfs_dir2_db_off_to_dataptr(geo, mp->m_dirdatablk + 1, 0) & ctx->pos = xfs_dir2_db_off_to_dataptr(geo, geo->datablk + 1, 0) &
0x7fffffff; 0x7fffffff;
xfs_trans_brelse(NULL, bp); xfs_trans_brelse(NULL, bp);
return 0; return 0;
......
...@@ -247,7 +247,7 @@ xfs_dir2_block_to_sf( ...@@ -247,7 +247,7 @@ xfs_dir2_block_to_sf(
/* now we are done with the block, we can shrink the inode */ /* now we are done with the block, we can shrink the inode */
logflags = XFS_ILOG_CORE; logflags = XFS_ILOG_CORE;
error = xfs_dir2_shrink_inode(args, mp->m_dirdatablk, bp); error = xfs_dir2_shrink_inode(args, args->geo->datablk, bp);
if (error) { if (error) {
ASSERT(error != ENOSPC); ASSERT(error != ENOSPC);
goto out; goto out;
......
...@@ -156,9 +156,6 @@ typedef struct xfs_mount { ...@@ -156,9 +156,6 @@ typedef struct xfs_mount {
const struct xfs_dir_ops *m_nondir_inode_ops; /* !dir inode ops */ const struct xfs_dir_ops *m_nondir_inode_ops; /* !dir inode ops */
int m_dirblksize; /* directory block sz--bytes */ int m_dirblksize; /* directory block sz--bytes */
int m_dirblkfsbs; /* directory block sz--fsbs */ int m_dirblkfsbs; /* directory block sz--fsbs */
xfs_dablk_t m_dirdatablk; /* blockno of dir data v2 */
xfs_dablk_t m_dirleafblk; /* blockno of dir non-data v2 */
xfs_dablk_t m_dirfreeblk; /* blockno of dirfreeindex v2 */
uint m_chsize; /* size of next field */ uint m_chsize; /* size of next field */
atomic_t m_active_trans; /* number trans frozen */ atomic_t m_active_trans; /* number trans frozen */
#ifdef HAVE_PERCPU_SB #ifdef HAVE_PERCPU_SB
......
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