From: Mike Snitzer Date: Thu, 17 Jul 2014 16:32:34 +0000 (-0400) Subject: dm mpath: cleanup aspects of hannes' patch X-Git-Url: https://git.fsl.cs.sunysb.edu/?a=commitdiff_plain;h=8f2abb8bc6301976dda34810f4b155592da09b74;p=linux-dmdedup.git dm mpath: cleanup aspects of hannes' patch --- diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c index 494fd8aed7d..50007a7325b 100644 --- a/drivers/md/dm-mpath.c +++ b/drivers/md/dm-mpath.c @@ -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