summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2020-04-07 13:49:14 -0400
committerKent Overstreet <kent.overstreet@gmail.com>2020-04-07 15:31:40 -0400
commit410d97f7080579d0060129293166d51c992921ae (patch)
treeb9f2d055016483a138baf6dd70919c0d91ecfd4f
parente4871e8f27b451316fd7d909f0de4fa3d8a3e668 (diff)
bcachefs: Account for ioclock slop when throttling rebalance thread
This should fix an issue where the rebalance thread was spinning Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r--fs/bcachefs/rebalance.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/fs/bcachefs/rebalance.c b/fs/bcachefs/rebalance.c
index ab1934325948..e15a2b1dc5d0 100644
--- a/fs/bcachefs/rebalance.c
+++ b/fs/bcachefs/rebalance.c
@@ -204,17 +204,21 @@ static int bch2_rebalance_thread(void *arg)
prev_run_time;
if (w.dev_most_full_percent < 20 && throttle > 0) {
- r->state = REBALANCE_THROTTLED;
r->throttled_until_iotime = io_start +
div_u64(w.dev_most_full_capacity *
(20 - w.dev_most_full_percent),
50);
- r->throttled_until_cputime = start + throttle;
- bch2_kthread_io_clock_wait(clock,
- r->throttled_until_iotime,
- throttle);
- continue;
+ if (atomic_long_read(&clock->now) + clock->max_slop <
+ r->throttled_until_iotime) {
+ r->throttled_until_cputime = start + throttle;
+ r->state = REBALANCE_THROTTLED;
+
+ bch2_kthread_io_clock_wait(clock,
+ r->throttled_until_iotime,
+ throttle);
+ continue;
+ }
}
/* minimum 1 mb/sec: */