Skip to content

Commit 8b21ac8

Browse files
bmarzinsMike Snitzer
authored andcommitted
dm-delay: remove timer_lock
Instead of manually checking the timer details in queue_timeout(), call timer_reduce() to start the timer or reduce the expiration time. This avoids needing a lock. Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com> Signed-off-by: Mike Snitzer <snitzer@kernel.org>
1 parent c542ee1 commit 8b21ac8

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

drivers/md/dm-delay.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ struct delay_class {
2828

2929
struct delay_c {
3030
struct timer_list delay_timer;
31-
struct mutex timer_lock;
3231
struct mutex process_bios_lock; /* hold while removing bios to be processed from list */
3332
spinlock_t delayed_bios_lock; /* hold on all accesses to delayed_bios list */
3433
struct workqueue_struct *kdelayd_wq;
@@ -60,12 +59,7 @@ static void handle_delayed_timer(struct timer_list *t)
6059

6160
static void queue_timeout(struct delay_c *dc, unsigned long expires)
6261
{
63-
mutex_lock(&dc->timer_lock);
64-
65-
if (!timer_pending(&dc->delay_timer) || expires < dc->delay_timer.expires)
66-
mod_timer(&dc->delay_timer, expires);
67-
68-
mutex_unlock(&dc->timer_lock);
62+
timer_reduce(&dc->delay_timer, expires);
6963
}
7064

7165
static inline bool delay_is_fast(struct delay_c *dc)
@@ -176,7 +170,6 @@ static void delay_dtr(struct dm_target *ti)
176170
kthread_stop(dc->worker);
177171

178172
mutex_destroy(&dc->process_bios_lock);
179-
mutex_destroy(&dc->timer_lock);
180173

181174
kfree(dc);
182175
}
@@ -234,7 +227,6 @@ static int delay_ctr(struct dm_target *ti, unsigned int argc, char **argv)
234227

235228
ti->private = dc;
236229
INIT_LIST_HEAD(&dc->delayed_bios);
237-
mutex_init(&dc->timer_lock);
238230
mutex_init(&dc->process_bios_lock);
239231
spin_lock_init(&dc->delayed_bios_lock);
240232
dc->may_delay = true;

0 commit comments

Comments
 (0)