summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchristophe.varoqui@free.fr <christophe.varoqui@free.fr>2003-12-22 20:52:01 -0800
committerGreg KH <gregkh@suse.de>2005-04-26 21:13:10 -0700
commit88bca8484d88ce543f40d631ec9048795a725c13 (patch)
tree04c835ce14165ebe4e7a2ab7f899e208e3f6c5a9
parent4081da7fe560f0ad173a9836589d6839d9dff9df (diff)
[PATCH] extras multipath update
incremental to 20031222, 2003-12-22 multipath-010 * introduce dm-simplecmd for RESUME & SUSPEND requests * split add_map() in setup_map() & dm-addmap() * setup_map() correctly submits "SUSPEND-RELOAD-RESUME or CREATE" sequences instead of the bogus "RELOAD or CREATE"
-rw-r--r--extras/multipath/ChangeLog4
-rw-r--r--extras/multipath/main.c70
2 files changed, 53 insertions, 21 deletions
diff --git a/extras/multipath/ChangeLog b/extras/multipath/ChangeLog
index dc29400e0e..ee26e06ac0 100644
--- a/extras/multipath/ChangeLog
+++ b/extras/multipath/ChangeLog
@@ -1,4 +1,8 @@
2003-12-22 multipath-010
+ * introduce dm-simplecmd for RESUME & SUSPEND requests
+ * split add_map() in setup_map() & dm-addmap()
+ * setup_map() correctly submits "SUSPEND-RELOAD-RESUME or CREATE"
+ sequences instead of the bogus "RELOAD or CREATE"
* don't print .sg_dev if equal to .dev (2.6) in print_path()
* since the kernel code handles defective paths, remove all
code to cope with them :
diff --git a/extras/multipath/main.c b/extras/multipath/main.c
index c57cd4fe7e..293ee06fbc 100644
--- a/extras/multipath/main.c
+++ b/extras/multipath/main.c
@@ -589,12 +589,50 @@ make_dm_node(char * str)
}
static int
-add_map(struct env * conf, struct path * all_paths,
+dm_simplecmd(int task, const char *name) {
+ int r = 0;
+ struct dm_task *dmt;
+
+ if (!(dmt = dm_task_create(task)))
+ return 0;
+
+ if (!dm_task_set_name(dmt, name))
+ goto out;
+
+ r = dm_task_run(dmt);
+
+ out:
+ dm_task_destroy(dmt);
+ return r;
+}
+
+static int
+dm_addmap(int task, const char *name, const char *params, long size) {
+ struct dm_task *dmt;
+
+ if (!(dmt = dm_task_create(task)))
+ return 0;
+
+ if (!dm_task_set_name(dmt, name))
+ goto addout;
+
+ if (!dm_task_add_target(dmt, 0, size, DM_TARGET, params))
+ goto addout;
+
+ if (!dm_task_run(dmt))
+ goto addout;
+
+ addout:
+ dm_task_destroy(dmt);
+ return 1;
+}
+
+static int
+setup_map(struct env * conf, struct path * all_paths,
struct multipath * mp, int index, int op)
{
char params[255];
char * params_p;
- struct dm_task *dmt;
int i, np;
/* defaults for multipath target */
@@ -602,11 +640,6 @@ add_map(struct env * conf, struct path * all_paths,
char * dm_ps_name = "round-robin";
int dm_ps_nr_args = 0;
- if (!(dmt = dm_task_create(op)))
- return 0;
-
- if (!dm_task_set_name(dmt, mp[index].wwid))
- goto addout;
params_p = &params[0];
np = 0;
@@ -614,11 +647,9 @@ add_map(struct env * conf, struct path * all_paths,
if (0 == all_paths[PINDEX(index,i)].sg_id.scsi_type)
np++;
}
- if (np == 0)
- goto addout;
if (np < 1)
- goto addout;
+ return 0;
params_p += sprintf(params_p, "%i", conf->dm_path_test_int);
@@ -650,7 +681,7 @@ add_map(struct env * conf, struct path * all_paths,
}
if (mp[index].size < 0)
- goto addout;
+ return 0;
if (!conf->quiet) {
if (op == DM_DEVICE_RELOAD)
@@ -661,18 +692,15 @@ add_map(struct env * conf, struct path * all_paths,
mp[index].wwid, mp[index].size, DM_TARGET, params);
}
- if (!dm_task_add_target(dmt, 0, mp[index].size, DM_TARGET, params))
- goto addout;
+ if (op == DM_DEVICE_RELOAD)
+ dm_simplecmd(DM_DEVICE_SUSPEND, mp[index].wwid);
- if (!dm_task_run(dmt))
- goto addout;
+ dm_addmap(op, mp[index].wwid, params, mp[index].size);
+ if (op == DM_DEVICE_RELOAD)
+ dm_simplecmd(DM_DEVICE_RESUME, mp[index].wwid);
make_dm_node(mp[index].wwid);
-
- addout:
- dm_task_destroy(dmt);
- return 1;
}
static int
@@ -802,9 +830,9 @@ main(int argc, char *argv[])
for (k=0; k<=nmp; k++) {
if (map_present(mp[k].wwid)) {
- add_map(&conf, all_paths, mp, k, DM_DEVICE_RELOAD);
+ setup_map(&conf, all_paths, mp, k, DM_DEVICE_RELOAD);
} else {
- add_map(&conf, all_paths, mp, k, DM_DEVICE_CREATE);
+ setup_map(&conf, all_paths, mp, k, DM_DEVICE_CREATE);
}
}