[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[dm-devel] format_dev_t() cleanup



As discussed on IRC, a first step towards somewhat better logging...


Just call format_dev_t() once and store the result on dm_dev to ease
logging the device.

Signed-off-by: Lars Marowsky-Bree <lmb suse de>

Index: linux-2.6.5/drivers/md/dm-mpath.c
===================================================================
--- linux-2.6.5.orig/drivers/md/dm-mpath.c	2005-01-19 14:41:17.000000000 +0100
+++ linux-2.6.5/drivers/md/dm-mpath.c	2005-01-21 15:33:23.801629900 +0100
@@ -780,7 +783,9 @@ static int fail_path(struct pgpath *pgpa
 		goto out;
 
 	m = pgpath->pg->m;
-
+	
+	DMWARN("dm-multipath: Failing path %s.", pgpath->path.dev->name);
+	
 	pgpath->pg->ps.type->fail_path(&pgpath->pg->ps, &pgpath->path);
 	pgpath->path.is_active = 0;
 	pgpath->fail_count++;
@@ -936,14 +941,20 @@ void dm_pg_init_complete(struct path *pa
 	unsigned long flags;
 
 	/* We insist on failing the path if the PG is already bypassed. */
-	if (err_flags && pg->bypassed)
+	if (err_flags && pg->bypassed) {
+		DMWARN("dm-multipath: PG init failed for bypassed PG.");
 		err_flags |= MP_FAIL_PATH;
-
-	if (err_flags & MP_FAIL_PATH)
+	}
+	
+	if (err_flags & MP_FAIL_PATH) {
+		DMWARN("dm-multipath: failed PG init causes path to be failed.");
 		fail_path(pgpath);
-
-	if (err_flags & MP_BYPASS_PG)
+	}
+	
+	if (err_flags & MP_BYPASS_PG) {
+		DMINFO("dm-multipath: PG init result causes PG to be bypassed.");
 		bypass_pg(m, pg, 1);
+	}
 
 	spin_lock_irqsave(&m->lock, flags);
 	if (!err_flags)
@@ -1078,7 +1089,6 @@ static int multipath_status(struct dm_ta
 	struct priority_group *pg;
 	struct pgpath *p;
 	unsigned pg_num;
-	char buffer[32];
 	char state;
 
 	/* Features */
@@ -1131,9 +1141,8 @@ static int multipath_status(struct dm_ta
 			DMEMIT("%u %u ", pg->nr_paths, pg->ps.type->info_args);
 
 			list_for_each_entry(p, &pg->pgpaths, list) {
-				format_dev_t(buffer, p->path.dev->bdev->bd_dev);
 				spin_lock_irqsave(&p->queued_lock, flags);
-				DMEMIT("%s %s %u ", buffer,
+				DMEMIT("%s %s %u ", p->path.dev->name,
 				       p->path.is_active ? "A" : "F",
 				       p->fail_count);
 				if (pg->ps.type->status)
@@ -1159,8 +1168,7 @@ static int multipath_status(struct dm_ta
 			DMEMIT("%u %u ", pg->nr_paths, pg->ps.type->table_args);
 
 			list_for_each_entry(p, &pg->pgpaths, list) {
-				format_dev_t(buffer, p->path.dev->bdev->bd_dev);
-				DMEMIT("%s ", buffer);
+				DMEMIT("%s ", p->path.dev->name);
 				if (pg->ps.type->status)
 					sz += pg->ps.type->status(&pg->ps,
 					      &p->path, type, result + sz,
Index: linux-2.6.5/drivers/md/dm-flakey.c
===================================================================
--- linux-2.6.5.orig/drivers/md/dm-flakey.c	2005-01-19 14:41:17.000000000 +0100
+++ linux-2.6.5/drivers/md/dm-flakey.c	2005-01-21 15:22:57.853370404 +0100
@@ -107,7 +107,6 @@ static int flakey_status(struct dm_targe
 			 char *result, unsigned int maxlen)
 {
 	struct flakey *f = (struct flakey *) ti->private;
-	char buffer[32];
 
 	switch (type) {
 	case STATUSTYPE_INFO:
@@ -115,8 +114,7 @@ static int flakey_status(struct dm_targe
 		break;
 
 	case STATUSTYPE_TABLE:
-		format_dev_t(buffer, f->dev->bdev->bd_dev);
-		snprintf(result, maxlen, "%s " SECTOR_FORMAT, buffer, f->start);
+		snprintf(result, maxlen, "%s " SECTOR_FORMAT, f->dev->name, f->start);
 		break;
 	}
 	return 0;
Index: linux-2.6.5/drivers/md/dm-table.c
===================================================================
--- linux-2.6.5.orig/drivers/md/dm-table.c	2005-01-19 14:41:17.000000000 +0100
+++ linux-2.6.5/drivers/md/dm-table.c	2005-01-21 15:32:43.015672004 +0100
@@ -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);
 
Index: linux-2.6.5/drivers/md/dm-bbr.c
===================================================================
--- linux-2.6.5.orig/drivers/md/dm-bbr.c	2005-01-19 14:41:01.000000000 +0100
+++ linux-2.6.5/drivers/md/dm-bbr.c	2005-01-21 15:22:05.745091987 +0100
@@ -334,9 +334,8 @@ static u32 bbr_table_to_remap_list(struc
 		}
 	}
 	if (in_use_blks) {
-		char b[32];
 		DMWARN("dm-bbr: There are %u BBR entries for device %s",
-		       in_use_blks, format_dev_t(b, bbr_id->dev->bdev->bd_dev));
+		       in_use_blks, bbr_id->dev->name);
 	}
 
 	return in_use_blks;
@@ -480,7 +479,6 @@ static int bbr_io_remap_error(struct bbr
 	unsigned long index;
 	unsigned long error;
 	u64 lsn, new_lsn;
-	char b[32];
 	int rc;
 
 	job.bdev = bbr_id->dev->bdev;
@@ -503,7 +501,7 @@ static int bbr_io_remap_error(struct bbr
 
 			/* Write the data to its new location. */
 			DMWARN("dm-bbr: device %s: Trying to remap bad sector "PFU64" to sector "PFU64,
-			       format_dev_t(b, bbr_id->dev->bdev->bd_dev),
+			       bbr_id->dev->name,
 			       starting_lsn + lsn, new_lsn);
 			job.sector = new_lsn;
 			rc = dm_io_sync(1, &job, rw, &pl, offset, &error);
@@ -512,7 +510,7 @@ static int bbr_io_remap_error(struct bbr
 				 * Try the next one.
 				 */
 				DMERR("dm-bbr: device %s: replacement sector "PFU64" is bad. Skipping.",
-				      format_dev_t(b, bbr_id->dev->bdev->bd_dev), new_lsn);
+				      bbr_id->dev->name, new_lsn);
 				atomic_inc(&bbr_id->in_use_replacement_blks);
 				continue;
 			}
@@ -549,7 +547,7 @@ static int bbr_io_remap_error(struct bbr
 			if (rc) {
 				/* Error writing one of the tables to disk. */
 				DMERR("dm-bbr: device %s: error updating BBR tables on disk.",
-				      format_dev_t(b, bbr_id->dev->bdev->bd_dev));
+				      bbr_id->dev->name);
 				return rc;
 			}
 
@@ -558,7 +556,7 @@ static int bbr_io_remap_error(struct bbr
 						    &bbr_table->entries[index]);
 			if (rc) {
 				DMERR("dm-bbr: device %s: error adding new entry to remap tree.",
-				      format_dev_t(b, bbr_id->dev->bdev->bd_dev));
+				      bbr_id->dev->name);
 				return rc;
 			}
 
@@ -760,14 +758,13 @@ static int bbr_endio(struct dm_target *t
 
 	if (error && bbr_io) {
 		unsigned long flags;
-		char b[32];
 
 		dm_bio_restore(bbr_io, bio);
 		map_context->ptr = NULL;
 
 		DMERR("dm-bbr: device %s: I/O failure on sector %lu. "
 		      "Scheduling for retry.",
-		      format_dev_t(b, bbr_id->dev->bdev->bd_dev),
+		      bbr_id->dev->name,
 		      (unsigned long)bio->bi_sector);
 
 		spin_lock_irqsave(&bbr_id->remap_ios_lock, flags);
@@ -893,7 +890,6 @@ static int bbr_status(struct dm_target *
 		      char *result, unsigned int maxlen)
 {
 	struct bbr_private *bbr_id = ti->private;
-	char b[BDEVNAME_SIZE];
 
 	switch (type) {
 	case STATUSTYPE_INFO:
@@ -902,7 +898,7 @@ static int bbr_status(struct dm_target *
 
 	case STATUSTYPE_TABLE:
 		snprintf(result, maxlen, "%s "PFU64" "PFU64" "PFU64" "PFU64" "PFU64" "PFU64" %u",
-			 format_dev_t(b, bbr_id->dev->bdev->bd_dev),
+			 bbr_id->dev->name,
 			 bbr_id->offset, bbr_id->lba_table1, bbr_id->lba_table2,
 			 bbr_id->nr_sects_bbr_table,
 			 bbr_id->start_replacement_sect,
Index: linux-2.6.5/drivers/md/dm-crypt.c
===================================================================
--- linux-2.6.5.orig/drivers/md/dm-crypt.c	2005-01-19 14:41:00.000000000 +0100
+++ linux-2.6.5/drivers/md/dm-crypt.c	2005-01-21 15:22:39.760051508 +0100
@@ -690,7 +690,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 *mode = NULL;
 	int offset;
@@ -729,10 +728,9 @@ static int crypt_status(struct dm_target
 			result[offset++] = '-';
 		}
 
-		format_dev_t(buffer, cc->dev->bdev->bd_dev);
 		snprintf(result + offset, maxlen - offset, " " SECTOR_FORMAT
 		         " %s " SECTOR_FORMAT, cc->iv_offset,
-		         buffer, cc->start);
+		         cc->dev->name, cc->start);
 		break;
 	}
 	return 0;
Index: linux-2.6.5/drivers/md/dm-snap.c
===================================================================
--- linux-2.6.5.orig/drivers/md/dm-snap.c	2005-01-19 14:41:17.000000000 +0100
+++ linux-2.6.5/drivers/md/dm-snap.c	2005-01-21 15:27:36.544076418 +0100
@@ -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;
 	}
 
Index: linux-2.6.5/drivers/md/dm-linear.c
===================================================================
--- linux-2.6.5.orig/drivers/md/dm-linear.c	2004-04-04 05:37:23.000000000 +0200
+++ linux-2.6.5/drivers/md/dm-linear.c	2005-01-21 15:23:19.779121435 +0100
@@ -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,7 @@ 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;
Index: linux-2.6.5/drivers/md/dm.h
===================================================================
--- linux-2.6.5.orig/drivers/md/dm.h	2005-01-19 14:41:17.000000000 +0100
+++ linux-2.6.5/drivers/md/dm.h	2005-01-21 15:29:51.041149663 +0100
@@ -44,6 +44,7 @@ struct dm_dev {
 	atomic_t count;
 	int mode;
 	struct block_device *bdev;
+	char name[BDEVNAME_SIZE];
 };
 
 struct dm_table;
Index: linux-2.6.5/drivers/md/dm-raid1.c
===================================================================
--- linux-2.6.5.orig/drivers/md/dm-raid1.c	2005-01-19 14:41:17.000000000 +0100
+++ linux-2.6.5/drivers/md/dm-raid1.c	2005-01-21 15:26:04.544707487 +0100
@@ -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;
 
@@ -1192,8 +1191,7 @@ static int mirror_status(struct dm_targe
 	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);
+			DMEMIT("%s ", ms->mirror[m].dev->name);
 		}
 
 		DMEMIT(SECTOR_FORMAT "/" SECTOR_FORMAT,
@@ -1204,9 +1202,8 @@ 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);
 			DMEMIT("%s " SECTOR_FORMAT " ",
-			       buffer, ms->mirror[m].offset);
+			       ms->mirror[m].dev->name, ms->mirror[m].offset);
 		}
 	}
 
Index: linux-2.6.5/drivers/md/dm-stripe.c
===================================================================
--- linux-2.6.5.orig/drivers/md/dm-stripe.c	2005-01-19 14:41:17.000000000 +0100
+++ linux-2.6.5/drivers/md/dm-stripe.c	2005-01-21 15:28:05.342809573 +0100
@@ -189,7 +189,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:
@@ -199,8 +198,7 @@ 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,
+			DMEMIT(" %s " SECTOR_FORMAT, sc->stripe[i].dev->name,
 			       sc->stripe[i].physical_start);
 		}
 		break;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]