summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cli/src/cli-rpc-ops.c21
-rw-r--r--xlators/features/bit-rot/src/bitd/bit-rot-scrub-status.h2
-rw-r--r--xlators/features/bit-rot/src/bitd/bit-rot-scrub.c2
-rw-r--r--xlators/features/bit-rot/src/bitd/bit-rot.c27
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c26
5 files changed, 64 insertions, 14 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 8f6073fb1e8..ea0a63bf748 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -10829,6 +10829,8 @@ gf_cli_print_bitrot_scrub_status (dict_t *dict)
uint64_t seconds = 0;
char *last_scrub = NULL;
uint64_t error_count = 0;
+ int8_t scrub_running = 0;
+ char *scrub_state_op = NULL;
ret = dict_get_str (dict, "volname", &volname);
@@ -10865,9 +10867,25 @@ gf_cli_print_bitrot_scrub_status (dict_t *dict)
goto out;
}
+ for (i = 1; i <= count; i++) {
+ memset (key, 0, 256);
+ snprintf (key, 256, "scrub-running-%d", i);
+ ret = dict_get_int8 (dict, key, &scrub_running);
+ if (ret)
+ gf_log ("cli", GF_LOG_TRACE, "failed to get scrubbed "
+ "files");
+ if (scrub_running)
+ break;
+ }
+
+ if (scrub_running)
+ gf_asprintf (&scrub_state_op, "%s (In Progress)", state_scrub);
+ else
+ gf_asprintf (&scrub_state_op, "%s (Idle)", state_scrub);
+
cli_out ("\n%s: %s\n", "Volume name ", volname);
- cli_out ("%s: %s\n", "State of scrub", state_scrub);
+ cli_out ("%s: %s\n", "State of scrub", scrub_state_op);
cli_out ("%s: %s\n", "Scrub impact", scrub_impact);
@@ -10977,6 +10995,7 @@ gf_cli_print_bitrot_scrub_status (dict_t *dict)
"===============");
out:
+ GF_FREE (scrub_state_op);
return 0;
}
diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-scrub-status.h b/xlators/features/bit-rot/src/bitd/bit-rot-scrub-status.h
index 694ba0acbe3..02bd0fab04e 100644
--- a/xlators/features/bit-rot/src/bitd/bit-rot-scrub-status.h
+++ b/xlators/features/bit-rot/src/bitd/bit-rot-scrub-status.h
@@ -28,6 +28,8 @@ struct br_scrub_stats {
struct timeval scrub_end_tv; /* Scrubbing finishing time */
+ int8_t scrub_running; /* Scrub running or not */
+
pthread_mutex_t lock;
};
diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c
index e36762e8b22..2f5729f1e6d 100644
--- a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c
+++ b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c
@@ -666,6 +666,7 @@ br_scrubber_entry_control (xlator_t *this)
if (scrub_monitor->state == BR_SCRUB_STATE_PENDING)
scrub_monitor->state = BR_SCRUB_STATE_ACTIVE;
br_scrubber_log_time (this, "started");
+ priv->scrub_stat.scrub_running = 1;
}
UNLOCK (&scrub_monitor->lock);
}
@@ -682,6 +683,7 @@ br_scrubber_exit_control (xlator_t *this)
LOCK (&scrub_monitor->lock);
{
br_scrubber_log_time (this, "finished");
+ priv->scrub_stat.scrub_running = 0;
if (scrub_monitor->state == BR_SCRUB_STATE_ACTIVE) {
(void) br_fsscan_activate (this);
diff --git a/xlators/features/bit-rot/src/bitd/bit-rot.c b/xlators/features/bit-rot/src/bitd/bit-rot.c
index 45f8d1d624c..46bef085404 100644
--- a/xlators/features/bit-rot/src/bitd/bit-rot.c
+++ b/xlators/features/bit-rot/src/bitd/bit-rot.c
@@ -1541,7 +1541,6 @@ br_scrubber_status_get (xlator_t *this, dict_t **dict)
{
int ret = -1;
- char key[256] = {0,};
br_private_t *priv = NULL;
struct br_scrub_stats *scrub_stats = NULL;
@@ -1557,33 +1556,35 @@ br_scrubber_status_get (xlator_t *this, dict_t **dict)
"files");
}
- memset (key, 0, 256);
- snprintf (key, 256, "scrubbed-files");
- ret = dict_set_uint64 (*dict, key, scrub_stats->scrubbed_files);
+ ret = dict_set_int8 (*dict, "scrub-running",
+ scrub_stats->scrub_running);
+ if (ret) {
+ gf_msg_debug (this->name, 0, "Failed setting scrub_running "
+ "entry to the dictionary");
+ }
+
+ ret = dict_set_uint64 (*dict, "scrubbed-files",
+ scrub_stats->scrubbed_files);
if (ret) {
gf_msg_debug (this->name, 0, "Failed to setting scrubbed file "
"entry to the dictionary");
}
- memset (key, 0, 256);
- snprintf (key, 256, "unsigned-files");
- ret = dict_set_uint64 (*dict, key, scrub_stats->unsigned_files);
+ ret = dict_set_uint64 (*dict, "unsigned-files",
+ scrub_stats->unsigned_files);
if (ret) {
gf_msg_debug (this->name, 0, "Failed to set unsigned file count"
" entry to the dictionary");
}
- memset (key, 0, 256);
- snprintf (key, 256, "scrub-duration");
- ret = dict_set_uint64 (*dict, key, scrub_stats->scrub_duration);
+ ret = dict_set_uint64 (*dict, "scrub-duration",
+ scrub_stats->scrub_duration);
if (ret) {
gf_msg_debug (this->name, 0, "Failed to set scrub duration"
" entry to the dictionary");
}
- memset (key, 0, 256);
- snprintf (key, 256, "last-scrub-time");
- ret = dict_set_dynstr_with_alloc (*dict, key,
+ ret = dict_set_dynstr_with_alloc (*dict, "last-scrub-time",
scrub_stats->last_scrub_time);
if (ret) {
gf_msg_debug (this->name, 0, "Failed to set "
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 0ea19438df7..354edbb0da5 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -8590,6 +8590,7 @@ glusterd_volume_bitrot_scrub_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict)
glusterd_volinfo_t *volinfo = NULL;
int src_count = 0;
int dst_count = 0;
+ int8_t scrub_running = 0;
this = THIS;
GF_ASSERT (this);
@@ -8639,6 +8640,19 @@ glusterd_volume_bitrot_scrub_use_rsp_dict (dict_t *aggr, dict_t *rsp_dict)
}
memset (key, 0, 256);
+ snprintf (key, 256, "scrub-running-%d", src_count);
+ ret = dict_get_int8 (rsp_dict, key, &scrub_running);
+ if (!ret) {
+ memset (key, 0, 256);
+ snprintf (key, 256, "scrub-running-%d", src_count+dst_count);
+ ret = dict_set_int8 (aggr, key, scrub_running);
+ if (ret) {
+ gf_msg_debug (this->name, 0, "Failed to set "
+ "scrub-running value");
+ }
+ }
+
+ memset (key, 0, 256);
snprintf (key, 256, "scrubbed-files-%d", src_count);
ret = dict_get_uint64 (rsp_dict, key, &value);
if (!ret) {
@@ -8809,6 +8823,7 @@ glusterd_bitrot_volume_node_rsp (dict_t *aggr, dict_t *rsp_dict)
xlator_t *this = NULL;
glusterd_conf_t *priv = NULL;
glusterd_volinfo_t *volinfo = NULL;
+ int8_t scrub_running = 0;
this = THIS;
GF_ASSERT (this);
@@ -8918,6 +8933,17 @@ glusterd_bitrot_volume_node_rsp (dict_t *aggr, dict_t *rsp_dict)
}
}
+ ret = dict_get_int8 (rsp_dict, "scrub-running", &scrub_running);
+ if (!ret) {
+ memset (key, 0, 256);
+ snprintf (key, 256, "scrub-running-%d", i);
+ ret = dict_set_uint64 (aggr, key, scrub_running);
+ if (ret) {
+ gf_msg_debug (this->name, 0, "Failed to set "
+ "scrub-running value");
+ }
+ }
+
ret = dict_get_uint64 (rsp_dict, "scrubbed-files", &value);
if (!ret) {
memset (key, 0, 256);