Skip to content

Commit 0607eb1

Browse files
fdmananakdave
authored andcommitted
Btrfs: fix missing error return if writeback for extent buffer never started
If lock_extent_buffer_for_io() fails, it returns a negative value, but its caller btree_write_cache_pages() ignores such error. This means that a call to flush_write_bio(), from lock_extent_buffer_for_io(), might have failed. We should make btree_write_cache_pages() notice such error values and stop immediatelly, making sure filemap_fdatawrite_range() returns an error to the transaction commit path. A failure from flush_write_bio() should also result in the endio callback end_bio_extent_buffer_writepage() being invoked, which sets the BTRFS_FS_*_ERR bits appropriately, so that there's no risk a transaction or log commit doesn't catch a writeback failure. Reviewed-by: Josef Bacik <[email protected]> Signed-off-by: Filipe Manana <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent eb5b64f commit 0607eb1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

fs/btrfs/extent_io.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3978,6 +3978,10 @@ int btree_write_cache_pages(struct address_space *mapping,
39783978
if (!ret) {
39793979
free_extent_buffer(eb);
39803980
continue;
3981+
} else if (ret < 0) {
3982+
done = 1;
3983+
free_extent_buffer(eb);
3984+
break;
39813985
}
39823986

39833987
ret = write_one_eb(eb, wbc, &epd);

0 commit comments

Comments
 (0)