diff options
author | Krishnan Parthasarathi <kparthas@redhat.com> | 2013-09-24 23:32:29 -0700 |
---|---|---|
committer | Gerrit Code Review <review@dev.gluster.org> | 2013-09-24 23:32:29 -0700 |
commit | bf32c7f905b1bce24f1dd45994f2476e189930c9 (patch) | |
tree | 6dff8d65481777968ebeaaf07f7b8e82c1b2762a | |
parent | 2a0b0aa78f1d7fdbfd2457c1303aaf0cfdcbb7ff (diff) | |
parent | a19e50c4a653995619d7814bfbb44b0f85ed9569 (diff) |
Merge "quota-enforcer: initialize enforcer rpc iff quota is enabled" into upstream_on_quota
-rw-r--r-- | xlators/features/quota/src/quota-enforcer-client.c | 14 | ||||
-rw-r--r-- | xlators/features/quota/src/quota.c | 33 |
2 files changed, 40 insertions, 7 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 603eb351..9a182d2c 100644 --- a/xlators/features/quota/src/quota.c +++ b/xlators/features/quota/src/quota.c @@ -3911,11 +3911,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; @@ -3944,6 +3947,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: |