Re: [PATCH 08/11] ext4: consolidate fsverity_info lookup

Christoph Hellwig
2026-01-23T05:18:40Z

On Thu, Jan 22, 2026 at 01:54:57PM -0800, Darrick J. Wong wrote:
> > + if (folio->index <
> > + DIV_ROUND_UP(inode->i_size, PAGE_SIZE))
>
> I keep seeing this predicate, maybe it should go into fsverity.h as a
> helper function with the comment about mmap that I was muttering about
> in the previous patch?

Right now it is not generic. Nothing in the generic fsverity code
known about the offset, ext4 and f2fs just happened to chose the
same constant (and the ext4 one leak to buffer.c), while btrfs stores
the verity hashed totally differently. I hope the xfs works ends up
with a consolidated way of doing this, at which point such a helper
would be useful.

> Or maybe a "get verity info for given folio index" helper?

How would that make sense?

> /*
> * Grab the fsverity context needed to verify the contents of the folio.
> *
> *
> */
> static inline struct fsverity_info *vi
> fsverity_folio_info(const struct folio *folio)
> {
> struct inode *inode = folio->mapping->host;
>
> if (folio->index < DIV_ROUND_UP(inode->i_size, PAGE_SIZE))
> return fsverity_get_info(inode);
> return NULL;
> }

Tthe offset right now is entirely file system specific,
so we can't do this. Maybe that'll change with further consolidation.