diff options
author | Ilya Dryomov <idryomov@gmail.com> | 2012-03-27 10:09:17 -0400 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2012-03-27 10:09:17 -0400 |
commit | 0c460c0d70e10463e44bdf1d406e9c5ec03b1af6 (patch) | |
tree | 8c28962481b64a3dcabb2294094435832a23516d /fs | |
parent | e8920a640be5d4ebe3fee0670639a81d4ffc904c (diff) |
Btrfs: move alloc_profile_is_valid() to volumes.c
Header file is not a good place to define functions. This also moves a
call to alloc_profile_is_valid() down the stack and removes a redundant
check from __btrfs_alloc_chunk() - alloc_profile_is_valid() takes it
into account.
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/ctree.h | 23 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 2 | ||||
-rw-r--r-- | fs/btrfs/volumes.c | 30 |
3 files changed, 25 insertions, 30 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index f057e92df39f..a56e1e00105f 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -2734,29 +2734,6 @@ static inline void free_fs_info(struct btrfs_fs_info *fs_info) | |||
2734 | kfree(fs_info->super_for_commit); | 2734 | kfree(fs_info->super_for_commit); |
2735 | kfree(fs_info); | 2735 | kfree(fs_info); |
2736 | } | 2736 | } |
2737 | /** | ||
2738 | * alloc_profile_is_valid - see if a given profile is valid and reduced | ||
2739 | * @flags: profile to validate | ||
2740 | * @extended: if true @flags is treated as an extended profile | ||
2741 | */ | ||
2742 | static inline int alloc_profile_is_valid(u64 flags, int extended) | ||
2743 | { | ||
2744 | u64 mask = (extended ? BTRFS_EXTENDED_PROFILE_MASK : | ||
2745 | BTRFS_BLOCK_GROUP_PROFILE_MASK); | ||
2746 | |||
2747 | flags &= ~BTRFS_BLOCK_GROUP_TYPE_MASK; | ||
2748 | |||
2749 | /* 1) check that all other bits are zeroed */ | ||
2750 | if (flags & ~mask) | ||
2751 | return 0; | ||
2752 | |||
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; | ||
2759 | } | ||
2760 | 2737 | ||
2761 | /* root-item.c */ | 2738 | /* root-item.c */ |
2762 | int btrfs_find_root_ref(struct btrfs_root *tree_root, | 2739 | int btrfs_find_root_ref(struct btrfs_root *tree_root, |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 8c5bd8fa8245..304710cae653 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -3400,8 +3400,6 @@ 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(!alloc_profile_is_valid(flags, 0)); | ||
3404 | |||
3405 | space_info = __find_space_info(extent_root->fs_info, flags); | 3403 | space_info = __find_space_info(extent_root->fs_info, flags); |
3406 | if (!space_info) { | 3404 | if (!space_info) { |
3407 | ret = update_space_info(extent_root->fs_info, flags, | 3405 | ret = update_space_info(extent_root->fs_info, flags, |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index e4ef0f2fdb73..def9e25f87f2 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -2598,6 +2598,30 @@ error: | |||
2598 | return ret; | 2598 | return ret; |
2599 | } | 2599 | } |
2600 | 2600 | ||
2601 | /** | ||
2602 | * alloc_profile_is_valid - see if a given profile is valid and reduced | ||
2603 | * @flags: profile to validate | ||
2604 | * @extended: if true @flags is treated as an extended profile | ||
2605 | */ | ||
2606 | static int alloc_profile_is_valid(u64 flags, int extended) | ||
2607 | { | ||
2608 | u64 mask = (extended ? BTRFS_EXTENDED_PROFILE_MASK : | ||
2609 | BTRFS_BLOCK_GROUP_PROFILE_MASK); | ||
2610 | |||
2611 | flags &= ~BTRFS_BLOCK_GROUP_TYPE_MASK; | ||
2612 | |||
2613 | /* 1) check that all other bits are zeroed */ | ||
2614 | if (flags & ~mask) | ||
2615 | return 0; | ||
2616 | |||
2617 | /* 2) see if profile is reduced */ | ||
2618 | if (flags == 0) | ||
2619 | return !extended; /* "0" is valid for usual profiles */ | ||
2620 | |||
2621 | /* true if exactly one bit set */ | ||
2622 | return (flags & (flags - 1)) == 0; | ||
2623 | } | ||
2624 | |||
2601 | static inline int balance_need_close(struct btrfs_fs_info *fs_info) | 2625 | static inline int balance_need_close(struct btrfs_fs_info *fs_info) |
2602 | { | 2626 | { |
2603 | /* cancel requested || normal exit path */ | 2627 | /* cancel requested || normal exit path */ |
@@ -3124,11 +3148,7 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans, | |||
3124 | int i; | 3148 | int i; |
3125 | int j; | 3149 | int j; |
3126 | 3150 | ||
3127 | if ((type & BTRFS_BLOCK_GROUP_RAID1) && | 3151 | BUG_ON(!alloc_profile_is_valid(type, 0)); |
3128 | (type & BTRFS_BLOCK_GROUP_DUP)) { | ||
3129 | WARN_ON(1); | ||
3130 | type &= ~BTRFS_BLOCK_GROUP_DUP; | ||
3131 | } | ||
3132 | 3152 | ||
3133 | if (list_empty(&fs_devices->alloc_list)) | 3153 | if (list_empty(&fs_devices->alloc_list)) |
3134 | return -ENOSPC; | 3154 | return -ENOSPC; |