diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-07-05 09:14:14 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-07-05 09:16:45 -0400 |
commit | 8b06995115a8ade5e0b154311b771279ff97317f (patch) | |
tree | eecd3c3cf493e9441a6b1ed0c0061bce045b7a66 /libbcachefs/movinggc.c | |
parent | d061c7ea11672438ad339766ef1a73702c0778ab (diff) |
Update bcachefs sources to 2be6fc9b111c bcachefs: bch2_gc_btree() should not use btree_root_lock
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'libbcachefs/movinggc.c')
-rw-r--r-- | libbcachefs/movinggc.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/libbcachefs/movinggc.c b/libbcachefs/movinggc.c index eb49dd04..f7aa835d 100644 --- a/libbcachefs/movinggc.c +++ b/libbcachefs/movinggc.c @@ -290,18 +290,23 @@ unsigned long bch2_copygc_wait_amount(struct bch_fs *c) void bch2_copygc_wait_to_text(struct printbuf *out, struct bch_fs *c) { - prt_printf(out, "Currently waiting for: "); + printbuf_tabstop_push(out, 32); + prt_printf(out, "running:\t%u\n", c->copygc_running); + prt_printf(out, "copygc_wait:\t%llu\n", c->copygc_wait); + prt_printf(out, "copygc_wait_at:\t%llu\n", c->copygc_wait_at); + + prt_printf(out, "Currently waiting for:\t"); prt_human_readable_u64(out, max(0LL, c->copygc_wait - atomic64_read(&c->io_clock[WRITE].now)) << 9); prt_newline(out); - prt_printf(out, "Currently waiting since: "); + prt_printf(out, "Currently waiting since:\t"); prt_human_readable_u64(out, max(0LL, atomic64_read(&c->io_clock[WRITE].now) - c->copygc_wait_at) << 9); prt_newline(out); - prt_printf(out, "Currently calculated wait: "); + prt_printf(out, "Currently calculated wait:\t"); prt_human_readable_u64(out, bch2_copygc_wait_amount(c)); prt_newline(out); } @@ -352,19 +357,18 @@ static int bch2_copygc_thread(void *arg) } last = atomic64_read(&clock->now); - wait = bch2_copygc_wait_amount(c); + wait = max_t(long, 0, bch2_copygc_wait_amount(c) - clock->max_slop); - if (wait > clock->max_slop) { + if (wait > 0) { c->copygc_wait_at = last; c->copygc_wait = last + wait; move_buckets_wait(&ctxt, buckets, true); - trace_and_count(c, copygc_wait, c, wait, last + wait); - bch2_kthread_io_clock_wait(clock, last + wait, - MAX_SCHEDULE_TIMEOUT); + trace_and_count(c, copygc_wait, c, wait, c->copygc_wait); + bch2_io_clock_schedule_timeout(clock, c->copygc_wait); continue; } - c->copygc_wait = 0; + c->copygc_wait = c->copygc_wait_at = 0; c->copygc_running = true; ret = bch2_copygc(&ctxt, buckets, &did_work); @@ -379,8 +383,7 @@ static int bch2_copygc_thread(void *arg) 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); + bch2_io_clock_schedule_timeout(clock, last + (min_member_capacity >> 8)); } } @@ -396,9 +399,10 @@ static int bch2_copygc_thread(void *arg) void bch2_copygc_stop(struct bch_fs *c) { - if (c->copygc_thread) { - kthread_stop(c->copygc_thread); - put_task_struct(c->copygc_thread); + struct task_struct *t = rcu_dereference_protected(c->copygc_thread, true); + if (t) { + kthread_stop(t); + put_task_struct(t); } c->copygc_thread = NULL; } @@ -425,8 +429,8 @@ int bch2_copygc_start(struct bch_fs *c) get_task_struct(t); - c->copygc_thread = t; - wake_up_process(c->copygc_thread); + rcu_assign_pointer(c->copygc_thread, t); + wake_up_process(t); return 0; } |