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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx>
---
 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);
 
-- 
2.35.1




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux