Re: [PATCH v6 17/19] iomap: Restructure iomap_readpages_actor

Matthew Wilcox
2020-02-19T05:35:51Z

On Tue, Feb 18, 2020 at 07:17:18PM -0800, John Hubbard wrote:
> > - for (done = 0; done < length; done += ret) {
>
> nit: this "for" loop was perfect just the way it was. :) I'd vote here for reverting
> the change to a "while" loop. Because with this change, now the code has to
> separately initialize "done", separately increment "done", and the beauty of a
> for loop is that the loop init and control is all clearly in one place. For things
> that follow that model (as in this case!), that's a Good Thing.
>
> And I don't see any technical reason (even in the following patch) that requires
> this change.

It's doing the increment in the wrong place. We want the increment done in
the middle of the loop, before we check whether we've got to the end of
the page. Not at the end of the loop.

> > + BUG_ON(ctx.cur_page);
>
> Is a full BUG_ON() definitely called for here? Seems like a WARN might suffice...

Dave made a similar comment; I'll pick this up there.