aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fusionio.com>2013-01-31 14:58:00 -0500
committerJosef Bacik <jbacik@fusionio.com>2013-02-20 12:59:29 -0500
commit0bec9ef525e33233d7739b71be83bb78746f6e94 (patch)
tree0cc7a1074c0611758b459b776ae0474e8278874a /fs/btrfs/inode.c
parent779880ef35b60ac82eed1dcaec6db5b34a170df8 (diff)
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>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 82c7c66f8523..2b48d2d51d50 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2022,11 +2022,23 @@ out:
2022 if (trans) 2022 if (trans)
2023 btrfs_end_transaction(trans, root); 2023 btrfs_end_transaction(trans, root);
2024 2024
2025 if (ret) 2025 if (ret) {
2026 clear_extent_uptodate(io_tree, ordered_extent->file_offset, 2026 clear_extent_uptodate(io_tree, ordered_extent->file_offset,
2027 ordered_extent->file_offset + 2027 ordered_extent->file_offset +
2028 ordered_extent->len - 1, NULL, GFP_NOFS); 2028 ordered_extent->len - 1, NULL, GFP_NOFS);
2029 2029
2030 /*
2031 * If the ordered extent had an IOERR or something else went
2032 * wrong we need to return the space for this ordered extent
2033 * back to the allocator.
2034 */
2035 if (!test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags) &&
2036 !test_bit(BTRFS_ORDERED_PREALLOC, &ordered_extent->flags))
2037 btrfs_free_reserved_extent(root, ordered_extent->start,
2038 ordered_extent->disk_len);
2039 }
2040
2041
2030 /* 2042 /*
2031 * This needs to be done to make sure anybody waiting knows we are done 2043 * This needs to be done to make sure anybody waiting knows we are done
2032 * updating everything for this ordered extent. 2044 * updating everything for this ordered extent.