]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: use a separate slab cache for deferred xattr work state
authorDarrick J. Wong <djwong@kernel.org>
Wed, 22 Jun 2022 19:28:52 +0000 (14:28 -0500)
committerEric Sandeen <sandeen@sandeen.net>
Wed, 22 Jun 2022 19:28:52 +0000 (14:28 -0500)
Source kernel commit: e2c78949b641d34cb4051b32c2fa5e03a4bfef35

Create a separate slab cache for struct xfs_attr_item objects, since we
can pack the (104-byte) intent items more tightly than we can with the
general slab cache objects.  On x86, this means 39 intents per memory
page instead of 32.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/defer_item.c
libxfs/xfs_attr.c
libxfs/xfs_attr.h
libxfs/xfs_defer.c

index e88df58fef38793faee370a9e874b44e34fd7dc8..c5f7ca7e50fe4ed661d92fec848785c076b3d73b 100644 (file)
@@ -491,7 +491,10 @@ xfs_attr_free_item(
 {
        if (attr->xattri_da_state)
                xfs_da_state_free(attr->xattri_da_state);
-       kmem_free(attr);
+       if (attr->xattri_da_args->op_flags & XFS_DA_OP_RECOVERY)
+               kmem_free(attr);
+       else
+               kmem_cache_free(xfs_attr_intent_cache, attr);
 }
 
 /* Process an attr. */
index ed81123d4e5c35c47dfa3398cda90076ae974169..23608614a2cf806b8c0dddfac3432baa011b9f1a 100644 (file)
@@ -27,6 +27,7 @@
 
 struct kmem_cache              *xfs_attri_cache;
 struct kmem_cache              *xfs_attrd_cache;
+struct kmem_cache              *xfs_attr_intent_cache;
 
 /*
  * xfs_attr.c
@@ -900,7 +901,7 @@ xfs_attr_item_init(
 
        struct xfs_attr_item    *new;
 
-       new = kmem_zalloc(sizeof(struct xfs_attr_item), KM_NOFS);
+       new = kmem_cache_zalloc(xfs_attr_intent_cache, GFP_NOFS | __GFP_NOFAIL);
        new->xattri_op_flags = op_flags;
        new->xattri_da_args = args;
 
@@ -1648,3 +1649,20 @@ xfs_attr_namecheck(
        /* There shouldn't be any nulls here */
        return !memchr(name, 0, length);
 }
+
+int __init
+xfs_attr_intent_init_cache(void)
+{
+       xfs_attr_intent_cache = kmem_cache_create("xfs_attr_item",
+                       sizeof(struct xfs_attr_item),
+                       0, 0, NULL);
+
+       return xfs_attr_intent_cache != NULL ? 0 : -ENOMEM;
+}
+
+void
+xfs_attr_intent_destroy_cache(void)
+{
+       kmem_cache_destroy(xfs_attr_intent_cache);
+       xfs_attr_intent_cache = NULL;
+}
index c739caa11a4b3fbde79244cf72e31e36fa5d45c4..cb3b3d270569567de4a426e7224fd4d570f002ea 100644 (file)
@@ -634,4 +634,8 @@ xfs_attr_init_replace_state(struct xfs_da_args *args)
        return xfs_attr_init_add_state(args);
 }
 
+extern struct kmem_cache *xfs_attr_intent_cache;
+int __init xfs_attr_intent_init_cache(void);
+void xfs_attr_intent_destroy_cache(void);
+
 #endif /* __XFS_ATTR_H__ */
index c8e564e168b7d763a5e5012965901f51cf016e2b..4d0ed4ad0a735d245dbb649840b0383d163fc65f 100644 (file)
@@ -872,6 +872,9 @@ xfs_defer_init_item_caches(void)
        if (error)
                goto err;
        error = xfs_attrd_init_cache();
+       if (error)
+               goto err;
+       error = xfs_attr_intent_init_cache();
        if (error)
                goto err;
        return 0;
@@ -884,6 +887,7 @@ err:
 void
 xfs_defer_destroy_item_caches(void)
 {
+       xfs_attr_intent_destroy_cache();
        xfs_attri_destroy_cache();
        xfs_attrd_destroy_cache();
        xfs_extfree_intent_destroy_cache();