btrfs: introduce a bitmap based csum range search function
[sfrench/cifs-2.6.git] / fs / btrfs / free-space-tree.c
index 367bcfcf68f51eb085f669d989ba98b7885cdd26..c667e878ef1a6e93027190bb91f8e2a8054812e4 100644 (file)
@@ -5,12 +5,17 @@
 
 #include <linux/kernel.h>
 #include <linux/sched/mm.h>
+#include "messages.h"
 #include "ctree.h"
 #include "disk-io.h"
 #include "locking.h"
 #include "free-space-tree.h"
 #include "transaction.h"
 #include "block-group.h"
+#include "fs.h"
+#include "accessors.h"
+#include "extent-tree.h"
+#include "root-tree.h"
 
 static int __add_block_group_free_space(struct btrfs_trans_handle *trans,
                                        struct btrfs_block_group *block_group,
@@ -803,7 +808,7 @@ int __remove_from_free_space_tree(struct btrfs_trans_handle *trans,
        u32 flags;
        int ret;
 
-       if (block_group->needs_free_space) {
+       if (test_bit(BLOCK_GROUP_FLAG_NEEDS_FREE_SPACE, &block_group->runtime_flags)) {
                ret = __add_block_group_free_space(trans, block_group, path);
                if (ret)
                        return ret;
@@ -996,7 +1001,7 @@ int __add_to_free_space_tree(struct btrfs_trans_handle *trans,
        u32 flags;
        int ret;
 
-       if (block_group->needs_free_space) {
+       if (test_bit(BLOCK_GROUP_FLAG_NEEDS_FREE_SPACE, &block_group->runtime_flags)) {
                ret = __add_block_group_free_space(trans, block_group, path);
                if (ret)
                        return ret;
@@ -1299,7 +1304,7 @@ static int __add_block_group_free_space(struct btrfs_trans_handle *trans,
 {
        int ret;
 
-       block_group->needs_free_space = 0;
+       clear_bit(BLOCK_GROUP_FLAG_NEEDS_FREE_SPACE, &block_group->runtime_flags);
 
        ret = add_new_free_space_info(trans, block_group, path);
        if (ret)
@@ -1321,7 +1326,7 @@ int add_block_group_free_space(struct btrfs_trans_handle *trans,
                return 0;
 
        mutex_lock(&block_group->free_space_lock);
-       if (!block_group->needs_free_space)
+       if (!test_bit(BLOCK_GROUP_FLAG_NEEDS_FREE_SPACE, &block_group->runtime_flags))
                goto out;
 
        path = btrfs_alloc_path();
@@ -1354,7 +1359,7 @@ int remove_block_group_free_space(struct btrfs_trans_handle *trans,
        if (!btrfs_fs_compat_ro(trans->fs_info, FREE_SPACE_TREE))
                return 0;
 
-       if (block_group->needs_free_space) {
+       if (test_bit(BLOCK_GROUP_FLAG_NEEDS_FREE_SPACE, &block_group->runtime_flags)) {
                /* We never added this block group to the free space tree. */
                return 0;
        }