summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPoornima G <pgurusid@redhat.com>2016-05-16 08:27:41 -0400
committerRaghavendra Talur <rtalur@redhat.com>2016-05-20 02:33:00 -0700
commit46e85abdac1ab50cedaf1651d2df00adc673afdc (patch)
tree5756650c3b4357ffe71616dd9013abdc5125bf7d
parentd6a23889b174cce1f54560a036d82c84b2bf53c5 (diff)
leases: Do not init the threads when lease is disabled
Backport of http://review.gluster.org/#/c/14360/ Change-Id: I08c4caf94bf3dfceba6f7d3cc8945c61d9b12dbc BUG: 1337638 Signed-off-by: Poornima G <pgurusid@redhat.com> Reviewed-on: http://review.gluster.org/14360 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: Jeff Darcy <jdarcy@redhat.com> Signed-off-by: Poornima G <pgurusid@redhat.com> Reviewed-on: http://review.gluster.org/14433 Reviewed-by: Raghavendra Talur <rtalur@redhat.com>
-rw-r--r--xlators/features/leases/src/leases.c72
-rw-r--r--xlators/features/leases/src/leases.h1
2 files changed, 60 insertions, 13 deletions
diff --git a/xlators/features/leases/src/leases.c b/xlators/features/leases/src/leases.c
index 2c1db34bd9c..4e5ceab3ffa 100644
--- a/xlators/features/leases/src/leases.c
+++ b/xlators/features/leases/src/leases.c
@@ -947,6 +947,41 @@ mem_acct_init (xlator_t *this)
return ret;
}
+static int
+leases_init_priv (xlator_t *this)
+{
+ int ret = 0;
+ leases_private_t *priv = NULL;
+
+ priv = this->private;
+ GF_ASSERT (priv);
+
+ if (!priv->timer_wheel) {
+ if (!glusterfs_global_timer_wheel (this)) {
+ gf_msg_debug (this->name, 0, "Initing the global "
+ "timer wheel");
+ ret = glusterfs_global_timer_wheel_init (this->ctx);
+ if (ret) {
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ LEASE_MSG_NO_TIMER_WHEEL,
+ "Initing the global timer "
+ "wheel failed");
+ goto out;
+ }
+ }
+ priv->timer_wheel = glusterfs_global_timer_wheel (this);
+ }
+
+ if (!priv->inited_recall_thr) {
+ pthread_create (&priv->recall_thr, NULL,
+ expired_recall_cleanup, this);
+ priv->inited_recall_thr = _gf_true;
+ }
+
+out:
+ return ret;
+}
+
int
reconfigure (xlator_t *this, dict_t *options)
{
@@ -956,8 +991,22 @@ reconfigure (xlator_t *this, dict_t *options)
priv = this->private;
GF_ASSERT (priv);
+ /* TODO: In case of reconfigure, if its enabling the leases
+ * its not an issue, but if its disabling the leases, there
+ * is more to it, like recall all the existing leases, wait
+ * for unlock of all the leases etc., hence not supporting the
+ * reconfigure for now.
+
GF_OPTION_RECONF ("leases", priv->leases_enabled,
options, bool, out);
+
+ if (priv->leases_enabled) {
+ ret = leases_init_priv (this);
+ if (ret)
+ goto out;
+ }
+ */
+
GF_OPTION_RECONF ("lease-lock-recall-timeout",
priv->recall_lease_timeout,
options, int32, out);
@@ -989,26 +1038,20 @@ init (xlator_t *this)
INIT_LIST_HEAD (&priv->client_list);
INIT_LIST_HEAD (&priv->recall_list);
- priv->timer_wheel = glusterfs_global_timer_wheel (this);
- if (!priv->timer_wheel) {
- gf_msg_debug (this->name, 0, "Initing the global timer wheel");
- ret = glusterfs_global_timer_wheel_init (this->ctx);
- if (ret) {
- gf_msg (this->name, GF_LOG_ERROR, 0,
- LEASE_MSG_NO_TIMER_WHEEL,
- "Initing the global timer wheel failed");
+ this->private = priv;
+
+ if (priv->leases_enabled) {
+ ret = leases_init_priv (this);
+ if (ret)
goto out;
- }
}
- pthread_create (&priv->recall_thr, NULL, expired_recall_cleanup, this);
-
- this->private = priv;
ret = 0;
out:
if (ret) {
GF_FREE (priv);
+ this->private = NULL;
}
return ret;
@@ -1025,9 +1068,12 @@ fini (xlator_t *this)
}
this->private = NULL;
- priv->fini = _gf_false;
+ priv->fini = _gf_true;
+ pthread_cond_broadcast (&priv->cond);
pthread_join (priv->recall_thr, NULL);
+ priv->inited_recall_thr = _gf_false;
+
GF_FREE (priv);
return 0;
diff --git a/xlators/features/leases/src/leases.h b/xlators/features/leases/src/leases.h
index 16143691075..e9f0286ad28 100644
--- a/xlators/features/leases/src/leases.h
+++ b/xlators/features/leases/src/leases.h
@@ -151,6 +151,7 @@ struct _leases_private {
is qued and waits for unlock/expiry */
gf_boolean_t fini;
pthread_t recall_thr;
+ gf_boolean_t inited_recall_thr;
pthread_mutex_t mutex;
pthread_cond_t cond;
};