aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/volumes.c
diff options
context:
space:
mode:
authorIlya Dryomov <idryomov@gmail.com>2012-03-27 10:09:16 -0400
committerIlya Dryomov <idryomov@gmail.com>2012-03-27 10:09:16 -0400
commit899c81eac890bcfa5f3636f4c43f68e8393ac1f8 (patch)
treef2a202c25edd6a58a4c0018db03617b6b0c46fc8 /fs/btrfs/volumes.c
parente3176ca2769e420f64eba4b093bbddea6d7a89c3 (diff)
Btrfs: add wrappers for working with alloc profiles
Add functions to abstract the conversion between chunk and extended allocation profile formats and switch everybody to use them. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r--fs/btrfs/volumes.c20
1 files changed, 8 insertions, 12 deletions
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 */
2253static int chunk_profiles_filter(u64 chunk_profile, 2253static 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
2368static int chunk_soft_convert_filter(u64 chunk_profile, 2366static 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;