From c810ea1e2ba5c15b11808e2bd378e95c428b7f96 Mon Sep 17 00:00:00 2001 From: Poornima G Date: Mon, 4 Apr 2016 07:13:09 -0400 Subject: rpc : Change the way client uuid is built Problem: Today the main users of client uuid are protocol layers, locks, leases. Protocol layers requires each client uuid to be unique, even across connects and disconnects. Locks and leases on the server side also use the same client uid which changes across file migrations. Which makes the graph switch and file migration tedious for locks and leases. file migration across bricks becomes difficult as client uuid for the same client, is different on the other brick. The exact set of issues exists for leases as well. Solution would be to introduce a constant in the client-uid string which the locks and leases can use to identify the owner client across bricks. Client uuid currently: %s(ctx uuid)-%s(protocol client name)-%d(graph id)%s(setvolume count/reconnect count) Proposed Client uuid: "CTX_ID:%s-GRAPH_ID:%d-PID:%d-HOST:%s-PC_NAME:%s-RECON_NO:%s" - CTX_ID: This is will be constant per client. - GRAPH_ID, PID, HOST, PC_NAME(protocol client name), RECON_NO(setvolume count) remains the same. Change-Id: Ia81d57a9693207cd325d7b26aee4593fcbd6482c BUG: 1369028 Signed-off-by: Susant Palai --- xlators/protocol/client/src/client-handshake.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'xlators/protocol/client') diff --git a/xlators/protocol/client/src/client-handshake.c b/xlators/protocol/client/src/client-handshake.c index 587e256b51a..ca3d140d08e 100644 --- a/xlators/protocol/client/src/client-handshake.c +++ b/xlators/protocol/client/src/client-handshake.c @@ -1312,6 +1312,7 @@ client_setvolume (xlator_t *this, struct rpc_clnt *rpc) clnt_conf_t *conf = NULL; dict_t *options = NULL; char counter_str[32] = {0}; + char hostname[256] = {0,}; options = this->options; conf = this->private; @@ -1354,9 +1355,17 @@ client_setvolume (xlator_t *this, struct rpc_clnt *rpc) "-%"PRIu64, conf->setvol_count); conf->setvol_count++; } - ret = gf_asprintf (&process_uuid_xl, "%s-%s-%d%s", - this->ctx->process_uuid, this->name, - this->graph->id, counter_str); + + if (gethostname (hostname, 256) == -1) { + gf_msg (this->name, GF_LOG_ERROR, errno, + LG_MSG_GETHOSTNAME_FAILED, "gethostname: failed"); + + goto fail; + } + + ret = gf_asprintf (&process_uuid_xl, GLUSTER_PROCESS_UUID_FMT, + this->ctx->process_uuid, this->graph->id, getpid(), + hostname, this->name, counter_str); if (-1 == ret) { gf_msg (this->name, GF_LOG_ERROR, 0, PC_MSG_PROCESS_UUID_SET_FAIL, "asprintf failed while " -- cgit