]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - fs/btrfs/block-group.h
Merge tag 'trace-v5.6-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt...
[linux.git] / fs / btrfs / block-group.h
index 9b409676c4b2bf1d50e5b8b7d4cb5f6300781609..107bb557ca8de8ea08d2e0d62613105ae0b95b04 100644 (file)
@@ -12,6 +12,19 @@ enum btrfs_disk_cache_state {
        BTRFS_DC_SETUP,
 };
 
+/*
+ * This describes the state of the block_group for async discard.  This is due
+ * to the two pass nature of it where extent discarding is prioritized over
+ * bitmap discarding.  BTRFS_DISCARD_RESET_CURSOR is set when we are resetting
+ * between lists to prevent contention for discard state variables
+ * (eg. discard_cursor).
+ */
+enum btrfs_discard_state {
+       BTRFS_DISCARD_EXTENTS,
+       BTRFS_DISCARD_BITMAPS,
+       BTRFS_DISCARD_RESET_CURSOR,
+};
+
 /*
  * Control flags for do_chunk_alloc's force field CHUNK_ALLOC_NO_FORCE means to
  * only allocate a chunk if we really need one.
@@ -116,7 +129,13 @@ struct btrfs_block_group {
        /* For read-only block groups */
        struct list_head ro_list;
 
+       /* For discard operations */
        atomic_t trimming;
+       struct list_head discard_list;
+       int discard_index;
+       u64 discard_eligible_time;
+       u64 discard_cursor;
+       enum btrfs_discard_state discard_state;
 
        /* For dirty block groups */
        struct list_head dirty_list;
@@ -158,6 +177,22 @@ struct btrfs_block_group {
        struct btrfs_full_stripe_locks_tree full_stripe_locks_root;
 };
 
+static inline u64 btrfs_block_group_end(struct btrfs_block_group *block_group)
+{
+       return (block_group->start + block_group->length);
+}
+
+static inline bool btrfs_is_block_group_data_only(
+                                       struct btrfs_block_group *block_group)
+{
+       /*
+        * In mixed mode the fragmentation is expected to be high, lowering the
+        * efficiency, so only proper data block groups are considered.
+        */
+       return (block_group->flags & BTRFS_BLOCK_GROUP_DATA) &&
+              !(block_group->flags & BTRFS_BLOCK_GROUP_METADATA);
+}
+
 #ifdef CONFIG_BTRFS_DEBUG
 static inline int btrfs_should_fragment_free_space(
                struct btrfs_block_group *block_group)
@@ -248,4 +283,9 @@ static inline int btrfs_block_group_done(struct btrfs_block_group *cache)
                cache->cached == BTRFS_CACHE_ERROR;
 }
 
+#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
+int btrfs_rmap_block(struct btrfs_fs_info *fs_info, u64 chunk_start,
+                    u64 physical, u64 **logical, int *naddrs, int *stripe_len);
+#endif
+
 #endif /* BTRFS_BLOCK_GROUP_H */