diff -Nru multipath-tools-0.4.9/debian/changelog multipath-tools-0.4.9/debian/changelog --- multipath-tools-0.4.9/debian/changelog 2015-03-23 15:56:46.000000000 -0300 +++ multipath-tools-0.4.9/debian/changelog 2015-04-08 15:38:12.000000000 -0300 @@ -1,3 +1,11 @@ +multipath-tools (0.4.9-3ubuntu11non512Bsectors1) UNRELEASED; urgency=medium + + * Support disks with non 512-byte sectors (LP: #1441930) + - Added 0016-kpartx-non-512B-GPT.patch + - Added 0017-kpartx-non-512B-sectors.patch + + -- Mauricio Faria de Oliveira Wed, 08 Apr 2015 15:35:11 -0300 + multipath-tools (0.4.9-3ubuntu11) vivid; urgency=medium [ Mauricio Faria de Oliveira ] diff -Nru multipath-tools-0.4.9/debian/patches/0016-kpartx-non-512B-GPT.patch multipath-tools-0.4.9/debian/patches/0016-kpartx-non-512B-GPT.patch --- multipath-tools-0.4.9/debian/patches/0016-kpartx-non-512B-GPT.patch 1969-12-31 21:00:00.000000000 -0300 +++ multipath-tools-0.4.9/debian/patches/0016-kpartx-non-512B-GPT.patch 2015-04-08 15:33:16.000000000 -0300 @@ -0,0 +1,45 @@ +Origin: upstream, http://git.opensvc.com/gitweb.cgi?p=multipath-tools/.git;a=commit;h=126f7a19d02c943c5cd27967f3259dba435ce46c +From: Benjamin Marzinski +Date: Thu, 2 May 2013 21:46:23 +0000 (-0500) +Subject: Make kpartx correctly handle non-512 byte GPT +X-Git-Tag: 0.5.0~104 +X-Git-Url: http://git.opensvc.com/gitweb.cgi?p=multipath-tools%2F.git;a=commitdiff_plain;h=126f7a19d02c943c5cd27967f3259dba435ce46c + +Make kpartx correctly handle non-512 byte GPT + +The gpt code in kpartx correctly handled non-512 byte gpt +partitions right up until it was time to actually write out the +slice data. At that point it forgot to convert the logical block +address into a the proper slice offset. This patch fixes that. + +Signed-off-by: Philipp Schmidt +Signed-off-by: Benjamin Marzinski +--- + +diff --git a/kpartx/gpt.c b/kpartx/gpt.c +index 3082cae..0a22927 100644 +--- a/kpartx/gpt.c ++++ b/kpartx/gpt.c +@@ -637,6 +637,7 @@ read_gpt_pt (int fd, struct slice all, struct slice *sp, int ns) + uint32_t i; + int n = 0; + int last_used_index=-1; ++ int sector_size_mul = get_sector_size(fd)/512; + + if (!find_valid_gpt (fd, &gpt, &ptes) || !gpt || !ptes) { + if (gpt) +@@ -652,9 +653,11 @@ read_gpt_pt (int fd, struct slice all, struct slice *sp, int ns) + sp[n].size = 0; + n++; + } else { +- sp[n].start = __le64_to_cpu(ptes[i].starting_lba); +- sp[n].size = __le64_to_cpu(ptes[i].ending_lba) - +- __le64_to_cpu(ptes[i].starting_lba) + 1; ++ sp[n].start = sector_size_mul * ++ __le64_to_cpu(ptes[i].starting_lba); ++ sp[n].size = sector_size_mul * ++ (__le64_to_cpu(ptes[i].ending_lba) - ++ __le64_to_cpu(ptes[i].starting_lba) + 1); + last_used_index=n; + n++; + } diff -Nru multipath-tools-0.4.9/debian/patches/0017-kpartx-non-512B-sectors.patch multipath-tools-0.4.9/debian/patches/0017-kpartx-non-512B-sectors.patch --- multipath-tools-0.4.9/debian/patches/0017-kpartx-non-512B-sectors.patch 1969-12-31 21:00:00.000000000 -0300 +++ multipath-tools-0.4.9/debian/patches/0017-kpartx-non-512B-sectors.patch 2015-04-08 15:37:59.000000000 -0300 @@ -0,0 +1,167 @@ +Origin: upstream, http://git.opensvc.com/gitweb.cgi?p=multipath-tools/.git;a=commit;h=b9fb5c7d09f07f5bc6ae02f23079385724dff411 +From: Petr Uzel +Date: Tue, 16 Jul 2013 07:13:01 +0000 (+0200) +Subject: kpartx: support disk with non-512B sectors +X-Git-Tag: 0.5.0~73 +X-Git-Url: http://git.opensvc.com/gitweb.cgi?p=multipath-tools%2F.git;a=commitdiff_plain;h=b9fb5c7d09f07f5bc6ae02f23079385724dff411 + +kpartx: support disk with non-512B sectors + +libdevmapper expects sector size to be recalculated to 512B, so we need +to teach kpartx to do so if the underlying DM device has different +sector size (for GPT and msods partition tables). + +Signed-off-by: Petr Uzel +--- + +diff --git a/kpartx/dos.c b/kpartx/dos.c +index a1a9961..0e57f0e 100644 +--- a/kpartx/dos.c ++++ b/kpartx/dos.c +@@ -26,7 +26,9 @@ read_extended_partition(int fd, struct partition *ep, int en, + int moretodo = 1; + int i, n=0; + +- next = start = le32_to_cpu(ep->start_sect); ++ int sector_size_mul = get_sector_size(fd)/512; ++ ++ next = start = sector_size_mul * le32_to_cpu(ep->start_sect); + + while (moretodo) { + here = next; +@@ -45,14 +47,14 @@ read_extended_partition(int fd, struct partition *ep, int en, + memcpy(&p, bp + 0x1be + i * sizeof (p), sizeof (p)); + if (is_extended(p.sys_type)) { + if (p.nr_sects && !moretodo) { +- next = start + le32_to_cpu(p.start_sect); ++ next = start + sector_size_mul * le32_to_cpu(p.start_sect); + moretodo = 1; + } + continue; + } + if (n < ns) { +- sp[n].start = here + le32_to_cpu(p.start_sect); +- sp[n].size = le32_to_cpu(p.nr_sects); ++ sp[n].start = here + sector_size_mul * le32_to_cpu(p.start_sect); ++ sp[n].size = sector_size_mul * le32_to_cpu(p.nr_sects); + sp[n].container = en + 1; + n++; + } else { +@@ -77,6 +79,7 @@ read_dos_pt(int fd, struct slice all, struct slice *sp, int ns) { + unsigned long offset = all.start; + int i, n=4; + unsigned char *bp; ++ int sector_size_mul = get_sector_size(fd)/512; + + bp = (unsigned char *)getblock(fd, offset); + if (bp == NULL) +@@ -90,15 +93,15 @@ read_dos_pt(int fd, struct slice all, struct slice *sp, int ns) { + if (is_gpt(p.sys_type)) + return 0; + if (i < ns) { +- sp[i].start = le32_to_cpu(p.start_sect); +- sp[i].size = le32_to_cpu(p.nr_sects); ++ sp[i].start = sector_size_mul * le32_to_cpu(p.start_sect); ++ sp[i].size = sector_size_mul * le32_to_cpu(p.nr_sects); + } else { + fprintf(stderr, + "dos_partition: too many slices\n"); + break; + } + if (is_extended(p.sys_type)) { +- sp[i].size = 2; /* extended partitions only get two ++ sp[i].size = sector_size_mul * 2; /* extended partitions only get two + sectors mapped for LILO to install */ + n += read_extended_partition(fd, &p, i, sp+n, ns-n); + } +diff --git a/kpartx/gpt.c b/kpartx/gpt.c +index 0a22927..5a54970 100644 +--- a/kpartx/gpt.c ++++ b/kpartx/gpt.c +@@ -38,6 +38,7 @@ + #include + #include + #include "crc32.h" ++#include "kpartx.h" + + #if BYTE_ORDER == LITTLE_ENDIAN + # define __le16_to_cpu(x) (x) +@@ -116,25 +117,6 @@ is_pmbr_valid(legacy_mbr *mbr) + + + /************************************************************ +- * get_sector_size +- * Requires: +- * - filedes is an open file descriptor, suitable for reading +- * Modifies: nothing +- * Returns: +- * sector size, or 512. +- ************************************************************/ +-static int +-get_sector_size(int filedes) +-{ +- int rc, sector_size = 512; +- +- rc = ioctl(filedes, BLKSSZGET, §or_size); +- if (rc) +- sector_size = 512; +- return sector_size; +-} +- +-/************************************************************ + * _get_num_sectors + * Requires: + * - filedes is an open file descriptor, suitable for reading +diff --git a/kpartx/kpartx.c b/kpartx/kpartx.c +index 98d88c0..1369542 100644 +--- a/kpartx/kpartx.c ++++ b/kpartx/kpartx.c +@@ -26,6 +26,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -695,3 +696,14 @@ getblock (int fd, unsigned int secnr) { + + return bp->block; + } ++ ++int ++get_sector_size(int filedes) ++{ ++ int rc, sector_size = 512; ++ ++ rc = ioctl(filedes, BLKSSZGET, §or_size); ++ if (rc) ++ sector_size = 512; ++ return sector_size; ++} +diff --git a/kpartx/kpartx.h b/kpartx/kpartx.h +index 61d31b6..a55c211 100644 +--- a/kpartx/kpartx.h ++++ b/kpartx/kpartx.h +@@ -2,6 +2,7 @@ + #define _KPARTX_H + + #include ++#include + + /* + * For each partition type there is a routine that takes +@@ -18,6 +19,13 @@ + #define safe_sprintf(var, format, args...) \ + snprintf(var, sizeof(var), format, ##args) >= sizeof(var) + ++#ifndef BLKSSZGET ++#define BLKSSZGET _IO(0x12,104) /* get block device sector size */ ++#endif ++ ++int ++get_sector_size(int filedes); ++ + /* + * units: 512 byte sectors + */ diff -Nru multipath-tools-0.4.9/debian/patches/series multipath-tools-0.4.9/debian/patches/series --- multipath-tools-0.4.9/debian/patches/series 2015-03-20 15:43:15.000000000 -0300 +++ multipath-tools-0.4.9/debian/patches/series 2015-04-08 15:37:59.000000000 -0300 @@ -16,3 +16,5 @@ 0014-Fix-race-condition-in-stop_waiter_thread.patch 1002-fix-linking-library.patch 0015-shared-lock-for-udev.patch +0016-kpartx-non-512B-GPT.patch +0017-kpartx-non-512B-sectors.patch