Skip to content

Commit 8d24790

Browse files
bmarzinsMike Snitzer
authored andcommitted
dm-delay: fix workqueue delay_timer race
delay_timer could be pending when delay_dtr() is called. It needs to be shut down before kdelayd_wq is destroyed, so it won't try queueing more work to kdelayd_wq while that's getting destroyed. Also the del_timer_sync() call in delay_presuspend() doesn't protect against the timer getting immediately rearmed by the queued call to flush_delayed_bios(), but there's no real harm if that does happen. timer_delete() is less work, and is basically just as likely to stop a pointless call to flush_delayed_bios(). Fixes: 26b9f22 ("dm: delay target") Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com> Signed-off-by: Mike Snitzer <snitzer@kernel.org>
1 parent 83637d9 commit 8d24790

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/md/dm-delay.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,10 @@ static void delay_dtr(struct dm_target *ti)
154154
{
155155
struct delay_c *dc = ti->private;
156156

157-
if (dc->kdelayd_wq)
157+
if (dc->kdelayd_wq) {
158+
timer_shutdown_sync(&dc->delay_timer);
158159
destroy_workqueue(dc->kdelayd_wq);
160+
}
159161

160162
if (dc->read.dev)
161163
dm_put_device(ti, dc->read.dev);
@@ -335,7 +337,7 @@ static void delay_presuspend(struct dm_target *ti)
335337
mutex_unlock(&delayed_bios_lock);
336338

337339
if (!delay_is_fast(dc))
338-
del_timer_sync(&dc->delay_timer);
340+
timer_delete(&dc->delay_timer);
339341
flush_delayed_bios(dc, true);
340342
}
341343

0 commit comments

Comments
 (0)