]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/btree_types.h
Update bcachefs sources to 8a65cc4951 bcachefs: Improve bch2_dev_freespace_init()
[bcachefs-tools-debian] / libbcachefs / btree_types.h
index af226eed818bc5d0b2072ae95fa70f824ce0d81c..07c509aaa4ef399bf07d3119eac84a61965c4fbb 100644 (file)
@@ -6,7 +6,7 @@
 #include <linux/rhashtable.h>
 #include <linux/six.h>
 
-#include "bkey_methods.h"
+//#include "bkey_methods.h"
 #include "buckets_types.h"
 #include "darray.h"
 #include "journal_types.h"
@@ -160,6 +160,16 @@ struct btree_cache {
        /* Number of elements in live + freeable lists */
        unsigned                used;
        unsigned                reserve;
+       unsigned                freed;
+       unsigned                not_freed_lock_intent;
+       unsigned                not_freed_lock_write;
+       unsigned                not_freed_dirty;
+       unsigned                not_freed_read_in_flight;
+       unsigned                not_freed_write_in_flight;
+       unsigned                not_freed_noevict;
+       unsigned                not_freed_write_blocked;
+       unsigned                not_freed_will_make_reachable;
+       unsigned                not_freed_access_bit;
        atomic_t                dirty;
        struct shrinker         shrink;
 
@@ -278,7 +288,6 @@ struct btree_iter {
        unsigned                snapshot;
 
        struct bpos             pos;
-       struct bpos             pos_after_commit;
        /*
         * Current unpacked key - so that bch2_btree_iter_next()/
         * bch2_btree_iter_next_slot() can correctly advance pos.
@@ -316,7 +325,7 @@ struct btree_key_cache {
 struct bkey_cached_key {
        u32                     btree_id;
        struct bpos             pos;
-} __attribute__((packed, aligned(4)));
+} __packed __aligned(4);
 
 #define BKEY_CACHED_ACCESSED           0
 #define BKEY_CACHED_DIRTY              1
@@ -408,6 +417,7 @@ struct btree_trans {
        bool                    in_traverse_all:1;
        bool                    memory_allocation_failure:1;
        bool                    is_initial_gc:1;
+       bool                    journal_replay_not_finished:1;
        enum bch_errcode        restarted:16;
        u32                     restart_count;
        unsigned long           last_restarted_ip;
@@ -445,6 +455,23 @@ struct btree_trans {
        struct replicas_delta_list *fs_usage_deltas;
 };
 
+#define BCH_BTREE_WRITE_TYPES()                                                \
+       x(initial,              0)                                      \
+       x(init_next_bset,       1)                                      \
+       x(cache_reclaim,        2)                                      \
+       x(journal_reclaim,      3)                                      \
+       x(interior,             4)
+
+enum btree_write_type {
+#define x(t, n) BTREE_WRITE_##t,
+       BCH_BTREE_WRITE_TYPES()
+#undef x
+       BTREE_WRITE_TYPE_NR,
+};
+
+#define BTREE_WRITE_TYPE_MASK  (roundup_pow_of_two(BTREE_WRITE_TYPE_NR) - 1)
+#define BTREE_WRITE_TYPE_BITS  ilog2(roundup_pow_of_two(BTREE_WRITE_TYPE_NR))
+
 #define BTREE_FLAGS()                                                  \
        x(read_in_flight)                                               \
        x(read_error)                                                   \
@@ -464,6 +491,8 @@ struct btree_trans {
        x(never_write)
 
 enum btree_flags {
+       /* First bits for btree node write type */
+       BTREE_NODE_FLAGS_START = BTREE_WRITE_TYPE_BITS - 1,
 #define x(flag)        BTREE_NODE_##flag,
        BTREE_FLAGS()
 #undef x