diff options
| author | Kaushal M <kaushal@redhat.com> | 2012-11-28 16:22:15 +0530 | 
|---|---|---|
| committer | Anand Avati <avati@redhat.com> | 2013-02-06 12:17:06 -0800 | 
| commit | 02d653931c8967accf766014efce0c2dce340cdf (patch) | |
| tree | 20b354f959f1973be332708c5d0a54d7bc3d8a66 /xlators/mgmt | |
| parent | 242c12bf602acc3cdb4517cd1b6b06d5099fee0f (diff) | |
glusterd,glusterfsd,libgfapi: Client op-version
This patch introduces op-version support for glusterfs clients.
Now, a client sends its supported op-versions during the volfile fetch request
and glusterd will return the volfile only if the client can support the current
op-version of the cluster.
Change-Id: Iab1f1f1706802962bcf27058657c44e8a344d2f6
BUG: 907311
Signed-off-by: Kaushal M <kaushal@redhat.com>
Reviewed-on: http://review.gluster.org/4247
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/mgmt')
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handshake.c | 72 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd.h | 17 | 
2 files changed, 69 insertions, 20 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c index 6a273df54b6..5b3299d549a 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handshake.c +++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c @@ -124,7 +124,17 @@ server_getspec (rpcsvc_request_t *req)          gf_getspec_req        args                   = {0,};          gf_getspec_rsp        rsp                    = {0,};          char                  addrstr[RPCSVC_PEER_STRLEN] = {0}; +        dict_t               *dict                   = NULL; +        xlator_t             *this                   = NULL; +        glusterd_conf_t      *conf                   = NULL; +        int                   client_min_op_version  = 0; +        int                   client_max_op_version  = 0; +        this = THIS; +        GF_ASSERT (this); + +        conf = this->private; +        GF_ASSERT (conf);          ret = xdr_to_generic (req->msg[0], &args,                                (xdrproc_t)xdr_gf_getspec_req); @@ -134,6 +144,63 @@ server_getspec (rpcsvc_request_t *req)                  goto fail;          } +        if (!args.xdata.xdata_len) { +                // For clients <= 3.3.0, only allow if op_version = 1 +                if (1 != conf->op_version) { +                        ret = -1; +                        op_errno = ENOTSUP; +                        gf_log (this->name, GF_LOG_INFO, +                                "Client %s doesn't support required op-version. " +                                "Rejecting getspec request.", +                                req->trans->peerinfo.identifier); +                        goto fail; +                } +        } else { +                // For clients > 3.3, only allow if they can support +                // clusters' op_version +                dict = dict_new (); +                if (!dict) { +                        ret = -1; +                        goto fail; +                } + +                ret = dict_unserialize (args.xdata.xdata_val, +                                        args.xdata.xdata_len, &dict); +                if (ret) { +                        gf_log (this->name, GF_LOG_ERROR, +                                "Failed to unserialize request dictionary"); +                        goto fail; +                } + +                ret = dict_get_int32 (dict, "min-op-version", +                                      &client_min_op_version); +                if (ret) { +                        gf_log (this->name, GF_LOG_ERROR, +                                "Failed to get client-min-op-version"); +                        goto fail; +                } + +                ret = dict_get_int32 (dict, "max-op-version", +                                      &client_max_op_version); +                if (ret) { +                        gf_log (this->name, GF_LOG_ERROR, +                                "Failed to get client-max-op-version"); +                        goto fail; +                } + +                if ((client_min_op_version > conf->op_version) || +                    (client_max_op_version < conf->op_version)) { +                        ret = -1; +                        op_errno = ENOTSUP; +                        //TODO: Add client identifier +                        gf_log (this->name, GF_LOG_INFO, +                                "Client %s doesn't support required op-version. " +                                "Rejecting getspec request.", +                                req->trans->peerinfo.identifier); +                        goto fail; +                } +        } +          volume = args.key;          trans = req->trans; @@ -387,7 +454,7 @@ glusterd_mgmt_hndsk_versions_ack (rpcsvc_request_t *req)          glusterd_conf_t   *conf            = NULL;          int                ret             = -1;          int                op_errno        = EINVAL; -        int32_t            peer_op_version = 0; +        int                peer_op_version = 0;          gf_mgmt_hndsk_req  args            = {{0,},};          gf_mgmt_hndsk_rsp  rsp             = {0,}; @@ -406,8 +473,7 @@ glusterd_mgmt_hndsk_versions_ack (rpcsvc_request_t *req)                                        (args.hndsk.hndsk_len), ret, op_errno,                                        out); -        ret = dict_get_int32 (clnt_dict, GD_OP_VERSION_KEY, -                              &peer_op_version); +        ret = dict_get_int32 (clnt_dict, GD_OP_VERSION_KEY, &peer_op_version);          if (ret) {                  gf_log (this->name, GF_LOG_WARNING,                          "failed to get the op-version key peer=%s", diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h index f7bfad697e8..95e23674c57 100644 --- a/xlators/mgmt/glusterd/src/glusterd.h +++ b/xlators/mgmt/glusterd/src/glusterd.h @@ -114,23 +114,6 @@ typedef struct {          gf_boolean_t            online;  } nodesrv_t; -#define GD_OP_VERSION_KEY     "operating-version" -#define GD_MIN_OP_VERSION_KEY "minimum-operating-version" -#define GD_MAX_OP_VERSION_KEY "maxium-operating-version" - -/* Gluster versions - OP-VERSION mapping - * - * 3.3.0                - 1 - * 3.3.Next/3.Next      - 2 - * - * (TODO: Change above comment once gluster version is finalised) - */ -#define GD_OP_VERSION_MIN  1 /* MIN is the fresh start op-version, mostly -                                should not change */ -#define GD_OP_VERSION_MAX  2 /* MAX VERSION is the maximum count in VME table, -                                should keep changing with introduction of newer -                                versions */ -  typedef struct {          gf_boolean_t    quorum;          double          quorum_ratio;  | 
