[PATCH v3 10/13] btrfs: move fsverity to filesystem inode

Christian Brauner
2025-07-22T19:28: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/btrfs/btrfs_inode.h | 3 +++
fs/btrfs/inode.c | 3 +++
fs/btrfs/super.c | 4 ++++
3 files changed, 10 insertions(+)

diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index a79fa0726f1d..10852d13fa00 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -339,6 +339,9 @@ struct btrfs_inode {

struct rw_semaphore i_mmap_lock;
struct inode vfs_inode;
+#ifdef CONFIG_FS_VERITY
+ struct fsverity_info *i_fsverity_info;
+#endif
};

static inline u64 btrfs_get_first_dir_index_to_log(const struct btrfs_inode *inode)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index c0c778243bf1..ff0e0bde221a 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7873,6 +7873,9 @@ struct inode *btrfs_alloc_inode(struct super_block *sb)
INIT_LIST_HEAD(&ei->delalloc_inodes);
INIT_LIST_HEAD(&ei->delayed_iput);
init_rwsem(&ei->i_mmap_lock);
+#ifdef CONFIG_FS_VERITY
+ ei->i_fsverity_info = NULL;
+#endif

return inode;
}
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index a0c65adce1ab..e5def2ce85d9 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -2395,6 +2395,10 @@ static long btrfs_free_cached_objects(struct super_block *sb, struct shrink_cont
}

static const struct super_operations btrfs_super_ops = {
+#ifdef CONFIG_FS_VERITY
+ .i_fsverity = offsetof(struct btrfs_inode, i_fsverity_info) -
+ offsetof(struct btrfs_inode, vfs_inode),
+#endif
.drop_inode = btrfs_drop_inode,
.evict_inode = btrfs_evict_inode,
.put_super = btrfs_put_super,

--
2.47.2