Move the fsverity_info pointer into the filesystem-specific part of the
inode by adding the field ext4_inode_info::i_verity_info and configuring
fsverity_operations::inode_info_offs accordingly.

This is a prerequisite for a later commit that removes
inode::i_verity_info, saving memory and improving cache efficiency on
filesystems that don't support fsverity.

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/ext4/ext4.h   | 4 ++++
 fs/ext4/super.c  | 3 +++
 fs/ext4/verity.c | 2 ++
 3 files changed, 9 insertions(+)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index c897109dadb15..6cb784a56b3ba 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1184,10 +1184,14 @@ struct ext4_inode_info {
        kprojid_t i_projid;
 
 #ifdef CONFIG_FS_ENCRYPTION
        struct fscrypt_inode_info *i_crypt_info;
 #endif
+
+#ifdef CONFIG_FS_VERITY
+       struct fsverity_info *i_verity_info;
+#endif
 };
 
 /*
  * File system states
  */
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 0c3059ecce37c..46138a6cb32a3 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1471,10 +1471,13 @@ static void init_once(void *foo)
        inode_init_once(&ei->vfs_inode);
        ext4_fc_init_inode(&ei->vfs_inode);
 #ifdef CONFIG_FS_ENCRYPTION
        ei->i_crypt_info = NULL;
 #endif
+#ifdef CONFIG_FS_VERITY
+       ei->i_verity_info = NULL;
+#endif
 }
 
 static int __init init_inodecache(void)
 {
        ext4_inode_cachep = kmem_cache_create_usercopy("ext4_inode_cache",
diff --git a/fs/ext4/verity.c b/fs/ext4/verity.c
index d9203228ce979..b0acb0c503137 100644
--- a/fs/ext4/verity.c
+++ b/fs/ext4/verity.c
@@ -387,10 +387,12 @@ static int ext4_write_merkle_tree_block(struct inode 
*inode, const void *buf,
 
        return pagecache_write(inode, buf, size, pos);
 }
 
 const struct fsverity_operations ext4_verityops = {
+       .inode_info_offs        = (int)offsetof(struct ext4_inode_info, 
i_verity_info) -
+                                 (int)offsetof(struct ext4_inode_info, 
vfs_inode),
        .begin_enable_verity    = ext4_begin_enable_verity,
        .end_enable_verity      = ext4_end_enable_verity,
        .get_verity_descriptor  = ext4_get_verity_descriptor,
        .read_merkle_tree_page  = ext4_read_merkle_tree_page,
        .write_merkle_tree_block = ext4_write_merkle_tree_block,
-- 
2.50.1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to