summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDawit Alemu <dalemu@redhat.com>2013-12-30 22:59:39 -0500
committerVijay Bellur <vbellur@redhat.com>2014-01-24 02:05:35 -0800
commit48b8186bdc2f5e45b58aadf849b2bd60c9a77330 (patch)
treeb6c3c49cb40bf14572da45b346a54ab175739859
parentbb63256b7ea1f186bbe3fae9040a6c191c9d6544 (diff)
cli: Add options to the CLI that let the user control the reset of
stats "volume profile info" automatically clears incremental stats. There isn't a command to: - fetch stats without clearing incremental stats and - clear cumulative and incremental stats This change introduces two arguments (i.e. peek and clear). 'clear' will wipe both incremental and cumulative stats. 'peek' fetches stats without wiping incremental stats. 'volume profile info peek' - fetches incremental and cumulative stats without wiping incremental stats 'volume profile info incremental peek' - fetches incremental stats without wiping incremental stats 'volume profile info clear' - clears both incremental and cumultiave stats Change-Id: I91834515ad672eca5f882809941147d7d997c4c9 BUG: 1047416 Signed-off-by: Dawit Alemu <dalemu@redhat.com> Reviewed-on: http://review.gluster.org/6620 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Kaushal M <kaushal@redhat.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r--cli/src/cli-cmd-parser.c37
-rw-r--r--cli/src/cli-cmd-volume.c2
-rw-r--r--cli/src/cli-rpc-ops.c39
-rw-r--r--cli/src/cli-xml-output.c46
-rw-r--r--rpc/xdr/src/cli1-xdr.c11
-rw-r--r--rpc/xdr/src/cli1-xdr.h15
-rw-r--r--rpc/xdr/src/cli1-xdr.x8
-rw-r--r--tests/bugs/bug-1030580.t8
-rw-r--r--tests/bugs/bug-1047416.t66
-rw-r--r--tests/volume.rc23
-rw-r--r--xlators/debug/io-stats/src/io-stats.c105
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c10
12 files changed, 294 insertions, 76 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index dd9398184..7a2ff026d 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -1972,10 +1972,13 @@ int32_t
cli_cmd_volume_profile_parse (const char **words, int wordcount,
dict_t **options)
{
- dict_t *dict = NULL;
- char *volname = NULL;
- int ret = -1;
- gf1_cli_stats_op op = GF_CLI_STATS_NONE;
+ dict_t *dict = NULL;
+ char *volname = NULL;
+ int ret = -1;
+ gf1_cli_stats_op op = GF_CLI_STATS_NONE;
+ gf1_cli_info_op info_op = GF_CLI_INFO_NONE;
+ gf_boolean_t is_peek = _gf_false;
+
char *opwords[] = { "start", "stop", "info", NULL };
char *w = NULL;
@@ -2005,7 +2008,7 @@ cli_cmd_volume_profile_parse (const char **words, int wordcount,
wordcount > 5)
goto out;
- if (strcmp (w, "info") == 0 && wordcount > 6)
+ if (strcmp (w, "info") == 0 && wordcount > 7)
goto out;
if (strcmp (w, "start") == 0) {
@@ -2014,16 +2017,22 @@ cli_cmd_volume_profile_parse (const char **words, int wordcount,
op = GF_CLI_STATS_STOP;
} else if (strcmp (w, "info") == 0) {
op = GF_CLI_STATS_INFO;
+ info_op = GF_CLI_INFO_ALL;
if (wordcount > 4) {
if (strcmp (words[4], "incremental") == 0) {
- op = GF_CLI_STATS_INFO_INCREMENTAL;
+ info_op = GF_CLI_INFO_INCREMENTAL;
+ if (wordcount > 5 &&
+ strcmp (words[5], "peek") == 0) {
+ is_peek = _gf_true;
+ }
} else if (strcmp (words[4], "cumulative") == 0) {
- op = GF_CLI_STATS_INFO_CUMULATIVE;
+ info_op = GF_CLI_INFO_CUMULATIVE;
+ } else if (strcmp (words[4], "clear") == 0) {
+ info_op = GF_CLI_INFO_CLEAR;
+ } else if (strcmp (words[4], "peek") == 0) {
+ is_peek = _gf_true;
}
}
- ret = dict_set_int32 (dict, "info-op", op);
- if (ret)
- goto out;
} else
GF_ASSERT (!"opword mismatch");
@@ -2031,6 +2040,14 @@ cli_cmd_volume_profile_parse (const char **words, int wordcount,
if (ret)
goto out;
+ ret = dict_set_int32 (dict, "info-op", (int32_t)info_op);
+ if (ret)
+ goto out;
+
+ ret = dict_set_int32 (dict, "peek", is_peek);
+ if (ret)
+ goto out;
+
if (!strcmp (words[wordcount - 1], "nfs")) {
ret = dict_set_int32 (dict, "nfs", _gf_true);
if (ret)
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index a7e72dabd..9c29b7f3b 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -2334,7 +2334,7 @@ struct cli_cmd volume_cmds[] = {
cli_cmd_check_gsync_exists_cbk},
#endif
- { "volume profile <VOLNAME> {start | info [incremental | cumulative] | stop} [nfs]",
+ { "volume profile <VOLNAME> {start|info [peek|incremental [peek]|cumulative|clear]|stop} [nfs]",
cli_cmd_volume_profile_cbk,
"volume profile operations"},
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index d1b39014d..0b6bcb54b 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -4775,6 +4775,8 @@ gf_cli_profile_volume_cbk (struct rpc_req *req, struct iovec *iov,
char *volname = NULL;
char *brick = NULL;
char str[1024] = {0,};
+ int stats_cleared = 0;
+ gf1_cli_info_op info_op = GF_CLI_INFO_NONE;
if (-1 == req->rpc_status) {
goto out;
@@ -4840,8 +4842,6 @@ gf_cli_profile_volume_cbk (struct rpc_req *req, struct iovec *iov,
(rsp.op_ret) ? "unsuccessful": "successful");
break;
case GF_CLI_STATS_INFO:
- case GF_CLI_STATS_INFO_INCREMENTAL:
- case GF_CLI_STATS_INFO_CUMULATIVE:
break;
default:
cli_out ("volume profile on %s has been %s ",
@@ -4856,11 +4856,15 @@ gf_cli_profile_volume_cbk (struct rpc_req *req, struct iovec *iov,
goto out;
}
- if (op < GF_CLI_STATS_INFO || GF_CLI_STATS_INFO_CUMULATIVE < op) {
+ if (GF_CLI_STATS_INFO != op) {
ret = 0;
goto out;
}
+ ret = dict_get_int32 (dict, "info-op", (int32_t*)&info_op);
+ if (ret)
+ goto out;
+
ret = dict_get_int32 (dict, "count", &brick_count);
if (ret)
goto out;
@@ -4880,6 +4884,7 @@ gf_cli_profile_volume_cbk (struct rpc_req *req, struct iovec *iov,
}
ret = dict_get_str_boolean (dict, "nfs", _gf_false);
+
if (ret)
snprintf (str, sizeof (str), "NFS Server : %s", brick);
else
@@ -4888,15 +4893,25 @@ gf_cli_profile_volume_cbk (struct rpc_req *req, struct iovec *iov,
memset (str, '-', strlen (str));
cli_out ("%s", str);
- snprintf (key, sizeof (key), "%d-cumulative", i);
- ret = dict_get_int32 (dict, key, &interval);
- if (ret == 0) {
- cmd_profile_volume_brick_out (dict, i, interval);
- }
- snprintf (key, sizeof (key), "%d-interval", i);
- ret = dict_get_int32 (dict, key, &interval);
- if (ret == 0) {
- cmd_profile_volume_brick_out (dict, i, interval);
+ if (GF_CLI_INFO_CLEAR == info_op) {
+ snprintf (key, sizeof (key), "%d-stats-cleared", i);
+ ret = dict_get_int32 (dict, key, &stats_cleared);
+ if (ret)
+ goto out;
+ cli_out (stats_cleared ? "Cleared stats." :
+ "Failed to clear stats.");
+ } else {
+ snprintf (key, sizeof (key), "%d-cumulative", i);
+ ret = dict_get_int32 (dict, key, &interval);
+ if (ret == 0)
+ cmd_profile_volume_brick_out (dict, i,
+ interval);
+
+ snprintf (key, sizeof (key), "%d-interval", i);
+ ret = dict_get_int32 (dict, key, &interval);
+ if (ret == 0)
+ cmd_profile_volume_brick_out (dict, i,
+ interval);
}
i++;
}
diff --git a/cli/src/cli-xml-output.c b/cli/src/cli-xml-output.c
index 886c372dc..822b98df5 100644
--- a/cli/src/cli-xml-output.c
+++ b/cli/src/cli-xml-output.c
@@ -2229,11 +2229,13 @@ cli_xml_output_vol_profile (dict_t *dict, int op_ret, int op_errno,
xmlDocPtr doc = NULL;
char *volname = NULL;
int op = GF_CLI_STATS_NONE;
+ int info_op = GF_CLI_INFO_NONE;
int brick_count = 0;
char *brick_name = NULL;
int interval = 0;
char key[1024] = {0,};
int i = 0;
+ int stats_cleared = 0;
ret = cli_begin_xml_output (&writer, &doc);
if (ret)
@@ -2261,7 +2263,7 @@ cli_xml_output_vol_profile (dict_t *dict, int op_ret, int op_errno,
"%d", op);
XML_RET_CHECK_AND_GOTO (ret, out);
- if (op < GF_CLI_STATS_INFO || GF_CLI_STATS_INFO_CUMULATIVE < op)
+ if (GF_CLI_STATS_INFO != op)
goto cont;
ret = dict_get_int32 (dict, "count", &brick_count);
@@ -2271,6 +2273,10 @@ cli_xml_output_vol_profile (dict_t *dict, int op_ret, int op_errno,
"%d", brick_count);
XML_RET_CHECK_AND_GOTO (ret, out);
+ ret = dict_get_int32 (dict, "info-op", &info_op);
+ if (ret)
+ goto out;
+
while (i < brick_count) {
i++;
@@ -2286,23 +2292,37 @@ cli_xml_output_vol_profile (dict_t *dict, int op_ret, int op_errno,
(writer, (xmlChar *)"brickName", "%s", brick_name);
XML_RET_CHECK_AND_GOTO (ret, out);
- snprintf (key, sizeof (key), "%d-cumulative", i);
- ret = dict_get_int32 (dict, key, &interval);
- if (ret == 0) {
- ret = cli_xml_output_vol_profile_stats
- (writer, dict, i, interval);
+ if (GF_CLI_INFO_CLEAR == info_op) {
+ snprintf (key, sizeof (key), "%d-stats-cleared", i);
+ ret = dict_get_int32 (dict, key, &stats_cleared);
if (ret)
goto out;
- }
- memset (key, 0, sizeof (key));
- snprintf (key, sizeof (key), "%d-interval", i);
- ret = dict_get_int32 (dict, key, &interval);
- if (ret == 0) {
- ret = cli_xml_output_vol_profile_stats
- (writer, dict, i, interval);
+ ret = xmlTextWriterWriteFormatElement
+ (writer, (xmlChar *)"clearStats", "%s",
+ stats_cleared ? "Cleared stats." :
+ "Failed to clear stats.");
if (ret)
goto out;
+ } else {
+ snprintf (key, sizeof (key), "%d-cumulative", i);
+ ret = dict_get_int32 (dict, key, &interval);
+ if (ret == 0) {
+ ret = cli_xml_output_vol_profile_stats
+ (writer, dict, i, interval);
+ if (ret)
+ goto out;
+ }
+
+ memset (key, 0, sizeof (key));
+ snprintf (key, sizeof (key), "%d-interval", i);
+ ret = dict_get_int32 (dict, key, &interval);
+ if (ret == 0) {
+ ret = cli_xml_output_vol_profile_stats
+ (writer, dict, i, interval);
+ if (ret)
+ goto out;
+ }
}
/* </brick> */
diff --git a/rpc/xdr/src/cli1-xdr.c b/rpc/xdr/src/cli1-xdr.c
index 7d85b43c1..bf58e9904 100644
--- a/rpc/xdr/src/cli1-xdr.c
+++ b/rpc/xdr/src/cli1-xdr.c
@@ -157,6 +157,17 @@ xdr_gf1_cli_stats_op (XDR *xdrs, gf1_cli_stats_op *objp)
}
bool_t
+xdr_gf1_cli_info_op (XDR *xdrs, gf1_cli_info_op *objp)
+{
+ register int32_t *buf;
+ buf = NULL;
+
+ if (!xdr_enum (xdrs, (enum_t *) objp))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
xdr_gf1_cli_top_op (XDR *xdrs, gf1_cli_top_op *objp)
{
register int32_t *buf;
diff --git a/rpc/xdr/src/cli1-xdr.h b/rpc/xdr/src/cli1-xdr.h
index 815384e80..11297cc25 100644
--- a/rpc/xdr/src/cli1-xdr.h
+++ b/rpc/xdr/src/cli1-xdr.h
@@ -140,12 +140,19 @@ enum gf1_cli_stats_op {
GF_CLI_STATS_START = 1,
GF_CLI_STATS_STOP = 2,
GF_CLI_STATS_INFO = 3,
- GF_CLI_STATS_INFO_INCREMENTAL = 4,
- GF_CLI_STATS_INFO_CUMULATIVE = 5,
- GF_CLI_STATS_TOP = 6
+ GF_CLI_STATS_TOP = 4,
};
typedef enum gf1_cli_stats_op gf1_cli_stats_op;
+enum gf1_cli_info_op {
+ GF_CLI_INFO_NONE = 0,
+ GF_CLI_INFO_ALL = 1,
+ GF_CLI_INFO_INCREMENTAL = 2,
+ GF_CLI_INFO_CUMULATIVE = 3,
+ GF_CLI_INFO_CLEAR = 4,
+};
+typedef enum gf1_cli_info_op gf1_cli_info_op;
+
enum gf1_cli_top_op {
GF_CLI_TOP_NONE = 0,
GF_CLI_TOP_OPEN = 0 + 1,
@@ -286,6 +293,7 @@ extern bool_t xdr_gf1_cli_sync_volume (XDR *, gf1_cli_sync_volume*);
extern bool_t xdr_gf1_cli_op_flags (XDR *, gf1_cli_op_flags*);
extern bool_t xdr_gf1_cli_gsync_set (XDR *, gf1_cli_gsync_set*);
extern bool_t xdr_gf1_cli_stats_op (XDR *, gf1_cli_stats_op*);
+extern bool_t xdr_gf1_cli_info_op (XDR *, gf1_cli_info_op*);
extern bool_t xdr_gf1_cli_top_op (XDR *, gf1_cli_top_op*);
extern bool_t xdr_gf_cli_status_type (XDR *, gf_cli_status_type*);
extern bool_t xdr_gf_cli_req (XDR *, gf_cli_req*);
@@ -314,6 +322,7 @@ extern bool_t xdr_gf1_cli_sync_volume ();
extern bool_t xdr_gf1_cli_op_flags ();
extern bool_t xdr_gf1_cli_gsync_set ();
extern bool_t xdr_gf1_cli_stats_op ();
+extern bool_t xdr_gf1_cli_info_op ();
extern bool_t xdr_gf1_cli_top_op ();
extern bool_t xdr_gf_cli_status_type ();
extern bool_t xdr_gf_cli_req ();
diff --git a/rpc/xdr/src/cli1-xdr.x b/rpc/xdr/src/cli1-xdr.x
index 46f4581ee..a283006b0 100644
--- a/rpc/xdr/src/cli1-xdr.x
+++ b/rpc/xdr/src/cli1-xdr.x
@@ -97,6 +97,14 @@ enum gf1_cli_stats_op {
GF_CLI_STATS_TOP = 4
};
+enum gf1_cli_info_op {
+ GF_CLI_INFO_NONE = 0,
+ GF_CLI_INFO_ALL = 1,
+ GF_CLI_INFO_INCREMENTAL = 2,
+ GF_CLI_INFO_CUMULATIVE = 3,
+ GF_CLI_INFO_CLEAR = 4
+};
+
enum gf1_cli_top_op {
GF_CLI_TOP_NONE = 0,
GF_CLI_TOP_OPEN,
diff --git a/tests/bugs/bug-1030580.t b/tests/bugs/bug-1030580.t
index ed1cdb864..642c6dc44 100644
--- a/tests/bugs/bug-1030580.t
+++ b/tests/bugs/bug-1030580.t
@@ -9,14 +9,6 @@ function write_to_file {
dd of=$M0/1 if=/dev/zero bs=1M count=128 oflag=append 2>&1 >/dev/null
}
-function cumulative_stat_count {
- echo "$1" | grep "Cumulative Stats:" | wc -l
-}
-
-function incremental_stat_count {
- echo "$1" | grep "Interval$2Stats:" | wc -l
-}
-
TEST glusterd
TEST pidof glusterd
TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}0 $H0:$B0/${V0}1
diff --git a/tests/bugs/bug-1047416.t b/tests/bugs/bug-1047416.t
new file mode 100644
index 000000000..53c7f8614
--- /dev/null
+++ b/tests/bugs/bug-1047416.t
@@ -0,0 +1,66 @@
+#!/bin/bash
+
+. $(dirname $0)/../include.rc
+. $(dirname $0)/../volume.rc
+
+cleanup;
+
+function write_to_file {
+ dd of=$M0/1 if=/dev/zero bs=1M count=128 oflag=append 2>&1 >/dev/null
+}
+
+TEST glusterd
+TEST pidof glusterd
+TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}0 $H0:$B0/${V0}1
+TEST $CLI volume start $V0
+TEST $CLI volume profile $V0 start
+TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0 --attribute-timeout=0 --entry-timeout=0
+
+# Verify 'volume profile info' prints both cumulative and incremental stats
+write_to_file &
+wait
+output=$($CLI volume profile $V0 info)
+EXPECT 2 cumulative_stat_count "$output"
+EXPECT 2 incremental_stat_count "$output" ' 0 '
+
+# Verify 'volume profile info peek' prints both cumulative and incremental stats
+# without clearing incremental stats
+write_to_file &
+wait
+output=$($CLI volume profile $V0 info peek)
+EXPECT 2 cumulative_stat_count "$output"
+EXPECT 2 incremental_stat_count "$output" ' 1 '
+
+write_to_file &
+wait
+output=$($CLI volume profile $V0 info peek)
+EXPECT 2 cumulative_stat_count "$output"
+EXPECT 2 incremental_stat_count "$output" ' 1 '
+
+# Verify 'volume profile info incremental peek' prints incremental stats only
+# without clearing incremental stats
+write_to_file &
+wait
+output=$($CLI volume profile $V0 info incremental peek)
+EXPECT 0 cumulative_stat_count "$output"
+EXPECT 2 incremental_stat_count "$output" ' 1 '
+
+write_to_file &
+wait
+output=$($CLI volume profile $V0 info incremental peek)
+EXPECT 0 cumulative_stat_count "$output"
+EXPECT 2 incremental_stat_count "$output" ' 1 '
+
+# Verify 'volume profile info clear' clears both incremental and cumulative stats
+write_to_file &
+wait
+output=$($CLI volume profile $V0 info clear)
+EXPECT 2 cleared_stat_count "$output"
+
+output=$($CLI volume profile $V0 info)
+EXPECT 2 cumulative_stat_count "$output"
+EXPECT 2 incremental_stat_count "$output" ' 0 '
+EXPECT 4 data_read_count "$output" ' 0 '
+EXPECT 4 data_written_count "$output" ' 0 '
+
+cleanup;
diff --git a/tests/volume.rc b/tests/volume.rc
index b1aa904fb..5e2f95e76 100644
--- a/tests/volume.rc
+++ b/tests/volume.rc
@@ -279,3 +279,26 @@ function get_hex_xattr {
local path=$2
getfattr -d -m. -e hex $2 2>/dev/null | grep $1 | cut -f2 -d'=' | cut -f2 -d'x'
}
+
+function cumulative_stat_count {
+ echo "$1" | grep "Cumulative Stats:" | wc -l
+}
+
+function incremental_stat_count {
+ echo "$1" | grep "Interval$2Stats:" | wc -l
+}
+
+function cleared_stat_count {
+ echo "$1" | grep "Cleared stats." | wc -l
+}
+
+function data_read_count {
+ echo "$1" | grep "Data Read:$2bytes" | wc -l
+}
+
+function data_written_count {
+ echo "$1" | grep "Data Written:$2bytes" | wc -l
+}
+
+
+
diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c
index 65aeee52b..fa0dd395c 100644
--- a/xlators/debug/io-stats/src/io-stats.c
+++ b/xlators/debug/io-stats/src/io-stats.c
@@ -917,9 +917,19 @@ ios_dump_args_init (struct ios_dump_args *args, ios_dump_type_t type,
return ret;
}
+static void
+ios_global_stats_clear (struct ios_global_stats *stats, struct timeval *now)
+{
+ GF_ASSERT (stats);
+ GF_ASSERT (now);
+
+ memset (stats, 0, sizeof (*stats));
+ stats->started_at = *now;
+}
+
int
io_stats_dump (xlator_t *this, struct ios_dump_args *args,
- gf1_cli_stats_op op)
+ gf1_cli_stats_op op, gf_boolean_t is_peek)
{
struct ios_conf *conf = NULL;
struct ios_global_stats cumulative = {0, };
@@ -937,29 +947,31 @@ io_stats_dump (xlator_t *this, struct ios_dump_args *args,
gettimeofday (&now, NULL);
LOCK (&conf->lock);
{
- if (op == GF_CLI_STATS_INFO ||
- op == GF_CLI_STATS_INFO_CUMULATIVE)
+ if (op == GF_CLI_INFO_ALL ||
+ op == GF_CLI_INFO_CUMULATIVE)
cumulative = conf->cumulative;
- if (op == GF_CLI_STATS_INFO ||
- op == GF_CLI_STATS_INFO_INCREMENTAL) {
+ if (op == GF_CLI_INFO_ALL ||
+ op == GF_CLI_INFO_INCREMENTAL) {
incremental = conf->incremental;
+ increment = conf->increment;
- increment = conf->increment++;
+ if (!is_peek) {
+ increment = conf->increment++;
- memset (&conf->incremental, 0,
- sizeof (conf->incremental));
- conf->incremental.started_at = now;
+ ios_global_stats_clear (&conf->incremental,
+ &now);
+ }
}
}
UNLOCK (&conf->lock);
- if (op == GF_CLI_STATS_INFO ||
- op == GF_CLI_STATS_INFO_CUMULATIVE)
+ if (op == GF_CLI_INFO_ALL ||
+ op == GF_CLI_INFO_CUMULATIVE)
io_stats_dump_global (this, &cumulative, &now, -1, args);
- if (op == GF_CLI_STATS_INFO ||
- op == GF_CLI_STATS_INFO_INCREMENTAL)
+ if (op == GF_CLI_INFO_ALL ||
+ op == GF_CLI_INFO_INCREMENTAL)
io_stats_dump_global (this, &incremental, &now, increment, args);
return 0;
@@ -2218,10 +2230,10 @@ conditional_dump (dict_t *dict, char *key, data_t *value, void *data)
gf_log (this->name, GF_LOG_ERROR, "failed to open %s "
"for writing", filename);
return -1;
- }
+ }
(void) ios_dump_args_init (&args, IOS_DUMP_TYPE_FILE,
logfp);
- io_stats_dump (this, &args, GF_CLI_STATS_INFO);
+ io_stats_dump (this, &args, GF_CLI_INFO_ALL, _gf_false);
fclose (logfp);
}
return 0;
@@ -2625,6 +2637,29 @@ ios_destroy_top_stats (struct ios_conf *conf)
return;
}
+static int
+io_stats_clear (struct ios_conf *conf)
+{
+ struct timeval now;
+ int ret = -1;
+
+ GF_ASSERT (conf);
+
+ if (!gettimeofday (&now, NULL))
+ {
+ LOCK (&conf->lock);
+ {
+ ios_global_stats_clear (&conf->cumulative, &now);
+ ios_global_stats_clear (&conf->incremental, &now);
+ conf->increment = 0;
+ }
+ UNLOCK (&conf->lock);
+ ret = 0;
+ }
+
+ return ret;
+}
+
int
reconfigure (xlator_t *this, dict_t *options)
{
@@ -2791,6 +2826,7 @@ notify (xlator_t *this, int32_t event, void *data, ...)
int32_t list_cnt = 0;
double throughput = 0;
double time = 0;
+ gf_boolean_t is_peek = _gf_false;
va_list ap;
dict = data;
@@ -2851,13 +2887,40 @@ notify (xlator_t *this, int32_t event, void *data, ...)
}
} else {
ret = dict_get_int32 (dict, "info-op", &op);
- if (ret || op < GF_CLI_STATS_INFO ||
- GF_CLI_STATS_INFO_CUMULATIVE < op)
- op = GF_CLI_STATS_INFO;
+ if (ret || op < GF_CLI_INFO_ALL ||
+ GF_CLI_INFO_CLEAR < op)
+ op = GF_CLI_INFO_ALL;
+
+ ret = dict_set_int32 (output, "info-op", op);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "Failed to set info-op in dict");
+ goto out;
+ }
+
+ if (GF_CLI_INFO_CLEAR == op) {
+ ret = io_stats_clear (this->private);
+ if (ret)
+ gf_log (this->name, GF_LOG_ERROR,
+ "Failed to clear info stats");
- (void) ios_dump_args_init (&args, IOS_DUMP_TYPE_DICT,
- output);
- ret = io_stats_dump (this, &args, op);
+ ret = dict_set_int32 (output, "stats-cleared",
+ ret ? 0 : 1);
+ if (ret)
+ gf_log (this->name, GF_LOG_ERROR,
+ "Failed to set stats-cleared"
+ " in dict");
+ }
+ else {
+ ret = dict_get_str_boolean (dict, "peek",
+ _gf_false);
+ if (-1 != ret)
+ is_peek = ret;
+
+ (void) ios_dump_args_init (&args,
+ IOS_DUMP_TYPE_DICT, output);
+ ret = io_stats_dump (this, &args, op, is_peek);
+ }
}
break;
default:
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 06ee849f5..0ddb52b3a 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -1094,8 +1094,7 @@ glusterd_op_stage_stats_volume (dict_t *dict, char **op_errstr)
}
if ((GF_CLI_STATS_STOP == stats_op) ||
- (GF_CLI_STATS_INFO <= stats_op &&
- stats_op <= GF_CLI_STATS_INFO_CUMULATIVE)) {
+ (GF_CLI_STATS_INFO == stats_op)) {
if (_gf_false == glusterd_is_profile_on (volinfo)) {
snprintf (msg, sizeof (msg), "Profile on Volume %s is"
" not started", volinfo->volname);
@@ -1105,8 +1104,7 @@ glusterd_op_stage_stats_volume (dict_t *dict, char **op_errstr)
}
}
if ((GF_CLI_STATS_TOP == stats_op) ||
- (GF_CLI_STATS_INFO <= stats_op &&
- stats_op <= GF_CLI_STATS_INFO_CUMULATIVE)) {
+ (GF_CLI_STATS_INFO == stats_op)) {
if (_gf_false == glusterd_is_volume_started (volinfo)) {
snprintf (msg, sizeof (msg), "Volume %s is not started.",
volinfo->volname);
@@ -1908,8 +1906,6 @@ glusterd_op_stats_volume (dict_t *dict, char **op_errstr,
glusterd_remove_profile_volume_options (volinfo);
break;
case GF_CLI_STATS_INFO:
- case GF_CLI_STATS_INFO_INCREMENTAL:
- case GF_CLI_STATS_INFO_CUMULATIVE:
case GF_CLI_STATS_TOP:
//info is already collected in brick op.
//just goto out;
@@ -4480,8 +4476,6 @@ glusterd_bricks_select_profile_volume (dict_t *dict, char **op_errstr,
goto out;
break;
case GF_CLI_STATS_INFO:
- case GF_CLI_STATS_INFO_INCREMENTAL:
- case GF_CLI_STATS_INFO_CUMULATIVE:
ret = dict_get_str_boolean (dict, "nfs", _gf_false);
if (ret) {
if (!glusterd_is_nodesvc_online ("nfs")) {