diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-30 18:15:36 +0100 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-11-04 19:17:11 +0100 |
commit | 1f7056b735d59843faee70f504f71e1fbffc51d8 (patch) | |
tree | 750329cbbdf53b838d4413141c6ab172efdef3c2 /fs/bcachefs/movinggc.c | |
parent | bcachefs: Skip deleted members in member_to_text() (diff) | |
download | linux-1f7056b735d59843faee70f504f71e1fbffc51d8.tar.xz linux-1f7056b735d59843faee70f504f71e1fbffc51d8.zip |
bcachefs: Ensure copygc does not spin
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 | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/fs/bcachefs/movinggc.c b/fs/bcachefs/movinggc.c index f73b9b7f4bf7..e0efa5282a77 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,21 @@ 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_trans_unlock_long(ctxt.trans); + bch2_kthread_io_clock_wait(clock, last + (min_member_capacity >> 6), + MAX_SCHEDULE_TIMEOUT); + } } move_buckets_wait(&ctxt, &buckets, true); |