From: Yang Shi <shy828301@gmail.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Jens Axboe <axboe@kernel.dk>, Arnd Bergmann <arnd@arndb.de>,
Ajay Garg <ajaygargnsit@gmail.com>,
Hugh Dickins <hughd@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Linux-MM <linux-mm@kvack.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mm: shmem: do not call PageHWPoison on a ERR-page
Date: Sat, 13 Nov 2021 14:29:52 -0800 [thread overview]
Message-ID: <CAHbLzkp_SGYbjK27-TPajxbKYJDCv==8Oj4TzP6MdTNoBtve0A@mail.gmail.com> (raw)
In-Reply-To: <CAHk-=wh2fa20a-qe+8q8no3_2MD-DokXvKNDhDC6qMJyCTvnPw@mail.gmail.com>
On Sat, Nov 13, 2021 at 12:23 PM Linus Torvalds
<torvalds@linux-foundation.org> wrote:
>
> On Sat, Nov 13, 2021 at 12:16 PM Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
> >
> > Neither of the fixes were sent to me, and honestly, I think the real
> > issue is that the original commit is just too broken for words.
>
> Side note: the one you pointed to (by Ajay), had the comment that it
> could be done differently as an optimization.
>
> And I very much agree with that, although I think it would be a lot
> more than an optimization: just doing
>
> if (error)
> return ERR_PTR(error);
>
> earlier in the function would have avoided the issue entirely, and
> would have made the code a lot easier to read too.
>
> But what made me decide to just revert it entirely was that the
> original commit that caused this all also had stuff like this:
>
> - return shmem_getpage(inode, index, pagep, SGP_WRITE);
> + ret = shmem_getpage(inode, index, pagep, SGP_WRITE);
> +
> + if (*pagep && PageHWPoison(*pagep)) {
> + unlock_page(*pagep);
> + put_page(*pagep);
> + ret = -EIO;
> + }
> +
> + return ret;
>
> which is another example of exactly the same issue: ignoring errors,
> and then acting on other information and creating new errors.
>
> Again, that code should have checked and handled errors first, and
> then - if there wasn't an error - added that new HWpoison handling.
>
> So that just made me go "this is not worth fixing up, this just needs
> re-doing", and thus I just went for the revert instead.
I'm so sorry for the inconvenience.
The above snippet is actually ok since if *pagep returned via
shmem_getpage()'s parameter is not NULL, then ret is 0. When
shmem_getpage() returns error code, *pagep is NULL IIUC. So it
actually doesn't ignore errors then create and return new error.
But I do agree it seems tricky for someone who is not familiar with
shmem code. And if shmem code is changed in the future it may be error
prone. I could rewrite it to:
if (ret < 0)
goto out;
if (*pagep && PageHWPoison(*pagep)) {
unlock_page(*pagep);
put_page(*pagep);
ret = -EIO;
}
out:
return ret;
And fold in Ajay's fix (will take Muchun's version which returns error
earlier). Hopefully it still can make -rc1. Of course rc2 is fine
either.
>
> Linus
next prev parent reply other threads:[~2021-11-13 22:30 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-11 8:46 Ajay Garg
2021-11-11 11:06 ` Muchun Song
2021-11-11 11:40 ` Ajay Garg
2021-11-11 12:11 ` Muchun Song
2021-11-11 12:21 ` Ajay Garg
2021-11-11 13:09 ` Muchun Song
2021-11-11 18:42 ` Yang Shi
2021-11-11 17:45 ` Ajay Garg
2021-11-11 17:59 ` Jens Axboe
2021-11-13 17:21 ` Jens Axboe
2021-11-13 20:16 ` Linus Torvalds
2021-11-13 20:21 ` Jens Axboe
2021-11-13 20:23 ` Linus Torvalds
2021-11-13 22:29 ` Yang Shi [this message]
2021-11-13 22:58 ` Linus Torvalds
2021-11-14 3:10 ` Yang Shi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAHbLzkp_SGYbjK27-TPajxbKYJDCv==8Oj4TzP6MdTNoBtve0A@mail.gmail.com' \
--to=shy828301@gmail.com \
--cc=ajaygargnsit@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=axboe@kernel.dk \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox