summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Marzinski <bmarzins@fedoraproject.org>2010-01-25 21:51:36 +0000
committerBenjamin Marzinski <bmarzins@fedoraproject.org>2010-01-25 21:51:36 +0000
commit9dd8747664e4fac6bff76fbd591ff63e6e72a52c (patch)
tree3ea475830bfd48c7eaddded4b2925568f7b4b6fc
parent284217efef3a1625f6fde81aeeda8e483945b5be (diff)
Added RHEL5-style-partitions.patchdevice-mapper-multipath-0_4_9-6_fc12
Make kpartx deal with logical partitions like it did in RHEL5/F-9. Don't create a dm-device for the extended partition itself. Create the logical partitions on top of the dm-device for the whole disk. Resolves bz #557065
-rw-r--r--RHEL5-style-partitions.patch325
-rw-r--r--device-mapper-multipath.spec11
2 files changed, 335 insertions, 1 deletions
diff --git a/RHEL5-style-partitions.patch b/RHEL5-style-partitions.patch
new file mode 100644
index 0000000..c2e8c1e
--- /dev/null
+++ b/RHEL5-style-partitions.patch
@@ -0,0 +1,325 @@
+---
+ kpartx/bsd.c | 35 ----------------
+ kpartx/dos.c | 7 +--
+ kpartx/kpartx.c | 121 +++++++-------------------------------------------------
+ kpartx/kpartx.h | 1
+ kpartx/sun.c | 35 ----------------
+ 5 files changed, 24 insertions(+), 175 deletions(-)
+
+Index: multipath-tools/kpartx/bsd.c
+===================================================================
+--- multipath-tools.orig/kpartx/bsd.c
++++ multipath-tools/kpartx/bsd.c
+@@ -50,10 +50,10 @@ 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, end;
++ unsigned int offset = all.start;
+ int max_partitions;
+ char *bp;
+- int n = 0, i, j;
++ int n = 0;
+
+ bp = getblock(fd, offset+1); /* 1 sector suffices */
+ if (bp == NULL)
+@@ -79,36 +79,5 @@ 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;
+ }
+Index: multipath-tools/kpartx/dos.c
+===================================================================
+--- multipath-tools.orig/kpartx/dos.c
++++ multipath-tools/kpartx/dos.c
+@@ -16,7 +16,7 @@ is_extended(int type) {
+ }
+
+ static int
+-read_extended_partition(int fd, struct partition *ep, int en,
++read_extended_partition(int fd, struct partition *ep,
+ struct slice *sp, int ns)
+ {
+ struct partition p;
+@@ -53,7 +53,6 @@ read_extended_partition(int fd, struct p
+ if (n < ns) {
+ sp[n].start = here + le32_to_cpu(p.start_sect);
+ sp[n].size = le32_to_cpu(p.nr_sects);
+- sp[n].container = en + 1;
+ n++;
+ } else {
+ fprintf(stderr,
+@@ -98,7 +97,9 @@ read_dos_pt(int fd, struct slice all, st
+ break;
+ }
+ if (is_extended(p.sys_type)) {
+- n += read_extended_partition(fd, &p, i, sp+n, ns-n);
++ n += read_extended_partition(fd, &p, sp+n, ns-n);
++ /* hide the extended partition itself */
++ sp[i].size = 0;
+ }
+ }
+ return n;
+Index: multipath-tools/kpartx/kpartx.c
+===================================================================
+--- multipath-tools.orig/kpartx/kpartx.c
++++ multipath-tools/kpartx/kpartx.c
+@@ -185,7 +185,7 @@ get_hotplug_device(void)
+
+ int
+ main(int argc, char **argv){
+- int fd, i, j, m, n, op, off, arg, c, d;
++ int fd, i, j, k, n, op, off, arg;
+ struct slice all;
+ struct pt *ptp;
+ enum action what = LIST;
+@@ -347,49 +347,30 @@ main(int argc, char **argv){
+ else
+ continue;
+
++ /*
++ * test for overlap, as in the case of an extended partition
++ * zero their size to avoid mapping
++ */
++ for (j = 0; j < n; j++) {
++ for (k = j + 1; k < n; k++) {
++ if (slices[k].start > slices[j].start &&
++ slices[k].start < slices[j].start +
++ slices[j].size)
++ slices[j].size = 0;
++ }
++ }
++
+ switch(what) {
+ case LIST:
+- for (j = 0, c = 0, m = 0; j < n; j++) {
++ for (j = 0; j < n; j++) {
+ if (slices[j].size == 0)
+ continue;
+- if (slices[j].container > 0) {
+- c++;
+- continue;
+- }
+-
+- slices[j].minor = m++;
+
+ printf("%s%s%d : 0 %" PRIu64 " %s %" PRIu64"\n",
+ mapname, delim, j+1,
+ slices[j].size, device,
+ slices[j].start);
+ }
+- /* Loop to resolve contained slices */
+- d = c;
+- while (c) {
+- for (j = 0; j < n; j++) {
+- uint64_t start;
+- int k = slices[j].container - 1;
+-
+- if (slices[j].size == 0)
+- continue;
+- if (slices[j].minor > 0)
+- continue;
+- if (slices[j].container == 0)
+- continue;
+- slices[j].minor = m++;
+-
+- start = slices[j].start - slices[k].start;
+- printf("%s%s%d : 0 %" PRIu64 " /dev/dm-%d %" PRIu64 "\n",
+- mapname, delim, j+1,
+- slices[j].size,
+- slices[k].minor, start);
+- c--;
+- }
+- /* Terminate loop if nothing more to resolve */
+- if (d == c)
+- break;
+- }
+
+ if (loopcreated && S_ISREG (buf.st_mode)) {
+ if (del_loop(device)) {
+@@ -435,16 +416,10 @@ main(int argc, char **argv){
+ break;
+
+ case ADD:
+- for (j = 0, c = 0; j < n; j++) {
++ for (j = 0; j < n; j++) {
+ if (slices[j].size == 0)
+ continue;
+
+- /* Skip all contained slices */
+- if (slices[j].container > 0) {
+- c++;
+- continue;
+- }
+-
+ if (safe_sprintf(partname, "%s%s%d",
+ mapname, delim, j+1)) {
+ fprintf(stderr, "partname too small\n");
+@@ -485,70 +460,6 @@ main(int argc, char **argv){
+ slices[j].minor, slices[j].size,
+ DM_TARGET, params);
+ }
+- /* Loop to resolve contained slices */
+- d = c;
+- while (c) {
+- for (j = 0; j < n; j++) {
+- uint64_t start;
+- int k = slices[j].container - 1;
+-
+- if (slices[j].size == 0)
+- continue;
+-
+- /* Skip all existing slices */
+- if (slices[j].minor > 0)
+- continue;
+-
+- /* Skip all simple slices */
+- if (slices[j].container == 0)
+- continue;
+-
+- /* Check container slice */
+- if (slices[k].size == 0)
+- fprintf(stderr, "Invalid slice %d\n",
+- k);
+-
+- if (safe_sprintf(partname, "%s%s%d",
+- mapname, delim, j+1)) {
+- fprintf(stderr, "partname too small\n");
+- exit(1);
+- }
+- strip_slash(partname);
+-
+- start = slices[j].start - slices[k].start;
+- if (safe_sprintf(params, "%d:%d %" PRIu64,
+- slices[k].major,
+- slices[k].minor,
+- start)) {
+- fprintf(stderr, "params too small\n");
+- exit(1);
+- }
+-
+- op = (dm_map_present(partname) ?
+- DM_DEVICE_RELOAD : DM_DEVICE_CREATE);
+-
+- dm_addmap(op, partname, DM_TARGET, params,
+- slices[j].size, uuid, j+1,
+- buf.st_mode & 0777,
+- buf.st_uid, buf.st_gid);
+-
+- if (op == DM_DEVICE_RELOAD)
+- dm_simplecmd(DM_DEVICE_RESUME,
+- partname, 1);
+-
+- dm_devn(partname, &slices[j].major,
+- &slices[j].minor);
+-
+- if (verbose)
+- printf("add map %s : 0 %" PRIu64 " %s %s\n",
+- partname, slices[j].size,
+- DM_TARGET, params);
+- c--;
+- }
+- /* Terminate loop */
+- if (d == c)
+- break;
+- }
+ break;
+
+ default:
+Index: multipath-tools/kpartx/kpartx.h
+===================================================================
+--- multipath-tools.orig/kpartx/kpartx.h
++++ multipath-tools/kpartx/kpartx.h
+@@ -24,7 +24,6 @@
+ struct slice {
+ uint64_t start;
+ uint64_t size;
+- int container;
+ int major;
+ int minor;
+ };
+Index: multipath-tools/kpartx/sun.c
+===================================================================
+--- multipath-tools.orig/kpartx/sun.c
++++ multipath-tools/kpartx/sun.c
+@@ -62,8 +62,8 @@ 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;
++ unsigned int offset = all.start;
++ int i, n;
+ char *bp;
+
+ bp = getblock(fd, offset);
+@@ -95,37 +95,6 @@ read_sun_pt(int fd, struct slice all, st
+ 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/device-mapper-multipath.spec b/device-mapper-multipath.spec
index 8dafd4c..8e7d06b 100644
--- a/device-mapper-multipath.spec
+++ b/device-mapper-multipath.spec
@@ -1,7 +1,7 @@
Summary: Tools to manage multipath devices using device-mapper
Name: device-mapper-multipath
Version: 0.4.9
-Release: 5%{?dist}
+Release: 6%{?dist}
License: GPL+
Group: System Environment/Base
URL: http://christophe.varoqui.free.fr/
@@ -24,6 +24,7 @@ Patch13: stop_warnings.patch
Patch14: move_bindings.patch
Patch15: dont_remove.patch
Patch16: udev_change.patch
+Patch17: RHEL5-style-partitions.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Requires: %{name}-libs = %{version}-%{release}
@@ -80,6 +81,7 @@ kpartx manages partition creation and removal for device-mapper devices.
%patch14 -p1 -b .move_bindings
%patch15 -p1 -b .dont_remove
%patch16 -p1 -b .udev_change
+%patch17 -p1 -b .partitions
%build
%define _sbindir /sbin
@@ -146,6 +148,13 @@ fi
%{_mandir}/man8/kpartx.8.gz
%changelog
+* Mon Jan 25 2010 Benjamin Marzinski <bmarzins@redhat.com> - 0.4.9-6
+- Added RHEL5-style-partitions.patch
+ * Make kpartx deal with logical partitions like it did in RHEL5/F-9.
+ Don't create a dm-device for the extended partition itself.
+ Create the logical partitions on top of the dm-device for the whole disk.
+- Resolves bz #557065
+
* Thu Aug 20 2009 Benjamin Marzinski <bmarzins@redhat.com> - 0.4.8-5
- Fixed problem where maps were being added and then removed.
- Changed the udev rules to fix some issues.