]> www.infradead.org Git - users/hch/misc.git/commitdiff
ceph: move crypt info pointer to fs-specific part of inode
authorEric Biggers <ebiggers@kernel.org>
Sun, 10 Aug 2025 07:56:59 +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 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 <brauner@kernel.org>
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Link: https://lore.kernel.org/20250810075706.172910-7-ebiggers@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/ceph/crypto.c
fs/ceph/inode.c
fs/ceph/super.h

index cab7226192073f1ec18dedcf2c6e7d450ecbbc32..7026e794813ca11fd6ac9d560ab04f0fa333db7e 100644 (file)
@@ -133,6 +133,8 @@ static const union fscrypt_policy *ceph_get_dummy_policy(struct super_block *sb)
 }
 
 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,
index fc543075b827a9d0138fda91174e1e099caed33c..480cb3a1d639ac2484eebbd937c516c57b7b765f 100644 (file)
@@ -665,6 +665,7 @@ struct inode *ceph_alloc_inode(struct super_block *sb)
        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
index cf176aab0f82399aa4f8ea0fd16fb61f40c73030..25d8bacbcf44081b6357901cfd8f8e8771d81fed 100644 (file)
@@ -463,6 +463,7 @@ struct ceph_inode_info {
        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;