Move the fscrypt_inode_info pointer into the filesystem-specific part of the inode by adding the field ceph_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 <brau...@kernel.org> Signed-off-by: Christian Brauner <brau...@kernel.org> Signed-off-by: Eric Biggers <ebigg...@kernel.org> --- fs/ceph/crypto.c | 2 ++ fs/ceph/inode.c | 1 + fs/ceph/super.h | 1 + 3 files changed, 4 insertions(+) diff --git a/fs/ceph/crypto.c b/fs/ceph/crypto.c index cab7226192073..7026e794813ca 100644 --- a/fs/ceph/crypto.c +++ b/fs/ceph/crypto.c @@ -131,10 +131,12 @@ static const union fscrypt_policy *ceph_get_dummy_policy(struct super_block *sb) { return ceph_sb_to_fs_client(sb)->fsc_dummy_enc_policy.policy; } static struct fscrypt_operations ceph_fscrypt_ops = { + .inode_info_offs = (int)offsetof(struct ceph_inode_info, i_crypt_info) - + (int)offsetof(struct ceph_inode_info, netfs.inode), .needs_bounce_pages = 1, .get_context = ceph_crypt_get_context, .set_context = ceph_crypt_set_context, .get_dummy_policy = ceph_get_dummy_policy, .empty_dir = ceph_crypt_empty_dir, diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index fc543075b827a..480cb3a1d639a 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -663,10 +663,11 @@ struct inode *ceph_alloc_inode(struct super_block *sb) INIT_WORK(&ci->i_work, ceph_inode_work); ci->i_work_mask = 0; memset(&ci->i_btime, '\0', sizeof(ci->i_btime)); #ifdef CONFIG_FS_ENCRYPTION + ci->i_crypt_info = NULL; ci->fscrypt_auth = NULL; ci->fscrypt_auth_len = 0; #endif return &ci->netfs.inode; } diff --git a/fs/ceph/super.h b/fs/ceph/super.h index cf176aab0f823..25d8bacbcf440 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -461,10 +461,11 @@ struct ceph_inode_info { struct work_struct i_work; unsigned long i_work_mask; #ifdef CONFIG_FS_ENCRYPTION + struct fscrypt_inode_info *i_crypt_info; u32 fscrypt_auth_len; u32 fscrypt_file_len; u8 *fscrypt_auth; u8 *fscrypt_file; #endif -- 2.50.1 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel