Skip to content

Commit 818c659

Browse files
Eric Biggersbrauner
authored andcommitted
fs: remove inode::i_verity_info
Now that all fsverity-capable filesystems store the pointer to fsverity_info in the filesystem-specific part of the inode structure, inode::i_verity_info is no longer needed. Update fsverity_info_addr() to no longer support the fallback to inode::i_verity_info. Finally, remove inode::i_verity_info itself, and move the forward declaration of struct fsverity_info from fs.h (which no longer needs it) to fsverity.h. The end result of the migration to the filesystem-specific pointer is memory savings on CONFIG_FS_VERITY=y kernels for all filesystems that don't support fsverity. Specifically, their in-memory inodes are now smaller by the size of a pointer: either 4 or 8 bytes. Co-developed-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Eric Biggers <ebiggers@kernel.org> Link: https://lore.kernel.org/20250810075706.172910-13-ebiggers@kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent fcafdd4 commit 818c659

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

include/linux/fs.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ struct seq_file;
7373
struct workqueue_struct;
7474
struct iov_iter;
7575
struct fscrypt_operations;
76-
struct fsverity_info;
7776
struct fsverity_operations;
7877
struct fsnotify_mark_connector;
7978
struct fsnotify_sb_info;
@@ -779,10 +778,6 @@ struct inode {
779778
struct fsnotify_mark_connector __rcu *i_fsnotify_marks;
780779
#endif
781780

782-
#ifdef CONFIG_FS_VERITY
783-
struct fsverity_info *i_verity_info;
784-
#endif
785-
786781
void *i_private; /* fs or device private pointer */
787782
} __randomize_layout;
788783

include/linux/fsverity.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
/* Arbitrary limit to bound the kmalloc() size. Can be changed. */
2727
#define FS_VERITY_MAX_DESCRIPTOR_SIZE 16384
2828

29+
struct fsverity_info;
30+
2931
/* Verity operations for filesystems */
3032
struct fsverity_operations {
3133
/**
@@ -130,11 +132,15 @@ struct fsverity_operations {
130132

131133
#ifdef CONFIG_FS_VERITY
132134

135+
/*
136+
* Returns the address of the verity info pointer within the filesystem-specific
137+
* part of the inode. (To save memory on filesystems that don't support
138+
* fsverity, a field in 'struct inode' itself is no longer used.)
139+
*/
133140
static inline struct fsverity_info **
134141
fsverity_info_addr(const struct inode *inode)
135142
{
136-
if (inode->i_sb->s_vop->inode_info_offs == 0)
137-
return (struct fsverity_info **)&inode->i_verity_info;
143+
VFS_WARN_ON_ONCE(inode->i_sb->s_vop->inode_info_offs == 0);
138144
return (void *)inode + inode->i_sb->s_vop->inode_info_offs;
139145
}
140146

0 commit comments

Comments
 (0)