[09/11] mm: Remove AS_EIO and AS_ENOSPC

Message ID 20230109051823.480289-10-willy@infradead.org
State New
Headers
Series Remove AS_EIO and AS_ENOSPC |

Commit Message

Matthew Wilcox Jan. 9, 2023, 5:18 a.m. UTC
  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) <willy@infradead.org>
---
 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(-)
  

Patch

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