[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230109051823.480289-7-willy@infradead.org>
Date: Mon, 9 Jan 2023 05:18:18 +0000
From: "Matthew Wilcox (Oracle)" <willy@...radead.org>
To: unlisted-recipients:; (no To-header on input)
Cc: "Matthew Wilcox (Oracle)" <willy@...radead.org>,
Jeff Layton <jlayton@...hat.com>,
linux-fsdevel@...r.kernel.org, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, Christoph Hellwig <hch@....de>
Subject: [PATCH 06/11] filemap: Convert filemap_write_and_wait_range() to use errseq
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) <willy@...radead.org>
---
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);
--
2.35.1
Powered by blists - more mailing lists