btrfs: concentrate all tree block parentness check parameters into one structure
[sfrench/cifs-2.6.git] / fs / btrfs / block-group.h
index 8fb14b99a1d1fdf4e170df449f05c1ec83f94533..a02ea76fd6cffe6acee57f45bb9406e6b559d46c 100644 (file)
@@ -55,6 +55,10 @@ enum btrfs_block_group_flags {
        BLOCK_GROUP_FLAG_CHUNK_ITEM_INSERTED,
        BLOCK_GROUP_FLAG_ZONE_IS_ACTIVE,
        BLOCK_GROUP_FLAG_ZONED_DATA_RELOC,
+       /* Does the block group need to be added to the free space tree? */
+       BLOCK_GROUP_FLAG_NEEDS_FREE_SPACE,
+       /* Indicate that the block group is placed on a sequential zone */
+       BLOCK_GROUP_FLAG_SEQUENTIAL_ZONE,
 };
 
 enum btrfs_caching_type {
@@ -99,6 +103,12 @@ struct btrfs_block_group {
        u64 cache_generation;
        u64 global_root_id;
 
+       /*
+        * The last committed used bytes of this block group, if the above @used
+        * is still the same as @commit_used, we don't need to update block
+        * group item of this block group.
+        */
+       u64 commit_used;
        /*
         * If the free space extent count exceeds this number, convert the block
         * group to bitmaps.
@@ -202,15 +212,6 @@ struct btrfs_block_group {
        /* Lock for free space tree operations. */
        struct mutex free_space_lock;
 
-       /*
-        * Does the block group need to be added to the free space tree?
-        * Protected by free_space_lock.
-        */
-       int needs_free_space;
-
-       /* Flag indicating this block group is placed on a sequential zone */
-       bool seq_zone;
-
        /*
         * Number of extents in this block group used for swap files.
         * All accesses protected by the spinlock 'lock'.
@@ -251,16 +252,7 @@ static inline bool btrfs_is_block_group_data_only(
 }
 
 #ifdef CONFIG_BTRFS_DEBUG
-static inline int btrfs_should_fragment_free_space(
-               struct btrfs_block_group *block_group)
-{
-       struct btrfs_fs_info *fs_info = block_group->fs_info;
-
-       return (btrfs_test_opt(fs_info, FRAGMENT_METADATA) &&
-               block_group->flags & BTRFS_BLOCK_GROUP_METADATA) ||
-              (btrfs_test_opt(fs_info, FRAGMENT_DATA) &&
-               block_group->flags &  BTRFS_BLOCK_GROUP_DATA);
-}
+int btrfs_should_fragment_free_space(struct btrfs_block_group *block_group);
 #endif
 
 struct btrfs_block_group *btrfs_lookup_first_block_group(