summaryrefslogtreecommitdiffstats
path: root/xlators/features/bit-rot/src/bitd/bit-rot-ssm.c
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2016-04-29 17:45:31 +0530
committerVenky Shankar <vshankar@redhat.com>2016-05-19 23:18:25 -0700
commite63049cba0f2b94b0b082cc8bfd5921b8443ef45 (patch)
tree90037fc5942b63cddcfda8ecec6e7d6b8cd5b015 /xlators/features/bit-rot/src/bitd/bit-rot-ssm.c
parent2e2ef4f833abe28f7895ea022654aac74e353702 (diff)
features/bitrot: Introduce scrubber monitor thread
The patch does following changes. 1. Introduce scrubber monitor thread. 2. Move scrub status related APIs to separate file and make part of libbitrot library. Problem: Earlier, each child of the scrubber was maintaining the state machine and hence there was no way to track the start and end time of scrubbing as each brick has it's own start and end time. Also each brick was maintaining it's own timer wheel instance. It was also not possible to get scrubbed files count per session as we could not get last child which finishes scrubbing to reset it to zero. Solution: Introduce scrubber monitor thread. It does following. 1. Maintains the scrubber state machine. Earlier each child had it's own state machine. Now, only monitor maintains on behalf of all it's children. 2. Maintains the timer wheel instance. Earlier each child had it's own timer wheel instance. Now, only monitor maintains on behalf of all it's children. As a result, we can track the scrub statistics easily and correctly. Upstream master: http://review.gluster.org/14044 http://review.gluster.org/#/c/14146 Upstream 3.7: http://review.gluster.org/14140 NOTE: The patch #14146 is a compilation warning not detected in master branch and detected only in 3.7 branch. Since the compilation warning is introduced by patch #14044, the above two backports are made into this single patch in 3.7 and the same is backported to 3.8. BUG: 1332839 Change-Id: I1cec0b229c851fec793a1288c23e43bcec755cba Signed-off-by: Kotresh HR <khiremat@redhat.com> Reviewed-on: http://review.gluster.org/14201 Smoke: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Venky Shankar <vshankar@redhat.com>
Diffstat (limited to 'xlators/features/bit-rot/src/bitd/bit-rot-ssm.c')
-rw-r--r--xlators/features/bit-rot/src/bitd/bit-rot-ssm.c65
1 files changed, 43 insertions, 22 deletions
diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-ssm.c b/xlators/features/bit-rot/src/bitd/bit-rot-ssm.c
index fcffc04feda..d304fc804ee 100644
--- a/xlators/features/bit-rot/src/bitd/bit-rot-ssm.c
+++ b/xlators/features/bit-rot/src/bitd/bit-rot-ssm.c
@@ -12,52 +12,73 @@
#include "bit-rot-scrub.h"
#include "bit-rot-bitd-messages.h"
-int br_scrub_ssm_noop (xlator_t *this, br_child_t *child)
+int br_scrub_ssm_noop (xlator_t *this)
{
return 0;
}
int
-br_scrub_ssm_state_pause (xlator_t *this, br_child_t *child)
+br_scrub_ssm_state_pause (xlator_t *this)
{
+ br_private_t *priv = NULL;
+ struct br_monitor *scrub_monitor = NULL;
+
+ priv = this->private;
+ scrub_monitor = &priv->scrub_monitor;
+
gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_GENERIC_SSM_INFO,
- "Scrubber paused [Brick: %s]", child->brick_path);
- _br_child_set_scrub_state (child, BR_SCRUB_STATE_PAUSED);
+ "Scrubber paused");
+ _br_monitor_set_scrub_state (scrub_monitor, BR_SCRUB_STATE_PAUSED);
return 0;
}
int
-br_scrub_ssm_state_ipause (xlator_t *this, br_child_t *child)
+br_scrub_ssm_state_ipause (xlator_t *this)
{
+ br_private_t *priv = NULL;
+ struct br_monitor *scrub_monitor = NULL;
+
+ priv = this->private;
+ scrub_monitor = &priv->scrub_monitor;
+
gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_GENERIC_SSM_INFO,
- "Scrubber paused [Brick: %s]", child->brick_path);
- _br_child_set_scrub_state (child, BR_SCRUB_STATE_IPAUSED);
+ "Scrubber paused");
+ _br_monitor_set_scrub_state (scrub_monitor, BR_SCRUB_STATE_IPAUSED);
return 0;
}
int
-br_scrub_ssm_state_active (xlator_t *this, br_child_t *child)
+br_scrub_ssm_state_active (xlator_t *this)
{
- struct br_scanfs *fsscan = &child->fsscan;
+ br_private_t *priv = NULL;
+ struct br_monitor *scrub_monitor = NULL;
- if (fsscan->over) {
- (void) br_fsscan_activate (this, child);
+ priv = this->private;
+ scrub_monitor = &priv->scrub_monitor;
+
+ if (scrub_monitor->done) {
+ (void) br_fsscan_activate (this);
} else {
gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_GENERIC_SSM_INFO,
- "Scrubbing resumed [Brick %s]", child->brick_path);
- _br_child_set_scrub_state (child, BR_SCRUB_STATE_ACTIVE);
+ "Scrubbing resumed");
+ _br_monitor_set_scrub_state (scrub_monitor, BR_SCRUB_STATE_ACTIVE);
}
return 0;
}
int
-br_scrub_ssm_state_stall (xlator_t *this, br_child_t *child)
+br_scrub_ssm_state_stall (xlator_t *this)
{
+ br_private_t *priv = NULL;
+ struct br_monitor *scrub_monitor = NULL;
+
+ priv = this->private;
+ scrub_monitor = &priv->scrub_monitor;
+
gf_msg (this->name, GF_LOG_INFO, 0, BRB_MSG_GENERIC_SSM_INFO,
- "Brick [%s] is under active scrubbing. Pausing scrub..",
- child->brick_path);
- _br_child_set_scrub_state (child, BR_SCRUB_STATE_STALLED);
+ "Volume is under active scrubbing. Pausing scrub..");
+ _br_monitor_set_scrub_state (scrub_monitor, BR_SCRUB_STATE_STALLED);
return 0;
}
@@ -72,22 +93,22 @@ br_scrub_ssm[BR_SCRUB_MAXSTATES][BR_SCRUB_MAXEVENTS] = {
};
int32_t
-br_scrub_state_machine (xlator_t *this, br_child_t *child)
+br_scrub_state_machine (xlator_t *this)
{
br_private_t *priv = NULL;
br_scrub_ssm_call *call = NULL;
- struct br_scanfs *fsscan = NULL;
struct br_scrubber *fsscrub = NULL;
br_scrub_state_t currstate = 0;
br_scrub_event_t event = 0;
+ struct br_monitor *scrub_monitor = NULL;
priv = this->private;
- fsscan = &child->fsscan;
fsscrub = &priv->fsscrub;
+ scrub_monitor = &priv->scrub_monitor;
- currstate = fsscan->state;
+ currstate = scrub_monitor->state;
event = _br_child_get_scrub_event (fsscrub);
call = br_scrub_ssm[currstate][event];
- return call (this, child);
+ return call (this);
}