Skip to contentSkip to conversation

Btrfs: fix btrfs_update_reserved_bytes usage

PATCH New Josef Bacik 1 participant 1 message Jun 7, 2011 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Btrfs: fix btrfs_update_reserved_bytes usage

For some reason btrfs_update_reserved_bytes was only ever updating the bytes_reserved counter of the space info if the space info was data. I assume this is because the original enospc stuff used bytes_reserved to account for space reserved for enospc accounting, but now that we're using bytes_may_use thats incorrect. So this patch fixes btrfs_update_reserved_bytes to always update the space_info as well. Also it fixes a weird case where we tried to add the space to the enospc accounting stuff. Rather than doing that just add it back to the space info and then it can be accounted for later. Thanks,

---
 fs/btrfs/ctree.h            |    2 +-
 fs/btrfs/extent-tree.c      |   76 ++++++++++++------------------------------
 fs/btrfs/free-space-cache.c |    4 +-
 3 files changed, 25 insertions(+), 57 deletions(-)
fs/btrfs/ctree.h +1 -1
index 93a409f..0c62c6c 100644
@@ -2177,7 +2177,7 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans,
 
 int btrfs_free_reserved_extent(struct btrfs_root *root, u64 start, u64 len);
 int btrfs_update_reserved_bytes(struct btrfs_block_group_cache *cache,
-				u64 num_bytes, int reserve, int sinfo);
+				u64 num_bytes, int reserve);
 int btrfs_prepare_extent_commit(struct btrfs_trans_handle *trans,
 				struct btrfs_root *root);
 int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans,
fs/btrfs/extent-tree.c +22 -54

115 lines not on this page · raw message

fs/btrfs/free-space-cache.c +2 -2
index 38f3fd9..c97fa7e 100644
@@ -2511,7 +2511,7 @@ int btrfs_trim_block_group(struct btrfs_block_group_cache *block_group,
 		if (bytes >= minlen) {
 			int update_ret;
 			update_ret = btrfs_update_reserved_bytes(block_group,
-								 bytes, 1, 1);
+								 bytes, 1);
 
 			ret = btrfs_error_discard_extent(fs_info->extent_root,
 							 start,
@@ -2521,7 +2521,7 @@ int btrfs_trim_block_group(struct btrfs_block_group_cache *block_group,
 			btrfs_add_free_space(block_group, start, bytes);
 			if (!update_ret)
 				btrfs_update_reserved_bytes(block_group,
-							    bytes, 0, 1);
+							    bytes, 0);
 
 			if (ret)
 				break;
Signature · 1 line
1.7.2.3