diff options
-rw-r--r-- | fs/btrfs/ctree.h | 15 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 25 | ||||
-rw-r--r-- | fs/btrfs/volumes.c | 20 |
3 files changed, 30 insertions, 30 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index c2e17cd299b7..aba7832a2285 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -849,6 +849,21 @@ struct btrfs_csum_item { | |||
849 | */ | 849 | */ |
850 | #define BTRFS_AVAIL_ALLOC_BIT_SINGLE (1ULL << 48) | 850 | #define BTRFS_AVAIL_ALLOC_BIT_SINGLE (1ULL << 48) |
851 | 851 | ||
852 | #define BTRFS_EXTENDED_PROFILE_MASK (BTRFS_BLOCK_GROUP_PROFILE_MASK | \ | ||
853 | BTRFS_AVAIL_ALLOC_BIT_SINGLE) | ||
854 | |||
855 | static inline u64 chunk_to_extended(u64 flags) | ||
856 | { | ||
857 | if ((flags & BTRFS_BLOCK_GROUP_PROFILE_MASK) == 0) | ||
858 | flags |= BTRFS_AVAIL_ALLOC_BIT_SINGLE; | ||
859 | |||
860 | return flags; | ||
861 | } | ||
862 | static inline u64 extended_to_chunk(u64 flags) | ||
863 | { | ||
864 | return flags & ~BTRFS_AVAIL_ALLOC_BIT_SINGLE; | ||
865 | } | ||
866 | |||
852 | struct btrfs_block_group_item { | 867 | struct btrfs_block_group_item { |
853 | __le64 used; | 868 | __le64 used; |
854 | __le64 chunk_objectid; | 869 | __le64 chunk_objectid; |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 4269777f185e..9f16fdb463c7 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -3098,11 +3098,8 @@ static int update_space_info(struct btrfs_fs_info *info, u64 flags, | |||
3098 | 3098 | ||
3099 | static void set_avail_alloc_bits(struct btrfs_fs_info *fs_info, u64 flags) | 3099 | static void set_avail_alloc_bits(struct btrfs_fs_info *fs_info, u64 flags) |
3100 | { | 3100 | { |
3101 | u64 extra_flags = flags & BTRFS_BLOCK_GROUP_PROFILE_MASK; | 3101 | u64 extra_flags = chunk_to_extended(flags) & |
3102 | 3102 | BTRFS_EXTENDED_PROFILE_MASK; | |
3103 | /* chunk -> extended profile */ | ||
3104 | if (extra_flags == 0) | ||
3105 | extra_flags = BTRFS_AVAIL_ALLOC_BIT_SINGLE; | ||
3106 | 3103 | ||
3107 | if (flags & BTRFS_BLOCK_GROUP_DATA) | 3104 | if (flags & BTRFS_BLOCK_GROUP_DATA) |
3108 | fs_info->avail_data_alloc_bits |= extra_flags; | 3105 | fs_info->avail_data_alloc_bits |= extra_flags; |
@@ -3181,9 +3178,7 @@ u64 btrfs_reduce_alloc_profile(struct btrfs_root *root, u64 flags) | |||
3181 | } | 3178 | } |
3182 | 3179 | ||
3183 | out: | 3180 | out: |
3184 | /* extended -> chunk profile */ | 3181 | return extended_to_chunk(flags); |
3185 | flags &= ~BTRFS_AVAIL_ALLOC_BIT_SINGLE; | ||
3186 | return flags; | ||
3187 | } | 3182 | } |
3188 | 3183 | ||
3189 | static u64 get_alloc_profile(struct btrfs_root *root, u64 flags) | 3184 | static u64 get_alloc_profile(struct btrfs_root *root, u64 flags) |
@@ -6914,11 +6909,8 @@ static u64 update_block_group_flags(struct btrfs_root *root, u64 flags) | |||
6914 | tgt = BTRFS_BLOCK_GROUP_METADATA | bctl->meta.target; | 6909 | tgt = BTRFS_BLOCK_GROUP_METADATA | bctl->meta.target; |
6915 | } | 6910 | } |
6916 | 6911 | ||
6917 | if (tgt) { | 6912 | if (tgt) |
6918 | /* extended -> chunk profile */ | 6913 | return extended_to_chunk(tgt); |
6919 | tgt &= ~BTRFS_AVAIL_ALLOC_BIT_SINGLE; | ||
6920 | return tgt; | ||
6921 | } | ||
6922 | } | 6914 | } |
6923 | 6915 | ||
6924 | /* | 6916 | /* |
@@ -7597,11 +7589,8 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans, | |||
7597 | 7589 | ||
7598 | static void clear_avail_alloc_bits(struct btrfs_fs_info *fs_info, u64 flags) | 7590 | static void clear_avail_alloc_bits(struct btrfs_fs_info *fs_info, u64 flags) |
7599 | { | 7591 | { |
7600 | u64 extra_flags = flags & BTRFS_BLOCK_GROUP_PROFILE_MASK; | 7592 | u64 extra_flags = chunk_to_extended(flags) & |
7601 | 7593 | BTRFS_EXTENDED_PROFILE_MASK; | |
7602 | /* chunk -> extended profile */ | ||
7603 | if (extra_flags == 0) | ||
7604 | extra_flags = BTRFS_AVAIL_ALLOC_BIT_SINGLE; | ||
7605 | 7594 | ||
7606 | if (flags & BTRFS_BLOCK_GROUP_DATA) | 7595 | if (flags & BTRFS_BLOCK_GROUP_DATA) |
7607 | fs_info->avail_data_alloc_bits &= ~extra_flags; | 7596 | fs_info->avail_data_alloc_bits &= ~extra_flags; |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 58aad63e1ad3..4b263a2009b0 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -2250,15 +2250,13 @@ static void unset_balance_control(struct btrfs_fs_info *fs_info) | |||
2250 | * Balance filters. Return 1 if chunk should be filtered out | 2250 | * Balance filters. Return 1 if chunk should be filtered out |
2251 | * (should not be balanced). | 2251 | * (should not be balanced). |
2252 | */ | 2252 | */ |
2253 | static int chunk_profiles_filter(u64 chunk_profile, | 2253 | static int chunk_profiles_filter(u64 chunk_type, |
2254 | struct btrfs_balance_args *bargs) | 2254 | struct btrfs_balance_args *bargs) |
2255 | { | 2255 | { |
2256 | chunk_profile &= BTRFS_BLOCK_GROUP_PROFILE_MASK; | 2256 | chunk_type = chunk_to_extended(chunk_type) & |
2257 | BTRFS_EXTENDED_PROFILE_MASK; | ||
2257 | 2258 | ||
2258 | if (chunk_profile == 0) | 2259 | if (bargs->profiles & chunk_type) |
2259 | chunk_profile = BTRFS_AVAIL_ALLOC_BIT_SINGLE; | ||
2260 | |||
2261 | if (bargs->profiles & chunk_profile) | ||
2262 | return 0; | 2260 | return 0; |
2263 | 2261 | ||
2264 | return 1; | 2262 | return 1; |
@@ -2365,18 +2363,16 @@ static int chunk_vrange_filter(struct extent_buffer *leaf, | |||
2365 | return 1; | 2363 | return 1; |
2366 | } | 2364 | } |
2367 | 2365 | ||
2368 | static int chunk_soft_convert_filter(u64 chunk_profile, | 2366 | static int chunk_soft_convert_filter(u64 chunk_type, |
2369 | struct btrfs_balance_args *bargs) | 2367 | struct btrfs_balance_args *bargs) |
2370 | { | 2368 | { |
2371 | if (!(bargs->flags & BTRFS_BALANCE_ARGS_CONVERT)) | 2369 | if (!(bargs->flags & BTRFS_BALANCE_ARGS_CONVERT)) |
2372 | return 0; | 2370 | return 0; |
2373 | 2371 | ||
2374 | chunk_profile &= BTRFS_BLOCK_GROUP_PROFILE_MASK; | 2372 | chunk_type = chunk_to_extended(chunk_type) & |
2375 | 2373 | BTRFS_EXTENDED_PROFILE_MASK; | |
2376 | if (chunk_profile == 0) | ||
2377 | chunk_profile = BTRFS_AVAIL_ALLOC_BIT_SINGLE; | ||
2378 | 2374 | ||
2379 | if (bargs->target & chunk_profile) | 2375 | if (bargs->target == chunk_type) |
2380 | return 1; | 2376 | return 1; |
2381 | 2377 | ||
2382 | return 0; | 2378 | return 0; |