summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root@potab.(none)>2005-08-10 14:43:43 +0200
committerroot <root@potab.(none)>2005-08-10 14:43:43 +0200
commit9951e43f31b64aaff8b8fd3ae9e8255cbac8a6c7 (patch)
treebe82d175ad14714836d10d3ee2a39c18fe677c8f
parent48994c1b64fac2f9bb9ce4de6bfb4a03b242a023 (diff)
downloadmultipath-tools-9951e43f31b64aaff8b8fd3ae9e8255cbac8a6c7.tar.gz
multipath-tools-9951e43f31b64aaff8b8fd3ae9e8255cbac8a6c7.tar.bz2
multipath-tools-9951e43f31b64aaff8b8fd3ae9e8255cbac8a6c7.zip
[libmultipath] support multipath maps >2TB
Size field moved to ULL in struct path and multipath, as per $KSRC/drivers/block/genhd.c suggests /sys/block/*/size size is. Users updated.
-rw-r--r--libmultipath/devmapper.c6
-rw-r--r--libmultipath/devmapper.h5
-rw-r--r--libmultipath/discovery.c13
-rw-r--r--libmultipath/discovery.h2
-rw-r--r--libmultipath/structs.h4
-rw-r--r--multipath/main.c16
6 files changed, 27 insertions, 19 deletions
diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
index acfcfa1..a0489f0 100644
--- a/libmultipath/devmapper.c
+++ b/libmultipath/devmapper.c
@@ -84,7 +84,7 @@ dm_simplecmd (int task, const char *name) {
extern int
dm_addmap (int task, const char *name, const char *target,
- const char *params, unsigned long size) {
+ const char *params, unsigned long long size) {
int r = 0;
struct dm_task *dmt;
@@ -135,7 +135,7 @@ out:
}
extern int
-dm_get_map(char * name, unsigned long * size, char * outparams)
+dm_get_map(char * name, unsigned long long * size, char * outparams)
{
int r = 1;
struct dm_task *dmt;
@@ -648,7 +648,7 @@ dm_remove_partmaps (char * mapname)
struct dm_names *names;
unsigned next = 0;
char params[PARAMS_SIZE];
- unsigned long size;
+ unsigned long long size;
char dev_t[32];
int r = 1;
diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h
index 48bb268..d930aae 100644
--- a/libmultipath/devmapper.h
+++ b/libmultipath/devmapper.h
@@ -1,8 +1,9 @@
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);
+int dm_addmap (int, const char *, const char *, const char *,
+ unsigned long long);
int dm_map_present (char *);
-int dm_get_map(char *, unsigned long *, char *);
+int dm_get_map(char *, unsigned long long *, char *);
int dm_get_status(char *, char *);
int dm_type(char *, char *);
int dm_flush_map (char *, char *);
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index e8ea0de..77d133a 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -154,11 +154,13 @@ declare_sysfs_get_str(rev, "%s/block/%s/device/rev");
declare_sysfs_get_str(dev, "%s/block/%s/dev");
#define declare_sysfs_get_val(fname, fmt) \
-extern unsigned long \
+extern unsigned long long \
sysfs_get_##fname (char * sysfs_path, char * dev) \
{ \
char attr_path[SYSFS_PATH_SIZE]; \
char attr_buff[SYSFS_PATH_SIZE]; \
+ int r; \
+ unsigned long long val; \
\
if (safe_sprintf(attr_path, fmt, sysfs_path, dev)) \
return 0; \
@@ -169,7 +171,12 @@ sysfs_get_##fname (char * sysfs_path, char * dev) \
if (0 > sysfs_read_attribute_value(attr_path, attr_buff, sizeof(attr_buff))) \
return 0; \
\
- return strtoul(attr_buff, NULL, 0); \
+ r = sscanf(attr_buff, "%llu\n", &val); \
+\
+ if (r != 1) \
+ return 0; \
+ else \
+ return (val); \
}
declare_sysfs_get_val(size, "%s/block/%s/size");
@@ -453,7 +460,7 @@ common_sysfs_pathinfo (struct path * curpath)
if (curpath->size == 0)
return 1;
- condlog(3, "size = %lu", curpath->size);
+ condlog(3, "size = %llu", curpath->size);
return 0;
}
diff --git a/libmultipath/discovery.h b/libmultipath/discovery.h
index c43d0ac..b083494 100644
--- a/libmultipath/discovery.h
+++ b/libmultipath/discovery.h
@@ -26,7 +26,7 @@ int sysfs_get_model (char * sysfs_path, char * dev, char * buff, int len);
int sysfs_get_rev (char * sysfs_path, char * dev, char * buff, int len);
int sysfs_get_dev (char * sysfs_path, char * dev, char * buff, int len);
-unsigned long sysfs_get_size (char * sysfs_path, char * dev);
+unsigned long long sysfs_get_size (char * sysfs_path, char * dev);
int path_discovery (vector pathvec, struct config * conf, int flag);
void basename (char *, char *);
diff --git a/libmultipath/structs.h b/libmultipath/structs.h
index bd36d7d..f37293a 100644
--- a/libmultipath/structs.h
+++ b/libmultipath/structs.h
@@ -72,7 +72,7 @@ struct path {
char rev[SCSI_REV_SIZE];
char serial[SERIAL_SIZE];
char tgt_node_name[NODE_NAME_SIZE];
- unsigned long size;
+ unsigned long long size;
unsigned int checkint;
unsigned int tick;
int state;
@@ -102,7 +102,7 @@ struct multipath {
int action;
int pgfailback;
int failback_tick;
- unsigned long size;
+ unsigned long long size;
vector paths;
vector pg;
char params[PARAMS_SIZE];
diff --git a/multipath/main.c b/multipath/main.c
index 4941236..e71c296 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -172,7 +172,7 @@ static void
print_map (struct multipath * mpp)
{
if (mpp->size && mpp->params)
- printf("0 %lu %s %s\n",
+ printf("0 %llu %s %s\n",
mpp->size, DEFAULT_TARGET, mpp->params);
return;
}
@@ -228,14 +228,14 @@ print_mp (struct multipath * mpp)
printf("\n");
- if (mpp->size < 2048)
- printf("[size=%lu kB]", mpp->size / 2);
- else if (mpp->size < 2097152)
- printf("[size=%lu MB]", mpp->size / 2048);
- else if (mpp->size < 2147483648)
- printf("[size=%lu GB]", mpp->size / 2097152 );
+ if (mpp->size < (1 << 11))
+ printf("[size=%llu kB]", mpp->size);
+ else if (mpp->size < (1 << 21))
+ printf("[size=%llu MB]", mpp->size >> 10);
+ else if (mpp->size < (1 << 31))
+ printf("[size=%llu GB]", mpp->size >> 20);
else
- printf("[size=%lu TB]", mpp->size / 2147483648);
+ printf("[size=%llu TB]", mpp->size >> 30);
if (mpp->features)
printf("[features=\"%s\"]", mpp->features);