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

From: Christoph Hellwig
Date: Wed Nov 03 2021 - 11:54:59 EST


On Tue, Nov 02, 2021 at 08:28:02PM +0000, Matthew Wilcox wrote:
> On Tue, Nov 02, 2021 at 12:26:42AM -0700, Christoph Hellwig wrote:
> > Looking at the code not part of the context this looks fine. But I
> > really wonder if this (and also the blocks change above) would be
> > better off being split into separate, clearly documented patches.
>
> How do these three patches look? I retained your R-b on all three since
> I figured the one you offered below was good for all of them.

Sounds good, and the patches looks good. Minor nitpicks below:

> Rename end_offset to end_pos and file_offset to pos to match the
> rest of the file. Simplify the loop by calculating nblocks
> up front instead of each time around the loop.

Might be worth mentioning why it changes the types from u64 to loff_t.

> /*
> - * Walk through the page to find areas to write back. If we run off the
> - * end of the current map or find the current map invalid, grab a new
> - * one.
> + * Walk through the folio to find areas to write back. If we
> + * run off the end of the current map or find the current map
> + * invalid, grab a new one.

No real need for reflowing the comment, it still fits just fine even
with the folio change.

> Rename end_offset to end_pos and offset_into_page to poff to match the
> rest of the file. Simplify the handling of the last page straddling
> i_size.

... by doing the EOF check purely based on the byte granularity i_size
instead of converting to a pgoff prematurely.

> + isize = i_size_read(inode);
> + end_pos = page_offset(page) + PAGE_SIZE;
> + if (end_pos - 1 >= isize) {

Wouldn't this check be more obvious as:

if (end_pos > i_size) {