bcachefs: Increase size of btree node reserve
authorKent Overstreet <kent.overstreet@gmail.com>
Mon, 15 Jun 2020 21:38:26 +0000 (17:38 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:41 +0000 (17:08 -0400)
Also tweak the allocator to be more aggressive about keeping it full.
The recent changes to make updates to interior nodes transactional (and
thus generate updates to the alloc btree) all put more stress on the
btree node reserves.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/alloc_background.c
fs/bcachefs/bcachefs.h

index 678218ca0feb902df11cdedb112af26513a8c8ba..93ee5cdfbe354571928b66344bd43d98e06b904e 100644 (file)
@@ -501,6 +501,7 @@ static void bch2_bucket_clock_init(struct bch_fs *c, int rw)
 static int wait_buckets_available(struct bch_fs *c, struct bch_dev *ca)
 {
        unsigned long gc_count = c->gc_count;
+       u64 available;
        int ret = 0;
 
        ca->allocator_state = ALLOCATOR_BLOCKED;
@@ -516,9 +517,11 @@ static int wait_buckets_available(struct bch_fs *c, struct bch_dev *ca)
                if (gc_count != c->gc_count)
                        ca->inc_gen_really_needs_gc = 0;
 
-               if ((ssize_t) (dev_buckets_available(c, ca) -
-                              ca->inc_gen_really_needs_gc) >=
-                   (ssize_t) fifo_free(&ca->free_inc))
+               available = max_t(s64, 0, dev_buckets_available(c, ca) -
+                                 ca->inc_gen_really_needs_gc);
+
+               if (available > fifo_free(&ca->free_inc) ||
+                   (available && !fifo_full(&ca->free[RESERVE_BTREE])))
                        break;
 
                up_read(&c->gc_lock);
index d293afcda75a5064d4ba10c64786995824c78344..42e3395884c142d66e96c8a6294904a8ef3f4a49 100644 (file)
@@ -340,7 +340,7 @@ enum bch_time_stats {
 #define BTREE_RESERVE_MAX      (BTREE_MAX_DEPTH + (BTREE_MAX_DEPTH - 1))
 
 /* Size of the freelist we allocate btree nodes from: */
-#define BTREE_NODE_RESERVE     BTREE_RESERVE_MAX
+#define BTREE_NODE_RESERVE     (BTREE_RESERVE_MAX * 4)
 
 #define BTREE_NODE_OPEN_BUCKET_RESERVE (BTREE_RESERVE_MAX * BCH_REPLICAS_MAX)