[PATCH v4 13/15] f2fs: move fsverity to filesystem inode

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

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

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 53cb6b6fc70b..f4d04f6fd680 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -908,6 +908,9 @@ struct f2fs_inode_info {
#ifdef CONFIG_FS_ENCRYPTION
struct fscrypt_inode_info *i_crypt_info; /* filesystem encryption info */
#endif
+#ifdef CONFIG_FS_VERITY
+ struct fsverity_info *i_verity_info;
+#endif
};

static inline void get_read_extent_info(struct extent_info *ext,
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index dab4078c2f6a..628469ee2b28 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1456,6 +1456,9 @@ static struct inode *f2fs_alloc_inode(struct super_block *sb)
#ifdef CONFIG_FS_ENCRYPTION
fi->i_crypt_info = NULL;
#endif
+#ifdef CONFIG_FS_VERITY
+ fi->i_verity_info = NULL;
+#endif

return &fi->vfs_inode;
}
diff --git a/fs/f2fs/verity.c b/fs/f2fs/verity.c
index 2287f238ae09..1529fe072ff9 100644
--- a/fs/f2fs/verity.c
+++ b/fs/f2fs/verity.c
@@ -287,6 +287,10 @@ static int f2fs_write_merkle_tree_block(struct inode *inode, const void *buf,
}

const struct fsverity_operations f2fs_verityops = {
+#ifdef CONFIG_FS_VERITY
+ .inode_info_offs = offsetof(struct f2fs_inode_info, i_verity_info) -
+ offsetof(struct f2fs_inode_info, vfs_inode),
+#endif
.begin_enable_verity = f2fs_begin_enable_verity,
.end_enable_verity = f2fs_end_enable_verity,
.get_verity_descriptor = f2fs_get_verity_descriptor,

--
2.47.2