]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/alloc_types.h
Update bcachefs sources to 717b356d1d bcachefs: Convert journal validation to bkey_in...
[bcachefs-tools-debian] / libbcachefs / alloc_types.h
index e66a85f7a9a3d954cdac1d32a793e2fd380613d0..804a843f23c16ea4100baba6690d589ab98368e1 100644 (file)
@@ -9,27 +9,31 @@
 #include "fifo.h"
 
 struct bucket_alloc_state {
-       u64     cur_bucket;
        u64     buckets_seen;
        u64     skipped_open;
        u64     skipped_need_journal_commit;
+       u64     skipped_nocow;
        u64     skipped_nouse;
 };
 
-struct ec_bucket_buf;
-
-#define BCH_ALLOC_RESERVES()           \
-       x(btree_movinggc)               \
+#define BCH_WATERMARKS()               \
+       x(stripe)                       \
+       x(normal)                       \
+       x(copygc)                       \
        x(btree)                        \
-       x(movinggc)                     \
-       x(none)
+       x(btree_copygc)                 \
+       x(reclaim)
 
-enum alloc_reserve {
-#define x(name)        RESERVE_##name,
-       BCH_ALLOC_RESERVES()
+enum bch_watermark {
+#define x(name)        BCH_WATERMARK_##name,
+       BCH_WATERMARKS()
 #undef x
+       BCH_WATERMARK_NR,
 };
 
+#define BCH_WATERMARK_BITS     3
+#define BCH_WATERMARK_MASK     ~(~0U << BCH_WATERMARK_BITS)
+
 #define OPEN_BUCKETS_COUNT     1024
 
 #define WRITE_POINT_HASH_NR    32
@@ -51,10 +55,9 @@ struct open_bucket {
         * the block in the stripe this open_bucket corresponds to:
         */
        u8                      ec_idx;
-       enum bch_data_type      data_type:8;
+       enum bch_data_type      data_type:6;
        unsigned                valid:1;
        unsigned                on_partial_list:1;
-       unsigned                alloc_reserve:3;
 
        u8                      dev;
        u8                      gen;
@@ -74,23 +77,46 @@ struct dev_stripe_state {
        u64                     next_alloc[BCH_SB_MEMBERS_MAX];
 };
 
+#define WRITE_POINT_STATES()           \
+       x(stopped)                      \
+       x(waiting_io)                   \
+       x(waiting_work)                 \
+       x(running)
+
+enum write_point_state {
+#define x(n)   WRITE_POINT_##n,
+       WRITE_POINT_STATES()
+#undef x
+       WRITE_POINT_STATE_NR
+};
+
 struct write_point {
-       struct hlist_node       node;
-       struct mutex            lock;
-       u64                     last_used;
-       unsigned long           write_point;
-       enum bch_data_type      data_type;
+       struct {
+               struct hlist_node       node;
+               struct mutex            lock;
+               u64                     last_used;
+               unsigned long           write_point;
+               enum bch_data_type      data_type;
+
+               /* calculated based on how many pointers we're actually going to use: */
+               unsigned                sectors_free;
+
+               struct open_buckets     ptrs;
+               struct dev_stripe_state stripe;
 
-       /* calculated based on how many pointers we're actually going to use: */
-       unsigned                sectors_free;
+               u64                     sectors_allocated;
+       } __attribute__((__aligned__(SMP_CACHE_BYTES)));
 
-       struct open_buckets     ptrs;
-       struct dev_stripe_state stripe;
+       struct {
+               struct work_struct      index_update_work;
 
-       struct work_struct      index_update_work;
+               struct list_head        writes;
+               spinlock_t              writes_lock;
 
-       struct list_head        writes;
-       spinlock_t              writes_lock;
+               enum write_point_state  state;
+               u64                     last_state_change;
+               u64                     time[WRITE_POINT_STATE_NR];
+       } __attribute__((__aligned__(SMP_CACHE_BYTES)));
 };
 
 struct write_point_specifier {