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

f2fs: 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 f2fs_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-5-ebiggers@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Eric Biggers and committed by
Christian Brauner
7afb71ee 80e07df4

+9 -1
+3
fs/f2fs/f2fs.h
··· 907 907 908 908 unsigned int atomic_write_cnt; 909 909 loff_t original_i_size; /* original i_size before atomic write */ 910 + #ifdef CONFIG_FS_ENCRYPTION 911 + struct fscrypt_inode_info *i_crypt_info; /* filesystem encryption info */ 912 + #endif 910 913 }; 911 914 912 915 static inline void get_read_extent_info(struct extent_info *ext,
+6 -1
fs/f2fs/super.c
··· 480 480 struct f2fs_inode_info *fi = (struct f2fs_inode_info *) foo; 481 481 482 482 inode_init_once(&fi->vfs_inode); 483 + #ifdef CONFIG_FS_ENCRYPTION 484 + fi->i_crypt_info = NULL; 485 + #endif 483 486 } 484 487 485 488 #ifdef CONFIG_QUOTA ··· 3573 3570 } 3574 3571 3575 3572 static const struct fscrypt_operations f2fs_cryptops = { 3573 + .inode_info_offs = (int)offsetof(struct f2fs_inode_info, i_crypt_info) - 3574 + (int)offsetof(struct f2fs_inode_info, vfs_inode), 3576 3575 .needs_bounce_pages = 1, 3577 3576 .has_32bit_inodes = 1, 3578 3577 .supports_subblock_data_units = 1, ··· 3586 3581 .has_stable_inodes = f2fs_has_stable_inodes, 3587 3582 .get_devices = f2fs_get_devices, 3588 3583 }; 3589 - #endif 3584 + #endif /* CONFIG_FS_ENCRYPTION */ 3590 3585 3591 3586 static struct inode *f2fs_nfs_get_inode(struct super_block *sb, 3592 3587 u64 ino, u32 generation)