Skip to content

Commit 4491a3d

Browse files
cmaiolinodjwong
authored andcommitted
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: Carlos Maiolino <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> [darrick: reduce struct typedef usage] Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Dave Chinner <[email protected]>
1 parent bae633a commit 4491a3d

File tree

5 files changed

+21
-33
lines changed

5 files changed

+21
-33
lines changed

fs/xfs/libxfs/xfs_attr.c

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,6 @@ xfs_attr_node_addname(
739739
struct xfs_da_state *state;
740740
struct xfs_da_state_blk *blk;
741741
struct xfs_inode *dp;
742-
struct xfs_mount *mp;
743742
int retval, error;
744743

745744
trace_xfs_attr_node_addname(args);
@@ -748,11 +747,8 @@ xfs_attr_node_addname(
748747
* Fill in bucket of arguments/results/context to carry around.
749748
*/
750749
dp = args->dp;
751-
mp = dp->i_mount;
752750
restart:
753-
state = xfs_da_state_alloc();
754-
state->args = args;
755-
state->mp = mp;
751+
state = xfs_da_state_alloc(args);
756752

757753
/*
758754
* Search to see if name already exists, and get back a pointer
@@ -899,9 +895,8 @@ xfs_attr_node_addname(
899895
* attr, not the "new" one.
900896
*/
901897
args->attr_filter |= XFS_ATTR_INCOMPLETE;
902-
state = xfs_da_state_alloc();
903-
state->args = args;
904-
state->mp = mp;
898+
state = xfs_da_state_alloc(args);
899+
905900
state->inleaf = 0;
906901
error = xfs_da3_node_lookup_int(state, &retval);
907902
if (error)
@@ -975,9 +970,7 @@ xfs_attr_node_removename(
975970
* Tie a string around our finger to remind us where we are.
976971
*/
977972
dp = args->dp;
978-
state = xfs_da_state_alloc();
979-
state->args = args;
980-
state->mp = dp->i_mount;
973+
state = xfs_da_state_alloc(args);
981974

982975
/*
983976
* 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)
12071200

12081201
trace_xfs_attr_node_get(args);
12091202

1210-
state = xfs_da_state_alloc();
1211-
state->args = args;
1212-
state->mp = args->dp->i_mount;
1203+
state = xfs_da_state_alloc(args);
12131204

12141205
/*
12151206
* Search to see if name exists, and get back a pointer to it.

fs/xfs/libxfs/xfs_da_btree.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,16 @@ kmem_zone_t *xfs_da_state_zone; /* anchor for state struct zone */
7878
* Allocate a dir-state structure.
7979
* We don't put them on the stack since they're large.
8080
*/
81-
xfs_da_state_t *
82-
xfs_da_state_alloc(void)
81+
struct xfs_da_state *
82+
xfs_da_state_alloc(
83+
struct xfs_da_args *args)
8384
{
84-
return kmem_cache_zalloc(xfs_da_state_zone, GFP_NOFS | __GFP_NOFAIL);
85+
struct xfs_da_state *state;
86+
87+
state = kmem_cache_zalloc(xfs_da_state_zone, GFP_NOFS | __GFP_NOFAIL);
88+
state->args = args;
89+
state->mp = args->dp->i_mount;
90+
return state;
8591
}
8692

8793
/*

fs/xfs/libxfs/xfs_da_btree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ enum xfs_dacmp xfs_da_compname(struct xfs_da_args *args,
219219
const unsigned char *name, int len);
220220

221221

222-
xfs_da_state_t *xfs_da_state_alloc(void);
222+
struct xfs_da_state *xfs_da_state_alloc(struct xfs_da_args *args);
223223
void xfs_da_state_free(xfs_da_state_t *state);
224224

225225
void xfs_da3_node_hdr_from_disk(struct xfs_mount *mp,

fs/xfs/libxfs/xfs_dir2_node.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,9 +2015,7 @@ xfs_dir2_node_addname(
20152015
/*
20162016
* Allocate and initialize the state (btree cursor).
20172017
*/
2018-
state = xfs_da_state_alloc();
2019-
state->args = args;
2020-
state->mp = args->dp->i_mount;
2018+
state = xfs_da_state_alloc(args);
20212019
/*
20222020
* Look up the name. We're not supposed to find it, but
20232021
* this gives us the insertion point.
@@ -2086,9 +2084,8 @@ xfs_dir2_node_lookup(
20862084
/*
20872085
* Allocate and initialize the btree cursor.
20882086
*/
2089-
state = xfs_da_state_alloc();
2090-
state->args = args;
2091-
state->mp = args->dp->i_mount;
2087+
state = xfs_da_state_alloc(args);
2088+
20922089
/*
20932090
* Fill in the path to the entry in the cursor.
20942091
*/
@@ -2139,9 +2136,7 @@ xfs_dir2_node_removename(
21392136
/*
21402137
* Allocate and initialize the btree cursor.
21412138
*/
2142-
state = xfs_da_state_alloc();
2143-
state->args = args;
2144-
state->mp = args->dp->i_mount;
2139+
state = xfs_da_state_alloc(args);
21452140

21462141
/* Look up the entry we're deleting, set up the cursor. */
21472142
error = xfs_da3_node_lookup_int(state, &rval);
@@ -2206,9 +2201,7 @@ xfs_dir2_node_replace(
22062201
/*
22072202
* Allocate and initialize the btree cursor.
22082203
*/
2209-
state = xfs_da_state_alloc();
2210-
state->args = args;
2211-
state->mp = args->dp->i_mount;
2204+
state = xfs_da_state_alloc(args);
22122205

22132206
/*
22142207
* We have to save new inode number and ftype since

fs/xfs/scrub/dabtree.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,7 @@ xchk_da_btree(
476476
ds.dargs.whichfork = whichfork;
477477
ds.dargs.trans = sc->tp;
478478
ds.dargs.op_flags = XFS_DA_OP_OKNOENT;
479-
ds.state = xfs_da_state_alloc();
480-
ds.state->args = &ds.dargs;
481-
ds.state->mp = mp;
479+
ds.state = xfs_da_state_alloc(&ds.dargs);
482480
ds.sc = sc;
483481
ds.private = private;
484482
if (whichfork == XFS_ATTR_FORK) {

0 commit comments

Comments
 (0)