]> www.infradead.org Git - users/hch/misc.git/commitdiff
ext4: move crypt info pointer to fs-specific part of inode
authorEric Biggers <ebiggers@kernel.org>
Sun, 10 Aug 2025 07:56:56 +0000 (00:56 -0700)
committerChristian Brauner <brauner@kernel.org>
Thu, 21 Aug 2025 11:58:07 +0000 (13:58 +0200)
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>
fs/ext4/crypto.c
fs/ext4/ext4.h
fs/ext4/super.c

index 0a056d97e64024a3aa47a86d87a3b9fddbe700df..cf0a0970c095620ef4591a66c869bc3b3e009879 100644 (file)
@@ -227,6 +227,8 @@ static bool ext4_has_stable_inodes(struct super_block *sb)
 }
 
 const struct fscrypt_operations ext4_cryptops = {
+       .inode_info_offs        = (int)offsetof(struct ext4_inode_info, i_crypt_info) -
+                                 (int)offsetof(struct ext4_inode_info, vfs_inode),
        .needs_bounce_pages     = 1,
        .has_32bit_inodes       = 1,
        .supports_subblock_data_units = 1,
index 01a6e2de7fc3ef0e20b039d3200b9c9bd656f59f..c897109dadb1572780432f2f667f54ccce2be75f 100644 (file)
@@ -1182,6 +1182,10 @@ struct ext4_inode_info {
        __u32 i_csum_seed;
 
        kprojid_t i_projid;
+
+#ifdef CONFIG_FS_ENCRYPTION
+       struct fscrypt_inode_info *i_crypt_info;
+#endif
 };
 
 /*
index c7d39da7e733b13b2760da3341c8991401043a0b..0c3059ecce37ce9b79b867030022b3aacde25fab 100644 (file)
@@ -1470,6 +1470,9 @@ static void init_once(void *foo)
        init_rwsem(&ei->i_data_sem);
        inode_init_once(&ei->vfs_inode);
        ext4_fc_init_inode(&ei->vfs_inode);
+#ifdef CONFIG_FS_ENCRYPTION
+       ei->i_crypt_info = NULL;
+#endif
 }
 
 static int __init init_inodecache(void)