From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E05ABC433F5 for ; Sat, 13 Nov 2021 22:30:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 49FE8610FE for ; Sat, 13 Nov 2021 22:30:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 49FE8610FE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 5BFFE6B0073; Sat, 13 Nov 2021 17:30:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5700C6B0078; Sat, 13 Nov 2021 17:30:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 410E96B007B; Sat, 13 Nov 2021 17:30:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0102.hostedemail.com [216.40.44.102]) by kanga.kvack.org (Postfix) with ESMTP id 334CF6B0073 for ; Sat, 13 Nov 2021 17:30:06 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id D0C4182DB5 for ; Sat, 13 Nov 2021 22:30:05 +0000 (UTC) X-FDA: 78805351170.17.9248918 Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) by imf06.hostedemail.com (Postfix) with ESMTP id 6D6A1801AB04 for ; Sat, 13 Nov 2021 22:30:05 +0000 (UTC) Received: by mail-ed1-f46.google.com with SMTP id x15so53412593edv.1 for ; Sat, 13 Nov 2021 14:30:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=t/8BrQDY4QMPS2nacboOjM/lCVglZ4d38pfjPWfMGuM=; b=hRjv9mmmDbyoeVA0CMPq5xGs+wSrdWBsg0EdyTC7L4UHamhN+U905uFl9m9eU7xE4V 13854VR2dwJZXLtuUsGJglkXqe7TAY3ixO5TImJDWuQJpNizD68bzfAVDF5AWAao2wTD hVZshSaSZ+y31GFTuProMSv2mpvAgl95tNnLDbwqMifZS8luwe7WxFE0SuPpD7dIDXmv Zy0IlEXxWdIrGVywmeokT/mjF6RqIbg3tYoWsYl9vKKTcjYVCM1PUCwg/8uBVJby605l STMKw2kEh81zbOV7OlAwhWW6geZNJho8z8NDOHHkZLMaM/tldFppntaBYjkgEDkCGoWx Rp8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=t/8BrQDY4QMPS2nacboOjM/lCVglZ4d38pfjPWfMGuM=; b=EQSzrguMzl05tQuH1KPZiKMHP5VKz/4Je2BtipLSFr4dUqDsI6Mqza66kT+rgnr7wI suCD0/PSIxg89QHdGre4lu58hanfBqNhYHQm1lGJHo3nSh1ipXKMSI0sB3r4CqLR8LEG Rtj2s9LBoyqwOtqk1zLbj/9ZUksGIsffAPm5BAfNNvk3IOwr9JE4nSwCksuJazmcJMNK Mo0fn9Wc2u/jr/20xKbdD/HpfGyBQjdPPlRVXRCYXMP5mZhJ7yKJXdgodOEQHd5vVYFX HO2Jfp63JMwf9AOsxeJd0TCd5922U5oXaaQGWjfCPde+D1Y/Kkx4fPoXLN+YViNq25dL tdpQ== X-Gm-Message-State: AOAM533f/wVmQjxv2WsdDtb8Da9wA+mZqZutmZG2cUOZQksA4EdDbgEY oCgS504esSXv6vYkWFun2FsgsBPLUOkiTzaO1S4= X-Google-Smtp-Source: ABdhPJyvx1/28UPunkTlxeYgNt5OytWgywAl/h+fgA7lZGzRxdW80lotD3MlVdRcykABhWG9zIukrCu8dBJ2egLaPf8= X-Received: by 2002:a17:907:dab:: with SMTP id go43mr30941491ejc.537.1636842604012; Sat, 13 Nov 2021 14:30:04 -0800 (PST) MIME-Version: 1.0 References: <20211111084617.6746-1-ajaygargnsit@gmail.com> <628a49dc-f6f7-5aa4-8a4d-4f2ed19b7f3f@kernel.dk> In-Reply-To: From: Yang Shi Date: Sat, 13 Nov 2021 14:29:52 -0800 Message-ID: Subject: Re: [PATCH] mm: shmem: do not call PageHWPoison on a ERR-page To: Linus Torvalds Cc: Jens Axboe , Arnd Bergmann , Ajay Garg , Hugh Dickins , Andrew Morton , Linux-MM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 6D6A1801AB04 X-Stat-Signature: np18pipibekcm6qgts99xapa8b45ngxo Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=hRjv9mmm; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf06.hostedemail.com: domain of shy828301@gmail.com designates 209.85.208.46 as permitted sender) smtp.mailfrom=shy828301@gmail.com X-HE-Tag: 1636842605-4020 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sat, Nov 13, 2021 at 12:23 PM Linus Torvalds wrote: > > On Sat, Nov 13, 2021 at 12:16 PM Linus Torvalds > 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