lkml.org 
[lkml]   [2023]   [Jan]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 06/11] filemap: Convert filemap_write_and_wait_range() to use errseq
Date
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@infradead.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
\
 
 \ /
  Last update: 2023-03-26 23:32    [W:0.141 / U:1.360 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site