aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/volumes.c
diff options
context:
space:
mode:
authorMiao Xie <miaox@cn.fujitsu.com>2014-09-03 09:35:37 -0400
committerChris Mason <clm@fb.com>2014-09-17 16:38:37 -0400
commit1c1161870c8bcb0d966ebbf1aec05a87a79a4175 (patch)
treeaf397f11a4cf07440999efb3ccac8d435346b619 /fs/btrfs/volumes.c
parent43530c46cc55cf5a381e788276a93c83cbc95e46 (diff)
Btrfs: update free_chunk_space during allocting a new chunk
We should update free_chunk_space in time when we allocate a new chunk, not when we deal with the pending device update and block group insertion, because we need the real free_chunk_space data to calculate the reserved space, if we don't update it in time, we would consider the disk space which has be allocated as free space, and would use it to do overcommit reservation. Fix it. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r--fs/btrfs/volumes.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 45e0b5d0f6dd..d8e4a3d1ad89 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -4432,6 +4432,11 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
4432 for (i = 0; i < map->num_stripes; i++) 4432 for (i = 0; i < map->num_stripes; i++)
4433 map->stripes[i].dev->bytes_used += stripe_size; 4433 map->stripes[i].dev->bytes_used += stripe_size;
4434 4434
4435 spin_lock(&extent_root->fs_info->free_chunk_lock);
4436 extent_root->fs_info->free_chunk_space -= (stripe_size *
4437 map->num_stripes);
4438 spin_unlock(&extent_root->fs_info->free_chunk_lock);
4439
4435 free_extent_map(em); 4440 free_extent_map(em);
4436 check_raid56_incompat_flag(extent_root->fs_info, type); 4441 check_raid56_incompat_flag(extent_root->fs_info, type);
4437 4442
@@ -4515,11 +4520,6 @@ int btrfs_finish_chunk_alloc(struct btrfs_trans_handle *trans,
4515 goto out; 4520 goto out;
4516 } 4521 }
4517 4522
4518 spin_lock(&extent_root->fs_info->free_chunk_lock);
4519 extent_root->fs_info->free_chunk_space -= (stripe_size *
4520 map->num_stripes);
4521 spin_unlock(&extent_root->fs_info->free_chunk_lock);
4522
4523 stripe = &chunk->stripe; 4523 stripe = &chunk->stripe;
4524 for (i = 0; i < map->num_stripes; i++) { 4524 for (i = 0; i < map->num_stripes; i++) {
4525 device = map->stripes[i].dev; 4525 device = map->stripes[i].dev;