[Sheepdog] [PATCH] sheepdog: add the contents of dprintf

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Mon May 10 08:55:42 CEST 2010


Some eprintf calls are also replaced to dprintf calls.
Define `DEBUG_SDOG' when you want to print debug outputs.

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 block/sheepdog.c |   28 ++++++++++++++++++----------
 1 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/block/sheepdog.c b/block/sheepdog.c
index 89f1ccb..6c0dfe2 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -211,7 +211,14 @@ do {									\
 } while (0)
 
 #undef dprintf
+#ifdef DEBUG_SDOG
+#define dprintf(fmt, args...)						\
+do {									\
+	fprintf(stdout, "%s %d: " fmt, __func__, __LINE__, ##args);	\
+} while (0)
+#else
 #define dprintf(fmt, args...)
+#endif
 
 #define min_t(type, x, y) ({			\
 	type __min1 = (x);			\
@@ -963,7 +970,7 @@ static int sd_open(BlockDriverState *bs, const char *filename, int flags)
 		goto out;
 
 	if (snapid)
-		eprintf("%" PRIx32 " non current inode was open.\n", vid);
+		dprintf("%" PRIx32 " non current inode was open.\n", vid);
 	else
 		s->is_current = 1;
 
@@ -1104,7 +1111,7 @@ static int sd_claim(BlockDriverState *bs)
 	unsigned int wlen, rlen = 0;
 	char buf[SD_MAX_VDI_LEN];
 
-	eprintf("%s\n", s->name);
+	dprintf("%s\n", s->name);
 
 	fd = connect_to_sdog(s->addr);
 	if (fd < 0)
@@ -1146,7 +1153,7 @@ static void sd_release(BlockDriverState *bs)
 	unsigned int wlen, rlen = 0;
 	int fd, ret;
 
-	eprintf("%s\n", s->name);
+	dprintf("%s\n", s->name);
 
 	fd = connect_to_sdog(s->addr);
 	if (fd < 0)
@@ -1218,7 +1225,7 @@ static int sd_create_branch(struct bdrv_sd_state *s)
 	uint32_t vid;
 	char *buf;
 
-	eprintf("%" PRIx32 " is not current.\n", s->inode.vdi_id);
+	dprintf("%" PRIx32 " is not current.\n", s->inode.vdi_id);
 
 	buf = qemu_malloc(SD_INODE_SIZE);
 	if (!buf)
@@ -1229,7 +1236,7 @@ static int sd_create_branch(struct bdrv_sd_state *s)
 	if (ret)
 		goto out;
 
-	eprintf("%" PRIx32 " is created.\n", vid);
+	dprintf("%" PRIx32 " is created.\n", vid);
 
 	fd = connect_to_sdog(s->addr);
 	if (fd < 0) {
@@ -1249,7 +1256,7 @@ static int sd_create_branch(struct bdrv_sd_state *s)
 
 	s->is_current = 1;
 	ret = 0;
-	eprintf("%" PRIx32 " was newly created.\n", s->inode.vdi_id);
+	dprintf("%" PRIx32 " was newly created.\n", s->inode.vdi_id);
 
 out:
 	qemu_free(buf);
@@ -1302,9 +1309,10 @@ static void sd_readv_writev_bh_cb(void *p)
 		}
 
 		if (create) {
-			dprintf("update ino (%" PRIu64") %"
+			dprintf("update ino (%" PRIu32") %"
 				PRIu64 " %" PRIu64 " %" PRIu64 "\n",
-				inode->oid, oid, to_data_oid(inode->oid, idx), idx);
+				inode->vdi_id, oid,
+				vid_to_data_oid(inode->data_vdi_id[idx], idx), idx);
 			oid = vid_to_data_oid(inode->vdi_id, idx);
 			dprintf("new oid %lx\n", oid);
 		}
@@ -1401,7 +1409,7 @@ static int sd_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
 
 	sd_release(bs);
 
-	eprintf("sn_info: name %s id_str %s s: name %s vm_state_size %d "
+	dprintf("sn_info: name %s id_str %s s: name %s vm_state_size %d "
 		"is_current %d\n", sn_info->name, sn_info->id_str,
 		s->name, sn_info->vm_state_size, s->is_current);
 
@@ -1462,7 +1470,7 @@ static int sd_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
 	}
 
 	memcpy(&s->inode, inode, datalen);
-	eprintf("s->inode: name %s snap_id %x oid %x\n",
+	dprintf("s->inode: name %s snap_id %x oid %x\n",
 		s->inode.name, s->inode.snap_id, s->inode.vdi_id);
 
 cleanup:
-- 
1.5.6.5




More information about the sheepdog mailing list