[sheepdog] [PATCH] add INFO level operation logging on each node.
MORITA Kazutaka
morita.kazutaka at gmail.com
Thu Jan 23 07:43:12 CET 2014
At Fri, 10 Jan 2014 15:05:21 +0900,
Yoshinori Matsuo wrote:
>
> 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;
> +
I think this variable name should explain why the operation needs to
be logged. How about something like "bool is_admin_op"?
> 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);
This sd_debug() should be called only when is_logging_op() is false.
> + 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);
> + }
How about adding sd_debug() when is_logging_op() is false?
Thanks,
Kazutaka
More information about the sheepdog
mailing list