]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/bcachefs.h
Update bcachefs sources to ed6b7f81a7 six locks: Disable percpu read lock mode in...
[bcachefs-tools-debian] / libbcachefs / bcachefs.h
index c8620127f1aef8f3ceb081ad634837d885a2b677..f354c9dd0d08f48e30d6202781969fad2020765e 100644 (file)
 #define BCH_WRITE_REF_DEBUG
 #endif
 
+#ifndef dynamic_fault
 #define dynamic_fault(...)             0
-#define race_fault(...)                        0
+#endif
+
+#define race_fault(...)                        dynamic_fault("bcachefs:race")
 
 #define trace_and_count(_c, _name, ...)                                        \
 do {                                                                   \
@@ -442,6 +445,7 @@ enum gc_phase {
        GC_PHASE_BTREE_need_discard,
        GC_PHASE_BTREE_backpointers,
        GC_PHASE_BTREE_bucket_gens,
+       GC_PHASE_BTREE_snapshot_trees,
 
        GC_PHASE_PENDING_DELETE,
 };
@@ -516,9 +520,6 @@ struct bch_dev {
        unsigned                nr_open_buckets;
        unsigned                nr_btree_reserve;
 
-       open_bucket_idx_t       open_buckets_partial[OPEN_BUCKETS_COUNT];
-       open_bucket_idx_t       open_buckets_partial_nr;
-
        size_t                  inc_gen_needs_gc;
        size_t                  inc_gen_really_needs_gc;
        size_t                  buckets_waiting_on_journal;
@@ -629,18 +630,6 @@ struct btree_path_buf {
 
 #define REPLICAS_DELTA_LIST_MAX        (1U << 16)
 
-struct snapshot_t {
-       u32                     parent;
-       u32                     children[2];
-       u32                     subvol; /* Nonzero only if a subvolume points to this node: */
-       u32                     equiv;
-};
-
-typedef struct {
-       u32             subvol;
-       u64             inum;
-} subvol_inum;
-
 #define BCACHEFS_ROOT_SUBVOL_INUM                                      \
        ((subvol_inum) { BCACHEFS_ROOT_SUBVOL,  BCACHEFS_ROOT_INO })
 
@@ -655,7 +644,6 @@ typedef struct {
        x(fallocate)                                                    \
        x(discard)                                                      \
        x(invalidate)                                                   \
-       x(move)                                                         \
        x(delete_dead_snapshots)                                        \
        x(snapshot_delete_pagecache)                                    \
        x(sysfs)
@@ -809,6 +797,12 @@ struct bch_fs {
        struct workqueue_struct *btree_io_complete_wq;
        /* copygc needs its own workqueue for index updates.. */
        struct workqueue_struct *copygc_wq;
+       /*
+        * Use a dedicated wq for write ref holder tasks. Required to avoid
+        * dependency problems with other wq tasks that can block on ref
+        * draining, such as read-only transition.
+        */
+       struct workqueue_struct *write_ref_wq;
 
        /* ALLOCATION */
        struct bch_devs_mask    rw_devs[BCH_DATA_NR];
@@ -859,6 +853,9 @@ struct bch_fs {
        struct open_bucket      open_buckets[OPEN_BUCKETS_COUNT];
        open_bucket_idx_t       open_buckets_hash[OPEN_BUCKETS_COUNT];
 
+       open_bucket_idx_t       open_buckets_partial[OPEN_BUCKETS_COUNT];
+       open_bucket_idx_t       open_buckets_partial_nr;
+
        struct write_point      btree_write_point;
        struct write_point      rebalance_write_point;
 
@@ -922,27 +919,33 @@ struct bch_fs {
 
        mempool_t               large_bkey_pool;
 
+       /* MOVE.C */
+       struct list_head        moving_context_list;
+       struct mutex            moving_context_lock;
+
+       struct list_head        data_progress_list;
+       struct mutex            data_progress_lock;
+
        /* REBALANCE */
        struct bch_fs_rebalance rebalance;
 
        /* COPYGC */
        struct task_struct      *copygc_thread;
-       copygc_heap             copygc_heap;
        struct write_point      copygc_write_point;
+       s64                     copygc_wait_at;
        s64                     copygc_wait;
        bool                    copygc_running;
        wait_queue_head_t       copygc_running_wq;
 
-       /* DATA PROGRESS STATS */
-       struct list_head        data_progress_list;
-       struct mutex            data_progress_lock;
-
        /* STRIPES: */
        GENRADIX(struct stripe) stripes;
        GENRADIX(struct gc_stripe) gc_stripes;
 
+       struct hlist_head       ec_stripes_new[32];
+       spinlock_t              ec_stripes_new_lock;
+
        ec_stripes_heap         ec_stripes_heap;
-       spinlock_t              ec_stripes_heap_lock;
+       struct mutex            ec_stripes_heap_lock;
 
        /* ERASURE CODING */
        struct list_head        ec_stripe_head_list;
@@ -950,20 +953,23 @@ struct bch_fs {
 
        struct list_head        ec_stripe_new_list;
        struct mutex            ec_stripe_new_lock;
+       wait_queue_head_t       ec_stripe_new_wait;
 
        struct work_struct      ec_stripe_create_work;
        u64                     ec_stripe_hint;
 
-       struct bio_set          ec_bioset;
-
        struct work_struct      ec_stripe_delete_work;
-       struct llist_head       ec_stripe_delete_list;
+
+       struct bio_set          ec_bioset;
 
        /* REFLINK */
-       u64                     reflink_hint;
        reflink_gc_table        reflink_gc_table;
        size_t                  reflink_gc_nr;
 
+       /* fs.c */
+       struct list_head        vfs_inodes_list;
+       struct mutex            vfs_inodes_lock;
+
        /* VFS IO PATH - fs-io.c */
        struct bio_set          writepage_bioset;
        struct bio_set          dio_write_bioset;
@@ -1121,4 +1127,7 @@ static inline bool bch2_dev_exists2(const struct bch_fs *c, unsigned dev)
        return dev < c->sb.nr_devices && c->devs[dev];
 }
 
+#define BKEY_PADDED_ONSTACK(key, pad)                          \
+       struct { struct bkey_i key; __u64 key ## _pad[pad]; }
+
 #endif /* _BCACHEFS_H */