diff options
| author | Harry Yoo <harry.yoo@oracle.com> | 2026-01-13 15:18:39 +0900 |
|---|---|---|
| committer | Vlastimil Babka <vbabka@suse.cz> | 2026-02-04 10:05:35 +0100 |
| commit | 43d9bb4236fd1dd2e4646bee7f556542eefa422a (patch) | |
| tree | 804b540eb7c89ca07a97d9cf8ccbbc106455bed7 /fs/ext4 | |
| parent | a13b68d79d5caa5ec0d34b4c0fb2dedf3259fc32 (diff) | |
ext4: specify the free pointer offset for ext4_inode_cache
Convert ext4_inode_cache to use the kmem_cache_args interface and
specify a free pointer offset.
Since ext4_inode_cache uses a constructor, the free pointer would be
placed after the object to prevent overwriting fields used by the
constructor.
However, some fields such as ->i_flags are not used by the constructor
and can safely be repurposed for the free pointer.
Specify the free pointer offset at i_flags to reduce the object size.
Signed-off-by: Harry Yoo <harry.yoo@oracle.com>
Link: https://patch.msgid.link/20260113061845.159790-4-harry.yoo@oracle.com
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Diffstat (limited to 'fs/ext4')
| -rw-r--r-- | fs/ext4/super.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 87205660c5d0..6f1c2c497871 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1491,12 +1491,19 @@ static void init_once(void *foo) static int __init init_inodecache(void) { - ext4_inode_cachep = kmem_cache_create_usercopy("ext4_inode_cache", - sizeof(struct ext4_inode_info), 0, - SLAB_RECLAIM_ACCOUNT | SLAB_ACCOUNT, - offsetof(struct ext4_inode_info, i_data), - sizeof_field(struct ext4_inode_info, i_data), - init_once); + struct kmem_cache_args args = { + .useroffset = offsetof(struct ext4_inode_info, i_data), + .usersize = sizeof_field(struct ext4_inode_info, i_data), + .use_freeptr_offset = true, + .freeptr_offset = offsetof(struct ext4_inode_info, i_flags), + .ctor = init_once, + }; + + ext4_inode_cachep = kmem_cache_create("ext4_inode_cache", + sizeof(struct ext4_inode_info), + &args, + SLAB_RECLAIM_ACCOUNT | SLAB_ACCOUNT); + if (ext4_inode_cachep == NULL) return -ENOMEM; return 0; |
