Skip to content

Commit 8a3d00d

Browse files
Eric Biggersbrauner
authored andcommitted
fsverity: check IS_VERITY() in fsverity_cleanup_inode()
Since getting the address of the fsverity_info has gotten a bit more expensive, make fsverity_cleanup_inode() check for IS_VERITY() instead. This avoids adding more overhead to non-verity files. This assumes that verity info is never set when !IS_VERITY(), which is currently true, but add a VFS_WARN_ON_ONCE() that asserts that. (This of course defeats the optimization, but only when CONFIG_VFS_DEBUG=y.) Signed-off-by: Eric Biggers <ebiggers@kernel.org> Link: https://lore.kernel.org/20250810075706.172910-14-ebiggers@kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 818c659 commit 8a3d00d

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

include/linux/fsverity.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,15 @@ void __fsverity_cleanup_inode(struct inode *inode);
190190
*/
191191
static inline void fsverity_cleanup_inode(struct inode *inode)
192192
{
193-
if (*fsverity_info_addr(inode))
193+
/*
194+
* Only IS_VERITY() inodes can have verity info, so start by checking
195+
* for IS_VERITY() (which is faster than retrieving the pointer to the
196+
* verity info). This minimizes overhead for non-verity inodes.
197+
*/
198+
if (IS_VERITY(inode))
194199
__fsverity_cleanup_inode(inode);
200+
else
201+
VFS_WARN_ON_ONCE(*fsverity_info_addr(inode) != NULL);
195202
}
196203

197204
/* read_metadata.c */

0 commit comments

Comments
 (0)