Commit e77e4efc authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Account for ioclock slop when throttling rebalance thread

This should fix an issue where the rebalance thread was spinning
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 0f9dda47
...@@ -204,18 +204,22 @@ static int bch2_rebalance_thread(void *arg) ...@@ -204,18 +204,22 @@ static int bch2_rebalance_thread(void *arg)
prev_run_time; prev_run_time;
if (w.dev_most_full_percent < 20 && throttle > 0) { if (w.dev_most_full_percent < 20 && throttle > 0) {
r->state = REBALANCE_THROTTLED;
r->throttled_until_iotime = io_start + r->throttled_until_iotime = io_start +
div_u64(w.dev_most_full_capacity * div_u64(w.dev_most_full_capacity *
(20 - w.dev_most_full_percent), (20 - w.dev_most_full_percent),
50); 50);
if (atomic_long_read(&clock->now) + clock->max_slop <
r->throttled_until_iotime) {
r->throttled_until_cputime = start + throttle; r->throttled_until_cputime = start + throttle;
r->state = REBALANCE_THROTTLED;
bch2_kthread_io_clock_wait(clock, bch2_kthread_io_clock_wait(clock,
r->throttled_until_iotime, r->throttled_until_iotime,
throttle); throttle);
continue; continue;
} }
}
/* minimum 1 mb/sec: */ /* minimum 1 mb/sec: */
r->pd.rate.rate = r->pd.rate.rate =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment