fsverity and large folios

Matthew Wilcox
2026-04-06T04:58:45Z

I suspect that fsverity simply doesn't support large folios today.
However, I assume that we'd like to support them someday (eg to support
16KiB block devices on a machine with a 4KiB page size).

To make a move in that direction, I started to convert
->read_markle_tree_page() to ->read_merkle_tree_folio(). But there's
a problem. The Merkle tree is stored at "some offset" from the EOF. And
the knowledge of what offset is particular to the individual filesystem
(or potentially each individual file). That means that we can't hoist
the "folio_file_page(folio, index)" call from the filesystem to the core
code because the core code doesn't know what offset the tree is stored at.

And it's kind of dangerous because calling offset_in_folio(folio,
byte_offset) doesn't work correctly eitheer (it's fine as long as the
Merkle tree starts at some multiple of folio_size() from the base of
the file ... which is a nasty gotcha to stumble across!)

This actually came up for me because fsverity is using PageChecked(),
and it's the last part of the kernel still using PageChecked(). I was
hoping to replace these uses with folio_test/set_checked(), but it all
feels a bit fragile at this point.

I don't have an idea beyond exposing ->verity_metadata_pos() to the
core code from individual filesystems, which feels like poor
architecture. Ideas welcome.