OBS User unknown 2007-05-21 16:10:25 +00:00 committed by Git OBS Bridge
parent e7e18dce4a
commit 7f701d7470
3 changed files with 581 additions and 101 deletions

View File

@ -1,18 +1,22 @@
Makefile.inc | 1 -
devmap_name/Makefile | 5 +-
kpartx/Makefile | 10 +-
kpartx/devmapper.c | 29 ++
kpartx/Makefile | 16 +-
kpartx/bsd.c | 39 +++-
kpartx/devmapper.c | 32 +++-
kpartx/devmapper.h | 1 +
kpartx/dos.c | 7 +-
kpartx/kpartx.c | 125 ++++++++--
kpartx/kpartx.h | 3 +
kpartx/kpartx_id | 110 ++++++++
kpartx/kpartx.c | 158 +++++++++---
kpartx/kpartx.h | 4 +
kpartx/kpartx.rules | 36 +++
kpartx/kpartx_id | 93 +++++++
kpartx/sun.c | 131 ++++++++++
libcheckers/Makefile | 4 +-
libmultipath/Makefile | 6 +-
libmultipath/Makefile | 8 +-
libmultipath/config.h | 1 +
libmultipath/configure.c | 4 +-
libmultipath/discovery.c | 422 ++++++++++++-------------------
libmultipath/discovery.h | 7 +-
libmultipath/hwtable.c | 14 +-
libmultipath/list.h | 289 +++++++++++++++++++++
libmultipath/print.c | 47 ++--
libmultipath/structs.h | 15 +-
@ -22,10 +26,10 @@
libmultipath/uevent.c | 99 +++++---
libmultipath/util.c | 52 ++++
libmultipath/util.h | 4 +-
multipath/Makefile | 10 +-
multipath/Makefile | 12 +-
multipath/main.c | 11 +-
multipath/multipath.init.suse | 104 ++++++++
multipathd/71-multipath.rules | 27 ++
multipath/multipath.rules | 19 +-
multipathd/Makefile | 7 +-
multipathd/cli_handlers.c | 17 ++-
multipathd/main.c | 92 +++----
@ -38,7 +42,7 @@
path_priority/pp_netapp/Makefile | 2 +-
path_priority/pp_random/Makefile | 2 +-
path_priority/pp_tpc/Makefile | 2 +-
40 files changed, 1685 insertions(+), 432 deletions(-)
44 files changed, 1881 insertions(+), 478 deletions(-)
diff --git a/Makefile.inc b/Makefile.inc
index fe6cbdf..786565c 100644
@ -75,9 +79,23 @@ index 8b0c678..57051d9 100644
- rm -f core *.o $(EXEC) *.gz
+ rm -f core *.o $(EXEC)
diff --git a/kpartx/Makefile b/kpartx/Makefile
index 522a6a0..9832467 100644
index 522a6a0..a8ea2be 100644
--- a/kpartx/Makefile
+++ b/kpartx/Makefile
@@ -10,11 +10,11 @@ CFLAGS += -I. -D_LARGEFILE64_SOURCE
ifeq ($(strip $(BUILD)),klibc)
OBJS = bsd.o dos.o kpartx.o solaris.o unixware.o gpt.o crc32.o \
- lopart.o xstrncpy.o devmapper.o dasd.o mac.o \
+ lopart.o xstrncpy.o devmapper.o dasd.o mac.o sun.o \
$(MULTIPATHLIB)-$(BUILD).a $(libdm)
else
LDFLAGS = -ldevmapper
- OBJS = bsd.o dos.o kpartx.o solaris.o unixware.o dasd.o \
+ OBJS = bsd.o dos.o kpartx.o solaris.o unixware.o dasd.o sun.o \
gpt.o mac.o crc32.o lopart.o xstrncpy.o devmapper.o
endif
@@ -23,7 +23,7 @@ EXEC = kpartx
all: $(BUILD)
@ -87,7 +105,7 @@ index 522a6a0..9832467 100644
glibc: prepare $(OBJS)
$(CC) $(OBJS) -o $(EXEC) $(LDFLAGS)
@@ -34,15 +34,15 @@ klibc: prepare $(OBJS)
@@ -34,15 +34,17 @@ klibc: prepare $(OBJS)
$(MULTIPATHLIB)-$(BUILD).a:
make -C $(multipathdir) BUILD=$(BUILD)
@ -99,6 +117,8 @@ index 522a6a0..9832467 100644
+ install -m 755 kpartx_id $(DESTDIR)$(bindir)
install -d $(DESTDIR)$(mandir)
install -m 644 $(EXEC).8 $(DESTDIR)$(mandir)
+ install -d $(DESTDIR)/etc/udev/rules.d
+ install -m 644 kpartx.rules $(DESTDIR)/etc/udev/rules.d/70-kpartx.rules
uninstall:
rm -f $(DESTDIR)$(bindir)/$(EXEC)
@ -107,11 +127,87 @@ index 522a6a0..9832467 100644
clean:
- rm -f core *.o $(EXEC) *.gz
+ rm -f core *.o $(EXEC)
diff --git a/kpartx/bsd.c b/kpartx/bsd.c
index 3ae2dc4..f87175e 100644
--- a/kpartx/bsd.c
+++ b/kpartx/bsd.c
@@ -10,7 +10,7 @@ struct bsd_disklabel {
short int d_type; /* drive type */
short int d_subtype; /* controller/d_type specific */
char d_typename[16]; /* type name, e.g. "eagle" */
- char d_packname[16]; /* pack identifier */
+ char d_packname[16]; /* pack identifier */
unsigned int d_secsize; /* # of bytes per sector */
unsigned int d_nsectors; /* # of data sectors per track */
unsigned int d_ntracks; /* # of tracks per cylinder */
@@ -50,12 +50,12 @@ int
read_bsd_pt(int fd, struct slice all, struct slice *sp, int ns) {
struct bsd_disklabel *l;
struct bsd_partition *p;
- unsigned int offset = all.start;
+ unsigned int offset = all.start, end;
int max_partitions;
char *bp;
- int n = 0;
+ int n = 0, i, j;
- bp = getblock(fd, offset+1); /* 1 sector suffices */
+ bp = getblock(fd, offset+1); /* 1 sector suffices */
if (bp == NULL)
return -1;
@@ -79,5 +79,36 @@ read_bsd_pt(int fd, struct slice all, st
break;
}
}
+ /*
+ * Convention has it that the bsd disklabel will always have
+ * the 'c' partition spanning the entire disk.
+ * So we have to check for contained slices.
+ */
+ for(i = 0; i < n; i++) {
+ if (sp[i].size == 0)
+ continue;
+
+ end = sp[i].start + sp[i].size;
+ for(j = 0; j < n; j ++) {
+ if ( i == j )
+ continue;
+ if (sp[j].size == 0)
+ continue;
+
+ if (sp[i].start < sp[j].start) {
+ if (end > sp[j].start &&
+ end < sp[j].start + sp[j].size) {
+ /* Invalid slice */
+ fprintf(stderr,
+ "bsd_disklabel: slice %d overlaps with %d\n", i , j);
+ sp[i].size = 0;
+ }
+ } else {
+ if (end <= sp[j].start + sp[j].size) {
+ sp[i].container = j + 1;
+ }
+ }
+ }
+ }
return n;
}
diff --git a/kpartx/devmapper.c b/kpartx/devmapper.c
index 4b228ed..e5da022 100644
index 4b228ed..6e3e198 100644
--- a/kpartx/devmapper.c
+++ b/kpartx/devmapper.c
@@ -219,3 +219,32 @@ out:
@@ -200,7 +200,8 @@ char *
dm_mapuuid(int major, int minor)
{
struct dm_task *dmt;
- char *tmp, *uuid = NULL;
+ const char *tmp;
+ char *uuid = NULL;
if (!(dmt = dm_task_create(DM_DEVICE_INFO)))
return NULL;
@@ -219,3 +220,32 @@ out:
dm_task_destroy(dmt);
return uuid;
}
@ -143,7 +239,7 @@ index 4b228ed..e5da022 100644
+ dm_task_destroy(dmt);
+ return r;
+}
+
+
diff --git a/kpartx/devmapper.h b/kpartx/devmapper.h
index e20e456..ccdbead 100644
--- a/kpartx/devmapper.h
@ -186,19 +282,101 @@ index a707423..1691105 100644
}
return n;
diff --git a/kpartx/kpartx.c b/kpartx/kpartx.c
index b406b95..c48a59c 100644
index b406b95..52dfe93 100644
--- a/kpartx/kpartx.c
+++ b/kpartx/kpartx.c
@@ -79,6 +79,7 @@ initpts(void)
addpts("unixware", read_unixware_pt);
addpts("dasd", read_dasd_pt);
addpts("mac", read_mac_pt);
+ addpts("sun", read_sun_pt);
}
static char short_opts[] = "ladgvnp:t:";
@@ -115,7 +116,6 @@ strip_slash (char * device)
char * p = device;
while (*(p++) != 0x0) {
-
if (*p == '/')
*p = '!';
}
@@ -125,9 +125,9 @@ static int
find_devname_offset (char * device)
{
char *p, *q = NULL;
-
+
p = device;
-
+
while (*p++)
if (*p == '/')
q = p;
@@ -182,7 +182,7 @@ get_hotplug_device(void)
int
main(int argc, char **argv){
- int fd, i, j, k, n, op, off, arg;
+ int fd, i, j, k, m, n, op, off, arg, c, d;
+ int fd, i, j, m, n, op, off, arg, c, d;
struct slice all;
struct pt *ptp;
enum action what = LIST;
@@ -353,30 +353,47 @@ main(int argc, char **argv){
@@ -205,7 +205,7 @@ main(int argc, char **argv){
type = device = diskdevice = NULL;
memset(&all, 0, sizeof(all));
memset(&partname, 0, sizeof(partname));
-
+
/* Check whether hotplug mode. */
progname = strrchr(argv[0], '/');
@@ -264,7 +264,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);
}
@@ -291,7 +291,7 @@ main(int argc, char **argv){
if (!loopdev && what == DELETE)
exit (0);
-
+
if (!loopdev) {
loopdev = find_unused_loop_device();
@@ -308,7 +308,7 @@ main(int argc, char **argv){
memset(delim, 0, DELIM_SIZE);
set_delimiter(device, delim);
}
-
+
off = find_devname_offset(device);
if (!loopdev) {
@@ -320,7 +320,7 @@ main(int argc, char **argv){
if (!uuid)
uuid = device + off;
-
+
if (!mapname)
mapname = device + off;
@@ -339,7 +339,7 @@ main(int argc, char **argv){
if (type && strcmp(type, ptp->type))
continue;
-
+
/* here we get partitions */
n = ptp->fn(fd, all, slices, SIZE(slices));
@@ -353,30 +353,50 @@ main(int argc, char **argv){
else
continue;
@ -229,14 +407,20 @@ index b406b95..c48a59c 100644
+ slices[j].minor = m++;
printf("%s%s%d : 0 %lu %s %lu\n",
mapname, delim, j+1,
(unsigned long) slices[j].size, device,
(unsigned long) slices[j].start);
- mapname, delim, j+1,
- (unsigned long) slices[j].size, device,
- (unsigned long) slices[j].start);
+ mapname, delim, j+1,
+ (unsigned long) slices[j].size, device,
+ (unsigned long) slices[j].start);
}
+ /* Loop to resolve contained slices */
+ d = c;
+ while (c) {
+ for (j = 0; j < n; j++) {
+ unsigned long start;
+ int k = slices[j].container - 1;
+
+ if (slices[j].size == 0)
+ continue;
+ if (slices[j].minor > 0)
@ -245,11 +429,11 @@ index b406b95..c48a59c 100644
+ continue;
+ slices[j].minor = m++;
+
+ start = slices[j].start - slices[k].start;
+ printf("%s%s%d : 0 %lu /dev/dm-%d %lu\n",
+ mapname, delim, j+1,
+ (unsigned long) slices[j].size,
+ slices[j].minor,
+ (unsigned long) slices[j].start);
+ slices[k].minor, start);
+ c--;
+ }
+ /* Terminate loop if nothing more to resolve */
@ -260,7 +444,16 @@ index b406b95..c48a59c 100644
break;
case DELETE:
@@ -410,10 +427,16 @@ main(int argc, char **argv){
@@ -401,7 +421,7 @@ main(int argc, char **argv){
if (S_ISREG (buf.st_mode)) {
if (del_loop(device)) {
if (verbose)
- printf("can't del loop : %s\n",
+ printf("can't del loop : %s\n",
device);
exit(1);
}
@@ -410,17 +430,23 @@ main(int argc, char **argv){
break;
case ADD:
@ -278,11 +471,19 @@ index b406b95..c48a59c 100644
if (safe_sprintf(partname, "%s%s%d",
mapname, delim, j+1)) {
fprintf(stderr, "partname too small\n");
@@ -437,10 +460,74 @@ main(int argc, char **argv){
exit(1);
}
strip_slash(partname);
-
+
if (safe_sprintf(params, "%s %lu", device,
(unsigned long)slices[j].start)) {
fprintf(stderr, "params too small\n");
@@ -437,10 +463,74 @@ main(int argc, char **argv){
dm_simplecmd(DM_DEVICE_RESUME,
partname);
+ dm_devn(partname, &slices[j].major,
+ dm_devn(partname, &slices[j].major,
+ &slices[j].minor);
+
if (verbose)
@ -322,7 +523,7 @@ index b406b95..c48a59c 100644
+ exit(1);
+ }
+ strip_slash(partname);
+
+
+ if (safe_sprintf(params, "%d:%d %lu",
+ slices[k].major,
+ slices[k].minor,
@ -340,8 +541,8 @@ index b406b95..c48a59c 100644
+ if (op == DM_DEVICE_RELOAD)
+ dm_simplecmd(DM_DEVICE_RESUME,
+ partname);
+
+ dm_devn(partname, &slices[j].major,
+
+ dm_devn(partname, &slices[j].major,
+ &slices[j].minor);
+
+ if (verbose)
@ -356,8 +557,17 @@ index b406b95..c48a59c 100644
}
break;
@@ -516,7 +606,7 @@ getblock (int fd, unsigned int secnr) {
bp->next = blockhead;
blockhead = bp;
bp->block = (char *) xmalloc(READ_SIZE);
-
+
if (read(fd, bp->block, READ_SIZE) != READ_SIZE) {
fprintf(stderr, "read error, sector %d\n", secnr);
bp->block = NULL;
diff --git a/kpartx/kpartx.h b/kpartx/kpartx.h
index 6a715de..b49c543 100644
index 6a715de..9b3aeca 100644
--- a/kpartx/kpartx.h
+++ b/kpartx/kpartx.h
@@ -22,6 +22,9 @@
@ -370,12 +580,62 @@ index 6a715de..b49c543 100644
};
typedef int (ptreader)(int fd, struct slice all, struct slice *sp, int ns);
@@ -33,6 +36,7 @@ extern ptreader read_unixware_pt;
extern ptreader read_gpt_pt;
extern ptreader read_dasd_pt;
extern ptreader read_mac_pt;
+extern ptreader read_sun_pt;
char *getblock(int fd, unsigned int secnr);
diff --git a/kpartx/kpartx.rules b/kpartx/kpartx.rules
new file mode 100644
index 0000000..8666d45
--- /dev/null
+++ b/kpartx/kpartx.rules
@@ -0,0 +1,36 @@
+#
+# persistent links for device-mapper devices
+# only hardware-backed device-mapper devices (ie multipath, dmraid,
+# and kpartx) have meaningful persistent device names
+#
+
+KERNEL!="dm-*", GOTO="multipath_end"
+ACTION=="remove", GOTO="multipath_end"
+
+ENV{DM_TABLE_STATE}!="LIVE", GOTO="multipath_end"
+
+ENV{DM_UUID}=="?*", IMPORT{program}=="/sbin/kpartx_id %M %m $env{DM_UUID}"
+
+OPTIONS="link_priority=50"
+
+# Create persistent links for multipath tables
+ENV{DM_UUID}=="mpath-*", \
+ SYMLINK+="disk/by-id/$env{DM_TYPE}-$env{DM_NAME}"
+
+# Create persistent links for dmraid tables
+ENV{DM_UUID}=="mpath-*", \
+ SYMLINK+="disk/by-id/$env{DM_TYPE}-$env{DM_NAME}"
+
+# Create persistent links for partitions
+ENV{DM_PART}=="?*", \
+ SYMLINK+="disk/by-id/$env{DM_TYPE}-$env{DM_NAME}-part$env{DM_PART}"
+
+# Create dm tables for partitions
+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"
+
+LABEL="multipath_end"
+
+
diff --git a/kpartx/kpartx_id b/kpartx/kpartx_id
new file mode 100644
index 0000000..c599e5d
index 0000000..e876b98
--- /dev/null
+++ b/kpartx/kpartx_id
@@ -0,0 +1,110 @@
@@ -0,0 +1,93 @@
+#!/bin/bash
+#
+# kpartx_id
@ -403,6 +663,7 @@ index 0000000..c599e5d
+
+MAJOR=$1
+MINOR=$2
+UUID=$3
+
+if [ -z "$MAJOR" -o -z "$MINOR" ]; then
+ echo "usage: $0 major minor"
@ -414,23 +675,10 @@ index 0000000..c599e5d
+ exit 0
+fi
+
+# Get the table info
+tblinfo=$($DMSETUP info -c --noheadings -o name,uuid -j $MAJOR -m $MINOR)
+if [ $? -ne 0 ] || [ -z "$tblinfo" ]; then
+ exit $?
+fi
+
+set -- $(IFS=":"; echo $tblinfo)
+tblname=$1
+tbluuid=$2
+
+if [ -z "$tbluuid" ] ; then
+ exit 0
+fi
+
+# Table UUIDs are always '<type>-<uuid>'.
+dmuuid=${tbluuid#*-}
+dmtbl=${tbluuid%%-*}
+dmuuid=${UUID#*-}
+dmtbl=${UUID%%-*}
+dmpart=${dmtbl#part}
+# kpartx types are 'part<num>'
+if [ "$dmpart" == "$dmtbl" ] ; then
@ -444,9 +692,10 @@ index 0000000..c599e5d
+if [ "$dmtbl" == "part" ] ; then
+ # The name of the kpartx table is the name of the parent table
+ dmname=$($DMSETUP info -c --noheadings -o name -u $dmuuid)
+ echo "DM_NAME=$dmname"
+ # We need the dependencies of the parent table to figure out
+ # the type if the parent is a multipath table
+ case "$dmparent" in
+ case "$dmuuid" in
+ mpath-*)
+ dmdeps=$($DMSETUP deps -u $dmuuid)
+ ;;
@ -454,38 +703,169 @@ index 0000000..c599e5d
+elif [ "$dmtbl" == "mpath" ] ; then
+ dmname=$tblname
+ # We need the dependencies of the table to figure out the type
+ dmdeps=$($DMSETUP deps -u $tbluuid)
+ dmdeps=$($DMSETUP deps -u $UUID)
+elif [ "$dmtbl" == "dmraid" ] ; then
+ dmname=$tblname
+fi
+
+if [ -z "$dmname" ] ; then
+ exit 0
+fi
+
+echo "ID_DM_TABLE=$dmtbl"
+echo "ID_DM_NAME=$dmname"
+[ -n "$dmpart" ] && echo "ID_DM_PART=$dmpart"
+[ -n "$dmpart" ] && echo "DM_PART=$dmpart"
+
+# Figure out the type of the map. For non-multipath maps it's
+# always 'raid'.
+if [ -n "$dmdeps" ] ; then
+ case "$dmdeps" in
+ *\(94,*)
+ echo "ID_DM_TYPE=dasd"
+ echo "DM_TYPE=dasd"
+ ;;
+ *\(9*)
+ echo "ID_DM_TYPE=raid"
+ echo "DM_TYPE=raid"
+ ;;
+ *)
+ echo "ID_DM_TYPE=scsi"
+ echo "DM_TYPE=scsi"
+ ;;
+ esac
+else
+ echo "ID_DM_TYPE=raid"
+ echo "DM_TYPE=raid"
+fi
+
+exit 0
diff --git a/kpartx/sun.c b/kpartx/sun.c
new file mode 100644
index 0000000..3d88b21
--- /dev/null
+++ b/kpartx/sun.c
@@ -0,0 +1,131 @@
+/*
+ * Lifted from util-linux' partx sun.c
+ *
+ * Copyrights of the original file apply
+ * Copyright (c) 2007 Hannes Reinecke
+ */
+#include "kpartx.h"
+#include "byteorder.h"
+#include <stdio.h>
+#include <sys/types.h>
+#include <time.h> /* time_t */
+
+#define SUN_DISK_MAGIC 0xDABE /* Disk magic number */
+#define SUN_DISK_MAXPARTITIONS 8
+
+struct __attribute__ ((packed)) sun_raw_part {
+ u_int32_t start_cylinder; /* where the part starts... */
+ u_int32_t num_sectors; /* ...and it's length */
+};
+
+struct __attribute__ ((packed)) sun_part_info {
+ u_int8_t spare1;
+ u_int8_t id; /* Partition type */
+ u_int8_t spare2;
+ u_int8_t flags; /* Partition flags */
+};
+
+struct __attribute__ ((packed)) sun_disk_label {
+ char info[128]; /* Informative text string */
+ u_int8_t spare0[14];
+ struct sun_part_info infos[SUN_DISK_MAXPARTITIONS];
+ u_int8_t spare1[246]; /* Boot information etc. */
+ u_int16_t rspeed; /* Disk rotational speed */
+ u_int16_t pcylcount; /* Physical cylinder count */
+ u_int16_t sparecyl; /* extra sects per cylinder */
+ u_int8_t spare2[4]; /* More magic... */
+ u_int16_t ilfact; /* Interleave factor */
+ u_int16_t ncyl; /* Data cylinder count */
+ u_int16_t nacyl; /* Alt. cylinder count */
+ u_int16_t ntrks; /* Tracks per cylinder */
+ u_int16_t nsect; /* Sectors per track */
+ u_int8_t spare3[4]; /* Even more magic... */
+ struct sun_raw_part partitions[SUN_DISK_MAXPARTITIONS];
+ u_int16_t magic; /* Magic number */
+ u_int16_t csum; /* Label xor'd checksum */
+};
+
+/* Checksum Verification */
+static int
+sun_verify_checksum (struct sun_disk_label *label)
+{
+ u_int16_t *ush = ((u_int16_t *)(label + 1)) - 1;
+ u_int16_t csum = 0;
+
+ while (ush >= (u_int16_t *)label)
+ csum ^= *ush--;
+
+ return !csum;
+}
+
+int
+read_sun_pt(int fd, struct slice all, struct slice *sp, int ns) {
+ struct sun_disk_label *l;
+ struct sun_raw_part *s;
+ unsigned int offset = all.start, end;
+ int i, j, n;
+ char *bp;
+
+ bp = getblock(fd, offset);
+ if (bp == NULL)
+ return -1;
+
+ l = (struct sun_disk_label *) bp;
+ if(be16_to_cpu(l->magic) != SUN_DISK_MAGIC)
+ return -1;
+
+ if (!sun_verify_checksum(l)) {
+ fprintf(stderr, "Corrupted Sun disk label\n");
+ return -1;
+ }
+
+ for(i=0, n=0; i<SUN_DISK_MAXPARTITIONS; i++) {
+ s = &l->partitions[i];
+
+ if (s->num_sectors == 0)
+ continue;
+ if (n < ns) {
+ sp[n].start = offset +
+ be32_to_cpu(s->start_cylinder) * be16_to_cpu(l->nsect) * be16_to_cpu(l->ntrks);
+ sp[n].size = be32_to_cpu(s->num_sectors);
+ n++;
+ } else {
+ fprintf(stderr,
+ "sun_disklabel: too many slices\n");
+ break;
+ }
+ }
+ /*
+ * Convention has it that the SUN disklabel will always have
+ * the 'c' partition spanning the entire disk.
+ * So we have to check for contained slices.
+ */
+ for(i = 0; i < SUN_DISK_MAXPARTITIONS; i++) {
+ if (sp[i].size == 0)
+ continue;
+
+ end = sp[i].start + sp[i].size;
+ for(j = 0; j < SUN_DISK_MAXPARTITIONS; j ++) {
+ if ( i == j )
+ continue;
+ if (sp[j].size == 0)
+ continue;
+
+ if (sp[i].start < sp[j].start) {
+ if (end > sp[j].start &&
+ end < sp[j].start + sp[j].size) {
+ /* Invalid slice */
+ fprintf(stderr,
+ "sun_disklabel: slice %d overlaps with %d\n", i , j);
+ sp[i].size = 0;
+ }
+ } else {
+ if (end <= sp[j].start + sp[j].size) {
+ sp[i].container = j + 1;
+ }
+ }
+ }
+ }
+ return n;
+}
+
diff --git a/libcheckers/Makefile b/libcheckers/Makefile
index 6340a68..bdd423f 100644
--- a/libcheckers/Makefile
@ -506,7 +886,7 @@ index 6340a68..bdd423f 100644
- rm -f core *.a *.o *.gz
+ rm -f core *.a *.o
diff --git a/libmultipath/Makefile b/libmultipath/Makefile
index ef561a8..a6ad89b 100644
index ef561a8..3ab059a 100644
--- a/libmultipath/Makefile
+++ b/libmultipath/Makefile
@@ -13,7 +13,7 @@ OBJS = memory.o parser.o vector.o devmap
@ -518,6 +898,15 @@ index ef561a8..a6ad89b 100644
PREVBUILD = $(shell nm debug.o 2> /dev/null|grep log_safe)
@@ -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)
@ -1162,6 +1551,73 @@ index ab62a59..c7cf7e8 100644
int path_discovery (vector pathvec, struct config * conf, int flag);
void basename (char *, char *);
diff --git a/libmultipath/hwtable.c b/libmultipath/hwtable.c
index d5b227f..27098b2 100644
--- a/libmultipath/hwtable.c
+++ b/libmultipath/hwtable.c
@@ -63,7 +63,7 @@ static struct hwentry default_hw[] = {
.vendor = "DEC",
.product = "HSG80",
.getuid = DEFAULT_GETUID,
- .getprio = "mpath_prio_hp_sw /dev/%n",
+ .getprio = "/sbin/mpath_prio_hp_sw /dev/%n",
.features = "1 queue_if_no_path",
.hwhandler = DEFAULT_HWHANDLER,
.selector = DEFAULT_SELECTOR,
@@ -94,7 +94,7 @@ static struct hwentry default_hw[] = {
.vendor = "(COMPAQ|HP)",
.product = "(MSA|HSV)1.0.*",
.getuid = DEFAULT_GETUID,
- .getprio = "mpath_prio_hp_sw /dev/%n",
+ .getprio = "/sbin/mpath_prio_hp_sw /dev/%n",
.features = "1 queue_if_no_path",
.hwhandler = DEFAULT_HWHANDLER,
.selector = DEFAULT_SELECTOR,
@@ -110,7 +110,7 @@ static struct hwentry default_hw[] = {
.vendor = "HP",
.product = "MSA VOLUME",
.getuid = DEFAULT_GETUID,
- .getprio = "mpath_prio_alua /dev/%n",
+ .getprio = "/sbin/mpath_prio_alua /dev/%n",
.features = DEFAULT_FEATURES,
.hwhandler = DEFAULT_HWHANDLER,
.selector = DEFAULT_SELECTOR,
@@ -126,7 +126,7 @@ static struct hwentry default_hw[] = {
.vendor = "(COMPAQ|HP)",
.product = "(MSA|HSV)1.1.*",
.getuid = DEFAULT_GETUID,
- .getprio = "mpath_prio_alua /dev/%n",
+ .getprio = "/sbin/mpath_prio_alua /dev/%n",
.features = DEFAULT_FEATURES,
.hwhandler = DEFAULT_HWHANDLER,
.selector = DEFAULT_SELECTOR,
@@ -142,7 +142,7 @@ static struct hwentry default_hw[] = {
.vendor = "HP",
.product = "HSV2.*",
.getuid = DEFAULT_GETUID,
- .getprio = "mpath_prio_alua /dev/%n",
+ .getprio = "/sbin/mpath_prio_alua /dev/%n",
.features = DEFAULT_FEATURES,
.hwhandler = DEFAULT_HWHANDLER,
.selector = DEFAULT_SELECTOR,
@@ -406,7 +406,7 @@ static struct hwentry default_hw[] = {
.vendor = "IBM",
.product = "S/390 DASD ECKD",
.bl_product = "S/390.*",
- .getuid = "dasdinfo -u -b %n",
+ .getuid = "/sbin/dasdinfo -u -b %n",
.getprio = NULL,
.features = "1 queue_if_no_path",
.hwhandler = DEFAULT_HWHANDLER,
@@ -521,7 +521,7 @@ static struct hwentry default_hw[] = {
.vendor = "SGI",
.product = "IS.*",
.getuid = DEFAULT_GETUID,
- .getprio = "mpath_prio_tpc /dev/%n",
+ .getprio = "/sbin/mpath_prio_tpc /dev/%n",
.features = DEFAULT_FEATURES,
.hwhandler = DEFAULT_HWHANDLER,
.selector = DEFAULT_SELECTOR,
diff --git a/libmultipath/list.h b/libmultipath/list.h
new file mode 100644
index 0000000..8626630
@ -2259,7 +2715,7 @@ index e86bae2..d0df8aa 100644
#define safe_sprintf(var, format, args...) \
snprintf(var, sizeof(var), format, ##args) >= sizeof(var)
diff --git a/multipath/Makefile b/multipath/Makefile
index 947d481..a31afe2 100644
index 947d481..3f32c41 100644
--- a/multipath/Makefile
+++ b/multipath/Makefile
@@ -12,7 +12,7 @@ CFLAGS += -I$(multipathdir) -I$(checkers
@ -2287,7 +2743,8 @@ index 947d481..a31afe2 100644
- install -s -m 755 $(EXEC) $(DESTDIR)$(bindir)/
+ install -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/
+ install -m 644 multipath.rules $(DESTDIR)/etc/udev/rules.d/71-multipath.rules
install -d $(DESTDIR)$(mandir)
install -m 644 $(EXEC).8 $(DESTDIR)$(mandir)
+ install -d $(DESTDIR)$(man5dir)
@ -2457,39 +2914,33 @@ index 0000000..34a128c
+ ;;
+esac
+rc_exit
diff --git a/multipathd/71-multipath.rules b/multipathd/71-multipath.rules
new file mode 100644
index 0000000..756ebe7
--- /dev/null
+++ b/multipathd/71-multipath.rules
@@ -0,0 +1,27 @@
+#
+# persistent links for device-mapper devices
+# only hardware-backed device-mapper devices (ie multipath, dmraid,
+# and kpartx) have meaningful persistent device names
+#
+
+KERNEL!="dm-*", GOTO="multipath_end"
+ACTION=="add|remove", GOTO="multipath_end"
+
+ACTION=="change", IMPORT{program}=="/sbin/kpartx_id %M %m"
+
+# Create persistent links for tables
+ACTION=="change", ENV{ID_DM_TABLE}=="mpath|dmraid", ENV{ID_DM_TYPE}=="?*", \
+ SYMLINK+="disk/by-id/$env{ID_DM_TYPE}-$env{ID_DM_NAME}"
+
+# Create dm tables for partitions
+ACTION=="change", ENV{ID_DM_TABLE}=="mpath|dmraid", \
+ RUN+="/sbin/kpartx -a -p _part /dev/mapper/$env{ID_DM_NAME}"
+
+# Create persistent links for partitions
+ACTION=="change", ENV{ID_DM_TABLE}=="part", ENV{ID_DM_TYPE}=="?*", \
+ SYMLINK+="disk/by-id/$env{ID_DM_TYPE}-$env{ID_DM_NAME}-part$env{ID_DM_PART}"
+
diff --git a/multipath/multipath.rules b/multipath/multipath.rules
index 10751ce..9d3579f 100644
--- a/multipath/multipath.rules
+++ b/multipath/multipath.rules
@@ -1,18 +1,7 @@
#
-# multipath and multipath partitions nodes are created in /dev/mapper/
-# this file should be installed in /etc/udev/rules.d
+# udev rules for multipathing.
+# The persistent symlinks are created with the kpartx rules
#
-# !! udev must not discard DM events !!
-# !! check the other installed rules !!
-#
-
-# lookup the devmap name
-#ACTION=="add", SUBSYSTEM=="block", KERNEL=="dm-*", \
-# PROGRAM="/sbin/devmap_name %M %m"
-ACTION=="add", SUBSYSTEM=="block", KERNEL=="dm-*", \
- PROGRAM="/sbin/dmsetup -j %M -m %m --noopencount --noheadings -c -o name info"
-
-# take care of devmap partitioning
-ACTION=="add", SUBSYSTEM=="block", KERNEL=="dm-*", \
- RUN+="/sbin/kpartx -a /dev/mapper/%c"
+# socket for uevents
+RUN+="socket:/org/kernel/dm/multipath_event"
+LABEL="multipath_end"
+
diff --git a/multipathd/Makefile b/multipathd/Makefile
index da351dc..bbab8da 100644
--- a/multipathd/Makefile

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Mon May 21 15:34:07 CEST 2007 - hare@suse.de
- Rework udev handling
- Split off kpartx package
-------------------------------------------------------------------
Mon May 14 16:20:55 CEST 2007 - hare@suse.de

View File

@ -15,13 +15,13 @@ BuildRequires: device-mapper-devel readline-devel
URL: http://christophe.varoqui.free.fr/
License: BSD License and BSD-like, GNU General Public License (GPL)
Group: System/Base
Requires: device-mapper
Requires: device-mapper kpartx
%if %suse_version > 800
PreReq: %insserv_prereq
%endif
Autoreqprov: on
Version: 0.4.7
Release: 48
Release: 50
Summary: Tools to Manage Multipathed Devices with the device-mapper
Source: multipath-tools-%{version}.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-build
@ -46,6 +46,20 @@ multipath maps partionable
Authors:
--------
Christophe Varoqui <christophe.varoqui@free.fr>
%package -n kpartx
Summary: Manages partition tables on device-mapper devices
Group: System/Base
%description -n kpartx
The kpartx program maps linear devmaps to device partitions, which
makes multipath maps partionable.
Authors:
--------
Christophe Varoqui <christophe.varoqui@free.fr>
@ -63,8 +77,6 @@ make OPTFLAGS="$RPM_OPT_FLAGS" BUILD=glibc
mkdir -p $RPM_BUILD_ROOT/sbin
mkdir -p $RPM_BUILD_ROOT%{_mandir}/man8
make DESTDIR=$RPM_BUILD_ROOT install
rm $RPM_BUILD_ROOT/etc/udev/rules.d/multipath.rules
install -m 644 multipathd/71-multipath.rules $RPM_BUILD_ROOT/etc/udev/rules.d
mkdir -p $RPM_BUILD_ROOT/etc/init.d
install -m 744 multipath/multipath.init.suse $RPM_BUILD_ROOT/etc/init.d/boot.multipath
install -m 744 multipathd/multipathd.init.suse $RPM_BUILD_ROOT/etc/init.d/multipathd
@ -84,13 +96,13 @@ mkdir -p $RPM_BUILD_ROOT/var/cache/multipath/
%defattr(-,root,root)
%doc AUTHOR COPYING README ChangeLog
%doc multipath.conf*
%dir /etc/udev
%dir /etc/udev/rules.d
%config /etc/init.d/multipathd
%config /etc/init.d/boot.multipath
%config /etc/udev
%config /etc/udev/rules.d/71-multipath.rules
/sbin/devmap_name
/sbin/multipath
/sbin/kpartx
/sbin/kpartx_id
/sbin/multipathd
/sbin/mpath_prio_netapp
/sbin/mpath_prio_balance_units
@ -104,11 +116,22 @@ mkdir -p $RPM_BUILD_ROOT/var/cache/multipath/
%{_mandir}/man8/devmap_name.8*
%{_mandir}/man8/multipath.8*
%{_mandir}/man5/multipath.conf.5*
%{_mandir}/man8/kpartx.8*
%{_mandir}/man8/multipathd.8*
%{_mandir}/man8/mpath_prio_alua.8*
%files -n kpartx
%defattr(-,root,root)
%dir /etc/udev
%dir /etc/udev/rules.d
%config /etc/udev/rules.d/70-kpartx.rules
/sbin/kpartx
/sbin/kpartx_id
%{_mandir}/man8/kpartx.8*
%changelog
* Mon May 21 2007 - hare@suse.de
- Rework udev handling
- Split off kpartx package
* Mon May 14 2007 - hare@suse.de
- Merge in latest fixes from upstream
- Add all SuSE specific files to git repository.