Btrfs: unreserve space if our ordered extent fails to work
When a transaction aborts or there's an EIO on an ordered extent or any error really we will not free up the space we reserved for this ordered extent. This results in warnings from the block group cache cleanup in the case of a transaction abort, or leaking space in the case of EIO on an ordered extent. Fix this up by free'ing the reserved space if we have an error at all trying to complete an ordered extent. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com>
This commit is contained in:
parent
779880ef35
commit
0bec9ef525
|
@ -2022,11 +2022,23 @@ out:
|
||||||
if (trans)
|
if (trans)
|
||||||
btrfs_end_transaction(trans, root);
|
btrfs_end_transaction(trans, root);
|
||||||
|
|
||||||
if (ret)
|
if (ret) {
|
||||||
clear_extent_uptodate(io_tree, ordered_extent->file_offset,
|
clear_extent_uptodate(io_tree, ordered_extent->file_offset,
|
||||||
ordered_extent->file_offset +
|
ordered_extent->file_offset +
|
||||||
ordered_extent->len - 1, NULL, GFP_NOFS);
|
ordered_extent->len - 1, NULL, GFP_NOFS);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the ordered extent had an IOERR or something else went
|
||||||
|
* wrong we need to return the space for this ordered extent
|
||||||
|
* back to the allocator.
|
||||||
|
*/
|
||||||
|
if (!test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags) &&
|
||||||
|
!test_bit(BTRFS_ORDERED_PREALLOC, &ordered_extent->flags))
|
||||||
|
btrfs_free_reserved_extent(root, ordered_extent->start,
|
||||||
|
ordered_extent->disk_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This needs to be done to make sure anybody waiting knows we are done
|
* This needs to be done to make sure anybody waiting knows we are done
|
||||||
* updating everything for this ordered extent.
|
* updating everything for this ordered extent.
|
||||||
|
|
Loading…
Reference in New Issue