Skip to content

Commit e75fd33

Browse files
fdmananakdave
authored andcommitted
Btrfs: fix btrfs_wait_ordered_range() so that it waits for all ordered extents
In btrfs_wait_ordered_range() once we find an ordered extent that has finished with an error we exit the loop and don't wait for any other ordered extents that might be still in progress. All the users of btrfs_wait_ordered_range() expect that there are no more ordered extents in progress after that function returns. So past fixes such like the ones from the two following commits: ff612ba ("btrfs: fix panic during relocation after ENOSPC before writeback happens") 28aeeac ("Btrfs: fix panic when starting bg cache writeout after IO error") don't work when there are multiple ordered extents in the range. Fix that by making btrfs_wait_ordered_range() wait for all ordered extents even after it finds one that had an error. Link: kdave/btrfs-progs#228 (comment) CC: [email protected] # 4.4+ Reviewed-by: Qu Wenruo <[email protected]> Reviewed-by: Josef Bacik <[email protected]> Signed-off-by: Filipe Manana <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent b778cf9 commit e75fd33

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

fs/btrfs/ordered-data.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,10 +679,15 @@ int btrfs_wait_ordered_range(struct inode *inode, u64 start, u64 len)
679679
}
680680
btrfs_start_ordered_extent(inode, ordered, 1);
681681
end = ordered->file_offset;
682+
/*
683+
* If the ordered extent had an error save the error but don't
684+
* exit without waiting first for all other ordered extents in
685+
* the range to complete.
686+
*/
682687
if (test_bit(BTRFS_ORDERED_IOERR, &ordered->flags))
683688
ret = -EIO;
684689
btrfs_put_ordered_extent(ordered);
685-
if (ret || end == 0 || end == start)
690+
if (end == 0 || end == start)
686691
break;
687692
end--;
688693
}

0 commit comments

Comments
 (0)