summaryrefslogtreecommitdiff
path: root/extras/multipath
diff options
context:
space:
mode:
Diffstat (limited to 'extras/multipath')
-rw-r--r--extras/multipath/ChangeLog10
-rw-r--r--extras/multipath/Makefile28
-rw-r--r--extras/multipath/devinfo.c2
-rw-r--r--extras/multipath/devmap_name.830
-rw-r--r--extras/multipath/main.c37
-rw-r--r--extras/multipath/main.h5
-rw-r--r--extras/multipath/multipath.853
-rw-r--r--extras/multipath/multipath.hotplug3
8 files changed, 132 insertions, 36 deletions
diff --git a/extras/multipath/ChangeLog b/extras/multipath/ChangeLog
index 43aa497e51..a2863ec23e 100644
--- a/extras/multipath/ChangeLog
+++ b/extras/multipath/ChangeLog
@@ -1,3 +1,13 @@
+2004-02-21 multipath-018
+ * From the Debian SID inclusion review (Philipp Matthias Hahn)
+ * use DESTDIR install prefix in the Makefile
+ * add man pages for devmap_name & multipath
+ * correct libsysfs.h includes
+ * fork the hotplug script in its own shell
+ * Sync with the kernel device mapper code as of 2.6.3-udm3
+ ie. Remove the test interval parameter and its uses
+ * Remove superfluous scsi parameter passed from hotplug
+ * Add the man pages to the [un]install targets
2004-02-17 multipath-017
* remove the restrictive -f flag.
Introduce a more generic "-m iopolicy" one.
diff --git a/extras/multipath/Makefile b/extras/multipath/Makefile
index eeec25b893..ee7f60e472 100644
--- a/extras/multipath/Makefile
+++ b/extras/multipath/Makefile
@@ -10,8 +10,11 @@ bindir = ${exec_prefix}/sbin
udevdir = ../..
klibcdir = $(udevdir)/klibc
sysfsdir = $(udevdir)/libsysfs
+mandir = /usr/share/man/man8
CC = gcc
+GZIP = /bin/gzip -c
+
GCCINCDIR := ${shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp"}
KERNEL_DIR = /lib/modules/${shell uname -r}/build
CFLAGS = -pipe -g -O2 -Wall -Wunused -Wstrict-prototypes -nostdinc \
@@ -45,26 +48,33 @@ all: recurse
$(EXEC): $(OBJS)
$(LD) -o $(EXEC) $(CRT0) $(OBJS) $(SYSFSOBJS) $(DMOBJS) $(LIB) $(LIBGCC)
strip $(EXEC)
+ $(GZIP) $(EXEC).8 > $(EXEC).8.gz
devmap_name: devmap_name.o
$(LD) -o devmap_name $(CRT0) devmap_name.o $(DMOBJS) $(LIB) $(LIBGCC)
strip devmap_name
+ $(GZIP) devmap_name.8 > devmap_name.8.gz
clean:
- rm -f core *.o $(EXEC) devmap_name
+ rm -f core *.o $(EXEC) devmap_name *.gz
$(MAKE) -C libdevmapper clean
install:
- install -d $(bindir)
- install -m 755 $(EXEC) $(bindir)/
- install -m 755 devmap_name $(bindir)/
- install -d /etc/hotplug.d/scsi/
- install -m 755 multipath.hotplug /etc/hotplug.d/scsi/
+ install -d $(DESTDIR)$(bindir)
+ install -m 755 $(EXEC) $(DESTDIR)$(bindir)/
+ install -m 755 devmap_name $(DESTDIR)$(bindir)/
+ install -d $(DESTDIR)/etc/hotplug.d/scsi/
+ install -m 755 multipath.hotplug $(DESTDIR)/etc/hotplug.d/scsi/
+ install -d $(DESTDIR)$(mandir)
+ install -m 644 devmap_name.8.gz $(DESTDIR)$(mandir)
+ install -m 644 multipath.8.gz $(DESTDIR)$(mandir)
uninstall:
- rm /etc/hotplug.d/scsi/multipath.hotplug
- rm $(bindir)/$(EXEC)
- rm $(bindir)/devmap_name
+ rm $(DESTDIR)/etc/hotplug.d/scsi/multipath.hotplug
+ rm $(DESTDIR)$(bindir)/$(EXEC)
+ rm $(DESTDIR)$(bindir)/devmap_name
+ rm $(DESTDIR)$(mandir)/devmap_name.8.gz
+ rm $(DESTDIR)$(mandir)/multipath.8.gz
# Code dependencies
main.o: main.c main.h sg_include.h devinfo.h
diff --git a/extras/multipath/devinfo.c b/extras/multipath/devinfo.c
index a6b089f517..323da2f2f0 100644
--- a/extras/multipath/devinfo.c
+++ b/extras/multipath/devinfo.c
@@ -3,7 +3,7 @@
#include <string.h>
#include <fcntl.h>
#include <sys/ioctl.h>
-#include <libsysfs.h>
+#include <sysfs/libsysfs.h>
#include "devinfo.h"
#include "sg_include.h"
diff --git a/extras/multipath/devmap_name.8 b/extras/multipath/devmap_name.8
new file mode 100644
index 0000000000..f4f03c3ec6
--- /dev/null
+++ b/extras/multipath/devmap_name.8
@@ -0,0 +1,30 @@
+.TH DEVMAP_NAME 8 "February 2004" "" "Linux Administrator's Manual"
+.SH NAME
+devmap_name \- Query device-mapper name
+.SH SYNOPSIS
+.BI devmap_name " major minor"
+.SH DESCRIPTION
+.B devmap_name
+queries the device-mapper for the name for the device
+specified by
+.I major
+and
+.I minor
+number.
+.br
+.B devmap_name
+can be called from
+.B udev
+by the following rule in
+.IR /etc/udev/udev.rules :
+.sp
+.nf
+KERNEL="dm-[0-9]*", PROGRAM="/sbin/devmap_name %M %m", \\
+ NAME="%k", SYMLINK="%c"
+.fi
+.SH "SEE ALSO"
+.BR udev (8),
+.BR dmsetup (8)
+.SH AUTHORS
+.B devmap_name
+was developed by Christophe Varoqui, <christophe.varoqui@free.fr> and others.
diff --git a/extras/multipath/main.c b/extras/multipath/main.c
index 706b2d1317..dfaa6867dd 100644
--- a/extras/multipath/main.c
+++ b/extras/multipath/main.c
@@ -25,7 +25,7 @@
#include <linux/kdev_t.h>
#include <string.h>
#include <sys/ioctl.h>
-#include <libsysfs.h>
+#include <sysfs/libsysfs.h>
#include "libdevmapper/libdevmapper.h"
#include "main.h"
#include "devinfo.h"
@@ -110,7 +110,7 @@ get_all_paths_sysfs(struct env * conf, struct path * all_paths)
char path[FILE_NAME_SIZE];
struct path curpath;
- /* if called from hotplug, only consider the paths that relate to */
+ /* if called from hotplug, only consider the paths that relate */
/* to the device pointed by conf.hotplugdev */
memset(empty_buff, 0, WWID_SIZE);
memset(refwwid, 0, WWID_SIZE);
@@ -442,6 +442,7 @@ group_by_serial(struct multipath * mp, struct path * all_paths, char * str) {
path_count, path_buff);
}
sprintf(str, " %i%s", pg_count, pg_buff);
+ free(bitmap);
}
static int
@@ -507,8 +508,6 @@ setup_map(struct env * conf, struct path * all_paths,
if (np < 1)
return 0;
- params_p += sprintf(params_p, "%i", conf->dm_path_test_int);
-
if ((all_paths[PINDEX(index,0)].iopolicy == MULTIBUS &&
conf->iopolicy == -1) || conf->iopolicy == MULTIBUS) {
params_p += sprintf(params_p, " 1 %i %s %i %i",
@@ -602,18 +601,19 @@ static void
usage(char * progname)
{
fprintf(stderr, VERSION_STRING);
- fprintf(stderr, "Usage: %s [-v|-q] [-d] [-i int] [-m max_devs] ",
+ fprintf(stderr, "Usage: %s [-v|-q] [-d] [-m max_devs]",
progname);
- fprintf(stderr, "[-p failover|multibus|group_by_serial]\n");
+ fprintf(stderr, "[-p failover|multibus|group_by_serial] [device]\n");
fprintf(stderr, "\t-v\t\tverbose, print all paths and multipaths\n");
fprintf(stderr, "\t-q\t\tquiet, no output at all\n");
fprintf(stderr, "\t-d\t\tdry run, do not create or update devmaps\n");
- fprintf(stderr, "\t-i\t\tmultipath target param : polling interval\n");
fprintf(stderr, "\t-m max_devs\tscan {max_devs} devices at most\n");
fprintf(stderr, "\t-p policy\tforce maps to specified policy :\n");
- fprintf(stderr, "\t\t\tfailover\t1 path per priority group\n");
- fprintf(stderr, "\t\t\tmultibus\tall paths in 1 priority group\n");
- fprintf(stderr, "\t\t\tgroup_by_serial\t1 priority group per serial\n");
+ fprintf(stderr, "\t failover\t\t- 1 path per priority group\n");
+ fprintf(stderr, "\t multibus\t\t- all paths in 1 priority group\n");
+ fprintf(stderr, "\t group_by_serial\t- 1 priority group per serial\n");
+ fprintf(stderr, "\tdevice\t\tlimit scope to the device's multipath\n");
+ fprintf(stderr, "\t\t\t(hotplug-style $DEVPATH reference)\n");
exit(1);
}
@@ -632,7 +632,6 @@ main(int argc, char *argv[])
conf.verbose = 0; /* 1 == Print all_paths and mp */
conf.quiet = 0; /* 1 == Do not even print devmaps */
conf.iopolicy = -1; /* Apply the defaults in get_unique_id() */
- conf.dm_path_test_int = 10;
for (i = 1; i < argc; ++i) {
if (0 == strcmp("-v", argv[i])) {
@@ -649,25 +648,19 @@ main(int argc, char *argv[])
conf.quiet = 1;
} else if (0 == strcmp("-d", argv[i]))
conf.dry_run = 1;
- else if (0 == strcmp("-i", argv[i]))
- conf.dm_path_test_int = atoi(argv[++i]);
- else if (0 == strcmp("-p", argv[i++])) {
+ else if (0 == strcmp("-p", argv[i])) {
+ i++;
if (!strcmp(argv[i], "failover"))
conf.iopolicy = FAILOVER;
if (!strcmp(argv[i], "multibus"))
conf.iopolicy = MULTIBUS;
if (!strcmp(argv[i], "group_by_serial"))
conf.iopolicy = GROUP_BY_SERIAL;
- } else if (0 == strcmp("scsi", argv[i]))
- strcpy(conf.hotplugdev, argv[++i]);
- else if (*argv[i] == '-') {
+ } else if (*argv[i] == '-') {
fprintf(stderr, "Unknown switch: %s\n", argv[i]);
usage(argv[0]);
- } else if (*argv[i] != '-') {
- fprintf(stderr, "Unknown argument\n");
- usage(argv[0]);
- }
-
+ } else
+ strncpy(conf.hotplugdev, argv[i], FILE_NAME_SIZE);
}
/* dynamic allocations */
diff --git a/extras/multipath/main.h b/extras/multipath/main.h
index e05555599f..cee99d2b88 100644
--- a/extras/multipath/main.h
+++ b/extras/multipath/main.h
@@ -102,7 +102,6 @@ struct env {
int dry_run;
int iopolicy;
int with_sysfs;
- int dm_path_test_int;
char sysfs_path[FILE_NAME_SIZE];
char hotplugdev[FILE_NAME_SIZE];
};
@@ -110,8 +109,8 @@ struct env {
/* Build version */
#define PROG "multipath"
-#define VERSION_CODE 0x000010
-#define DATE_CODE 0x0C1503
+#define VERSION_CODE 0x000012
+#define DATE_CODE 0x021504
#define MULTIPATH_VERSION(version) \
(version >> 16) & 0xFF, \
diff --git a/extras/multipath/multipath.8 b/extras/multipath/multipath.8
new file mode 100644
index 0000000000..98746424b4
--- /dev/null
+++ b/extras/multipath/multipath.8
@@ -0,0 +1,53 @@
+.TH MULTIPATH 8 "February 2004" "" "Linux Administrator's Manual"
+.SH NAME
+multipath \- Device mapper target autoconfig
+.SH SYNOPSIS
+.B multipath
+.RB [\| \-v | \-q \|]
+.RB [\| \-d \|]
+.RB [\| \-m\ \c
+.IR max_devs \|]
+.RB [\| \-p\ \c
+.BR failover | multibus | group_by_serial \|]
+.RB [\| device \|]
+.SH DESCRIPTION
+.B multipath
+is used to detect multiple paths to devices for fail-over or performance reasons and coalesces them.
+.SH OPTIONS
+.TP
+.B \-v
+verbose, print all paths and multipaths
+.TP
+.B \-q
+quiet, no output at all
+.TP
+.B \-d
+dry run, do not create or update devmaps
+.TP
+.BI \-m " max_devs"
+scan
+.I max_devs
+devices at most
+.TP
+.BI \-p " policy"
+force maps to specified policy:
+.RS 1.2i
+.TP 1.2i
+.B failover
+1 path per priority group
+.TP
+.B multibus
+all paths in 1 priority group
+.TP
+.B group_by_serial
+1 priority group per serial
+.RE
+.TP
+.B device
+limit the [re]configuration to the specified device's multipath scope. device is given in its hotplug $DEVPATH form like /devices/pci0000:03/0000:03:01.0/host0/0:0:5:1
+.SH "SEE ALSO"
+.BR udev (8),
+.BR dmsetup (8)
+.SH AUTHORS
+.B multipath
+was developed by Christophe Varoqui, <christophe.varoqui@free.fr> and others.
diff --git a/extras/multipath/multipath.hotplug b/extras/multipath/multipath.hotplug
index 9bab619826..9f44f86c9b 100644
--- a/extras/multipath/multipath.hotplug
+++ b/extras/multipath/multipath.hotplug
@@ -1,6 +1,7 @@
+#!bin/sh
. /etc/hotplug/hotplug.functions
# wait for sysfs
sleep 1
-mesg `/sbin/multipath scsi $DEVPATH`
+mesg `/sbin/multipath $DEVPATH`