summaryrefslogtreecommitdiffstats
path: root/xlators/features/bit-rot/src/bitd/bit-rot.c
diff options
context:
space:
mode:
authorVenky Shankar <vshankar@redhat.com>2015-06-09 10:02:11 +0530
committerRaghavendra Bhat <raghavendra@redhat.com>2015-07-09 03:29:01 -0700
commita90b7c5d640bc7bf1bd648c69127fd1953e27421 (patch)
tree462c6fa36a9bed62d513f127520a2667df2905d4 /xlators/features/bit-rot/src/bitd/bit-rot.c
parent2874ee4d65185a607f1f646fc88ba8eb400aaa9a (diff)
features/bitrot: handle scrub states via state machine
Backport of http://review.gluster.org/11149 A bunch of command line options for scrubber tempted the use of state machine to track current state of scrubber under various circumstances where the options could be in effect. Change-Id: Id614bb2e6af30a90d2391ea31ae0a3edeb4e0d69 BUG: 1226666 Signed-off-by: Venky Shankar <vshankar@redhat.com> Reviewed-on: http://review.gluster.org/11541 Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators/features/bit-rot/src/bitd/bit-rot.c')
-rw-r--r--xlators/features/bit-rot/src/bitd/bit-rot.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/xlators/features/bit-rot/src/bitd/bit-rot.c b/xlators/features/bit-rot/src/bitd/bit-rot.c
index 2e50268b1fd..551ac9396e9 100644
--- a/xlators/features/bit-rot/src/bitd/bit-rot.c
+++ b/xlators/features/bit-rot/src/bitd/bit-rot.c
@@ -1092,6 +1092,16 @@ br_set_child_state (br_child_t *child, br_child_state_t state)
UNLOCK (&child->lock);
}
+static void
+br_set_scrub_state (br_child_t *child, br_scrub_state_t state)
+{
+ LOCK (&child->lock);
+ {
+ _br_child_set_scrub_state (child, state);
+ }
+ UNLOCK (&child->lock);
+}
+
/**
* At this point a thread is spawned to crawl the filesystem (in
* tortoise pace) to sign objects that were not signed in previous run(s).
@@ -1155,6 +1165,7 @@ br_launch_scrubber (xlator_t *this, br_child_t *child,
priv = this->private;
fsscan->kick = _gf_false;
+ fsscan->over = _gf_false;
ret = gf_thread_create (&child->thread, NULL, br_fsscanner, child);
if (ret != 0) {
gf_msg (this->name, GF_LOG_ALERT, 0, BRB_MSG_SPAWN_FAILED,
@@ -1166,7 +1177,7 @@ br_launch_scrubber (xlator_t *this, br_child_t *child,
/* this needs to be serialized with reconfigure() */
pthread_mutex_lock (&priv->lock);
{
- ret = br_fsscan_schedule (this, child, fsscan, fsscrub);
+ ret = br_scrub_state_machine (this, child);
}
pthread_mutex_unlock (&priv->lock);
if (ret)
@@ -1391,6 +1402,11 @@ br_cleanup_scrubber (xlator_t *this, br_child_t *child)
fsscan->timer = NULL;
}
+ /**
+ * 0x3: reset scrubber state
+ */
+ _br_child_set_scrub_state (child, BR_SCRUB_STATE_INACTIVE);
+
gf_log (this->name, GF_LOG_INFO,
"Cleaned up scrubber for brick [%s]", child->brick_path);
@@ -1779,6 +1795,8 @@ br_init_children (xlator_t *this, br_private_t *priv)
LOCK_INIT (&child->lock);
child->witnessed = 0;
+
+ br_set_scrub_state (child, BR_SCRUB_STATE_INACTIVE);
br_set_child_state (child, BR_CHILD_STATE_DISCONNECTED);
child->this = this;
@@ -1906,13 +1924,11 @@ fini (xlator_t *this)
}
static void
-br_reconfigure_child (xlator_t *this,
- br_child_t *child, struct br_scrubber *fsscrub)
+br_reconfigure_child (xlator_t *this, br_child_t *child)
{
int32_t ret = 0;
- struct br_scanfs *fsscan = &child->fsscan;
- ret = br_fsscan_reschedule (this, child, fsscan, fsscrub, _gf_true);
+ ret = br_scrub_state_machine (this, child);
if (ret) {
gf_log (this->name, GF_LOG_ERROR,
"Could not reschedule scrubber for brick: %s. "
@@ -1924,14 +1940,12 @@ br_reconfigure_child (xlator_t *this,
static int
br_reconfigure_scrubber (xlator_t *this, dict_t *options)
{
- int i = 0;
- int32_t ret = -1;
- br_child_t *child = NULL;
- br_private_t *priv = NULL;
- struct br_scrubber *fsscrub = NULL;
+ int i = 0;
+ int32_t ret = -1;
+ br_child_t *child = NULL;
+ br_private_t *priv = NULL;
priv = this->private;
- fsscrub = &priv->fsscrub;
pthread_mutex_lock (&priv->lock);
{
@@ -1942,7 +1956,7 @@ br_reconfigure_scrubber (xlator_t *this, dict_t *options)
if (ret)
goto err;
- /* reschedule all _up_ subvolume(s) */
+ /* change state for all _up_ subvolume(s) */
for (; i < priv->child_count; i++) {
child = &priv->children[i];
@@ -1957,7 +1971,7 @@ br_reconfigure_scrubber (xlator_t *this, dict_t *options)
}
if (_br_is_child_connected (child))
- br_reconfigure_child (this, child, fsscrub);
+ br_reconfigure_child (this, child);
/**
* for the rest.. either the child is in initialization