diff options
-rw-r--r-- | fs/btrfs/ctree.h | 21 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 2 | ||||
-rw-r--r-- | fs/btrfs/volumes.c | 6 |
3 files changed, 17 insertions, 12 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index aba7832a2285..f057e92df39f 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -2735,22 +2735,27 @@ static inline void free_fs_info(struct btrfs_fs_info *fs_info) | |||
2735 | kfree(fs_info); | 2735 | kfree(fs_info); |
2736 | } | 2736 | } |
2737 | /** | 2737 | /** |
2738 | * profile_is_valid - tests whether a given profile is valid and reduced | 2738 | * alloc_profile_is_valid - see if a given profile is valid and reduced |
2739 | * @flags: profile to validate | 2739 | * @flags: profile to validate |
2740 | * @extended: if true @flags is treated as an extended profile | 2740 | * @extended: if true @flags is treated as an extended profile |
2741 | */ | 2741 | */ |
2742 | static inline int profile_is_valid(u64 flags, int extended) | 2742 | static inline int alloc_profile_is_valid(u64 flags, int extended) |
2743 | { | 2743 | { |
2744 | u64 mask = ~BTRFS_BLOCK_GROUP_PROFILE_MASK; | 2744 | u64 mask = (extended ? BTRFS_EXTENDED_PROFILE_MASK : |
2745 | BTRFS_BLOCK_GROUP_PROFILE_MASK); | ||
2745 | 2746 | ||
2746 | flags &= ~BTRFS_BLOCK_GROUP_TYPE_MASK; | 2747 | flags &= ~BTRFS_BLOCK_GROUP_TYPE_MASK; |
2747 | if (extended) | ||
2748 | mask &= ~BTRFS_AVAIL_ALLOC_BIT_SINGLE; | ||
2749 | 2748 | ||
2750 | if (flags & mask) | 2749 | /* 1) check that all other bits are zeroed */ |
2750 | if (flags & ~mask) | ||
2751 | return 0; | 2751 | return 0; |
2752 | /* true if zero or exactly one bit set */ | 2752 | |
2753 | return (flags & (~flags + 1)) == flags; | 2753 | /* 2) see if profile is reduced */ |
2754 | if (flags == 0) | ||
2755 | return !extended; /* "0" is valid for usual profiles */ | ||
2756 | |||
2757 | /* true if exactly one bit set */ | ||
2758 | return (flags & (flags - 1)) == 0; | ||
2754 | } | 2759 | } |
2755 | 2760 | ||
2756 | /* root-item.c */ | 2761 | /* root-item.c */ |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 9f16fdb463c7..8c5bd8fa8245 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -3400,7 +3400,7 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans, | |||
3400 | int wait_for_alloc = 0; | 3400 | int wait_for_alloc = 0; |
3401 | int ret = 0; | 3401 | int ret = 0; |
3402 | 3402 | ||
3403 | BUG_ON(!profile_is_valid(flags, 0)); | 3403 | BUG_ON(!alloc_profile_is_valid(flags, 0)); |
3404 | 3404 | ||
3405 | space_info = __find_space_info(extent_root->fs_info, flags); | 3405 | space_info = __find_space_info(extent_root->fs_info, flags); |
3406 | if (!space_info) { | 3406 | if (!space_info) { |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 4b263a2009b0..e4ef0f2fdb73 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -2669,7 +2669,7 @@ int btrfs_balance(struct btrfs_balance_control *bctl, | |||
2669 | allowed |= (BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID1 | | 2669 | allowed |= (BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID1 | |
2670 | BTRFS_BLOCK_GROUP_RAID10); | 2670 | BTRFS_BLOCK_GROUP_RAID10); |
2671 | 2671 | ||
2672 | if (!profile_is_valid(bctl->data.target, 1) || | 2672 | if (!alloc_profile_is_valid(bctl->data.target, 1) || |
2673 | bctl->data.target & ~allowed) { | 2673 | bctl->data.target & ~allowed) { |
2674 | printk(KERN_ERR "btrfs: unable to start balance with target " | 2674 | printk(KERN_ERR "btrfs: unable to start balance with target " |
2675 | "data profile %llu\n", | 2675 | "data profile %llu\n", |
@@ -2677,7 +2677,7 @@ int btrfs_balance(struct btrfs_balance_control *bctl, | |||
2677 | ret = -EINVAL; | 2677 | ret = -EINVAL; |
2678 | goto out; | 2678 | goto out; |
2679 | } | 2679 | } |
2680 | if (!profile_is_valid(bctl->meta.target, 1) || | 2680 | if (!alloc_profile_is_valid(bctl->meta.target, 1) || |
2681 | bctl->meta.target & ~allowed) { | 2681 | bctl->meta.target & ~allowed) { |
2682 | printk(KERN_ERR "btrfs: unable to start balance with target " | 2682 | printk(KERN_ERR "btrfs: unable to start balance with target " |
2683 | "metadata profile %llu\n", | 2683 | "metadata profile %llu\n", |
@@ -2685,7 +2685,7 @@ int btrfs_balance(struct btrfs_balance_control *bctl, | |||
2685 | ret = -EINVAL; | 2685 | ret = -EINVAL; |
2686 | goto out; | 2686 | goto out; |
2687 | } | 2687 | } |
2688 | if (!profile_is_valid(bctl->sys.target, 1) || | 2688 | if (!alloc_profile_is_valid(bctl->sys.target, 1) || |
2689 | bctl->sys.target & ~allowed) { | 2689 | bctl->sys.target & ~allowed) { |
2690 | printk(KERN_ERR "btrfs: unable to start balance with target " | 2690 | printk(KERN_ERR "btrfs: unable to start balance with target " |
2691 | "system profile %llu\n", | 2691 | "system profile %llu\n", |