diff options
Diffstat (limited to 'xlators/features/bit-rot')
-rw-r--r-- | xlators/features/bit-rot/src/bitd/bit-rot-scrub-status.h | 2 | ||||
-rw-r--r-- | xlators/features/bit-rot/src/bitd/bit-rot-scrub.c | 2 | ||||
-rw-r--r-- | xlators/features/bit-rot/src/bitd/bit-rot.c | 27 |
3 files changed, 18 insertions, 13 deletions
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 8b95f056a16..a5885642b89 100644 --- a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c +++ b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c @@ -664,6 +664,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); } @@ -680,6 +681,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 ed436c34dc4..174af2b6a15 100644 --- a/xlators/features/bit-rot/src/bitd/bit-rot.c +++ b/xlators/features/bit-rot/src/bitd/bit-rot.c @@ -1536,7 +1536,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; @@ -1552,33 +1551,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 " |