Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 285960
b: refs/heads/master
c: ed25e9b
h: refs/heads/master
v: v3
  • Loading branch information
Ilya Dryomov committed Jan 16, 2012
1 parent 5e98399 commit db99709
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f43ffb60fd94e98be02780944e182ade6653b916
refs/heads/master: ed25e9b26f898d8d63ae4a836489f1923534143b
24 changes: 24 additions & 0 deletions trunk/fs/btrfs/volumes.c
Original file line number Diff line number Diff line change
Expand Up @@ -2102,6 +2102,24 @@ static void unset_balance_control(struct btrfs_fs_info *fs_info)
kfree(bctl);
}

/*
* Balance filters. Return 1 if chunk should be filtered out
* (should not be balanced).
*/
static int chunk_profiles_filter(u64 chunk_profile,
struct btrfs_balance_args *bargs)
{
chunk_profile &= BTRFS_BLOCK_GROUP_PROFILE_MASK;

if (chunk_profile == 0)
chunk_profile = BTRFS_AVAIL_ALLOC_BIT_SINGLE;

if (bargs->profiles & chunk_profile)
return 0;

return 1;
}

static int should_balance_chunk(struct btrfs_root *root,
struct extent_buffer *leaf,
struct btrfs_chunk *chunk, u64 chunk_offset)
Expand All @@ -2123,6 +2141,12 @@ static int should_balance_chunk(struct btrfs_root *root,
else if (chunk_type & BTRFS_BLOCK_GROUP_METADATA)
bargs = &bctl->meta;

/* profiles filter */
if ((bargs->flags & BTRFS_BALANCE_ARGS_PROFILES) &&
chunk_profiles_filter(chunk_type, bargs)) {
return 0;
}

return 1;
}

Expand Down
4 changes: 4 additions & 0 deletions trunk/fs/btrfs/volumes.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ struct map_lookup {
#define BTRFS_BALANCE_TYPE_MASK (BTRFS_BALANCE_DATA | \
BTRFS_BALANCE_SYSTEM | \
BTRFS_BALANCE_METADATA)
/*
* Balance filters
*/
#define BTRFS_BALANCE_ARGS_PROFILES (1ULL << 0)

struct btrfs_balance_args;
struct btrfs_balance_control {
Expand Down

0 comments on commit db99709

Please sign in to comment.