[PATCH RFC DRAFT v2 12/13] f2fs: move fsverity to filesystem inode

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

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/file.c | 4 ++++
fs/f2fs/namei.c | 16 ++++++++++++++++
fs/f2fs/super.c | 3 +++
4 files changed, 26 insertions(+)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 152990273c68..c43f8be39cef 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_fscrypt_info; /* filesystem encryption info */
#endif
+#ifdef CONFIG_FS_VERITY
+ struct fsverity_info *i_fsverity_info;
+#endif
};

static inline void get_read_extent_info(struct extent_info *ext,
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index f0003672a42c..dee7ac9e27bb 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -1153,6 +1153,10 @@ const struct inode_operations f2fs_file_inode_operations = {
#ifdef CONFIG_FS_ENCRYPTION
.i_fscrypt = offsetof(struct f2fs_inode_info, i_fscrypt_info) -
offsetof(struct f2fs_inode_info, vfs_inode),
+#endif
+#ifdef CONFIG_FS_VERITY
+ .i_fsverity = offsetof(struct f2fs_inode_info, i_fsverity_info) -
+ offsetof(struct f2fs_inode_info, vfs_inode),
#endif
.getattr = f2fs_getattr,
.setattr = f2fs_setattr,
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 998b0c31f728..e30a55fb71bb 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -1337,6 +1337,10 @@ const struct inode_operations f2fs_encrypted_symlink_inode_operations = {
#ifdef CONFIG_FS_ENCRYPTION
.i_fscrypt = offsetof(struct f2fs_inode_info, i_fscrypt_info) -
offsetof(struct f2fs_inode_info, vfs_inode),
+#endif
+#ifdef CONFIG_FS_VERITY
+ .i_fsverity = offsetof(struct f2fs_inode_info, i_fsverity_info) -
+ offsetof(struct f2fs_inode_info, vfs_inode),
#endif
.get_link = f2fs_encrypted_get_link,
.getattr = f2fs_encrypted_symlink_getattr,
@@ -1348,6 +1352,10 @@ const struct inode_operations f2fs_dir_inode_operations = {
#ifdef CONFIG_FS_ENCRYPTION
.i_fscrypt = offsetof(struct f2fs_inode_info, i_fscrypt_info) -
offsetof(struct f2fs_inode_info, vfs_inode),
+#endif
+#ifdef CONFIG_FS_VERITY
+ .i_fsverity = offsetof(struct f2fs_inode_info, i_fsverity_info) -
+ offsetof(struct f2fs_inode_info, vfs_inode),
#endif
.create = f2fs_create,
.lookup = f2fs_lookup,
@@ -1373,6 +1381,10 @@ const struct inode_operations f2fs_symlink_inode_operations = {
#ifdef CONFIG_FS_ENCRYPTION
.i_fscrypt = offsetof(struct f2fs_inode_info, i_fscrypt_info) -
offsetof(struct f2fs_inode_info, vfs_inode),
+#endif
+#ifdef CONFIG_FS_VERITY
+ .i_fsverity = offsetof(struct f2fs_inode_info, i_fsverity_info) -
+ offsetof(struct f2fs_inode_info, vfs_inode),
#endif
.get_link = f2fs_get_link,
.getattr = f2fs_getattr,
@@ -1384,6 +1396,10 @@ const struct inode_operations f2fs_special_inode_operations = {
#ifdef CONFIG_FS_ENCRYPTION
.i_fscrypt = offsetof(struct f2fs_inode_info, i_fscrypt_info) -
offsetof(struct f2fs_inode_info, vfs_inode),
+#endif
+#ifdef CONFIG_FS_VERITY
+ .i_fsverity = offsetof(struct f2fs_inode_info, i_fsverity_info) -
+ offsetof(struct f2fs_inode_info, vfs_inode),
#endif
.getattr = f2fs_getattr,
.setattr = f2fs_setattr,
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 9f8e5ae13dc9..b88d446b3970 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_fscrypt_info = NULL;
#endif
+#ifdef CONFIG_FS_VERITY
+ fi->i_fsverity_info = NULL;
+#endif

return &fi->vfs_inode;
}

--
2.47.2