2022-12-14 22:47:42

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 0/4] fsverity cleanups

This series implements a few cleanups that have been suggested
in the thread "[RFC PATCH 00/11] fs-verity support for XFS"
(https://lore.kernel.org/linux-fsdevel/[email protected]/T/#u).

This applies to mainline (commit 93761c93e9da).

Eric Biggers (4):
fsverity: optimize fsverity_file_open() on non-verity files
fsverity: optimize fsverity_prepare_setattr() on non-verity files
fsverity: optimize fsverity_cleanup_inode() on non-verity files
fsverity: pass pos and size to ->write_merkle_tree_block

fs/btrfs/verity.c | 19 ++++-------
fs/ext4/verity.c | 6 ++--
fs/f2fs/verity.c | 6 ++--
fs/verity/enable.c | 4 +--
fs/verity/open.c | 46 ++++---------------------
include/linux/fsverity.h | 74 +++++++++++++++++++++++++++++++++-------
6 files changed, 84 insertions(+), 71 deletions(-)


base-commit: 93761c93e9da28d8a020777cee2a84133082b477
--
2.38.1


2022-12-14 22:50:16

by Eric Biggers

[permalink] [raw]
Subject: [PATCH 3/4] fsverity: optimize fsverity_cleanup_inode() on non-verity files

From: Eric Biggers <[email protected]>

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 <[email protected]>
---
fs/verity/open.c | 10 ++--------
include/linux/fsverity.h | 14 +++++++++++++-
2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/fs/verity/open.c b/fs/verity/open.c
index e1e531d5e09a..c723a62841db 100644
--- a/fs/verity/open.c
+++ b/fs/verity/open.c
@@ -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)
{
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 */

--
2.38.1

2022-12-14 23:14:40

by Dave Chinner

[permalink] [raw]
Subject: Re: [PATCH 0/4] fsverity cleanups

On Wed, Dec 14, 2022 at 02:43:00PM -0800, Eric Biggers wrote:
> This series implements a few cleanups that have been suggested
> in the thread "[RFC PATCH 00/11] fs-verity support for XFS"
> (https://lore.kernel.org/linux-fsdevel/[email protected]/T/#u).
>
> This applies to mainline (commit 93761c93e9da).
>
> Eric Biggers (4):
> fsverity: optimize fsverity_file_open() on non-verity files
> fsverity: optimize fsverity_prepare_setattr() on non-verity files
> fsverity: optimize fsverity_cleanup_inode() on non-verity files
> fsverity: pass pos and size to ->write_merkle_tree_block
>
> fs/btrfs/verity.c | 19 ++++-------
> fs/ext4/verity.c | 6 ++--
> fs/f2fs/verity.c | 6 ++--
> fs/verity/enable.c | 4 +--
> fs/verity/open.c | 46 ++++---------------------
> include/linux/fsverity.h | 74 +++++++++++++++++++++++++++++++++-------
> 6 files changed, 84 insertions(+), 71 deletions(-)

The whole series looks fairly sane to me.

Acked-by: Dave Chinner <[email protected]>

--
Dave Chinner
[email protected]

2023-01-04 07:07:29

by Eric Biggers

[permalink] [raw]
Subject: Re: [PATCH 0/4] fsverity cleanups

On Wed, Dec 14, 2022 at 02:43:00PM -0800, Eric Biggers wrote:
> This series implements a few cleanups that have been suggested
> in the thread "[RFC PATCH 00/11] fs-verity support for XFS"
> (https://lore.kernel.org/linux-fsdevel/[email protected]/T/#u).
>
> This applies to mainline (commit 93761c93e9da).
>
> Eric Biggers (4):
> fsverity: optimize fsverity_file_open() on non-verity files
> fsverity: optimize fsverity_prepare_setattr() on non-verity files
> fsverity: optimize fsverity_cleanup_inode() on non-verity files
> fsverity: pass pos and size to ->write_merkle_tree_block
>
> fs/btrfs/verity.c | 19 ++++-------
> fs/ext4/verity.c | 6 ++--
> fs/f2fs/verity.c | 6 ++--
> fs/verity/enable.c | 4 +--
> fs/verity/open.c | 46 ++++---------------------
> include/linux/fsverity.h | 74 +++++++++++++++++++++++++++++++++-------
> 6 files changed, 84 insertions(+), 71 deletions(-)
>
>

Applied for 6.3. (To
https://git.kernel.org/pub/scm/fs/fscrypt/fscrypt.git/log/?h=fsverity for now,
but there might be a new git repo soon, as is being discussed elsewhere.)

- Eric