diff options
Diffstat (limited to 'xlators/protocol/server/src/server-handshake.c')
-rw-r--r-- | xlators/protocol/server/src/server-handshake.c | 87 |
1 files changed, 45 insertions, 42 deletions
diff --git a/xlators/protocol/server/src/server-handshake.c b/xlators/protocol/server/src/server-handshake.c index 8886221aa92..b2d50e106b6 100644 --- a/xlators/protocol/server/src/server-handshake.c +++ b/xlators/protocol/server/src/server-handshake.c @@ -20,6 +20,7 @@ #include "compat-errno.h" #include "glusterfs3.h" #include "authenticate.h" +#include "client_t.h" struct __get_xl_struct { const char *name; @@ -94,9 +95,9 @@ _volfile_update_checksum (xlator_t *this, char *key, uint32_t checksum) if (temp_volfile->checksum != checksum) { gf_log (this->name, GF_LOG_INFO, - "the volume file got modified between earlier access " - "and now, this may lead to inconsistency between " - "clients, advised to remount client"); + "the volume file was modified between a prior access " + "and now. This may lead to inconsistency between " + "clients, you are advised to remount client"); temp_volfile->checksum = checksum; } @@ -109,10 +110,10 @@ static size_t getspec_build_volfile_path (xlator_t *this, const char *key, char *path, size_t path_len) { - int ret = -1; + char *filename = NULL; + server_conf_t *conf = NULL; + int ret = -1; int free_filename = 0; - char *filename = NULL; - server_conf_t *conf = NULL; char data_key[256] = {0,}; conf = this->private; @@ -329,14 +330,14 @@ server_setvolume (rpcsvc_request_t *req) { gf_setvolume_req args = {{0,},}; gf_setvolume_rsp rsp = {0,}; - server_connection_t *conn = NULL; + client_t *client = NULL; server_conf_t *conf = NULL; peer_info_t *peerinfo = NULL; dict_t *reply = NULL; dict_t *config_params = NULL; dict_t *params = NULL; char *name = NULL; - char *process_uuid = NULL; + char *client_uid = NULL; char *clnt_version = NULL; xlator_t *xl = NULL; char *msg = NULL; @@ -393,7 +394,7 @@ server_setvolume (rpcsvc_request_t *req) params->extra_free = buf; buf = NULL; - ret = dict_get_str (params, "process-uuid", &process_uuid); + ret = dict_get_str (params, "process-uuid", &client_uid); if (ret < 0) { ret = dict_set_str (reply, "ERROR", "UUID not specified"); @@ -420,25 +421,26 @@ server_setvolume (rpcsvc_request_t *req) goto fail; } - conn = server_connection_get (this, process_uuid); - if (!conn) { + client = gf_client_get (this, &req->cred, client_uid); + if (client == NULL) { op_ret = -1; op_errno = ENOMEM; goto fail; } - gf_log (this->name, GF_LOG_DEBUG, "Connected to %s", conn->id); - cancelled = server_cancel_conn_timer (this, conn); - if (cancelled)//Do connection_put on behalf of grace-timer-handler. - server_connection_put (this, conn, NULL); - if (conn->lk_version != 0 && - conn->lk_version != lk_version) { - (void) server_connection_cleanup (this, conn, + gf_log (this->name, GF_LOG_DEBUG, "Connected to %s", + client->server_ctx.client_uid); + cancelled = server_cancel_grace_timer (this, client); + if (cancelled)//Do gf_client_put on behalf of grace-timer-handler. + gf_client_put (client, NULL); + if (client->server_ctx.lk_version != 0 && + client->server_ctx.lk_version != lk_version) { + (void) server_connection_cleanup (this, client, INTERNAL_LOCKS | POSIX_LOCKS); } - if (req->trans->xl_private != conn) - req->trans->xl_private = conn; + if (req->trans->xl_private != client) + req->trans->xl_private = client; ret = dict_get_int32 (params, "fops-version", &fop_version); if (ret < 0) { @@ -563,10 +565,10 @@ server_setvolume (rpcsvc_request_t *req) gf_log (this->name, GF_LOG_INFO, "accepted client from %s (version: %s)", - conn->id, + client->server_ctx.client_uid, (clnt_version) ? clnt_version : "old"); op_ret = 0; - conn->bound_xl = xl; + client->bound_xl = xl; ret = dict_set_str (reply, "ERROR", "Success"); if (ret < 0) gf_log (this->name, GF_LOG_DEBUG, @@ -574,7 +576,7 @@ server_setvolume (rpcsvc_request_t *req) } else { gf_log (this->name, GF_LOG_ERROR, "Cannot authenticate client from %s %s", - conn->id, + client->server_ctx.client_uid, (clnt_version) ? clnt_version : "old"); op_ret = -1; @@ -586,7 +588,7 @@ server_setvolume (rpcsvc_request_t *req) goto fail; } - if (conn->bound_xl == NULL) { + if (client->bound_xl == NULL) { ret = dict_set_str (reply, "ERROR", "Check volfile and handshake " "options in protocol/client"); @@ -599,20 +601,21 @@ server_setvolume (rpcsvc_request_t *req) goto fail; } - if ((conn->bound_xl != NULL) && + if ((client->bound_xl != NULL) && (ret >= 0) && - (conn->bound_xl->itable == NULL)) { + (client->bound_xl->itable == NULL)) { /* create inode table for this bound_xl, if one doesn't already exist */ gf_log (this->name, GF_LOG_TRACE, "creating inode table with lru_limit=%"PRId32", " "xlator=%s", conf->inode_lru_limit, - conn->bound_xl->name); + client->bound_xl->name); /* TODO: what is this ? */ - conn->bound_xl->itable = inode_table_new (conf->inode_lru_limit, - conn->bound_xl); + client->bound_xl->itable = + inode_table_new (conf->inode_lru_limit, + client->bound_xl); } ret = dict_set_str (reply, "process-uuid", @@ -622,7 +625,7 @@ server_setvolume (rpcsvc_request_t *req) "failed to set 'process-uuid'"); ret = dict_set_uint32 (reply, "clnt-lk-version", - conn->lk_version); + client->server_ctx.lk_version); if (ret) gf_log (this->name, GF_LOG_WARNING, "failed to set 'clnt-lk-version'"); @@ -664,15 +667,15 @@ fail: * list of connections the server is maintaining and might segfault * during statedump when bound_xl of the connection is accessed. */ - if (op_ret && conn && !xl) { + if (op_ret && !xl) { /* We would have set the xl_private of the transport to the * @conn. But if we have put the connection i.e shutting down * the connection, then we should set xl_private to NULL as it * would be pointing to a freed memory and would segfault when * accessed upon getting DISCONNECT. */ - if (server_connection_put (this, conn, NULL) == NULL) - req->trans->xl_private = NULL; + gf_client_put (client, NULL); + req->trans->xl_private = NULL; } server_submit_reply (NULL, req, &rsp, NULL, 0, NULL, (xdrproc_t)xdr_gf_setvolume_rsp); @@ -709,12 +712,12 @@ server_ping (rpcsvc_request_t *req) int server_set_lk_version (rpcsvc_request_t *req) { - int op_ret = -1; - int op_errno = EINVAL; - gf_set_lk_ver_req args = {0, }; - gf_set_lk_ver_rsp rsp = {0,}; - server_connection_t *conn = NULL; - xlator_t *this = NULL; + int op_ret = -1; + int op_errno = EINVAL; + gf_set_lk_ver_req args = {0,}; + gf_set_lk_ver_rsp rsp = {0,}; + client_t *client = NULL; + xlator_t *this = NULL; this = req->svc->mydata; //TODO: Decide on an appropriate errno for the error-path @@ -730,9 +733,9 @@ server_set_lk_version (rpcsvc_request_t *req) goto fail; } - conn = server_connection_get (this, args.uid); - conn->lk_version = args.lk_ver; - server_connection_put (this, conn, NULL); + client = gf_client_get (this, &req->cred, args.uid); + client->server_ctx.lk_version = args.lk_ver; + gf_client_put (client, NULL); rsp.lk_ver = args.lk_ver; |