diff options
author | Poornima G <pgurusid@redhat.com> | 2016-01-22 11:44:21 -0500 |
---|---|---|
committer | Kaleb KEITHLEY <kkeithle@redhat.com> | 2017-01-23 19:13:15 -0500 |
commit | f2e7b6800b812e8bbc9bdbcea4c400a1784e31dc (patch) | |
tree | 2809f95a28204a4769e4dac07db8fe7b79a980f9 /cli/src | |
parent | 4008a48080b9910b9948c35892e762e91198d134 (diff) |
glusterd: add a cli command to trigger a statedump on a client
With this, we will be able to trigger statedumps on remote Gluster
clients, mainly targetted for applications using libgfapi.
Design:
SIGUSR signal is the most comman way of taking a statedump in Gluster.
But it cannot be used for libgfapi based processes, as the process
loading the library might have already consumed SIGUSR signal. Hence
going by the command way.
One has to issue a Gluster command to initiate a statedump on the
libgfapi based client. The command takes hostname and PID as an
argument. All the glusterds in the cluster, check if they are connected
to the specified hostname, and send an RPC request to all the connected
clients from that hostname (via the mgmt connection).
URL: http://review.gluster.org/16357
Change-Id: Icbe4d2f026b32a2c7d5535e1bfb2cdaaff042e91
BUG: 1169302
Signed-off-by: Poornima G <pgurusid@redhat.com>
[ndevos: minor fixes and split patch in smaller pieces]
Reviewed-on: https://review.gluster.org/9228
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Tested-by: Niels de Vos <ndevos@redhat.com>
Smoke: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Samikshan Bairagya <samikshan@gmail.com>
Diffstat (limited to 'cli/src')
-rw-r--r-- | cli/src/cli-cmd-parser.c | 46 | ||||
-rw-r--r-- | cli/src/cli-cmd-volume.c | 4 |
2 files changed, 38 insertions, 12 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 3cc6ca97d37..d93af0e79d3 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -3541,19 +3541,44 @@ cli_cmd_volume_statedump_options_parse (const char **words, int wordcount, dict_t *dict = NULL; int option_cnt = 0; char *option = NULL; - char option_str[100] = {0,}; - - for (i = 3; i < wordcount; i++, option_cnt++) { - if (!cli_cmd_validate_dumpoption (words[i], &option)) { + char option_str[_POSIX_HOST_NAME_MAX + 100] = {0,}; + char *tmp = NULL; + char *ip_addr = NULL; + char *pid = NULL; + + if ((wordcount >= 5) && ((strcmp (words[3], "client")) == 0)) { + tmp = gf_strdup(words[4]); + if (!tmp) { + ret = -1; + goto out; + } + ip_addr = strtok(tmp, ":"); + pid = strtok(NULL, ":"); + if (valid_internet_address (ip_addr, _gf_true) + && pid && gf_valid_pid (pid, strlen(pid))) { + strncat (option_str, words[3], strlen (words[3])); + strncat (option_str, " ", 1); + strncat (option_str, ip_addr, strlen (ip_addr)); + strncat (option_str, " ", 1); + strncat (option_str, pid, strlen (pid)); + option_cnt = 3; + } else { + ret = -1; + goto out; + } + } else { + for (i = 3; i < wordcount; i++, option_cnt++) { + if (!cli_cmd_validate_dumpoption (words[i], &option)) { + ret = -1; + goto out; + } + strncat (option_str, option, strlen (option)); + strncat (option_str, " ", 1); + } + if ((strstr (option_str, "nfs")) && strstr (option_str, "quotad")) { ret = -1; goto out; } - strncat (option_str, option, strlen (option)); - strncat (option_str, " ", 1); - } - if((strstr (option_str, "nfs")) && strstr (option_str, "quotad")) { - ret = -1; - goto out; } dict = dict_new (); @@ -3570,6 +3595,7 @@ cli_cmd_volume_statedump_options_parse (const char **words, int wordcount, *options = dict; out: + GF_FREE (tmp); if (ret && dict) dict_unref (dict); if (ret) diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index dbf1e3e2326..5f07a057d47 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -3285,8 +3285,8 @@ struct cli_cmd volume_cmds[] = { cli_cmd_volume_heal_cbk, "self-heal commands on volume specified by <VOLNAME>"}, - {"volume statedump <VOLNAME> [nfs|quotad] [all|mem|iobuf|callpool|priv|fd|" - "inode|history]...", + {"volume statedump <VOLNAME> [[nfs|quotad] [all|mem|iobuf|callpool|" + "priv|fd|inode|history]... | [client <hostname:process-id>]]", cli_cmd_volume_statedump_cbk, "perform statedump on bricks"}, |