aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fusionio.com>2012-09-12 14:08:47 -0400
committerChris Mason <chris.mason@fusionio.com>2012-10-01 15:19:21 -0400
commit698d0082c4875a2ccc10b52ee8f415faad46b754 (patch)
treedafa91d15c927cf5e951c7dbd05bedd36a90d406 /fs/btrfs/extent-tree.c
parentea658badc47e614e38ab4d98510488474c7e6d4b (diff)
Btrfs: remove bytes argument from do_chunk_alloc
Everybody is just making stuff up, and it's just used to see if we really do need to alloc a chunk, and since we do this when we already know we really do it's just a waste of space. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 254fd3289f4c..0bc83b3f33db 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -94,8 +94,8 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,
94 u64 flags, struct btrfs_disk_key *key, 94 u64 flags, struct btrfs_disk_key *key,
95 int level, struct btrfs_key *ins); 95 int level, struct btrfs_key *ins);
96static int do_chunk_alloc(struct btrfs_trans_handle *trans, 96static int do_chunk_alloc(struct btrfs_trans_handle *trans,
97 struct btrfs_root *extent_root, u64 alloc_bytes, 97 struct btrfs_root *extent_root, u64 flags,
98 u64 flags, int force); 98 int force);
99static int find_next_key(struct btrfs_path *path, int level, 99static int find_next_key(struct btrfs_path *path, int level,
100 struct btrfs_key *key); 100 struct btrfs_key *key);
101static void dump_space_info(struct btrfs_space_info *info, u64 bytes, 101static void dump_space_info(struct btrfs_space_info *info, u64 bytes,
@@ -3404,7 +3404,6 @@ alloc:
3404 return PTR_ERR(trans); 3404 return PTR_ERR(trans);
3405 3405
3406 ret = do_chunk_alloc(trans, root->fs_info->extent_root, 3406 ret = do_chunk_alloc(trans, root->fs_info->extent_root,
3407 bytes + 2 * 1024 * 1024,
3408 alloc_target, 3407 alloc_target,
3409 CHUNK_ALLOC_NO_FORCE); 3408 CHUNK_ALLOC_NO_FORCE);
3410 btrfs_end_transaction(trans, root); 3409 btrfs_end_transaction(trans, root);
@@ -3486,8 +3485,7 @@ static void force_metadata_allocation(struct btrfs_fs_info *info)
3486} 3485}
3487 3486
3488static int should_alloc_chunk(struct btrfs_root *root, 3487static int should_alloc_chunk(struct btrfs_root *root,
3489 struct btrfs_space_info *sinfo, u64 alloc_bytes, 3488 struct btrfs_space_info *sinfo, int force)
3490 int force)
3491{ 3489{
3492 struct btrfs_block_rsv *global_rsv = &root->fs_info->global_block_rsv; 3490 struct btrfs_block_rsv *global_rsv = &root->fs_info->global_block_rsv;
3493 u64 num_bytes = sinfo->total_bytes - sinfo->bytes_readonly; 3491 u64 num_bytes = sinfo->total_bytes - sinfo->bytes_readonly;
@@ -3518,7 +3516,7 @@ static int should_alloc_chunk(struct btrfs_root *root,
3518 return 1; 3516 return 1;
3519 } 3517 }
3520 3518
3521 if (num_allocated + alloc_bytes < div_factor(num_bytes, 8)) 3519 if (num_allocated + 2 * 1024 * 1024 < div_factor(num_bytes, 8))
3522 return 0; 3520 return 0;
3523 return 1; 3521 return 1;
3524} 3522}
@@ -3568,8 +3566,7 @@ static void check_system_chunk(struct btrfs_trans_handle *trans,
3568} 3566}
3569 3567
3570static int do_chunk_alloc(struct btrfs_trans_handle *trans, 3568static int do_chunk_alloc(struct btrfs_trans_handle *trans,
3571 struct btrfs_root *extent_root, u64 alloc_bytes, 3569 struct btrfs_root *extent_root, u64 flags, int force)
3572 u64 flags, int force)
3573{ 3570{
3574 struct btrfs_space_info *space_info; 3571 struct btrfs_space_info *space_info;
3575 struct btrfs_fs_info *fs_info = extent_root->fs_info; 3572 struct btrfs_fs_info *fs_info = extent_root->fs_info;
@@ -3593,7 +3590,7 @@ again:
3593 return 0; 3590 return 0;
3594 } 3591 }
3595 3592
3596 if (!should_alloc_chunk(extent_root, space_info, alloc_bytes, force)) { 3593 if (!should_alloc_chunk(extent_root, space_info, force)) {
3597 spin_unlock(&space_info->lock); 3594 spin_unlock(&space_info->lock);
3598 return 0; 3595 return 0;
3599 } else if (space_info->chunk_alloc) { 3596 } else if (space_info->chunk_alloc) {
@@ -3869,7 +3866,6 @@ static int flush_space(struct btrfs_root *root,
3869 break; 3866 break;
3870 } 3867 }
3871 ret = do_chunk_alloc(trans, root->fs_info->extent_root, 3868 ret = do_chunk_alloc(trans, root->fs_info->extent_root,
3872 num_bytes,
3873 btrfs_get_alloc_profile(root, 0), 3869 btrfs_get_alloc_profile(root, 0),
3874 CHUNK_ALLOC_NO_FORCE); 3870 CHUNK_ALLOC_NO_FORCE);
3875 btrfs_end_transaction(trans, root); 3871 btrfs_end_transaction(trans, root);
@@ -5868,8 +5864,7 @@ loop:
5868 index = 0; 5864 index = 0;
5869 loop++; 5865 loop++;
5870 if (loop == LOOP_ALLOC_CHUNK) { 5866 if (loop == LOOP_ALLOC_CHUNK) {
5871 ret = do_chunk_alloc(trans, root, num_bytes + 5867 ret = do_chunk_alloc(trans, root, data,
5872 2 * 1024 * 1024, data,
5873 CHUNK_ALLOC_FORCE); 5868 CHUNK_ALLOC_FORCE);
5874 /* 5869 /*
5875 * Do not bail out on ENOSPC since we 5870 * Do not bail out on ENOSPC since we
@@ -7269,7 +7264,7 @@ int btrfs_set_block_group_ro(struct btrfs_root *root,
7269 7264
7270 alloc_flags = update_block_group_flags(root, cache->flags); 7265 alloc_flags = update_block_group_flags(root, cache->flags);
7271 if (alloc_flags != cache->flags) { 7266 if (alloc_flags != cache->flags) {
7272 ret = do_chunk_alloc(trans, root, 2 * 1024 * 1024, alloc_flags, 7267 ret = do_chunk_alloc(trans, root, alloc_flags,
7273 CHUNK_ALLOC_FORCE); 7268 CHUNK_ALLOC_FORCE);
7274 if (ret < 0) 7269 if (ret < 0)
7275 goto out; 7270 goto out;
@@ -7279,7 +7274,7 @@ int btrfs_set_block_group_ro(struct btrfs_root *root,
7279 if (!ret) 7274 if (!ret)
7280 goto out; 7275 goto out;
7281 alloc_flags = get_alloc_profile(root, cache->space_info->flags); 7276 alloc_flags = get_alloc_profile(root, cache->space_info->flags);
7282 ret = do_chunk_alloc(trans, root, 2 * 1024 * 1024, alloc_flags, 7277 ret = do_chunk_alloc(trans, root, alloc_flags,
7283 CHUNK_ALLOC_FORCE); 7278 CHUNK_ALLOC_FORCE);
7284 if (ret < 0) 7279 if (ret < 0)
7285 goto out; 7280 goto out;
@@ -7293,7 +7288,7 @@ int btrfs_force_chunk_alloc(struct btrfs_trans_handle *trans,
7293 struct btrfs_root *root, u64 type) 7288 struct btrfs_root *root, u64 type)
7294{ 7289{
7295 u64 alloc_flags = get_alloc_profile(root, type); 7290 u64 alloc_flags = get_alloc_profile(root, type);
7296 return do_chunk_alloc(trans, root, 2 * 1024 * 1024, alloc_flags, 7291 return do_chunk_alloc(trans, root, alloc_flags,
7297 CHUNK_ALLOC_FORCE); 7292 CHUNK_ALLOC_FORCE);
7298} 7293}
7299 7294