atomic: use <linux/atomic.h>
[linux-2.6.git] / drivers / md / dm-mpath.c
index b82d288..c354701 100644 (file)
@@ -19,7 +19,7 @@
 #include <linux/time.h>
 #include <linux/workqueue.h>
 #include <scsi/scsi_dh.h>
-#include <asm/atomic.h>
+#include <linux/atomic.h>
 
 #define DM_MSG_PREFIX "multipath"
 #define MESG_STR(x) x, sizeof(x)
@@ -844,8 +844,8 @@ static int multipath_ctr(struct dm_target *ti, unsigned int argc,
 {
        /* target parameters */
        static struct param _params[] = {
-               {1, 1024, "invalid number of priority groups"},
-               {1, 1024, "invalid initial priority group number"},
+               {0, 1024, "invalid number of priority groups"},
+               {0, 1024, "invalid initial priority group number"},
        };
 
        int r;
@@ -879,6 +879,13 @@ static int multipath_ctr(struct dm_target *ti, unsigned int argc,
        if (r)
                goto bad;
 
+       if ((!m->nr_priority_groups && next_pg_num) ||
+           (m->nr_priority_groups && !next_pg_num)) {
+               ti->error = "invalid initial priority group";
+               r = -EINVAL;
+               goto bad;
+       }
+
        /* parse the priority groups */
        while (as.argc) {
                struct priority_group *pg;
@@ -1065,7 +1072,7 @@ out:
 static int action_dev(struct multipath *m, struct dm_dev *dev,
                      action_fn action)
 {
-       int r = 0;
+       int r = -EINVAL;
        struct pgpath *pgpath;
        struct priority_group *pg;
 
@@ -1283,24 +1290,22 @@ static int do_end_io(struct multipath *m, struct request *clone,
        if (!error && !clone->errors)
                return 0;       /* I/O complete */
 
-       if (error == -EOPNOTSUPP)
-               return error;
-
-       if (clone->cmd_flags & REQ_DISCARD)
-               /*
-                * Pass all discard request failures up.
-                * FIXME: only fail_path if the discard failed due to a
-                * transport problem.  This requires precise understanding
-                * of the underlying failure (e.g. the SCSI sense).
-                */
+       if (error == -EOPNOTSUPP || error == -EREMOTEIO || error == -EILSEQ)
                return error;
 
        if (mpio->pgpath)
                fail_path(mpio->pgpath);
 
        spin_lock_irqsave(&m->lock, flags);
-       if (!m->nr_valid_paths && !m->queue_if_no_path && !__must_push_back(m))
-               r = -EIO;
+       if (!m->nr_valid_paths) {
+               if (!m->queue_if_no_path) {
+                       if (!__must_push_back(m))
+                               r = -EIO;
+               } else {
+                       if (error == -EBADE)
+                               r = error;
+               }
+       }
        spin_unlock_irqrestore(&m->lock, flags);
 
        return r;
@@ -1417,7 +1422,7 @@ static int multipath_status(struct dm_target *ti, status_type_t type,
        else if (m->current_pg)
                pg_num = m->current_pg->pg_num;
        else
-                       pg_num = 1;
+               pg_num = (m->nr_priority_groups ? 1 : 0);
 
        DMEMIT("%u ", pg_num);
 
@@ -1671,7 +1676,7 @@ out:
  *---------------------------------------------------------------*/
 static struct target_type multipath_target = {
        .name = "multipath",
-       .version = {1, 2, 0},
+       .version = {1, 3, 0},
        .module = THIS_MODULE,
        .ctr = multipath_ctr,
        .dtr = multipath_dtr,