Re: Any way to ensure minimal folio size and alignment for iomap based direct IO?

Pankaj Raghav (Samsung)
2025-09-15T18:12:39Z

> > But unfortunately I can not find any folio allocation for the direct IO
> > routine except the zero_page...
> >
> > Any clue on the iomap part, or is the btrfs requirement incompatible with
> > iomap in the first place?
>
> It's nothing to do with iomap. We can't make the assumption that
> userspace is using large folios for, eg, anonymous memory. Or if
> the memory is backed by page cache, we can't assume that the file
> that's mmaped is on a similarly-aligned block device.

Just to add to willy's point, XFS did not have this requirement when we
upstreamed block size > page size support. The only thing that XFS does
is to pad the direct I/O with zeroes if I/O was smaller than block size.

Is it very difficult to add multi-shot checksum calls for a data block
in btrfs? Does it break certain reliability guarantees?

Another crazy idea would be to either fall back to buffered I/O if this
condition is not met or allocate a new folio and copy the contents so that
it meets the condition of single large folio that matches the block
size (like we do in bio_copy_user_iov() when we cannot map).

--
Pankaj