Commit 37e51a76 authored by Jeff Layton's avatar Jeff Layton

mm: clean up error handling in write_one_page

Don't try to check PageError since that's potentially racy and not
necessarily going to be set after writepage errors out.

Instead, check the mapping for an error after writepage returns. That
should also help us detect errors that occurred if the VM tried to
clean the page earlier due to memory pressure.
Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
parent 11ab8319
...@@ -2371,9 +2371,8 @@ int do_writepages(struct address_space *mapping, struct writeback_control *wbc) ...@@ -2371,9 +2371,8 @@ int do_writepages(struct address_space *mapping, struct writeback_control *wbc)
* *
* The page must be locked by the caller and will be unlocked upon return. * The page must be locked by the caller and will be unlocked upon return.
* *
* write_one_page() returns a negative error code if I/O failed. Note that * Note that the mapping's AS_EIO/AS_ENOSPC flags will be cleared when this
* the address_space is not marked for error. The caller must do this if * function returns.
* needed.
*/ */
int write_one_page(struct page *page) int write_one_page(struct page *page)
{ {
...@@ -2391,15 +2390,15 @@ int write_one_page(struct page *page) ...@@ -2391,15 +2390,15 @@ int write_one_page(struct page *page)
if (clear_page_dirty_for_io(page)) { if (clear_page_dirty_for_io(page)) {
get_page(page); get_page(page);
ret = mapping->a_ops->writepage(page, &wbc); ret = mapping->a_ops->writepage(page, &wbc);
if (ret == 0) { if (ret == 0)
wait_on_page_writeback(page); wait_on_page_writeback(page);
if (PageError(page))
ret = -EIO;
}
put_page(page); put_page(page);
} else { } else {
unlock_page(page); unlock_page(page);
} }
if (!ret)
ret = filemap_check_errors(mapping);
return ret; return ret;
} }
EXPORT_SYMBOL(write_one_page); EXPORT_SYMBOL(write_one_page);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment