]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/bcachefs.h
Update bcachefs sources to 8d3fc97ca3 bcachefs: Fixes for building in userspace
[bcachefs-tools-debian] / libbcachefs / bcachefs.h
index 53e7b5a0bea9c3725e79b911902bd79d1f72b541..8a43fcfa0a8c2505aa6cfaf20d0e733afb393360 100644 (file)
  *
  * BTREE NODES:
  *
- * Our unit of allocation is a bucket, and we we can't arbitrarily allocate and
+ * Our unit of allocation is a bucket, and we can't arbitrarily allocate and
  * free smaller than a bucket - so, that's how big our btree nodes are.
  *
  * (If buckets are really big we'll only use part of the bucket for a btree node
@@ -226,9 +226,15 @@ do {                                                                       \
         dynamic_fault("bcachefs:meta:write:" name)
 
 #ifdef __KERNEL__
-#define bch2_fmt(_c, fmt)              "bcachefs (%s): " fmt "\n", ((_c)->name)
+#define BCACHEFS_LOG_PREFIX
+#endif
+
+#ifdef BCACHEFS_LOG_PREFIX
+#define bch2_log_msg(_c, fmt)          "bcachefs (%s): " fmt, ((_c)->name)
+#define bch2_fmt(_c, fmt)              bch2_log_msg(_c, fmt "\n")
 #define bch2_fmt_inum(_c, _inum, fmt)  "bcachefs (%s inum %llu): " fmt "\n", ((_c)->name), (_inum)
 #else
+#define bch2_log_msg(_c, fmt)          fmt
 #define bch2_fmt(_c, fmt)              fmt "\n"
 #define bch2_fmt_inum(_c, _inum, fmt)  "inum %llu: " fmt "\n", (_inum)
 #endif
@@ -280,7 +286,7 @@ do {                                                                        \
                "When reading btree nodes, read all replicas and "      \
                "compare them")
 
-/* Parameters that should only be compiled in in debug mode: */
+/* Parameters that should only be compiled in debug mode: */
 #define BCH_DEBUG_PARAMS_DEBUG()                                       \
        BCH_DEBUG_PARAM(expensive_debug_checks,                         \
                "Enables various runtime debugging checks that "        \
@@ -557,13 +563,13 @@ struct journal_seq_blacklist_table {
 
 struct journal_keys {
        struct journal_key {
+               u64             journal_seq;
+               u32             journal_offset;
                enum btree_id   btree_id:8;
                unsigned        level:8;
                bool            allocated;
                bool            overwritten;
                struct bkey_i   *k;
-               u32             journal_seq;
-               u32             journal_offset;
        }                       *d;
        /*
         * Gap buffer: instead of all the empty space in the array being at the
@@ -573,7 +579,6 @@ struct journal_keys {
        size_t                  gap;
        size_t                  nr;
        size_t                  size;
-       u64                     journal_seq_base;
 };
 
 struct btree_path_buf {
@@ -597,6 +602,23 @@ typedef struct {
 #define BCACHEFS_ROOT_SUBVOL_INUM                                      \
        ((subvol_inum) { BCACHEFS_ROOT_SUBVOL,  BCACHEFS_ROOT_INO })
 
+#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(BTREE_WRITE_TYPE_MASK)
+
 struct bch_fs {
        struct closure          cl;
 
@@ -706,6 +728,13 @@ struct bch_fs {
        struct workqueue_struct *btree_interior_update_worker;
        struct work_struct      btree_interior_update_work;
 
+       /* btree_io.c: */
+       spinlock_t              btree_write_error_lock;
+       struct btree_write_stats {
+               atomic64_t      nr;
+               atomic64_t      bytes;
+       }                       btree_write_stats[BTREE_WRITE_TYPE_NR];
+
        /* btree_iter.c: */
        struct mutex            btree_trans_lock;
        struct list_head        btree_trans_list;
@@ -813,7 +842,6 @@ struct bch_fs {
        struct mutex            gc_gens_lock;
 
        /* IO PATH */
-       struct semaphore        io_in_flight;
        struct bio_set          bio_read;
        struct bio_set          bio_read_split;
        struct bio_set          bio_write;
@@ -881,11 +909,6 @@ struct bch_fs {
        struct bio_set          dio_write_bioset;
        struct bio_set          dio_read_bioset;
 
-
-       atomic64_t              btree_writes_nr;
-       atomic64_t              btree_writes_sectors;
-       spinlock_t              btree_write_error_lock;
-
        /* ERRORS */
        struct list_head        fsck_errors;
        struct mutex            fsck_error_lock;
@@ -930,7 +953,6 @@ struct bch_fs {
 
        struct time_stats       times[BCH_TIME_STAT_NR];
 
-       const char              *btree_transaction_fns[BCH_TRANSACTIONS_NR];
        struct btree_transaction_stats btree_transaction_stats[BCH_TRANSACTIONS_NR];
 };