[sheepdog] [PATCH] add INFO level operation logging on each node.

Yoshinori Matsuo matsuo.yoshinori at lab.ntt.co.jp
Fri Jan 10 07:05:21 CET 2014


Administrator couldn't track operation on each node without this function.
This function logs only administrative operation at rx_main and tx_main.
Operations that is not related to administrative operation are not
logged in this function. such as read/write etc.

Signed-off-by: Yoshinori Matsuo <matsuo.yoshinori at lab.ntt.co.jp>
---
 sheep/ops.c        |   19 +++++++++++++++++++
 sheep/request.c    |   17 +++++++++++++++++
 sheep/sheep_priv.h |    1 +
 3 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/sheep/ops.c b/sheep/ops.c
index 1e9bc1e..df2b95f 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -26,6 +26,9 @@ struct sd_op_template {
 	/* process request even when cluster is not working */
 	bool force;
 
+	/* log operations at info level */
+	bool logging;
+
 	/*
 	 * process_work() will be called in a worker thread, and process_main()
 	 * will be called in the main thread.
@@ -1007,6 +1010,7 @@ static struct sd_op_template sd_ops[] = {
 	[SD_OP_NEW_VDI] = {
 		.name = "NEW_VDI",
 		.type = SD_OP_TYPE_CLUSTER,
+		.logging = true,
 		.process_work = cluster_new_vdi,
 		.process_main = post_cluster_new_vdi,
 	},
@@ -1014,6 +1018,7 @@ static struct sd_op_template sd_ops[] = {
 	[SD_OP_DEL_VDI] = {
 		.name = "DEL_VDI",
 		.type = SD_OP_TYPE_CLUSTER,
+		.logging = true,
 		.process_work = cluster_del_vdi,
 		.process_main = post_cluster_del_vdi,
 	},
@@ -1022,6 +1027,7 @@ static struct sd_op_template sd_ops[] = {
 		.name = "MAKE_FS",
 		.type = SD_OP_TYPE_CLUSTER,
 		.force = true,
+		.logging = true,
 		.process_main = cluster_make_fs,
 	},
 
@@ -1029,6 +1035,7 @@ static struct sd_op_template sd_ops[] = {
 		.name = "SHUTDOWN",
 		.type = SD_OP_TYPE_CLUSTER,
 		.force = true,
+		.logging = true,
 		.process_main = cluster_shutdown,
 	},
 
@@ -1042,6 +1049,7 @@ static struct sd_op_template sd_ops[] = {
 		.name = "FORCE_RECOVER",
 		.type = SD_OP_TYPE_CLUSTER,
 		.force = true,
+		.logging = true,
 		.process_work = cluster_force_recover_work,
 		.process_main = cluster_force_recover_main,
 	},
@@ -1095,18 +1103,21 @@ static struct sd_op_template sd_ops[] = {
 	[SD_OP_REWEIGHT] = {
 		.name = "REWEIGHT",
 		.type = SD_OP_TYPE_CLUSTER,
+		.logging = true,
 		.process_main = cluster_reweight,
 	},
 
 	[SD_OP_ENABLE_RECOVER] = {
 		.name = "ENABLE_RECOVER",
 		.type = SD_OP_TYPE_CLUSTER,
+		.logging = true,
 		.process_main = cluster_enable_recover,
 	},
 
 	[SD_OP_DISABLE_RECOVER] = {
 		.name = "DISABLE_RECOVER",
 		.type = SD_OP_TYPE_CLUSTER,
+		.logging = true,
 		.process_main = cluster_disable_recover,
 	},
 
@@ -1226,6 +1237,7 @@ static struct sd_op_template sd_ops[] = {
 		.name = "KILL_NODE",
 		.type = SD_OP_TYPE_LOCAL,
 		.force = true,
+		.logging = true,
 		.process_main = local_kill_node,
 	},
 
@@ -1238,12 +1250,14 @@ static struct sd_op_template sd_ops[] = {
 	[SD_OP_MD_PLUG] = {
 		.name = "MD_PLUG_DISKS",
 		.type = SD_OP_TYPE_LOCAL,
+		.logging = true,
 		.process_main = local_md_plug,
 	},
 
 	[SD_OP_MD_UNPLUG] = {
 		.name = "MD_UNPLUG_DISKS",
 		.type = SD_OP_TYPE_LOCAL,
+		.logging = true,
 		.process_main = local_md_unplug,
 	},
 
@@ -1374,6 +1388,11 @@ bool is_force_op(const struct sd_op_template *op)
 	return !!op->force;
 }
 
+bool is_logging_op(const struct sd_op_template *op)
+{
+	return !!op->logging;
+}
+
 bool has_process_work(const struct sd_op_template *op)
 {
 	return !!op->process_work;
diff --git a/sheep/request.c b/sheep/request.c
index 9f3f110..15c6cbf 100644
--- a/sheep/request.c
+++ b/sheep/request.c
@@ -762,6 +762,14 @@ static void rx_main(struct work *work)
 	conn_rx_on(&ci->conn);
 
 	sd_debug("%d, %s:%d", ci->conn.fd, ci->conn.ipstr, ci->conn.port);
+	if (is_logging_op(get_sd_op(req->rq.opcode))) {
+		sd_info("req=%p, fd=%d, client=%s:%d, op=%s, data=%s",
+			req,
+			ci->conn.fd,
+			ci->conn.ipstr, ci->conn.port,
+			op_name(get_sd_op(req->rq.opcode)),
+			(char *)req->data);
+	}
 	queue_request(req);
 }
 
@@ -800,6 +808,15 @@ static void tx_main(struct work *work)
 
 	refcount_dec(&ci->refcnt);
 
+	if (is_logging_op(ci->tx_req->op)) {
+		sd_info("req=%p, fd=%d, client=%s:%d, op=%s, result=%02X",
+			ci->tx_req,
+			ci->conn.fd,
+			ci->conn.ipstr,
+			ci->conn.port,
+			op_name(ci->tx_req->op),
+			ci->tx_req->rp.result);
+	}
 	free_request(ci->tx_req);
 	ci->tx_req = NULL;
 
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index c0a138c..f0e9b9c 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -412,6 +412,7 @@ bool is_local_op(const struct sd_op_template *op);
 bool is_peer_op(const struct sd_op_template *op);
 bool is_gateway_op(const struct sd_op_template *op);
 bool is_force_op(const struct sd_op_template *op);
+bool is_logging_op(const struct sd_op_template *op);
 bool has_process_work(const struct sd_op_template *op);
 bool has_process_main(const struct sd_op_template *op);
 void do_process_work(struct work *work);
-- 
1.7.2.5




More information about the sheepdog mailing list