diff mbox series

[05/11] page-writeback: Convert folio_write_one() to use an errseq

Message ID 20230109051823.480289-6-willy@infradead.org (mailing list archive)
State New, archived
Headers show
Series Remove AS_EIO and AS_ENOSPC | expand

Commit Message

Matthew Wilcox (Oracle) Jan. 9, 2023, 5:18 a.m. UTC
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) <willy@infradead.org>
---
 mm/page-writeback.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
diff mbox series

Patch

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);