dm mpath: really fix lockdep warning
authorHannes Reinecke <hare@suse.de>
Mon, 26 May 2014 12:45:39 +0000 (14:45 +0200)
committerMike Snitzer <snitzer@redhat.com>
Tue, 27 May 2014 14:46:01 +0000 (10:46 -0400)
lockdep complains about a circular locking.  And indeed, we need to
release the lock before calling dm_table_run_md_queue_async().

As such, commit 4cdd2ad ("dm mpath: fix lock order inconsistency in
multipath_ioctl") must also be reverted in addition to fixing the
lock order in the other dm_table_run_md_queue_async() callers.

Reported-by: Bart van Assche <bvanassche@acm.org>
Tested-by: Bart van Assche <bvanassche@acm.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm-mpath.c

index fa0f6cbd6a41283d21b1286558eb4764e2c06b4b..ebfa411d1a7d4b0193596b515f7086639057b5d0 100644 (file)
@@ -445,11 +445,11 @@ static int queue_if_no_path(struct multipath *m, unsigned queue_if_no_path,
        else
                m->saved_queue_if_no_path = queue_if_no_path;
        m->queue_if_no_path = queue_if_no_path;
-       if (!m->queue_if_no_path)
-               dm_table_run_md_queue_async(m->ti->table);
-
        spin_unlock_irqrestore(&m->lock, flags);
 
+       if (!queue_if_no_path)
+               dm_table_run_md_queue_async(m->ti->table);
+
        return 0;
 }
 
@@ -954,7 +954,7 @@ out:
  */
 static int reinstate_path(struct pgpath *pgpath)
 {
-       int r = 0;
+       int r = 0, run_queue = 0;
        unsigned long flags;
        struct multipath *m = pgpath->pg->m;
 
@@ -978,7 +978,7 @@ static int reinstate_path(struct pgpath *pgpath)
 
        if (!m->nr_valid_paths++) {
                m->current_pgpath = NULL;
-               dm_table_run_md_queue_async(m->ti->table);
+               run_queue = 1;
        } else if (m->hw_handler_name && (m->current_pg == pgpath->pg)) {
                if (queue_work(kmpath_handlerd, &pgpath->activate_path.work))
                        m->pg_init_in_progress++;
@@ -991,6 +991,8 @@ static int reinstate_path(struct pgpath *pgpath)
 
 out:
        spin_unlock_irqrestore(&m->lock, flags);
+       if (run_queue)
+               dm_table_run_md_queue_async(m->ti->table);
 
        return r;
 }
@@ -1566,8 +1568,8 @@ static int multipath_ioctl(struct dm_target *ti, unsigned int cmd,
                }
                if (m->pg_init_required)
                        __pg_init_all_paths(m);
-               dm_table_run_md_queue_async(m->ti->table);
                spin_unlock_irqrestore(&m->lock, flags);
+               dm_table_run_md_queue_async(m->ti->table);
        }
 
        return r ? : __blkdev_driver_ioctl(bdev, mode, cmd, arg);