|
@@ -4121,7 +4121,7 @@ static u64 get_alloc_profile(struct btrfs_fs_info *fs_info, u64 orig_flags)
|
|
|
return btrfs_reduce_alloc_profile(fs_info, flags);
|
|
|
}
|
|
|
|
|
|
-u64 btrfs_get_alloc_profile(struct btrfs_root *root, int data)
|
|
|
+static u64 get_alloc_profile_by_root(struct btrfs_root *root, int data)
|
|
|
{
|
|
|
struct btrfs_fs_info *fs_info = root->fs_info;
|
|
|
u64 flags;
|
|
@@ -4138,6 +4138,21 @@ u64 btrfs_get_alloc_profile(struct btrfs_root *root, int data)
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
+u64 btrfs_data_alloc_profile(struct btrfs_fs_info *fs_info)
|
|
|
+{
|
|
|
+ return get_alloc_profile(fs_info, BTRFS_BLOCK_GROUP_DATA);
|
|
|
+}
|
|
|
+
|
|
|
+u64 btrfs_metadata_alloc_profile(struct btrfs_fs_info *fs_info)
|
|
|
+{
|
|
|
+ return get_alloc_profile(fs_info, BTRFS_BLOCK_GROUP_METADATA);
|
|
|
+}
|
|
|
+
|
|
|
+u64 btrfs_system_alloc_profile(struct btrfs_fs_info *fs_info)
|
|
|
+{
|
|
|
+ return get_alloc_profile(fs_info, BTRFS_BLOCK_GROUP_SYSTEM);
|
|
|
+}
|
|
|
+
|
|
|
static u64 btrfs_space_info_used(struct btrfs_space_info *s_info,
|
|
|
bool may_use_included)
|
|
|
{
|
|
@@ -4187,7 +4202,7 @@ again:
|
|
|
data_sinfo->force_alloc = CHUNK_ALLOC_FORCE;
|
|
|
spin_unlock(&data_sinfo->lock);
|
|
|
alloc:
|
|
|
- alloc_target = btrfs_get_alloc_profile(root, 1);
|
|
|
+ alloc_target = btrfs_data_alloc_profile(fs_info);
|
|
|
/*
|
|
|
* It is ugly that we don't call nolock join
|
|
|
* transaction for the free space inode case here.
|
|
@@ -4463,9 +4478,8 @@ void check_system_chunk(struct btrfs_trans_handle *trans,
|
|
|
}
|
|
|
|
|
|
if (left < thresh) {
|
|
|
- u64 flags;
|
|
|
+ u64 flags = btrfs_system_alloc_profile(fs_info);
|
|
|
|
|
|
- flags = btrfs_get_alloc_profile(fs_info->chunk_root, 0);
|
|
|
/*
|
|
|
* Ignore failure to create system chunk. We might end up not
|
|
|
* needing it, as we might not need to COW all nodes/leafs from
|
|
@@ -4629,7 +4643,7 @@ static int can_overcommit(struct btrfs_root *root,
|
|
|
if (space_info->flags & BTRFS_BLOCK_GROUP_DATA)
|
|
|
return 0;
|
|
|
|
|
|
- profile = btrfs_get_alloc_profile(root, 0);
|
|
|
+ profile = get_alloc_profile_by_root(root, 0);
|
|
|
used = btrfs_space_info_used(space_info, false);
|
|
|
|
|
|
/*
|
|
@@ -4894,7 +4908,7 @@ static int flush_space(struct btrfs_fs_info *fs_info,
|
|
|
break;
|
|
|
}
|
|
|
ret = do_chunk_alloc(trans, fs_info,
|
|
|
- btrfs_get_alloc_profile(root, 0),
|
|
|
+ btrfs_metadata_alloc_profile(fs_info),
|
|
|
CHUNK_ALLOC_NO_FORCE);
|
|
|
btrfs_end_transaction(trans);
|
|
|
if (ret > 0 || ret == -ENOSPC)
|
|
@@ -7954,7 +7968,7 @@ int btrfs_reserve_extent(struct btrfs_root *root, u64 ram_bytes,
|
|
|
u64 flags;
|
|
|
int ret;
|
|
|
|
|
|
- flags = btrfs_get_alloc_profile(root, is_data);
|
|
|
+ flags = get_alloc_profile_by_root(root, is_data);
|
|
|
again:
|
|
|
WARN_ON(num_bytes < fs_info->sectorsize);
|
|
|
ret = find_free_extent(fs_info, ram_bytes, num_bytes, empty_size,
|