Commit 8e1f065b authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Darrick J. Wong

xfs: refactor the tail of xfs_writepage_map

Rejuggle how we deal with the different error vs non-error and have
ioends vs not have ioend cases to keep the fast path streamlined, and
the duplicate code at a minimum.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent 1b65d3dd
...@@ -854,7 +854,14 @@ xfs_writepage_map( ...@@ -854,7 +854,14 @@ xfs_writepage_map(
* submission of outstanding ioends on the writepage context so they are * submission of outstanding ioends on the writepage context so they are
* treated correctly on error. * treated correctly on error.
*/ */
if (count) { if (unlikely(error)) {
if (!count) {
xfs_aops_discard_page(page);
ClearPageUptodate(page);
unlock_page(page);
goto done;
}
/* /*
* If the page was not fully cleaned, we need to ensure that the * If the page was not fully cleaned, we need to ensure that the
* higher layers come back to it correctly. That means we need * higher layers come back to it correctly. That means we need
...@@ -863,12 +870,12 @@ xfs_writepage_map( ...@@ -863,12 +870,12 @@ xfs_writepage_map(
* so another attempt to write this page in this writeback sweep * so another attempt to write this page in this writeback sweep
* will be made. * will be made.
*/ */
if (error) {
set_page_writeback_keepwrite(page); set_page_writeback_keepwrite(page);
} else { } else {
clear_page_dirty_for_io(page); clear_page_dirty_for_io(page);
set_page_writeback(page); set_page_writeback(page);
} }
unlock_page(page); unlock_page(page);
/* /*
...@@ -884,22 +891,14 @@ xfs_writepage_map( ...@@ -884,22 +891,14 @@ xfs_writepage_map(
if (error2 && !error) if (error2 && !error)
error = error2; error = error2;
} }
} else if (error) {
xfs_aops_discard_page(page);
ClearPageUptodate(page);
unlock_page(page);
} else {
/* /*
* We can end up here with no error and nothing to write if we * We can end up here with no error and nothing to write if we race with
* race with a partial page truncate on a sub-page block sized * a partial page truncate on a sub-page block sized filesystem.
* filesystem. In that case we need to mark the page clean.
*/ */
clear_page_dirty_for_io(page); if (!count)
set_page_writeback(page);
unlock_page(page);
end_page_writeback(page); end_page_writeback(page);
} done:
mapping_set_error(page->mapping, error); mapping_set_error(page->mapping, error);
return error; return error;
} }
......
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