Re: Re: [PATCH] fuse: when copying a folio delay the mark dirty until the end

Horst Birthelmer
2026-03-16T20:11:51Z

On Mon, Mar 16, 2026 at 10:29:52AM -0700, Joanne Koong wrote:
> On Mon, Mar 16, 2026 at 8:16 AM Horst Birthelmer <horst@birthelmer.com> wrote:
> >
> > From: Horst Birthelmer <hbirthelmer@ddn.com>
> >
> > Doing set_page_dirty_lock() for every page is inefficient
> > for large folios.
> > When copying a folio (and with large folios enabled,
> > this can be many pages) we can delay the marking dirty
> > and flush_dcache_page() until the whole folio is handled
> > and do it once per folio instead of once per page.
> >
> > Signed-off-by: Horst Birthelmer <hbirthelmer@ddn.com>
> > ---
> > Currently when doing a folio copy
> > flush_dcache_page(cs->pg) and set_page_dirty_lock(cs->pg)
> > are called for every page.
> >
> > We can do this at the end for the whole folio.
>
> Hi Horst,
>
> I think these are two different entities. cs->pg is the page that
> corresponds to the userspace buffer / pipe while the (large) folio
> corresponds to the pages in the page cache. flush_dcache_folio(folio)
> and flush_dcache_page(cs->pg) are not interchangeable (I don't think
> it's likely either that the pages backing the userspace buffer/pipe
> are large folios).
>
> Thanks,
> Joanne

Hi Joanne,

I feel a bit embarassed ... but you are completely right.
I was interested in solving this case:

fuse_uring_args_to_ring() or fuse_uring_args_to_ring_pages()
fuse_copy_init(&cs, true, &iter) ← cs->write = TRUE
fuse_copy_args(&cs, num_args, args->in_pages, ...)
if (args->in_pages)
fuse_copy_folios(cs, arg->size, 0)
fuse_copy_folio(cs, &ap->folios[i], ...)

when we have large folios

But those are not the same.

Thanks,
Horst