diff options
| author | Poornima G <pgurusid@redhat.com> | 2016-05-16 08:27:41 -0400 | 
|---|---|---|
| committer | Jeff Darcy <jdarcy@redhat.com> | 2016-05-19 07:39:40 -0700 | 
| commit | 6f1a71210ee0a0f3741b5ece3b5240c1e4b5fa6d (patch) | |
| tree | 6227bb2b0db32d6af8912dca6d0646f734da902d | |
| parent | 8816d97faca31026c01c8c60241ebddcb855880e (diff) | |
leases: Do not init the threads when lease is disabled
Change-Id: I08c4caf94bf3dfceba6f7d3cc8945c61d9b12dbc
BUG: 1319992
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>
| -rw-r--r-- | xlators/features/leases/src/leases.c | 72 | ||||
| -rw-r--r-- | xlators/features/leases/src/leases.h | 1 | 
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 c779f1a67e7..77818b2053f 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;  };  | 
