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