[libmultipath] support multipath maps >2TB
authorroot <root@potab.(none)>
Wed, 10 Aug 2005 12:43:43 +0000 (14:43 +0200)
committerroot <root@potab.(none)>
Wed, 10 Aug 2005 12:43:43 +0000 (14:43 +0200)
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.

libmultipath/devmapper.c
libmultipath/devmapper.h
libmultipath/discovery.c
libmultipath/discovery.h
libmultipath/structs.h
multipath/main.c

index acfcfa1..a0489f0 100644 (file)
@@ -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;
 
index 48bb268..d930aae 100644 (file)
@@ -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 *);
index e8ea0de..77d133a 100644 (file)
@@ -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;
 }
index c43d0ac..b083494 100644 (file)
@@ -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 *);
index bd36d7d..f37293a 100644 (file)
@@ -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];
index 4941236..e71c296 100644 (file)
@@ -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);