Printing the commands as plain text instead of an opcode makes debugging
a lot easier.

Signed-off-by: Christoph Hellwig <hch@lst.de>

---
 sheep/group.c      |    2 +-
 sheep/ops.c        |   38 ++++++++++++++++++++++++++++++++++++++
 sheep/sdnet.c      |   10 +++++-----
 sheep/sheep_priv.h |    1 +
 4 files changed, 45 insertions(+), 6 deletions(-)

Index: sheepdog/sheep/ops.c
===================================================================
--- sheepdog.orig/sheep/ops.c	2012-07-13 09:24:16.423304255 +0200
+++ sheepdog/sheep/ops.c	2012-07-13 11:29:37.973259317 +0200
@@ -35,6 +35,7 @@ enum sd_op_type {
 };
 
 struct sd_op_template {
+	const char *name;
 	enum sd_op_type type;
 
 	/* process request even when cluster is not working */
@@ -759,65 +760,77 @@ static struct sd_op_template sd_ops[] =
 
 	/* cluster operations */
 	[SD_OP_NEW_VDI] = {
+		.name = "NEW_VDI",
 		.type = SD_OP_TYPE_CLUSTER,
 		.process_work = cluster_new_vdi,
 		.process_main = post_cluster_new_vdi,
 	},
 
 	[SD_OP_DEL_VDI] = {
+		.name = "DEL_VDI",
 		.type = SD_OP_TYPE_CLUSTER,
 		.process_work = cluster_del_vdi,
 	},
 
 	[SD_OP_GET_VDI_INFO] = {
+		.name = "GET_VDI_INFO",
 		.type = SD_OP_TYPE_CLUSTER,
 		.process_work = cluster_get_vdi_info,
 	},
 
 	[SD_OP_LOCK_VDI] = {
+		.name = "LOCK_VDI",
 		.type = SD_OP_TYPE_CLUSTER,
 		.process_work = cluster_get_vdi_info,
 	},
 
 	[SD_OP_MAKE_FS] = {
+		.name = "MAKE_FS",
 		.type = SD_OP_TYPE_CLUSTER,
 		.force = 1,
 		.process_main = cluster_make_fs,
 	},
 
 	[SD_OP_SHUTDOWN] = {
+		.name = "SHUTDOWN",
 		.type = SD_OP_TYPE_CLUSTER,
 		.process_main = cluster_shutdown,
 	},
 
 	[SD_OP_GET_VDI_ATTR] = {
+		.name = "GET_VDI_ATTR",
 		.type = SD_OP_TYPE_CLUSTER,
 		.process_work = cluster_get_vdi_attr,
 	},
 
 	[SD_OP_RELEASE_VDI] = {
+		.name = "RELEASE_VDI",
 		.type = SD_OP_TYPE_CLUSTER,
 	},
 
 	[SD_OP_RECOVER] = {
+		.name = "RECOVER",
 		.type = SD_OP_TYPE_CLUSTER,
 		.force = 1,
 		.process_main = cluster_manual_recover,
 	},
 
 	[SD_OP_SNAPSHOT] = {
+		.name = "SNAPSHOT",
 		.type = SD_OP_TYPE_CLUSTER,
 		.force = 1,
 		.process_main = cluster_snapshot,
 	},
 
 	[SD_OP_RESTORE] = {
+		.name = "RESTORE",
 		.type = SD_OP_TYPE_CLUSTER,
 		.force = 1,
 		.process_main = cluster_restore,
 	},
 
 	[SD_OP_CLEANUP] = {
+		.name = "CLEANUP",
 		.type = SD_OP_TYPE_CLUSTER,
 		.force = 1,
 		.process_main = cluster_cleanup,
@@ -825,34 +838,40 @@ static struct sd_op_template sd_ops[] =
 
 	/* local operations */
 	[SD_OP_GET_STORE_LIST] = {
+		.name = "GET_STORE_LIST",
 		.type = SD_OP_TYPE_LOCAL,
 		.force = 1,
 		.process_work = local_get_store_list,
 	},
 
 	[SD_OP_READ_VDIS] = {
+		.name = "READ_VDIS",
 		.type = SD_OP_TYPE_LOCAL,
 		.force = 1,
 		.process_main = local_read_vdis,
 	},
 
 	[SD_OP_GET_NODE_LIST] = {
+		.name = "GET_NODE_LIST",
 		.type = SD_OP_TYPE_LOCAL,
 		.force = 1,
 		.process_main = local_get_node_list,
 	},
 
 	[SD_OP_STAT_SHEEP] = {
+		.name = "STAT_SHEEP",
 		.type = SD_OP_TYPE_LOCAL,
 		.process_work = local_stat_sheep,
 	},
 
 	[SD_OP_STAT_RECOVERY] = {
+		.name = "STAT_RECOVERY",
 		.type = SD_OP_TYPE_LOCAL,
 		.process_main = local_stat_recovery,
 	},
 
 	[SD_OP_STAT_CLUSTER] = {
+		.name = "STAT_CLUSTER",
 		.type = SD_OP_TYPE_LOCAL,
 		.force = 1,
 		.process_work = local_stat_cluster,
@@ -864,33 +883,39 @@ static struct sd_op_template sd_ops[] =
 	},
 
 	[SD_OP_GET_EPOCH] = {
+		.name = "GET_OBJ_LIST",
 		.type = SD_OP_TYPE_LOCAL,
 		.process_work = local_get_epoch,
 	},
 
 	[SD_OP_GET_SNAP_FILE] = {
+		.name = "GET_SNAP_FILE",
 		.type = SD_OP_TYPE_LOCAL,
 		.force = 1,
 		.process_work = local_get_snap_file,
 	},
 
 	[SD_OP_FLUSH_VDI] = {
+		.name = "FLUSH_VDI",
 		.type = SD_OP_TYPE_LOCAL,
 		.process_work = local_flush_vdi,
 	},
 
 	[SD_OP_FLUSH_DEL_CACHE] = {
+		.name = "DEL_CACHE",
 		.type = SD_OP_TYPE_LOCAL,
 		.process_work = local_flush_and_del,
 	},
 
 	[SD_OP_TRACE] = {
+		.name = "TRACE",
 		.type = SD_OP_TYPE_LOCAL,
 		.force = 1,
 		.process_main = local_trace_ops,
 	},
 
 	[SD_OP_TRACE_CAT] = {
+		.name = "TRACE_CAT",
 		.type = SD_OP_TYPE_LOCAL,
 		.force = 1,
 		.process_main = local_trace_cat_ops,
@@ -898,42 +923,50 @@ static struct sd_op_template sd_ops[] =
 
 	/* gateway I/O operations */
 	[SD_OP_CREATE_AND_WRITE_OBJ] = {
+		.name = "CREATE_AND_WRITE_OBJ",
 		.type = SD_OP_TYPE_GATEWAY,
 		.process_work = gateway_create_and_write_obj,
 	},
 
 	[SD_OP_READ_OBJ] = {
+		.name = "READ_OBJ",
 		.type = SD_OP_TYPE_GATEWAY,
 		.process_work = gateway_read_obj,
 	},
 
 	[SD_OP_WRITE_OBJ] = {
+		.name = "WRITE_OBJ",
 		.type = SD_OP_TYPE_GATEWAY,
 		.process_work = gateway_write_obj,
 	},
 
 	[SD_OP_REMOVE_OBJ] = {
+		.name = "REMOVE_OBJ",
 		.type = SD_OP_TYPE_GATEWAY,
 		.process_work = gateway_remove_obj,
 	},
 
 	/* peer I/O operations */
 	[SD_OP_CREATE_AND_WRITE_PEER] = {
+		.name = "CREATE_AND_WRITE_PEER",
 		.type = SD_OP_TYPE_PEER,
 		.process_work = peer_create_and_write_obj,
 	},
 
 	[SD_OP_READ_PEER] = {
+		.name = "READ_PEER",
 		.type = SD_OP_TYPE_PEER,
 		.process_work = peer_read_obj,
 	},
 
 	[SD_OP_WRITE_PEER] = {
+		.name = "WRITE_PEER",
 		.type = SD_OP_TYPE_PEER,
 		.process_work = peer_write_obj,
 	},
 
 	[SD_OP_REMOVE_PEER] = {
+		.name = "REMOVE_PEER",
 		.type = SD_OP_TYPE_PEER,
 		.process_work = peer_remove_obj,
 	},
@@ -947,6 +980,11 @@ struct sd_op_template *get_sd_op(uint8_t
 	return sd_ops + opcode;
 }
 
+const char *op_name(struct sd_op_template *op)
+{
+	return op->name;
+}
+
 int is_cluster_op(struct sd_op_template *op)
 {
 	return op->type == SD_OP_TYPE_CLUSTER;
Index: sheepdog/sheep/sdnet.c
===================================================================
--- sheepdog.orig/sheep/sdnet.c	2012-07-13 09:24:16.423304255 +0200
+++ sheepdog/sheep/sdnet.c	2012-07-13 11:31:54.473258506 +0200
@@ -110,16 +110,16 @@ static void local_op_done(struct work *w
 static int check_request_epoch(struct request *req)
 {
 	if (before(req->rq.epoch, sys->epoch)) {
-		eprintf("old node version %u, %u, %x\n",
-			sys->epoch, req->rq.epoch, req->rq.opcode);
+		eprintf("old node version %u, %u (%s)\n",
+			sys->epoch, req->rq.epoch, op_name(req->op));
 		/* ask gateway to retry. */
 		req->rp.result = SD_RES_OLD_NODE_VER;
 		req->rp.epoch = sys->epoch;
 		put_request(req);
 		return -1;
 	} else if (after(req->rq.epoch, sys->epoch)) {
-		eprintf("new node version %u, %u, %x\n",
-			sys->epoch, req->rq.epoch, req->rq.opcode);
+		eprintf("new node version %u, %u (%s)\n",
+			sys->epoch, req->rq.epoch, op_name(req->op));
 
 		/* put on local wait queue, waiting for local epoch
 		   to be lifted */
@@ -320,7 +320,7 @@ static void queue_request(struct request
 		goto done;
 	}
 
-	dprintf("%x\n", hdr->opcode);
+	dprintf("%s\n", op_name(req->op));
 
 	switch (sys->status) {
 	case SD_STATUS_SHUTDOWN:
Index: sheepdog/sheep/sheep_priv.h
===================================================================
--- sheepdog.orig/sheep/sheep_priv.h	2012-07-13 09:24:16.423304255 +0200
+++ sheepdog/sheep/sheep_priv.h	2012-07-13 11:29:45.119925946 +0200
@@ -284,6 +284,7 @@ void put_request(struct request *req);
 /* Operations */
 
 struct sd_op_template *get_sd_op(uint8_t opcode);
+const char *op_name(struct sd_op_template *op);
 int is_cluster_op(struct sd_op_template *op);
 int is_local_op(struct sd_op_template *op);
 int is_peer_op(struct sd_op_template *op);
Index: sheepdog/sheep/group.c
===================================================================
--- sheepdog.orig/sheep/group.c	2012-07-13 11:33:04.303258089 +0200
+++ sheepdog/sheep/group.c	2012-07-13 11:34:11.339924363 +0200
@@ -335,7 +335,7 @@ bool sd_block_handler(struct sd_node *se
  */
 void queue_cluster_request(struct request *req)
 {
-	eprintf("%p %x\n", req, req->rq.opcode);
+	eprintf("%s (%p)\n", op_name(req->op), req);
 
 	if (has_process_work(req->op)) {
 		list_add_tail(&req->pending_list, &sys->pending_list);


