Re: [PATCH 14/17] iomap: make buffered writes work with RWF_UNCACHED

Darrick J. Wong
2024-12-12T06:26:42Z

On Wed, Dec 11, 2024 at 09:50:19PM -0800, Christoph Hellwig wrote:
> On Thu, Nov 14, 2024 at 08:25:18AM -0700, Jens Axboe wrote:
> > + if (iocb->ki_flags & IOCB_UNCACHED)
> > + iter.flags |= IOMAP_UNCACHED;
> >
> > - while ((ret = iomap_iter(&iter, ops)) > 0)
> > + while ((ret = iomap_iter(&iter, ops)) > 0) {
> > + if (iocb->ki_flags & IOCB_UNCACHED)
> > + iter.iomap.flags |= IOMAP_F_UNCACHED;
>
> iomap.flags and the IOMAP_F_* namespace is used to communicate flags
> from the file system to the iomap core, so this looks wrong.

Not entirely true -- IOMAP_F_SIZE_CHANGED is used to communicate state
from iomap to gfs2, and IOMAP_F_STALE is set/checked only by the iomap
core. iomap.h even says as much.

Though given that there's a 4-byte gap in struct iomap between flags and
the bdev pointer (at least on 64-bit) maybe we should make a separate
field for these iomap state bits?

> > size_t poff = offset_in_folio(folio, pos);
> > int error;
> >
> > + if (folio_test_uncached(folio))
> > + wpc->iomap.flags |= IOMAP_F_UNCACHED;
>
> I guess this is what actually makes it work. Note that with the iomap
> zoned series I posted yesteday things change a bit here in that the flags
> in the wpc are decouple from the iomap flags, and this would now become
> a wpc only flag as it isn't really a fs to iomap cummunication, but
> based on iomap / page cache state.

Hrmmm I'll go take a second look at that patch in the morning in case a
better idea comes along.

--D