*/
/* hardware vendor specifics : add support for new models below */
+
+/* this one get EVPD page 0x83 off 8 */
+/* tested ok with StorageWorks */
static int
-get_storageworks_wwid(int fd, char *str)
+get_evpd_wwid(int fd, char *str)
{
char buff[64];
static int
get_unique_id(int fd, struct path * mypath)
{
- if (strncmp(mypath->product_id, "HSV110 (C)COMPAQ", 16) == 0 ||
- strncmp(mypath->product_id, "HSG80 ", 16) == 0) {
- get_storageworks_wwid(fd, mypath->wwid);
- return 0;
+ int i;
+ static struct {
+ char * vendor;
+ char * product;
+ int (*getuid) (int fd, char * wwid);
+ } wlist[] = {
+ {"COMPAQ ", "HSV110 (C)COMPAQ", &get_evpd_wwid},
+ {"COMPAQ ", "MSA1000 ", &get_evpd_wwid},
+ {"COMPAQ ", "MSA1000 VOLUME ", &get_evpd_wwid},
+ {"DEC ", "HSG80 ", &get_evpd_wwid},
+ {"HP ", "HSV100 ", &get_evpd_wwid},
+ {"HP ", "A6189A ", &get_evpd_wwid},
+ {"HP ", "OPEN- ", &get_evpd_wwid},
+ {"DDN ", "SAN DataDirector", &get_evpd_wwid},
+ {"FSC ", "CentricStor ", &get_evpd_wwid},
+ {"HITACHI ", "DF400 ", &get_evpd_wwid},
+ {"HITACHI ", "DF500 ", &get_evpd_wwid},
+ {"HITACHI ", "DF600 ", &get_evpd_wwid},
+ {"IBM ", "ProFibre 4000R ", &get_evpd_wwid},
+ {"SGI ", "TP9100 ", &get_evpd_wwid},
+ {"SGI ", "TP9300 ", &get_evpd_wwid},
+ {"SGI ", "TP9400 ", &get_evpd_wwid},
+ {"SGI ", "TP9500 ", &get_evpd_wwid},
+ {NULL, NULL, NULL},
+ };
+
+ for (i = 0; wlist[i].vendor; i++) {
+ if (strncmp(mypath->vendor_id, wlist[i].vendor, 8) == 0 &&
+ strncmp(mypath->product_id, wlist[i].product, 16) == 0) {
+ wlist[i].getuid(fd, mypath->wwid);
+ return 0;
+ }
}
-
return 1;
}
strcpy(str2, ++p);
}
+static int
+blacklist (char * dev) {
+ int i;
+ static struct {
+ char * headstr;
+ int lengh;
+ } blist[] = {
+ {"cciss", 5},
+ {"hd", 2},
+ {"md", 2},
+ {"dm", 2},
+ {"sr", 2},
+ {"scd", 3},
+ {"ram", 3},
+ {"raw", 3},
+ {NULL, 0},
+ };
+
+ for (i = 0; blist[i].lengh; i++) {
+ if (strncmp(dev, blist[i].headstr, blist[i].lengh) == 0)
+ return 1;
+ }
+ return 0;
+}
+
static int
get_all_paths_sysfs(struct env * conf, struct path * all_paths)
{
sdir = sysfs_open_directory(block_path);
sysfs_read_directory(sdir);
dlist_for_each_data(sdir->subdirs, devp, struct sysfs_directory) {
+ if (blacklist(devp->name))
+ continue;
sysfs_read_directory(devp);
if(devp->links == NULL)
continue;
sprintf(all_paths[k].sg_dev, "/dev/%s", buff);
strcpy(all_paths[k].dev, all_paths[k].sg_dev);
if ((sg_fd = open(all_paths[k].sg_dev, O_RDONLY)) < 0) {
+ if (conf->verbose)
+ fprintf(stderr, "can't open %s. mknod ?",
+ all_paths[k].sg_dev);
continue;
}
get_lun_strings(sg_fd, &all_paths[k]);
sprintf(buff, "%d", k);
strncat(file_name, buff, FILE_NAME_SIZE);
strcpy(all_paths[k].sg_dev, file_name);
- if ((sg_fd = open(file_name, O_RDONLY)) < 0)
+ if ((sg_fd = open(file_name, O_RDONLY)) < 0) {
+ if (conf->verbose)
+ fprintf(stderr, "can't open %s. mknod ?",
+ file_name);
continue;
+ }
get_lun_strings(sg_fd, &all_paths[k]);
get_unique_id(sg_fd, &all_paths[k]);
all_paths[k].state = do_tur(sg_fd);
} else
strcat(fname, "xxxx");
- if ((fd = open(fname, O_RDONLY)) < 0)
+ if ((fd = open(fname, O_RDONLY)) < 0) {
+ if (conf->verbose)
+ fprintf(stderr, "can't open %s. mknod ?",
+ fname);
continue;
+ }
res = ioctl(fd, SCSI_IOCTL_GET_IDLUN, &my_scsi_id);
if (res < 0) {
int i, np;
long size = -1;
+ /* defaults for multipath target */
+ int dm_nr_path_args = 2;
+ int dm_path_test_int = 10;
+ char * dm_ps_name = "round-robin";
+ int dm_ps_nr_args = 2;
+ int dm_path_failback_int = 10;
+ int dm_path_nr_fail = 2;
+ int dm_ps_prio = 1;
+ int dm_ps_min_io = 2;
+
+
if (!(dmt = dm_task_create(op)))
return 0;
}
if (np == 0)
goto addout;
- params_p += sprintf(params_p, "%i 32", np);
+ /* temporarily disable creation of single path maps */
+ /* Sistina should modify the target limits */
+ if (np < 2)
+ goto addout;
+
+ params_p += sprintf(params_p, "%i %i %i %s %i",
+ np, dm_nr_path_args, dm_path_test_int,
+ dm_ps_name, dm_ps_nr_args);
for (i=0; i<=mp[index].npaths; i++) {
if (( 0 == all_paths[PINDEX(index,i)].state) ||
continue;
if (size < 0)
size = get_disk_size(conf, all_paths[PINDEX(index,0)].dev);
- params_p += sprintf(params_p, " %s %i",
- all_paths[PINDEX(index,i)].dev, 0);
+ params_p += sprintf(params_p, " %s %i %i %i %i",
+ all_paths[PINDEX(index,i)].dev,
+ dm_path_failback_int, dm_path_nr_fail,
+ dm_ps_prio, dm_ps_min_io);
}
if (size < 0)
exit(1);
}
+static int
+filepresent(char * run) {
+ struct stat buf;
+
+ if(!stat(run, &buf))
+ return 1;
+ return 0;
+}
+
int
main(int argc, char *argv[])
{
+ char * run = "/var/run/multipath.run";
+ char * resched = "/var/run/multipath.reschedule";
struct multipath * mp;
struct path * all_paths;
struct scsi_dev * all_scsi_ids;
}
+ if (filepresent(run)) {
+ if (conf.verbose) {
+ fprintf(stderr, "Already running.\n");
+ fprintf(stderr, "If you know what you do, please ");
+ fprintf(stderr, "remove %s\n", run);
+ }
+ /* leave a trace that we were called while already running */
+ open(resched, O_CREAT);
+ return 1;
+ }
+
/* dynamic allocations */
mp = malloc(conf.max_devs * sizeof(struct multipath));
all_paths = malloc(conf.max_devs * sizeof(struct path));
all_scsi_ids = malloc(conf.max_devs * sizeof(struct scsi_dev));
- if (mp == NULL || all_paths == NULL || all_scsi_ids == NULL)
+ if (mp == NULL || all_paths == NULL || all_scsi_ids == NULL) {
+ unlink(run);
+ exit(1);
+ }
+start:
+ if(!open(run, O_CREAT))
exit(1);
if (!conf.with_sysfs) {
fprintf(stdout, "\n");
print_all_mp(all_paths, mp, nmp);
fprintf(stdout, "\n");
- //printf("\n");
}
- if (conf.dry_run)
+ if (conf.dry_run) {
+ unlink(run);
exit(0);
+ }
for (k=0; k<=nmp; k++) {
if (map_present(mp[k].wwid)) {
add_map(&conf, all_paths, mp, k, DM_DEVICE_CREATE);
}
}
+ unlink(run);
+
+ /* start again if we were ask to during this process run */
+ /* ie. do not loose an event-asked run */
+ if (filepresent(resched)) {
+ unlink(resched);
+ goto start;
+ }
exit(0);
}