Commit 4491a3dd authored by Carlos Maiolino's avatar Carlos Maiolino Committed by Darrick J. Wong

xfs: Refactor xfs_da_state_alloc() helper

Every call to xfs_da_state_alloc() also requires setting up state->args
and state->mp

Change xfs_da_state_alloc() to receive an xfs_da_args_t as argument and
return a xfs_da_state_t with both args and mp already set.
Signed-off-by: default avatarCarlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
[darrick: reduce struct typedef usage]
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
parent bae633a4
...@@ -739,7 +739,6 @@ xfs_attr_node_addname( ...@@ -739,7 +739,6 @@ xfs_attr_node_addname(
struct xfs_da_state *state; struct xfs_da_state *state;
struct xfs_da_state_blk *blk; struct xfs_da_state_blk *blk;
struct xfs_inode *dp; struct xfs_inode *dp;
struct xfs_mount *mp;
int retval, error; int retval, error;
trace_xfs_attr_node_addname(args); trace_xfs_attr_node_addname(args);
...@@ -748,11 +747,8 @@ xfs_attr_node_addname( ...@@ -748,11 +747,8 @@ xfs_attr_node_addname(
* Fill in bucket of arguments/results/context to carry around. * Fill in bucket of arguments/results/context to carry around.
*/ */
dp = args->dp; dp = args->dp;
mp = dp->i_mount;
restart: restart:
state = xfs_da_state_alloc(); state = xfs_da_state_alloc(args);
state->args = args;
state->mp = mp;
/* /*
* Search to see if name already exists, and get back a pointer * Search to see if name already exists, and get back a pointer
...@@ -899,9 +895,8 @@ xfs_attr_node_addname( ...@@ -899,9 +895,8 @@ xfs_attr_node_addname(
* attr, not the "new" one. * attr, not the "new" one.
*/ */
args->attr_filter |= XFS_ATTR_INCOMPLETE; args->attr_filter |= XFS_ATTR_INCOMPLETE;
state = xfs_da_state_alloc(); state = xfs_da_state_alloc(args);
state->args = args;
state->mp = mp;
state->inleaf = 0; state->inleaf = 0;
error = xfs_da3_node_lookup_int(state, &retval); error = xfs_da3_node_lookup_int(state, &retval);
if (error) if (error)
...@@ -975,9 +970,7 @@ xfs_attr_node_removename( ...@@ -975,9 +970,7 @@ xfs_attr_node_removename(
* Tie a string around our finger to remind us where we are. * Tie a string around our finger to remind us where we are.
*/ */
dp = args->dp; dp = args->dp;
state = xfs_da_state_alloc(); state = xfs_da_state_alloc(args);
state->args = args;
state->mp = dp->i_mount;
/* /*
* Search to see if name exists, and get back a pointer to it. * Search to see if name exists, and get back a pointer to it.
...@@ -1207,9 +1200,7 @@ xfs_attr_node_get(xfs_da_args_t *args) ...@@ -1207,9 +1200,7 @@ xfs_attr_node_get(xfs_da_args_t *args)
trace_xfs_attr_node_get(args); trace_xfs_attr_node_get(args);
state = xfs_da_state_alloc(); state = xfs_da_state_alloc(args);
state->args = args;
state->mp = args->dp->i_mount;
/* /*
* Search to see if name exists, and get back a pointer to it. * Search to see if name exists, and get back a pointer to it.
......
...@@ -78,10 +78,16 @@ kmem_zone_t *xfs_da_state_zone; /* anchor for state struct zone */ ...@@ -78,10 +78,16 @@ kmem_zone_t *xfs_da_state_zone; /* anchor for state struct zone */
* Allocate a dir-state structure. * Allocate a dir-state structure.
* We don't put them on the stack since they're large. * We don't put them on the stack since they're large.
*/ */
xfs_da_state_t * struct xfs_da_state *
xfs_da_state_alloc(void) xfs_da_state_alloc(
struct xfs_da_args *args)
{ {
return kmem_cache_zalloc(xfs_da_state_zone, GFP_NOFS | __GFP_NOFAIL); struct xfs_da_state *state;
state = kmem_cache_zalloc(xfs_da_state_zone, GFP_NOFS | __GFP_NOFAIL);
state->args = args;
state->mp = args->dp->i_mount;
return state;
} }
/* /*
......
...@@ -219,7 +219,7 @@ enum xfs_dacmp xfs_da_compname(struct xfs_da_args *args, ...@@ -219,7 +219,7 @@ enum xfs_dacmp xfs_da_compname(struct xfs_da_args *args,
const unsigned char *name, int len); const unsigned char *name, int len);
xfs_da_state_t *xfs_da_state_alloc(void); struct xfs_da_state *xfs_da_state_alloc(struct xfs_da_args *args);
void xfs_da_state_free(xfs_da_state_t *state); void xfs_da_state_free(xfs_da_state_t *state);
void xfs_da3_node_hdr_from_disk(struct xfs_mount *mp, void xfs_da3_node_hdr_from_disk(struct xfs_mount *mp,
......
...@@ -2015,9 +2015,7 @@ xfs_dir2_node_addname( ...@@ -2015,9 +2015,7 @@ xfs_dir2_node_addname(
/* /*
* Allocate and initialize the state (btree cursor). * Allocate and initialize the state (btree cursor).
*/ */
state = xfs_da_state_alloc(); state = xfs_da_state_alloc(args);
state->args = args;
state->mp = args->dp->i_mount;
/* /*
* Look up the name. We're not supposed to find it, but * Look up the name. We're not supposed to find it, but
* this gives us the insertion point. * this gives us the insertion point.
...@@ -2086,9 +2084,8 @@ xfs_dir2_node_lookup( ...@@ -2086,9 +2084,8 @@ xfs_dir2_node_lookup(
/* /*
* Allocate and initialize the btree cursor. * Allocate and initialize the btree cursor.
*/ */
state = xfs_da_state_alloc(); state = xfs_da_state_alloc(args);
state->args = args;
state->mp = args->dp->i_mount;
/* /*
* Fill in the path to the entry in the cursor. * Fill in the path to the entry in the cursor.
*/ */
...@@ -2139,9 +2136,7 @@ xfs_dir2_node_removename( ...@@ -2139,9 +2136,7 @@ xfs_dir2_node_removename(
/* /*
* Allocate and initialize the btree cursor. * Allocate and initialize the btree cursor.
*/ */
state = xfs_da_state_alloc(); state = xfs_da_state_alloc(args);
state->args = args;
state->mp = args->dp->i_mount;
/* Look up the entry we're deleting, set up the cursor. */ /* Look up the entry we're deleting, set up the cursor. */
error = xfs_da3_node_lookup_int(state, &rval); error = xfs_da3_node_lookup_int(state, &rval);
...@@ -2206,9 +2201,7 @@ xfs_dir2_node_replace( ...@@ -2206,9 +2201,7 @@ xfs_dir2_node_replace(
/* /*
* Allocate and initialize the btree cursor. * Allocate and initialize the btree cursor.
*/ */
state = xfs_da_state_alloc(); state = xfs_da_state_alloc(args);
state->args = args;
state->mp = args->dp->i_mount;
/* /*
* We have to save new inode number and ftype since * We have to save new inode number and ftype since
......
...@@ -476,9 +476,7 @@ xchk_da_btree( ...@@ -476,9 +476,7 @@ xchk_da_btree(
ds.dargs.whichfork = whichfork; ds.dargs.whichfork = whichfork;
ds.dargs.trans = sc->tp; ds.dargs.trans = sc->tp;
ds.dargs.op_flags = XFS_DA_OP_OKNOENT; ds.dargs.op_flags = XFS_DA_OP_OKNOENT;
ds.state = xfs_da_state_alloc(); ds.state = xfs_da_state_alloc(&ds.dargs);
ds.state->args = &ds.dargs;
ds.state->mp = mp;
ds.sc = sc; ds.sc = sc;
ds.private = private; ds.private = private;
if (whichfork == XFS_ATTR_FORK) { if (whichfork == XFS_ATTR_FORK) {
......
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