diff mbox series

[5/5] xfs: Remove xfs_da_state_alloc() helper

Message ID 20200710091536.95828-6-cmaiolino@redhat.com (mailing list archive)
State New, archived
Headers show
Series Continue xfs kmem cleanup - V2 | expand

Commit Message

Carlos Maiolino July 10, 2020, 9:15 a.m. UTC
xfs_da_state_alloc() can simply be replaced by kmem_cache_zalloc()
calls directly. No need to keep this helper around.

Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
---
 fs/xfs/libxfs/xfs_attr.c      |  9 +++++----
 fs/xfs/libxfs/xfs_da_btree.c  | 10 ----------
 fs/xfs/libxfs/xfs_da_btree.h  |  1 -
 fs/xfs/libxfs/xfs_dir2_node.c |  8 ++++----
 fs/xfs/scrub/dabtree.c        |  3 ++-
 5 files changed, 11 insertions(+), 20 deletions(-)

Comments

Christoph Hellwig July 10, 2020, 4:11 p.m. UTC | #1
On Fri, Jul 10, 2020 at 11:15:36AM +0200, Carlos Maiolino wrote:
> xfs_da_state_alloc() can simply be replaced by kmem_cache_zalloc()
> calls directly. No need to keep this helper around.

Wouldn't it be nicer to keep the helper, and also make it setup
->args and ->mp?
Carlos Maiolino July 13, 2020, 9:17 a.m. UTC | #2
On Fri, Jul 10, 2020 at 05:11:11PM +0100, Christoph Hellwig wrote:
> On Fri, Jul 10, 2020 at 11:15:36AM +0200, Carlos Maiolino wrote:
> > xfs_da_state_alloc() can simply be replaced by kmem_cache_zalloc()
> > calls directly. No need to keep this helper around.
> 
> Wouldn't it be nicer to keep the helper, and also make it setup
> ->args and ->mp?

Yup, sounds good, thanks for the suggestion, I'll update the patch accordingly.
diff mbox series

Patch

diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
index 3b1bd6e112f89..a9499b2fdfb83 100644
--- a/fs/xfs/libxfs/xfs_attr.c
+++ b/fs/xfs/libxfs/xfs_attr.c
@@ -750,7 +750,7 @@  xfs_attr_node_addname(
 	dp = args->dp;
 	mp = dp->i_mount;
 restart:
-	state = xfs_da_state_alloc();
+	state = kmem_cache_zalloc(xfs_da_state_zone, GFP_NOFS | __GFP_NOFAIL);
 	state->args = args;
 	state->mp = mp;
 
@@ -899,7 +899,8 @@  xfs_attr_node_addname(
 		 * attr, not the "new" one.
 		 */
 		args->attr_filter |= XFS_ATTR_INCOMPLETE;
-		state = xfs_da_state_alloc();
+		state = kmem_cache_zalloc(xfs_da_state_zone,
+					  GFP_NOFS | __GFP_NOFAIL);
 		state->args = args;
 		state->mp = mp;
 		state->inleaf = 0;
@@ -975,7 +976,7 @@  xfs_attr_node_removename(
 	 * Tie a string around our finger to remind us where we are.
 	 */
 	dp = args->dp;
-	state = xfs_da_state_alloc();
+	state = kmem_cache_zalloc(xfs_da_state_zone, GFP_NOFS | __GFP_NOFAIL);
 	state->args = args;
 	state->mp = dp->i_mount;
 
@@ -1207,7 +1208,7 @@  xfs_attr_node_get(xfs_da_args_t *args)
 
 	trace_xfs_attr_node_get(args);
 
-	state = xfs_da_state_alloc();
+	state = kmem_cache_zalloc(xfs_da_state_zone, GFP_NOFS | __GFP_NOFAIL);
 	state->args = args;
 	state->mp = args->dp->i_mount;
 
diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index a4e1f01daf3d8..a704c1a91bece 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -74,16 +74,6 @@  STATIC int	xfs_da3_blk_unlink(xfs_da_state_t *state,
 
 kmem_zone_t *xfs_da_state_zone;	/* anchor for state struct zone */
 
-/*
- * Allocate a dir-state structure.
- * We don't put them on the stack since they're large.
- */
-xfs_da_state_t *
-xfs_da_state_alloc(void)
-{
-	return kmem_cache_zalloc(xfs_da_state_zone, GFP_NOFS | __GFP_NOFAIL);
-}
-
 /*
  * Kill the altpath contents of a da-state structure.
  */
diff --git a/fs/xfs/libxfs/xfs_da_btree.h b/fs/xfs/libxfs/xfs_da_btree.h
index 6e25de6621e4f..50c803ffb80d8 100644
--- a/fs/xfs/libxfs/xfs_da_btree.h
+++ b/fs/xfs/libxfs/xfs_da_btree.h
@@ -219,7 +219,6 @@  enum xfs_dacmp xfs_da_compname(struct xfs_da_args *args,
 				const unsigned char *name, int len);
 
 
-xfs_da_state_t *xfs_da_state_alloc(void);
 void xfs_da_state_free(xfs_da_state_t *state);
 
 void	xfs_da3_node_hdr_from_disk(struct xfs_mount *mp,
diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c
index 6ac4aad98cd76..8d9c0df5b0836 100644
--- a/fs/xfs/libxfs/xfs_dir2_node.c
+++ b/fs/xfs/libxfs/xfs_dir2_node.c
@@ -2015,7 +2015,7 @@  xfs_dir2_node_addname(
 	/*
 	 * Allocate and initialize the state (btree cursor).
 	 */
-	state = xfs_da_state_alloc();
+	state = kmem_cache_zalloc(xfs_da_state_zone, GFP_NOFS | __GFP_NOFAIL);
 	state->args = args;
 	state->mp = args->dp->i_mount;
 	/*
@@ -2086,7 +2086,7 @@  xfs_dir2_node_lookup(
 	/*
 	 * Allocate and initialize the btree cursor.
 	 */
-	state = xfs_da_state_alloc();
+	state = kmem_cache_zalloc(xfs_da_state_zone, GFP_NOFS | __GFP_NOFAIL);
 	state->args = args;
 	state->mp = args->dp->i_mount;
 	/*
@@ -2139,7 +2139,7 @@  xfs_dir2_node_removename(
 	/*
 	 * Allocate and initialize the btree cursor.
 	 */
-	state = xfs_da_state_alloc();
+	state = kmem_cache_zalloc(xfs_da_state_zone, GFP_NOFS | __GFP_NOFAIL);
 	state->args = args;
 	state->mp = args->dp->i_mount;
 
@@ -2206,7 +2206,7 @@  xfs_dir2_node_replace(
 	/*
 	 * Allocate and initialize the btree cursor.
 	 */
-	state = xfs_da_state_alloc();
+	state = kmem_cache_zalloc(xfs_da_state_zone, GFP_NOFS | __GFP_NOFAIL);
 	state->args = args;
 	state->mp = args->dp->i_mount;
 
diff --git a/fs/xfs/scrub/dabtree.c b/fs/xfs/scrub/dabtree.c
index 44b15015021f3..cf454957db1f8 100644
--- a/fs/xfs/scrub/dabtree.c
+++ b/fs/xfs/scrub/dabtree.c
@@ -476,7 +476,8 @@  xchk_da_btree(
 	ds.dargs.whichfork = whichfork;
 	ds.dargs.trans = sc->tp;
 	ds.dargs.op_flags = XFS_DA_OP_OKNOENT;
-	ds.state = xfs_da_state_alloc();
+	ds.state = kmem_cache_zalloc(xfs_da_state_zone,
+				     GFP_NOFS | __GFP_NOFAIL);
 	ds.state->args = &ds.dargs;
 	ds.state->mp = mp;
 	ds.sc = sc;