Re: [PATCH v2 19/23] xfs: disable direct read path for fs-verity sealed files

Eric Biggers
2023-04-05T18:03:50Z

On Wed, Apr 05, 2023 at 08:50:10AM -0700, Christoph Hellwig wrote:
> On Wed, Apr 05, 2023 at 08:09:27AM -0700, Darrick J. Wong wrote:
> > Thinking about this a little more -- I suppose we shouldn't just go
> > breaking directio reads from a verity file if we can help it. Is there
> > a way to ask fsverity to perform its validation against some arbitrary
> > memory buffer that happens to be fs-block aligned?

You could certainly add such a function that wraps around verify_data_block().
The minimal function prototype needed (without supporting readahead or reusing
the ahash_request) would be something like the following, I think:

bool fsverity_verify_blocks_dio(struct inode *inode, u64 pos,
struct folio *folio,
size_t len, size_t offset);

And I really hope that you don't want to do DIO to the *Merkle tree*, as that
would make the problem significantly harder. I think DIO for the data, but
handling the Merkle tree in the usual way, would be okay?

>
> That would be my preference as well. But maybe Eric know a good reason
> why this hasn't been done yet.
>

I believe it would be possible, especially if DIO to the Merkle tree is not in
scope. There just hasn't been a reason to the work yet. And ext4 and f2fs
already fall back to buffer I/O for other filesystem features, so there was
precedent for not bothering with DIO, at least in the initial version.

- Eric