public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
* fsverity cleanups, speedup and memory usage optimization v2
@ 2026-01-22  8:21 Christoph Hellwig
  2026-01-22  8:21 ` [PATCH 01/11] fs,fsverity: reject size changes on fsverity files in setattr_prepare Christoph Hellwig
                   ` (11 more replies)
  0 siblings, 12 replies; 54+ messages in thread
From: Christoph Hellwig @ 2026-01-22  8:21 UTC (permalink / raw)
  To: Eric Biggers
  Cc: Al Viro, Christian Brauner, Jan Kara, David Sterba,
	Theodore Ts'o, Jaegeuk Kim, Chao Yu, Andrey Albershteyn,
	Matthew Wilcox (Oracle), linux-fsdevel, linux-btrfs, linux-ext4,
	linux-f2fs-devel, fsverity

Hi all,

this series has a hodge podge of fsverity enhances that I looked into as
part of the review of the xfs fsverity support series.

The first part calls fsverity code from VFS code instead of requiring
boilerplate in the file systems.  The first patch fixes a bug in btrfs
as part of that, as btrfs was missing a check.  An xfstests
test case for this was submitted already.

The middle part optimizes the fsverity read path by kicking off readahead
for the fsverity hashes from the data read submission context, which in my
simply testing showed huge benefits for sequential reads using dd.
I haven't been able to get fio to run on a preallocated fio file, but
I expect random read benefits would be significantly better than that
still.

The last part avoids the need for a pointer in every inode for fsverity
and instead uses a rhashtable lookup, which is once per read_folio or
->readahead invocation and for for btrfs another time for each bio
completion.  Right now this does not increse the number of inodes in
each slab, but for ext4 we are getting very close to that (within
16 bytes by my count).

Changes since v1:
 - reorder to keep the most controversial part last
 - drop moving the open handling to common code (for now)
 - factor the page cache read code into common code
 - reduce the number of hash lookups
 - add a barrier in the fsverity_active that pairs with the cmpxchg
   that sets the inode flag.

Diffstat:
 fs/attr.c                    |   12 ++
 fs/btrfs/btrfs_inode.h       |    4 
 fs/btrfs/extent_io.c         |   37 +++++---
 fs/btrfs/inode.c             |   13 ---
 fs/btrfs/verity.c            |   11 --
 fs/buffer.c                  |   25 ++---
 fs/ext4/ext4.h               |    4 
 fs/ext4/inode.c              |    4 
 fs/ext4/readpage.c           |   31 ++++---
 fs/ext4/super.c              |    4 
 fs/ext4/verity.c             |   34 ++------
 fs/f2fs/compress.c           |    7 -
 fs/f2fs/data.c               |   73 +++++++++++------
 fs/f2fs/f2fs.h               |   12 --
 fs/f2fs/file.c               |    4 
 fs/f2fs/inode.c              |    1 
 fs/f2fs/super.c              |    3 
 fs/f2fs/verity.c             |   34 ++------
 fs/inode.c                   |    9 ++
 fs/verity/Makefile           |    3 
 fs/verity/enable.c           |   39 +++++----
 fs/verity/fsverity_private.h |   19 ++--
 fs/verity/open.c             |   80 ++++++++++---------
 fs/verity/pagecache.c        |   53 ++++++++++++
 fs/verity/read_metadata.c    |   10 +-
 fs/verity/verify.c           |   94 +++++++++++++++-------
 include/linux/fsverity.h     |  180 +++++++++++++++----------------------------
 27 files changed, 422 insertions(+), 378 deletions(-)

^ permalink raw reply	[flat|nested] 54+ messages in thread
* fsverity speedup and memory usage optimization v5
@ 2026-02-02  6:06 Christoph Hellwig
  2026-02-02  6:06 ` [PATCH 07/11] fs: consolidate fsverity_info lookup in buffer.c Christoph Hellwig
  0 siblings, 1 reply; 54+ messages in thread
From: Christoph Hellwig @ 2026-02-02  6:06 UTC (permalink / raw)
  To: Eric Biggers
  Cc: Al Viro, Christian Brauner, Jan Kara, David Sterba,
	Theodore Ts'o, Jaegeuk Kim, Chao Yu, Andrey Albershteyn,
	Matthew Wilcox, linux-fsdevel, linux-btrfs, linux-ext4,
	linux-f2fs-devel, fsverity

Hi all,

this series has a hodge podge of fsverity enhances that I looked into as
part of the review of the xfs fsverity support series.

The first part optimizes the fsverity read path by kicking off readahead
for the fsverity hashes from the data read submission context, which in my
simply testing showed huge benefits for sequential reads using dd.
I haven't been able to get fio to run on a preallocated fio file, but
I expect random read benefits would be significantly better than that
still.

The second part avoids the need for a pointer in every inode for fsverity
and instead uses a rhashtable lookup, which is done once per read_folio
or ->readahead invocation plus for btrfs only for each bio completion.
Right now this does not increse the number of inodes in
each slab, but for ext4 we are getting very close to that (within
16 bytes by my count).

Changes since v5:
 - drop already merged patches
 - fix a bisection hazard for non-ENOENT error returns from
   generic_read_merkle_tree_page
 - don't recurse on invalidate_lock
 - refactor page_cache_ra_unbounded locking to support the above
 - refactor ext4 and f2fs fsverity readahead to remove the need for the
   first_folio branch in the main readpages loop

Changes since v4:
 - drop the constification of ctx->vi again
 - fix __filemap_get_folio error handling again
 - don't use "pgoff_t long"
 - improve documentation of the new pagecache helpers
 - reduce the number of fsverity_info lookups in btrfs
 - improve the documentation for fsverity_active

Changes since v2:
 - use sizeof_field for .key_len
 - fix a rebase error that caused an extra fsverity_get_info in
   fsverity_init_verification_context
 - add verify.o to the build in the correct patch
 - fix handling of non-ENOENT ERR_PTR folios in
   generic_readahead_merkle_tree
 - split fixing the __filemap_get_folio error handling into a
   separate patch
 - fix the readahead range in fsverity_read_merkle_tree
 - remove __fsverity_readahead as a result of the above
 - simplify the start/end_hidx calculation in fsverity_readahead
 - drop the > i_size check in fsverity_readahead
 - use pgoff_t where applicable
 - constify fsverity_info pointers in the verification path
 - use IS_ENABLED to disable code not used for non-fsverity builds in
   ext4 and f2fs
 - allow bisection for non-fsverity builds by provinding a stub
   fsverity_info_addr prototype
 - drop the now superflous inode argument to
   fsverity_init_verification_context
 - improve the kerneldoc for fsverity_readahead
 - improve various commit messages
 - fix the barrier placement in fsverity_active
 - mark fsverity_active to work around stupid compilers

Changes since v1:
 - reorder to keep the most controversial part last
 - drop moving the open handling to common code (for now)
 - factor the page cache read code into common code
 - reduce the number of hash lookups
 - add a barrier in the fsverity_active that pairs with the cmpxchg
   that sets the inode flag.

Diffstat:
 fs/btrfs/btrfs_inode.h       |    4 -
 fs/btrfs/extent_io.c         |   53 ++++++++++------
 fs/btrfs/inode.c             |    3 
 fs/btrfs/verity.c            |    6 -
 fs/buffer.c                  |   25 +++----
 fs/ext4/ext4.h               |    8 --
 fs/ext4/inode.c              |   27 --------
 fs/ext4/readpage.c           |   62 +++++++++++++++----
 fs/ext4/super.c              |    3 
 fs/ext4/verity.c             |   15 +++-
 fs/f2fs/compress.c           |    7 +-
 fs/f2fs/data.c               |   88 +++++++++++++++++----------
 fs/f2fs/f2fs.h               |   12 ---
 fs/f2fs/file.c               |    2 
 fs/f2fs/super.c              |    3 
 fs/f2fs/verity.c             |   15 +++-
 fs/verity/enable.c           |   30 +++++----
 fs/verity/fsverity_private.h |   21 +++---
 fs/verity/open.c             |   77 +++++++++++++++---------
 fs/verity/pagecache.c        |   44 ++++++++++---
 fs/verity/read_metadata.c    |   19 ++++--
 fs/verity/verify.c           |   94 ++++++++++++++++++-----------
 include/linux/fsverity.h     |  136 ++++++++++++++++++++++---------------------
 mm/readahead.c               |   13 ++--
 24 files changed, 440 insertions(+), 327 deletions(-)

^ permalink raw reply	[flat|nested] 54+ messages in thread

end of thread, other threads:[~2026-02-02 13:38 UTC | newest]

Thread overview: 54+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-22  8:21 fsverity cleanups, speedup and memory usage optimization v2 Christoph Hellwig
2026-01-22  8:21 ` [PATCH 01/11] fs,fsverity: reject size changes on fsverity files in setattr_prepare Christoph Hellwig
2026-01-22  9:12   ` Jan Kara
2026-01-22 21:21   ` Darrick J. Wong
2026-01-22  8:21 ` [PATCH 02/11] fs,fsverity: clear out fsverity_info from common code Christoph Hellwig
2026-01-22  9:15   ` Jan Kara
2026-01-22 21:22   ` Darrick J. Wong
2026-01-22  8:21 ` [PATCH 03/11] fsverity: pass struct file to ->write_merkle_tree_block Christoph Hellwig
2026-01-22 10:04   ` Andrey Albershteyn
2026-01-22 21:23   ` Darrick J. Wong
2026-01-22  8:22 ` [PATCH 04/11] fsverity: start consolidating pagecache code Christoph Hellwig
2026-01-22  9:18   ` Jan Kara
2026-01-22 10:12   ` Andrey Albershteyn
2026-01-22 21:27   ` Darrick J. Wong
2026-01-23  5:12     ` Christoph Hellwig
2026-01-23  7:21       ` Darrick J. Wong
2026-01-24 19:27   ` Eric Biggers
2026-01-26  4:27     ` Christoph Hellwig
2026-01-22  8:22 ` [PATCH 05/11] fsverity: kick off hash readahead at data I/O submission time Christoph Hellwig
2026-01-22 21:42   ` Darrick J. Wong
2026-01-23  5:14     ` Christoph Hellwig
2026-01-23  7:22       ` Darrick J. Wong
2026-01-24 20:53   ` Eric Biggers
2026-01-26  4:30     ` Christoph Hellwig
2026-01-22  8:22 ` [PATCH 06/11] fsverity: push out fsverity_info lookup Christoph Hellwig
2026-01-22 21:45   ` Darrick J. Wong
2026-01-24 21:19   ` Eric Biggers
2026-01-26  4:33     ` Christoph Hellwig
2026-01-22  8:22 ` [PATCH 07/11] fs: consolidate fsverity_info lookup in buffer.c Christoph Hellwig
2026-01-22 21:49   ` Darrick J. Wong
2026-01-23  5:15     ` Christoph Hellwig
2026-01-23  7:23       ` Darrick J. Wong
2026-01-23  7:24         ` Christoph Hellwig
2026-01-22  8:22 ` [PATCH 08/11] ext4: consolidate fsverity_info lookup Christoph Hellwig
2026-01-22 21:54   ` Darrick J. Wong
2026-01-23  5:18     ` Christoph Hellwig
2026-01-23  7:25       ` Darrick J. Wong
2026-01-22  8:22 ` [PATCH 09/11] f2fs: " Christoph Hellwig
2026-01-22  8:22 ` [PATCH 10/11] btrfs: " Christoph Hellwig
2026-01-22  8:22 ` [PATCH 11/11] fsverity: use a hashtable to find the fsverity_info Christoph Hellwig
2026-01-22 22:04   ` Darrick J. Wong
2026-01-23  5:27     ` Christoph Hellwig
2026-01-23  7:27       ` Darrick J. Wong
2026-01-23  7:30         ` Christoph Hellwig
2026-01-25  1:31   ` Eric Biggers
2026-01-25 21:48     ` Matthew Wilcox
2026-01-26  4:44       ` Christoph Hellwig
2026-01-26 20:12         ` Eric Biggers
2026-01-28 21:38           ` Matthew Wilcox
2026-01-28 22:14             ` Eric Biggers
2026-01-26  4:43     ` Christoph Hellwig
2026-01-22 15:42 ` fsverity cleanups, speedup and memory usage optimization v2 David Sterba
  -- strict thread matches above, loose matches on Subject: below --
2026-02-02  6:06 fsverity speedup and memory usage optimization v5 Christoph Hellwig
2026-02-02  6:06 ` [PATCH 07/11] fs: consolidate fsverity_info lookup in buffer.c Christoph Hellwig
2026-02-02 13:38   ` Jan Kara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox