Skip to content

Commit a2d23f3

Browse files
author
Kent Overstreet
committed
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 <[email protected]>
1 parent b5cbb42 commit a2d23f3

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

fs/bcachefs/clock.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,9 @@ static struct io_timer *get_expired_timer(struct io_clock *clock,
132132
{
133133
struct io_timer *ret = NULL;
134134

135-
spin_lock(&clock->timer_lock);
136-
137135
if (clock->timers.used &&
138136
time_after_eq(now, clock->timers.data[0]->expire))
139137
heap_pop(&clock->timers, ret, io_timer_cmp, NULL);
140-
141-
spin_unlock(&clock->timer_lock);
142-
143138
return ret;
144139
}
145140

@@ -148,8 +143,10 @@ void __bch2_increment_clock(struct io_clock *clock, unsigned sectors)
148143
struct io_timer *timer;
149144
unsigned long now = atomic64_add_return(sectors, &clock->now);
150145

146+
spin_lock(&clock->timer_lock);
151147
while ((timer = get_expired_timer(clock, now)))
152148
timer->fn(timer);
149+
spin_unlock(&clock->timer_lock);
153150
}
154151

155152
void bch2_io_timers_to_text(struct printbuf *out, struct io_clock *clock)

0 commit comments

Comments
 (0)