[PATCH RFC DRAFT v2 11/13] ext4: move fsverity to filesystem inode

Christian Brauner
2025-07-22T12:58:19Z

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/file.c | 4 ++++
fs/ext4/namei.c | 8 ++++++++
fs/ext4/super.c | 3 +++
fs/ext4/symlink.c | 12 ++++++++++++
5 files changed, 31 insertions(+)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index e9710366d87a..d388a7fb1a87 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_fscrypt_info;
#endif
+
+#ifdef CONFIG_FS_VERITY
+ struct fsverity_info *i_fsverity_info;
+#endif
};

/*
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index 9bdee2757bdf..06347086b87e 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -984,6 +984,10 @@ const struct inode_operations ext4_file_inode_operations = {
#ifdef CONFIG_FS_ENCRYPTION
.i_fscrypt = offsetof(struct ext4_inode_info, i_fscrypt_info) -
offsetof(struct ext4_inode_info, vfs_inode),
+#endif
+#ifdef CONFIG_FS_VERITY
+ .i_fsverity = offsetof(struct ext4_inode_info, i_fsverity_info) -
+ offsetof(struct ext4_inode_info, vfs_inode),
#endif
.setattr = ext4_setattr,
.getattr = ext4_file_getattr,
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index fb953834265c..c80ac16d9ca8 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -4217,6 +4217,10 @@ const struct inode_operations ext4_dir_inode_operations = {
#ifdef CONFIG_FS_ENCRYPTION
.i_fscrypt = offsetof(struct ext4_inode_info, i_fscrypt_info) -
offsetof(struct ext4_inode_info, vfs_inode),
+#endif
+#ifdef CONFIG_FS_VERITY
+ .i_fsverity = offsetof(struct ext4_inode_info, i_fsverity_info) -
+ offsetof(struct ext4_inode_info, vfs_inode),
#endif
.create = ext4_create,
.lookup = ext4_lookup,
@@ -4242,6 +4246,10 @@ const struct inode_operations ext4_special_inode_operations = {
#ifdef CONFIG_FS_ENCRYPTION
.i_fscrypt = offsetof(struct ext4_inode_info, i_fscrypt_info) -
offsetof(struct ext4_inode_info, vfs_inode),
+#endif
+#ifdef CONFIG_FS_VERITY
+ .i_fsverity = offsetof(struct ext4_inode_info, i_fsverity_info) -
+ offsetof(struct ext4_inode_info, vfs_inode),
#endif
.setattr = ext4_setattr,
.getattr = ext4_getattr,
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 6085d6c9169b..f003b23a62e7 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_fscrypt_info = NULL;
+#endif
+#ifdef CONFIG_FS_VERITY
+ ei->i_fsverity_info = NULL;
#endif
return &ei->vfs_inode;
}
diff --git a/fs/ext4/symlink.c b/fs/ext4/symlink.c
index 6b67a9a5c02c..4cb96956a17e 100644
--- a/fs/ext4/symlink.c
+++ b/fs/ext4/symlink.c
@@ -118,6 +118,10 @@ const struct inode_operations ext4_encrypted_symlink_inode_operations = {
#ifdef CONFIG_FS_ENCRYPTION
.i_fscrypt = offsetof(struct ext4_inode_info, i_fscrypt_info) -
offsetof(struct ext4_inode_info, vfs_inode),
+#endif
+#ifdef CONFIG_FS_VERITY
+ .i_fsverity = offsetof(struct ext4_inode_info, i_fsverity_info) -
+ offsetof(struct ext4_inode_info, vfs_inode),
#endif
.get_link = ext4_encrypted_get_link,
.setattr = ext4_setattr,
@@ -129,6 +133,10 @@ const struct inode_operations ext4_symlink_inode_operations = {
#ifdef CONFIG_FS_ENCRYPTION
.i_fscrypt = offsetof(struct ext4_inode_info, i_fscrypt_info) -
offsetof(struct ext4_inode_info, vfs_inode),
+#endif
+#ifdef CONFIG_FS_VERITY
+ .i_fsverity = offsetof(struct ext4_inode_info, i_fsverity_info) -
+ offsetof(struct ext4_inode_info, vfs_inode),
#endif
.get_link = ext4_get_link,
.setattr = ext4_setattr,
@@ -140,6 +148,10 @@ const struct inode_operations ext4_fast_symlink_inode_operations = {
#ifdef CONFIG_FS_ENCRYPTION
.i_fscrypt = offsetof(struct ext4_inode_info, i_fscrypt_info) -
offsetof(struct ext4_inode_info, vfs_inode),
+#endif
+#ifdef CONFIG_FS_VERITY
+ .i_fsverity = offsetof(struct ext4_inode_info, i_fsverity_info) -
+ offsetof(struct ext4_inode_info, vfs_inode),
#endif
.get_link = simple_get_link,
.setattr = ext4_setattr,

--
2.47.2