Message ID | 20230109051823.480289-3-willy@infradead.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1992121wrt; Sun, 8 Jan 2023 21:50:40 -0800 (PST) X-Google-Smtp-Source: AMrXdXsH39mmRLe57mOcYYSUi0i7Fs7xZJNugpyEk6/7yDQRXqJpJ+8qndKJ6FL249w5LA/A2IOG X-Received: by 2002:aa7:cb4b:0:b0:491:3a5c:6e5 with SMTP id w11-20020aa7cb4b000000b004913a5c06e5mr18015883edt.1.1673243439926; Sun, 08 Jan 2023 21:50:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673243439; cv=none; d=google.com; s=arc-20160816; b=fxXhP8pfNmQWMmyamKCqRUsqM51KM5REgL8/3ejqOwlLT9H+jQpYXyGaeFUgm8RVf7 etwgTnEs9DhAD4PpxiKiA5cOWU3JQbwQD4uQgXkBsg4AZPNY/e3P7wpu8AQ3u2D9cUWC lE+ETRNgv6OR+m4STbj8DtMnwfhEknhqzmA3OKpdw2g8YK90edpgJQpISEhp7Jhjgt89 655NCVKICjaMQJE3zHSTXiougrbnqW7vYoFuH4pSFXWNdPoKhAyiuYMp9Rguapny/T8/ RF+oZFslcqbx4jEceb3zDIlvALv9jTXEW3JFUurUCU6moetnuvsGXYKWvZVj3vb3QB1Q blNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=ka5+iF4ZHGa0/h4sTq7sbQGVl9e8Q3iYzmlIIaQ/sWI=; b=k5PppBLaBLnYhgtzR4CHM3ca2OQ/L+DOVoD4maSYXMCW2NagIO6ds4JDqSMY1gzl1l 6AN+2MkgRq40c33mewuN9sWFNyDlraSMmq5NKETmZRitvCL3DjEVQ3k1itptlAij9Dza hN9ajWc+sOUCnOzwvpJYYhK4w3rGnNg1G24ObAD4qCpWgT54ceG42T5rzmmXvPaALXZz 1vg2RDPdVYCXLQhK+s7xXQDmTMLtsx2ZX1NIFRyXXkA0oh6HaEor+afFfmdsV0QyrVm6 ZnNzqgTFjJUMN+eEFQvoPNrt99pUosycRG38gtJb4slOzsFE6BcMjVW14ydpGfmZjC3L nUVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b="i/qCQROx"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id em8-20020a056402364800b0048ec063ea63si8411176edb.396.2023.01.08.21.50.16; Sun, 08 Jan 2023 21:50:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b="i/qCQROx"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236593AbjAIFTt (ORCPT <rfc822;jian.xie.xdx@gmail.com> + 99 others); Mon, 9 Jan 2023 00:19:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234878AbjAIFSY (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 9 Jan 2023 00:18:24 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D69A6DE80; Sun, 8 Jan 2023 21:18:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=ka5+iF4ZHGa0/h4sTq7sbQGVl9e8Q3iYzmlIIaQ/sWI=; b=i/qCQROxWBGYJBbp7WWwA2/Yvw Dp51Rqs4Jyu0jDo2hlrt+BgXNzbaN0GGMq7jiZbomx7g2Z1moIfQd4S26iD20Wx1lgwxVcVVLJlfB m3oJgbKQ7cxdKfhGyEArj6Pdh/Vavd0nsnL+WwFB9DYdYPvjEMdayAceV2jqlDwDfoc1bB9+8xv/W 2sD8mcl3FP9+WTM0o7s8uiBCj5KapY4EWuMdX7aB0vExNWT2/2+ku+8olFqdDnvPmw9+fspzT718R 3MzT+pW9s1EyjLZYJH8nv6yJcMkiJnMmFZLvaNPl+bbgf4FKlttTj+F+vUdAZFW0YOKrcSrFt4Nfx AQo3heCw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEkYD-0020wp-46; Mon, 09 Jan 2023 05:18:25 +0000 From: "Matthew Wilcox (Oracle)" <willy@infradead.org> Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>, Jeff Layton <jlayton@redhat.com>, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Christoph Hellwig <hch@lst.de> Subject: [PATCH 02/11] filemap: Remove filemap_check_and_keep_errors() Date: Mon, 9 Jan 2023 05:18:14 +0000 Message-Id: <20230109051823.480289-3-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230109051823.480289-1-willy@infradead.org> References: <20230109051823.480289-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754522913234715418?= X-GMAIL-MSGID: =?utf-8?q?1754522913234715418?= |
Series |
Remove AS_EIO and AS_ENOSPC
|
|
Commit Message
Matthew Wilcox
Jan. 9, 2023, 5:18 a.m. UTC
Convert both callers to use the "new" errseq infrastructure.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
mm/filemap.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
Comments
On Mon, 2023-01-09 at 05:18 +0000, Matthew Wilcox (Oracle) wrote: > Convert both callers to use the "new" errseq infrastructure. > > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> > --- > mm/filemap.c | 18 ++++++------------ > 1 file changed, 6 insertions(+), 12 deletions(-) > > diff --git a/mm/filemap.c b/mm/filemap.c > index c4d4ace9cc70..48daedc224d9 100644 > --- a/mm/filemap.c > +++ b/mm/filemap.c > @@ -355,16 +355,6 @@ int filemap_check_errors(struct address_space *mapping) > } > EXPORT_SYMBOL(filemap_check_errors); > > -static int filemap_check_and_keep_errors(struct address_space *mapping) > -{ > - /* Check for outstanding write errors */ > - if (test_bit(AS_EIO, &mapping->flags)) > - return -EIO; > - if (test_bit(AS_ENOSPC, &mapping->flags)) > - return -ENOSPC; > - return 0; > -} > - > /** > * filemap_fdatawrite_wbc - start writeback on mapping dirty pages in range > * @mapping: address space structure to write > @@ -567,8 +557,10 @@ EXPORT_SYMBOL(filemap_fdatawait_range); > int filemap_fdatawait_range_keep_errors(struct address_space *mapping, > loff_t start_byte, loff_t end_byte) > { > + errseq_t since = filemap_sample_wb_err(mapping); > + > __filemap_fdatawait_range(mapping, start_byte, end_byte); > - return filemap_check_and_keep_errors(mapping); > + return filemap_check_wb_err(mapping, since); > } > EXPORT_SYMBOL(filemap_fdatawait_range_keep_errors); I looked at making this sort of change across the board alongside the original wb_err patches, but I backed off at the time. With the above patch, this function will no longer report a writeback error that occurs before the sample. Given that writeback can happen at any time, that seemed like it might be an undesirable change, and I didn't follow through. It is true that the existing flag-based code may miss errors too, if multiple tasks are test_and_clear'ing the bits, but I think the above is even more likely to happen, esp. under memory pressure. To do this right, we probably need to look at these callers and have them track a long-term errseq_t "since" value before they ever dirty the pages, and then continually check-and-advance vs. that. For instance, the main caller of the above function is jbd2. Would it be reasonable to add in a new errseq_t value to the jnode for tracking errors? > > @@ -613,8 +605,10 @@ EXPORT_SYMBOL(file_fdatawait_range); > */ > int filemap_fdatawait_keep_errors(struct address_space *mapping) > { > + errseq_t since = filemap_sample_wb_err(mapping); > + > __filemap_fdatawait_range(mapping, 0, LLONG_MAX); > - return filemap_check_and_keep_errors(mapping); > + return filemap_check_wb_err(mapping, since); > } > EXPORT_SYMBOL(filemap_fdatawait_keep_errors); >
On Mon, Jan 09, 2023 at 08:48:49AM -0500, Jeff Layton wrote: > On Mon, 2023-01-09 at 05:18 +0000, Matthew Wilcox (Oracle) wrote: > > Convert both callers to use the "new" errseq infrastructure. > > I looked at making this sort of change across the board alongside the > original wb_err patches, but I backed off at the time. > > With the above patch, this function will no longer report a writeback > error that occurs before the sample. Given that writeback can happen at > any time, that seemed like it might be an undesirable change, and I > didn't follow through. > > It is true that the existing flag-based code may miss errors too, if > multiple tasks are test_and_clear'ing the bits, but I think the above is > even more likely to happen, esp. under memory pressure. > > To do this right, we probably need to look at these callers and have > them track a long-term errseq_t "since" value before they ever dirty the > pages, and then continually check-and-advance vs. that. > > For instance, the main caller of the above function is jbd2. Would it be > reasonable to add in a new errseq_t value to the jnode for tracking > errors? Doesn't b4678df184b3 address this problem? If nobody has seen the error, we return 0 instead of the current value of wb_err, ensuring that somebody always sees the error.
On Mon, 2023-01-09 at 14:02 +0000, Matthew Wilcox wrote: > On Mon, Jan 09, 2023 at 08:48:49AM -0500, Jeff Layton wrote: > > On Mon, 2023-01-09 at 05:18 +0000, Matthew Wilcox (Oracle) wrote: > > > Convert both callers to use the "new" errseq infrastructure. > > > > I looked at making this sort of change across the board alongside the > > original wb_err patches, but I backed off at the time. > > > > With the above patch, this function will no longer report a writeback > > error that occurs before the sample. Given that writeback can happen at > > any time, that seemed like it might be an undesirable change, and I > > didn't follow through. > > > > It is true that the existing flag-based code may miss errors too, if > > multiple tasks are test_and_clear'ing the bits, but I think the above is > > even more likely to happen, esp. under memory pressure. > > > > To do this right, we probably need to look at these callers and have > > them track a long-term errseq_t "since" value before they ever dirty the > > pages, and then continually check-and-advance vs. that. > > > > For instance, the main caller of the above function is jbd2. Would it be > > reasonable to add in a new errseq_t value to the jnode for tracking > > errors? > > Doesn't b4678df184b3 address this problem? If nobody has seen the > error, we return 0 instead of the current value of wb_err, ensuring > that somebody always sees the error. > I was originally thinking no, but now I think you're correct. We do initialize the "since" value to 0 if an error has never been seen, so that (sort of) emulates the behavior of the existing AS_EIO/AS_ENOSPC flags. It's still not quite as reliable as plumbing a "since" value through all of the callers (particularly in the case where there are multiple waiters), but maybe it's good enough here. I'll look over the rest of the set. Thanks, -- Jeff Layton <jlayton@redhat.com>
On Mon, Jan 09, 2023 at 09:31:00AM -0500, Jeff Layton wrote: > On Mon, 2023-01-09 at 14:02 +0000, Matthew Wilcox wrote: > > On Mon, Jan 09, 2023 at 08:48:49AM -0500, Jeff Layton wrote: > > > On Mon, 2023-01-09 at 05:18 +0000, Matthew Wilcox (Oracle) wrote: > > > > Convert both callers to use the "new" errseq infrastructure. > > > > > > I looked at making this sort of change across the board alongside the > > > original wb_err patches, but I backed off at the time. > > > > > > With the above patch, this function will no longer report a writeback > > > error that occurs before the sample. Given that writeback can happen at > > > any time, that seemed like it might be an undesirable change, and I > > > didn't follow through. > > > > > > It is true that the existing flag-based code may miss errors too, if > > > multiple tasks are test_and_clear'ing the bits, but I think the above is > > > even more likely to happen, esp. under memory pressure. > > > > > > To do this right, we probably need to look at these callers and have > > > them track a long-term errseq_t "since" value before they ever dirty the > > > pages, and then continually check-and-advance vs. that. > > > > > > For instance, the main caller of the above function is jbd2. Would it be > > > reasonable to add in a new errseq_t value to the jnode for tracking > > > errors? > > > > Doesn't b4678df184b3 address this problem? If nobody has seen the > > error, we return 0 instead of the current value of wb_err, ensuring > > that somebody always sees the error. > > > > I was originally thinking no, but now I think you're correct. > > We do initialize the "since" value to 0 if an error has never been seen, > so that (sort of) emulates the behavior of the existing AS_EIO/AS_ENOSPC > flags. > > It's still not quite as reliable as plumbing a "since" value through all > of the callers (particularly in the case where there are multiple > waiters), but maybe it's good enough here. I actually think we may have the opposite problem; that for some of these scenarios, we never mark the error as seen. ie we always end up calling errseq_check() and never errseq_check_and_advance(). So every time we write something, it'll remind us that we have an error.
diff --git a/mm/filemap.c b/mm/filemap.c index c4d4ace9cc70..48daedc224d9 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -355,16 +355,6 @@ int filemap_check_errors(struct address_space *mapping) } EXPORT_SYMBOL(filemap_check_errors); -static int filemap_check_and_keep_errors(struct address_space *mapping) -{ - /* Check for outstanding write errors */ - if (test_bit(AS_EIO, &mapping->flags)) - return -EIO; - if (test_bit(AS_ENOSPC, &mapping->flags)) - return -ENOSPC; - return 0; -} - /** * filemap_fdatawrite_wbc - start writeback on mapping dirty pages in range * @mapping: address space structure to write @@ -567,8 +557,10 @@ EXPORT_SYMBOL(filemap_fdatawait_range); int filemap_fdatawait_range_keep_errors(struct address_space *mapping, loff_t start_byte, loff_t end_byte) { + errseq_t since = filemap_sample_wb_err(mapping); + __filemap_fdatawait_range(mapping, start_byte, end_byte); - return filemap_check_and_keep_errors(mapping); + return filemap_check_wb_err(mapping, since); } EXPORT_SYMBOL(filemap_fdatawait_range_keep_errors); @@ -613,8 +605,10 @@ EXPORT_SYMBOL(file_fdatawait_range); */ int filemap_fdatawait_keep_errors(struct address_space *mapping) { + errseq_t since = filemap_sample_wb_err(mapping); + __filemap_fdatawait_range(mapping, 0, LLONG_MAX); - return filemap_check_and_keep_errors(mapping); + return filemap_check_wb_err(mapping, since); } EXPORT_SYMBOL(filemap_fdatawait_keep_errors);