Commit 9f4c3f87 authored by Bart Van Assche's avatar Bart Van Assche Committed by Mike Snitzer

dm: convert wait loops to use autoremove_wake_function()

Use autoremove_wake_function() instead of default_wake_function()
to make the dm wait loops more similar to other wait loops in the
kernel.  This patch does not change any functionality.
Signed-off-by: default avatarBart Van Assche <bart.vanassche@sandisk.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent e3fabdfd
...@@ -1193,21 +1193,17 @@ static int multipath_ctr(struct dm_target *ti, unsigned argc, char **argv) ...@@ -1193,21 +1193,17 @@ static int multipath_ctr(struct dm_target *ti, unsigned argc, char **argv)
static void multipath_wait_for_pg_init_completion(struct multipath *m) static void multipath_wait_for_pg_init_completion(struct multipath *m)
{ {
DECLARE_WAITQUEUE(wait, current); DEFINE_WAIT(wait);
add_wait_queue(&m->pg_init_wait, &wait);
while (1) { while (1) {
set_current_state(TASK_UNINTERRUPTIBLE); prepare_to_wait(&m->pg_init_wait, &wait, TASK_UNINTERRUPTIBLE);
if (!atomic_read(&m->pg_init_in_progress)) if (!atomic_read(&m->pg_init_in_progress))
break; break;
io_schedule(); io_schedule();
} }
set_current_state(TASK_RUNNING); finish_wait(&m->pg_init_wait, &wait);
remove_wait_queue(&m->pg_init_wait, &wait);
} }
static void flush_multipath_work(struct multipath *m) static void flush_multipath_work(struct multipath *m)
......
...@@ -1944,12 +1944,10 @@ EXPORT_SYMBOL_GPL(dm_put); ...@@ -1944,12 +1944,10 @@ EXPORT_SYMBOL_GPL(dm_put);
static int dm_wait_for_completion(struct mapped_device *md, long task_state) static int dm_wait_for_completion(struct mapped_device *md, long task_state)
{ {
int r = 0; int r = 0;
DECLARE_WAITQUEUE(wait, current); DEFINE_WAIT(wait);
add_wait_queue(&md->wait, &wait);
while (1) { while (1) {
set_current_state(task_state); prepare_to_wait(&md->wait, &wait, task_state);
if (!md_in_flight(md)) if (!md_in_flight(md))
break; break;
...@@ -1961,9 +1959,7 @@ static int dm_wait_for_completion(struct mapped_device *md, long task_state) ...@@ -1961,9 +1959,7 @@ static int dm_wait_for_completion(struct mapped_device *md, long task_state)
io_schedule(); io_schedule();
} }
set_current_state(TASK_RUNNING); finish_wait(&md->wait, &wait);
remove_wait_queue(&md->wait, &wait);
return r; return r;
} }
......
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