summaryrefslogtreecommitdiffstats
path: root/xlators/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/protocol')
-rw-r--r--xlators/protocol/client/src/client-handshake.c7
-rw-r--r--xlators/protocol/server/src/server-handshake.c31
2 files changed, 22 insertions, 16 deletions
diff --git a/xlators/protocol/client/src/client-handshake.c b/xlators/protocol/client/src/client-handshake.c
index e6a5e84f422..0437f1f272d 100644
--- a/xlators/protocol/client/src/client-handshake.c
+++ b/xlators/protocol/client/src/client-handshake.c
@@ -836,8 +836,7 @@ client_setvolume_cbk(struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
} else {
- strncpy(ctx->volume_id, volume_id,
- min(strlen(volume_id), GF_UUID_BUF_SIZE));
+ strncpy(ctx->volume_id, volume_id, GF_UUID_BUF_SIZE);
}
}
@@ -1036,6 +1035,10 @@ client_setvolume(xlator_t *this, struct rpc_clnt *rpc)
if (strncmp("snapd", remote_subvol, 5)) {
/* If any value is set, the first element will be non-0.
It would be '0', but not '\0' :-) */
+ if (!this->ctx->volume_id[0]) {
+ strncpy(this->ctx->volume_id, this->graph->volume_id,
+ GF_UUID_BUF_SIZE);
+ }
if (this->ctx->volume_id[0]) {
ret = dict_set_str(options, "volume-id", this->ctx->volume_id);
if (ret < 0) {
diff --git a/xlators/protocol/server/src/server-handshake.c b/xlators/protocol/server/src/server-handshake.c
index 1f347db4f77..dda58b60ca0 100644
--- a/xlators/protocol/server/src/server-handshake.c
+++ b/xlators/protocol/server/src/server-handshake.c
@@ -409,22 +409,25 @@ server_setvolume(rpcsvc_request_t *req)
client_name = "unknown";
}
- ret = dict_get_str_sizen(params, "volume-id", &volume_id);
- if (!ret && strcmp(xl->graph->volume_id, volume_id)) {
- ret = dict_set_str(reply, "ERROR",
- "Volume-ID different, possible case "
- "of same brick re-used in another volume");
- if (ret < 0)
- gf_msg_debug(this->name, 0, "failed to set error msg");
+ /* If any value is set, the first element will be non-0.
+ It would be '0', but not '\0' :-) */
+ if (xl->graph->volume_id[0]) {
+ ret = dict_get_str_sizen(params, "volume-id", &volume_id);
+ if (!ret && strcmp(xl->graph->volume_id, volume_id)) {
+ ret = dict_set_str(reply, "ERROR",
+ "Volume-ID different, possible case "
+ "of same brick re-used in another volume");
+ if (ret < 0)
+ gf_msg_debug(this->name, 0, "failed to set error msg");
- op_ret = -1;
- op_errno = EINVAL;
- goto fail;
+ op_ret = -1;
+ op_errno = EINVAL;
+ goto fail;
+ }
+ ret = dict_set_str(reply, "volume-id", tmp->volume_id);
+ if (ret)
+ gf_msg_debug(this->name, 0, "failed to set 'volume-id'");
}
- ret = dict_set_str(reply, "volume-id", tmp->volume_id);
- if (ret)
- gf_msg_debug(this->name, 0, "failed to set 'volume-id'");
-
client = gf_client_get(this, &req->cred, client_uid, subdir_mount);
if (client == NULL) {
op_ret = -1;