]> err.no Git - linux-2.6/commitdiff
[PATCH] dm: remove SECTOR_FORMAT
authorAndrew Morton <akpm@osdl.org>
Mon, 27 Mar 2006 09:17:48 +0000 (01:17 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 27 Mar 2006 16:44:58 +0000 (08:44 -0800)
We don't know what type sector_t has.  Sometimes it's unsigned long, sometimes
it's unsigned long long.  For example on ppc64 it's unsigned long with
CONFIG_LBD=n and on x86_64 it's unsigned long long with CONFIG_LBD=n.

The way to handle all of this is to always use unsigned long long and to
always typecast the sector_t when printing it.

Acked-by: Alasdair G Kergon <agk@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/md/dm-crypt.c
drivers/md/dm-linear.c
drivers/md/dm-raid1.c
drivers/md/dm-snap.c
drivers/md/dm-stripe.c
drivers/md/dm.h

index 259e86f265492bb98f5af0af59d185f9d841dd4b..61a590bb6241018f10cecfdd4f92aed8d4b29168 100644 (file)
@@ -518,6 +518,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
        char *ivopts;
        unsigned int crypto_flags;
        unsigned int key_size;
+       unsigned long long tmpll;
 
        if (argc != 5) {
                ti->error = PFX "Not enough arguments";
@@ -633,15 +634,17 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
                goto bad5;
        }
 
-       if (sscanf(argv[2], SECTOR_FORMAT, &cc->iv_offset) != 1) {
+       if (sscanf(argv[2], "%llu", &tmpll) != 1) {
                ti->error = PFX "Invalid iv_offset sector";
                goto bad5;
        }
+       cc->iv_offset = tmpll;
 
-       if (sscanf(argv[4], SECTOR_FORMAT, &cc->start) != 1) {
+       if (sscanf(argv[4], "%llu", &tmpll) != 1) {
                ti->error = PFX "Invalid device sector";
                goto bad5;
        }
+       cc->start = tmpll;
 
        if (dm_get_device(ti, argv[3], cc->start, ti->len,
                          dm_table_get_mode(ti->table), &cc->dev)) {
@@ -885,8 +888,8 @@ static int crypt_status(struct dm_target *ti, status_type_t type,
                        result[sz++] = '-';
                }
 
-               DMEMIT(" " SECTOR_FORMAT " %s " SECTOR_FORMAT,
-                      cc->iv_offset, cc->dev->name, cc->start);
+               DMEMIT(" %llu %s %llu", (unsigned long long)cc->iv_offset,
+                               cc->dev->name, (unsigned long long)cc->start);
                break;
        }
        return 0;
index 6a2cd5dc8a6352879d396e6a977b6508730ba0d2..daf586c0898dc2b91aa2ebe33090a0acc7721951 100644 (file)
@@ -26,6 +26,7 @@ struct linear_c {
 static int linear_ctr(struct dm_target *ti, unsigned int argc, char **argv)
 {
        struct linear_c *lc;
+       unsigned long long tmp;
 
        if (argc != 2) {
                ti->error = "dm-linear: Invalid argument count";
@@ -38,10 +39,11 @@ static int linear_ctr(struct dm_target *ti, unsigned int argc, char **argv)
                return -ENOMEM;
        }
 
-       if (sscanf(argv[1], SECTOR_FORMAT, &lc->start) != 1) {
+       if (sscanf(argv[1], "%llu", &tmp) != 1) {
                ti->error = "dm-linear: Invalid device sector";
                goto bad;
        }
+       lc->start = tmp;
 
        if (dm_get_device(ti, argv[0], lc->start, ti->len,
                          dm_table_get_mode(ti->table), &lc->dev)) {
@@ -87,8 +89,8 @@ static int linear_status(struct dm_target *ti, status_type_t type,
                break;
 
        case STATUSTYPE_TABLE:
-               snprintf(result, maxlen, "%s " SECTOR_FORMAT, lc->dev->name,
-                        lc->start);
+               snprintf(result, maxlen, "%s %llu", lc->dev->name,
+                               (unsigned long long)lc->start);
                break;
        }
        return 0;
index 3d90f1b37e083e30237523fb6fbad98e8d4f5d04..d12cf3e5e0763cfd9f3d8acb3771f8ee4197f283 100644 (file)
@@ -934,9 +934,9 @@ static inline int _check_region_size(struct dm_target *ti, uint32_t size)
 static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
                      unsigned int mirror, char **argv)
 {
-       sector_t offset;
+       unsigned long long offset;
 
-       if (sscanf(argv[1], SECTOR_FORMAT, &offset) != 1) {
+       if (sscanf(argv[1], "%llu", &offset) != 1) {
                ti->error = "dm-mirror: Invalid offset";
                return -EINVAL;
        }
@@ -1203,16 +1203,17 @@ static int mirror_status(struct dm_target *ti, status_type_t type,
                for (m = 0; m < ms->nr_mirrors; m++)
                        DMEMIT("%s ", ms->mirror[m].dev->name);
 
-               DMEMIT(SECTOR_FORMAT "/" SECTOR_FORMAT,
-                      ms->rh.log->type->get_sync_count(ms->rh.log),
-                      ms->nr_regions);
+               DMEMIT("%llu/%llu",
+                       (unsigned long long)ms->rh.log->type->
+                               get_sync_count(ms->rh.log),
+                       (unsigned long long)ms->nr_regions);
                break;
 
        case STATUSTYPE_TABLE:
                DMEMIT("%d ", ms->nr_mirrors);
                for (m = 0; m < ms->nr_mirrors; m++)
-                       DMEMIT("%s " SECTOR_FORMAT " ",
-                              ms->mirror[m].dev->name, ms->mirror[m].offset);
+                       DMEMIT("%s %llu ", ms->mirror[m].dev->name,
+                               (unsigned long long)ms->mirror[m].offset);
        }
 
        return 0;
index 14bd1a1815b1b4792f3933bdcc0486b57cecb2ec..a5765f9fbe02f2322a7993fe895bb009815b57f6 100644 (file)
@@ -959,9 +959,9 @@ static int snapshot_status(struct dm_target *ti, status_type_t type,
                                snap->store.fraction_full(&snap->store,
                                                          &numerator,
                                                          &denominator);
-                               snprintf(result, maxlen,
-                                        SECTOR_FORMAT "/" SECTOR_FORMAT,
-                                        numerator, denominator);
+                               snprintf(result, maxlen, "%llu/%llu",
+                                       (unsigned long long)numerator,
+                                       (unsigned long long)denominator);
                        }
                        else
                                snprintf(result, maxlen, "Unknown");
@@ -974,9 +974,10 @@ static int snapshot_status(struct dm_target *ti, status_type_t type,
                 * to make private copies if the output is to
                 * make sense.
                 */
-               snprintf(result, maxlen, "%s %s %c " SECTOR_FORMAT,
+               snprintf(result, maxlen, "%s %s %c %llu",
                         snap->origin->name, snap->cow->name,
-                        snap->type, snap->chunk_size);
+                        snap->type,
+                        (unsigned long long)snap->chunk_size);
                break;
        }
 
index 697aacafb02aedb3dd68ef3d97deda93a007b9ed..204f796ee9e32d36797079a595705c54f2c19c6f 100644 (file)
@@ -49,9 +49,9 @@ static inline struct stripe_c *alloc_context(unsigned int stripes)
 static int get_stripe(struct dm_target *ti, struct stripe_c *sc,
                      unsigned int stripe, char **argv)
 {
-       sector_t start;
+       unsigned long long start;
 
-       if (sscanf(argv[1], SECTOR_FORMAT, &start) != 1)
+       if (sscanf(argv[1], "%llu", &start) != 1)
                return -EINVAL;
 
        if (dm_get_device(ti, argv[0], start, sc->stripe_width,
@@ -201,10 +201,11 @@ static int stripe_status(struct dm_target *ti,
                break;
 
        case STATUSTYPE_TABLE:
-               DMEMIT("%d " SECTOR_FORMAT, sc->stripes, sc->chunk_mask + 1);
+               DMEMIT("%d %llu", sc->stripes,
+                       (unsigned long long)sc->chunk_mask + 1);
                for (i = 0; i < sc->stripes; i++)
-                       DMEMIT(" %s " SECTOR_FORMAT, sc->stripe[i].dev->name,
-                              sc->stripe[i].physical_start);
+                       DMEMIT(" %s %llu", sc->stripe[i].dev->name,
+                           (unsigned long long)sc->stripe[i].physical_start);
                break;
        }
        return 0;
index 4eaf075da21761095d5e0f919e7508d8d072d6bf..0ff11d6f81587d965766a10c173dc72da983deb0 100644 (file)
 #define DMEMIT(x...) sz += ((sz >= maxlen) ? \
                          0 : scnprintf(result + sz, maxlen - sz, x))
 
-/*
- * FIXME: I think this should be with the definition of sector_t
- * in types.h.
- */
-#ifdef CONFIG_LBD
-#define SECTOR_FORMAT "%llu"
-#else
-#define SECTOR_FORMAT "%lu"
-#endif
-
 #define SECTOR_SHIFT 9
 
 /*