From dcc96757fbafa555a548271c7efd52ca796f9552 Mon Sep 17 00:00:00 2001 From: Samikshan Bairagya Date: Wed, 28 Dec 2016 20:33:54 +0530 Subject: [PATCH 309/361] glusterd: Add info on op-version for clients in vol status output Currently the `gluster volume status clients` command gives us the following information on clients: 1. Brick name 2. Client count for each brick 3. hostname:port for each client 4. Bytes read and written for each client There is no information regarding op-version for each client. This patch adds that to the output. mainline: > BUG: 1409078 > Reviewed-on: http://review.gluster.org/16303 > Smoke: Gluster Build System > NetBSD-regression: NetBSD Build System > CentOS-regression: Gluster Build System > Reviewed-by: Atin Mukherjee (cherry picked from commit fc39ed4d69f7e7f7ca9b3fd100f8be307ae53fe2) BUG: 1351185 Change-Id: Ib2ece93ab00c234162bb92b7c67a7d86f3350a8d Signed-off-by: Samikshan Bairagya Reviewed-on: https://code.engineering.redhat.com/gerrit/101289 Tested-by: Milind Changire Reviewed-by: Atin Mukherjee --- cli/src/cli-rpc-ops.c | 19 +++++++++++++------ cli/src/cli-xml-output.c | 12 ++++++++++++ xlators/protocol/client/src/client-handshake.c | 6 ++++++ xlators/protocol/server/src/server-handshake.c | 18 ++++++++++++++++++ xlators/protocol/server/src/server-messages.h | 11 ++++++++++- xlators/protocol/server/src/server.c | 8 ++++++++ 6 files changed, 67 insertions(+), 7 deletions(-) diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index bea5437..5a0cfdf 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -7253,6 +7253,7 @@ cli_print_volume_status_clients (dict_t *dict, gf_boolean_t notbrick) char *clientname = NULL; uint64_t bytesread = 0; uint64_t byteswrite = 0; + uint32_t opversion = 0; char key[1024] = {0,}; int i = 0; int j = 0; @@ -7318,10 +7319,10 @@ cli_print_volume_status_clients (dict_t *dict, gf_boolean_t notbrick) if (client_count == 0) continue; - cli_out ("%-48s %15s %15s", "Hostname", "BytesRead", - "BytesWritten"); - cli_out ("%-48s %15s %15s", "--------", "---------", - "------------"); + cli_out ("%-48s %15s %15s %15s", "Hostname", "BytesRead", + "BytesWritten", "OpVersion"); + cli_out ("%-48s %15s %15s %15s", "--------", "---------", + "------------", "---------"); for (j =0; j < client_count; j++) { memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), @@ -7338,8 +7339,14 @@ cli_print_volume_status_clients (dict_t *dict, gf_boolean_t notbrick) "brick%d.client%d.byteswrite", i, j); ret = dict_get_uint64 (dict, key, &byteswrite); - cli_out ("%-48s %15"PRIu64" %15"PRIu64, - clientname, bytesread, byteswrite); + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), + "brick%d.client%d.opversion", i, j); + ret = dict_get_uint32 (dict, key, &opversion); + + cli_out ("%-48s %15"PRIu64" %15"PRIu64" %15"PRIu32, + clientname, bytesread, byteswrite, + opversion); } } out: diff --git a/cli/src/cli-xml-output.c b/cli/src/cli-xml-output.c index 063e171..d0d8179 100644 --- a/cli/src/cli-xml-output.c +++ b/cli/src/cli-xml-output.c @@ -743,6 +743,7 @@ cli_xml_output_vol_status_clients (xmlTextWriterPtr writer, dict_t *dict, char *hostname = NULL; uint64_t bytes_read = 0; uint64_t bytes_write = 0; + uint32_t opversion = 0; char key[1024] = {0,}; int i = 0; @@ -797,6 +798,17 @@ cli_xml_output_vol_status_clients (xmlTextWriterPtr writer, dict_t *dict, "%"PRIu64, bytes_write); XML_RET_CHECK_AND_GOTO (ret, out); + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "brick%d.client%d.opversion", + brick_index, i); + ret = dict_get_uint32 (dict, key, &opversion); + if (ret) + goto out; + ret = xmlTextWriterWriteFormatElement (writer, + (xmlChar *)"opVersion", + "%"PRIu32, opversion); + XML_RET_CHECK_AND_GOTO (ret, out); + /* */ ret = xmlTextWriterEndElement (writer); XML_RET_CHECK_AND_GOTO (ret, out); diff --git a/xlators/protocol/client/src/client-handshake.c b/xlators/protocol/client/src/client-handshake.c index 7866697..f51c43f 100644 --- a/xlators/protocol/client/src/client-handshake.c +++ b/xlators/protocol/client/src/client-handshake.c @@ -1379,6 +1379,12 @@ client_setvolume (xlator_t *this, struct rpc_clnt *rpc) "msg", client_get_lk_ver (conf)); } + ret = dict_set_int32 (options, "opversion", GD_OP_VERSION_MAX); + if (ret < 0) { + gf_msg (this->name, GF_LOG_ERROR, 0, PC_MSG_DICT_SET_FAILED, + "Failed to set client opversion in handshake message"); + } + ret = dict_serialized_length (options); if (ret < 0) { gf_msg (this->name, GF_LOG_ERROR, 0, PC_MSG_DICT_ERROR, diff --git a/xlators/protocol/server/src/server-handshake.c b/xlators/protocol/server/src/server-handshake.c index 1230cdf..a33efb8 100644 --- a/xlators/protocol/server/src/server-handshake.c +++ b/xlators/protocol/server/src/server-handshake.c @@ -431,6 +431,8 @@ server_setvolume (rpcsvc_request_t *req) uint32_t lk_version = 0; char *buf = NULL; gf_boolean_t cancelled = _gf_false; + uint32_t opversion = 0; + rpc_transport_t *xprt = NULL; params = dict_new (); reply = dict_new (); @@ -669,6 +671,22 @@ server_setvolume (rpcsvc_request_t *req) gf_msg_debug (this->name, 0, "failed to set " "peer-info"); } + + ret = dict_get_uint32 (params, "opversion", &opversion); + if (ret) + gf_msg (this->name, GF_LOG_INFO, 0, + PS_MSG_CLIENT_OPVERSION_GET_FAILED, + "Failed to get client opversion"); + + /* Assign op-version value to the client */ + pthread_mutex_lock (&conf->mutex); + list_for_each_entry (xprt, &conf->xprt_list, list) { + if (strcmp (peerinfo->identifier, xprt->peerinfo.identifier)) + continue; + xprt->peerinfo.max_op_version = opversion; + } + pthread_mutex_unlock (&conf->mutex); + if (conf->auth_modules == NULL) { gf_msg (this->name, GF_LOG_ERROR, 0, PS_MSG_AUTH_INIT_FAILED, "Authentication module not initialized"); diff --git a/xlators/protocol/server/src/server-messages.h b/xlators/protocol/server/src/server-messages.h index 5593e68..b8245af 100644 --- a/xlators/protocol/server/src/server-messages.h +++ b/xlators/protocol/server/src/server-messages.h @@ -40,7 +40,7 @@ */ #define GLFS_PS_BASE GLFS_MSGID_COMP_PS -#define GLFS_NUM_MESSAGES 90 +#define GLFS_NUM_MESSAGES 91 #define GLFS_MSGID_END (GLFS_PS_BASE + GLFS_NUM_MESSAGES + 1) /* Messages with message IDs */ #define glfs_msg_start_x GLFS_PS_BASE, "Invalid: Start of messages" @@ -848,6 +848,15 @@ */ #define PS_MSG_COMPOUND_INFO (GLFS_PS_BASE + 90) + +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ + +#define PS_MSG_CLIENT_OPVERSION_GET_FAILED (GLFS_PS_BASE + 91) /*------------*/ #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c index 0bbfd09..db4338e 100644 --- a/xlators/protocol/server/src/server.c +++ b/xlators/protocol/server/src/server.c @@ -276,6 +276,14 @@ server_priv_to_dict (xlator_t *this, dict_t *dict) if (ret) goto unlock; + memset (key, 0, sizeof (key)); + snprintf (key, sizeof (key), "client%d.opversion", + count); + ret = dict_set_uint32 (dict, key, + peerinfo->max_op_version); + if (ret) + goto unlock; + count++; } } -- 1.8.3.1