summaryrefslogtreecommitdiffstats
path: root/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c
diff options
context:
space:
mode:
authorVenky Shankar <vshankar@redhat.com>2015-06-04 08:50:48 +0530
committerRaghavendra Bhat <raghavendra@redhat.com>2015-06-25 04:45:19 -0700
commit6ab37f0cb4fd8313dab93360a41acbaf422f39b5 (patch)
tree7ecc921307f5fd083e1ef5f37d1728ecca9140f2 /xlators/features/bit-rot/src/bitd/bit-rot-scrub.c
parent367049879e149e2cd3ec3ba96de7f495a30de180 (diff)
features/bitrot: cleanup, v2
This patch uses "cleanup, v1" infrastrcuture to cleanup scrubber (data structures, threads, timers, etc..) on brick disconnection. Signer is not cleaned up yet: probably would be done as part of another patch. Change-Id: I78a92b8a7f02b2f39078aa9a5a6b101fc499fd70 BUG: 1231619 Signed-off-by: Venky Shankar <vshankar@redhat.com> Reviewed-on: http://review.gluster.org/11148 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Diffstat (limited to 'xlators/features/bit-rot/src/bitd/bit-rot-scrub.c')
-rw-r--r--xlators/features/bit-rot/src/bitd/bit-rot-scrub.c27
1 files changed, 19 insertions, 8 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 bb3f1290026..d9c17260259 100644
--- a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c
+++ b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c
@@ -388,6 +388,14 @@ br_scrubber_scrub_begin (xlator_t *this, struct br_fsscan_entry *fsentry)
}
static void
+_br_lock_cleaner (void *arg)
+{
+ pthread_mutex_t *mutex = arg;
+
+ pthread_mutex_unlock (mutex);
+}
+
+static void
wait_for_scrubbing (xlator_t *this, struct br_scanfs *fsscan)
{
br_private_t *priv = NULL;
@@ -396,8 +404,10 @@ wait_for_scrubbing (xlator_t *this, struct br_scanfs *fsscan)
priv = this->private;
fsscrub = &priv->fsscrub;
+ pthread_cleanup_push (_br_lock_cleaner, &fsscan->waitlock);
pthread_mutex_lock (&fsscan->waitlock);
{
+ pthread_cleanup_push (_br_lock_cleaner, &fsscrub->mutex);
pthread_mutex_lock (&fsscrub->mutex);
{
list_replace_init (&fsscan->queued, &fsscan->ready);
@@ -406,12 +416,14 @@ wait_for_scrubbing (xlator_t *this, struct br_scanfs *fsscan)
pthread_cond_broadcast (&fsscrub->cond);
}
pthread_mutex_unlock (&fsscrub->mutex);
+ pthread_cleanup_pop (0);
while (fsscan->entries != 0)
pthread_cond_wait
(&fsscan->waitcond, &fsscan->waitlock);
}
pthread_mutex_unlock (&fsscan->waitlock);
+ pthread_cleanup_pop (0);
}
static inline void
@@ -460,6 +472,8 @@ br_fsscanner_handle_entry (xlator_t *subvol,
this = child->this;
fsscan = &child->fsscan;
+ _mask_cancellation ();
+
fsentry = GF_CALLOC (1, sizeof (*fsentry), gf_br_mt_br_fsscan_entry_t);
if (!fsentry)
goto error_return;
@@ -494,6 +508,8 @@ br_fsscanner_handle_entry (xlator_t *subvol,
}
UNLOCK (&fsscan->entrylock);
+ _unmask_cancellation ();
+
if (scrub)
wait_for_scrubbing (this, fsscan);
@@ -530,6 +546,7 @@ br_fsscanner_log_time (xlator_t *this, br_child_t *child, const char *sfx)
static void
br_fsscanner_wait_until_kicked (struct br_scanfs *fsscan)
{
+ pthread_cleanup_push (_br_lock_cleaner, &fsscan->wakelock);
pthread_mutex_lock (&fsscan->wakelock);
{
while (!fsscan->kick)
@@ -538,6 +555,7 @@ br_fsscanner_wait_until_kicked (struct br_scanfs *fsscan)
fsscan->kick = _gf_false;
}
pthread_mutex_unlock (&fsscan->wakelock);
+ pthread_cleanup_pop (0);
}
void *
@@ -773,13 +791,6 @@ br_scrubber_calc_scale (xlator_t *this,
}
-static void
-br_scrubber_cleanup_handler (void *arg)
-{
- struct br_scrubber *fsscrub = arg;
- pthread_mutex_unlock (&fsscrub->mutex);
-}
-
static inline br_child_t *
_br_scrubber_get_next_child (struct br_scrubber *fsscrub)
{
@@ -839,7 +850,7 @@ static void
br_scrubber_pick_entry (struct br_scrubber *fsscrub,
struct br_fsscan_entry **fsentry)
{
- pthread_cleanup_push (br_scrubber_cleanup_handler, fsscrub);
+ pthread_cleanup_push (_br_lock_cleaner, &fsscrub->mutex);
pthread_mutex_lock (&fsscrub->mutex);
{