From patchwork Mon Jan 9 05:18:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13093045 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE515C61DB3 for ; Mon, 9 Jan 2023 05:18:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236362AbjAIFSo (ORCPT ); Mon, 9 Jan 2023 00:18:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234729AbjAIFST (ORCPT ); Mon, 9 Jan 2023 00:18:19 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2C4DDEBB; Sun, 8 Jan 2023 21:18:17 -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=/TboxjvLj2LzaTPo6wOwSPdZqcAQLPCIOhhkOsSnAto=; b=nb4a5StFHAwGzV5DL8zXSWnxJw zX600UOuwgmVsgmjNFBmqtMFxS3xy8oIktPbQkH8TRK7ibTOd9FSpSh760MmC9CNX44HBqsWmi/N/ UDlCxOA7LujBoWs15c9vzwZdsHq5P+N6jwyH3KWvAvYzHO2vlJFU9V1QNqyBGQRrdrZwNcdugBvtP 3zAHtqfRrI9/eo03r3LBI3D0DlE6gp7IrVEkLzTfqFcNiqtxYLZGQs5aDUuOlcHvk31wtghpU8Omp 15oltxC23wFZYvXnu2blmo/TycCTrH3pEYJvW4N4bLOfpWYrtEf0G6ZhxHe1M6ij03Kc3FJ4BHc5S 19VIUrTA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEkYC-0020wm-NL; 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 01/11] memory-failure: Remove comment referencing AS_EIO Date: Mon, 9 Jan 2023 05:18:13 +0000 Message-Id: <20230109051823.480289-2-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 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org The EIO is now reported to every caller which has the file open on the next operation which returns an error. We obviously cannot check whether the user took action correctly on that error, but we can remove this comment as wb_err is never cleared, unlike AS_EIO. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Christoph Hellwig --- mm/memory-failure.c | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index c77a9e37e27e..1a1c66f7e5dd 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -992,34 +992,6 @@ static int me_pagecache_dirty(struct page_state *ps, struct page *p) * who check the mapping. * This way the application knows that something went * wrong with its dirty file data. - * - * There's one open issue: - * - * The EIO will be only reported on the next IO - * operation and then cleared through the IO map. - * Normally Linux has two mechanisms to pass IO error - * first through the AS_EIO flag in the address space - * and then through the PageError flag in the page. - * Since we drop pages on memory failure handling the - * only mechanism open to use is through AS_AIO. - * - * This has the disadvantage that it gets cleared on - * the first operation that returns an error, while - * the PageError bit is more sticky and only cleared - * when the page is reread or dropped. If an - * application assumes it will always get error on - * fsync, but does other operations on the fd before - * and the page is dropped between then the error - * will not be properly reported. - * - * This can already happen even without hwpoisoned - * pages: first on metadata IO errors (which only - * report through AS_EIO) or when the page is dropped - * at the wrong time. - * - * So right now we assume that the application DTRT on - * the first EIO, but we're not worse than other parts - * of the kernel. */ mapping_set_error(mapping, -EIO); } From patchwork Mon Jan 9 05:18:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13093048 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACB40C5479D for ; Mon, 9 Jan 2023 05:19:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236406AbjAIFS6 (ORCPT ); Mon, 9 Jan 2023 00:18:58 -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 ); 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)" Cc: "Matthew Wilcox (Oracle)" , Jeff Layton , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Christoph Hellwig 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 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Convert both callers to use the "new" errseq infrastructure. Signed-off-by: Matthew Wilcox (Oracle) --- 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); @@ -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); From patchwork Mon Jan 9 05:18:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13093047 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4793C5479D for ; Mon, 9 Jan 2023 05:18:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236397AbjAIFSv (ORCPT ); Mon, 9 Jan 2023 00:18:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236122AbjAIFSV (ORCPT ); Mon, 9 Jan 2023 00:18:21 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF662CE16; Sun, 8 Jan 2023 21:18:20 -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=q/yHyMldu60gOBaQs0jTxyPBD38OhQT4AJEanuofTzA=; b=iVygUdYUAJcdSPVDpeLxNQYVjX VZ2eUIAr5Ni+Oq6UGlvHzp4wUhACJQlG+KVRJBJsBYXc1bElntXZ9kqQZPw8xJ1uMo9SviLIzgjB/ 4osnd9cWjUDxrDgHRBs2L3rrTD3u/kTJ9kxjdg1fqA2JTvD1KaonAc6P7HxK2kpd13noRlgtZSdQs /6GV9vYKYJNFilnTeuY/k/DjIGsd5d3k+A24w5+VIhfm31A30b6n0A9heS7y6kXjUPEXgm42wFA6X PuBqeYRiNfeuoD7/Jaiv8zElM3UVQOwf1xBIJNJ7j+aRCqZlyr5dbmR8mGAHAdXVWwd7VTg+FteSH n5LpyBKg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEkYD-0020wr-6J; 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 03/11] f2fs: Convert f2fs_wait_on_node_pages_writeback() to errseq Date: Mon, 9 Jan 2023 05:18:15 +0000 Message-Id: <20230109051823.480289-4-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 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Convert from the old filemap_check_errors() to the errseq infrastructure. This means we will not report any previously-occurring error, and we will not clear any previously-occurring error. Signed-off-by: Matthew Wilcox (Oracle) --- fs/f2fs/node.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index dde4c0458704..a87b5515c681 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -2055,12 +2055,14 @@ int f2fs_sync_node_pages(struct f2fs_sb_info *sbi, int f2fs_wait_on_node_pages_writeback(struct f2fs_sb_info *sbi, unsigned int seq_id) { + struct address_space *mapping = NODE_MAPPING(sbi); struct fsync_node_entry *fn; struct page *page; struct list_head *head = &sbi->fsync_node_list; unsigned long flags; unsigned int cur_seq_id = 0; int ret2, ret = 0; + errseq_t since = filemap_sample_wb_err(mapping); while (seq_id && cur_seq_id < seq_id) { spin_lock_irqsave(&sbi->fsync_node_lock, flags); @@ -2088,7 +2090,7 @@ int f2fs_wait_on_node_pages_writeback(struct f2fs_sb_info *sbi, break; } - ret2 = filemap_check_errors(NODE_MAPPING(sbi)); + ret2 = filemap_check_wb_err(mapping, since); if (!ret) ret = ret2; From patchwork Mon Jan 9 05:18:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13093049 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C8E6C61DB3 for ; Mon, 9 Jan 2023 05:19:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236442AbjAIFTC (ORCPT ); Mon, 9 Jan 2023 00:19:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236277AbjAIFS1 (ORCPT ); Mon, 9 Jan 2023 00:18:27 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D43DECE16; Sun, 8 Jan 2023 21:18:26 -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=h9sfp3qLT5oZoYTMaEr7e7TXlhgkzcAwkjYXoXSr31A=; b=PcO+1hL8pqtTOSY4yjQyps5RAT 8G47NpMFqRsfCTyyb3fqOkD4nZvLhv1r3FVYZrLgN00r1oeN21QCtKgEmFKzGXeWTCrysJbJ5YCil Aen/7Z5sWnYFTkumxQdid4EhfMATxkw91mIj+zVArGyLIan5liKmfdqEW61z3f8VWfKyIhAxEoXFX OFPTEcFDp3LtnC3sMgROMruznAor3rlG093CS6uBuQeVaKkIhsONDXkN5aHoXxKuympj6b484oPaV jgvthhmyZLyRzVTiLrG9W00eMDs0V5nEXE8hsS2ogRU3/wyaoGYP/GTMBu+Za3JZpHnvcsoysOqXm XozSWbbw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEkYD-0020wt-9W; 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 04/11] fuse: Convert fuse_flush() to use file_check_and_advance_wb_err() Date: Mon, 9 Jan 2023 05:18:16 +0000 Message-Id: <20230109051823.480289-5-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 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org As with fsync, use the newer file_check_and_advance_wb_err() instead of filemap_check_errors(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/fuse/file.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 875314ee6f59..7174646ddf09 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -500,11 +500,10 @@ static int fuse_flush(struct file *file, fl_owner_t id) fuse_sync_writes(inode); inode_unlock(inode); - err = filemap_check_errors(file->f_mapping); + err = file_check_and_advance_wb_err(file); if (err) return err; - err = 0; if (fm->fc->no_flush) goto inval_attr_out; 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: 13093038 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 839BBC5479D for ; Mon, 9 Jan 2023 05:18:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235369AbjAIFSU (ORCPT ); Mon, 9 Jan 2023 00:18:20 -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 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 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); From patchwork Mon Jan 9 05:18:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13093040 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78D06C5479D for ; Mon, 9 Jan 2023 05:18:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236181AbjAIFSX (ORCPT ); Mon, 9 Jan 2023 00:18:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234167AbjAIFSS (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 3D669CE17; 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=b0czJbVeNEC59VHM8B9sq3qAwimTZQLD9J+IkbH6tGY=; b=ROGJTN6UntJy+YzsThEJJrxCJi TtVnoQq6up+P0EtHyGjHt6GeNnEoNZZk5bvjdgDBnt5U65teg3i0Q/vxeBhKrad0sQs5iCaUJ9aai hCoVJCKYxDMlWwNLtSUIdhPNwVYFZp7rjLsp1+yMFDTlOZEtR/uM5wKsrSTfHHqwDseBTLtSg1DqX 9fj9xRKQeflkeQLrCnDNMoea62skAbanZyCf2l5+xZAyzuXC4pRHywBj+sm5Z1MGsJ/DbzLeUgH2w RCVS9uE/Mi1NxFEeqnCNUT4mhbmgSj9IAKRM104Ix+jlmWWqNram/pb4oU6K2cN5Lppll1ajraNhZ 0ddXvYzQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEkYD-0020x5-JH; 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 06/11] filemap: Convert filemap_write_and_wait_range() to use errseq Date: Mon, 9 Jan 2023 05:18:18 +0000 Message-Id: <20230109051823.480289-7-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 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Use the errseq APIs to discover writeback errors instead of filemap_check_errors(). This gives us more precise information about whether this writeback generated the error. This will no longer clear errors, so they will be visible to other users, which is what we want. Take this opportunity to de-indent filemap_write_and_wait_range(). Signed-off-by: Matthew Wilcox (Oracle) --- mm/filemap.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 48daedc224d9..c72b2e1140d7 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -659,26 +659,27 @@ EXPORT_SYMBOL_GPL(filemap_range_has_writeback); int filemap_write_and_wait_range(struct address_space *mapping, loff_t lstart, loff_t lend) { - int err = 0, err2; + int err; + errseq_t since; if (lend < lstart) return 0; + if (!mapping_needs_writeback(mapping)) + return 0; - if (mapping_needs_writeback(mapping)) { - err = __filemap_fdatawrite_range(mapping, lstart, lend, - WB_SYNC_ALL); - /* - * Even if the above returned error, the pages may be - * written partially (e.g. -ENOSPC), so we wait for it. - * But the -EIO is special case, it may indicate the worst - * thing (e.g. bug) happened, so we avoid waiting for it. - */ - if (err != -EIO) - __filemap_fdatawait_range(mapping, lstart, lend); - } - err2 = filemap_check_errors(mapping); + since = filemap_sample_wb_err(mapping); + err = __filemap_fdatawrite_range(mapping, lstart, lend, WB_SYNC_ALL); + /* + * Even if the above returned an error, the pages may be written + * partially (e.g. -ENOSPC), so we wait for it. But the -EIO + * is a special case, it may indicate the worst thing (e.g. bug) + * happened, so we avoid waiting for it. + */ + if (err != -EIO) + __filemap_fdatawait_range(mapping, lstart, lend); if (!err) - err = err2; + err = filemap_check_wb_err(mapping, since); + return err; } EXPORT_SYMBOL(filemap_write_and_wait_range); From patchwork Mon Jan 9 05:18:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13093042 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4123C61DB3 for ; Mon, 9 Jan 2023 05:18:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236307AbjAIFS3 (ORCPT ); Mon, 9 Jan 2023 00:18:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234227AbjAIFSS (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 51C8AD127; 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=k+ZZta1I7fiddKSuD0VDKROProxG+mv989F2OQevFVE=; b=DoU3MBHwJXeUVlXpjR6BahDygE rEByLa9Kflz15xo39pKdfYcKiETrJxGAkDDIbdIRjAGz/2E2RS4zEGILLyeqi9+0oACdLFofz2Eyi s6f9m61E66DO+xVmMf8K2EY5OIGT2ttz5Q/c+eaMDstvvR5SvYWv5iL99XYnfo0i+EZw8gogjFn6/ 3CyvkQspNvX+c3ppbQ0JYxfo6J8koDQa9sFSx6I/T6fXMY28OQdYc1E8eM/bKizrOzUkkjPnOplht +UMBnwvIz/lKlPh5NwijUi27DC/U4yD7F7LdoRBlZnWa00pQ/DnconPqvKN98qR+aN5WcURO4Hv27 J0LlnnNg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEkYD-0020xB-Nx; 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 07/11] filemap: Convert filemap_fdatawait_range() to errseq Date: Mon, 9 Jan 2023 05:18:19 +0000 Message-Id: <20230109051823.480289-8-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 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org This removes the unwelcome behaviour of clearing the errors in the address space, which is the same behaviour as filemap_fdatawait_range_keep_errors(), so unify the two functions. We can also get rid of filemap_fdatawait_keep_errors() as it is now the same as filemap_fdatawait() Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/pagemap.h | 7 +++--- mm/filemap.c | 51 +---------------------------------------- 2 files changed, 5 insertions(+), 53 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 29e1f9e76eb6..985fd47739f4 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -33,16 +33,17 @@ int invalidate_inode_pages2_range(struct address_space *mapping, int write_inode_now(struct inode *, int sync); int filemap_fdatawrite(struct address_space *); int filemap_flush(struct address_space *); -int filemap_fdatawait_keep_errors(struct address_space *mapping); int filemap_fdatawait_range(struct address_space *, loff_t lstart, loff_t lend); -int filemap_fdatawait_range_keep_errors(struct address_space *mapping, - loff_t start_byte, loff_t end_byte); static inline int filemap_fdatawait(struct address_space *mapping) { return filemap_fdatawait_range(mapping, 0, LLONG_MAX); } +#define filemap_fdatawait_range_keep_errors(mapping, start, end) \ + filemap_fdatawait_range(mapping, start, end) +#define filemap_fdatawait_keep_errors(mapping) filemap_fdatawait(mapping) + bool filemap_range_has_page(struct address_space *, loff_t lstart, loff_t lend); int filemap_write_and_wait_range(struct address_space *mapping, loff_t lstart, loff_t lend); diff --git a/mm/filemap.c b/mm/filemap.c index c72b2e1140d7..887520db115a 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -526,43 +526,17 @@ static void __filemap_fdatawait_range(struct address_space *mapping, * in the given range and wait for all of them. Check error status of * the address space and return it. * - * Since the error status of the address space is cleared by this function, - * callers are responsible for checking the return value and handling and/or - * reporting the error. - * * Return: error status of the address space. */ int filemap_fdatawait_range(struct address_space *mapping, loff_t start_byte, loff_t end_byte) -{ - __filemap_fdatawait_range(mapping, start_byte, end_byte); - return filemap_check_errors(mapping); -} -EXPORT_SYMBOL(filemap_fdatawait_range); - -/** - * filemap_fdatawait_range_keep_errors - wait for writeback to complete - * @mapping: address space structure to wait for - * @start_byte: offset in bytes where the range starts - * @end_byte: offset in bytes where the range ends (inclusive) - * - * Walk the list of under-writeback pages of the given address space in the - * given range and wait for all of them. Unlike filemap_fdatawait_range(), - * this function does not clear error status of the address space. - * - * Use this function if callers don't handle errors themselves. Expected - * call sites are system-wide / filesystem-wide data flushers: e.g. sync(2), - * fsfreeze(8) - */ -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_wb_err(mapping, since); } -EXPORT_SYMBOL(filemap_fdatawait_range_keep_errors); +EXPORT_SYMBOL(filemap_fdatawait_range); /** * file_fdatawait_range - wait for writeback to complete @@ -589,29 +563,6 @@ int file_fdatawait_range(struct file *file, loff_t start_byte, loff_t end_byte) } EXPORT_SYMBOL(file_fdatawait_range); -/** - * filemap_fdatawait_keep_errors - wait for writeback without clearing errors - * @mapping: address space structure to wait for - * - * Walk the list of under-writeback pages of the given address space - * and wait for all of them. Unlike filemap_fdatawait(), this function - * does not clear error status of the address space. - * - * Use this function if callers don't handle errors themselves. Expected - * call sites are system-wide / filesystem-wide data flushers: e.g. sync(2), - * fsfreeze(8) - * - * Return: error status of the address space. - */ -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_wb_err(mapping, since); -} -EXPORT_SYMBOL(filemap_fdatawait_keep_errors); - /* Returns true if writeback might be needed or already in progress. */ static bool mapping_needs_writeback(struct address_space *mapping) { From patchwork Mon Jan 9 05:18:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13093041 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FE98C677F1 for ; Mon, 9 Jan 2023 05:18:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236213AbjAIFS0 (ORCPT ); Mon, 9 Jan 2023 00:18:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229622AbjAIFSS (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 8E2D1D2C8; 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=UvH9ycUllkHxgh2ZsVpQIK1Y6EVpAeDrvEMZLSZxFIM=; b=LbvKlGSOOBJGYKzPTxzwC51OUM 4pi+Lu0AKUj5674G9a9HGH2avOJVNKMzAho+9kZg1BLmoaQWZGFapak9qevcs5vCNX4cowDhjDTMy fecc/Mp4vTjQxDqsMnH/5D+7oIUueYz/KbNAPa3cSljyAFyidWyyb6gUZ0lx9YaUaNCpo18r76syB DIIOJfRRf+AcFziAPXk8JB5K4EdITspdaBq+l84JN1RdFBkFF+cD7zAqa1vPwm8jweofhVKpcmaFM i137t3ozQkjZdDD9Vrt8EYXLDGZ808AQNdtpYA+unsLNTlfaq9tJjcQ3MUy87+YUWevUMEmHHRCjb WlbLNRRA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEkYD-0020xJ-SI; 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 08/11] cifs: Remove call to filemap_check_wb_err() Date: Mon, 9 Jan 2023 05:18:20 +0000 Message-Id: <20230109051823.480289-9-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 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org filemap_write_and_wait() now calls filemap_check_wb_err(), so we cannot glean any additional information by calling it ourselves. It may also be misleading as it will pick up on any errors since the beginning of time which may well be since before this program opened the file. Signed-off-by: Matthew Wilcox (Oracle) --- fs/cifs/file.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 22dfc1f8b4f1..7e7ee26cf77d 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -3042,14 +3042,12 @@ int cifs_flush(struct file *file, fl_owner_t id) int rc = 0; if (file->f_mode & FMODE_WRITE) - rc = filemap_write_and_wait(inode->i_mapping); + rc = filemap_write_and_wait(file->f_mapping); cifs_dbg(FYI, "Flush inode %p file %p rc %d\n", inode, file, rc); - if (rc) { - /* get more nuanced writeback errors */ - rc = filemap_check_wb_err(file->f_mapping, 0); + if (rc) trace_cifs_flush_err(inode->i_ino, rc); - } + return rc; } From patchwork Mon Jan 9 05:18:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13093043 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9AE94C677F1 for ; Mon, 9 Jan 2023 05:18:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236219AbjAIFSa (ORCPT ); Mon, 9 Jan 2023 00:18:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234347AbjAIFSS (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 9929ED2DC; 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=YLUcsaMTdWzUTPeweatSYOos3qbQs6I0puU7586j9/8=; b=rAzQJTyZjPOc2dWheR771P9Y5N zEFvxTxSDP0E8IpVfF6xp0gNN58oO9Dpqu10uAK0toI8KWtTrYdFheabjxryK47Fc/6XtgZMl/qcK qFHVBKck4DfGAQMCUFkPHaYjIOxCKUezVTuKaQ5SABoD/vTuoEjpfNQOUqxuDHw5k8oDZq+xFcfSl XJl+2VeymGOsq6o/fwSbipUr+VEFYqSYdhM6Eg9Z/n+gV0uwM27qKhuw14Nd2fpbBlbZj6Z0Xvh9O JApINzQ7SNd06B2+cWVk5UY4YnSzbEpF03HpCfFRUUzauiuhQLMORV1XQIxAzasoT5c5qgxAGv65O TUrFVwvQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEkYE-0020xQ-0e; Mon, 09 Jan 2023 05:18:26 +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 09/11] mm: Remove AS_EIO and AS_ENOSPC Date: Mon, 9 Jan 2023 05:18:21 +0000 Message-Id: <20230109051823.480289-10-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 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org All users are now converted to use wb_err, so convert the remaining comments, drop the unused filemap_check_errors() and remove the compatibility code in mapping_set_error() and file_check_and_advance_wb_err(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/btrfs/extent_io.c | 6 +++--- fs/f2fs/data.c | 2 +- include/linux/pagemap.h | 20 +++++--------------- mm/filemap.c | 21 --------------------- 4 files changed, 9 insertions(+), 40 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 9bd32daa9b9a..f1c3572b6a90 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2386,7 +2386,7 @@ static void set_btree_ioerr(struct page *page, struct extent_buffer *eb) * or the content of some node/leaf from a past generation that got * cowed or deleted and is no longer valid. * - * Note: setting AS_EIO/AS_ENOSPC in the btree inode's i_mapping would + * Note: setting wb_err in the btree inode's i_mapping would * not be enough - we need to distinguish between log tree extents vs * non-log tree extents, and the next filemap_fdatawait_range() call * will catch and clear such errors in the mapping - and that call might @@ -2397,10 +2397,10 @@ static void set_btree_ioerr(struct page *page, struct extent_buffer *eb) * set (since it's a runtime flag, not persisted on disk). * * Using the flags below in the btree inode also makes us achieve the - * goal of AS_EIO/AS_ENOSPC when writepages() returns success, started + * goal of wb_err when writepages() returns success, started * writeback for all dirty pages and before filemap_fdatawait_range() * is called, the writeback for all dirty pages had already finished - * with errors - because we were not using AS_EIO/AS_ENOSPC, + * with errors - because we were not using wb_err, * filemap_fdatawait_range() would return success, as it could not know * that writeback errors happened (the pages were no longer tagged for * writeback). diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 97e816590cd9..566fe19ca57d 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2913,7 +2913,7 @@ int f2fs_write_single_data_page(struct page *page, int *submitted, redirty_page_for_writepage(wbc, page); /* * pageout() in MM traslates EAGAIN, so calls handle_write_error() - * -> mapping_set_error() -> set_bit(AS_EIO, ...). + * -> mapping_set_error(). * file_write_and_wait_range() will see EIO error, which is critical * to return value of fsync() followed by atomic_write failure to user. */ diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 985fd47739f4..573b8cce3a85 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -51,7 +51,6 @@ int __filemap_fdatawrite_range(struct address_space *mapping, loff_t start, loff_t end, int sync_mode); int filemap_fdatawrite_range(struct address_space *mapping, loff_t start, loff_t end); -int filemap_check_errors(struct address_space *mapping); void __filemap_set_wb_err(struct address_space *mapping, int err); int filemap_fdatawrite_wbc(struct address_space *mapping, struct writeback_control *wbc); @@ -192,14 +191,11 @@ static inline bool mapping_shrinkable(struct address_space *mapping) * Bits in mapping->flags. */ enum mapping_flags { - AS_EIO = 0, /* IO error on async write */ - AS_ENOSPC = 1, /* ENOSPC on async write */ - AS_MM_ALL_LOCKS = 2, /* under mm_take_all_locks() */ - AS_UNEVICTABLE = 3, /* e.g., ramdisk, SHM_LOCK */ - AS_EXITING = 4, /* final truncate in progress */ - /* writeback related tags are not used */ - AS_NO_WRITEBACK_TAGS = 5, - AS_LARGE_FOLIO_SUPPORT = 6, + AS_MM_ALL_LOCKS = 0, /* under mm_take_all_locks() */ + AS_UNEVICTABLE, /* e.g., ramdisk, SHM_LOCK */ + AS_EXITING, /* final truncate in progress */ + AS_NO_WRITEBACK_TAGS, /* writeback related tags are not used */ + AS_LARGE_FOLIO_SUPPORT, }; /** @@ -227,12 +223,6 @@ static inline void mapping_set_error(struct address_space *mapping, int error) /* Record it in superblock */ if (mapping->host) errseq_set(&mapping->host->i_sb->s_wb_err, error); - - /* Record it in flags for now, for legacy callers */ - if (error == -ENOSPC) - set_bit(AS_ENOSPC, &mapping->flags); - else - set_bit(AS_EIO, &mapping->flags); } static inline void mapping_set_unevictable(struct address_space *mapping) diff --git a/mm/filemap.c b/mm/filemap.c index 887520db115a..7bf8442bcfaa 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -341,20 +341,6 @@ void delete_from_page_cache_batch(struct address_space *mapping, filemap_free_folio(mapping, fbatch->folios[i]); } -int filemap_check_errors(struct address_space *mapping) -{ - int ret = 0; - /* Check for outstanding write errors */ - if (test_bit(AS_ENOSPC, &mapping->flags) && - test_and_clear_bit(AS_ENOSPC, &mapping->flags)) - ret = -ENOSPC; - if (test_bit(AS_EIO, &mapping->flags) && - test_and_clear_bit(AS_EIO, &mapping->flags)) - ret = -EIO; - return ret; -} -EXPORT_SYMBOL(filemap_check_errors); - /** * filemap_fdatawrite_wbc - start writeback on mapping dirty pages in range * @mapping: address space structure to write @@ -684,13 +670,6 @@ int file_check_and_advance_wb_err(struct file *file) spin_unlock(&file->f_lock); } - /* - * We're mostly using this function as a drop in replacement for - * filemap_check_errors. Clear AS_EIO/AS_ENOSPC to emulate the effect - * that the legacy code would have had on these flags. - */ - clear_bit(AS_EIO, &mapping->flags); - clear_bit(AS_ENOSPC, &mapping->flags); return err; } EXPORT_SYMBOL(file_check_and_advance_wb_err); From patchwork Mon Jan 9 05:18:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13093046 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61B55C54EBD for ; Mon, 9 Jan 2023 05:18:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236336AbjAIFSe (ORCPT ); Mon, 9 Jan 2023 00:18:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234366AbjAIFSS (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 CB478DE80; 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=lzB774qlWOGeuLTuMSFQPkmJwRXTwSiLN6M5EhwWaoI=; b=mKbzCktscn6Jx0BP1xTRqukdZF nsrtNLVPeVuRjragXpmoIVeIzgGb0cnGyr1MUaySI1GDPtjn0IbSqa1+ySzdBGWA1S+PzmWo59/+f wH9GGe5EvRbCf1EvX6MwIPKGc6bpARRvARTX+OeC+dTWgQAsx9Pq4h2GNzhFWNOFVSkYkGn9pCgRO P8JFQRh+f9PZko0g5ck1IucaLmdMcqlO3ERpHcWUv0XNcctHTopQkPQOZ3QxjGmbwkUSMj0yMwp31 HxN2gKdn3STEHlZiuf/HEmUJitZ5FijtDNFgXX/ve9HDjDPTWu7ilckbmLKnRpQcSsvi0IiYuJ+8Z ViBPmQCQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEkYE-0020xW-4R; Mon, 09 Jan 2023 05:18:26 +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 10/11] mm: Remove filemap_fdatawait_range_keep_errors() Date: Mon, 9 Jan 2023 05:18:22 +0000 Message-Id: <20230109051823.480289-11-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 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org This function is now the same as filemap_fdatawait_range(), so change both callers to use that instead. Signed-off-by: Matthew Wilcox (Oracle) --- fs/jbd2/commit.c | 12 +++++------- include/linux/pagemap.h | 2 -- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c index 4810438b7856..36aa1b117a50 100644 --- a/fs/jbd2/commit.c +++ b/fs/jbd2/commit.c @@ -221,11 +221,10 @@ EXPORT_SYMBOL(jbd2_submit_inode_data); int jbd2_wait_inode_data(journal_t *journal, struct jbd2_inode *jinode) { if (!jinode || !(jinode->i_flags & JI_WAIT_DATA) || - !jinode->i_vfs_inode || !jinode->i_vfs_inode->i_mapping) + !jinode->i_vfs_inode || !jinode->i_vfs_inode->i_mapping) return 0; - return filemap_fdatawait_range_keep_errors( - jinode->i_vfs_inode->i_mapping, jinode->i_dirty_start, - jinode->i_dirty_end); + return filemap_fdatawait_range(jinode->i_vfs_inode->i_mapping, + jinode->i_dirty_start, jinode->i_dirty_end); } EXPORT_SYMBOL(jbd2_wait_inode_data); @@ -270,9 +269,8 @@ int jbd2_journal_finish_inode_data_buffers(struct jbd2_inode *jinode) { struct address_space *mapping = jinode->i_vfs_inode->i_mapping; - return filemap_fdatawait_range_keep_errors(mapping, - jinode->i_dirty_start, - jinode->i_dirty_end); + return filemap_fdatawait_range(mapping, jinode->i_dirty_start, + jinode->i_dirty_end); } /* diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 573b8cce3a85..7fe2a5ec1c12 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -40,8 +40,6 @@ static inline int filemap_fdatawait(struct address_space *mapping) return filemap_fdatawait_range(mapping, 0, LLONG_MAX); } -#define filemap_fdatawait_range_keep_errors(mapping, start, end) \ - filemap_fdatawait_range(mapping, start, end) #define filemap_fdatawait_keep_errors(mapping) filemap_fdatawait(mapping) bool filemap_range_has_page(struct address_space *, loff_t lstart, loff_t lend); From patchwork Mon Jan 9 05:18:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13093044 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82411C5479D for ; Mon, 9 Jan 2023 05:18:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236276AbjAIFSc (ORCPT ); Mon, 9 Jan 2023 00:18:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234414AbjAIFST (ORCPT ); Mon, 9 Jan 2023 00:18:19 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC210DE9C; 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=vQF/XULxVm6847KaRqQbhdaohxHXi2nEuadxTiR1ZyE=; b=aRa6C07mcL3ngPuqUeUeiq9Ewx ojEY5TSS9TePzq8VcMu5ajWtwn4NiV+m5NNngSAtK9zTzdDs3q90VzpUCMIrSyZGbu7kEiTeRh619 6q3IWbwiybuoZMlQU/vqIim43gIyzhp3Ph8+GVUVj/vWGpTU/+Vxfh6YkJL/frk+TJxlOamIQqcWt IzYn4QhNA4rFF0qJuAkxUWsHMRoGHusUQ/kdpMG6Wvwysl2pFmTgzmP41oczAMhe2Rntw6fQfNV5C y5mvfiSAJm2MwpIQYvhXFRsv37zIzK32GV2QCdxDA5nlXXnWl94CSidw9tcoy3HcxKd6KOir4+OTQ wQw0SzcQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEkYE-0020xc-8n; Mon, 09 Jan 2023 05:18:26 +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 11/11] mm: Remove filemap_fdatawait_keep_errors() Date: Mon, 9 Jan 2023 05:18:23 +0000 Message-Id: <20230109051823.480289-12-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 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org This function is now the same as filemap_fdatawait(), so change all callers to use that instead. Remove the comments which talk about keeping the errors around for other callers as this is now the only behaviour. Signed-off-by: Matthew Wilcox (Oracle) --- block/bdev.c | 8 +------- fs/fs-writeback.c | 7 +------ fs/xfs/scrub/bmap.c | 2 +- include/linux/pagemap.h | 2 -- 4 files changed, 3 insertions(+), 16 deletions(-) diff --git a/block/bdev.c b/block/bdev.c index edc110d90df4..2fae19f0a5c2 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -1053,13 +1053,7 @@ void sync_bdevs(bool wait) if (!atomic_read(&bdev->bd_openers)) { ; /* skip */ } else if (wait) { - /* - * We keep the error status of individual mapping so - * that applications can catch the writeback error using - * fsync(2). See filemap_fdatawait_keep_errors() for - * details. - */ - filemap_fdatawait_keep_errors(inode->i_mapping); + filemap_fdatawait(inode->i_mapping); } else { filemap_fdatawrite(inode->i_mapping); } diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 6fba5a52127b..dc0158125e5d 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -2598,12 +2598,7 @@ static void wait_sb_inodes(struct super_block *sb) spin_unlock(&inode->i_lock); rcu_read_unlock(); - /* - * We keep the error status of individual mapping so that - * applications can catch the writeback error using fsync(2). - * See filemap_fdatawait_keep_errors() for details. - */ - filemap_fdatawait_keep_errors(mapping); + filemap_fdatawait(mapping); cond_resched(); diff --git a/fs/xfs/scrub/bmap.c b/fs/xfs/scrub/bmap.c index d50d0eab196a..8f169047d410 100644 --- a/fs/xfs/scrub/bmap.c +++ b/fs/xfs/scrub/bmap.c @@ -64,7 +64,7 @@ xchk_setup_inode_bmap( */ error = filemap_fdatawrite(mapping); if (!error) - error = filemap_fdatawait_keep_errors(mapping); + error = filemap_fdatawait(mapping); if (error && (error != -ENOSPC && error != -EIO)) goto out; } diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 7fe2a5ec1c12..69190335deb1 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -40,8 +40,6 @@ static inline int filemap_fdatawait(struct address_space *mapping) return filemap_fdatawait_range(mapping, 0, LLONG_MAX); } -#define filemap_fdatawait_keep_errors(mapping) filemap_fdatawait(mapping) - bool filemap_range_has_page(struct address_space *, loff_t lstart, loff_t lend); int filemap_write_and_wait_range(struct address_space *mapping, loff_t lstart, loff_t lend);