Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ext4: move crypt info pointer to fs-specific part of inode

Move the fscrypt_inode_info pointer into the filesystem-specific part of
the inode by adding the field ext4_inode_info::i_crypt_info and
configuring fscrypt_operations::inode_info_offs accordingly.

This is a prerequisite for a later commit that removes
inode::i_crypt_info, saving memory and improving cache efficiency with
filesystems that don't support fscrypt.

Co-developed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Link: https://lore.kernel.org/20250810075706.172910-4-ebiggers@kernel.org
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Eric Biggers and committed by
Christian Brauner
80e07df4 93221de3

+9
+2
fs/ext4/crypto.c
··· 227 227 } 228 228 229 229 const struct fscrypt_operations ext4_cryptops = { 230 + .inode_info_offs = (int)offsetof(struct ext4_inode_info, i_crypt_info) - 231 + (int)offsetof(struct ext4_inode_info, vfs_inode), 230 232 .needs_bounce_pages = 1, 231 233 .has_32bit_inodes = 1, 232 234 .supports_subblock_data_units = 1,
+4
fs/ext4/ext4.h
··· 1182 1182 __u32 i_csum_seed; 1183 1183 1184 1184 kprojid_t i_projid; 1185 + 1186 + #ifdef CONFIG_FS_ENCRYPTION 1187 + struct fscrypt_inode_info *i_crypt_info; 1188 + #endif 1185 1189 }; 1186 1190 1187 1191 /*
+3
fs/ext4/super.c
··· 1470 1470 init_rwsem(&ei->i_data_sem); 1471 1471 inode_init_once(&ei->vfs_inode); 1472 1472 ext4_fc_init_inode(&ei->vfs_inode); 1473 + #ifdef CONFIG_FS_ENCRYPTION 1474 + ei->i_crypt_info = NULL; 1475 + #endif 1473 1476 } 1474 1477 1475 1478 static int __init init_inodecache(void)