Re: [LSF/MM/BPF TOPIC] File system checksum offload

Qu Wenruo
2025-02-03T08:36:24Z

在 2025/2/3 19:00, hch@infradead.org 写道:
> On Mon, Feb 03, 2025 at 08:26:33AM +0000, Matthew Wilcox wrote:
>> so this is a block layer issue if it's not set.
>
> And even if the flag is set direct I/O ignores it. So while passing
> through such a flag through virtio might be useful we need to eventually
> sort out the fact that direct I/O doesn't respect it.

The example I mentioned is just an easy-to-reproduce example, there are
even worse cases, like multi-thread workload where one is doing direct
IO, the other one is modifying the buffer.

So passing AS_STABLE_WRITES is only a solution for the specific case I
mentioned, not a generic solution at all.

But I would still appreciate any movement to expose that flag to virtio-blk.

>
> Locking up any thread touching memory under direct I/O might be quite
> heavy handed, so this means bounce buffering on page fault. We had
> plenty of discussion of this before, but I don't think anyone actually
> looked into implementing it.
>

Thus my current plan to fix it is to make btrfs to skip csum for direct IO.
This will make btrfs to align with EXT4/XFS behavior, without the
complex AS_STABLE_FLAGS passing (and there is no way for user space to
probe that flag IIRC).

But that will break the current per-inode level NODATASUM setting, and
will cause some incompatibility (a new incompat flag needed, extra
handling if no data csum found, extra fsck support etc).

Thanks,
Qu