summaryrefslogtreecommitdiffstats
path: root/xlators/features/quota
diff options
context:
space:
mode:
authorRaghavendra G <rgowdapp@redhat.com>2014-05-26 10:35:45 +0530
committerRaghavendra G <rgowdapp@redhat.com>2014-06-05 03:32:22 -0700
commita89e35727e3a9a7226c7a16479935b7109b11663 (patch)
tree6e37cdb6c4948f2ab25ffee533a2aac982569562 /xlators/features/quota
parent7801334d4872c3b5c5580ea46654ef0cc0b83658 (diff)
features/quota: unref and set priv->rpc_clnt to NULL once disabled.
Change-Id: Ic1a6bc36b26cf31f00644bd674b24daa11745e64 BUG: 1103636 Signed-off-by: Raghavendra G <rgowdapp@redhat.com> Reviewed-on: http://review.gluster.org/7876 Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators/features/quota')
-rw-r--r--xlators/features/quota/src/quota-enforcer-client.c18
-rw-r--r--xlators/features/quota/src/quota.c27
2 files changed, 31 insertions, 14 deletions
diff --git a/xlators/features/quota/src/quota-enforcer-client.c b/xlators/features/quota/src/quota-enforcer-client.c
index 7d8ab937d1e..a52180936e3 100644
--- a/xlators/features/quota/src/quota-enforcer-client.c
+++ b/xlators/features/quota/src/quota-enforcer-client.c
@@ -336,16 +336,18 @@ quota_enforcer_init (xlator_t *this, dict_t *options)
int ret = -1;
priv = this->private;
- if (priv->rpc_clnt) {
- gf_log (this->name, GF_LOG_TRACE, "quota enforcer clnt already "
- "inited");
- //Turns out to be a NOP if the clnt is already connected.
- ret = quota_enforcer_blocking_connect (priv->rpc_clnt);
- if (ret)
- goto out;
- return priv->rpc_clnt;
+ LOCK (&priv->lock);
+ {
+ if (priv->rpc_clnt) {
+ ret = 0;
+ rpc = priv->rpc_clnt;
+ }
}
+ UNLOCK (&priv->lock);
+
+ if (rpc)
+ goto out;
priv->quota_enforcer = &quota_enforcer_clnt;
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);
}
}