Skip to content

Commit e2c7894

Browse files
Darrick J. Wongdchinner
authored andcommitted
xfs: use a separate slab cache for deferred xattr work state
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 <[email protected]> Reviewed-by: Allison Henderson <[email protected]> Reviewed-by: Dave Chinner <[email protected]> Signed-off-by: Dave Chinner <[email protected]>
1 parent b53d212 commit e2c7894

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

fs/xfs/libxfs/xfs_attr.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
struct kmem_cache *xfs_attri_cache;
3131
struct kmem_cache *xfs_attrd_cache;
32+
struct kmem_cache *xfs_attr_intent_cache;
3233

3334
/*
3435
* xfs_attr.c
@@ -902,7 +903,7 @@ xfs_attr_item_init(
902903

903904
struct xfs_attr_item *new;
904905

905-
new = kmem_zalloc(sizeof(struct xfs_attr_item), KM_NOFS);
906+
new = kmem_cache_zalloc(xfs_attr_intent_cache, GFP_NOFS | __GFP_NOFAIL);
906907
new->xattri_op_flags = op_flags;
907908
new->xattri_da_args = args;
908909

@@ -1650,3 +1651,20 @@ xfs_attr_namecheck(
16501651
/* There shouldn't be any nulls here */
16511652
return !memchr(name, 0, length);
16521653
}
1654+
1655+
int __init
1656+
xfs_attr_intent_init_cache(void)
1657+
{
1658+
xfs_attr_intent_cache = kmem_cache_create("xfs_attr_item",
1659+
sizeof(struct xfs_attr_item),
1660+
0, 0, NULL);
1661+
1662+
return xfs_attr_intent_cache != NULL ? 0 : -ENOMEM;
1663+
}
1664+
1665+
void
1666+
xfs_attr_intent_destroy_cache(void)
1667+
{
1668+
kmem_cache_destroy(xfs_attr_intent_cache);
1669+
xfs_attr_intent_cache = NULL;
1670+
}

fs/xfs/libxfs/xfs_attr.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,4 +634,8 @@ xfs_attr_init_replace_state(struct xfs_da_args *args)
634634
return xfs_attr_init_add_state(args);
635635
}
636636

637+
extern struct kmem_cache *xfs_attr_intent_cache;
638+
int __init xfs_attr_intent_init_cache(void);
639+
void xfs_attr_intent_destroy_cache(void);
640+
637641
#endif /* __XFS_ATTR_H__ */

fs/xfs/libxfs/xfs_defer.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,9 @@ xfs_defer_init_item_caches(void)
877877
if (error)
878878
goto err;
879879
error = xfs_attrd_init_cache();
880+
if (error)
881+
goto err;
882+
error = xfs_attr_intent_init_cache();
880883
if (error)
881884
goto err;
882885
return 0;
@@ -889,6 +892,7 @@ xfs_defer_init_item_caches(void)
889892
void
890893
xfs_defer_destroy_item_caches(void)
891894
{
895+
xfs_attr_intent_destroy_cache();
892896
xfs_attri_destroy_cache();
893897
xfs_attrd_destroy_cache();
894898
xfs_extfree_intent_destroy_cache();

fs/xfs/xfs_attr_item.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,10 @@ xfs_attr_free_item(
404404
{
405405
if (attr->xattri_da_state)
406406
xfs_da_state_free(attr->xattri_da_state);
407-
kmem_free(attr);
407+
if (attr->xattri_da_args->op_flags & XFS_DA_OP_RECOVERY)
408+
kmem_free(attr);
409+
else
410+
kmem_cache_free(xfs_attr_intent_cache, attr);
408411
}
409412

410413
/* Process an attr. */

0 commit comments

Comments
 (0)