[PATCH v4 12/15] ext4: move fsverity to filesystem inode

Christian Brauner
2025-07-23T10:58:40Z

Move fsverity data pointer into the filesystem's private inode and
record the offset from the embedded struct inode.

This will allow us to drop the fsverity data pointer from struct inode
itself and move it into the filesystem's inode.

Signed-off-by: Christian Brauner <brauner@kernel.org>
---
fs/ext4/ext4.h | 4 ++++
fs/ext4/super.c | 3 +++
fs/ext4/verity.c | 4 ++++
3 files changed, 11 insertions(+)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 75209a09b19f..d7befc610ca2 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1201,6 +1201,10 @@ struct ext4_inode_info {
#ifdef CONFIG_FS_ENCRYPTION
struct fscrypt_inode_info *i_crypt_info;
#endif
+
+#ifdef CONFIG_FS_VERITY
+ struct fsverity_info *i_verity_info;
+#endif
};

/*
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 47c450c68a3b..ff4070df5d77 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1414,6 +1414,9 @@ static struct inode *ext4_alloc_inode(struct super_block *sb)
spin_lock_init(&ei->i_fc_lock);
#ifdef CONFIG_FS_ENCRYPTION
ei->i_crypt_info = NULL;
+#endif
+#ifdef CONFIG_FS_VERITY
+ ei->i_verity_info = NULL;
#endif
return &ei->vfs_inode;
}
diff --git a/fs/ext4/verity.c b/fs/ext4/verity.c
index d9203228ce97..70d9c6c73313 100644
--- a/fs/ext4/verity.c
+++ b/fs/ext4/verity.c
@@ -389,6 +389,10 @@ static int ext4_write_merkle_tree_block(struct inode *inode, const void *buf,
}

const struct fsverity_operations ext4_verityops = {
+#ifdef CONFIG_FS_VERITY
+ .inode_info_offs = offsetof(struct ext4_inode_info, i_verity_info) -
+ offsetof(struct ext4_inode_info, vfs_inode),
+#endif
.begin_enable_verity = ext4_begin_enable_verity,
.end_enable_verity = ext4_end_enable_verity,
.get_verity_descriptor = ext4_get_verity_descriptor,

--
2.47.2