Skip to content

Commit 2d83ed6

Browse files
adam900710kdave
authored andcommitted
btrfs: return any hit error from extent_writepage_io()
Since the support of bs < ps support, extent_writepage_io() will submit multiple blocks inside the folio. But if we hit error submitting one sector, but the next sector can still be submitted successfully, the function extent_writepage_io() will still return 0. This will make btrfs to silently ignore the error without setting error flag for the filemap. Fix it by recording the first error hit, and always return that value. Fixes: 8bf334b ("btrfs: fix double accounting race when extent_writepage_io() failed") Reviewed-by: Daniel Vacek <neelx@suse.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 5afe85b commit 2d83ed6

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

fs/btrfs/extent_io.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,7 +1679,7 @@ static noinline_for_stack int extent_writepage_io(struct btrfs_inode *inode,
16791679
struct btrfs_fs_info *fs_info = inode->root->fs_info;
16801680
unsigned long range_bitmap = 0;
16811681
bool submitted_io = false;
1682-
bool error = false;
1682+
int found_error = 0;
16831683
const u64 folio_start = folio_pos(folio);
16841684
const unsigned int blocks_per_folio = btrfs_blocks_per_folio(fs_info, folio);
16851685
u64 cur;
@@ -1743,7 +1743,8 @@ static noinline_for_stack int extent_writepage_io(struct btrfs_inode *inode,
17431743
*/
17441744
btrfs_mark_ordered_io_finished(inode, folio, cur,
17451745
fs_info->sectorsize, false);
1746-
error = true;
1746+
if (!found_error)
1747+
found_error = ret;
17471748
continue;
17481749
}
17491750
submitted_io = true;
@@ -1760,11 +1761,11 @@ static noinline_for_stack int extent_writepage_io(struct btrfs_inode *inode,
17601761
* If we hit any error, the corresponding sector will have its dirty
17611762
* flag cleared and writeback finished, thus no need to handle the error case.
17621763
*/
1763-
if (!submitted_io && !error) {
1764+
if (!submitted_io && !found_error) {
17641765
btrfs_folio_set_writeback(fs_info, folio, start, len);
17651766
btrfs_folio_clear_writeback(fs_info, folio, start, len);
17661767
}
1767-
return ret;
1768+
return found_error;
17681769
}
17691770

17701771
/*

0 commit comments

Comments
 (0)