Skip to content

Commit

Permalink
fsverity: optimize fsverity_cleanup_inode() on non-verity files
Browse files Browse the repository at this point in the history
Make fsverity_cleanup_inode() an inline function that checks for
non-NULL ->i_verity_info, then (if needed) calls
__fsverity_cleanup_inode() to do the real work.  This reduces the
overhead on non-verity files.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Acked-by: Dave Chinner <dchinner@redhat.com>
Link: https://lore.kernel.org/r/20221214224304.145712-4-ebiggers@kernel.org
  • Loading branch information
Eric Biggers committed Jan 1, 2023
1 parent 01d90c0 commit 9642946
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
10 changes: 2 additions & 8 deletions fs/verity/open.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,18 +348,12 @@ int __fsverity_prepare_setattr(struct dentry *dentry, struct iattr *attr)
}
EXPORT_SYMBOL_GPL(__fsverity_prepare_setattr);

/**
* fsverity_cleanup_inode() - free the inode's verity info, if present
* @inode: an inode being evicted
*
* Filesystems must call this on inode eviction to free ->i_verity_info.
*/
void fsverity_cleanup_inode(struct inode *inode)
void __fsverity_cleanup_inode(struct inode *inode)
{
fsverity_free_info(inode->i_verity_info);
inode->i_verity_info = NULL;
}
EXPORT_SYMBOL_GPL(fsverity_cleanup_inode);
EXPORT_SYMBOL_GPL(__fsverity_cleanup_inode);

int __init fsverity_init_info_cache(void)
{
Expand Down
14 changes: 13 additions & 1 deletion include/linux/fsverity.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,19 @@ int fsverity_get_digest(struct inode *inode,

int __fsverity_file_open(struct inode *inode, struct file *filp);
int __fsverity_prepare_setattr(struct dentry *dentry, struct iattr *attr);
void fsverity_cleanup_inode(struct inode *inode);
void __fsverity_cleanup_inode(struct inode *inode);

/**
* fsverity_cleanup_inode() - free the inode's verity info, if present
* @inode: an inode being evicted
*
* Filesystems must call this on inode eviction to free ->i_verity_info.
*/
static inline void fsverity_cleanup_inode(struct inode *inode)
{
if (inode->i_verity_info)
__fsverity_cleanup_inode(inode);
}

/* read_metadata.c */

Expand Down

0 comments on commit 9642946

Please sign in to comment.