Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1139030ybl; Sat, 17 Aug 2019 20:02:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqwBchMDHhqCJF5Fhi+v5QlKHwIktlqPpbAl5xEhIxr5goxUYOb0Paq2h1Zq9VH2OytOTkNc X-Received: by 2002:a62:3887:: with SMTP id f129mr13630995pfa.245.1566097347275; Sat, 17 Aug 2019 20:02:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566097347; cv=none; d=google.com; s=arc-20160816; b=0ZK86MAgCvL/22XyGAUvNG/LAglwzF1l9PbBBKOrMZo5qN6sCqC3MG1hHOamAzysMg vMEueWKYJE8XYHSFYrNJ24uE489HSm5QKlPKczEmUx5G47IiNwuT1IMq2Wg1+me6js0t d97SybEzhRock9leyAGDjqn93mw+MyA7Z4w+QErKIPdZoKIj9w/l5igSE/qeH8Xwu3fj v5HXtNKlftAYFLnUCnXlDWElvo2cMjqutfQiimBxWenqJc3G/kczPirdKioF22kNcdIN Im+ZXyHDDznwek/rCBtnGxu/A38UFPa73n6gZ6+kueGKg9pd/dNs9eTKrZjQqP19RhHB +gRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=I4C6rCQzwDF8szQde73gehM1EeR+FLkMDXAWM2PWei0=; b=WabzZB2SvRvHnAJsTMhaeXHnLxzisk4NIAELg9nLNXOA4ZXQ2mj0RPooDhoIa9Hfnm 6kfw20YfkkrjbXeP3eSh8uqsKASCdkrcG+TXq1tzNrK6CI66ECAeeMvVNqs/aOpVQCRs 5Gh9bkMPFxlm6Iwo1MfH9EchbIqyLlZxWSZ28c5Qx0m1SBleaPFw6HtO58FF5NNsuQ23 bzKrBSJu4dY5VOVJQrBqPrqCwKUYG2uJTQ5SEah5em8T7JY+6wW4jfFRqbVkb5BM2xlU z4fow7FWvFbnwRMofaHQoYejF0fj9QDxWJimgc/C92938tlE5AQBcg0Rxv8zUo6+5eQI HBBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aol.com header.s=a2048 header.b=LIeaEYsc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=aol.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r10si7071810pgs.474.2019.08.17.20.02.11; Sat, 17 Aug 2019 20:02:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@aol.com header.s=a2048 header.b=LIeaEYsc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=aol.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726416AbfHRDBW (ORCPT + 99 others); Sat, 17 Aug 2019 23:01:22 -0400 Received: from sonic314-21.consmr.mail.gq1.yahoo.com ([98.137.69.84]:35641 "EHLO sonic314-21.consmr.mail.gq1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726097AbfHRDBW (ORCPT ); Sat, 17 Aug 2019 23:01:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1566097281; bh=I4C6rCQzwDF8szQde73gehM1EeR+FLkMDXAWM2PWei0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From:Subject; b=LIeaEYsczsqtRf493QsS5KzQsZg1T9VF0F1j0fYENqYOc/REzKc+saTP3doZjsZ07TqlentmL2Sy63QiG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DCG_kECBprd1ekeDLz49EUol2GC7N1yU0dNaEDlyys g24e33ZxljD_YT3EUzTDyt6z9GKHSa1dUZHqYpA5U5JwXdjGMtxxyOuQrfsBFVm7jwp3ExjnDeDD nRCgaA7w8qQn6JqkBN1jj3Tm8FWWj9eLLNNeVhtqTAUvvtHMQuGO2qBOye8kXan6wBaOrePilxF9 JWZDgSEeclN8q0FitALbDqYHkSWTPmllFSfAtLFu_GMAZQLCWxL3czRWBNd6Cxqtlg_d43s3SIIr QMDk3cOz9uPIO6kWkDpdc1GVfbYLG6T73w5_7V1.Zzxn02wGvKYJNGBjRf4c9.3.ete6b0GYR6RZ lS9Gq8YZfTIiVqe.0ZAwjbC7MET3w0rrjOaqZz30MV_Zajd0dOMb1djHNpJguEfggpkp9LVPyPko x8AeHh2Jly1W0xq3WAqRHankPneXNgYTk7Qj.TIWBnVhfpBszlob_iC1KNHVnaMt7BzD_TTte26G 2EhAjWG9b_6WuiescpSbAiJa04.qVAr8TZnY- Received: from sonic.gate.mail.ne1.yahoo.com by sonic314.consmr.mail.gq1.yahoo.com with HTTP; Sun, 18 Aug 2019 03:01:21 +0000 Received: by smtp424.mail.gq1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 67844616e4907afc199d186c2f61c1e0; Sun, 18 Aug 2019 03:01:19 +0000 (UTC) Date: Sun, 18 Aug 2019 11:01:10 +0800 From: Gao Xiang To: Matthew Wilcox Cc: Chao Yu , Richard Weinberger , Greg Kroah-Hartman , devel@driverdev.osuosl.org, linux-fsdevel@vger.kernel.org, LKML , linux-erofs@lists.ozlabs.org, Chao Yu , Miao Xie , Fang Wei , Gao Xiang , stable@vger.kernel.org Subject: Re: [PATCH v2] staging: erofs: fix an error handling in erofs_readdir() Message-ID: <20190818030109.GA8225@hsiangkao-HP-ZHAN-66-Pro-G1> References: <20190818014835.5874-1-hsiangkao@aol.com> <20190818015631.6982-1-hsiangkao@aol.com> <20190818022055.GA14592@bombadil.infradead.org> <20190818023240.GA7739@hsiangkao-HP-ZHAN-66-Pro-G1> <20190818025339.GB14592@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190818025339.GB14592@bombadil.infradead.org> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Aug 17, 2019 at 07:53:39PM -0700, Matthew Wilcox wrote: > On Sun, Aug 18, 2019 at 10:32:45AM +0800, Gao Xiang wrote: > > On Sat, Aug 17, 2019 at 07:20:55PM -0700, Matthew Wilcox wrote: > > > On Sun, Aug 18, 2019 at 09:56:31AM +0800, Gao Xiang wrote: > > > > @@ -82,8 +82,12 @@ static int erofs_readdir(struct file *f, struct dir_context *ctx) > > > > unsigned int nameoff, maxsize; > > > > > > > > dentry_page = read_mapping_page(mapping, i, NULL); > > > > - if (IS_ERR(dentry_page)) > > > > - continue; > > > > + if (IS_ERR(dentry_page)) { > > > > + errln("fail to readdir of logical block %u of nid %llu", > > > > + i, EROFS_V(dir)->nid); > > > > + err = PTR_ERR(dentry_page); > > > > + break; > > > > > > I don't think you want to use the errno that came back from > > > read_mapping_page() (which is, I think, always going to be -EIO). > > > Rather you want -EFSCORRUPTED, at least if I understand the recent > > > patches to ext2/ext4/f2fs/xfs/... > > > > Thanks for your reply and noticing this. :) > > > > Yes, as I talked with you about read_mapping_page() in a xfs related > > topic earlier, I think I fully understand what returns here. > > > > I actually had some concern about that before sending out this patch. > > You know the status is > > PG_uptodate is not set and PG_error is set here. > > > > But we cannot know it is actually a disk read error or due to > > corrupted images (due to lack of page flags or some status, and > > I think it could be a waste of page structure space for such > > corrupted image or disk error)... > > > > And some people also like propagate errors from insiders... > > (and they could argue about err = -EFSCORRUPTED as well..) > > > > I'd like hear your suggestion about this after my words above? > > still return -EFSCORRUPTED? > > I don't think it matters whether it's due to a disk error or a corrupted > image. We can't read the directory entry, so we should probably return > -EFSCORRUPTED. Thinking about it some more, read_mapping_page() can > also return -ENOMEM, so it should probably look something like this: OK, I will send the next version like what you described below. I realized that at first but I have no tendency to return EFSCORRUPTED or EIO here. Thanks, Gao Xiang > > err = 0; > if (dentry_page == ERR_PTR(-ENOMEM)) > err = -ENOMEM; > else if (IS_ERR(dentry_page)) { > errln("fail to readdir of logical block %u of nid %llu", > i, EROFS_V(dir)->nid); > err = -EFSCORRUPTED; > } > > if (err) > break;