Commit ccac11da authored by Miaohe Lin's avatar Miaohe Lin Committed by akpm

filemap: minor cleanup for filemap_write_and_wait_range

Restructure the logic in filemap_write_and_wait_range to simplify the code
and make it more consistent with file_write_and_wait_range. No functional
change intended.

Link: https://lkml.kernel.org/r/20220627132351.55680-1-linmiaohe@huawei.comSigned-off-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
Reviewed-by: default avatarMuchun Song <songmuchun@bytedance.com>
Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 7f82f922
...@@ -667,7 +667,7 @@ EXPORT_SYMBOL_GPL(filemap_range_has_writeback); ...@@ -667,7 +667,7 @@ EXPORT_SYMBOL_GPL(filemap_range_has_writeback);
int filemap_write_and_wait_range(struct address_space *mapping, int filemap_write_and_wait_range(struct address_space *mapping,
loff_t lstart, loff_t lend) loff_t lstart, loff_t lend)
{ {
int err = 0; int err = 0, err2;
if (mapping_needs_writeback(mapping)) { if (mapping_needs_writeback(mapping)) {
err = __filemap_fdatawrite_range(mapping, lstart, lend, err = __filemap_fdatawrite_range(mapping, lstart, lend,
...@@ -678,18 +678,12 @@ int filemap_write_and_wait_range(struct address_space *mapping, ...@@ -678,18 +678,12 @@ int filemap_write_and_wait_range(struct address_space *mapping,
* But the -EIO is special case, it may indicate the worst * But the -EIO is special case, it may indicate the worst
* thing (e.g. bug) happened, so we avoid waiting for it. * thing (e.g. bug) happened, so we avoid waiting for it.
*/ */
if (err != -EIO) { if (err != -EIO)
int err2 = filemap_fdatawait_range(mapping, __filemap_fdatawait_range(mapping, lstart, lend);
lstart, lend);
if (!err)
err = err2;
} else {
/* Clear any previously stored errors */
filemap_check_errors(mapping);
}
} else {
err = filemap_check_errors(mapping);
} }
err2 = filemap_check_errors(mapping);
if (!err)
err = err2;
return err; return err;
} }
EXPORT_SYMBOL(filemap_write_and_wait_range); EXPORT_SYMBOL(filemap_write_and_wait_range);
......
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