Re: [PATCH 18/21] iomap: Convert iomap_add_to_ioend to take a folio

Matthew Wilcox
2021-11-04T03:44:28Z

On Wed, Nov 03, 2021 at 09:00:57AM -0700, Darrick J. Wong wrote:
> > - wpc->ops->discard_folio(page_folio(page), file_offset);
> > + wpc->ops->discard_folio(folio, pos);
>
> /me wonders why this wouldn't have been done in whichever patch added
> folio as a local variable, but fmeh, the end result is the same:

Found it and fixed it.

> > @@ -1474,17 +1474,15 @@ iomap_do_writepage(struct page *page, struct writeback_control *wbc, void *data)
> > * memory is zeroed when mapped, and writes to that region are
> > * not written out to the file."
> > */
> > - zero_user_segment(page, poff, PAGE_SIZE);
> > -
> > - /* Adjust the end_offset to the end of file */
> > + zero_user_segment(&folio->page, poff, folio_size(folio));
>
> Question: is &folio->page != page here? I guess the idea is that we
> have a (potentially multi-page) folio straddling i_size, and we need to
> zero everything in the whole folio after i_size. But then why not pass
> the whole folio?

Ugh, thanks. You made me realise that zero_user_segments() is still
conditional on CONFIG_TRANSPARENT_HUGEPAGE. It's a relic of when I
was going to do all of this with THP; before I switched to the folio
mental model.

So now we're going to get folio_zero_segments(), folio_zero_segment()
and folio_zero_range().