dm mpath: cleanup aspects of hannes' patch
authorMike Snitzer <snitzer@redhat.com>
Thu, 17 Jul 2014 16:32:34 +0000 (12:32 -0400)
committerMike Snitzer <snitzer@redhat.com>
Thu, 17 Jul 2014 22:53:55 +0000 (18:53 -0400)
drivers/md/dm-mpath.c

index 494fd8aed7d2974b5f4fcf74f16e97151543f6c9..50007a7325be1d55f330e1ea60ffa9084d2dd813 100644 (file)
@@ -514,6 +514,9 @@ static int parse_path_selector(struct dm_arg_set *as, struct priority_group *pg,
        return 0;
 }
 
+static void __fail_path(struct pgpath *pgpath, struct multipath *m,
+                       struct path_selector *ps);
+
 static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps,
                               struct dm_target *ti)
 {
@@ -567,7 +570,7 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps
        if (p->path.dev)
                q = bdev_get_queue(p->path.dev->bdev);
 
-       if (q && (m->retain_attached_hw_handler || m->hw_handler_name)) {
+       if (q && m->retain_attached_hw_handler) {
                attached_handler_name = scsi_dh_attached_handler_name(q, GFP_KERNEL);
                if (attached_handler_name) {
                        /*
@@ -625,11 +628,9 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps
                goto bad;
        }
 
-       if (!p->is_active) {
-               ps->type->fail_path(ps, &p->path);
-               p->fail_count++;
-               m->nr_valid_paths--;
-       }
+       if (!p->is_active)
+               __fail_path(p, m, ps);
+
        return p;
 
  bad:
@@ -946,6 +947,15 @@ static void multipath_dtr(struct dm_target *ti)
        free_multipath(m);
 }
 
+static void __fail_path(struct pgpath *pgpath, struct multipath *m,
+                       struct path_selector *ps)
+{
+       ps->type->fail_path(ps, &pgpath->path);
+       pgpath->fail_count++;
+
+       m->nr_valid_paths--;
+}
+
 /*
  * Take a path out of use.
  */
@@ -961,11 +971,8 @@ static int fail_path(struct pgpath *pgpath)
 
        DMWARN("Failing path %s.", pgpath->path.pdev);
 
-       pgpath->pg->ps.type->fail_path(&pgpath->pg->ps, &pgpath->path);
        pgpath->is_active = 0;
-       pgpath->fail_count++;
-
-       m->nr_valid_paths--;
+       __fail_path(pgpath, m, &pgpath->pg->ps);
 
        if (pgpath == m->current_pgpath)
                m->current_pgpath = NULL;
@@ -995,12 +1002,6 @@ static int reinstate_path(struct pgpath *pgpath)
        if (pgpath->is_active)
                goto out;
 
-       if (!pgpath->path.dev) {
-               DMWARN("Cannot reinstate disabled path %s", pgpath->path.pdev);
-               r = -ENODEV;
-               goto out;
-       }
-
        if (!pgpath->pg->ps.type->reinstate_path) {
                DMWARN("Reinstate path not supported by path selector %s",
                       pgpath->pg->ps.type->name);
@@ -1045,11 +1046,11 @@ static int action_dev(struct multipath *m, struct dm_dev *dev,
        struct pgpath *pgpath;
        struct priority_group *pg;
 
-       if (!dev)
-               return 0;
-
        list_for_each_entry(pg, &m->priority_groups, list) {
                list_for_each_entry(pgpath, &pg->pgpaths, list) {
+                       // FIXME: this will _never_ match a removed failed path
+                       // that is now available and attempting to be reinstated
+                       // - shouldn't we be able to reinstate a removed failed path?
                        if (pgpath->path.dev == dev)
                                r = action(pgpath);
                }
@@ -1238,7 +1239,7 @@ static void activate_path(struct work_struct *work)
        struct pgpath *pgpath =
                container_of(work, struct pgpath, activate_path.work);
 
-       if (pgpath->path.dev && pgpath->is_active)
+       if (pgpath->is_active && pgpath->path.dev)
                scsi_dh_activate(bdev_get_queue(pgpath->path.dev->bdev),
                                 pg_init_done, pgpath);
        else