diff options
author | Krishnan Parthasarathi <kparthas@redhat.com> | 2013-08-30 11:35:25 +0530 |
---|---|---|
committer | Gerrit Code Review <review@dev.gluster.org> | 2013-09-24 23:20:54 -0700 |
commit | a19e50c4a653995619d7814bfbb44b0f85ed9569 (patch) | |
tree | cfdcec23a3f955d88a16d36f2edc6430871ec927 | |
parent | ce8fbc6f8549fe6377823252731c36d77b4fdbce (diff) |
quota-enforcer: initialize enforcer rpc iff quota is enabled
Details:
--------
In init, we should create an rpc only when quota is enabled
on the volume.
In reconfigure, we should reuse the enforcer rpc, if any, on
enable. On disable, we should disable the enforcer rpc, if present.
Change-Id: I03e9f7b2b6dfecd1e8d97f0fb2df3db717e4ad50
Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com>
-rw-r--r-- | xlators/features/quota/src/quota-enforcer-client.c | 14 | ||||
-rw-r--r-- | xlators/features/quota/src/quota.c | 35 |
2 files changed, 41 insertions, 8 deletions
diff --git a/xlators/features/quota/src/quota-enforcer-client.c b/xlators/features/quota/src/quota-enforcer-client.c index 99bfc163..d2863c7a 100644 --- a/xlators/features/quota/src/quota-enforcer-client.c +++ b/xlators/features/quota/src/quota-enforcer-client.c @@ -298,6 +298,8 @@ quota_enforcer_notify (struct rpc_clnt *rpc, void *mydata, return ret; } +//Returns a started rpc_clnt. Creates a new rpc_clnt if quota_priv doesn't have +//one already struct rpc_clnt * quota_enforcer_init (xlator_t *this, dict_t *options) { @@ -306,6 +308,13 @@ 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. + rpc_clnt_start (priv->rpc_clnt); + return priv->rpc_clnt; + } priv->quota_enforcer = "a_enforcer_clnt; ret = dict_set_str (options, "transport.address-family", "unix"); @@ -322,8 +331,10 @@ quota_enforcer_init (xlator_t *this, dict_t *options) goto out; rpc = rpc_clnt_new (options, this->ctx, this->name, 16); - if (!rpc) + if (!rpc) { + ret = -1; goto out; + } ret = rpc_clnt_register_notify (rpc, quota_enforcer_notify, this); if (ret) { @@ -339,7 +350,6 @@ out: rpc = NULL; } - priv->rpc_clnt = rpc; return rpc; } diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c index c1fd0ee1..fcba44d1 100644 --- a/xlators/features/quota/src/quota.c +++ b/xlators/features/quota/src/quota.c @@ -519,7 +519,7 @@ quota_validate (call_frame_t *frame, inode_t *inode, xlator_t *this, int ret = 0; dict_t *xdata = NULL; quota_priv_t *priv = NULL; - + local = frame->local; priv = this->private; @@ -3896,11 +3896,14 @@ init (xlator_t *this) goto err; } - priv->rpc_clnt = quota_enforcer_init (this, this->options); - if (priv->rpc_clnt == NULL) { - ret = -1; - gf_log (this->name, GF_LOG_WARNING, - "rpc init failed"); + if (priv->is_quota_on) { + priv->rpc_clnt = quota_enforcer_init (this, this->options); + if (priv->rpc_clnt == NULL) { + ret = -1; + gf_log (this->name, GF_LOG_WARNING, + "quota enforcer rpc init failed"); + goto err; + } } ret = 0; @@ -3929,6 +3932,26 @@ reconfigure (xlator_t *this, dict_t *options) GF_OPTION_RECONF ("hard-timeout", priv->hard_timeout, options, time, out); + if (priv->is_quota_on) { + priv->rpc_clnt = quota_enforcer_init (this, + this->options); + if (priv->rpc_clnt == NULL) { + ret = -1; + gf_log (this->name, GF_LOG_WARNING, + "quota enforcer rpc init failed"); + goto out; + } + + } else { + if (priv->rpc_clnt) { + // 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); + } + } ret = 0; out: |