summaryrefslogtreecommitdiffstats
path: root/include/linux/fsverity.h
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2022-12-14 14:43:03 -0800
committerEric Biggers <ebiggers@google.com>2023-01-01 15:46:48 -0800
commit9642946c6c851ba954689f184b3370e3594b6b1a (patch)
tree2ee4051f2fb36d041f2845bcd2427d3e3231e22e /include/linux/fsverity.h
parent01d90c07a592b532c7a673dfd8baa6d6e496273d (diff)
downloadlinux-9642946c6c851ba954689f184b3370e3594b6b1a.tar.gz
linux-9642946c6c851ba954689f184b3370e3594b6b1a.tar.bz2
linux-9642946c6c851ba954689f184b3370e3594b6b1a.zip
fsverity: optimize fsverity_cleanup_inode() on non-verity files
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
Diffstat (limited to 'include/linux/fsverity.h')
-rw-r--r--include/linux/fsverity.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/include/linux/fsverity.h b/include/linux/fsverity.h
index 84b498fff7ec..203f4962c54a 100644
--- a/include/linux/fsverity.h
+++ b/include/linux/fsverity.h
@@ -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 */