Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Eric Biggers and committed by
Christian Brauner
818c659a fcafdd42

+8 -7
-5
include/linux/fs.h
··· 73 73 struct workqueue_struct; 74 74 struct iov_iter; 75 75 struct fscrypt_operations; 76 - struct fsverity_info; 77 76 struct fsverity_operations; 78 77 struct fsnotify_mark_connector; 79 78 struct fsnotify_sb_info; ··· 776 777 __u32 i_fsnotify_mask; /* all events this inode cares about */ 777 778 /* 32-bit hole reserved for expanding i_fsnotify_mask */ 778 779 struct fsnotify_mark_connector __rcu *i_fsnotify_marks; 779 - #endif 780 - 781 - #ifdef CONFIG_FS_VERITY 782 - struct fsverity_info *i_verity_info; 783 780 #endif 784 781 785 782 void *i_private; /* fs or device private pointer */
+8 -2
include/linux/fsverity.h
··· 26 26 /* Arbitrary limit to bound the kmalloc() size. Can be changed. */ 27 27 #define FS_VERITY_MAX_DESCRIPTOR_SIZE 16384 28 28 29 + struct fsverity_info; 30 + 29 31 /* Verity operations for filesystems */ 30 32 struct fsverity_operations { 31 33 /** ··· 132 130 133 131 #ifdef CONFIG_FS_VERITY 134 132 133 + /* 134 + * Returns the address of the verity info pointer within the filesystem-specific 135 + * part of the inode. (To save memory on filesystems that don't support 136 + * fsverity, a field in 'struct inode' itself is no longer used.) 137 + */ 135 138 static inline struct fsverity_info ** 136 139 fsverity_info_addr(const struct inode *inode) 137 140 { 138 - if (inode->i_sb->s_vop->inode_info_offs == 0) 139 - return (struct fsverity_info **)&inode->i_verity_info; 141 + VFS_WARN_ON_ONCE(inode->i_sb->s_vop->inode_info_offs == 0); 140 142 return (void *)inode + inode->i_sb->s_vop->inode_info_offs; 141 143 } 142 144