From 1d9151816d9ef915974081d82fd78b59377b6d1a Mon Sep 17 00:00:00 2001
From: Mohit Agrawal <moagrawa@redhat.com>
Date: Sat, 9 Mar 2019 08:55:44 +0530
Subject: [PATCH 535/538] posix: Deletion of block hosting volume throwing
error "target is busy"
Deletion of block hosting volume with heketi-cli few volumes failed to delete
with the message "target is busy".After analyzing the root cause we found fd
was not closed because janitor thread was killed by posix_fini.To avoid the same before
notifying CHILD_DOWN event to parent all fd's should be closed by janitor_thread.
Note: The patch is applicable only for downstream release, in upstream release
we are using different approach to handle janitor_thread
Change-Id: I8c8482924af1868b4810e708962cd2978c2a40ab
BUG: 1669020
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/164908
Tested-by: RHGS Build Bot <nigelb@redhat.com>
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
---
xlators/storage/posix/src/posix.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index 8a6282d..9efa1f1 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -7115,6 +7115,15 @@ notify (xlator_t *this,
...)
{
xlator_t *victim = data;
+ struct posix_private *priv = NULL;
+ struct timespec sleep_till = {0,};
+
+ if (!this)
+ return 0;
+
+ priv = this->private;
+ if (!priv)
+ return 0;
switch (event)
{
@@ -7128,6 +7137,17 @@ notify (xlator_t *this,
{
if (!victim->cleanup_starting)
break;
+ pthread_mutex_lock (&priv->janitor_lock);
+ {
+ while (!list_empty (&priv->janitor_fds)) {
+ clock_gettime(CLOCK_REALTIME, &sleep_till);
+ sleep_till.tv_sec += 1;
+ (void)pthread_cond_timedwait(&priv->janitor_cond, &priv->janitor_lock,
+ &sleep_till);
+ }
+ }
+ pthread_mutex_unlock (&priv->janitor_lock);
+
gf_log(this->name, GF_LOG_INFO, "Sending CHILD_DOWN for brick %s",
victim->name);
default_notify(this->parents->xlator, GF_EVENT_CHILD_DOWN, data);
--
1.8.3.1