]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Btrfs: move alloc_profile_is_valid() to volumes.c
authorIlya Dryomov <idryomov@gmail.com>
Tue, 27 Mar 2012 14:09:17 +0000 (17:09 +0300)
committerIlya Dryomov <idryomov@gmail.com>
Tue, 27 Mar 2012 14:09:17 +0000 (17:09 +0300)
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>
fs/btrfs/ctree.h
fs/btrfs/extent-tree.c
fs/btrfs/volumes.c

index f057e92df39fadd127d0931873c7f22f0322523d..a56e1e00105f33bd7afefdf02414c0e854be8a9f 100644 (file)
@@ -2734,29 +2734,6 @@ static inline void free_fs_info(struct btrfs_fs_info *fs_info)
        kfree(fs_info->super_for_commit);
        kfree(fs_info);
 }
-/**
- * alloc_profile_is_valid - see if a given profile is valid and reduced
- * @flags: profile to validate
- * @extended: if true @flags is treated as an extended profile
- */
-static inline int alloc_profile_is_valid(u64 flags, int extended)
-{
-       u64 mask = (extended ? BTRFS_EXTENDED_PROFILE_MASK :
-                              BTRFS_BLOCK_GROUP_PROFILE_MASK);
-
-       flags &= ~BTRFS_BLOCK_GROUP_TYPE_MASK;
-
-       /* 1) check that all other bits are zeroed */
-       if (flags & ~mask)
-               return 0;
-
-       /* 2) see if profile is reduced */
-       if (flags == 0)
-               return !extended; /* "0" is valid for usual profiles */
-
-       /* true if exactly one bit set */
-       return (flags & (flags - 1)) == 0;
-}
 
 /* root-item.c */
 int btrfs_find_root_ref(struct btrfs_root *tree_root,
index 8c5bd8fa824595392278853c72127eef4ceb40dd..304710cae6536875acf176ad7130cecfea40d74c 100644 (file)
@@ -3400,8 +3400,6 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans,
        int wait_for_alloc = 0;
        int ret = 0;
 
-       BUG_ON(!alloc_profile_is_valid(flags, 0));
-
        space_info = __find_space_info(extent_root->fs_info, flags);
        if (!space_info) {
                ret = update_space_info(extent_root->fs_info, flags,
index e4ef0f2fdb739016c711b01af0a9f81c6237399e..def9e25f87f2730b868a85b45c9cc53186378702 100644 (file)
@@ -2598,6 +2598,30 @@ error:
        return ret;
 }
 
+/**
+ * alloc_profile_is_valid - see if a given profile is valid and reduced
+ * @flags: profile to validate
+ * @extended: if true @flags is treated as an extended profile
+ */
+static int alloc_profile_is_valid(u64 flags, int extended)
+{
+       u64 mask = (extended ? BTRFS_EXTENDED_PROFILE_MASK :
+                              BTRFS_BLOCK_GROUP_PROFILE_MASK);
+
+       flags &= ~BTRFS_BLOCK_GROUP_TYPE_MASK;
+
+       /* 1) check that all other bits are zeroed */
+       if (flags & ~mask)
+               return 0;
+
+       /* 2) see if profile is reduced */
+       if (flags == 0)
+               return !extended; /* "0" is valid for usual profiles */
+
+       /* true if exactly one bit set */
+       return (flags & (flags - 1)) == 0;
+}
+
 static inline int balance_need_close(struct btrfs_fs_info *fs_info)
 {
        /* cancel requested || normal exit path */
@@ -3124,11 +3148,7 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
        int i;
        int j;
 
-       if ((type & BTRFS_BLOCK_GROUP_RAID1) &&
-           (type & BTRFS_BLOCK_GROUP_DUP)) {
-               WARN_ON(1);
-               type &= ~BTRFS_BLOCK_GROUP_DUP;
-       }
+       BUG_ON(!alloc_profile_is_valid(type, 0));
 
        if (list_empty(&fs_devices->alloc_list))
                return -ENOSPC;