summaryrefslogtreecommitdiffstats
path: root/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c
diff options
context:
space:
mode:
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);
{