diff options
author | Kotresh HR <khiremat@redhat.com> | 2015-08-06 16:53:22 +0530 |
---|---|---|
committer | Venky Shankar <vshankar@redhat.com> | 2015-08-23 21:36:43 -0700 |
commit | 1b603f17a75b4d41d8d7eb9d832321dd7387dd31 (patch) | |
tree | 2644068d3ba3ed619dd6df3faee4639bb3139525 | |
parent | aee983ff43655771a9102592a284d0b0a29ad89f (diff) |
features/bitrot: Fix rescheduling scrub-frequency
While rescheduling scrub frequency, boot time of
the brick was considered where it is not required
and also delta is calculated using unsigned int
resulting in the loss of fractional part leading to
wrong scrub frequency. Boot time is completely
removed and delta calculation is simplified.
BUG: 1253160
Change-Id: I98dd1fa99304c6d91c0a330dfca7fef57a770397
Reviewed-on: http://review.gluster.org/11853
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Venky Shankar <vshankar@redhat.com>
Signed-off-by: Kotresh HR <khiremat@redhat.com>
Reviewed-on: http://review.gluster.org/11904
-rw-r--r-- | xlators/features/bit-rot/src/bitd/bit-rot-scrub.c | 31 |
1 files changed, 11 insertions, 20 deletions
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 2fb5caa392f..25bf884fd93 100644 --- a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c +++ b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c @@ -693,15 +693,9 @@ br_kickstart_scanner (struct gf_tw_timer_list *timer, } static inline uint32_t -br_fsscan_calculate_delta (uint32_t boot, uint32_t now, uint32_t times) +br_fsscan_calculate_delta (uint32_t times) { - uint32_t secs = 0; - uint32_t diff = 0; - - diff = (now - boot); - secs = times * ((diff / times) + 1); - - return (secs - diff); + return times; } #define BR_SCRUB_HOURLY (60 * 60) @@ -711,25 +705,25 @@ br_fsscan_calculate_delta (uint32_t boot, uint32_t now, uint32_t times) #define BR_SCRUB_MONTHLY (30 * 24 * 60 * 60) static unsigned int -br_fsscan_calculate_timeout (uint32_t boot, uint32_t now, scrub_freq_t freq) +br_fsscan_calculate_timeout (scrub_freq_t freq) { uint32_t timo = 0; switch (freq) { case BR_FSSCRUB_FREQ_HOURLY: - timo = br_fsscan_calculate_delta (boot, now, BR_SCRUB_HOURLY); + timo = br_fsscan_calculate_delta (BR_SCRUB_HOURLY); break; case BR_FSSCRUB_FREQ_DAILY: - timo = br_fsscan_calculate_delta (boot, now, BR_SCRUB_DAILY); + timo = br_fsscan_calculate_delta (BR_SCRUB_DAILY); break; case BR_FSSCRUB_FREQ_WEEKLY: - timo = br_fsscan_calculate_delta (boot, now, BR_SCRUB_WEEKLY); + timo = br_fsscan_calculate_delta (BR_SCRUB_WEEKLY); break; case BR_FSSCRUB_FREQ_BIWEEKLY: - timo = br_fsscan_calculate_delta (boot, now, BR_SCRUB_BIWEEKLY); + timo = br_fsscan_calculate_delta (BR_SCRUB_BIWEEKLY); break; case BR_FSSCRUB_FREQ_MONTHLY: - timo = br_fsscan_calculate_delta (boot, now, BR_SCRUB_MONTHLY); + timo = br_fsscan_calculate_delta (BR_SCRUB_MONTHLY); break; default: timo = 0; @@ -756,8 +750,7 @@ br_fsscan_schedule (xlator_t *this, br_child_t *child) (void) gettimeofday (&tv, NULL); fsscan->boot = tv.tv_sec; - timo = br_fsscan_calculate_timeout (fsscan->boot, - fsscan->boot, fsscrub->frequency); + timo = br_fsscan_calculate_timeout (fsscrub->frequency); if (timo == 0) { gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_ZERO_TIMEOUT_BUG, "BUG: Zero schedule timeout"); @@ -805,8 +798,7 @@ br_fsscan_activate (xlator_t *this, br_child_t *child) fsscrub = &priv->fsscrub; (void) gettimeofday (&now, NULL); - timo = br_fsscan_calculate_timeout (fsscan->boot, - now.tv_sec, fsscrub->frequency); + timo = br_fsscan_calculate_timeout (fsscrub->frequency); if (timo == 0) { gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_ZERO_TIMEOUT_BUG, "BUG: Zero schedule timeout"); @@ -841,8 +833,7 @@ br_fsscan_reschedule (xlator_t *this, br_child_t *child) fsscrub = &priv->fsscrub; (void) gettimeofday (&now, NULL); - timo = br_fsscan_calculate_timeout (fsscan->boot, - now.tv_sec, fsscrub->frequency); + timo = br_fsscan_calculate_timeout (fsscrub->frequency); if (timo == 0) { gf_msg (this->name, GF_LOG_ERROR, 0, BRB_MSG_ZERO_TIMEOUT_BUG, "BUG: Zero schedule timeout"); |