OBS User unknown 2008-04-29 22:47:42 +00:00 committed by Git OBS Bridge
parent 72e9d4e81b
commit 47b2f93a22
17 changed files with 11420 additions and 3398 deletions

View File

@ -0,0 +1,336 @@
From 0331715b87326c106192b1dbf76f147af10140e6 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Tue, 29 Apr 2008 14:25:21 +0200
Subject: [PATCH] Add cciss_tur checker
The 'normal' SG_IO tur checker has some issues with cciss, so
we'd better use a dedicated path checker here.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
libmultipath/checkers.h | 1 +
libmultipath/checkers/Makefile | 1 +
libmultipath/checkers/cciss.h | 142 +++++++++++++++++++++++++++++++++++++
libmultipath/checkers/cciss_tur.c | 137 +++++++++++++++++++++++++++++++++++
4 files changed, 281 insertions(+), 0 deletions(-)
create mode 100644 libmultipath/checkers/cciss.h
create mode 100644 libmultipath/checkers/cciss_tur.c
diff --git a/libmultipath/checkers.h b/libmultipath/checkers.h
index 93337f1..4ff475d 100644
--- a/libmultipath/checkers.h
+++ b/libmultipath/checkers.h
@@ -61,6 +61,7 @@
#define RDAC "rdac"
#define EMC_CLARIION "emc_clariion"
#define READSECTOR0 "readsector0"
+#define CCISS_TUR "cciss_tur"
#define DEFAULT_CHECKER DIRECTIO
diff --git a/libmultipath/checkers/Makefile b/libmultipath/checkers/Makefile
index f37a0f9..9b517f2 100644
--- a/libmultipath/checkers/Makefile
+++ b/libmultipath/checkers/Makefile
@@ -5,6 +5,7 @@
include ../../Makefile.inc
LIBS= \
+ libcheckcciss_tur.so \
libcheckreadsector0.so \
libchecktur.so \
libcheckdirectio.so \
diff --git a/libmultipath/checkers/cciss.h b/libmultipath/checkers/cciss.h
new file mode 100644
index 0000000..f6a37d8
--- /dev/null
+++ b/libmultipath/checkers/cciss.h
@@ -0,0 +1,142 @@
+#ifndef CCISS_H
+#define CCISS_H
+
+#include <linux/types.h>
+#include <linux/ioctl.h>
+
+#define CCISS_IOC_MAGIC 'B'
+
+/*
+ * transfer direction
+ */
+#define XFER_NONE 0x00
+#define XFER_WRITE 0x01
+#define XFER_READ 0x02
+#define XFER_RSVD 0x03
+
+/*
+ * task attribute
+ */
+#define ATTR_UNTAGGED 0x00
+#define ATTR_SIMPLE 0x04
+#define ATTR_HEADOFQUEUE 0x05
+#define ATTR_ORDERED 0x06
+#define ATTR_ACA 0x07
+
+/*
+ * cdb type
+ */
+#define TYPE_CMD 0x00
+#define TYPE_MSG 0x01
+
+#define SENSEINFOBYTES 32
+
+/*
+ * Type defs used in the following structs
+ */
+#define BYTE __u8
+#define WORD __u16
+#define HWORD __u16
+#define DWORD __u32
+
+#pragma pack(1)
+
+//Command List Structure
+typedef union _SCSI3Addr_struct {
+ struct {
+ BYTE Dev;
+ BYTE Bus:6;
+ BYTE Mode:2; // b00
+ } PeripDev;
+ struct {
+ BYTE DevLSB;
+ BYTE DevMSB:6;
+ BYTE Mode:2; // b01
+ } LogDev;
+ struct {
+ BYTE Dev:5;
+ BYTE Bus:3;
+ BYTE Targ:6;
+ BYTE Mode:2; // b10
+ } LogUnit;
+} SCSI3Addr_struct;
+
+typedef struct _PhysDevAddr_struct {
+ DWORD TargetId:24;
+ DWORD Bus:6;
+ DWORD Mode:2;
+ SCSI3Addr_struct Target[2]; //2 level target device addr
+} PhysDevAddr_struct;
+
+typedef struct _LogDevAddr_struct {
+ DWORD VolId:30;
+ DWORD Mode:2;
+ BYTE reserved[4];
+} LogDevAddr_struct;
+
+typedef union _LUNAddr_struct {
+ BYTE LunAddrBytes[8];
+ SCSI3Addr_struct SCSI3Lun[4];
+ PhysDevAddr_struct PhysDev;
+ LogDevAddr_struct LogDev;
+} LUNAddr_struct;
+
+typedef struct _RequestBlock_struct {
+ BYTE CDBLen;
+ struct {
+ BYTE Type:3;
+ BYTE Attribute:3;
+ BYTE Direction:2;
+ } Type;
+ HWORD Timeout;
+ BYTE CDB[16];
+} RequestBlock_struct;
+
+typedef union _MoreErrInfo_struct{
+ struct {
+ BYTE Reserved[3];
+ BYTE Type;
+ DWORD ErrorInfo;
+ }Common_Info;
+ struct{
+ BYTE Reserved[2];
+ BYTE offense_size;//size of offending entry
+ BYTE offense_num; //byte # of offense 0-base
+ DWORD offense_value;
+ }Invalid_Cmd;
+}MoreErrInfo_struct;
+
+typedef struct _ErrorInfo_struct {
+ BYTE ScsiStatus;
+ BYTE SenseLen;
+ HWORD CommandStatus;
+ DWORD ResidualCnt;
+ MoreErrInfo_struct MoreErrInfo;
+ BYTE SenseInfo[SENSEINFOBYTES];
+} ErrorInfo_struct;
+
+#pragma pack()
+
+typedef struct _IOCTL_Command_struct {
+ LUNAddr_struct LUN_info;
+ RequestBlock_struct Request;
+ ErrorInfo_struct error_info;
+ WORD buf_size; /* size in bytes of the buf */
+ BYTE *buf;
+} IOCTL_Command_struct;
+
+typedef struct _LogvolInfo_struct{
+ __u32 LunID;
+ int num_opens; /* number of opens on the logical volume */
+ int num_parts; /* number of partitions configured on logvol */
+} LogvolInfo_struct;
+
+#define CCISS_PASSTHRU _IOWR(CCISS_IOC_MAGIC, 11, IOCTL_Command_struct)
+#define CCISS_GETLUNINFO _IOR(CCISS_IOC_MAGIC, 17, LogvolInfo_struct)
+
+int cciss_init( struct checker *);
+void cciss_free (struct checker * c);
+int cciss_tur( struct checker *);
+
+#endif
+
diff --git a/libmultipath/checkers/cciss_tur.c b/libmultipath/checkers/cciss_tur.c
new file mode 100644
index 0000000..4c26901
--- /dev/null
+++ b/libmultipath/checkers/cciss_tur.c
@@ -0,0 +1,137 @@
+/*
+ *****************************************************************************
+ * *
+ * (C) Copyright 2007 Hewlett-Packard Development Company, L.P *
+ * *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU General Public License as published by the Free*
+ * Software Foundation; either version 2 of the License, or (at your option)*
+ * any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, but *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY*
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
+ * for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License along *
+ * with this program; if not, write to the Free Software Foundation, Inc., *
+ * 675 Mass Ave, Cambridge, MA 02139, USA. *
+ * *
+ * The copy of the GNU General Public License is available at *
+ * /opt/hp/HPDMmultipath-tool directoy *
+ * *
+ *****************************************************************************
+*/
+
+/*
+ * This program originally derived from and inspired by
+ * Christophe Varoqui's tur.c, part of libchecker.
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+
+#include "checkers.h"
+
+#include "cciss.h"
+
+#define TUR_CMD_LEN 6
+#define HEAVY_CHECK_COUNT 10
+
+#define MSG_CCISS_TUR_UP "cciss_tur checker reports path is up"
+#define MSG_CCISS_TUR_DOWN "cciss_tur checker reports path is down"
+
+struct cciss_tur_checker_context {
+ void * dummy;
+};
+
+int libcheck_init (struct checker * c)
+{
+ return 0;
+}
+
+void libcheck_free (struct checker * c)
+{
+ return;
+}
+
+extern int
+libcheck_check (struct checker * c)
+{
+ int rc;
+ int ret;
+ unsigned int lun = 0;
+ struct cciss_tur_checker_context * ctxt = NULL;
+ LogvolInfo_struct lvi; // logical "volume" info
+ IOCTL_Command_struct cic; // cciss ioctl command
+
+ if ((c->fd) <= 0) {
+ MSG(c,"no usable fd");
+ ret = -1;
+ goto out;
+ }
+
+ rc = ioctl(c->fd, CCISS_GETLUNINFO, &lvi);
+ if ( rc != 0) {
+ perror("Error: ");
+ fprintf(stderr, "cciss TUR failed in CCISS_GETLUNINFO: %s\n",
+ strerror(errno));
+ MSG(c,MSG_CCISS_TUR_DOWN);
+ ret = PATH_DOWN;
+ goto out;
+ } else {
+ lun = lvi.LunID;
+ }
+
+ memset(&cic, 0, sizeof(cic));
+ cic.LUN_info.LogDev.VolId = lun & 0x3FFFFFFF;
+ cic.LUN_info.LogDev.Mode = 0x01; /* logical volume addressing */
+ cic.Request.CDBLen = 6; /* need to try just 2 bytes here */
+ cic.Request.Type.Type = TYPE_CMD; // It is a command.
+ cic.Request.Type.Attribute = ATTR_SIMPLE;
+ cic.Request.Type.Direction = XFER_NONE;
+ cic.Request.Timeout = 0;
+
+ cic.Request.CDB[0] = 0;
+ cic.Request.CDB[1] = 0;
+ cic.Request.CDB[2] = 0;
+ cic.Request.CDB[3] = 0;
+ cic.Request.CDB[4] = 0;
+ cic.Request.CDB[5] = 0;
+
+ rc = ioctl(c->fd, CCISS_PASSTHRU, &cic);
+ if (rc < 0) {
+ fprintf(stderr, "cciss TUR failed: %s\n",
+ strerror(errno));
+ MSG(c,MSG_CCISS_TUR_DOWN);
+ ret = PATH_DOWN;
+ goto out;
+ }
+
+ if ((cic.error_info.CommandStatus | cic.error_info.ScsiStatus )) {
+ MSG(c,MSG_CCISS_TUR_DOWN);
+ ret = PATH_DOWN;
+ goto out;
+ }
+
+ MSG(c,MSG_CCISS_TUR_UP);
+
+ ret = PATH_UP;
+out:
+ /*
+ * caller told us he doesn't want to keep the context :
+ * free it
+ */
+ if (!c->context)
+ free(ctxt);
+
+ return(ret);
+}
--
1.5.2.4

View File

@ -3,16 +3,16 @@ index d970d29..e6a7296 100644
--- a/kpartx/Makefile
+++ b/kpartx/Makefile
@@ -37,8 +37,10 @@ $(MULTIPATHLIB)-$(BUILD).a:
install: $(EXEC) kpartx_id $(EXEC).8
install -d $(DESTDIR)$(bindir)
install: $(EXEC) $(EXEC).8
$(INSTALL_PROGRAM) -d $(DESTDIR)$(bindir)
$(INSTALL_PROGRAM) -m 755 $(EXEC) $(DESTDIR)$(bindir)
+ install -m 755 activate_dm_linear $(DESTDIR)$(bindir)
install -d $(DESTDIR)$(libudevdir)
install -m 755 kpartx_id $(DESTDIR)$(libudevdir)
+ install -m 755 dm_linear $(DESTDIR)$(libudevdir)
install -d $(DESTDIR)/etc/udev/rules.d
install -m 644 kpartx.rules $(DESTDIR)/etc/udev/rules.d/70-kpartx.rules
install -d $(DESTDIR)$(mandir)
+ $(INSTALL_PROGRAM) -m 755 activate_dm_linear $(DESTDIR)$(bindir)
$(INSTALL_PROGRAM) -d $(DESTDIR)$(libudevdir)
$(INSTALL_PROGRAM) -m 755 kpartx_id $(DESTDIR)$(libudevdir)
+ $(INSTALL_PROGRAM) -m 755 dm_linear $(DESTDIR)$(libudevdir)
$(INSTALL_PROGRAM) -d $(DESTDIR)/etc/udev/rules.d
$(INSTALL_PROGRAM) -m 644 kpartx.rules $(DESTDIR)/etc/udev/rules.d/70-kpartx.rules
$(INSTALL_PROGRAM) -d $(DESTDIR)$(mandir)
@@ -46,6 +48,11 @@ install: $(EXEC) kpartx_id $(EXEC).8
uninstall:
@ -158,7 +158,7 @@ index 9ab9a49..2746eff 100644
@@ -30,6 +34,8 @@ ENV{DM_STATE}=="ACTIVE", ENV{DM_UUID}=="mpath-*", \
RUN+="/sbin/kpartx -a -p _part /dev/$kernel"
ENV{DM_STATE}=="ACTIVE", ENV{DM_UUID}=="dmraid-*", \
RUN+="/sbin/kpartx -a -p _part /dev/$kernel"
RUN+="/sbin/kpartx -a -p -part /dev/$kernel"
+ENV{DM_STATE}=="ACTIVE", ENV{DM_UUID}=="linear-*", \
+ RUN+="/sbin/kpartx -a -p _part /dev/$kernel"

View File

@ -0,0 +1,58 @@
From 9c15b6662a2cf05c70175e8afcbde5a98fe12639 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Tue, 29 Apr 2008 12:59:07 +0200
Subject: [PATCH] [libmultipath] block SIGPIPE before writing to a pipe
We have to block SIGPIPE before we're writing to the communication
pipe otherwise the daemon will be killed if the listening program
terminates prematurely.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
libmultipath/uxsock.c | 23 ++++++++++++++++++++---
1 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/libmultipath/uxsock.c b/libmultipath/uxsock.c
index abb9f85..cdc3dbc 100644
--- a/libmultipath/uxsock.c
+++ b/libmultipath/uxsock.c
@@ -14,6 +14,7 @@
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/poll.h>
+#include <signal.h>
#include <errno.h>
#include "memory.h"
@@ -127,9 +128,25 @@ size_t read_all(int fd, void *buf, size_t len)
*/
int send_packet(int fd, const char *buf, size_t len)
{
- if (write_all(fd, &len, sizeof(len)) != sizeof(len)) return -1;
- if (write_all(fd, buf, len) != len) return -1;
- return 0;
+ int ret = 0;
+#ifdef DAEMON
+ sigset_t set, old;
+
+ /* Block SIGPIPE */
+ sigemptyset(&set);
+ sigaddset(&set, SIGPIPE);
+ pthread_sigmask(SIG_BLOCK, &set, &old);
+#endif
+ if (write_all(fd, &len, sizeof(len)) != sizeof(len))
+ ret = -1;
+ if (!ret && write_all(fd, buf, len) != len)
+ ret = -1;
+
+#ifdef DAEMON
+ /* And unblock it again */
+ pthread_sigmask(SIG_SETMASK, &old, NULL);
+#endif
+ return ret;
}
/*
--
1.5.2.4

View File

@ -0,0 +1,30 @@
From a3b85c9eefa959db9a54d27ffc34a23e9bceaeeb Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Tue, 29 Apr 2008 13:07:39 +0200
Subject: [PATCH] multipathd crash on shutdown
On shutdown multipathd flushes its internal message queue;
but we have to check if the messages on the queue are not empty.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
libmultipath/log_pthread.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/libmultipath/log_pthread.c b/libmultipath/log_pthread.c
index 5a82b6a..8976bfb 100644
--- a/libmultipath/log_pthread.c
+++ b/libmultipath/log_pthread.c
@@ -33,7 +33,8 @@ static void flush_logqueue (void)
pthread_mutex_lock(logq_lock);
empty = log_dequeue(la->buff);
pthread_mutex_unlock(logq_lock);
- log_syslog(la->buff);
+ if (!empty)
+ log_syslog(la->buff);
} while (empty == 0);
}
--
1.5.2.4

View File

@ -0,0 +1,30 @@
From f59db7b23a40f4f3b7317a3963eafafce6198e08 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Tue, 29 Apr 2008 13:45:41 +0200
Subject: [PATCH] Fixup varags usage
We already call va_end() at the correct position, no need to
duplicate it in log_safe().
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
libmultipath/log_pthread.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/libmultipath/log_pthread.c b/libmultipath/log_pthread.c
index 8976bfb..8909440 100644
--- a/libmultipath/log_pthread.c
+++ b/libmultipath/log_pthread.c
@@ -15,9 +15,7 @@
void log_safe (int prio, const char * fmt, va_list ap)
{
pthread_mutex_lock(logq_lock);
- //va_start(ap, fmt);
log_enqueue(prio, fmt, ap);
- va_end(ap);
pthread_mutex_unlock(logq_lock);
pthread_mutex_lock(logev_lock);
--
1.5.2.4

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,87 @@
From 50cebd09cf3c79c25638b3c7befeb1219b1a04d9 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Tue, 29 Apr 2008 13:48:23 +0200
Subject: [PATCH] libdevmapper prints garbage on shutdown
This patch fixes 2 logging bugs:
o multipath command prints unexpected log message like
"libdevmapper: libdm-common.c(303): Created /dev/mapper/<mapname>"
o multipathd doesn't log messages like "--------shut down------"
during the exit path
What is the problem:
o multipath command and multipathd register dm_write_log() using
dm_log_init() and it can be called from libdevmapper codes like
dm_lib_release().
o dm_write_log() references the global "conf" to find the verbosity,
but it is freed before dm_lib_release() calls dm_write_log().
o So dm_write_log() reads garbage value like big vervosity.
What does the patch do:
o multipath command sets NULL to "conf" after freeing it.
This prevents dm_write_log() from reading garbage data.
o multipath command and multipathd free "conf" after all logging
are completed, because the logging functions reference it
to find the verbosity.
Signed-off-by: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
multipath/main.c | 10 +++++++++-
multipathd/main.c | 10 ++++++++--
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/multipath/main.c b/multipath/main.c
index 0f4b2d2..b6ea6fd 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -429,9 +429,17 @@ main (int argc, char *argv[])
out:
sysfs_cleanup();
- free_config(conf);
dm_lib_release();
dm_lib_exit();
+
+ /*
+ * Freeing config must be done after dm_lib_exit(), because
+ * the logging function (dm_write_log()), which is called there,
+ * references the config.
+ */
+ free_config(conf);
+ conf = NULL;
+
#ifdef _DEBUG_
dbg_free_final(NULL);
#endif
diff --git a/multipathd/main.c b/multipathd/main.c
index 50e7441..385521c 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -1373,8 +1373,6 @@ child (void * param)
vecs->lock = NULL;
FREE(vecs);
vecs = NULL;
- free_config(conf);
- conf = NULL;
condlog(2, "--------shut down-------");
@@ -1384,6 +1382,14 @@ child (void * param)
dm_lib_release();
dm_lib_exit();
+ /*
+ * Freeing config must be done after condlog() and dm_lib_exit(),
+ * because logging functions like dlog() and dm_write_log()
+ * reference the config.
+ */
+ free_config(conf);
+ conf = NULL;
+
#ifdef _DEBUG_
dbg_free_final(NULL);
#endif
--
1.5.2.4

View File

@ -0,0 +1,123 @@
From d9cc62aa19e92df154f016c167265fd74a848063 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Tue, 29 Apr 2008 14:02:49 +0200
Subject: [PATCH] Don't print failure messages for callouts by default
Calling 'multipath -ll' on devices with paths results in
lots of error messages; they really should be suppressed
for the normal output. The user can always have them printed
out by increasing verbosity.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
libmultipath/callout.c | 14 ++++++++++++--
libmultipath/discovery.c | 8 ++++----
libmultipath/prioritizers/alua.c | 6 +++++-
3 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/libmultipath/callout.c b/libmultipath/callout.c
index d54f3ca..4dd33c5 100644
--- a/libmultipath/callout.c
+++ b/libmultipath/callout.c
@@ -10,6 +10,7 @@
#include <unistd.h>
#include <sys/types.h>
#include <stdlib.h>
+#include <fcntl.h>
#include <sys/wait.h>
#include <errno.h>
@@ -32,7 +33,7 @@ int execute_program(char *path, char *value, int len)
int retval;
int count;
int status;
- int fds[2];
+ int fds[2], null_fd;
pid_t pid;
char *pos;
char arg[PROGRAM_SIZE];
@@ -75,7 +76,16 @@ int execute_program(char *path, char *value, int len)
close(STDOUT_FILENO);
/* dup write side of pipe to STDOUT */
- dup(fds[1]);
+ if (dup(fds[1]) < 0)
+ return -1;
+
+ /* Ignore writes to stderr */
+ null_fd = open("/dev/null", O_WRONLY);
+ if (null_fd > 0) {
+ close(STDERR_FILENO);
+ dup(null_fd);
+ close(null_fd);
+ }
retval = execv(argv[0], argv);
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index 83e1865..8cfb53f 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -623,8 +623,8 @@ get_state (struct path * pp)
}
pp->state = checker_check(c);
condlog(3, "%s: state = %i", pp->dev, pp->state);
- if (pp->state == PATH_DOWN)
- condlog(2, "%s: checker msg is \"%s\"",
+ if (pp->state == PATH_DOWN && strlen(checker_message(c)))
+ condlog(3, "%s: checker msg is \"%s\"",
pp->dev, checker_message(c));
return 0;
}
@@ -642,7 +642,7 @@ get_prio (struct path * pp)
}
pp->priority = prio_getprio(pp->prio, pp);
if (pp->priority < 0) {
- condlog(0, "%s: %s prio error", pp->dev, prio_name(pp->prio));
+ condlog(3, "%s: %s prio error", pp->dev, prio_name(pp->prio));
pp->priority = PRIO_UNDEF;
return 1;
}
@@ -663,7 +663,7 @@ get_uid (struct path * pp)
condlog(0, "error formatting uid callout command");
memset(pp->wwid, 0, WWID_SIZE);
} else if (execute_program(buff, pp->wwid, WWID_SIZE)) {
- condlog(0, "error calling out %s", buff);
+ condlog(3, "error calling out %s", buff);
memset(pp->wwid, 0, WWID_SIZE);
return 1;
}
diff --git a/libmultipath/prioritizers/alua.c b/libmultipath/prioritizers/alua.c
index 67e4adb..1b52b8e 100644
--- a/libmultipath/prioritizers/alua.c
+++ b/libmultipath/prioritizers/alua.c
@@ -22,6 +22,7 @@
#define ALUA_PRIO_NOT_SUPPORTED 1
#define ALUA_PRIO_RTPG_FAILED 2
#define ALUA_PRIO_GETAAS_FAILED 3
+#define ALUA_PRIO_TPGS_FAILED 4
int
get_alua_info(int fd)
@@ -38,7 +39,7 @@ get_alua_info(int fd)
rc = get_target_port_group_support(fd);
if (rc < 0)
- return rc;
+ return -ALUA_PRIO_TPGS_FAILED;
if (rc == TPGS_NONE)
return -ALUA_PRIO_NOT_SUPPORTED;
@@ -85,6 +86,9 @@ int getprio (struct path * pp)
case ALUA_PRIO_GETAAS_FAILED:
condlog(0, "%s: couln't get asymmetric access state", pp->dev);
break;
+ case ALUA_PRIO_TPGS_FAILED:
+ condlog(3, "%s: couln't get supported alua states", pp->dev);
+ break;
}
}
return rc;
--
1.5.2.4

View File

@ -0,0 +1,491 @@
From 09345f745f894b261bccef694bcd36d79095d2b6 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Tue, 29 Apr 2008 16:17:56 +0200
Subject: [PATCH] Remove DEAMON defines
We're now building just one multipath.so library, so any
DAEMON defines are pointless. And we should be setting
the correct dlopen path during compilation.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
libmultipath/Makefile | 13 ++++++-------
libmultipath/checkers.c | 3 ++-
libmultipath/configure.c | 26 +++++++++++++-------------
libmultipath/debug.c | 8 +-------
libmultipath/debug.h | 10 +---------
libmultipath/devmapper.c | 12 ++----------
libmultipath/discovery.c | 11 +----------
libmultipath/dmparser.c | 4 +---
libmultipath/prio.c | 17 +++++++++--------
libmultipath/structs.c | 4 +---
libmultipath/structs_vec.c | 11 +++++------
libmultipath/structs_vec.h | 2 --
libmultipath/uxsock.c | 10 ++++------
libmultipath/waiter.h | 3 ---
multipath/Makefile | 2 +-
multipath/main.c | 2 ++
multipathd/Makefile | 2 +-
multipathd/main.c | 2 ++
18 files changed, 52 insertions(+), 90 deletions(-)
diff --git a/libmultipath/Makefile b/libmultipath/Makefile
index 16bd978..55721e8 100644
--- a/libmultipath/Makefile
+++ b/libmultipath/Makefile
@@ -11,23 +11,22 @@ OBJS = memory.o parser.o vector.o devmapper.o callout.o \
structs.o discovery.o propsel.o dict.o \
pgpolicies.o debug.o regex.o defaults.o uevent.o \
switchgroup.o uxsock.o print.o alias.o log_pthread.o \
- log.o configure.o structs_vec.o sysfs.o prio.o checkers.o
+ log.o configure.o structs_vec.o sysfs.o prio.o checkers.o \
+ lock.o waiter.o
-#ifeq ($(strip $(DAEMON)),1)
- OBJS += lock.o waiter.o
- CFLAGS += -DDAEMON
-#endif
-LIBDM_API_FLUSH = $(shell objdump -T /lib/libdevmapper.so.* | grep -c dm_task_no_flush)
+LIBDM_API_FLUSH = $(shell if test -d /lib64 ; then objdump -T /lib64/libdevmapper.so* ; else objdump -T /lib/libdevmapper.so.* ; fi | grep -c dm_task_no_flush)
ifeq ($(strip $(LIBDM_API_FLUSH)),1)
CFLAGS += -DLIBDM_API_FLUSH
endif
+CFLAGS += -DLIBMULTIPATH=\"$(libdir)\"
+
all: $(LIBS)
$(LIBS): $(OBJS)
- $(CC) $(SHARED_FLAGS) $(CFLAGS) -o $@ $(OBJS)
+ $(CC) $(SHARED_FLAGS) $(CFLAGS) -o $@ $(OBJS)
install:
$(INSTALL_PROGRAM) -o root -g root -m 755 -d $(libdir)
diff --git a/libmultipath/checkers.c b/libmultipath/checkers.c
index ff606d0..ce9dd86 100644
--- a/libmultipath/checkers.c
+++ b/libmultipath/checkers.c
@@ -61,7 +61,8 @@ struct checker * add_checker (char * name)
c = alloc_checker();
if (!c)
return NULL;
- snprintf(libname, LIB_CHECKER_NAMELEN, "libcheck%s.so", name);
+ snprintf(libname, LIB_CHECKER_NAMELEN, "%s/libcheck%s.so",
+ LIBMULTIPATH, name);
condlog(3, "loading %s checker", libname);
handle = dlopen(libname, RTLD_NOW);
errstr = dlerror();
diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index df31cdd..8fdc9f2 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -367,19 +367,19 @@ domap (struct multipath * mpp)
* DM_DEVICE_CREATE, DM_DEVICE_RENAME, or DM_DEVICE_RELOAD
* succeeded
*/
-#ifndef DAEMON
- dm_switchgroup(mpp->alias, mpp->bestpg);
- if (mpp->action != ACT_NOTHING)
- print_multipath_topology(mpp, conf->verbosity);
-#else
- mpp->stat_map_loads++;
- condlog(2, "%s: load table [0 %llu %s %s]", mpp->alias,
- mpp->size, DEFAULT_TARGET, mpp->params);
- /*
- * Required action is over, reset for the stateful daemon
- */
- mpp->action = ACT_NOTHING;
-#endif
+ if (!mpp->waiter) {
+ dm_switchgroup(mpp->alias, mpp->bestpg);
+ if (mpp->action != ACT_NOTHING)
+ print_multipath_topology(mpp, conf->verbosity);
+ } else {
+ mpp->stat_map_loads++;
+ condlog(2, "%s: load table [0 %llu %s %s]", mpp->alias,
+ mpp->size, DEFAULT_TARGET, mpp->params);
+ /*
+ * Required action is over, reset for the stateful daemon
+ */
+ mpp->action = ACT_NOTHING;
+ }
return DOMAP_OK;
}
return DOMAP_FAIL;
diff --git a/libmultipath/debug.c b/libmultipath/debug.c
index 05dfb06..d30517d 100644
--- a/libmultipath/debug.c
+++ b/libmultipath/debug.c
@@ -5,11 +5,9 @@
#include <stdlib.h>
#include <stdarg.h>
-#if DAEMON
#include "log_pthread.h"
#include <sys/types.h>
#include <time.h>
-#endif
#include "vector.h"
#include "config.h"
@@ -23,12 +21,11 @@ void dlog (int sink, int prio, const char * fmt, ...)
thres = (conf) ? conf->verbosity : 0;
if (prio <= thres) {
-#if DAEMON
if (!sink) {
time_t t = time(NULL);
struct tm *tb = localtime(&t);
char buff[16];
-
+
strftime(buff, sizeof(buff), "%b %d %H:%M:%S", tb);
buff[sizeof(buff)-1] = '\0';
@@ -37,9 +34,6 @@ void dlog (int sink, int prio, const char * fmt, ...)
}
else
log_safe(prio + 3, fmt, ap);
-#else
- vfprintf(stdout, fmt, ap);
-#endif
}
va_end(ap);
}
diff --git a/libmultipath/debug.h b/libmultipath/debug.h
index 082fff1..c6120c1 100644
--- a/libmultipath/debug.h
+++ b/libmultipath/debug.h
@@ -1,21 +1,13 @@
void dlog (int sink, int prio, const char * fmt, ...)
__attribute__((format(printf, 3, 4)));
-#if DAEMON
#include <pthread.h>
#include <stdarg.h>
#include "log_pthread.h"
-int logsink;
+extern int logsink;
#define condlog(prio, fmt, args...) \
dlog(logsink, prio, fmt "\n", ##args)
-
-#else /* DAEMON */
-
-#define condlog(prio, fmt, args...) \
- dlog(0, prio, fmt "\n", ##args)
-
-#endif /* DAEMON */
diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
index f21d3ab..cc01486 100644
--- a/libmultipath/devmapper.c
+++ b/libmultipath/devmapper.c
@@ -22,11 +22,9 @@
#include "devmapper.h"
#include "config.h"
-#if DAEMON
#include "log_pthread.h"
#include <sys/types.h>
#include <time.h>
-#endif
#define MAX_WAIT 5
#define LOOPS_PER_SEC 5
@@ -47,8 +45,7 @@ dm_write_log (int level, const char *file, int line, const char *f, ...)
if (thres <= 3 || level > thres)
return;
- va_start(ap, f);
-#if DAEMON
+ va_start(ap, f);
if (!logsink) {
time_t t = time(NULL);
struct tm *tb = localtime(&t);
@@ -65,12 +62,7 @@ dm_write_log (int level, const char *file, int line, const char *f, ...)
condlog(level, "libdevmapper: %s(%i): ", file, line);
log_safe(level + 3, f, ap);
}
-#else
- fprintf(stdout, "libdevmapper: %s(%i): ", file, line);
- vfprintf(stdout, f, ap);
- fprintf(stdout, "\n");
-#endif
- va_end(ap);
+ va_end(ap);
return;
}
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index 8cfb53f..7baa9e7 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -716,10 +716,6 @@ pathinfo (struct path *pp, vector hwtable, int mask)
if (mask & DI_WWID && !strlen(pp->wwid))
get_uid(pp);
-#ifndef DAEMON
- close(pp->fd);
- pp->fd = -1;
-#endif
return 0;
blank:
@@ -728,11 +724,6 @@ blank:
*/
memset(pp->wwid, 0, WWID_SIZE);
pp->state = PATH_DOWN;
-#ifndef DAEMON
- if (pp->fd > 0){
- close(pp->fd);
- pp->fd = -1;
- }
-#endif
+
return 0;
}
diff --git a/libmultipath/dmparser.c b/libmultipath/dmparser.c
index fe7d986..1ef22fb 100644
--- a/libmultipath/dmparser.c
+++ b/libmultipath/dmparser.c
@@ -277,10 +277,8 @@ disassemble_map (vector pathvec, char * params, struct multipath * mpp)
strncpy(pp->dev_t, word, BLK_DEV_SIZE);
-#ifndef DAEMON
- if (store_path(pathvec, pp))
+ if (mpp->waiter && store_path(pathvec, pp))
goto out;
-#endif
}
FREE(word);
diff --git a/libmultipath/prio.c b/libmultipath/prio.c
index 617fc19..4d6d840 100644
--- a/libmultipath/prio.c
+++ b/libmultipath/prio.c
@@ -28,18 +28,18 @@ void free_prio (struct prio * p)
void cleanup_prio(void)
{
- struct prio * prio_loop;
- struct prio * prio_temp;
+ struct prio * prio_loop;
+ struct prio * prio_temp;
- list_for_each_entry_safe(prio_loop, prio_temp, &prioritizers, node) {
- list_del(&prio_loop->node);
- free(prio_loop);
- }
+ list_for_each_entry_safe(prio_loop, prio_temp, &prioritizers, node) {
+ list_del(&prio_loop->node);
+ free(prio_loop);
+ }
}
struct prio * prio_lookup (char * name)
{
- struct prio * p;
+ struct prio * p;
list_for_each_entry(p, &prioritizers, node) {
if (!strncmp(name, p->name, PRIO_NAME_LEN))
@@ -61,7 +61,8 @@ struct prio * add_prio (char * name)
p = alloc_prio();
if (!p)
return NULL;
- snprintf(libname, LIB_PRIO_NAMELEN, "libprio%s.so", name);
+ snprintf(libname, LIB_PRIO_NAMELEN, "%s/libprio%s.so",
+ LIBMULTIPATH, name);
condlog(3, "loading %s prioritizer", libname);
handle = dlopen(libname, RTLD_NOW);
errstr = dlerror();
diff --git a/libmultipath/structs.c b/libmultipath/structs.c
index 11f3061..082d53f 100644
--- a/libmultipath/structs.c
+++ b/libmultipath/structs.c
@@ -170,14 +170,12 @@ free_multipath (struct multipath * mpp, int free_paths)
if (mpp->dmi)
FREE(mpp->dmi);
-
-#if DAEMON
+
/*
* better own vecs->lock here
*/
if (mpp->waiter)
((struct event_thread *)mpp->waiter)->mpp = NULL;
-#endif
free_pathvec(mpp->paths, free_paths);
free_pgvec(mpp->pg, free_paths);
diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c
index f4d69bb..6757eb9 100644
--- a/libmultipath/structs_vec.c
+++ b/libmultipath/structs_vec.c
@@ -62,7 +62,7 @@ adopt_paths (vector pathvec, struct multipath * mpp)
condlog(3, "%s: ownership set to %s",
pp->dev, mpp->alias);
pp->mpp = mpp;
-
+
if (!mpp->paths && !(mpp->paths = vector_alloc()))
return 1;
@@ -294,18 +294,17 @@ retry:
char new_alias[WWID_SIZE];
/*
- * detect an external rename of the multipath device
+ * detect an external rename of the multipath device
*/
if (dm_get_name(mpp->wwid, DEFAULT_TARGET, new_alias)) {
condlog(3, "%s multipath mapped device name has "
"changed from %s to %s", mpp->wwid,
mpp->alias, new_alias);
strcpy(mpp->alias, new_alias);
-#if DAEMON
- if (mpp->waiter)
+
+ if (mpp->waiter)
strncpy(((struct event_thread *)mpp->waiter)->mapname,
new_alias, WWID_SIZE);
-#endif
goto retry;
}
condlog(0, "%s: failed to setup multipath", mpp->alias);
@@ -341,7 +340,7 @@ add_map_without_path (struct vectors * vecs,
if (adopt_paths(vecs->pathvec, mpp))
goto out;
-
+
if (!vector_alloc_slot(vecs->mpvec))
goto out;
diff --git a/libmultipath/structs_vec.h b/libmultipath/structs_vec.h
index b8a416f..19a2387 100644
--- a/libmultipath/structs_vec.h
+++ b/libmultipath/structs_vec.h
@@ -2,9 +2,7 @@
#define _STRUCTS_VEC_H
struct vectors {
-#if DAEMON
pthread_mutex_t *lock;
-#endif
vector pathvec;
vector mpvec;
};
diff --git a/libmultipath/uxsock.c b/libmultipath/uxsock.c
index cdc3dbc..a070943 100644
--- a/libmultipath/uxsock.c
+++ b/libmultipath/uxsock.c
@@ -129,23 +129,21 @@ size_t read_all(int fd, void *buf, size_t len)
int send_packet(int fd, const char *buf, size_t len)
{
int ret = 0;
-#ifdef DAEMON
sigset_t set, old;
/* Block SIGPIPE */
sigemptyset(&set);
sigaddset(&set, SIGPIPE);
pthread_sigmask(SIG_BLOCK, &set, &old);
-#endif
- if (write_all(fd, &len, sizeof(len)) != sizeof(len))
+
+ if (write_all(fd, &len, sizeof(len)) != sizeof(len))
ret = -1;
if (!ret && write_all(fd, buf, len) != len)
- ret = -1;
+ ret = -1;
-#ifdef DAEMON
/* And unblock it again */
pthread_sigmask(SIG_SETMASK, &old, NULL);
-#endif
+
return ret;
}
diff --git a/libmultipath/waiter.h b/libmultipath/waiter.h
index 0223924..468ce5f 100644
--- a/libmultipath/waiter.h
+++ b/libmultipath/waiter.h
@@ -1,8 +1,6 @@
#ifndef _WAITER_H
#define _WAITER_H
-#if DAEMON
-
struct event_thread {
struct dm_task *dmt;
pthread_t thread;
@@ -19,5 +17,4 @@ int start_waiter_thread (struct multipath *mpp, struct vectors *vecs);
int waiteventloop (struct event_thread *waiter);
void *waitevent (void *et);
-#endif /* DAEMON */
#endif /* _WAITER_H */
diff --git a/multipath/Makefile b/multipath/Makefile
index 71df431..bb44e3e 100644
--- a/multipath/Makefile
+++ b/multipath/Makefile
@@ -7,7 +7,7 @@ include ../Makefile.inc
OBJS = main.o
CFLAGS += -I$(multipathdir) -Wl,-rpath,$(libdir)
-LDFLAGS += -laio -ldevmapper -lpthread \
+LDFLAGS += -laio -ldevmapper -lpthread -ldl \
-lmultipath -L$(multipathdir)
EXEC = multipath
diff --git a/multipath/main.c b/multipath/main.c
index b6ea6fd..c071cac 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -49,6 +49,8 @@
#include <pgpolicies.h>
#include <version.h>
+int logsink;
+
static int
filter_pathvec (vector pathvec, char * refwwid)
{
diff --git a/multipathd/Makefile b/multipathd/Makefile
index 6beb993..dd223c4 100644
--- a/multipathd/Makefile
+++ b/multipathd/Makefile
@@ -5,7 +5,7 @@ include ../Makefile.inc
#
# basic flags setting
#
-CFLAGS += -DDAEMON -I$(multipathdir) -Wl,-rpath,$(libdir)
+CFLAGS += -I$(multipathdir) -Wl,-rpath,$(libdir)
LDFLAGS += -lpthread -ldevmapper -lreadline -lncurses -laio \
-lmultipath -L$(multipathdir)
diff --git a/multipathd/main.c b/multipathd/main.c
index 385521c..2b1fd86 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -65,6 +65,8 @@
pthread_cond_t exit_cond = PTHREAD_COND_INITIALIZER;
pthread_mutex_t exit_mutex = PTHREAD_MUTEX_INITIALIZER;
+int logsink;
+
/*
* global copy of vecs for use in sig handlers
*/
--
1.5.2.4

View File

@ -0,0 +1,115 @@
From 5403925a5b8f8fd582d137cb2a54d742508dca75 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Tue, 29 Apr 2008 13:56:08 +0200
Subject: [PATCH] Improve sense code scanning in sg_read() and tur checker
sg_read and tur should be able to correctly parse sense data,
as we might need to retry any UNIT ATTENTION sense codes.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
libmultipath/checkers/libsg.c | 13 ++++++++-
libmultipath/checkers/tur.c | 58 ++++++++++++++++++++++++++++------------
2 files changed, 52 insertions(+), 19 deletions(-)
diff --git a/libmultipath/checkers/libsg.c b/libmultipath/checkers/libsg.c
index 9171b10..4cb7ecc 100644
--- a/libmultipath/checkers/libsg.c
+++ b/libmultipath/checkers/libsg.c
@@ -72,10 +72,21 @@ retry:
(0 == io_hdr.driver_status)) {
return PATH_UP;
} else {
+ int key = 0;
+
+ if (io_hdr.sb_len_wr > 3) {
+ if (sbb[0] == 0x72 || sbb[0] == 0x73)
+ key = sbb[1] & 0x0f;
+ else if (io_hdr.sb_len_wr > 13 &&
+ ((sbb[0] & 0x7f) == 0x70 ||
+ (sbb[0] & 0x7f) == 0x71))
+ key = sbb[2] & 0x0f;
+ }
+
/*
* Retry if UNIT_ATTENTION check condition.
*/
- if ((sbb[2]&0xf) == 6) {
+ if (key == 0x6) {
if (--retry_count)
goto retry;
}
diff --git a/libmultipath/checkers/tur.c b/libmultipath/checkers/tur.c
index e84435e..43b846d 100644
--- a/libmultipath/checkers/tur.c
+++ b/libmultipath/checkers/tur.c
@@ -41,26 +41,48 @@ extern int
libcheck_check (struct checker * c)
{
struct sg_io_hdr io_hdr;
- unsigned char turCmdBlk[TUR_CMD_LEN] = { 0x00, 0, 0, 0, 0, 0 };
- unsigned char sense_buffer[32];
+ unsigned char turCmdBlk[TUR_CMD_LEN] = { 0x00, 0, 0, 0, 0, 0 };
+ unsigned char sense_buffer[32];
+ int retry_tur = 5;
- memset(&io_hdr, 0, sizeof (struct sg_io_hdr));
- io_hdr.interface_id = 'S';
- io_hdr.cmd_len = sizeof (turCmdBlk);
- io_hdr.mx_sb_len = sizeof (sense_buffer);
- io_hdr.dxfer_direction = SG_DXFER_NONE;
- io_hdr.cmdp = turCmdBlk;
- io_hdr.sbp = sense_buffer;
- io_hdr.timeout = DEF_TIMEOUT;
- io_hdr.pack_id = 0;
- if (ioctl(c->fd, SG_IO, &io_hdr) < 0) {
+ retry:
+ memset(&io_hdr, 0, sizeof (struct sg_io_hdr));
+ io_hdr.interface_id = 'S';
+ io_hdr.cmd_len = sizeof (turCmdBlk);
+ io_hdr.mx_sb_len = sizeof (sense_buffer);
+ io_hdr.dxfer_direction = SG_DXFER_NONE;
+ io_hdr.cmdp = turCmdBlk;
+ io_hdr.sbp = sense_buffer;
+ io_hdr.timeout = DEF_TIMEOUT;
+ io_hdr.pack_id = 0;
+ if (ioctl(c->fd, SG_IO, &io_hdr) < 0) {
MSG(c, MSG_TUR_DOWN);
- return PATH_DOWN;
- }
- if (io_hdr.info & SG_INFO_OK_MASK) {
+ return PATH_DOWN;
+ }
+ if (io_hdr.info & SG_INFO_OK_MASK) {
+ int key = 0, asc, ascq;
+
+ if (io_hdr.sb_len_wr > 3) {
+ if (io_hdr.sbp[0] == 0x72 || io_hdr.sbp[0] == 0x73) {
+ key = io_hdr.sbp[1] & 0x0f;
+ asc = io_hdr.sbp[2];
+ ascq = io_hdr.sbp[3];
+ } else if (io_hdr.sb_len_wr > 13 &&
+ ((io_hdr.sbp[0] & 0x7f) == 0x70 ||
+ (io_hdr.sbp[0] & 0x7f) == 0x71)) {
+ key = io_hdr.sbp[2] & 0x0f;
+ asc = io_hdr.sbp[12];
+ ascq = io_hdr.sbp[13];
+ }
+ }
+ if (key == 0x6) {
+ /* Unit Attention, retry */
+ if (--retry_tur)
+ goto retry;
+ }
MSG(c, MSG_TUR_DOWN);
- return PATH_DOWN;
- }
+ return PATH_DOWN;
+ }
MSG(c, MSG_TUR_UP);
- return PATH_UP;
+ return PATH_UP;
}
--
1.5.2.4

View File

@ -0,0 +1,183 @@
diff --git a/Makefile b/Makefile
index a099daf..54be0a5 100644
--- a/Makefile
+++ b/Makefile
@@ -25,7 +25,6 @@ BUILDDIRS = \
libmultipath/checkers \
multipath \
multipathd \
- devmap_name \
kpartx
ifeq ($(MULTIPATH_VERSION),)
diff --git a/Makefile.inc b/Makefile.inc
index 622f557..0d00303 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -13,7 +13,7 @@ ifeq ($(TOPDIR),)
TOPDIR = ..
endif
-prefix =
+prefix =
exec_prefix = $(prefix)
bindir = $(exec_prefix)/sbin
libudevdir = ${prefix}/lib/udev
@@ -26,8 +26,8 @@ libdir = $(prefix)/lib/multipath
GZIP = /bin/gzip -9 -c
INSTALL_PROGRAM = install
-OPTFLAGS = -pipe -g -Wall -Wunused -Wstrict-prototypes -fPIC
-CFLAGS = $(OPTFLAGS)
+OPTFLAGS = -pipe -g -Wall -Wunused -Wstrict-prototypes
+CFLAGS = $(OPTFLAGS) -fPIC
SHARED_FLAGS = -shared
%.o: %.c
diff --git a/kpartx/Makefile b/kpartx/Makefile
index 21e4ad4..ef08d37 100644
--- a/kpartx/Makefile
+++ b/kpartx/Makefile
@@ -15,21 +15,19 @@ all: $(EXEC)
$(EXEC): $(OBJS)
$(CC) $(OBJS) -o $(EXEC) $(LDFLAGS)
- $(GZIP) $(EXEC).8 > $(EXEC).8.gz
-
+
install: $(EXEC) $(EXEC).8
$(INSTALL_PROGRAM) -d $(DESTDIR)$(bindir)
$(INSTALL_PROGRAM) -m 755 $(EXEC) $(DESTDIR)$(bindir)
$(INSTALL_PROGRAM) -d $(DESTDIR)$(libudevdir)
$(INSTALL_PROGRAM) -m 755 kpartx_id $(DESTDIR)$(libudevdir)
$(INSTALL_PROGRAM) -d $(DESTDIR)/etc/udev/rules.d
- $(INSTALL_PROGRAM) -m 644 kpartx.rules $(DESTDIR)/etc/udev/rules.d/
+ $(INSTALL_PROGRAM) -m 644 kpartx.rules $(DESTDIR)/etc/udev/rules.d/70-kpartx.rules
$(INSTALL_PROGRAM) -d $(DESTDIR)$(mandir)
- $(INSTALL_PROGRAM) -m 644 $(EXEC).8.gz $(DESTDIR)$(mandir)
+ $(INSTALL_PROGRAM) -m 644 $(EXEC).8 $(DESTDIR)$(mandir)
uninstall:
rm -f $(DESTDIR)$(bindir)/$(EXEC)
- rm -f $(DESTDIR)$(mandir)/$(EXEC).8.gz
clean:
- rm -f core *.o $(EXEC) *.gz
+ rm -f core *.o $(EXEC)
diff --git a/libmultipath/Makefile b/libmultipath/Makefile
index 55721e8..d4bcbef 100644
--- a/libmultipath/Makefile
+++ b/libmultipath/Makefile
@@ -28,9 +28,8 @@ all: $(LIBS)
$(LIBS): $(OBJS)
$(CC) $(SHARED_FLAGS) $(CFLAGS) -o $@ $(OBJS)
-install:
- $(INSTALL_PROGRAM) -o root -g root -m 755 -d $(libdir)
- $(INSTALL_PROGRAM) -o root -g root -m 755 $(LIBS) $(libdir)/$(LIBS)
+install: $(LIBS)
+ $(INSTALL_PROGRAM) -D $(LIBS) $(DESTDIR)$(libdir)/$(LIBS)
uninstall:
rm -f $(libdir)/$(LIBS)
diff --git a/libmultipath/checkers/Makefile b/libmultipath/checkers/Makefile
index 9b517f2..dbc09ba 100644
--- a/libmultipath/checkers/Makefile
+++ b/libmultipath/checkers/Makefile
@@ -21,7 +21,7 @@ libcheck%.so: libsg.o %.o
$(CC) $(SHARED_FLAGS) -o $@ $^
install:
- $(INSTALL_PROGRAM) -o root -g root -m 755 $(LIBS) $(libdir)
+ $(INSTALL_PROGRAM) -m 755 $(LIBS) $(DESTDIR)$(libdir)
uninstall:
rm -f $(libdir)/$(LIBS)
diff --git a/libmultipath/prioritizers/Makefile b/libmultipath/prioritizers/Makefile
index c05d457..46bb936 100644
--- a/libmultipath/prioritizers/Makefile
+++ b/libmultipath/prioritizers/Makefile
@@ -25,7 +25,7 @@ libprio%.so: %.o
$(CC) $(SHARED_FLAGS) -o $@ $^
install: $(LIBS)
- install -m 755 libprio*.so $(libdir)
+ install -m 755 libprio*.so $(DESTDIR)$(libdir)
uninstall:
rm -f $(libdir)/libprio*.so
diff --git a/libmultipath/prioritizers/hds.c b/libmultipath/prioritizers/hds.c
index 6ebe4d8..f3d4cb3 100644
--- a/libmultipath/prioritizers/hds.c
+++ b/libmultipath/prioritizers/hds.c
@@ -86,7 +86,7 @@
int hds_modular_prio (const char *dev, int fd)
{
int k;
- char vendor[8];
+ char vendor[9];
char product[32];
char serial[32];
char ldev[32];
diff --git a/multipath/Makefile b/multipath/Makefile
index bb44e3e..ed7ede1 100644
--- a/multipath/Makefile
+++ b/multipath/Makefile
@@ -16,24 +16,20 @@ all: $(EXEC)
$(EXEC): $(OBJS)
$(CC) $(CFLAGS) $(OBJS) -o $(EXEC) $(LDFLAGS)
- $(GZIP) $(EXEC).8 > $(EXEC).8.gz
- $(GZIP) $(EXEC).conf.5 > $(EXEC).conf.5.gz
install:
$(INSTALL_PROGRAM) -d $(DESTDIR)$(bindir)
$(INSTALL_PROGRAM) -m 755 $(EXEC) $(DESTDIR)$(bindir)/
$(INSTALL_PROGRAM) -d $(DESTDIR)/etc/udev/rules.d
- $(INSTALL_PROGRAM) -m 644 multipath.rules $(DESTDIR)/etc/udev/rules.d/
+ $(INSTALL_PROGRAM) -m 644 multipath.rules $(DESTDIR)/etc/udev/rules.d/71-multipath.rules
$(INSTALL_PROGRAM) -d $(DESTDIR)$(mandir)
- $(INSTALL_PROGRAM) -m 644 $(EXEC).8.gz $(DESTDIR)$(mandir)
+ $(INSTALL_PROGRAM) -m 644 $(EXEC).8 $(DESTDIR)$(mandir)
$(INSTALL_PROGRAM) -d $(DESTDIR)$(man5dir)
- $(INSTALL_PROGRAM) -m 644 $(EXEC).conf.5.gz $(DESTDIR)$(man5dir)
+ $(INSTALL_PROGRAM) -m 644 $(EXEC).conf.5 $(DESTDIR)$(man5dir)
uninstall:
rm $(DESTDIR)/etc/udev/rules.d/multipath.rules
rm $(DESTDIR)$(bindir)/$(EXEC)
- rm $(DESTDIR)$(mandir)/$(EXEC).8.gz
- rm $(DESTDIR)$(man5dir)/$(EXEC).conf.5.gz
clean:
- rm -f core *.o $(EXEC) *.gz
+ rm -f core *.o $(EXEC)
diff --git a/multipath/multipath.rules b/multipath/multipath.rules
diff --git a/multipathd/Makefile b/multipathd/Makefile
index dd223c4..5143b6b 100644
--- a/multipathd/Makefile
+++ b/multipathd/Makefile
@@ -29,20 +29,18 @@ all : $(EXEC)
$(EXEC): $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $(EXEC) $(OBJS)
- $(GZIP) $(EXEC).8 > $(EXEC).8.gz
install:
$(INSTALL_PROGRAM) -d $(DESTDIR)$(bindir)
$(INSTALL_PROGRAM) -m 755 $(EXEC) $(DESTDIR)$(bindir)
$(INSTALL_PROGRAM) -d $(DESTDIR)$(rcdir)
$(INSTALL_PROGRAM) -d $(DESTDIR)$(mandir)
- $(INSTALL_PROGRAM) -m 644 $(EXEC).8.gz $(DESTDIR)$(mandir)
+ $(INSTALL_PROGRAM) -m 644 $(EXEC).8 $(DESTDIR)$(mandir)
uninstall:
rm -f $(DESTDIR)$(bindir)/$(EXEC)
rm -f $(DESTDIR)$(rcdir)/$(EXEC)
- rm -f $(DESTDIR)$(mandir)/$(EXEC).8.gz
clean:
- rm -f core *.o $(EXEC) *.gz
+ rm -f core *.o $(EXEC)
diff --git a/multipathd/multipathd.init.suse b/multipathd/multipathd.init.suse

View File

@ -1,845 +0,0 @@
diff --git a/devmap_name/Makefile b/devmap_name/Makefile
index d8d8b09..57051d9 100644
--- a/devmap_name/Makefile
+++ b/devmap_name/Makefile
@@ -18,25 +18,22 @@ EXEC = devmap_name
all: $(BUILD)
prepare:
- rm -f core *.o *.gz
+ rm -f core *.o
glibc: prepare $(OBJS)
$(CC) $(OBJS) -o $(EXEC) $(LDFLAGS)
- $(GZIP) $(EXEC).8 > $(EXEC).8.gz
klibc: prepare $(OBJS)
$(CC) -static -o $(EXEC) $(OBJS)
- $(GZIP) $(EXEC).8 > $(EXEC).8.gz
install: $(EXEC) $(EXEC).8
install -d $(DESTDIR)$(bindir)
install -m 755 $(EXEC) $(DESTDIR)$(bindir)/
install -d $(DESTDIR)$(mandir)
- install -m 644 $(EXEC).8.gz $(DESTDIR)$(mandir)
+ install -m 644 $(EXEC).8 $(DESTDIR)$(mandir)
uninstall:
rm $(DESTDIR)$(bindir)/$(EXEC)
- rm $(DESTDIR)$(mandir)/$(EXEC).8.gz
clean:
- rm -f core *.o $(EXEC) *.gz
+ rm -f core *.o $(EXEC)
diff --git a/kpartx/Makefile b/kpartx/Makefile
index b4cca6c..d970d29 100644
--- a/kpartx/Makefile
+++ b/kpartx/Makefile
@@ -23,32 +23,29 @@ EXEC = kpartx
all: $(BUILD)
prepare:
- rm -f core *.o *.gz
+ rm -f core *.o
glibc: prepare $(OBJS)
$(CC) $(OBJS) -o $(EXEC) $(LDFLAGS)
- $(GZIP) $(EXEC).8 > $(EXEC).8.gz
-
+
klibc: prepare $(OBJS)
$(CC) -static -o $(EXEC) $(CRT0) $(OBJS) $(KLIBC) $(LIBGCC)
- $(GZIP) $(EXEC).8 > $(EXEC).8.gz
$(MULTIPATHLIB)-$(BUILD).a:
make -C $(multipathdir) BUILD=$(BUILD)
-install: $(EXEC) $(EXEC).8
+install: $(EXEC) kpartx_id $(EXEC).8
install -d $(DESTDIR)$(bindir)
$(INSTALL_PROGRAM) -m 755 $(EXEC) $(DESTDIR)$(bindir)
install -d $(DESTDIR)$(libudevdir)
install -m 755 kpartx_id $(DESTDIR)$(libudevdir)
install -d $(DESTDIR)/etc/udev/rules.d
- install -m 644 kpartx.rules $(DESTDIR)/etc/udev/rules.d/
+ install -m 644 kpartx.rules $(DESTDIR)/etc/udev/rules.d/70-kpartx.rules
install -d $(DESTDIR)$(mandir)
- install -m 644 $(EXEC).8.gz $(DESTDIR)$(mandir)
+ install -m 644 $(EXEC).8 $(DESTDIR)$(mandir)
uninstall:
rm -f $(DESTDIR)$(bindir)/$(EXEC)
- rm -f $(DESTDIR)$(mandir)/$(EXEC).8.gz
clean:
- rm -f core *.o $(EXEC) *.gz
+ rm -f core *.o $(EXEC)
diff --git a/kpartx/kpartx.c b/kpartx/kpartx.c
index dbe2ee2..f60e5f4 100644
--- a/kpartx/kpartx.c
+++ b/kpartx/kpartx.c
@@ -265,7 +265,7 @@ main(int argc, char **argv){
}
if (dm_prereq(DM_TARGET, 0, 0, 0) && (what == ADD || what == DELETE)) {
- fprintf(stderr, "device mapper prerequisites not met\n");
+ fprintf(stderr, "device mapper prerequisites not met\n");
exit(1);
}
@@ -387,10 +387,10 @@ main(int argc, char **argv){
slices[j].minor = m++;
start = slices[j].start - slices[k].start;
- printf("%s%s%d : 0 %lu /dev/dm-%d %lu\n",
+ printf("%s%s%d : 0 %lu %s%s%d %lu\n",
mapname, delim, j+1,
(unsigned long) slices[j].size,
- slices[k].minor, start);
+ mapname, delim, k, start);
c--;
}
/* Terminate loop if nothing more to resolve */
@@ -431,7 +431,7 @@ main(int argc, char **argv){
break;
case ADD:
- for (j=0, c = 0; j<n; j++) {
+ for (j = 0, c = 0; j < n; j++) {
if (slices[j].size == 0)
continue;
@@ -477,6 +477,7 @@ main(int argc, char **argv){
d = c;
while (c) {
for (j = 0; j < n; j++) {
+ unsigned long start;
int k = slices[j].container - 1;
if (slices[j].size == 0)
@@ -487,7 +488,7 @@ main(int argc, char **argv){
continue;
/* Skip all simple slices */
- if (k < 0)
+ if (slices[j].container == 0)
continue;
/* Check container slice */
@@ -502,10 +503,11 @@ main(int argc, char **argv){
}
strip_slash(partname);
+ start = slices[j].start - slices[k].start;
if (safe_sprintf(params, "%d:%d %lu",
slices[k].major,
slices[k].minor,
- (unsigned long)slices[j].start)) {
+ start)) {
fprintf(stderr, "params too small\n");
exit(1);
}
@@ -524,9 +526,12 @@ main(int argc, char **argv){
&slices[j].minor);
if (verbose)
- printf("add map %s : 0 %lu %s %s\n",
- partname, slices[j].size,
- DM_TARGET, params);
+ printf("add map %s (%d:%d): 0 %lu %s\n",
+ partname,
+ slices[j].major,
+ slices[j].minor,
+ slices[j].size,
+ params);
c--;
}
/* Terminate loop */
diff --git a/kpartx/kpartx.rules b/kpartx/kpartx.rules
index f32c718..9ab9a49 100644
--- a/kpartx/kpartx.rules
+++ b/kpartx/kpartx.rules
@@ -9,7 +9,7 @@ ACTION=="remove", GOTO="kpartx_end"
ENV{DM_TABLE_STATE}!="LIVE", GOTO="kpartx_end"
-ENV{DM_UUID}=="?*", IMPORT{program}=="/lib/udev/kpartx_id %M %m $env{DM_UUID}"
+ENV{DM_UUID}=="?*", IMPORT{program}=="kpartx_id %M %m $env{DM_UUID}"
OPTIONS="link_priority=50"
@@ -18,7 +18,7 @@ ENV{DM_UUID}=="mpath-*", \
SYMLINK+="disk/by-id/$env{DM_TYPE}-$env{DM_NAME}"
# Create persistent links for dmraid tables
-ENV{DM_UUID}=="mpath-*", \
+ENV{DM_UUID}=="dmraid-*", \
SYMLINK+="disk/by-id/$env{DM_TYPE}-$env{DM_NAME}"
# Create persistent links for partitions
@@ -27,9 +27,9 @@ ENV{DM_PART}=="?*", \
# Create dm tables for partitions
ENV{DM_STATE}=="ACTIVE", ENV{DM_UUID}=="mpath-*", \
- RUN+="/sbin/kpartx -a -p -part /dev/$kernel"
+ RUN+="/sbin/kpartx -a -p _part /dev/$kernel"
ENV{DM_STATE}=="ACTIVE", ENV{DM_UUID}=="dmraid-*", \
- RUN+="/sbin/kpartx -a -p -part /dev/$kernel"
+ RUN+="/sbin/kpartx -a -p _part /dev/$kernel"
LABEL="kpartx_end"
diff --git a/libcheckers/Makefile b/libcheckers/Makefile
index 6340a68..bdd423f 100644
--- a/libcheckers/Makefile
+++ b/libcheckers/Makefile
@@ -11,7 +11,7 @@ OBJS = libsg.o checkers.o readsector0.o tur.o directio.o emc_clariion.o hp_sw.o
all: $(BUILD)
prepare:
- @file *-$(BUILD).a >/dev/null 2>&1 || rm -f core *.o *.gz
+ @file *-$(BUILD).a >/dev/null 2>&1 || rm -f core *.o
klibc: prepare $(OBJS)
ar rs libcheckers-klibc.a *.o
@@ -24,4 +24,4 @@ install:
uninstall:
clean:
- rm -f core *.a *.o *.gz
+ rm -f core *.a *.o
diff --git a/libmultipath/Makefile b/libmultipath/Makefile
index 511f5ad..3ab059a 100644
--- a/libmultipath/Makefile
+++ b/libmultipath/Makefile
@@ -25,7 +25,7 @@ else
CLEAN = $(shell if [ ! "x$(PREVBUILD)" = "x" ]; then echo clean; fi)
endif
-LIBDM_API_FLUSH = $(shell objdump -T /lib/libdevmapper.so.* | grep -c dm_task_no_flush)
+LIBDM_API_FLUSH = $(shell /sbin/ldconfig -p | grep devmapper.so.1 | cut -d ' ' -f 4 | xargs objdump -T | grep -c dm_task_no_flush)
ifeq ($(strip $(LIBDM_API_FLUSH)),1)
CFLAGS += -DLIBDM_API_FLUSH
@@ -34,7 +34,7 @@ endif
all: $(BUILD)
prepare: $(CLEAN)
- @file *-$(BUILD).a >/dev/null 2>&1 || rm -f core *.o *.gz
+ @file *-$(BUILD).a >/dev/null 2>&1 || rm -f core *.o
@rm -f *-$(BUILD).a
klibc: $(OBJS)
@@ -48,4 +48,4 @@ install:
uninstall:
clean:
- rm -f core *.a *.o *.gz
+ rm -f core *.a *.o
diff --git a/libmultipath/config.c b/libmultipath/config.c
index a39af8a..1dfc18c 100644
--- a/libmultipath/config.c
+++ b/libmultipath/config.c
@@ -366,12 +366,15 @@ load_config (char * file)
/*
* read the config file
*/
+ set_current_keywords(&conf->keywords);
+ alloc_keywords();
if (filepresent(file)) {
- set_current_keywords(&conf->keywords);
if (init_data(file, init_keywords)) {
condlog(0, "error parsing config file");
goto out;
}
+ } else {
+ init_keywords();
}
/*
diff --git a/libmultipath/parser.c b/libmultipath/parser.c
index f9c555e..5302970 100644
--- a/libmultipath/parser.c
+++ b/libmultipath/parser.c
@@ -455,16 +455,23 @@ process_stream(vector keywords)
return r;
}
+int alloc_keywords(void)
+{
+ if (!keywords)
+ keywords = vector_alloc();
+
+ if (!keywords)
+ return 1;
+
+ return 0;
+}
+
/* Data initialization */
int
init_data(char *conf_file, void (*init_keywords) (void))
{
int r;
- if (!keywords)
- keywords = vector_alloc();
- if (!keywords)
- return 1;
stream = fopen(conf_file, "r");
if (!stream) {
syslog(LOG_WARNING, "Configuration file open problem");
diff --git a/libmultipath/parser.h b/libmultipath/parser.h
index 95d4e6f..8496684 100644
--- a/libmultipath/parser.h
+++ b/libmultipath/parser.h
@@ -74,6 +74,7 @@ extern vector read_value_block(void);
extern int alloc_value_block(vector strvec, void (*alloc_func) (vector));
extern void *set_value(vector strvec);
extern int process_stream(vector keywords);
+extern int alloc_keywords(void);
extern int init_data(char *conf_file, void (*init_keywords) (void));
extern struct keyword * find_keyword(vector v, char * name);
void set_current_keywords (vector *k);
diff --git a/libmultipath/print.c b/libmultipath/print.c
index 01a157a..489bc2b 100644
--- a/libmultipath/print.c
+++ b/libmultipath/print.c
@@ -738,7 +738,7 @@ snprint_hwentry (char * buff, int len, struct hwentry * hwe)
if (fwd > len)
return len;
iterate_sub_keywords(rootkw, kw, i) {
- fwd += snprint_keyword(buff + fwd, len - fwd, "\t\t%k %v\n",
+ fwd += snprint_keyword(buff + fwd, len - fwd, "\t\t%k \"%v\"\n",
kw, hwe);
if (fwd > len)
return len;
diff --git a/multipath/Makefile b/multipath/Makefile
index 4923b2f..bad9da7 100644
--- a/multipath/Makefile
+++ b/multipath/Makefile
@@ -22,9 +22,7 @@ all: $(BUILD)
prepare:
make -C $(multipathdir) prepare
- rm -f core *.o *.gz
- $(GZIP) $(EXEC).8 > $(EXEC).8.gz
- $(GZIP) $(EXEC).conf.5 > $(EXEC).conf.5.gz
+ rm -f core *.o
glibc: prepare $(OBJS)
$(CC) $(OBJS) -o $(EXEC) $(LDFLAGS)
@@ -42,17 +40,15 @@ install:
install -d $(DESTDIR)$(bindir)
$(INSTALL_PROGRAM) -m 755 $(EXEC) $(DESTDIR)$(bindir)/
install -d $(DESTDIR)/etc/udev/rules.d
- install -m 644 multipath.rules $(DESTDIR)/etc/udev/rules.d/
+ install -m 644 multipath.rules $(DESTDIR)/etc/udev/rules.d/71-multipath.rules
install -d $(DESTDIR)$(mandir)
- install -m 644 $(EXEC).8.gz $(DESTDIR)$(mandir)
+ install -m 644 $(EXEC).8 $(DESTDIR)$(mandir)
install -d $(DESTDIR)$(man5dir)
- install -m 644 $(EXEC).conf.5.gz $(DESTDIR)$(man5dir)
+ install -m 644 multipath.conf.5 $(DESTDIR)$(man5dir)
uninstall:
rm $(DESTDIR)/etc/udev/rules.d/multipath.rules
rm $(DESTDIR)$(bindir)/$(EXEC)
- rm $(DESTDIR)$(mandir)/$(EXEC).8.gz
- rm $(DESTDIR)$(man5dir)/$(EXEC).conf.5.gz
clean:
- rm -f core *.o $(EXEC) *.gz
+ rm -f core *.o $(EXEC)
diff --git a/multipath/main.c b/multipath/main.c
index 815c307..e2d7f41 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -72,7 +72,7 @@ static void
usage (char * progname)
{
fprintf (stderr, VERSION_STRING);
- fprintf (stderr, "Usage: %s\t[-v level] [-d] [-h|-l|-ll|-f|-F]\n",
+ fprintf (stderr, "Usage: %s\t[-v level] [-d] [-h|-l|-ll|-f|-F|-t]\n",
progname);
fprintf (stderr,
"\t\t\t[-p failover|multibus|group_by_serial|group_by_prio]\n" \
@@ -90,6 +90,7 @@ usage (char * progname)
"\t-ll\t\tshow multipath topology (maximum info)\n" \
"\t-f\t\tflush a multipath device map\n" \
"\t-F\t\tflush all multipath device maps\n" \
+ "\t-t\t\tprint internal hardware table\n" \
"\t-p policy\tforce all maps to specified policy :\n" \
"\t failover\t\t1 path per priority group\n" \
"\t multibus\t\tall paths in 1 priority group\n" \
@@ -307,6 +308,55 @@ out:
return r;
}
+static int
+dump_config (void)
+{
+ char * c;
+ char * reply;
+ unsigned int maxlen = 256;
+ int again = 1;
+
+ reply = MALLOC(maxlen);
+
+ while (again) {
+ if (!reply)
+ return 1;
+ c = reply;
+ c += snprint_defaults(c, reply + maxlen - c);
+ again = ((c - reply) == maxlen);
+ if (again) {
+ reply = REALLOC(reply, maxlen *= 2);
+ continue;
+ }
+ c += snprint_blacklist(c, reply + maxlen - c);
+ again = ((c - reply) == maxlen);
+ if (again) {
+ reply = REALLOC(reply, maxlen *= 2);
+ continue;
+ }
+ c += snprint_blacklist_except(c, reply + maxlen - c);
+ again = ((c - reply) == maxlen);
+ if (again) {
+ reply = REALLOC(reply, maxlen *= 2);
+ continue;
+ }
+ c += snprint_hwtable(c, reply + maxlen - c, conf->hwtable);
+ again = ((c - reply) == maxlen);
+ if (again) {
+ reply = REALLOC(reply, maxlen *= 2);
+ continue;
+ }
+ c += snprint_mptable(c, reply + maxlen - c, conf->mptable);
+ again = ((c - reply) == maxlen);
+ if (again)
+ reply = REALLOC(reply, maxlen *= 2);
+ }
+
+ printf("%s", reply);
+ FREE(reply);
+ return 0;
+}
+
int
main (int argc, char *argv[])
{
@@ -330,7 +380,7 @@ main (int argc, char *argv[])
condlog(0, "multipath tools need sysfs mounted");
exit(1);
}
- while ((arg = getopt(argc, argv, ":dhl::FfM:v:p:b:")) != EOF ) {
+ while ((arg = getopt(argc, argv, ":dhl::FfM:v:p:b:t")) != EOF ) {
switch(arg) {
case 1: printf("optarg : %s\n",optarg);
break;
@@ -373,6 +423,9 @@ main (int argc, char *argv[])
usage(argv[0]);
}
break;
+ case 't':
+ dump_config();
+ goto out;
case 'h':
usage(argv[0]);
case ':':
diff --git a/multipath/multipath.8 b/multipath/multipath.8
index 693872b..e72cc45 100644
--- a/multipath/multipath.8
+++ b/multipath/multipath.8
@@ -6,7 +6,7 @@ multipath \- Device mapper target autoconfig
.RB [\| \-v\ \c
.IR verbosity \|]
.RB [\| \-d \|]
-.RB [\| \-h | \-l | \-ll | \-f | \-F \|]
+.RB [\| \-h | \-l | \-ll | \-f | \-t | \-F \|]
.RB [\| \-p\ \c
.BR failover | multibus | group_by_serial | group_by_prio | group_by_node_name \|]
.RB [\| device \|]
@@ -47,6 +47,9 @@ flush a multipath device map specified as parameter, if unused
.B \-F
flush all unused multipath device maps
.TP
+.B \-t
+print internal hardware table to stdout
+.TP
.BI \-p " policy"
force maps to specified policy:
.RS 1.2i
@@ -76,6 +79,9 @@ is in the /dev/sdb (as shown by udev in the $DEVNAME variable) or major:minor fo
.I device
may alternatively be a multipath mapname
.SH "SEE ALSO"
+.BR multipathd (8),
+.BR multipath.conf (5),
+.BR kpartx (8),
.BR udev (8),
.BR dmsetup (8)
.BR hotplug (8)
diff --git a/multipath/multipath.init.suse b/multipath/multipath.init.suse
new file mode 100755
index 0000000..daea61f
--- /dev/null
+++ b/multipath/multipath.init.suse
@@ -0,0 +1,130 @@
+#! /bin/sh
+# Copyright (c) 2005 SuSE GmbH Nuernberg, Germany.
+#
+# Author: Hannes Reinecke <feedback@suse.de>
+#
+# init.d/boot.multipath
+#
+### BEGIN INIT INFO
+# Provides: boot.multipath
+# Required-Start: boot.device-mapper boot.udev
+# Required-Stop:
+# Default-Start: B
+# Default-Stop:
+# Short-Description: Create multipath device targets
+# Description: Setup initial multipath device-mapper targets
+### END INIT INFO
+
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+PROGRAM=/sbin/multipath
+
+# Set the maximum number of open files
+MAX_OPEN_FDS=4096
+
+test -x $PROGRAM || exit 5
+
+# Shell functions sourced from /etc/rc.status:
+# rc_check check and set local and overall rc status
+# rc_status check and set local and overall rc status
+# rc_status -v ditto but be verbose in local rc status
+# rc_status -v -r ditto and clear the local rc status
+# rc_failed set local and overall rc status to failed
+# rc_reset clear local rc status (overall remains)
+# rc_exit exit appropriate to overall rc status
+. /etc/rc.status
+
+# First reset status of this service
+rc_reset
+
+# Return values acc. to LSB for all commands but status:
+# 0 - success
+# 1 - misc error
+# 2 - invalid or excess args
+# 3 - unimplemented feature (e.g. reload)
+# 4 - insufficient privilege
+# 5 - program not installed
+# 6 - program not configured
+# 7 - program is not running
+#
+# Note that starting an already running service, stopping
+# or restarting a not-running service as well as the restart
+# with force-reload (in case signalling is not supported) are
+# considered a success.
+
+maplist=$(/sbin/dmsetup ls --target multipath | sed '/No devices/d' | cut -f 1)
+
+case "$1" in
+ start)
+ echo -n "Creating multipath targets:"
+ # Check whether multipath daemon is already running
+ if /sbin/multipathd -k"list paths" > /dev/null 2>&1 ; then
+ echo -n " (multipathd running)"
+ rc_status -v
+ rc_exit
+ fi
+
+ # Load prerequisite module
+ modprobe dm-multipath
+
+ # Be a chicken and flush all existing maps
+ for map in $maplist ; do
+ $PROGRAM -f $map
+ done
+
+ # Clear /dev/disk/by-name/ prior to start-up; multipath will
+ # recreate them.
+ rm -f /dev/disk/by-name/* 2>&1 >/dev/null
+
+ # Set the maximum number of open files
+ if [ -n "$MAX_OPEN_FDS" ] ; then
+ ulimit -n $MAX_OPEN_FDS
+ fi
+
+ # Start the program directly as checkproc doesn't work here
+ $PROGRAM -v 0
+
+ # Create all partitions which might have been missing
+ /sbin/dmsetup ls --target multipath --exec "/sbin/kpartx -a -p -part"
+
+ # Remember status and be verbose
+ rc_status -v
+ sleep 1
+ ;;
+ stop)
+ echo -n "Removing multipath targets:"
+
+ # Remove all partition mappings
+ if /sbin/dmsetup ls | sed '/No devices/d' | grep -q -- -part; then
+ /sbin/dmsetup ls --target multipath --exec "/sbin/kpartx -d -p -part" 2> /dev/null
+ fi
+
+ # Flush all existing maps
+ for map in $maplist ; do
+ $PROGRAM -f $map
+ done
+
+ rc_failed 0
+ rc_status -v
+ ;;
+ status)
+ echo -n "Checking multipath targets: "
+ # Display active multipath tables
+ tblnum=$(/sbin/dmsetup ls --target multipath | sed '/No devices/d' | wc --lines)
+ if [ "$tblnum" ] && [ $tblnum -gt 0 ] ; then
+ echo -n "($tblnum multipath devices) "
+ rc_failed 0
+ else
+ rc_failed 3
+ fi
+ rc_status -v
+ ;;
+ reload)
+ $0 stop
+ $0 start
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|status}"
+ exit 1
+ ;;
+esac
+rc_exit
diff --git a/multipathd/Makefile b/multipathd/Makefile
index b430b94..e076d56 100644
--- a/multipathd/Makefile
+++ b/multipathd/Makefile
@@ -35,7 +35,6 @@ klibc:
$(EXEC): clean $(OBJS)
$(CC) $(OBJS) -o $(EXEC) $(LDFLAGS)
- $(GZIP) $(EXEC).8 > $(EXEC).8.gz
$(CHECKERSLIB)-glibc.a:
$(MAKE) -C $(checkersdir) BUILD=glibc glibc
@@ -48,14 +47,13 @@ install:
$(INSTALL_PROGRAM) -m 755 $(EXEC) $(DESTDIR)$(bindir)
install -d $(DESTDIR)$(rcdir)
install -d $(DESTDIR)$(mandir)
- install -m 644 $(EXEC).8.gz $(DESTDIR)$(mandir)
+ install -m 644 $(EXEC).8 $(DESTDIR)$(mandir)
uninstall:
rm -f $(DESTDIR)$(bindir)/$(EXEC)
rm -f $(DESTDIR)$(rcdir)/$(EXEC)
- rm -f $(DESTDIR)$(mandir)/$(EXEC).8.gz
clean:
$(MAKE) -C $(multipathdir) prepare DAEMON=1
- rm -f core *.o $(EXEC) *.gz
+ rm -f core *.o $(EXEC)
diff --git a/multipathd/multipathd.init.suse b/multipathd/multipathd.init.suse
new file mode 100755
index 0000000..c850896
--- /dev/null
+++ b/multipathd/multipathd.init.suse
@@ -0,0 +1,133 @@
+#! /bin/sh
+# Copyright (c) 1995-2001 SuSE GmbH Nuernberg, Germany.
+#
+# Author: Hannes Reinecke <feedback@suse.de>
+#
+# init.d/routed
+#
+# and symbolic its link
+#
+# /usr/sbin/rcrouted
+#
+### BEGIN INIT INFO
+# Provides: multipathd
+# Required-Start: $syslog
+# Required-Stop:
+# Default-Start: 3 5
+# Default-Stop: 0 1 2 4 6
+# Short-Description: Starts multipath daemon
+# Description: Starts the multipath daemon
+### END INIT INFO
+
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+DAEMON=/sbin/multipathd
+PIDFILE=/var/run/multipathd.pid
+
+# Set the maximum number of open files
+MAX_OPEN_FDS=4096
+
+test -x $DAEMON || exit 5
+
+. /etc/rc.status
+
+# First reset status of this service
+rc_reset
+
+case "$1" in
+ start)
+ echo -n "Starting multipathd"
+
+ modprobe dm-multipath
+
+ # Set the maximum number of open files
+ if [ -n "$MAX_OPEN_FDS" ] ; then
+ ulimit -n $MAX_OPEN_FDS
+ fi
+
+ if [ -f $PIDFILE ]; then
+ PID="$(cat $PIDFILE)"
+ PROCNAME="$(ps -o cmd --no-headers $PID)"
+ fi
+
+ if [ "$PROCNAME" != "$DAEMON" ]; then
+ $DAEMON
+ fi
+
+ # Remember status and be verbose
+ rc_status -v
+ sleep 1
+ ;;
+ stop)
+ echo -n "Shutting down multipathd"
+ # Because of the way how multipathd sets up its own namespace
+ # and chroots to it, killproc cannot be used with this process.
+ # So implement a cruder version:
+ if [ -f $PIDFILE ]; then
+ PID="$(cat $PIDFILE)"
+ PROCNAME="$(ps -o cmd --no-headers $PID)"
+ fi
+
+ if [ "$PROCNAME" == "$DAEMON" ]; then
+ kill -TERM $PID
+ fi
+
+ # Remember status and be verbose
+ rc_status -v
+ ;;
+ try-restart)
+ ## Stop the service and if this succeeds (i.e. the
+ ## service was running before), start it again.
+ $0 status >/dev/null && $0 restart
+
+ # Remember status and be quiet
+ rc_status
+ ;;
+ restart|force-reload)
+ ## Stop the service and regardless of whether it was
+ ## running or not, start it again.
+ $0 stop
+ $0 start
+
+ # Remember status and be quiet
+ rc_status
+ ;;
+ reload)
+ ## Like force-reload, but if daemon does not support
+ ## signalling, do nothing (!)
+
+ # If it does not support reload:
+ exit 3
+ ;;
+ status)
+ echo -n "Checking for multipathd: "
+
+ # Status has a slightly different for the status command:
+ # 0 - service running
+ # 1 - service dead, but /var/run/ pid file exists
+ # 2 - service dead, but /var/lock/ lock file exists
+ # 3 - service not running
+
+ if [ -f $PIDFILE ]; then
+ PID="$(cat $PIDFILE)"
+ PROCNAME="$(ps -o cmd --no-headers $PID)"
+ if [ "$PROCNAME" == "$DAEMON" ]; then
+ (exit 0)
+ else
+ (exit 1)
+ fi
+ else
+ (exit 3)
+ fi
+
+ rc_status -v
+ ;;
+ probe)
+ ## Optional: Probe for the necessity of a reload,
+ ## give out the argument which is required for a reload.
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
+ exit 1
+ ;;
+esac
+rc_exit
diff --git a/path_priority/pp_alua/Makefile b/path_priority/pp_alua/Makefile
index 6f356a1..ce78455 100644
--- a/path_priority/pp_alua/Makefile
+++ b/path_priority/pp_alua/Makefile
@@ -35,19 +35,15 @@ glibc: $(OBJS)
klibc: $(OBJS)
$(CC) -static -o $(EXEC) $(OBJS)
-install: $(EXEC) $(EXEC).8.gz
+install: $(EXEC) $(EXEC).8
$(INSTALL) -s -m 755 $(EXEC) $(DESTDIR)$(bindir)/$(EXEC)
- $(INSTALL) -m 644 $(EXEC).8.gz $(DESTDIR)$(mandir)/$(EXEC).8.gz
+ $(INSTALL) -m 644 $(EXEC).8 $(DESTDIR)$(mandir)/$(EXEC).8
uninstall:
rm $(DESTDIR)$(bindir)/$(EXEC)
- rm $(DESTDIR)$(mandir)/$(EXEC).8.gz
clean:
- rm -f *.o *.gz $(EXEC)
-
-$(EXEC).8.gz: $(EXEC).8
- $(GZIP) $< >$@
+ rm -f *.o $(EXEC)
main.o: main.c rtpg.h spc3.h
diff --git a/path_priority/pp_balance_units/Makefile b/path_priority/pp_balance_units/Makefile
index cb1e6c6..43a0fc2 100644
--- a/path_priority/pp_balance_units/Makefile
+++ b/path_priority/pp_balance_units/Makefile
@@ -22,7 +22,7 @@ EXEC = mpath_prio_balance_units
all: $(BUILD)
prepare:
- rm -f core *.o *.gz
+ rm -f core *.o
glibc: prepare $(OBJS)
$(CC) -o $(EXEC) $(OBJS) $(LDFLAGS)
@@ -41,4 +41,4 @@ uninstall:
rm $(DESTDIR)$(bindir)/$(EXEC)
clean:
- rm -f core *.o $(EXEC) *.gz
+ rm -f core *.o $(EXEC)
diff --git a/path_priority/pp_hds_modular/pp_hds_modular.c b/path_priority/pp_hds_modular/pp_hds_modular.c
index 7411508..10b28b8 100644
--- a/path_priority/pp_hds_modular/pp_hds_modular.c
+++ b/path_priority/pp_hds_modular/pp_hds_modular.c
@@ -120,7 +120,7 @@ int main (int argc, char **argv)
int hds_modular_prio (const char *dev)
{
int sg_fd, k;
- char vendor[8];
+ char vendor[9];
char product[32];
char serial[32];
char ldev[32];

View File

@ -0,0 +1,297 @@
From 15805c2a7b107bdbc61880c9c3224a06ae04cc70 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Tue, 29 Apr 2008 14:12:57 +0200
Subject: [PATCH] Update hardware table
Update the built-in hardware table with definitions for various
new machines.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
libmultipath/hwtable.c | 135 ++++++++++++++++++++++++++++++++++++++----------
1 files changed, 107 insertions(+), 28 deletions(-)
diff --git a/libmultipath/hwtable.c b/libmultipath/hwtable.c
index d938379..5ed7090 100644
--- a/libmultipath/hwtable.c
+++ b/libmultipath/hwtable.c
@@ -84,7 +84,7 @@ static struct hwentry default_hw[] = {
.pgpolicy = MULTIBUS,
.pgfailback = FAILBACK_UNDEF,
.rr_weight = RR_WEIGHT_NONE,
- .no_path_retry = NO_PATH_RETRY_UNDEF,
+ .no_path_retry = 12,
.minio = DEFAULT_MINIO,
.checker_name = DIRECTIO,
.prio_name = DEFAULT_PRIO,
@@ -100,7 +100,7 @@ static struct hwentry default_hw[] = {
.pgpolicy = GROUP_BY_PRIO,
.pgfailback = FAILBACK_UNDEF,
.rr_weight = RR_WEIGHT_NONE,
- .no_path_retry = NO_PATH_RETRY_UNDEF,
+ .no_path_retry = 12,
.minio = DEFAULT_MINIO,
.checker_name = HP_SW,
.prio_name = PRIO_HP_SW,
@@ -116,7 +116,7 @@ static struct hwentry default_hw[] = {
.pgpolicy = GROUP_BY_PRIO,
.pgfailback = -FAILBACK_IMMEDIATE,
.rr_weight = RR_WEIGHT_NONE,
- .no_path_retry = NO_PATH_RETRY_UNDEF,
+ .no_path_retry = 12,
.minio = DEFAULT_MINIO,
.checker_name = TUR,
.prio_name = PRIO_ALUA,
@@ -128,8 +128,8 @@ static struct hwentry default_hw[] = {
.features = DEFAULT_FEATURES,
.hwhandler = DEFAULT_HWHANDLER,
.selector = DEFAULT_SELECTOR,
- .pgpolicy = MULTIBUS,
- .pgfailback = FAILBACK_UNDEF,
+ .pgpolicy = GROUP_BY_PRIO,
+ .pgfailback = -FAILBACK_IMMEDIATE,
.rr_weight = RR_WEIGHT_NONE,
.no_path_retry = 12,
.minio = DEFAULT_MINIO,
@@ -137,9 +137,9 @@ static struct hwentry default_hw[] = {
.prio_name = DEFAULT_PRIO,
},
{
- /* EVA 3000/5000 with new firmware */
+ /* EVA 3000/5000 with new firmware, EVA 4000/6000/8000 */
.vendor = "(COMPAQ|HP)",
- .product = "(MSA|HSV)1.1.*",
+ .product = "HSV1[01]1|HSV2[01]0|HSV300",
.getuid = DEFAULT_GETUID,
.features = DEFAULT_FEATURES,
.hwhandler = DEFAULT_HWHANDLER,
@@ -147,26 +147,26 @@ static struct hwentry default_hw[] = {
.pgpolicy = GROUP_BY_PRIO,
.pgfailback = -FAILBACK_IMMEDIATE,
.rr_weight = RR_WEIGHT_NONE,
- .no_path_retry = NO_PATH_RETRY_UNDEF,
+ .no_path_retry = 12,
.minio = DEFAULT_MINIO,
.checker_name = TUR,
.prio_name = PRIO_ALUA,
},
{
- /* EVA 4000/6000/8000 */
+ /* HP MSA2000 product family */
.vendor = "HP",
- .product = "HSV2.*",
+ .product = "MSA2[02]12*",
.getuid = DEFAULT_GETUID,
.features = DEFAULT_FEATURES,
.hwhandler = DEFAULT_HWHANDLER,
.selector = DEFAULT_SELECTOR,
- .pgpolicy = GROUP_BY_PRIO,
+ .pgpolicy = MULTIBUS,
.pgfailback = -FAILBACK_IMMEDIATE,
.rr_weight = RR_WEIGHT_NONE,
- .no_path_retry = NO_PATH_RETRY_UNDEF,
+ .no_path_retry = 12,
.minio = DEFAULT_MINIO,
.checker_name = TUR,
- .prio_name = PRIO_ALUA,
+ .prio_name = DEFAULT_PRIO,
},
{
/* HP Smart Array */
@@ -179,9 +179,9 @@ static struct hwentry default_hw[] = {
.pgpolicy = MULTIBUS,
.pgfailback = FAILBACK_UNDEF,
.rr_weight = RR_WEIGHT_NONE,
- .no_path_retry = NO_PATH_RETRY_UNDEF,
+ .no_path_retry = 12,
.minio = DEFAULT_MINIO,
- .checker_name = TUR,
+ .checker_name = CCISS_TUR,
.prio_name = DEFAULT_PRIO,
},
/*
@@ -321,19 +321,67 @@ static struct hwentry default_hw[] = {
.prio_name = DEFAULT_PRIO,
},
{
- /* IBM DS4100 / FAStT100 */
+ /* IBM FAStT 1722-600 */
+ .vendor = "IBM",
+ .product = "1722-600",
+ .getuid = DEFAULT_GETUID,
+ .features = "1 queue_if_no_path",
+ .hwhandler = "1 rdac",
+ .selector = DEFAULT_SELECTOR,
+ .pgpolicy = GROUP_BY_PRIO,
+ .pgfailback = -FAILBACK_IMMEDIATE,
+ .rr_weight = RR_WEIGHT_NONE,
+ .no_path_retry = 300,
+ .minio = DEFAULT_MINIO,
+ .checker_name = RDAC,
+ .prio_name = PRIO_RDAC,
+ },
+ {
+ /* IBM DS4400 / FAStT700 */
.vendor = "IBM",
.product = "1742",
.getuid = DEFAULT_GETUID,
.features = DEFAULT_FEATURES,
- .hwhandler = DEFAULT_HWHANDLER,
+ .hwhandler = "1 rdac",
.selector = DEFAULT_SELECTOR,
.pgpolicy = GROUP_BY_PRIO,
.pgfailback = -FAILBACK_IMMEDIATE,
.rr_weight = RR_WEIGHT_NONE,
- .no_path_retry = NO_PATH_RETRY_UNDEF,
+ .no_path_retry = NO_PATH_RETRY_QUEUE,
.minio = DEFAULT_MINIO,
- .checker_name = TUR,
+ .checker_name = RDAC,
+ .prio_name = PRIO_RDAC,
+ },
+ {
+ /* IBM DS4700 */
+ .vendor = "IBM",
+ .product = "1814",
+ .getuid = DEFAULT_GETUID,
+ .features = DEFAULT_FEATURES,
+ .hwhandler = "1 rdac",
+ .selector = DEFAULT_SELECTOR,
+ .pgpolicy = GROUP_BY_PRIO,
+ .pgfailback = -FAILBACK_IMMEDIATE,
+ .rr_weight = RR_WEIGHT_NONE,
+ .no_path_retry = NO_PATH_RETRY_QUEUE,
+ .minio = DEFAULT_MINIO,
+ .checker_name = RDAC,
+ .prio_name = PRIO_RDAC,
+ },
+ {
+ /* IBM DS4800 */
+ .vendor = "IBM",
+ .product = "1815",
+ .getuid = DEFAULT_GETUID,
+ .features = DEFAULT_FEATURES,
+ .hwhandler = "1 rdac",
+ .selector = DEFAULT_SELECTOR,
+ .pgpolicy = GROUP_BY_PRIO,
+ .pgfailback = -FAILBACK_IMMEDIATE,
+ .rr_weight = RR_WEIGHT_NONE,
+ .no_path_retry = NO_PATH_RETRY_QUEUE,
+ .minio = DEFAULT_MINIO,
+ .checker_name = RDAC,
.prio_name = PRIO_RDAC,
},
{
@@ -342,14 +390,14 @@ static struct hwentry default_hw[] = {
.product = "3526",
.getuid = DEFAULT_GETUID,
.features = DEFAULT_FEATURES,
- .hwhandler = DEFAULT_HWHANDLER,
+ .hwhandler = "1 rdac",
.selector = DEFAULT_SELECTOR,
.pgpolicy = GROUP_BY_PRIO,
.pgfailback = -FAILBACK_IMMEDIATE,
.rr_weight = RR_WEIGHT_NONE,
- .no_path_retry = NO_PATH_RETRY_UNDEF,
+ .no_path_retry = NO_PATH_RETRY_QUEUE,
.minio = DEFAULT_MINIO,
- .checker_name = TUR,
+ .checker_name = RDAC,
.prio_name = PRIO_RDAC,
},
{
@@ -449,7 +497,7 @@ static struct hwentry default_hw[] = {
.checker_name = DIRECTIO,
.prio_name = DEFAULT_PRIO,
},
- /*
+ /*
* NETAPP controller family
*
* Maintainer : Dave Wysochanski
@@ -470,7 +518,7 @@ static struct hwentry default_hw[] = {
.checker_name = DIRECTIO,
.prio_name = PRIO_NETAPP,
},
- /*
+ /*
* IBM NSeries (NETAPP) controller family
*
* Maintainer : Dave Wysochanski
@@ -538,7 +586,7 @@ static struct hwentry default_hw[] = {
.product = "TP9[45]00",
.getuid = DEFAULT_GETUID,
.features = DEFAULT_FEATURES,
- .hwhandler = DEFAULT_HWHANDLER,
+ .hwhandler = "1 rdac",
.selector = DEFAULT_SELECTOR,
.pgpolicy = GROUP_BY_PRIO,
.pgfailback = -FAILBACK_IMMEDIATE,
@@ -553,7 +601,7 @@ static struct hwentry default_hw[] = {
.product = "IS.*",
.getuid = DEFAULT_GETUID,
.features = DEFAULT_FEATURES,
- .hwhandler = DEFAULT_HWHANDLER,
+ .hwhandler = "1 rdac",
.selector = DEFAULT_SELECTOR,
.pgpolicy = GROUP_BY_PRIO,
.pgfailback = -FAILBACK_IMMEDIATE,
@@ -574,7 +622,7 @@ static struct hwentry default_hw[] = {
.product = "OPENstorage D280",
.getuid = DEFAULT_GETUID,
.features = DEFAULT_FEATURES,
- .hwhandler = DEFAULT_HWHANDLER,
+ .hwhandler = "1 rdac",
.selector = DEFAULT_SELECTOR,
.pgpolicy = GROUP_BY_PRIO,
.pgfailback = -FAILBACK_IMMEDIATE,
@@ -605,7 +653,7 @@ static struct hwentry default_hw[] = {
.checker_name = DIRECTIO,
.prio_name = DEFAULT_PRIO,
},
- /*
+ /*
* Pivot3 RAIGE
*
* Maintainer : Bart Brooks, Pivot3
@@ -626,6 +674,37 @@ static struct hwentry default_hw[] = {
.checker_name = TUR,
.prio_name = DEFAULT_PRIO,
},
+ {
+ .vendor = "SUN",
+ .product = "CSM200_R",
+ .getuid = DEFAULT_GETUID,
+ .features = DEFAULT_FEATURES,
+ .hwhandler = "1 rdac",
+ .selector = DEFAULT_SELECTOR,
+ .pgpolicy = GROUP_BY_PRIO,
+ .pgfailback = -FAILBACK_IMMEDIATE,
+ .rr_weight = RR_WEIGHT_NONE,
+ .no_path_retry = NO_PATH_RETRY_QUEUE,
+ .minio = DEFAULT_MINIO,
+ .checker_name = RDAC,
+ .prio_name = PRIO_RDAC,
+ },
+ /* SUN/LSI 2540 */
+ {
+ .vendor = "SUN",
+ .product = "LCSM100_F",
+ .getuid = DEFAULT_GETUID,
+ .features = DEFAULT_FEATURES,
+ .hwhandler = "1 rdac",
+ .selector = DEFAULT_SELECTOR,
+ .pgpolicy = GROUP_BY_PRIO,
+ .pgfailback = -FAILBACK_IMMEDIATE,
+ .rr_weight = RR_WEIGHT_NONE,
+ .no_path_retry = NO_PATH_RETRY_QUEUE,
+ .minio = DEFAULT_MINIO,
+ .checker_name = RDAC,
+ .prio_name = PRIO_RDAC,
+ },
/*
* EOL
*/
--
1.5.2.4

View File

@ -0,0 +1,135 @@
From 33ade231f9ce022b0d8eb7c56caf23b60b6a8a5c Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Tue, 29 Apr 2008 13:43:42 +0200
Subject: [PATCH] Use 'mpatha' for user_friendly_names option
We really should use 'mpatha' instead of 'mpath0' for the
generated names with the user_friendly_names option.
Otherwise we can't distinguish them from EVMS names.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
libmultipath/alias.c | 61 +++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 53 insertions(+), 8 deletions(-)
diff --git a/libmultipath/alias.c b/libmultipath/alias.c
index ca434fe..517b055 100644
--- a/libmultipath/alias.c
+++ b/libmultipath/alias.c
@@ -179,6 +179,46 @@ fail:
return -1;
}
+static int
+format_devname(char *name, int id, int len)
+{
+ int pos;
+
+ memset(name,0, len);
+ strcpy(name,"mpath");
+ for (pos = len - 1; pos >= 5; pos--) {
+ name[pos] = 'a' + id % 26;
+ if (id < 26)
+ break;
+ id /= 26;
+ id--;
+ }
+ memmove(name + 5, name + pos, len - pos);
+ name[5 + len - pos] = '\0';
+ return (5 + len - pos);
+}
+
+static int
+scan_devname(char *alias)
+{
+ char *c;
+ int i, n = 0;
+
+ if (strncmp(alias, "mpath", 5))
+ return -1;
+
+ c = alias + 5;
+ while (*c != '\0' && *c != ' ' && *c != '\t') {
+ i = *c - 'a';
+ n = ( n * 26 ) + i;
+ c++;
+ if (*c < 'a' || *c > 'z')
+ break;
+ n++;
+ }
+
+ return n;
+}
static int
lookup_binding(FILE *f, char *map_wwid, char **map_alias)
@@ -200,7 +240,8 @@ lookup_binding(FILE *f, char *map_wwid, char **map_alias)
alias = strtok(buf, " \t");
if (!alias) /* blank line */
continue;
- if (sscanf(alias, "mpath%d", &curr_id) == 1 && curr_id >= id)
+ curr_id = scan_devname(alias);
+ if (curr_id >= id)
id = curr_id + 1;
wwid = strtok(NULL, " \t");
if (!wwid){
@@ -221,7 +262,7 @@ lookup_binding(FILE *f, char *map_wwid, char **map_alias)
}
condlog(3, "No matching wwid [%s] in bindings file.", map_wwid);
return id;
-}
+}
static int
rlookup_binding(FILE *f, char **map_wwid, char *map_alias)
@@ -243,7 +284,8 @@ rlookup_binding(FILE *f, char **map_wwid, char *map_alias)
alias = strtok(buf, " \t");
if (!alias) /* blank line */
continue;
- if (sscanf(alias, "mpath%d", &curr_id) == 1 && curr_id >= id)
+ curr_id = scan_devname(alias);
+ if (curr_id >= id)
id = curr_id + 1;
wwid = strtok(NULL, " \t");
if (!wwid){
@@ -264,7 +306,7 @@ rlookup_binding(FILE *f, char **map_wwid, char *map_alias)
}
condlog(3, "No matching alias [%s] in bindings file.", map_alias);
return id;
-}
+}
static char *
allocate_binding(int fd, char *wwid, int id)
@@ -272,13 +314,16 @@ allocate_binding(int fd, char *wwid, int id)
char buf[LINE_MAX];
off_t offset;
char *alias, *c;
-
+ int i;
+
if (id < 0) {
condlog(0, "Bindings file full. Cannot allocate new binding");
return NULL;
}
-
- snprintf(buf, LINE_MAX, "mpath%d %s\n", id, wwid);
+
+ i = format_devname(buf, id, LINE_MAX);
+ c = buf + i;
+ snprintf(c,LINE_MAX - i, " %s\n", wwid);
buf[LINE_MAX - 1] = '\0';
offset = lseek(fd, 0, SEEK_END);
@@ -304,7 +349,7 @@ allocate_binding(int fd, char *wwid, int id)
condlog(3, "Created new binding [%s] for WWID [%s]", alias,
wwid);
return alias;
-}
+}
char *
get_user_friendly_alias(char *wwid, char *file)
--
1.5.2.4

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Tue Apr 29 17:05:19 CEST 2008 - hare@suse.de
- Merge in fixes from upstream
- Merge fixes from SLES10 SP2
-------------------------------------------------------------------
Wed Sep 19 15:30:41 CEST 2007 - hare@suse.de

View File

@ -1,7 +1,7 @@
#
# spec file for package multipath-tools (Version 0.4.7)
#
# Copyright (c) 2007 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany.
# This file and all modifications and additions to the pristine
# package are under the same license as the package itself.
#
@ -10,22 +10,34 @@
# norootforbuild
Name: multipath-tools
BuildRequires: device-mapper-devel libaio-devel readline-devel
Url: http://christophe.varoqui.free.fr/
License: BSD 3-Clause, GPL v2 or later
License: BSD 3-Clause; GPL v2 or later; LGPL v2.1 or later; Public Domain, Freeware; X11/MIT
Group: System/Base
Requires: device-mapper kpartx
PreReq: %insserv_prereq
PreReq: %insserv_prereq %fillup_prereq coreutils grep diffutils
AutoReqProv: on
Version: 0.4.7
Release: 77
Release: 118
Summary: Tools to Manage Multipathed Devices with the device-mapper
Source: multipath-tools-%{version}.tar.bz2
Source1: multipath.init.suse
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Patch0: %{name}-git-update.patch
Patch10: %{name}-suse-update
Patch11: %{name}-add-dm_linear
Patch1: %{name}-block-SIGPIPE
Patch2: %{name}-crash-on-shutdown
Patch3: %{name}-use-mpatha-user_friendly_names
Patch4: %{name}-fixup-varargs-usage
Patch5: %{name}-libdevmapper-garbage-on-shutdown
Patch6: %{name}-retry-sg_read
Patch7: %{name}-quieten-callouts
Patch8: %{name}-update-hwtable
Patch9: %{name}-add-cciss-tur
Patch10: %{name}-remove-DAEMON-defines
Patch11: %{name}-suse-build-fixes
Patch12: %{name}-add-dm_linear
%description
This package provides the tools to manage multipathed devices by
@ -49,6 +61,7 @@ Authors:
Christophe Varoqui <christophe.varoqui@free.fr>
%package -n kpartx
License: BSD 3-Clause; GPL v2 or later; LGPL v2.1 or later; Public Domain, Freeware; X11/MIT
Summary: Manages partition tables on device-mapper devices
Group: System/Base
Requires: device-mapper
@ -66,8 +79,19 @@ Authors:
%prep
%setup -n multipath-tools-%{version}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
cp %{S:1} multipath/multipath.init.suse
%build
make OPTFLAGS="$RPM_OPT_FLAGS" BUILD=glibc
@ -103,23 +127,13 @@ mkdir -p $RPM_BUILD_ROOT/var/cache/multipath/
%config /etc/init.d/multipathd
%config /etc/init.d/boot.multipath
%config /etc/udev/rules.d/71-multipath.rules
/sbin/devmap_name
/lib/multipath
/sbin/multipath
/sbin/multipathd
/sbin/mpath_prio_netapp
/sbin/mpath_prio_balance_units
/sbin/mpath_prio_random
/sbin/mpath_prio_alua
/sbin/mpath_prio_emc
/sbin/mpath_prio_rdac
/sbin/mpath_prio_hds_modular
/sbin/mpath_prio_hp_sw
%attr (0700, root, root) /var/cache/multipath
%{_mandir}/man8/devmap_name.8*
%{_mandir}/man8/multipath.8*
%{_mandir}/man5/multipath.conf.5*
%{_mandir}/man8/multipathd.8*
%{_mandir}/man8/mpath_prio_alua.8*
%files -n kpartx
%defattr(-,root,root)
@ -132,65 +146,69 @@ mkdir -p $RPM_BUILD_ROOT/var/cache/multipath/
/lib/udev/kpartx_id
/lib/udev/dm_linear
%{_mandir}/man8/kpartx.8*
%changelog
* Wed Sep 19 2007 - hare@suse.de
* Tue Apr 29 2008 hare@suse.de
- Merge in fixes from upstream
- Merge fixes from SLES10 SP2
* Wed Sep 19 2007 hare@suse.de
- Fixup generated dm_linear udev rules (#218122)
* Thu Aug 30 2007 - hare@suse.de
* Thu Aug 30 2007 hare@suse.de
- Rework dm_linear; udev rules should only be
created if the feature was activated (#302422)
* Fri Aug 10 2007 - hare@suse.de
* Fri Aug 10 2007 hare@suse.de
- Implement dm_linear (#218122)
* Thu Aug 02 2007 - hare@suse.de
* Thu Aug 02 2007 hare@suse.de
- Merge in latest fixes from upstream
- Remove local patches; merge with upstream
- Fix kpartx handling of extended partitions
- Use underscores for partition names (#293792)
* Mon May 21 2007 - hare@suse.de
* Mon May 21 2007 hare@suse.de
- Rework udev handling
- Split off kpartx package
* Mon May 14 2007 - hare@suse.de
* Mon May 14 2007 hare@suse.de
- Merge in latest fixes from upstream
- Add all SuSE specific files to git repository.
* Fri May 11 2007 - hare@suse.de
* Fri May 11 2007 hare@suse.de
- Include latest changes from upstream
- Remove libsysfs (242766)
- Handle extended partitions for kpartx
* Mon Dec 04 2006 - dmueller@suse.de
* Mon Dec 04 2006 dmueller@suse.de
- don't build as root
* Fri Nov 17 2006 - hare@suse.de
* Fri Nov 17 2006 hare@suse.de
- integrate upstream fixes
- update udev rule for YaST2 dmraid support (217807])
* Mon Nov 06 2006 - hare@suse.de
* Mon Nov 06 2006 hare@suse.de
- Really fixup udev rule (216167).
* Fri Oct 20 2006 - ro@suse.de
* Fri Oct 20 2006 ro@suse.de
- make it build
* Mon Sep 25 2006 - hare@suse.de
* Mon Sep 25 2006 hare@suse.de
- update to latest fixes from git tree
- remove fixes integrated in upstream
- fixup udev rule (#203688)
* Thu Sep 14 2006 - ro@suse.de
* Thu Sep 14 2006 ro@suse.de
- use device-mapper-devel in BuildRequires
* Thu Aug 31 2006 - hare@suse.de
* Thu Aug 31 2006 hare@suse.de
- include latest fixes from git tree
- update kpartx_id and udev rules to work
with dmraid.
- Fix return value for multipath -l
* Thu Aug 17 2006 - ro@suse.de
* Thu Aug 17 2006 ro@suse.de
- workaround problem in git-patch
normal patch can't do a "rename", so copy file first
* Tue Jul 11 2006 - hare@suse.de
* Tue Jul 11 2006 hare@suse.de
- Update to official version 0.4.7
- Refactor git update to apply to 0.4.7
* Wed Jun 28 2006 - hare@suse.de
* Wed Jun 28 2006 hare@suse.de
- Remove blacklisting of dasd device node,
use product_blacklist instead (#188688)
* Mon Jun 12 2006 - hare@suse.de
* Mon Jun 12 2006 hare@suse.de
- Add 72-multipath-compat.rules to create 'by-name'
symlink again for compability (#183663)
* Fri Jun 02 2006 - hare@suse.de
* Fri Jun 02 2006 hare@suse.de
- Merge in fixed from upstream
- Set device-mapper name correctly (#181127)
* Thu Jun 01 2006 - hare@suse.de
* Thu Jun 01 2006 hare@suse.de
- Merge in fixes from upstream
- Fixup aliasing handling
- Fix string length in pp_alua
@ -198,89 +216,89 @@ mkdir -p $RPM_BUILD_ROOT/var/cache/multipath/
- Fixup 71-multipath.rules to work correctly with the
updated device-mapper online/offline events (#176516 - LTC23961)
- Add kpartx_id for the updated 71-multipath.rules
* Mon May 22 2006 - schwab@suse.de
* Mon May 22 2006 schwab@suse.de
- Don't strip binaries.
* Tue May 02 2006 - hare@suse.de
* Tue May 02 2006 hare@suse.de
- Merge in fixes from upstream
- Merged local patches
- Added hds_modular prioritizer
- Remove merged patches
- Allow for setting of maximum number of open files (#149979)
- Implement 'stop' for init scripts
* Mon Apr 10 2006 - hare@suse.de
* Mon Apr 10 2006 hare@suse.de
- Lowering priority for pp_tpc
- Split off DS6000 to fixup priority handler (#161347)
* Wed Apr 05 2006 - hare@suse.de
* Wed Apr 05 2006 hare@suse.de
- Disable debug messages in pp_tpc.
* Wed Mar 29 2006 - hare@suse.de
* Wed Mar 29 2006 hare@suse.de
- Explicitely create partitions at boot time (#159927)
* Thu Mar 23 2006 - hare@suse.de
* Thu Mar 23 2006 hare@suse.de
- Add hwtable entry for IBM 3526.
* Tue Mar 14 2006 - hare@suse.de
* Tue Mar 14 2006 hare@suse.de
- Fix another typo in mpath_id.
* Tue Mar 14 2006 - hare@suse.de
* Tue Mar 14 2006 hare@suse.de
- Fix typo in mpath_id.
* Mon Mar 13 2006 - hare@suse.de
* Mon Mar 13 2006 hare@suse.de
- Fix autobuild warnings.
- Include some minor fixed from upstream.
* Thu Mar 09 2006 - hare@suse.de
* Thu Mar 09 2006 hare@suse.de
- Add mpath_id program to call kpartx only on multipathed
devices (#149995 - LTC21557).
- Include latest fixes from upstream.
* Wed Feb 08 2006 - hare@suse.de
* Wed Feb 08 2006 hare@suse.de
- Add device blacklisting (#85778)
- Further manpage installation fixes (#146179, #147053, #147911)
* Wed Jan 25 2006 - mls@suse.de
* Wed Jan 25 2006 mls@suse.de
- converted neededforbuild to BuildRequires
* Thu Jan 19 2006 - hare@suse.de
* Thu Jan 19 2006 hare@suse.de
- Fix manpage installation.
* Tue Jan 17 2006 - hare@suse.de
* Tue Jan 17 2006 hare@suse.de
- Include latest git fixes
- Remove old patches which are now upstream
- Add new hwtable entry for shark (#142176)
* Fri Dec 16 2005 - hare@suse.de
* Fri Dec 16 2005 hare@suse.de
- Fix dependencies for /etc/init.d/boot.multipath
- Fix kpartx rules to generate proper partition names.
* Wed Dec 07 2005 - hare@suse.de
* Wed Dec 07 2005 hare@suse.de
- Update to multipath-tools-0.4.6
- Include latest git fixes
- Port patches from SLES9 SP3
* Mon Oct 31 2005 - dmueller@suse.de
* Mon Oct 31 2005 dmueller@suse.de
- don't build as root
* Mon Sep 05 2005 - matz@suse.de
* Mon Sep 05 2005 matz@suse.de
- Fix broken usage of self-defined syscall [#114933].
* Fri Aug 26 2005 - hare@suse.de
* Fri Aug 26 2005 hare@suse.de
- Fix kpartx DASD partition support
* Thu Aug 04 2005 - hare@suse.de
* Thu Aug 04 2005 hare@suse.de
- Add 'directio' path checker
- Add support for S/390 DASD (PAV enablement).
- Update to package from SLES9
* Thu Jun 23 2005 - lmb@suse.de
* Thu Jun 23 2005 lmb@suse.de
- LUs with a WWN containing "fd" were blacklisted (#93562).
* Thu Jun 16 2005 - lmb@suse.de
* Thu Jun 16 2005 lmb@suse.de
- Remove stray newline character from /dev/disk/by-name/ entries
(#85798, #86763)
- Clear /dev/disk/by-name/ on boot. (#85978)
- scsi_id now handles EMC Symmetrix; remove work-around for #86760.
* Wed Jun 15 2005 - meissner@suse.de
* Wed Jun 15 2005 meissner@suse.de
- use RPM_OPT_FLAGS.
* Mon Jun 13 2005 - ro@suse.de
* Tue Jun 14 2005 ro@suse.de
- neededforbuild: udev -> sysfsutils
* Tue Jun 07 2005 - lmb@suse.de
* Tue Jun 07 2005 lmb@suse.de
- Import fixes from upstream.
- Hardware table updates for IBM ESS and EMC CX (#81688).
- Reinstate paths correctly after failure/restore cycle (#85781,
[#86444]).
- Create map names again and fix segfault in devmap_name (#85798).
* Tue May 24 2005 - hare@suse.de
* Tue May 24 2005 hare@suse.de
- Fix segmentation fault with EMC Symmetrix (#85614).
- Update EMC Symmetrix entry in hwtable.
* Mon May 23 2005 - hare@suse.de
* Mon May 23 2005 hare@suse.de
- Add hwtable entry for IBM DS6000. (#63903)
- Do a rescan for devices if multipath command line option is set.
* Fri May 20 2005 - hare@suse.de
* Fri May 20 2005 hare@suse.de
- Fix devmap_name to use mapname and return proper status (#84748).
* Thu May 12 2005 - lmb@suse.de
* Thu May 12 2005 lmb@suse.de
- Don't complain about default prio callout command (#81695).
- Reflect recent changes in boot.multipath as well as multipathd init
scripts.
@ -288,72 +306,72 @@ mkdir -p $RPM_BUILD_ROOT/var/cache/multipath/
(#81679).
- killproc/startproc/checkproc can't be used with multipathd because of
the way the daemon switches to its own namespace (#80443).
* Mon May 09 2005 - hare@suse.de
* Mon May 09 2005 hare@suse.de
- Use proper path checker for SGI TPC arrays.
- Update hwtable entries for SGI TP9400 and SGI TP9500.
- Write correct PID file (#80443).
* Mon Apr 25 2005 - lmb@suse.de
* Mon Apr 25 2005 lmb@suse.de
- Update to 0.4.4: pp_alua now licensed as GPL (#78628).
- multipath-tools-oom-adj.patch: oom_adj to a valid value.
* Thu Apr 21 2005 - lmb@suse.de
* Thu Apr 21 2005 lmb@suse.de
- Update to 0.4.4-pre18 which fixes the multipathd to initialize
correctly in the absence of a configuration file (79239).
* Wed Apr 20 2005 - lmb@suse.de
* Wed Apr 20 2005 lmb@suse.de
- Put multipath cache back into /dev because /var might not be mounted.
- Correct hwtable entry SGI TP9400, TP9500 and IBM 3542.
* Wed Apr 20 2005 - lmb@suse.de
* Wed Apr 20 2005 lmb@suse.de
- Update to 0.4.4-pre16
- Build against device-mapper.1.01.xx correctly.
* Tue Apr 19 2005 - lmb@suse.de
* Tue Apr 19 2005 lmb@suse.de
- Build w/o device-mapper update again.
* Mon Apr 18 2005 - lmb@suse.de
* Mon Apr 18 2005 lmb@suse.de
- Update to 0.4.4-pre14
- Build versus device-mapper-1.01.01 to prevent deadlocks in
kernel-space.
- Fix devmap_name to work with udev.
- Fix startup of multipathd w/o configuration file present.
* Fri Apr 15 2005 - lmb@suse.de
* Fri Apr 15 2005 lmb@suse.de
- Add path priority checker for EMC CLARiiON and make necessary
adjustments so that it gets called by default (#62491).
- Set the default udev dir to '/dev'
* Fri Apr 15 2005 - hare@suse.de
* Fri Apr 15 2005 hare@suse.de
- Fix to allocate default strings (#78056)
- Fix default entry for TPC9500.
* Wed Apr 13 2005 - hare@suse.de
* Wed Apr 13 2005 hare@suse.de
- Added pp_alua path priority checker.
- Update to multipath-tools-0.4.4-pre12.
* Mon Apr 11 2005 - hare@suse.de
* Mon Apr 11 2005 hare@suse.de
- Update to multipath-tools-0.4.4-pre10.
* Fri Apr 08 2005 - hare@suse.de
* Fri Apr 08 2005 hare@suse.de
- Update multipath to handle only true multipath devices (#62491).
- Update kpartx to use the device mapper target name if available.
- Add boot.multipath script for early set up of multipath targets.
* Thu Mar 31 2005 - hare@suse.de
* Thu Mar 31 2005 hare@suse.de
- Update devmap_name to select targets by table type (#62493).
* Tue Jan 25 2005 - lmb@suse.de
* Tue Jan 25 2005 lmb@suse.de
- Update to 0.4.2 and fix some bugs + add support for the extended DM
multipath kernel module. (#47491)
* Thu Nov 11 2004 - hare@suse.de
* Thu Nov 11 2004 hare@suse.de
- Fix bugs to make it work on S/390 (#47491).
* Fri Nov 05 2004 - hare@suse.de
* Fri Nov 05 2004 hare@suse.de
- Update to version 0.3.6 (#47491).
- Fix multipath init script
- Install configuration file example.
- Install multipathd in /sbin instead of /usr/bin.
* Tue Jul 20 2004 - fehr@suse.de
* Tue Jul 20 2004 fehr@suse.de
- updated README mp-tools-issues.pdf (see #40640)
* Wed Jun 09 2004 - fehr@suse.de
* Wed Jun 09 2004 fehr@suse.de
- added pdf with README to package (see #40640)
* Thu Jun 03 2004 - fehr@suse.de
* Thu Jun 03 2004 fehr@suse.de
- updated to version 0.2.1
- removed patches zero-currpath.patch and rm-newline-in-name.patch
already contained in 0.2.1
* Thu Jun 03 2004 - fehr@suse.de
* Thu Jun 03 2004 fehr@suse.de
- added patch zero-currpath.patch (see bugzilla #40640)
* Wed May 26 2004 - uli@suse.de
* Wed May 26 2004 uli@suse.de
- fixed to build on s390x
* Wed May 26 2004 - fehr@suse.de
* Wed May 26 2004 fehr@suse.de
- added patch rm-newline-in-name.patch (see bugzilla #40640)
* Tue May 25 2004 - fehr@suse.de
* Tue May 25 2004 fehr@suse.de
- created initial version of a SuSE package from version 0.2.0 of
multipath tools

127
multipath.init.suse Normal file
View File

@ -0,0 +1,127 @@
#! /bin/sh
# Copyright (c) 2005 SuSE GmbH Nuernberg, Germany.
#
# Author: Hannes Reinecke <feedback@suse.de>
#
# init.d/boot.multipath
#
### BEGIN INIT INFO
# Provides: boot.multipath
# Required-Start: boot.device-mapper boot.udev
# Required-Stop:
# Default-Start: B
# Default-Stop:
# Description: Create multipath device targets
### END INIT INFO
PATH=/bin:/usr/bin:/sbin:/usr/sbin
PROGRAM=/sbin/multipath
# Set the maximum number of open files
MAX_OPEN_FDS=4096
test -x $PROGRAM || exit 5
# Shell functions sourced from /etc/rc.status:
# rc_check check and set local and overall rc status
# rc_status check and set local and overall rc status
# rc_status -v ditto but be verbose in local rc status
# rc_status -v -r ditto and clear the local rc status
# rc_failed set local and overall rc status to failed
# rc_reset clear local rc status (overall remains)
# rc_exit exit appropriate to overall rc status
. /etc/rc.status
# First reset status of this service
rc_reset
# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - misc error
# 2 - invalid or excess args
# 3 - unimplemented feature (e.g. reload)
# 4 - insufficient privilege
# 5 - program not installed
# 6 - program not configured
# 7 - program is not running
#
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signalling is not supported) are
# considered a success.
case "$1" in
start)
echo -n "Creating multipath targets"
# Check whether multipath daemon is already running
if /sbin/multipathd -k"list paths" > /dev/null 2>&1 ; then
echo -n " (multipathd running)"
rc_status -v
rc_exit
fi
# Load prerequisite module
modprobe dm-multipath
# Be a chicken and flush all existing maps
$PROGRAM -F
# Clear /dev/disk/by-name/ prior to start-up; multipath will
# recreate them.
rm -f /dev/disk/by-name/* 2>&1 >/dev/null
# Set the maximum number of open files
if [ -n "$MAX_OPEN_FDS" ] ; then
ulimit -n $MAX_OPEN_FDS
fi
# Start the program directly as checkproc doesn't work here
$PROGRAM -v 0
# Create all partitions which might have been missing
for map in $(/sbin/dmsetup ls --target multipath | sed '/No devices/d' | sort -n +2 | sed -n 's/.*, \(.*\))/\1/p' ) ; do
wait=5
while [ $wait -gt 0 ] ; do
[ -e /dev/dm-$map ] && break
wait=$((wait - 1))
sleep 1;
done
if [ $wait -le 0 ] ; then
echo -n "timeout waiting for devices"
rc_failed 1
break;
fi
/sbin/kpartx -a -p -part /dev/dm-$map
done
# Remember status and be verbose
rc_status -v
sleep 1
;;
stop)
echo -n "Removing multipath targets:"
# Flush all existing maps
$PROGRAM -F
rc_failed 0
rc_status -v
;;
status)
echo -n "Checking multipath targets: "
# Display active multipath tables
tblnum=$(/sbin/dmsetup ls --target multipath | sed '/No devices/d' | wc --lines)
if [ "$tblnum" ] && [ $tblnum -gt 0 ] ; then
echo -n "($tblnum multipath devices) "
rc_failed 0
else
rc_failed 3
fi
rc_status -v
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
;;
esac
rc_exit