diff options
Diffstat (limited to 'libbcachefs/movinggc.c')
-rw-r--r-- | libbcachefs/movinggc.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/libbcachefs/movinggc.c b/libbcachefs/movinggc.c index f7aa835d..deef4f02 100644 --- a/libbcachefs/movinggc.c +++ b/libbcachefs/movinggc.c @@ -357,18 +357,19 @@ static int bch2_copygc_thread(void *arg) } last = atomic64_read(&clock->now); - wait = max_t(long, 0, bch2_copygc_wait_amount(c) - clock->max_slop); + wait = bch2_copygc_wait_amount(c); - if (wait > 0) { + if (wait > clock->max_slop) { c->copygc_wait_at = last; c->copygc_wait = last + wait; move_buckets_wait(&ctxt, buckets, true); - trace_and_count(c, copygc_wait, c, wait, c->copygc_wait); - bch2_io_clock_schedule_timeout(clock, c->copygc_wait); + trace_and_count(c, copygc_wait, c, wait, last + wait); + bch2_kthread_io_clock_wait(clock, last + wait, + MAX_SCHEDULE_TIMEOUT); continue; } - c->copygc_wait = c->copygc_wait_at = 0; + c->copygc_wait = 0; c->copygc_running = true; ret = bch2_copygc(&ctxt, buckets, &did_work); @@ -383,7 +384,8 @@ static int bch2_copygc_thread(void *arg) min_member_capacity = 128 * 2048; bch2_trans_unlock_long(ctxt.trans); - bch2_io_clock_schedule_timeout(clock, last + (min_member_capacity >> 8)); + bch2_kthread_io_clock_wait(clock, last + (min_member_capacity >> 6), + MAX_SCHEDULE_TIMEOUT); } } @@ -399,10 +401,9 @@ static int bch2_copygc_thread(void *arg) void bch2_copygc_stop(struct bch_fs *c) { - struct task_struct *t = rcu_dereference_protected(c->copygc_thread, true); - if (t) { - kthread_stop(t); - put_task_struct(t); + if (c->copygc_thread) { + kthread_stop(c->copygc_thread); + put_task_struct(c->copygc_thread); } c->copygc_thread = NULL; } @@ -429,8 +430,8 @@ int bch2_copygc_start(struct bch_fs *c) get_task_struct(t); - rcu_assign_pointer(c->copygc_thread, t); - wake_up_process(t); + c->copygc_thread = t; + wake_up_process(c->copygc_thread); return 0; } |