diff options
| author | vmallika <vmallika@redhat.com> | 2015-04-28 11:53:24 +0530 | 
|---|---|---|
| committer | Vijay Bellur <vbellur@redhat.com> | 2015-04-28 10:28:39 -0700 | 
| commit | a7e04388e03f3706c40be9d9444784a1579ed51d (patch) | |
| tree | 7fd120f8efed48c888fd849c12d1b9c03d513fe4 | |
| parent | bb86ba720aa9a89b0d2df5f2a6ac65c87edd260b (diff) | |
quota: display error when inode-quota cmds executed with cluster ver < 3.7
This is a backport of http://review.gluster.org/#/c/10261/
> In a heterogeneous cluster with op_version less than 3.7, inode quotas will
> be accounted on those bricks which has glusterfs version 3.7 and this is
> not available in older version.
> This will have incorrect values displayed when user queries inode count
> from CLI.
>
> This patch will display error when inode-quota commands
> are executed with cluster version less than 3.7
>
> Change-Id: Ia0e6d5635d1d8e7b2e2cfc3daa7b7f9e314a263a
> BUG: 1212253
> Signed-off-by: vmallika <vmallika@redhat.com>
> Reviewed-on: http://review.gluster.org/10261
> Tested-by: Gluster Build System <jenkins@build.gluster.com>
> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Change-Id: I1ddd605e5b87a248aa85f0eab14c404895751083
BUG: 1215907
Signed-off-by: vmallika <vmallika@redhat.com>
Reviewed-on: http://review.gluster.org/10415
Tested-by: NetBSD Build System
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
| -rw-r--r-- | rpc/xdr/src/cli1-xdr.x | 1 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-quota.c | 67 | 
2 files changed, 45 insertions, 23 deletions
diff --git a/rpc/xdr/src/cli1-xdr.x b/rpc/xdr/src/cli1-xdr.x index 922f22613eb..189df0e0ccc 100644 --- a/rpc/xdr/src/cli1-xdr.x +++ b/rpc/xdr/src/cli1-xdr.x @@ -73,6 +73,7 @@ enum gf_quota_type {          GF_QUOTA_OPTION_TYPE_SOFT_TIMEOUT,          GF_QUOTA_OPTION_TYPE_HARD_TIMEOUT,          GF_QUOTA_OPTION_TYPE_DEFAULT_SOFT_LIMIT, +        GF_QUOTA_OPTION_TYPE_VERSION_OBJECTS,          GF_QUOTA_OPTION_TYPE_LIMIT_OBJECTS,          GF_QUOTA_OPTION_TYPE_LIST_OBJECTS,          GF_QUOTA_OPTION_TYPE_REMOVE_OBJECTS, diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c index a137e82b230..97fa4380656 100644 --- a/xlators/mgmt/glusterd/src/glusterd-quota.c +++ b/xlators/mgmt/glusterd/src/glusterd-quota.c @@ -57,13 +57,47 @@ const char *gd_quota_op_list[GF_QUOTA_OPTION_TYPE_MAX + 1] = {          [GF_QUOTA_OPTION_TYPE_DEFAULT_SOFT_LIMIT] = "default-soft-limit",          [GF_QUOTA_OPTION_TYPE_LIMIT_OBJECTS]      = "limit-objects",          [GF_QUOTA_OPTION_TYPE_LIST_OBJECTS]       = "list-objects", -        [GF_QUOTA_OPTION_TYPE_REMOVE_OBJECTS]     = "remove-objetcs", +        [GF_QUOTA_OPTION_TYPE_REMOVE_OBJECTS]     = "remove-objects",          [GF_QUOTA_OPTION_TYPE_MAX]                = NULL  };  int  glusterd_store_quota_config (glusterd_volinfo_t *volinfo, char *path,                               char *gfid_str, int opcode, char **op_errstr); + +gf_boolean_t +glusterd_is_quota_supported (int32_t type, char **op_errstr) +{ +        xlator_t           *this        = NULL; +        glusterd_conf_t    *conf        = NULL; +        gf_boolean_t        supported   = _gf_false; + +        this = THIS; +        GF_VALIDATE_OR_GOTO ("glusterd", this, out); + +        conf = this->private; +        GF_VALIDATE_OR_GOTO (this->name, conf, out); + +        if ((conf->op_version == GD_OP_VERSION_MIN) && +            (type > GF_QUOTA_OPTION_TYPE_VERSION)) +                goto out; + +        if ((conf->op_version < GD_OP_VERSION_3_7_0) && +            (type > GF_QUOTA_OPTION_TYPE_VERSION_OBJECTS)) +                goto out; + +        supported = _gf_true; + +out: +        if (!supported && op_errstr != NULL && conf) +                gf_asprintf (op_errstr, "Volume quota failed. The cluster is " +                             "operating at version %d. Quota command" +                             " %s is unavailable in this version.", +                             conf->op_version, gd_quota_op_list[type]); + +        return supported; +} +  int  __glusterd_handle_quota (rpcsvc_request_t *req)  { @@ -121,18 +155,17 @@ __glusterd_handle_quota (rpcsvc_request_t *req)                  snprintf (msg, sizeof (msg), "Unable to get type of command");                  gf_log (this->name, GF_LOG_ERROR, "Unable to get type of cmd, "                          "while handling quota command"); -               goto out; +                goto out;          } -        if ((conf->op_version == GD_OP_VERSION_MIN) && -            (type > GF_QUOTA_OPTION_TYPE_VERSION)) { -                snprintf (msg, sizeof (msg), "Cannot execute command. The " -                         "cluster is operating at version %d. Quota command %s " -                         "is unavailable in this version", conf->op_version, -                         gd_quota_op_list[type]); +        if (!glusterd_is_quota_supported (type, NULL)) { +                snprintf (msg, sizeof (msg), "Volume quota failed. The cluster " +                          "is operating at version %d. Quota command" +                          " %s is unavailable in this version.", +                          conf->op_version, gd_quota_op_list[type]);                  ret = -1;                  goto out; -       } +        }          ret = glusterd_op_begin_synctask (req, GD_OP_QUOTA, dict); @@ -1090,13 +1123,7 @@ glusterd_op_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict)          ret = dict_get_int32 (dict, "type", &type); -        if ((priv->op_version == GD_OP_VERSION_MIN) && -            (type > GF_QUOTA_OPTION_TYPE_VERSION)) { -                gf_asprintf (op_errstr, "Volume quota failed. The cluster is " -                                        "operating at version %d. Quota command" -                                        " %s is unavailable in this version.", -                                        priv->op_version, -                                        gd_quota_op_list[type]); +        if (!glusterd_is_quota_supported (type, op_errstr)) {                  ret = -1;                  goto out;          } @@ -1421,13 +1448,7 @@ glusterd_op_stage_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict)                  goto out;          } -        if ((priv->op_version == GD_OP_VERSION_MIN) && -            (type > GF_QUOTA_OPTION_TYPE_VERSION)) { -                gf_asprintf (op_errstr, "Volume quota failed. The cluster is " -                                        "operating at version %d. Quota command" -                                        " %s is unavailable in this version.", -                                         priv->op_version, -                                         gd_quota_op_list[type]); +        if (!glusterd_is_quota_supported (type, op_errstr)) {                  ret = -1;                  goto out;          }  | 
