Commit 4ee218cd authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] dm: remove SECTOR_FORMAT

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: default avatarAlasdair G Kergon <agk@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 930d332a
...@@ -518,6 +518,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) ...@@ -518,6 +518,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
char *ivopts; char *ivopts;
unsigned int crypto_flags; unsigned int crypto_flags;
unsigned int key_size; unsigned int key_size;
unsigned long long tmpll;
if (argc != 5) { if (argc != 5) {
ti->error = PFX "Not enough arguments"; ti->error = PFX "Not enough arguments";
...@@ -633,15 +634,17 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) ...@@ -633,15 +634,17 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
goto bad5; 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"; ti->error = PFX "Invalid iv_offset sector";
goto bad5; 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"; ti->error = PFX "Invalid device sector";
goto bad5; goto bad5;
} }
cc->start = tmpll;
if (dm_get_device(ti, argv[3], cc->start, ti->len, if (dm_get_device(ti, argv[3], cc->start, ti->len,
dm_table_get_mode(ti->table), &cc->dev)) { dm_table_get_mode(ti->table), &cc->dev)) {
...@@ -885,8 +888,8 @@ static int crypt_status(struct dm_target *ti, status_type_t type, ...@@ -885,8 +888,8 @@ static int crypt_status(struct dm_target *ti, status_type_t type,
result[sz++] = '-'; result[sz++] = '-';
} }
DMEMIT(" " SECTOR_FORMAT " %s " SECTOR_FORMAT, DMEMIT(" %llu %s %llu", (unsigned long long)cc->iv_offset,
cc->iv_offset, cc->dev->name, cc->start); cc->dev->name, (unsigned long long)cc->start);
break; break;
} }
return 0; return 0;
......
...@@ -26,6 +26,7 @@ struct linear_c { ...@@ -26,6 +26,7 @@ struct linear_c {
static int linear_ctr(struct dm_target *ti, unsigned int argc, char **argv) static int linear_ctr(struct dm_target *ti, unsigned int argc, char **argv)
{ {
struct linear_c *lc; struct linear_c *lc;
unsigned long long tmp;
if (argc != 2) { if (argc != 2) {
ti->error = "dm-linear: Invalid argument count"; ti->error = "dm-linear: Invalid argument count";
...@@ -38,10 +39,11 @@ static int linear_ctr(struct dm_target *ti, unsigned int argc, char **argv) ...@@ -38,10 +39,11 @@ static int linear_ctr(struct dm_target *ti, unsigned int argc, char **argv)
return -ENOMEM; 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"; ti->error = "dm-linear: Invalid device sector";
goto bad; goto bad;
} }
lc->start = tmp;
if (dm_get_device(ti, argv[0], lc->start, ti->len, if (dm_get_device(ti, argv[0], lc->start, ti->len,
dm_table_get_mode(ti->table), &lc->dev)) { dm_table_get_mode(ti->table), &lc->dev)) {
...@@ -87,8 +89,8 @@ static int linear_status(struct dm_target *ti, status_type_t type, ...@@ -87,8 +89,8 @@ static int linear_status(struct dm_target *ti, status_type_t type,
break; break;
case STATUSTYPE_TABLE: case STATUSTYPE_TABLE:
snprintf(result, maxlen, "%s " SECTOR_FORMAT, lc->dev->name, snprintf(result, maxlen, "%s %llu", lc->dev->name,
lc->start); (unsigned long long)lc->start);
break; break;
} }
return 0; return 0;
......
...@@ -934,9 +934,9 @@ static inline int _check_region_size(struct dm_target *ti, uint32_t size) ...@@ -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, static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
unsigned int mirror, char **argv) 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"; ti->error = "dm-mirror: Invalid offset";
return -EINVAL; return -EINVAL;
} }
...@@ -1203,16 +1203,17 @@ static int mirror_status(struct dm_target *ti, status_type_t type, ...@@ -1203,16 +1203,17 @@ static int mirror_status(struct dm_target *ti, status_type_t type,
for (m = 0; m < ms->nr_mirrors; m++) for (m = 0; m < ms->nr_mirrors; m++)
DMEMIT("%s ", ms->mirror[m].dev->name); DMEMIT("%s ", ms->mirror[m].dev->name);
DMEMIT(SECTOR_FORMAT "/" SECTOR_FORMAT, DMEMIT("%llu/%llu",
ms->rh.log->type->get_sync_count(ms->rh.log), (unsigned long long)ms->rh.log->type->
ms->nr_regions); get_sync_count(ms->rh.log),
(unsigned long long)ms->nr_regions);
break; break;
case STATUSTYPE_TABLE: case STATUSTYPE_TABLE:
DMEMIT("%d ", ms->nr_mirrors); DMEMIT("%d ", ms->nr_mirrors);
for (m = 0; m < ms->nr_mirrors; m++) for (m = 0; m < ms->nr_mirrors; m++)
DMEMIT("%s " SECTOR_FORMAT " ", DMEMIT("%s %llu ", ms->mirror[m].dev->name,
ms->mirror[m].dev->name, ms->mirror[m].offset); (unsigned long long)ms->mirror[m].offset);
} }
return 0; return 0;
......
...@@ -959,9 +959,9 @@ static int snapshot_status(struct dm_target *ti, status_type_t type, ...@@ -959,9 +959,9 @@ static int snapshot_status(struct dm_target *ti, status_type_t type,
snap->store.fraction_full(&snap->store, snap->store.fraction_full(&snap->store,
&numerator, &numerator,
&denominator); &denominator);
snprintf(result, maxlen, snprintf(result, maxlen, "%llu/%llu",
SECTOR_FORMAT "/" SECTOR_FORMAT, (unsigned long long)numerator,
numerator, denominator); (unsigned long long)denominator);
} }
else else
snprintf(result, maxlen, "Unknown"); snprintf(result, maxlen, "Unknown");
...@@ -974,9 +974,10 @@ static int snapshot_status(struct dm_target *ti, status_type_t type, ...@@ -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 * to make private copies if the output is to
* make sense. * make sense.
*/ */
snprintf(result, maxlen, "%s %s %c " SECTOR_FORMAT, snprintf(result, maxlen, "%s %s %c %llu",
snap->origin->name, snap->cow->name, snap->origin->name, snap->cow->name,
snap->type, snap->chunk_size); snap->type,
(unsigned long long)snap->chunk_size);
break; break;
} }
......
...@@ -49,9 +49,9 @@ static inline struct stripe_c *alloc_context(unsigned int stripes) ...@@ -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, static int get_stripe(struct dm_target *ti, struct stripe_c *sc,
unsigned int stripe, char **argv) 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; return -EINVAL;
if (dm_get_device(ti, argv[0], start, sc->stripe_width, if (dm_get_device(ti, argv[0], start, sc->stripe_width,
...@@ -201,10 +201,11 @@ static int stripe_status(struct dm_target *ti, ...@@ -201,10 +201,11 @@ static int stripe_status(struct dm_target *ti,
break; break;
case STATUSTYPE_TABLE: 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++) for (i = 0; i < sc->stripes; i++)
DMEMIT(" %s " SECTOR_FORMAT, sc->stripe[i].dev->name, DMEMIT(" %s %llu", sc->stripe[i].dev->name,
sc->stripe[i].physical_start); (unsigned long long)sc->stripe[i].physical_start);
break; break;
} }
return 0; return 0;
......
...@@ -23,16 +23,6 @@ ...@@ -23,16 +23,6 @@
#define DMEMIT(x...) sz += ((sz >= maxlen) ? \ #define DMEMIT(x...) sz += ((sz >= maxlen) ? \
0 : scnprintf(result + sz, maxlen - sz, x)) 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 #define SECTOR_SHIFT 9
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment