From patchwork Mon Jan 9 05:18:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 40661 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1984638wrt; Sun, 8 Jan 2023 21:18:47 -0800 (PST) X-Google-Smtp-Source: AMrXdXuHG+gZxVvXkSe0pLRRDdvPIb3rQ68z6AsnbrgK2eBWZt4pIUCFa2FTfcWepfDw4K1FbOgi X-Received: by 2002:a05:6402:3608:b0:495:b002:4ba2 with SMTP id el8-20020a056402360800b00495b0024ba2mr11117080edb.3.1673241527455; Sun, 08 Jan 2023 21:18:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673241527; cv=none; d=google.com; s=arc-20160816; b=YoDsSCGdidp98yk42LaFKn2qhPKJzge/QGGzJ1TbwNZxDPHKn7or5fNMwEj7NZgh47 Xje6cl956V6vylpbzLHxcz5GDyzAw281ql9/F5OGWrf1t1sTwn7GeKstKtiSyx+22wtz BODFGKD0b8aY2wKcuMNImjPLdBzBd2qxz4Y6xvZhXBCbpfBHWzWg5VSMqbMOsPRXqjvo Xxityk/mBIfc20XIQIBhEiN2VAAmjMjqaSbpXBXK61NzmvQbuBqyTFRscalaSce0QSbH bfDF/ebaUU9bYZbS+ZdTLx/2/0EghYFadNqxj16JcEvuBKbPuwt4DrhKgGOzdReYk8mv IRcA== 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=20JVe/q5nqvxBF2DQBmPeH9KaV31rTvIVcnyqDD6QmU=; b=pegOrabsNf/NbyMHF3psjq+Va8TYRMR0YAYCrNLaTETfiPw1RIyiceS2tBeggy5+Yq CtEJGhREOzM8qfTJXip7wiUVCVCR0HkVk1E9onyeJNjZZhGwJxYzIiN/JbbPznLaTW+V 9y/Mp4aXb+G0g/a7e/KNCKzGHTpimoOTlXpla13FfZTW9xYAcJ34JbAsneQUqUi0KcuV u4lPaj3TJdp8s7L24WbBjzJ9pWFuv3P1qFnwXCGSXUbDjm7vd9wBcpQV0mxcC+7A6e8L jRv2a9k69np6Y1WviqxMzvX/jILwtfIHk9x7OLjuZM/6dxEy+UhZ4ttw5BqcN4lzuJIq W0Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=tx0zFFcH; 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 g14-20020a056402090e00b0048721e1b62csi9750335edz.613.2023.01.08.21.18.23; Sun, 08 Jan 2023 21:18:47 -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=tx0zFFcH; 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 S236042AbjAIFSV (ORCPT + 99 others); Mon, 9 Jan 2023 00:18:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231135AbjAIFSS (ORCPT ); Mon, 9 Jan 2023 00:18:18 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CEEACE16; Sun, 8 Jan 2023 21:18:15 -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=20JVe/q5nqvxBF2DQBmPeH9KaV31rTvIVcnyqDD6QmU=; b=tx0zFFcHpu3W2ppNLSOI9B5Sz+ xd91xrR9fMh4Z6dRVmSBn0jkXtna1ZZDZn0uFhvE6MiSIlY8+hIE0Lrio1bwW+2uWiaiMwb/Wpsd6 zJ8jSC2IElx3hY6ACHIcBjHn5xFGDTdpUCYWPxzpWl+sZ3GaZrI8u759dIKXifFdjiQM8gCO3a2nD JiCbF9/p1SucWAF0/taqy5CyWt3rpIpVpekZy0IdnRdWprkiL8MqmcxZn2XHNo1NIrzvk9pui+NL5 TK+MByXCi2QINbqO4iSHVv7NTJS/A9pOe9xQJ+MR5d0PJly663FCWwH722+gI7EaL+Ab+Hdq4zj07 OEHsN6BA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEkYD-0020wy-CL; Mon, 09 Jan 2023 05:18:25 +0000 From: "Matthew Wilcox (Oracle)" Cc: "Matthew Wilcox (Oracle)" , Jeff Layton , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Christoph Hellwig Subject: [PATCH 05/11] page-writeback: Convert folio_write_one() to use an errseq Date: Mon, 9 Jan 2023 05:18:17 +0000 Message-Id: <20230109051823.480289-6-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 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754520908201564350?= X-GMAIL-MSGID: =?utf-8?q?1754520908201564350?= Use the errseq infrastructure to detect an error due to writing back this folio instead of the old error checking code. Signed-off-by: Matthew Wilcox (Oracle) --- mm/page-writeback.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index ad608ef2a243..491b70dad994 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2610,15 +2610,12 @@ int do_writepages(struct address_space *mapping, struct writeback_control *wbc) * * The folio must be locked by the caller and will be unlocked upon return. * - * Note that the mapping's AS_EIO/AS_ENOSPC flags will be cleared when this - * function returns. - * * Return: %0 on success, negative error code otherwise */ int folio_write_one(struct folio *folio) { struct address_space *mapping = folio->mapping; - int ret = 0; + int err = 0; struct writeback_control wbc = { .sync_mode = WB_SYNC_ALL, .nr_to_write = folio_nr_pages(folio), @@ -2629,18 +2626,20 @@ int folio_write_one(struct folio *folio) folio_wait_writeback(folio); if (folio_clear_dirty_for_io(folio)) { + errseq_t since = filemap_sample_wb_err(mapping); + folio_get(folio); - ret = mapping->a_ops->writepage(&folio->page, &wbc); - if (ret == 0) + err = mapping->a_ops->writepage(&folio->page, &wbc); + if (!err) { folio_wait_writeback(folio); + err = filemap_check_wb_err(mapping, since); + } folio_put(folio); } else { folio_unlock(folio); } - if (!ret) - ret = filemap_check_errors(mapping); - return ret; + return err; } EXPORT_SYMBOL(folio_write_one);