]> err.no Git - linux-2.6/blobdiff - drivers/md/dm-mpath.c
cpuidle: make sysfs attributes sysdev class attributes
[linux-2.6] / drivers / md / dm-mpath.c
index 9b16788118d2e3c662483c9013f907a87030b125..71dd65aa31b696aa37a894b0d7bd9cbdc2034123 100644 (file)
@@ -7,7 +7,6 @@
 
 #include "dm.h"
 #include "dm-path-selector.h"
-#include "dm-hw-handler.h"
 #include "dm-bio-list.h"
 #include "dm-bio-record.h"
 #include "dm-uevent.h"
@@ -148,9 +147,12 @@ static struct priority_group *alloc_priority_group(void)
 static void free_pgpaths(struct list_head *pgpaths, struct dm_target *ti)
 {
        struct pgpath *pgpath, *tmp;
+       struct multipath *m = ti->private;
 
        list_for_each_entry_safe(pgpath, tmp, pgpaths, list) {
                list_del(&pgpath->list);
+               if (m->hw_handler_name)
+                       scsi_dh_detach(bdev_get_queue(pgpath->path.dev->bdev));
                dm_put_device(ti, pgpath->path.dev);
                free_pgpath(pgpath);
        }
@@ -526,8 +528,10 @@ static int parse_path_selector(struct arg_set *as, struct priority_group *pg,
        }
 
        r = read_param(_params, shift(as), &ps_argc, &ti->error);
-       if (r)
+       if (r) {
+               dm_put_path_selector(pst);
                return -EINVAL;
+       }
 
        r = pst->create(&pg->ps, ps_argc, as->argv);
        if (r) {
@@ -547,6 +551,7 @@ static struct pgpath *parse_path(struct arg_set *as, struct path_selector *ps,
 {
        int r;
        struct pgpath *p;
+       struct multipath *m = ti->private;
 
        /* we need at least a path arg */
        if (as->argc < 1) {
@@ -565,6 +570,15 @@ static struct pgpath *parse_path(struct arg_set *as, struct path_selector *ps,
                goto bad;
        }
 
+       if (m->hw_handler_name) {
+               r = scsi_dh_attach(bdev_get_queue(p->path.dev->bdev),
+                                  m->hw_handler_name);
+               if (r < 0) {
+                       dm_put_device(ti, p->path.dev);
+                       goto bad;
+               }
+       }
+
        r = ps->type->add_path(ps, &p->path, as->argc, as->argv, &ti->error);
        if (r) {
                dm_put_device(ti, p->path.dev);
@@ -624,8 +638,10 @@ static struct priority_group *parse_priority_group(struct arg_set *as,
                struct pgpath *pgpath;
                struct arg_set path_args;
 
-               if (as->argc < nr_params)
+               if (as->argc < nr_params) {
+                       ti->error = "not enough path parameters";
                        goto bad;
+               }
 
                path_args.argc = nr_params;
                path_args.argv = as->argv;
@@ -665,6 +681,8 @@ static int parse_hw_handler(struct arg_set *as, struct multipath *m)
        request_module("scsi_dh_%s", m->hw_handler_name);
        if (scsi_dh_handler_exist(m->hw_handler_name) == 0) {
                ti->error = "unknown hardware handler type";
+               kfree(m->hw_handler_name);
+               m->hw_handler_name = NULL;
                return -EINVAL;
        }
        consume(as, hw_argc - 1);
@@ -866,7 +884,7 @@ static int reinstate_path(struct pgpath *pgpath)
        if (pgpath->path.is_active)
                goto out;
 
-       if (!pgpath->pg->ps.type) {
+       if (!pgpath->pg->ps.type->reinstate_path) {
                DMWARN("Reinstate path not supported by path selector %s",
                       pgpath->pg->ps.type->name);
                r = -EINVAL;
@@ -1008,44 +1026,6 @@ static int pg_init_limit_reached(struct multipath *m, struct pgpath *pgpath)
        return limit_reached;
 }
 
-/*
- * pg_init must call this when it has completed its initialisation
- */
-void dm_pg_init_complete(struct dm_path *path, unsigned err_flags)
-{
-       struct pgpath *pgpath = path_to_pgpath(path);
-       struct priority_group *pg = pgpath->pg;
-       struct multipath *m = pg->m;
-       unsigned long flags;
-
-       /*
-        * If requested, retry pg_init until maximum number of retries exceeded.
-        * If retry not requested and PG already bypassed, always fail the path.
-        */
-       if (err_flags & MP_RETRY) {
-               if (pg_init_limit_reached(m, pgpath))
-                       err_flags |= MP_FAIL_PATH;
-       } else if (err_flags && pg->bypassed)
-               err_flags |= MP_FAIL_PATH;
-
-       if (err_flags & MP_FAIL_PATH)
-               fail_path(pgpath);
-
-       if (err_flags & MP_BYPASS_PG)
-               bypass_pg(m, pg, 1);
-
-       spin_lock_irqsave(&m->lock, flags);
-       if (err_flags & ~MP_RETRY) {
-               m->current_pgpath = NULL;
-               m->current_pg = NULL;
-       } else if (!m->pg_init_required)
-               m->queue_io = 0;
-
-       m->pg_init_in_progress = 0;
-       queue_work(kmultipathd, &m->process_queued_ios);
-       spin_unlock_irqrestore(&m->lock, flags);
-}
-
 static void pg_init_done(struct dm_path *path, int errors)
 {
        struct pgpath *pgpath = path_to_pgpath(path);
@@ -1497,8 +1477,6 @@ static void __exit dm_multipath_exit(void)
        kmem_cache_destroy(_mpio_cache);
 }
 
-EXPORT_SYMBOL_GPL(dm_pg_init_complete);
-
 module_init(dm_multipath_init);
 module_exit(dm_multipath_exit);