Skip to content

Commit cd26d53

Browse files
fdmananagregkh
authored andcommitted
Btrfs: fix btrfs_wait_ordered_range() so that it waits for all ordered extents
commit e75fd33 upstream. 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]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 4d886f9 commit cd26d53

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
@@ -712,10 +712,15 @@ int btrfs_wait_ordered_range(struct inode *inode, u64 start, u64 len)
712712
}
713713
btrfs_start_ordered_extent(inode, ordered, 1);
714714
end = ordered->file_offset;
715+
/*
716+
* If the ordered extent had an error save the error but don't
717+
* exit without waiting first for all other ordered extents in
718+
* the range to complete.
719+
*/
715720
if (test_bit(BTRFS_ORDERED_IOERR, &ordered->flags))
716721
ret = -EIO;
717722
btrfs_put_ordered_extent(ordered);
718-
if (ret || end == 0 || end == start)
723+
if (end == 0 || end == start)
719724
break;
720725
end--;
721726
}

0 commit comments

Comments
 (0)