Commit 5380311f authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David Sterba

btrfs: simplify the error handling in __extent_writepage_io

Remove the has_error and saved_ret variables, and just jump to a goto
label for error handling from the only place returning an error from the
main loop.
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 55173337
......@@ -1502,10 +1502,8 @@ static noinline_for_stack int __extent_writepage_io(struct btrfs_inode *inode,
u64 extent_offset;
u64 block_start;
struct extent_map *em;
int saved_ret = 0;
int ret = 0;
int nr = 0;
bool has_error = false;
bool compressed;
ret = btrfs_writepage_cow_fixup(page);
......@@ -1556,10 +1554,7 @@ static noinline_for_stack int __extent_writepage_io(struct btrfs_inode *inode,
if (IS_ERR(em)) {
btrfs_page_set_error(fs_info, page, cur, end - cur + 1);
ret = PTR_ERR_OR_ZERO(em);
has_error = true;
if (!saved_ret)
saved_ret = ret;
break;
goto out_error;
}
extent_offset = cur - em->start;
......@@ -1613,18 +1608,19 @@ static noinline_for_stack int __extent_writepage_io(struct btrfs_inode *inode,
submit_extent_page(bio_ctrl, disk_bytenr, page, iosize,
cur - page_offset(page));
ret = 0;
cur += iosize;
nr++;
}
btrfs_page_assert_not_dirty(fs_info, page);
*nr_ret = nr;
return 0;
out_error:
/*
* If we finish without problem, we should not only clear page dirty,
* but also empty subpage dirty bits
*/
if (!has_error)
btrfs_page_assert_not_dirty(fs_info, page);
else
ret = saved_ret;
*nr_ret = nr;
return ret;
}
......
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