summaryrefslogtreecommitdiffstats
path: root/xlators/protocol/server/src/server-handshake.c
diff options
context:
space:
mode:
authorAmar Tumballi <amar@kadalu.io>2019-11-17 11:00:50 +0530
committerXavi Hernandez <xhernandez@redhat.com>2019-11-29 07:01:53 +0000
commit1bfb0a750c6fcd0bbf4d68a1890704f0aefe6337 (patch)
tree2e83e49dd2b68a96984f093be8309d23dc1cf8ac /xlators/protocol/server/src/server-handshake.c
parent7c1e383876ad15ec6fc93d412311662f42390a11 (diff)
debug/io-stats: add an option to set volume-id
'volume-id' is good to have for a graph for uniquely identifying it. Add it to graph->volume_id while generating volfile itself. This can be further used in many other places. Updates: #763 Change-Id: I80516d62d28a284e8ff4707841570ced97a37e73 Signed-off-by: Amar Tumballi <amar@kadalu.io>
Diffstat (limited to 'xlators/protocol/server/src/server-handshake.c')
-rw-r--r--xlators/protocol/server/src/server-handshake.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/xlators/protocol/server/src/server-handshake.c b/xlators/protocol/server/src/server-handshake.c
index 1f347db..dda58b6 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;