@@ -4141,7 +4141,6 @@ int extent_writepages(struct address_space *mapping,
struct writeback_control *wbc)
{
int ret = 0;
- int flush_ret;
struct extent_page_data epd = {
.bio = NULL,
.tree = &BTRFS_I(mapping->host)->io_tree,
@@ -4150,8 +4149,12 @@ int extent_writepages(struct address_space *mapping,
};
ret = extent_write_cache_pages(mapping, wbc, &epd);
- flush_ret = flush_write_bio(&epd);
- BUG_ON(flush_ret < 0);
+ ASSERT(ret <= 0);
+ if (ret < 0) {
+ end_write_bio(&epd, ret);
+ return ret;
+ }
+ ret = flush_write_bio(&epd);
return ret;
}
Do proper cleanup if we hit any error in extent_writepages(), and check the return value of flush_write_bio(). Signed-off-by: Qu Wenruo <wqu@suse.com> --- fs/btrfs/extent_io.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)