diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-30 13:15:36 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-30 13:51:47 -0400 |
commit | 08398d3534d8cdba7d90d2e37ac8bdb3e143dedf (patch) | |
tree | 5958532877643e1ca12e949416dc43360d4b4a86 /fs/bcachefs/movinggc.c | |
parent | 6628827a87075d3f807c974045ed293ac1e8965b (diff) |
bcachefs: Ensure copygc does not spinbcachefs-v6.5
If copygc does no work - finds no fragmented buckets - wait for a bit of
IO to happen.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/movinggc.c')
-rw-r--r-- | fs/bcachefs/movinggc.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/fs/bcachefs/movinggc.c b/fs/bcachefs/movinggc.c index f73b9b7f4bf7..986d7ffbe486 100644 --- a/fs/bcachefs/movinggc.c +++ b/fs/bcachefs/movinggc.c @@ -188,7 +188,8 @@ static int bch2_copygc_get_buckets(struct moving_context *ctxt, noinline static int bch2_copygc(struct moving_context *ctxt, - struct buckets_in_flight *buckets_in_flight) + struct buckets_in_flight *buckets_in_flight, + bool *did_work) { struct btree_trans *trans = ctxt->trans; struct bch_fs *c = trans->c; @@ -224,6 +225,8 @@ static int bch2_copygc(struct moving_context *ctxt, f->bucket.k.gen, data_opts); if (ret) goto err; + + *did_work = true; } err: darray_exit(&buckets); @@ -322,6 +325,8 @@ static int bch2_copygc_thread(void *arg) false); while (!ret && !kthread_should_stop()) { + bool did_work = false; + bch2_trans_unlock(ctxt.trans); cond_resched(); @@ -352,10 +357,20 @@ static int bch2_copygc_thread(void *arg) c->copygc_wait = 0; c->copygc_running = true; - ret = bch2_copygc(&ctxt, &buckets); + ret = bch2_copygc(&ctxt, &buckets, &did_work); c->copygc_running = false; wake_up(&c->copygc_running_wq); + + if (!wait && !did_work) { + u64 min_member_capacity = bch2_min_rw_member_capacity(c); + + if (min_member_capacity == U64_MAX) + min_member_capacity = 128 * 2048; + + bch2_kthread_io_clock_wait(clock, last + (min_member_capacity >> 6), + MAX_SCHEDULE_TIMEOUT); + } } move_buckets_wait(&ctxt, &buckets, true); |