Commit ac818646 authored by Alasdair G Kergon's avatar Alasdair G Kergon Committed by Linus Torvalds

dm delay: cleanup

Use setup_timer().
Replace semaphore with mutex.
Signed-off-by: default avatarAlasdair G Kergon <agk@redhat.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 028867ac
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
struct delay_c { struct delay_c {
struct timer_list delay_timer; struct timer_list delay_timer;
struct semaphore timer_lock; struct mutex timer_lock;
struct work_struct flush_expired_bios; struct work_struct flush_expired_bios;
struct list_head delayed_bios; struct list_head delayed_bios;
atomic_t may_delay; atomic_t may_delay;
...@@ -58,12 +58,12 @@ static void handle_delayed_timer(unsigned long data) ...@@ -58,12 +58,12 @@ static void handle_delayed_timer(unsigned long data)
static void queue_timeout(struct delay_c *dc, unsigned long expires) static void queue_timeout(struct delay_c *dc, unsigned long expires)
{ {
down(&dc->timer_lock); mutex_lock(&dc->timer_lock);
if (!timer_pending(&dc->delay_timer) || expires < dc->delay_timer.expires) if (!timer_pending(&dc->delay_timer) || expires < dc->delay_timer.expires)
mod_timer(&dc->delay_timer, expires); mod_timer(&dc->delay_timer, expires);
up(&dc->timer_lock); mutex_unlock(&dc->timer_lock);
} }
static void flush_bios(struct bio *bio) static void flush_bios(struct bio *bio)
...@@ -193,13 +193,11 @@ static int delay_ctr(struct dm_target *ti, unsigned int argc, char **argv) ...@@ -193,13 +193,11 @@ static int delay_ctr(struct dm_target *ti, unsigned int argc, char **argv)
goto bad; goto bad;
} }
init_timer(&dc->delay_timer); setup_timer(&dc->delay_timer, handle_delayed_timer, (unsigned long)dc);
dc->delay_timer.function = handle_delayed_timer;
dc->delay_timer.data = (unsigned long)dc;
INIT_WORK(&dc->flush_expired_bios, flush_expired_bios); INIT_WORK(&dc->flush_expired_bios, flush_expired_bios);
INIT_LIST_HEAD(&dc->delayed_bios); INIT_LIST_HEAD(&dc->delayed_bios);
init_MUTEX(&dc->timer_lock); mutex_init(&dc->timer_lock);
atomic_set(&dc->may_delay, 1); atomic_set(&dc->may_delay, 1);
ti->private = dc; ti->private = dc;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment