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: Bart Van Assche <[email protected]>
---
 drivers/md/dm-mpath.c | 10 +++-------
 drivers/md/dm.c       | 10 +++-------
 2 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index ac734e5..8df7b12 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -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)
 {
-       DECLARE_WAITQUEUE(wait, current);
-
-       add_wait_queue(&m->pg_init_wait, &wait);
+       DEFINE_WAIT(wait);
 
        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))
                        break;
 
                io_schedule();
        }
-       set_current_state(TASK_RUNNING);
-
-       remove_wait_queue(&m->pg_init_wait, &wait);
+       finish_wait(&m->pg_init_wait, &wait);
 }
 
 static void flush_multipath_work(struct multipath *m)
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 7cce09e..090ef31 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1938,12 +1938,10 @@ EXPORT_SYMBOL_GPL(dm_put);
 static int dm_wait_for_completion(struct mapped_device *md, int sleep_state)
 {
        int r = 0;
-       DECLARE_WAITQUEUE(wait, current);
-
-       add_wait_queue(&md->wait, &wait);
+       DEFINE_WAIT(wait);
 
        while (1) {
-               set_current_state(sleep_state);
+               prepare_to_wait(&md->wait, &wait, sleep_state);
 
                if (!md_in_flight(md))
                        break;
@@ -1955,9 +1953,7 @@ static int dm_wait_for_completion(struct mapped_device 
*md, int sleep_state)
 
                io_schedule();
        }
-       set_current_state(TASK_RUNNING);
-
-       remove_wait_queue(&md->wait, &wait);
+       finish_wait(&md->wait, &wait);
 
        return r;
 }
-- 
2.9.3

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

Reply via email to