From 3b63a2eb7f9a67360564cf949de6e7a0e7313153 Mon Sep 17 00:00:00 2001 From: Kotresh HR Date: Wed, 12 Aug 2015 15:25:03 +0530 Subject: features/bitrot: Fix scrubber frequency set When bitrot is configured on multiple volumes in a cluster and scrubber-frequency is changed for one volume, it is resetting frequency for all other volumes w.r.t to its scrubber-frequency. This should not happen. Changing scrubber-frequency should affect only that volume on which it is set. This patch fixes the issue. Also restricted the logs to the configure volume. BUG: 1256669 Change-Id: I6eba385b50b3bdc86bc8f4ef295a004b3b87b68a Reviewed-on: http://review.gluster.org/11897 Tested-by: NetBSD Build System Tested-by: Gluster Build System Reviewed-by: Raghavendra Bhat Reviewed-by: Venky Shankar Signed-off-by: Kotresh HR Reviewed-on: http://review.gluster.org/12010 --- xlators/features/bit-rot/src/bitd/bit-rot-scrub.c | 24 ++++++++++++++++++----- xlators/features/bit-rot/src/bitd/bit-rot.h | 3 +++ 2 files changed, 22 insertions(+), 5 deletions(-) (limited to 'xlators/features/bit-rot') 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 25bf884fd93..a311e2e6da8 100644 --- a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c +++ b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c @@ -832,6 +832,9 @@ br_fsscan_reschedule (xlator_t *this, br_child_t *child) fsscan = &child->fsscan; fsscrub = &priv->fsscrub; + if (!fsscrub->frequency_reconf) + return 0; + (void) gettimeofday (&now, NULL); timo = br_fsscan_calculate_timeout (fsscrub->frequency); if (timo == 0) { @@ -1187,6 +1190,7 @@ br_scrubber_handle_throttle (xlator_t *this, br_private_t *priv, scrub_throttle_t nthrottle = BR_SCRUB_THROTTLE_VOID; fsscrub = &priv->fsscrub; + fsscrub->throttle_reconf = _gf_false; ret = br_scrubber_fetch_option (this, "scrub-throttle", options, &tmp); if (ret) @@ -1211,6 +1215,9 @@ br_scrubber_handle_throttle (xlator_t *this, br_private_t *priv, if (ret) goto error_return; + if (fsscrub->throttle != nthrottle) + fsscrub->throttle_reconf = _gf_true; + fsscrub->throttle = nthrottle; return 0; @@ -1248,6 +1255,7 @@ br_scrubber_handle_freq (xlator_t *this, br_private_t *priv, struct br_scrubber *fsscrub = NULL; fsscrub = &priv->fsscrub; + fsscrub->frequency_reconf = _gf_true; ret = br_scrubber_fetch_option (this, "scrub-freq", options, &tmp); if (ret) @@ -1271,7 +1279,11 @@ br_scrubber_handle_freq (xlator_t *this, br_private_t *priv, } else goto error_return; - fsscrub->frequency = frequency; + if (fsscrub->frequency == frequency) + fsscrub->frequency_reconf = _gf_false; + else + fsscrub->frequency = frequency; + return 0; error_return: @@ -1299,10 +1311,12 @@ static void br_scrubber_log_option (xlator_t *this, if (scrubstall) return; /* logged as pause */ - gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCRUB_TUNABLE, "SCRUB " - "TUNABLES:: [Frequency: %s, Throttle: %s]", - scrub_freq_str[fsscrub->frequency], - scrub_throttle_str[fsscrub->throttle]); + if (fsscrub->frequency_reconf || fsscrub->throttle_reconf) { + gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_SCRUB_TUNABLE, + "SCRUB TUNABLES:: [Frequency: %s, Throttle: %s]", + scrub_freq_str[fsscrub->frequency], + scrub_throttle_str[fsscrub->throttle]); + } } int32_t diff --git a/xlators/features/bit-rot/src/bitd/bit-rot.h b/xlators/features/bit-rot/src/bitd/bit-rot.h index 6cafd8be9f3..ebf847665f6 100644 --- a/xlators/features/bit-rot/src/bitd/bit-rot.h +++ b/xlators/features/bit-rot/src/bitd/bit-rot.h @@ -142,6 +142,9 @@ struct br_scrubber { */ scrub_freq_t frequency; + gf_boolean_t frequency_reconf; + gf_boolean_t throttle_reconf; + pthread_mutex_t mutex; pthread_cond_t cond; -- cgit