rpms/device-mapper-multipath/devel multipath-tools-0.4.7.4-uint64.patch, NONE, 1.1 device-mapper-multipath.spec, 1.34, 1.35
fedora-cvs-commits at redhat.com
fedora-cvs-commits at redhat.com
Fri Sep 8 00:38:04 UTC 2006
Author: pjones
Update of /cvs/dist/rpms/device-mapper-multipath/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv21008
Modified Files:
device-mapper-multipath.spec
Added Files:
multipath-tools-0.4.7.4-uint64.patch
Log Message:
- Fix kpartx to work with >2TB drives.
multipath-tools-0.4.7.4-uint64.patch:
devmapper.c | 4 +++-
devmapper.h | 6 ++++--
gpt.c | 31 ++++++++++++++++++++-----------
kpartx.c | 14 ++++++++------
kpartx.h | 6 ++++--
5 files changed, 39 insertions(+), 22 deletions(-)
--- NEW FILE multipath-tools-0.4.7.4-uint64.patch ---
--- multipath-tools-0.4.7.4/kpartx/devmapper.c.uint64 2006-09-07 20:16:42.000000000 -0400
+++ multipath-tools-0.4.7.4/kpartx/devmapper.c 2006-09-07 20:18:36.000000000 -0400
@@ -4,10 +4,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <stdint.h>
#include <libdevmapper.h>
#include <ctype.h>
#include <linux/kdev_t.h>
#include <errno.h>
+#include "devmapper.h"
#define UUID_PREFIX "part%d-"
#define MAX_PREFIX_LEN 8
@@ -72,7 +74,7 @@
extern int
dm_addmap (int task, const char *name, const char *target,
- const char *params, unsigned long size, const char *uuid, int part) {
+ const char *params, uint64_t size, const char *uuid, int part) {
int r = 0;
struct dm_task *dmt;
char *prefixed_uuid;
--- multipath-tools-0.4.7.4/kpartx/kpartx.c.uint64 2006-09-07 19:50:14.000000000 -0400
+++ multipath-tools-0.4.7.4/kpartx/kpartx.c 2006-09-07 20:23:42.000000000 -0400
@@ -25,6 +25,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <stdint.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <ctype.h>
@@ -364,10 +365,10 @@
if (slices[j].size == 0)
continue;
- printf("%s%s%d : 0 %lu %s %lu\n",
+ printf("%s%s%d : 0 %" PRIu64 " %s %" PRIu64"\n",
device + off, delim, j+1,
- (unsigned long) slices[j].size, device,
- (unsigned long) slices[j].start);
+ slices[j].size, device,
+ slices[j].start);
}
break;
@@ -413,8 +414,8 @@
}
strip_slash(partname);
- if (safe_sprintf(params, "%s %lu", device,
- (unsigned long)slices[j].start)) {
+ if (safe_sprintf(params, "%s %" PRIu64, device,
+ slices[j].start)) {
fprintf(stderr, "params too small\n");
exit(1);
}
@@ -430,7 +431,8 @@
partname);
if (verbose)
- printf("add map %s : 0 %lu %s %s\n",
+ printf("add map %s : 0 %" PRIu64
+ " %s %s\n",
partname, slices[j].size,
DM_TARGET, params);
}
--- multipath-tools-0.4.7.4/kpartx/kpartx.h.uint64 2006-09-07 19:49:45.000000000 -0400
+++ multipath-tools-0.4.7.4/kpartx/kpartx.h 2006-09-07 20:22:23.000000000 -0400
@@ -1,6 +1,8 @@
#ifndef _KPARTX_H
#define _KPARTX_H
+#include <stdint.h>
+
/*
* For each partition type there is a routine that takes
* a block device and a range, and returns the list of
@@ -20,8 +22,8 @@
* units: 512 byte sectors
*/
struct slice {
- unsigned long start;
- unsigned long size;
+ uint64_t start;
+ uint64_t size;
};
typedef int (ptreader)(int fd, struct slice all, struct slice *sp, int ns);
--- multipath-tools-0.4.7.4/kpartx/devmapper.h.uint64 2006-09-07 20:16:47.000000000 -0400
+++ multipath-tools-0.4.7.4/kpartx/devmapper.h 2006-09-07 20:18:35.000000000 -0400
@@ -1,7 +1,9 @@
+#include <stdint.h>
+
int dm_prereq (char *, int, int, int);
int dm_simplecmd (int, const char *);
-int dm_addmap (int, const char *, const char *, const char *, unsigned long,
- char *, int);
+int dm_addmap (int, const char *, const char *, const char *, uint64_t,
+ const char *, int);
int dm_map_present (char *);
char * dm_mapname(int major, int minor);
dev_t dm_get_first_dep(char *devname);
--- multipath-tools-0.4.7.4/kpartx/gpt.c.uint64 2006-09-07 19:25:16.000000000 -0400
+++ multipath-tools-0.4.7.4/kpartx/gpt.c 2006-09-07 20:27:51.000000000 -0400
@@ -36,6 +36,7 @@
#include <errno.h>
#include <endian.h>
#include <byteswap.h>
+#include <linux/fs.h>
#include "crc32.h"
#if BYTE_ORDER == LITTLE_ENDIAN
@@ -50,10 +51,18 @@
# define __cpu_to_le32(x) bswap_32(x)
#endif
+#ifndef BLKGETLASTSECT
#define BLKGETLASTSECT _IO(0x12,108) /* get last sector of block device */
+#endif
+#ifndef BLKGETSIZE
#define BLKGETSIZE _IO(0x12,96) /* return device size */
+#endif
+#ifndef BLKSSZGET
#define BLKSSZGET _IO(0x12,104) /* get block device sector size */
+#endif
+#ifndef BLKGETSIZE64
#define BLKGETSIZE64 _IOR(0x12,114,sizeof(uint64_t)) /* return device size in bytes (u64 *arg) */
+#endif
struct blkdev_ioctl_param {
unsigned int block;
@@ -143,20 +152,14 @@
static uint64_t
_get_num_sectors(int filedes)
{
- unsigned long sectors=0;
int rc;
-#if 0
- uint64_t bytes=0;
+ uint64_t bytes=0;
rc = ioctl(filedes, BLKGETSIZE64, &bytes);
if (!rc)
return bytes / get_sector_size(filedes);
-#endif
- rc = ioctl(filedes, BLKGETSIZE, §ors);
- if (rc)
- return 0;
- return sectors;
+ return 0;
}
/************************************************************
@@ -193,7 +196,7 @@
sectors = 1;
}
- return sectors - 1;
+ return sectors ? sectors - 1 : 0;
}
@@ -220,17 +223,22 @@
{
int sector_size = get_sector_size(fd);
off_t offset = lba * sector_size;
+ uint64_t lastlba;
ssize_t bytesread;
lseek(fd, offset, SEEK_SET);
bytesread = read(fd, buffer, bytes);
+ lastlba = last_lba(fd);
+ if (!lastlba)
+ return bytesread;
+
/* Kludge. This is necessary to read/write the last
block of an odd-sized disk, until Linux 2.5.x kernel fixes.
This is only used by gpt.c, and only to read
one sector, so we don't have to be fancy.
*/
- if (!bytesread && !(last_lba(fd) & 1) && lba == last_lba(fd)) {
+ if (!bytesread && !(lastlba & 1) && lba == lastlba) {
bytesread = read_lastoddsector(fd, lba, buffer, bytes);
}
return bytesread;
@@ -505,7 +513,8 @@
if (!gpt || !ptes)
return 0;
- lastlba = last_lba(fd);
+ if (!(lastlba = last_lba(fd)))
+ return 0;
good_pgpt = is_gpt_valid(fd, GPT_PRIMARY_PARTITION_TABLE_LBA,
&pgpt, &pptes);
if (good_pgpt) {
Index: device-mapper-multipath.spec
===================================================================
RCS file: /cvs/dist/rpms/device-mapper-multipath/devel/device-mapper-multipath.spec,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- device-mapper-multipath.spec 31 Aug 2006 22:21:44 -0000 1.34
+++ device-mapper-multipath.spec 8 Sep 2006 00:38:02 -0000 1.35
@@ -1,7 +1,7 @@
Summary: Tools to manage multipath devices using device-mapper.
Name: device-mapper-multipath
Version: 0.4.7
-Release: 4.1
+Release: 5
License: GPL
Group: System Environment/Base
URL: http://christophe.varoqui.free.fr/
@@ -13,6 +13,7 @@
BuildRequires: libselinux-devel, libsepol-devel
BuildRequires: readline-devel, ncurses-devel
Patch0: multipath-tools-0.4.7.4-badptr.patch
+Patch1: multipath-tools-0.4.7.4-uint64.patch
%description
%{name} provides tools to manage multipath devices by instructing the
@@ -32,6 +33,7 @@
%prep
%setup -q -n multipath-tools-0.4.7.4
%patch0 -p1 -b .badptr
+%patch1 -p1 -b .uint64
%build
make DESTDIR=$RPM_BUILD_ROOT
@@ -78,6 +80,9 @@
%{_mandir}/man8/kpartx.8.gz
%changelog
+* Thu Sep 7 2006 Peter Jones <pjones at redhat.com> - 0.4.7-5
+- Fix kpartx to handle with drives >2TB correctly.
+
* Thu Aug 31 2006 Peter Jones <pjones at redhat.com> - 0.4.7-4.1
- Split kpartx out into its own package so dmraid can use it without
installing multipathd
More information about the fedora-cvs-commits
mailing list