From a89e35727e3a9a7226c7a16479935b7109b11663 Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Mon, 26 May 2014 10:35:45 +0530 Subject: features/quota: unref and set priv->rpc_clnt to NULL once disabled. Change-Id: Ic1a6bc36b26cf31f00644bd674b24daa11745e64 BUG: 1103636 Signed-off-by: Raghavendra G Reviewed-on: http://review.gluster.org/7876 Reviewed-by: Krishnan Parthasarathi Tested-by: Gluster Build System --- xlators/features/quota/src/quota.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'xlators/features/quota/src/quota.c') diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c index 06ef9615a19..0bfa05e0596 100644 --- a/xlators/features/quota/src/quota.c +++ b/xlators/features/quota/src/quota.c @@ -4268,8 +4268,9 @@ quota_forget (xlator_t *this, inode_t *inode) int32_t init (xlator_t *this) { - int32_t ret = -1; - quota_priv_t *priv = NULL; + int32_t ret = -1; + quota_priv_t *priv = NULL; + rpc_clnt_t *rpc = NULL; if ((this->children == NULL) || this->children->next) { @@ -4308,13 +4309,19 @@ init (xlator_t *this) } if (priv->is_quota_on) { - priv->rpc_clnt = quota_enforcer_init (this, this->options); - if (priv->rpc_clnt == NULL) { + rpc = quota_enforcer_init (this, this->options); + if (rpc == NULL) { ret = -1; gf_log (this->name, GF_LOG_WARNING, "quota enforcer rpc init failed"); goto err; } + + LOCK (&priv->lock); + { + priv->rpc_clnt = rpc; + } + UNLOCK (&priv->lock); } ret = 0; @@ -4328,6 +4335,7 @@ reconfigure (xlator_t *this, dict_t *options) int32_t ret = -1; quota_priv_t *priv = NULL; gf_boolean_t quota_on = _gf_false; + rpc_clnt_t *rpc = NULL; priv = this->private; @@ -4355,13 +4363,20 @@ reconfigure (xlator_t *this, dict_t *options) } } else { - if (priv->rpc_clnt) { + LOCK (&priv->lock); + { + rpc = priv->rpc_clnt; + priv->rpc_clnt = NULL; + } + UNLOCK (&priv->lock); + + if (rpc != NULL) { // Quotad is shutdown when there is no started volume // which has quota enabled. So, we should disable the // enforcer client when quota is disabled on a volume, // to avoid spurious reconnect attempts to a service // (quotad), that is known to be down. - rpc_clnt_disable (priv->rpc_clnt); + rpc_clnt_unref (rpc); } } -- cgit