Skip to content

Commit 80e07df

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

3 files changed

Lines changed: 9 additions & 0 deletions

File tree

fs/ext4/crypto.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ static bool ext4_has_stable_inodes(struct super_block *sb)
227227
}
228228

229229
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),
230232
.needs_bounce_pages = 1,
231233
.has_32bit_inodes = 1,
232234
.supports_subblock_data_units = 1,

fs/ext4/ext4.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,6 +1182,10 @@ struct ext4_inode_info {
11821182
__u32 i_csum_seed;
11831183

11841184
kprojid_t i_projid;
1185+
1186+
#ifdef CONFIG_FS_ENCRYPTION
1187+
struct fscrypt_inode_info *i_crypt_info;
1188+
#endif
11851189
};
11861190

11871191
/*

fs/ext4/super.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,6 +1470,9 @@ static void init_once(void *foo)
14701470
init_rwsem(&ei->i_data_sem);
14711471
inode_init_once(&ei->vfs_inode);
14721472
ext4_fc_init_inode(&ei->vfs_inode);
1473+
#ifdef CONFIG_FS_ENCRYPTION
1474+
ei->i_crypt_info = NULL;
1475+
#endif
14731476
}
14741477

14751478
static int __init init_inodecache(void)

0 commit comments

Comments
 (0)