From 0b3e4130b576c11156d6327e4cc3c9310a74c143 Mon Sep 17 00:00:00 2001 From: Kotresh HR Date: Fri, 5 Aug 2016 09:03:22 +0530 Subject: feature/bitrot: Ondemand scrub option for bitrot The bitrot scrubber takes 'hourly/daily/biweekly/monthly' as the values for 'scrub-frequency'. There is no way to schedule the scrubbing when the admin wants it. Ondemand scrubbing brings in the new option 'ondemand' with which the admin can start scrubbing ondemand. It starts the scrubbing immediately. Ondemand scrubbing is successful only if the scrubber is in 'Active (Idle)' (waiting for it's next frequency cycle to start scrubbing). It is not entertained when the scrubber is in 'Paused' or already running. Here is the command line syntax. gluster volume bitrot scrub ondemand Change-Id: I84c28904367eed827a7dae8d6a535c14b28e9f4d BUG: 1366195 Signed-off-by: Kotresh HR Reviewed-on: http://review.gluster.org/15111 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Venky Shankar --- xlators/features/bit-rot/src/bitd/bit-rot.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'xlators/features/bit-rot/src/bitd/bit-rot.c') diff --git a/xlators/features/bit-rot/src/bitd/bit-rot.c b/xlators/features/bit-rot/src/bitd/bit-rot.c index ca3fc273e9f..882ac1da6b4 100644 --- a/xlators/features/bit-rot/src/bitd/bit-rot.c +++ b/xlators/features/bit-rot/src/bitd/bit-rot.c @@ -1534,7 +1534,6 @@ _br_qchild_event (xlator_t *this, br_child_t *child, br_child_handler *call) int br_scrubber_status_get (xlator_t *this, dict_t **dict) { - int ret = -1; br_private_t *priv = NULL; struct br_scrub_stats *scrub_stats = NULL; @@ -1600,9 +1599,11 @@ notify (xlator_t *this, int32_t event, void *data, ...) br_private_t *priv = NULL; dict_t *output = NULL; va_list ap; + struct br_monitor *scrub_monitor = NULL; subvol = (xlator_t *)data; priv = this->private; + scrub_monitor = &priv->scrub_monitor; gf_msg_trace (this->name, 0, "Notification received: %d", event); @@ -1676,6 +1677,30 @@ notify (xlator_t *this, int32_t event, void *data, ...) ret = br_scrubber_status_get (this, &output); gf_msg_debug (this->name, 0, "returning %d", ret); break; + + case GF_EVENT_SCRUB_ONDEMAND: + gf_log (this->name, GF_LOG_INFO, "BitRot scrub ondemand " + "called"); + + if (scrub_monitor->state != BR_SCRUB_STATE_PENDING) + return -2; + + /* Needs synchronization with reconfigure thread */ + pthread_mutex_lock (&priv->lock); + { + ret = br_scrub_state_machine (this, _gf_true); + } + pthread_mutex_unlock (&priv->lock); + + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, + BRB_MSG_RESCHEDULE_SCRUBBER_FAILED, + "Could not schedule ondemand scrubbing. " + "Scrubbing will continue according to " + "old frequency."); + } + gf_msg_debug (this->name, 0, "returning %d", ret); + break; default: default_notify (this, event, data); } @@ -2045,7 +2070,7 @@ br_reconfigure_monitor (xlator_t *this) { int32_t ret = 0; - ret = br_scrub_state_machine (this); + ret = br_scrub_state_machine (this, _gf_false); if (ret) { gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_RESCHEDULE_SCRUBBER_FAILED, -- cgit