diff options
author | Raghavendra Bhat <raghavendra@redhat.com> | 2012-11-14 19:25:14 +0530 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2013-01-17 21:15:13 -0800 |
commit | fd8b19af1713f2800af743d851706b96ca15d9ec (patch) | |
tree | c64194b286718ab320b328b2375901a34eb03b6e /cli | |
parent | 165044cee54ceaa8f0adec6d571e9ad54f4f8e5d (diff) |
debug/trace: save the recent fops received in the event-history
* Make use of event-history in debug/trace xlator to dump the recent fops,
when statedump is given. trace xlator saves the fop it received along
with the time in the event-history and upon statedump signal, dumps its
history. The size of the event-history can be given as a xlator option.
* Make changes in trace to take logging into log-file or logging to
history as an option. By default both are off.
Change-Id: I12baee5805c6efb55735cead4e2093fb94d7a6a0
BUG: 797171
Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>
Reviewed-on: http://review.gluster.org/4088
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'cli')
-rw-r--r-- | cli/src/cli-rpc-ops.c | 70 | ||||
-rw-r--r-- | cli/src/cli.h | 3 |
2 files changed, 70 insertions, 3 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index c5a0fffb8a6..20c60bf081e 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -1454,6 +1454,51 @@ out: return ret; } +char * +is_server_debug_xlator (void *myframe) +{ + call_frame_t *frame = NULL; + cli_local_t *local = NULL; + char **words = NULL; + char *key = NULL; + char *value = NULL; + char *debug_xlator = NULL; + + frame = myframe; + local = frame->local; + words = (char **)local->words; + + while (*words != NULL) { + if (strstr (*words, "trace") == NULL && + strstr (*words, "error-gen") == NULL) { + words++; + continue; + } + + key = *words; + words++; + value = *words; + if (strstr (value, "client")) { + words++; + continue; + } else { + if (!(strstr (value, "posix") || strstr (value, "acl") + || strstr (value, "locks") || + strstr (value, "io-threads") || + strstr (value, "marker") || + strstr (value, "index"))) { + words++; + continue; + } else { + debug_xlator = gf_strdup (key); + break; + } + } + } + + return debug_xlator; +} + int gf_cli_set_volume_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) @@ -1463,6 +1508,8 @@ gf_cli_set_volume_cbk (struct rpc_req *req, struct iovec *iov, dict_t *dict = NULL; char *help_str = NULL; char msg[1024] = {0,}; + char *debug_xlator = _gf_false; + char tmp_str[512] = {0,}; if (-1 == req->rpc_status) { goto out; @@ -1485,9 +1532,21 @@ gf_cli_set_volume_cbk (struct rpc_req *req, struct iovec *iov, ret = dict_unserialize (rsp.dict.dict_val, rsp.dict.dict_len, &dict); + /* For brick processes graph change does not happen on the fly. + * The proces has to be restarted. So this is a check from the + * volume set option such that if debug xlators such as trace/errorgen + * are provided in the set command, warn the user. + */ + debug_xlator = is_server_debug_xlator (myframe); + if (dict_get_str (dict, "help-str", &help_str) && !msg[0]) snprintf (msg, sizeof (msg), "Set volume %s", (rsp.op_ret) ? "unsuccessful": "successful"); + if (rsp.op_ret == 0 && debug_xlator) { + snprintf (tmp_str, sizeof (tmp_str), "\n%s translator has been " + "added to the server volume file. Please restart the" + " volume for enabling the translator", debug_xlator); + } if ((global_state->mode & GLUSTER_MODE_XML) && (help_str == NULL)) { ret = cli_xml_output_str ("volSet", msg, rsp.op_ret, @@ -1502,10 +1561,14 @@ gf_cli_set_volume_cbk (struct rpc_req *req, struct iovec *iov, cli_err ("volume set: failed: %s", rsp.op_errstr); if (!rsp.op_ret) { - if (help_str == NULL) - cli_out ("volume set: success"); - else + if (help_str == NULL) { + if (debug_xlator == NULL) + cli_out ("volume set: success"); + else + cli_out ("volume set: success%s", tmp_str); + }else { cli_out ("%s", help_str); + } } else { cli_err ("volume set: failed"); } @@ -1515,6 +1578,7 @@ gf_cli_set_volume_cbk (struct rpc_req *req, struct iovec *iov, out: if (dict) dict_unref (dict); + GF_FREE (debug_xlator); cli_cmd_broadcast_response (ret); return ret; } diff --git a/cli/src/cli.h b/cli/src/cli.h index ab401043d98..62216397ff7 100644 --- a/cli/src/cli.h +++ b/cli/src/cli.h @@ -378,4 +378,7 @@ cli_xml_output_generic_volume (char *op, dict_t *dict, int op_ret, int op_errno, int cli_xml_output_vol_gsync (dict_t *dict, int op_ret, int op_errno, char *op_errstr); + +char * +is_server_debug_xlator (void *myframe); #endif /* __CLI_H__ */ |