summaryrefslogtreecommitdiffstats
path: root/api/src/glfs-mgmt.c
diff options
context:
space:
mode:
authorPrashanth Pai <ppai@redhat.com>2018-02-09 09:27:03 +0530
committerAmar Tumballi <amarts@redhat.com>2018-02-16 16:16:25 +0000
commit664b946496368f625b5a15646b5aa791078055ef (patch)
tree0a574ce8ed3fee1b6d4fa6811def116ac8d170f6 /api/src/glfs-mgmt.c
parentb313d97faa766443a7f8128b6e19f3d2f1b267dd (diff)
Fetch backup volfile servers from glusterd2
Clients will request for a list of volfile servers from glusterd2 by setting a (optional) flag in GETSPEC RPC call. glusterd2 will check for the presence of this flag and accordingly return a list of glusterd2 servers in GETSPEC RPC reply. Currently, this list of servers returned only contains servers which have bricks belonging to the volume. See: https://github.com/gluster/glusterd2/issues/382 https://github.com/gluster/glusterfs/issues/351 Updates #351 Change-Id: I0eee3d0bf25a87627e562380ef73063926a16b81 Signed-off-by: Prashanth Pai <ppai@redhat.com>
Diffstat (limited to 'api/src/glfs-mgmt.c')
-rw-r--r--api/src/glfs-mgmt.c49
1 files changed, 47 insertions, 2 deletions
diff --git a/api/src/glfs-mgmt.c b/api/src/glfs-mgmt.c
index ac306e40027..f709b54d49e 100644
--- a/api/src/glfs-mgmt.c
+++ b/api/src/glfs-mgmt.c
@@ -580,6 +580,8 @@ glfs_mgmt_getspec_cbk (struct rpc_req *req, struct iovec *iov, int count,
FILE *tmpfp = NULL;
int need_retry = 0;
struct glfs *fs = NULL;
+ dict_t *dict = NULL;
+ char *servers_list = NULL;
frame = myframe;
ctx = frame->this->ctx;
@@ -617,6 +619,44 @@ glfs_mgmt_getspec_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
+ if (!rsp.xdata.xdata_len) {
+ goto volfile;
+ }
+
+ dict = dict_new ();
+ if (!dict) {
+ ret = -1;
+ errno = ENOMEM;
+ goto out;
+ }
+
+ ret = dict_unserialize (rsp.xdata.xdata_val, rsp.xdata.xdata_len,
+ &dict);
+ if (ret) {
+ gf_log (frame->this->name, GF_LOG_ERROR,
+ "failed to unserialize xdata to dictionary");
+ goto out;
+ }
+ dict->extra_stdfree = rsp.xdata.xdata_val;
+
+ /* glusterd2 only */
+ ret = dict_get_str (dict, "servers-list", &servers_list);
+ if (ret) {
+ goto volfile;
+ }
+
+ gf_log (frame->this->name, GF_LOG_INFO,
+ "Received list of available volfile servers: %s",
+ servers_list);
+
+ ret = gf_process_getspec_servers_list(&ctx->cmd_args, servers_list);
+ if (ret) {
+ gf_log (frame->this->name, GF_LOG_ERROR,
+ "Failed (%s) to process servers list: %s",
+ strerror (errno), servers_list);
+ }
+
+volfile:
ret = 0;
size = rsp.op_ret;
@@ -676,8 +716,8 @@ out:
if (rsp.spec)
free (rsp.spec);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ if (dict)
+ dict_unref (dict);
// Stop if server is running at an unsupported op-version
if (ENOTSUP == ret) {
@@ -752,6 +792,11 @@ glfs_volfile_fetch (struct glfs *fs)
goto out;
}
+ /* Ask for a list of volfile (glusterd2 only) servers */
+ if (GF_CLIENT_PROCESS == ctx->process_mode) {
+ req.flags = req.flags | GF_GETSPEC_FLAG_SERVERS_LIST;
+ }
+
ret = dict_allocate_and_serialize (dict, &req.xdata.xdata_val,
&req.xdata.xdata_len);
if (ret < 0) {