chiark / gitweb /
[PATCH] multipath update
authorchristophe.varoqui@free.fr <christophe.varoqui@free.fr>
Tue, 2 Mar 2004 07:08:47 +0000 (23:08 -0800)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 04:35:06 +0000 (21:35 -0700)
extras/multipath/ChangeLog
extras/multipath/Makefile
extras/multipath/devinfo.c
extras/multipath/devmap_name.8 [new file with mode: 0644]
extras/multipath/main.c
extras/multipath/main.h
extras/multipath/multipath.8 [new file with mode: 0644]
extras/multipath/multipath.hotplug

index 43aa497e51cd825ae1d5fc339e3f4d47dd9ed6be..a2863ec23e172b2a845d5860585f01f7d199beed 100644 (file)
@@ -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.
index eeec25b893c9473f67371bf7e224258f351e7717..ee7f60e472458f645c3ebf34c25854e9c5a7a5ca 100644 (file)
@@ -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
index a6b089f517511480d9c4e0bf544441bf401c0cc4..323da2f2f07b6b77875d2b7b7459835126a2e6af 100644 (file)
@@ -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 (file)
index 0000000..f4f03c3
--- /dev/null
@@ -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.
index 706b2d1317c9a072b2c7bb2cd7f5faa761efae57..dfaa6867dda84ed34a56504fa83d1a21ddd74499 100644 (file)
@@ -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 */
index e05555599fc8aa93db1987806e6834f98248dc3f..cee99d2b882c42f33307938d3a52aecbe55f09ec 100644 (file)
@@ -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 (file)
index 0000000..9874642
--- /dev/null
@@ -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.
index 9bab619826ad08f53a5a291b8d36ae2f47e3a9b5..9f44f86c9b04aeca05cca9bcef5fe31573e47966 100644 (file)
@@ -1,6 +1,7 @@
+#!bin/sh
 . /etc/hotplug/hotplug.functions
 
 # wait for sysfs
 sleep 1
 
-mesg `/sbin/multipath scsi $DEVPATH`
+mesg `/sbin/multipath $DEVPATH`