21ab4e
From f7dac49b41df49897b8555b922129bf7f76f60d8 Mon Sep 17 00:00:00 2001
21ab4e
From: Kotresh HR <khiremat@redhat.com>
21ab4e
Date: Thu, 15 Jun 2017 08:31:06 -0400
21ab4e
Subject: [PATCH 518/525] feature/bitrot: Fix ondemand scrub
21ab4e
21ab4e
The flag which keeps tracks of whether the scrub
21ab4e
frequency is changed from previous value should
21ab4e
not be considered for on-demand scrubbing. It
21ab4e
should be considered only for 'scrub-frequency'
21ab4e
where it should not be re-scheduled if it is
21ab4e
set to same value again. But in case ondemand
21ab4e
scrub, it should start the scrub immediately
21ab4e
no matter what the scrub-frequency.
21ab4e
21ab4e
Reproducer:
21ab4e
1. Enable bitrot
21ab4e
2. Set scrub-throttle
21ab4e
3. Set ondemand scrub
21ab4e
Make sure glusterd is not restarted while doing
21ab4e
above steps
21ab4e
21ab4e
> Change-Id: Ice5feaece7fff1579fb009d1a59d2b8292e23e0b
21ab4e
> BUG: 1461845
21ab4e
> Signed-off-by: Kotresh HR <khiremat@redhat.com>
21ab4e
> Reviewed-on: https://review.gluster.org/17552
21ab4e
> Smoke: Gluster Build System <jenkins@build.gluster.org>
21ab4e
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
21ab4e
> Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
21ab4e
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
21ab4e
21ab4e
Change-Id: Ice5feaece7fff1579fb009d1a59d2b8292e23e0b
21ab4e
BUG: 1454596
21ab4e
Signed-off-by: Kotresh HR <khiremat@redhat.com>
21ab4e
Reviewed-on: https://code.engineering.redhat.com/gerrit/109279
21ab4e
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
21ab4e
---
21ab4e
 xlators/features/bit-rot/src/bitd/bit-rot-scrub.c | 5 -----
21ab4e
 xlators/features/bit-rot/src/bitd/bit-rot.c       | 8 +++++++-
21ab4e
 2 files changed, 7 insertions(+), 6 deletions(-)
21ab4e
21ab4e
diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c
21ab4e
index 265fe60..8d25941 100644
21ab4e
--- a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c
21ab4e
+++ b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c
21ab4e
@@ -1049,16 +1049,11 @@ br_fsscan_ondemand (xlator_t *this)
21ab4e
         char timestr[1024]          = {0,};
21ab4e
         struct timeval      now     = {0,};
21ab4e
         br_private_t       *priv    = NULL;
21ab4e
-        struct br_scrubber *fsscrub = NULL;
21ab4e
         struct br_monitor  *scrub_monitor = NULL;
21ab4e
 
21ab4e
         priv = this->private;
21ab4e
-        fsscrub = &priv->fsscrub;
21ab4e
         scrub_monitor = &priv->scrub_monitor;
21ab4e
 
21ab4e
-        if (!fsscrub->frequency_reconf)
21ab4e
-                return 0;
21ab4e
-
21ab4e
         (void) gettimeofday (&now, NULL);
21ab4e
 
21ab4e
         timo = BR_SCRUB_ONDEMAND;
21ab4e
diff --git a/xlators/features/bit-rot/src/bitd/bit-rot.c b/xlators/features/bit-rot/src/bitd/bit-rot.c
21ab4e
index 6d60ca4..d88231b 100644
21ab4e
--- a/xlators/features/bit-rot/src/bitd/bit-rot.c
21ab4e
+++ b/xlators/features/bit-rot/src/bitd/bit-rot.c
21ab4e
@@ -1680,8 +1680,14 @@ notify (xlator_t *this, int32_t event, void *data, ...)
21ab4e
                 gf_log (this->name, GF_LOG_INFO, "BitRot scrub ondemand "
21ab4e
                               "called");
21ab4e
 
21ab4e
-                if (scrub_monitor->state != BR_SCRUB_STATE_PENDING)
21ab4e
+                if (scrub_monitor->state != BR_SCRUB_STATE_PENDING) {
21ab4e
+                        gf_msg (this->name, GF_LOG_ERROR, 0,
21ab4e
+                                BRB_MSG_RESCHEDULE_SCRUBBER_FAILED,
21ab4e
+                                "on demand scrub schedule failed. Scrubber is "
21ab4e
+                                "not in pending state. Current state is %d",
21ab4e
+                                 scrub_monitor->state);
21ab4e
                         return -2;
21ab4e
+                }
21ab4e
 
21ab4e
                 /* Needs synchronization with reconfigure thread */
21ab4e
                 pthread_mutex_lock (&priv->lock);
21ab4e
-- 
21ab4e
1.8.3.1
21ab4e