summaryrefslogtreecommitdiffstats
path: root/api/src
diff options
context:
space:
mode:
authorKaushal M <kaushal@redhat.com>2012-11-28 16:22:15 +0530
committerAnand Avati <avati@redhat.com>2013-02-06 12:17:06 -0800
commit02d653931c8967accf766014efce0c2dce340cdf (patch)
tree20b354f959f1973be332708c5d0a54d7bc3d8a66 /api/src
parent242c12bf602acc3cdb4517cd1b6b06d5099fee0f (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 'api/src')
-rw-r--r--api/src/glfs-mgmt.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/api/src/glfs-mgmt.c b/api/src/glfs-mgmt.c
index 2ead93863bc..a76692bfd06 100644
--- a/api/src/glfs-mgmt.c
+++ b/api/src/glfs-mgmt.c
@@ -477,6 +477,13 @@ out:
if (rsp.spec)
free (rsp.spec);
+ // Stop if server is running at an unsupported op-version
+ if (ENOTSUP == ret) {
+ gf_log ("mgmt", GF_LOG_ERROR, "Server is operating at an "
+ "op-version which is not supported");
+ glfs_init_done (fs, -1);
+ }
+
if (ret && ctx && !ctx->active) {
/* Do it only for the first time */
/* Failed to get the volume file, something wrong,
@@ -503,6 +510,7 @@ glfs_volfile_fetch (struct glfs *fs)
int ret = 0;
call_frame_t *frame = NULL;
glusterfs_ctx_t *ctx = NULL;
+ dict_t *dict = NULL;
ctx = fs->ctx;
cmd_args = &ctx->cmd_args;
@@ -512,10 +520,41 @@ glfs_volfile_fetch (struct glfs *fs)
req.key = cmd_args->volfile_id;
req.flags = 0;
+ dict = dict_new ();
+ if (!dict) {
+ ret = -1;
+ goto out;
+ }
+
+ // Set the supported min and max op-versions, so glusterd can make a
+ // decision
+ ret = dict_set_int32 (dict, "min-op-version", GD_OP_VERSION_MIN);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "Failed to set min-op-version"
+ " in request dict");
+ goto out;
+ }
+
+ ret = dict_set_int32 (dict, "max-op-version", GD_OP_VERSION_MAX);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR, "Failed to set max-op-version"
+ " in request dict");
+ goto out;
+ }
+
+ ret = dict_allocate_and_serialize (dict, &req.xdata.xdata_val,
+ &req.xdata.xdata_len);
+ if (ret < 0) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "Failed to serialize dictionary");
+ goto out;
+ }
+
ret = mgmt_submit_request (&req, frame, ctx, &clnt_handshake_prog,
GF_HNDSK_GETSPEC, mgmt_getspec_cbk,
(xdrproc_t)xdr_gf_getspec_req);
- return ret;
+out:
+ return ret;
}