Re: [PATCH] Fix mpage_writepage() for pages with buffers

From: Matthew Wilcox
Date: Wed Oct 11 2017 - 11:40:23 EST


On Tue, Oct 10, 2017 at 01:31:44PM -0700, Linus Torvalds wrote:
> On Tue, Oct 10, 2017 at 12:44 PM, Andrew Morton
> <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
> >
> > This is all pretty mature code (isn't it?). Any idea why this bug
> > popped up now?

I have no idea why it's suddenly popped up. It looks like it should
be a bohrbug, but it's actually a heisenbug, and I don't understand
that either.

> Also, while the patch looks sane, the
>
> clean_buffers(page, PAGE_SIZE);
>
> line really threw me. That's an insane value to pick, it looks like
> "bytes in page", but it isn't. It's just a random value that is bigger
> than "PAGE_SIZE >> SECTOR_SHIFT".
>
> I'd prefer to see just ~0u if the intention is just "bigger than
> anything possible".

Actually, I did choose it to be "number of bytes in the page", based on
the reasoning that I didn't want to calculate what the actual block size
was, and the block size surely couldn't be any smaller than one byte. I
forgot about the SECTOR_SIZE limit on filesystem block size, so your
spelling of "big enough" does look better.

Now that I think about it some more, I suppose we might end up with a
situation where we're eventually passing a hugepage to this routine,
and futureproofing it with ~0U probably makes more sense.