Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Benjamin Marzinski and committed by
Mike Snitzer
8b21ac87 c542ee14

+1 -9
+1 -9
drivers/md/dm-delay.c
··· 28 28 29 29 struct delay_c { 30 30 struct timer_list delay_timer; 31 - struct mutex timer_lock; 32 31 struct mutex process_bios_lock; /* hold while removing bios to be processed from list */ 33 32 spinlock_t delayed_bios_lock; /* hold on all accesses to delayed_bios list */ 34 33 struct workqueue_struct *kdelayd_wq; ··· 59 60 60 61 static void queue_timeout(struct delay_c *dc, unsigned long expires) 61 62 { 62 - mutex_lock(&dc->timer_lock); 63 - 64 - if (!timer_pending(&dc->delay_timer) || expires < dc->delay_timer.expires) 65 - mod_timer(&dc->delay_timer, expires); 66 - 67 - mutex_unlock(&dc->timer_lock); 63 + timer_reduce(&dc->delay_timer, expires); 68 64 } 69 65 70 66 static inline bool delay_is_fast(struct delay_c *dc) ··· 170 176 kthread_stop(dc->worker); 171 177 172 178 mutex_destroy(&dc->process_bios_lock); 173 - mutex_destroy(&dc->timer_lock); 174 179 175 180 kfree(dc); 176 181 } ··· 227 234 228 235 ti->private = dc; 229 236 INIT_LIST_HEAD(&dc->delayed_bios); 230 - mutex_init(&dc->timer_lock); 231 237 mutex_init(&dc->process_bios_lock); 232 238 spin_lock_init(&dc->delayed_bios_lock); 233 239 dc->may_delay = true;