Skip to content

Commit 7afb71e

Browse files
Eric Biggersbrauner
authored andcommitted
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>
1 parent 80e07df commit 7afb71e

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

fs/f2fs/f2fs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,9 @@ struct f2fs_inode_info {
907907

908908
unsigned int atomic_write_cnt;
909909
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
910913
};
911914

912915
static inline void get_read_extent_info(struct extent_info *ext,

fs/f2fs/super.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,9 @@ static void init_once(void *foo)
480480
struct f2fs_inode_info *fi = (struct f2fs_inode_info *) foo;
481481

482482
inode_init_once(&fi->vfs_inode);
483+
#ifdef CONFIG_FS_ENCRYPTION
484+
fi->i_crypt_info = NULL;
485+
#endif
483486
}
484487

485488
#ifdef CONFIG_QUOTA
@@ -3570,6 +3573,8 @@ static struct block_device **f2fs_get_devices(struct super_block *sb,
35703573
}
35713574

35723575
static const struct fscrypt_operations f2fs_cryptops = {
3576+
.inode_info_offs = (int)offsetof(struct f2fs_inode_info, i_crypt_info) -
3577+
(int)offsetof(struct f2fs_inode_info, vfs_inode),
35733578
.needs_bounce_pages = 1,
35743579
.has_32bit_inodes = 1,
35753580
.supports_subblock_data_units = 1,
@@ -3581,7 +3586,7 @@ static const struct fscrypt_operations f2fs_cryptops = {
35813586
.has_stable_inodes = f2fs_has_stable_inodes,
35823587
.get_devices = f2fs_get_devices,
35833588
};
3584-
#endif
3589+
#endif /* CONFIG_FS_ENCRYPTION */
35853590

35863591
static struct inode *f2fs_nfs_get_inode(struct super_block *sb,
35873592
u64 ino, u32 generation)

0 commit comments

Comments
 (0)