Move fscrypt data pointer into the filesystem's private inode and record the offset from the embedded struct inode. This will allow us to drop the fscrypt data pointer from struct inode itself and move it into the filesystem's inode. Signed-off-by: Christian Brauner <brauner@xxxxxxxxxx> --- fs/ext4/ext4.h | 4 ++++ fs/ext4/mballoc-test.c | 4 ++++ fs/ext4/super.c | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 18373de980f2..f27d57aea316 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1197,6 +1197,10 @@ struct ext4_inode_info { __u32 i_csum_seed; kprojid_t i_projid; + +#ifdef CONFIG_FS_ENCRYPTION + struct fscrypt_inode_info *i_fscrypt_info; +#endif }; /* diff --git a/fs/ext4/mballoc-test.c b/fs/ext4/mballoc-test.c index d634c12f1984..b8e039a666c3 100644 --- a/fs/ext4/mballoc-test.c +++ b/fs/ext4/mballoc-test.c @@ -53,6 +53,10 @@ static void mbt_free_inode(struct inode *inode) } static const struct super_operations mbt_sops = { +#ifdef CONFIG_FS_ENCRYPTION + .i_fscrypt = offsetof(struct ext4_inode_info, i_fscrypt_info) - + offsetof(struct ext4_inode_info, vfs_inode), +#endif .alloc_inode = mbt_alloc_inode, .free_inode = mbt_free_inode, }; diff --git a/fs/ext4/super.c b/fs/ext4/super.c index c7d39da7e733..2a03835b67d5 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1412,6 +1412,9 @@ static struct inode *ext4_alloc_inode(struct super_block *sb) INIT_WORK(&ei->i_rsv_conversion_work, ext4_end_io_rsv_work); ext4_fc_init_inode(&ei->vfs_inode); spin_lock_init(&ei->i_fc_lock); +#ifdef CONFIG_FS_ENCRYPTION + ei->i_fscrypt_info = NULL; +#endif return &ei->vfs_inode; } @@ -1607,6 +1610,10 @@ static const struct quotactl_ops ext4_qctl_operations = { #endif static const struct super_operations ext4_sops = { +#ifdef CONFIG_FS_ENCRYPTION + .i_fscrypt = offsetof(struct ext4_inode_info, i_fscrypt_info) - + offsetof(struct ext4_inode_info, vfs_inode), +#endif .alloc_inode = ext4_alloc_inode, .free_inode = ext4_free_in_core_inode, .destroy_inode = ext4_destroy_inode, -- 2.47.2