]> Pileus Git - ~andy/linux/commitdiff
Btrfs: do not reduce profile in do_chunk_alloc()
authorIlya Dryomov <idryomov@gmail.com>
Mon, 16 Jan 2012 20:04:48 +0000 (22:04 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 16 Jan 2012 20:04:48 +0000 (22:04 +0200)
Every caller of do_chunk_alloc() feeds it the reduced allocation
profile, so stop trying to reduce it one more time.  Instead check the
validity of the passed profile.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
fs/btrfs/ctree.h
fs/btrfs/extent-tree.c

index c4d98c8df5c5e067f8516230c94e88495585db0a..1e7aea60da2bf1d1e63fbcf886aa314534d3be6d 100644 (file)
@@ -2536,6 +2536,24 @@ static inline void free_fs_info(struct btrfs_fs_info *fs_info)
        kfree(fs_info->super_for_commit);
        kfree(fs_info);
 }
+/**
+ * profile_is_valid - tests whether a given profile is valid and reduced
+ * @flags: profile to validate
+ * @extended: if true @flags is treated as an extended profile
+ */
+static inline int profile_is_valid(u64 flags, int extended)
+{
+       u64 mask = ~BTRFS_BLOCK_GROUP_PROFILE_MASK;
+
+       flags &= ~BTRFS_BLOCK_GROUP_TYPE_MASK;
+       if (extended)
+               mask &= ~BTRFS_AVAIL_ALLOC_BIT_SINGLE;
+
+       if (flags & mask)
+               return 0;
+       /* true if zero or exactly one bit set */
+       return (flags & (~flags + 1)) == flags;
+}
 
 /* root-item.c */
 int btrfs_find_root_ref(struct btrfs_root *tree_root,
index 946b0671c5d927f4c7d48d47169660d374474ebb..a1a18ea7b6c63e540c1b0afce9d4318f127ba33e 100644 (file)
@@ -3295,7 +3295,7 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans,
        int wait_for_alloc = 0;
        int ret = 0;
 
-       flags = btrfs_reduce_alloc_profile(extent_root, flags);
+       BUG_ON(!profile_is_valid(flags, 0));
 
        space_info = __find_space_info(extent_root->fs_info, flags);
        if (!space_info) {