
From: Lars Marowsky-Bree <lmb@suse.de>,
      Alasdair G Kergon <agk@redhat.com>

Add a name field to struct dm_dev so we don't have to use format_dev_t()
all over the place for informative error messages.

Signed-Off-By: Alasdair G Kergon <agk@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/drivers/md/dm-crypt.c  |    4 +---
 25-akpm/drivers/md/dm-linear.c |    5 ++---
 25-akpm/drivers/md/dm-raid1.c  |   13 ++++---------
 25-akpm/drivers/md/dm-snap.c   |   11 +++--------
 25-akpm/drivers/md/dm-stripe.c |    7 ++-----
 25-akpm/drivers/md/dm-table.c  |    2 ++
 25-akpm/drivers/md/dm.h        |    1 +
 7 files changed, 15 insertions(+), 28 deletions(-)

diff -puN drivers/md/dm-crypt.c~device-mapper-store-name-directly-against-device drivers/md/dm-crypt.c
--- 25/drivers/md/dm-crypt.c~device-mapper-store-name-directly-against-device	Wed Feb  9 14:24:15 2005
+++ 25-akpm/drivers/md/dm-crypt.c	Wed Feb  9 14:24:15 2005
@@ -869,7 +869,6 @@ static int crypt_status(struct dm_target
 			char *result, unsigned int maxlen)
 {
 	struct crypt_config *cc = (struct crypt_config *) ti->private;
-	char buffer[32];
 	const char *cipher;
 	const char *chainmode = NULL;
 	unsigned int sz = 0;
@@ -910,9 +909,8 @@ static int crypt_status(struct dm_target
 			result[sz++] = '-';
 		}
 
-		format_dev_t(buffer, cc->dev->bdev->bd_dev);
 		DMEMIT(" " SECTOR_FORMAT " %s " SECTOR_FORMAT,
-		       cc->iv_offset, buffer, cc->start);
+		       cc->iv_offset, cc->dev->name, cc->start);
 		break;
 	}
 	return 0;
diff -puN drivers/md/dm.h~device-mapper-store-name-directly-against-device drivers/md/dm.h
--- 25/drivers/md/dm.h~device-mapper-store-name-directly-against-device	Wed Feb  9 14:24:15 2005
+++ 25-akpm/drivers/md/dm.h	Wed Feb  9 14:24:16 2005
@@ -44,6 +44,7 @@ struct dm_dev {
 	atomic_t count;
 	int mode;
 	struct block_device *bdev;
+	char name[16];
 };
 
 struct dm_table;
diff -puN drivers/md/dm-linear.c~device-mapper-store-name-directly-against-device drivers/md/dm-linear.c
--- 25/drivers/md/dm-linear.c~device-mapper-store-name-directly-against-device	Wed Feb  9 14:24:15 2005
+++ 25-akpm/drivers/md/dm-linear.c	Wed Feb  9 14:24:15 2005
@@ -80,7 +80,6 @@ static int linear_status(struct dm_targe
 			 char *result, unsigned int maxlen)
 {
 	struct linear_c *lc = (struct linear_c *) ti->private;
-	char buffer[32];
 
 	switch (type) {
 	case STATUSTYPE_INFO:
@@ -88,8 +87,8 @@ static int linear_status(struct dm_targe
 		break;
 
 	case STATUSTYPE_TABLE:
-		format_dev_t(buffer, lc->dev->bdev->bd_dev);
-		snprintf(result, maxlen, "%s " SECTOR_FORMAT, buffer, lc->start);
+		snprintf(result, maxlen, "%s " SECTOR_FORMAT, lc->dev->name,
+			 lc->start);
 		break;
 	}
 	return 0;
diff -puN drivers/md/dm-raid1.c~device-mapper-store-name-directly-against-device drivers/md/dm-raid1.c
--- 25/drivers/md/dm-raid1.c~device-mapper-store-name-directly-against-device	Wed Feb  9 14:24:15 2005
+++ 25-akpm/drivers/md/dm-raid1.c	Wed Feb  9 14:24:15 2005
@@ -1182,7 +1182,6 @@ static void mirror_resume(struct dm_targ
 static int mirror_status(struct dm_target *ti, status_type_t type,
 			 char *result, unsigned int maxlen)
 {
-	char buffer[32];
 	unsigned int m, sz;
 	struct mirror_set *ms = (struct mirror_set *) ti->private;
 
@@ -1191,10 +1190,8 @@ static int mirror_status(struct dm_targe
 	switch (type) {
 	case STATUSTYPE_INFO:
 		DMEMIT("%d ", ms->nr_mirrors);
-		for (m = 0; m < ms->nr_mirrors; m++) {
-			format_dev_t(buffer, ms->mirror[m].dev->bdev->bd_dev);
-			DMEMIT("%s ", buffer);
-		}
+		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),
@@ -1203,11 +1200,9 @@ static int mirror_status(struct dm_targe
 
 	case STATUSTYPE_TABLE:
 		DMEMIT("%d ", ms->nr_mirrors);
-		for (m = 0; m < ms->nr_mirrors; m++) {
-			format_dev_t(buffer, ms->mirror[m].dev->bdev->bd_dev);
+		for (m = 0; m < ms->nr_mirrors; m++)
 			DMEMIT("%s " SECTOR_FORMAT " ",
-			       buffer, ms->mirror[m].offset);
-		}
+			       ms->mirror[m].dev->name, ms->mirror[m].offset);
 	}
 
 	return 0;
diff -puN drivers/md/dm-snap.c~device-mapper-store-name-directly-against-device drivers/md/dm-snap.c
--- 25/drivers/md/dm-snap.c~device-mapper-store-name-directly-against-device	Wed Feb  9 14:24:15 2005
+++ 25-akpm/drivers/md/dm-snap.c	Wed Feb  9 14:24:15 2005
@@ -864,8 +864,6 @@ static int snapshot_status(struct dm_tar
 			   char *result, unsigned int maxlen)
 {
 	struct dm_snapshot *snap = (struct dm_snapshot *) ti->private;
-	char cow[32];
-	char org[32];
 
 	switch (type) {
 	case STATUSTYPE_INFO:
@@ -892,9 +890,8 @@ static int snapshot_status(struct dm_tar
 		 * to make private copies if the output is to
 		 * make sense.
 		 */
-		format_dev_t(cow, snap->cow->bdev->bd_dev);
-		format_dev_t(org, snap->origin->bdev->bd_dev);
-		snprintf(result, maxlen, "%s %s %c " SECTOR_FORMAT, org, cow,
+		snprintf(result, maxlen, "%s %s %c " SECTOR_FORMAT,
+			 snap->origin->name, snap->cow->name,
 			 snap->type, snap->chunk_size);
 		break;
 	}
@@ -1082,7 +1079,6 @@ static int origin_status(struct dm_targe
 			 unsigned int maxlen)
 {
 	struct dm_dev *dev = (struct dm_dev *) ti->private;
-	char buffer[32];
 
 	switch (type) {
 	case STATUSTYPE_INFO:
@@ -1090,8 +1086,7 @@ static int origin_status(struct dm_targe
 		break;
 
 	case STATUSTYPE_TABLE:
-		format_dev_t(buffer, dev->bdev->bd_dev);
-		snprintf(result, maxlen, "%s", buffer);
+		snprintf(result, maxlen, "%s", dev->name);
 		break;
 	}
 
diff -puN drivers/md/dm-stripe.c~device-mapper-store-name-directly-against-device drivers/md/dm-stripe.c
--- 25/drivers/md/dm-stripe.c~device-mapper-store-name-directly-against-device	Wed Feb  9 14:24:15 2005
+++ 25-akpm/drivers/md/dm-stripe.c	Wed Feb  9 14:24:15 2005
@@ -188,7 +188,6 @@ static int stripe_status(struct dm_targe
 	struct stripe_c *sc = (struct stripe_c *) ti->private;
 	unsigned int sz = 0;
 	unsigned int i;
-	char buffer[32];
 
 	switch (type) {
 	case STATUSTYPE_INFO:
@@ -197,11 +196,9 @@ static int stripe_status(struct dm_targe
 
 	case STATUSTYPE_TABLE:
 		DMEMIT("%d " SECTOR_FORMAT, sc->stripes, sc->chunk_mask + 1);
-		for (i = 0; i < sc->stripes; i++) {
-			format_dev_t(buffer, sc->stripe[i].dev->bdev->bd_dev);
-			DMEMIT(" %s " SECTOR_FORMAT, buffer,
+		for (i = 0; i < sc->stripes; i++)
+			DMEMIT(" %s " SECTOR_FORMAT, sc->stripe[i].dev->name,
 			       sc->stripe[i].physical_start);
-		}
 		break;
 	}
 	return 0;
diff -puN drivers/md/dm-table.c~device-mapper-store-name-directly-against-device drivers/md/dm-table.c
--- 25/drivers/md/dm-table.c~device-mapper-store-name-directly-against-device	Wed Feb  9 14:24:15 2005
+++ 25-akpm/drivers/md/dm-table.c	Wed Feb  9 14:24:16 2005
@@ -455,6 +455,8 @@ static int __table_get_device(struct dm_
 			return r;
 		}
 
+		format_dev_t(dd->name, dev);
+
 		atomic_set(&dd->count, 0);
 		list_add(&dd->list, &t->devices);
 
_
