mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-09 23:00:21 +00:00
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.com Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> Reviewed-by: Muchun Song <songmuchun@bytedance.com> Cc: Matthew Wilcox <willy@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
7f82f92231
commit
ccac11da67
18
mm/filemap.c
18
mm/filemap.c
@ -667,7 +667,7 @@ EXPORT_SYMBOL_GPL(filemap_range_has_writeback);
|
||||
int filemap_write_and_wait_range(struct address_space *mapping,
|
||||
loff_t lstart, loff_t lend)
|
||||
{
|
||||
int err = 0;
|
||||
int err = 0, err2;
|
||||
|
||||
if (mapping_needs_writeback(mapping)) {
|
||||
err = __filemap_fdatawrite_range(mapping, lstart, lend,
|
||||
@ -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
|
||||
* thing (e.g. bug) happened, so we avoid waiting for it.
|
||||
*/
|
||||
if (err != -EIO) {
|
||||
int err2 = filemap_fdatawait_range(mapping,
|
||||
lstart, lend);
|
||||
if (!err)
|
||||
err = err2;
|
||||
} else {
|
||||
/* Clear any previously stored errors */
|
||||
filemap_check_errors(mapping);
|
||||
}
|
||||
} else {
|
||||
err = filemap_check_errors(mapping);
|
||||
if (err != -EIO)
|
||||
__filemap_fdatawait_range(mapping, lstart, lend);
|
||||
}
|
||||
err2 = filemap_check_errors(mapping);
|
||||
if (!err)
|
||||
err = err2;
|
||||
return err;
|
||||
}
|
||||
EXPORT_SYMBOL(filemap_write_and_wait_range);
|
||||
|
Loading…
x
Reference in New Issue
Block a user