bcachefs: io clock: run timer fns under clock lock
We don't have a way to flush a timer that's executing the callback, and this is simple and limited enough in scope that we can just use the lock instead. Needed for the next patch that adds direct wakeups from the allocator to copygc, where we're now more frequently calling io_timer_del() on an expiring timer. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
b5cbb42dc5
commit
a2d23f3d91
1 changed files with 2 additions and 5 deletions
|
@ -132,14 +132,9 @@ static struct io_timer *get_expired_timer(struct io_clock *clock,
|
|||
{
|
||||
struct io_timer *ret = NULL;
|
||||
|
||||
spin_lock(&clock->timer_lock);
|
||||
|
||||
if (clock->timers.used &&
|
||||
time_after_eq(now, clock->timers.data[0]->expire))
|
||||
heap_pop(&clock->timers, ret, io_timer_cmp, NULL);
|
||||
|
||||
spin_unlock(&clock->timer_lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -148,8 +143,10 @@ void __bch2_increment_clock(struct io_clock *clock, unsigned sectors)
|
|||
struct io_timer *timer;
|
||||
unsigned long now = atomic64_add_return(sectors, &clock->now);
|
||||
|
||||
spin_lock(&clock->timer_lock);
|
||||
while ((timer = get_expired_timer(clock, now)))
|
||||
timer->fn(timer);
|
||||
spin_unlock(&clock->timer_lock);
|
||||
}
|
||||
|
||||
void bch2_io_timers_to_text(struct printbuf *out, struct io_clock *clock)
|
||||
|
|
Loading…
Reference in a new issue