summaryrefslogtreecommitdiffstats
path: root/xlators/protocol/client/src/client-handshake.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/protocol/client/src/client-handshake.c')
-rw-r--r--xlators/protocol/client/src/client-handshake.c762
1 files changed, 254 insertions, 508 deletions
diff --git a/xlators/protocol/client/src/client-handshake.c b/xlators/protocol/client/src/client-handshake.c
index ed9d0a5d9d8..ea5ef5c1800 100644
--- a/xlators/protocol/client/src/client-handshake.c
+++ b/xlators/protocol/client/src/client-handshake.c
@@ -8,13 +8,13 @@
cases as published by the Free Software Foundation.
*/
-#include "fd-lk.h"
+#include <glusterfs/fd-lk.h>
#include "client.h"
-#include "xlator.h"
-#include "defaults.h"
-#include "glusterfs.h"
-#include "statedump.h"
-#include "compat-errno.h"
+#include <glusterfs/xlator.h>
+#include <glusterfs/defaults.h>
+#include <glusterfs/glusterfs.h>
+#include <glusterfs/statedump.h>
+#include <glusterfs/compat-errno.h>
#include "glusterfs3.h"
#include "portmap-xdr.h"
@@ -27,14 +27,6 @@ extern rpc_clnt_prog_t clnt3_3_fop_prog;
extern rpc_clnt_prog_t clnt4_0_fop_prog;
extern rpc_clnt_prog_t clnt_pmap_prog;
-typedef struct client_fd_lk_local {
- gf_atomic_t ref;
- gf_boolean_t error;
- gf_lock_t lock;
- clnt_fd_ctx_t *fdctx;
-} clnt_fd_lk_local_t;
-
-
int32_t
client3_getspec(call_frame_t *frame, xlator_t *this, void *data)
{
@@ -42,7 +34,7 @@ client3_getspec(call_frame_t *frame, xlator_t *this, void *data)
return 0;
}
-int
+static int
client_notify_parents_child_up(xlator_t *this)
{
clnt_conf_t *conf = NULL;
@@ -55,219 +47,18 @@ client_notify_parents_child_up(xlator_t *this)
if (conf->child_up) {
ret = client_notify_dispatch_uniq(this, GF_EVENT_CHILD_UP, NULL);
if (ret) {
- gf_msg(this->name, GF_LOG_INFO, 0, PC_MSG_CHILD_UP_NOTIFY_FAILED,
- "notify of CHILD_UP failed");
+ gf_smsg(this->name, GF_LOG_INFO, 0, PC_MSG_CHILD_UP_NOTIFY_FAILED,
+ NULL);
goto out;
}
} else {
- gf_msg(this->name, GF_LOG_INFO, 0, PC_MSG_CHILD_STATUS,
- "Defering sending CHILD_UP message as the client "
- "translators are not yet ready to serve.");
+ gf_smsg(this->name, GF_LOG_INFO, 0, PC_MSG_CHILD_STATUS, NULL);
}
out:
return 0;
}
-int
-clnt_fd_lk_reacquire_failed(xlator_t *this, clnt_fd_ctx_t *fdctx,
- clnt_conf_t *conf)
-{
- int ret = -1;
-
- GF_VALIDATE_OR_GOTO("client", this, out);
- GF_VALIDATE_OR_GOTO(this->name, conf, out);
- GF_VALIDATE_OR_GOTO(this->name, fdctx, out);
-
- pthread_spin_lock(&conf->fd_lock);
- {
- fdctx->remote_fd = -1;
- }
- pthread_spin_unlock(&conf->fd_lock);
-
- ret = 0;
-out:
- return ret;
-}
-
-int
-client_fd_lk_count(fd_lk_ctx_t *lk_ctx)
-{
- int count = 0;
- fd_lk_ctx_node_t *fd_lk = NULL;
-
- GF_VALIDATE_OR_GOTO("client", lk_ctx, err);
-
- LOCK(&lk_ctx->lock);
- {
- list_for_each_entry(fd_lk, &lk_ctx->lk_list, next) count++;
- }
- UNLOCK(&lk_ctx->lock);
-
- return count;
-err:
- return -1;
-}
-
-clnt_fd_lk_local_t *
-clnt_fd_lk_local_ref(xlator_t *this, clnt_fd_lk_local_t *local)
-{
- GF_VALIDATE_OR_GOTO(this->name, local, out);
-
- GF_ATOMIC_INC(local->ref);
-out:
- return local;
-}
-
-int
-clnt_fd_lk_local_unref(xlator_t *this, clnt_fd_lk_local_t *local)
-{
- int ref = -1;
-
- GF_VALIDATE_OR_GOTO(this->name, local, out);
-
- ref = GF_ATOMIC_DEC(local->ref);
-
- if (ref == 0) {
- LOCK_DESTROY(&local->lock);
- GF_FREE(local);
- }
-out:
- return ref;
-}
-
-clnt_fd_lk_local_t *
-clnt_fd_lk_local_create(clnt_fd_ctx_t *fdctx)
-{
- clnt_fd_lk_local_t *local = NULL;
-
- local = GF_CALLOC(1, sizeof(clnt_fd_lk_local_t),
- gf_client_mt_clnt_fd_lk_local_t);
- if (!local)
- goto out;
-
- GF_ATOMIC_INIT(local->ref, 1);
- local->error = _gf_false;
- local->fdctx = fdctx;
-
- LOCK_INIT(&local->lock);
-out:
- return local;
-}
-
-int
-clnt_release_reopen_fd_cbk(struct rpc_req *req, struct iovec *iov, int count,
- void *myframe)
-{
- xlator_t *this = NULL;
- call_frame_t *frame = NULL;
- clnt_conf_t *conf = NULL;
- clnt_fd_ctx_t *fdctx = NULL;
-
- frame = myframe;
- this = frame->this;
- fdctx = (clnt_fd_ctx_t *)frame->local;
- conf = (clnt_conf_t *)this->private;
-
- clnt_fd_lk_reacquire_failed(this, fdctx, conf);
-
- fdctx->reopen_done(fdctx, fdctx->remote_fd, this);
-
- frame->local = NULL;
- STACK_DESTROY(frame->root);
-
- return 0;
-}
-
-int
-clnt_release_reopen_fd(xlator_t *this, clnt_fd_ctx_t *fdctx)
-{
- int ret = -1;
- clnt_conf_t *conf = NULL;
- call_frame_t *frame = NULL;
- gfs3_release_req req = {
- {
- 0,
- },
- };
-
- conf = (clnt_conf_t *)this->private;
-
- frame = create_frame(this, this->ctx->pool);
- if (!frame)
- goto out;
-
- frame->local = (void *)fdctx;
- req.fd = fdctx->remote_fd;
-
- ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_RELEASE,
- clnt_release_reopen_fd_cbk, NULL, NULL, 0, NULL,
- 0, NULL, (xdrproc_t)xdr_gfs3_releasedir_req);
-out:
- if (ret) {
- clnt_fd_lk_reacquire_failed(this, fdctx, conf);
- fdctx->reopen_done(fdctx, fdctx->remote_fd, this);
- }
- return 0;
-}
-
-int
-clnt_reacquire_lock_error(xlator_t *this, clnt_fd_ctx_t *fdctx,
- clnt_conf_t *conf)
-{
- int32_t ret = -1;
-
- GF_VALIDATE_OR_GOTO("client", this, out);
- GF_VALIDATE_OR_GOTO(this->name, fdctx, out);
- GF_VALIDATE_OR_GOTO(this->name, conf, out);
-
- clnt_release_reopen_fd(this, fdctx);
-
- ret = 0;
-out:
- return ret;
-}
-
-gf_boolean_t
-clnt_fd_lk_local_error_status(xlator_t *this, clnt_fd_lk_local_t *local)
-{
- gf_boolean_t error = _gf_false;
-
- LOCK(&local->lock);
- {
- error = local->error;
- }
- UNLOCK(&local->lock);
-
- return error;
-}
-
-int
-clnt_fd_lk_local_mark_error(xlator_t *this, clnt_fd_lk_local_t *local)
-{
- int32_t ret = -1;
- clnt_conf_t *conf = NULL;
- gf_boolean_t error = _gf_false;
-
- GF_VALIDATE_OR_GOTO("client", this, out);
- GF_VALIDATE_OR_GOTO(this->name, local, out);
-
- conf = (clnt_conf_t *)this->private;
-
- LOCK(&local->lock);
- {
- error = local->error;
- local->error = _gf_true;
- }
- UNLOCK(&local->lock);
-
- if (!error)
- clnt_reacquire_lock_error(this, local->fdctx, conf);
- ret = 0;
-out:
- return ret;
-}
-
void
client_default_reopen_done(clnt_fd_ctx_t *fdctx, int64_t rfd, xlator_t *this)
{
@@ -275,14 +66,12 @@ client_default_reopen_done(clnt_fd_ctx_t *fdctx, int64_t rfd, xlator_t *this)
"This function should never be called");
}
-void
+static void
client_reopen_done(clnt_fd_ctx_t *fdctx, int64_t rfd, xlator_t *this)
{
- clnt_conf_t *conf = NULL;
+ clnt_conf_t *conf = this->private;
gf_boolean_t destroy = _gf_false;
- conf = this->private;
-
pthread_spin_lock(&conf->fd_lock);
{
fdctx->remote_fd = rfd;
@@ -299,14 +88,12 @@ client_reopen_done(clnt_fd_ctx_t *fdctx, int64_t rfd, xlator_t *this)
client_fdctx_destroy(this, fdctx);
}
-void
+static void
client_child_up_reopen_done(clnt_fd_ctx_t *fdctx, int64_t rfd, xlator_t *this)
{
- clnt_conf_t *conf = NULL;
+ clnt_conf_t *conf = this->private;
uint64_t fd_count = 0;
- conf = this->private;
-
LOCK(&conf->rec_lock);
{
fd_count = --(conf->reopen_fd_count);
@@ -315,8 +102,7 @@ client_child_up_reopen_done(clnt_fd_ctx_t *fdctx, int64_t rfd, xlator_t *this)
client_reopen_done(fdctx, rfd, this);
if (fd_count == 0) {
- gf_msg(this->name, GF_LOG_INFO, 0, PC_MSG_CHILD_UP_NOTIFY,
- "last fd open'd/lock-self-heal'd - notifying CHILD-UP");
+ gf_smsg(this->name, GF_LOG_INFO, 0, PC_MSG_CHILD_UP_NOTIFY, NULL);
client_notify_parents_child_up(this);
}
}
@@ -329,21 +115,14 @@ client3_3_reopen_cbk(struct rpc_req *req, struct iovec *iov, int count,
gfs3_open_rsp rsp = {
0,
};
- clnt_local_t *local = NULL;
- clnt_fd_ctx_t *fdctx = NULL;
- call_frame_t *frame = NULL;
- xlator_t *this = NULL;
-
- frame = myframe;
- this = frame->this;
- local = frame->local;
- fdctx = local->fdctx;
+ call_frame_t *frame = myframe;
+ xlator_t *this = frame->this;
+ clnt_local_t *local = frame->local;
+ clnt_fd_ctx_t *fdctx = local->fdctx;
if (-1 == req->rpc_status) {
- gf_msg(frame->this->name, GF_LOG_WARNING, ENOTCONN,
- PC_MSG_RPC_STATUS_ERROR,
- "received RPC status error, "
- "returning ENOTCONN");
+ gf_smsg(frame->this->name, GF_LOG_WARNING, ENOTCONN,
+ PC_MSG_RPC_STATUS_ERROR, NULL);
rsp.op_ret = -1;
rsp.op_errno = ENOTCONN;
goto out;
@@ -351,16 +130,16 @@ client3_3_reopen_cbk(struct rpc_req *req, struct iovec *iov, int count,
ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_open_rsp);
if (ret < 0) {
- gf_msg(frame->this->name, GF_LOG_ERROR, EINVAL,
- PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed");
+ gf_smsg(frame->this->name, GF_LOG_ERROR, EINVAL,
+ PC_MSG_XDR_DECODING_FAILED, NULL);
rsp.op_ret = -1;
rsp.op_errno = EINVAL;
goto out;
}
if (rsp.op_ret < 0) {
- gf_msg(frame->this->name, GF_LOG_WARNING, rsp.op_errno,
- PC_MSG_DIR_OP_SUCCESS, "reopen on %s failed.", local->loc.path);
+ gf_smsg(frame->this->name, GF_LOG_WARNING, rsp.op_errno,
+ PC_MSG_REOPEN_FAILED, "path=%s", local->loc.path);
} else {
gf_msg_debug(frame->this->name, 0,
"reopen on %s succeeded (remote-fd = %" PRId64 ")",
@@ -368,12 +147,9 @@ client3_3_reopen_cbk(struct rpc_req *req, struct iovec *iov, int count,
}
if (rsp.op_ret == -1) {
- ret = -1;
goto out;
}
- ret = 0;
-
out:
fdctx->reopen_done(fdctx, (rsp.op_ret) ? -1 : rsp.fd, this);
@@ -393,19 +169,13 @@ client3_3_reopendir_cbk(struct rpc_req *req, struct iovec *iov, int count,
gfs3_open_rsp rsp = {
0,
};
- clnt_local_t *local = NULL;
- clnt_fd_ctx_t *fdctx = NULL;
- call_frame_t *frame = NULL;
-
- frame = myframe;
- local = frame->local;
- fdctx = local->fdctx;
+ call_frame_t *frame = myframe;
+ clnt_local_t *local = frame->local;
+ clnt_fd_ctx_t *fdctx = local->fdctx;
if (-1 == req->rpc_status) {
- gf_msg(frame->this->name, GF_LOG_WARNING, ENOTCONN,
- PC_MSG_RPC_STATUS_ERROR,
- "received RPC status error, "
- "returning ENOTCONN");
+ gf_smsg(frame->this->name, GF_LOG_WARNING, ENOTCONN,
+ PC_MSG_RPC_STATUS_ERROR, NULL);
rsp.op_ret = -1;
rsp.op_errno = ENOTCONN;
goto out;
@@ -413,25 +183,22 @@ client3_3_reopendir_cbk(struct rpc_req *req, struct iovec *iov, int count,
ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_opendir_rsp);
if (ret < 0) {
- gf_msg(frame->this->name, GF_LOG_ERROR, EINVAL,
- PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed");
+ gf_smsg(frame->this->name, GF_LOG_ERROR, EINVAL,
+ PC_MSG_XDR_DECODING_FAILED, NULL);
rsp.op_ret = -1;
rsp.op_errno = EINVAL;
goto out;
}
if (rsp.op_ret < 0) {
- gf_msg(frame->this->name, GF_LOG_WARNING, rsp.op_errno,
- PC_MSG_DIR_OP_FAILED, "reopendir on %s failed", local->loc.path);
+ gf_smsg(frame->this->name, GF_LOG_WARNING, rsp.op_errno,
+ PC_MSG_REOPEN_FAILED, "path=%s", local->loc.path, NULL);
} else {
- gf_msg(frame->this->name, GF_LOG_INFO, 0, PC_MSG_DIR_OP_SUCCESS,
- "reopendir on %s succeeded "
- "(fd = %" PRId64 ")",
- local->loc.path, rsp.fd);
+ gf_smsg(frame->this->name, GF_LOG_INFO, 0, PC_MSG_DIR_OP_SUCCESS,
+ "path=%s", local->loc.path, "fd=%" PRId64, rsp.fd, NULL);
}
if (-1 == rsp.op_ret) {
- ret = -1;
goto out;
}
@@ -462,7 +229,6 @@ protocol_client_reopendir(clnt_fd_ctx_t *fdctx, xlator_t *this)
local = mem_get0(this->local_pool);
if (!local) {
- ret = -1;
goto out;
}
local->fdctx = fdctx;
@@ -474,7 +240,6 @@ protocol_client_reopendir(clnt_fd_ctx_t *fdctx, xlator_t *this)
frame = create_frame(this, this->ctx->pool);
if (!frame) {
- ret = -1;
goto out;
}
@@ -486,11 +251,10 @@ protocol_client_reopendir(clnt_fd_ctx_t *fdctx, xlator_t *this)
frame->local = local;
ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_OPENDIR,
- client3_3_reopendir_cbk, NULL, NULL, 0, NULL, 0,
- NULL, (xdrproc_t)xdr_gfs3_opendir_req);
+ client3_3_reopendir_cbk, NULL,
+ (xdrproc_t)xdr_gfs3_opendir_req);
if (ret) {
- gf_msg(this->name, GF_LOG_ERROR, 0, PC_MSG_DIR_OP_FAILED,
- "failed to send the re-opendir request");
+ gf_smsg(this->name, GF_LOG_ERROR, 0, PC_MSG_DIR_OP_FAILED, NULL);
}
return 0;
@@ -521,13 +285,11 @@ protocol_client_reopenfile(clnt_fd_ctx_t *fdctx, xlator_t *this)
frame = create_frame(this, this->ctx->pool);
if (!frame) {
- ret = -1;
goto out;
}
local = mem_get0(this->local_pool);
if (!local) {
- ret = -1;
goto out;
}
@@ -547,11 +309,10 @@ protocol_client_reopenfile(clnt_fd_ctx_t *fdctx, xlator_t *this)
local->loc.path);
ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_OPEN,
- client3_3_reopen_cbk, NULL, NULL, 0, NULL, 0,
- NULL, (xdrproc_t)xdr_gfs3_open_req);
+ client3_3_reopen_cbk, NULL,
+ (xdrproc_t)xdr_gfs3_open_req);
if (ret) {
- gf_msg(this->name, GF_LOG_ERROR, 0, PC_MSG_DIR_OP_FAILED,
- "failed to send the re-open request");
+ gf_smsg(this->name, GF_LOG_ERROR, 0, PC_MSG_DIR_OP_FAILED, NULL);
}
return 0;
@@ -588,21 +349,14 @@ client4_0_reopen_cbk(struct rpc_req *req, struct iovec *iov, int count,
gfx_open_rsp rsp = {
0,
};
- clnt_local_t *local = NULL;
- clnt_fd_ctx_t *fdctx = NULL;
- call_frame_t *frame = NULL;
- xlator_t *this = NULL;
-
- frame = myframe;
- this = frame->this;
- local = frame->local;
- fdctx = local->fdctx;
+ call_frame_t *frame = myframe;
+ xlator_t *this = frame->this;
+ clnt_local_t *local = frame->local;
+ clnt_fd_ctx_t *fdctx = local->fdctx;
if (-1 == req->rpc_status) {
- gf_msg(frame->this->name, GF_LOG_WARNING, ENOTCONN,
- PC_MSG_RPC_STATUS_ERROR,
- "received RPC status error, "
- "returning ENOTCONN");
+ gf_smsg(frame->this->name, GF_LOG_WARNING, ENOTCONN,
+ PC_MSG_RPC_STATUS_ERROR, NULL);
rsp.op_ret = -1;
rsp.op_errno = ENOTCONN;
goto out;
@@ -610,16 +364,16 @@ client4_0_reopen_cbk(struct rpc_req *req, struct iovec *iov, int count,
ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_open_rsp);
if (ret < 0) {
- gf_msg(frame->this->name, GF_LOG_ERROR, EINVAL,
- PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed");
+ gf_smsg(frame->this->name, GF_LOG_ERROR, EINVAL,
+ PC_MSG_XDR_DECODING_FAILED, NULL);
rsp.op_ret = -1;
rsp.op_errno = EINVAL;
goto out;
}
if (rsp.op_ret < 0) {
- gf_msg(frame->this->name, GF_LOG_WARNING, rsp.op_errno,
- PC_MSG_DIR_OP_SUCCESS, "reopen on %s failed.", local->loc.path);
+ gf_smsg(frame->this->name, GF_LOG_WARNING, rsp.op_errno,
+ PC_MSG_REOPEN_FAILED, "path=%s", local->loc.path, NULL);
} else {
gf_msg_debug(frame->this->name, 0,
"reopen on %s succeeded (remote-fd = %" PRId64 ")",
@@ -627,12 +381,9 @@ client4_0_reopen_cbk(struct rpc_req *req, struct iovec *iov, int count,
}
if (rsp.op_ret == -1) {
- ret = -1;
goto out;
}
- ret = 0;
-
out:
fdctx->reopen_done(fdctx, (rsp.op_ret) ? -1 : rsp.fd, this);
@@ -652,19 +403,13 @@ client4_0_reopendir_cbk(struct rpc_req *req, struct iovec *iov, int count,
gfx_open_rsp rsp = {
0,
};
- clnt_local_t *local = NULL;
- clnt_fd_ctx_t *fdctx = NULL;
- call_frame_t *frame = NULL;
-
- frame = myframe;
- local = frame->local;
- fdctx = local->fdctx;
+ call_frame_t *frame = myframe;
+ clnt_local_t *local = frame->local;
+ clnt_fd_ctx_t *fdctx = local->fdctx;
if (-1 == req->rpc_status) {
- gf_msg(frame->this->name, GF_LOG_WARNING, ENOTCONN,
- PC_MSG_RPC_STATUS_ERROR,
- "received RPC status error, "
- "returning ENOTCONN");
+ gf_smsg(frame->this->name, GF_LOG_WARNING, ENOTCONN,
+ PC_MSG_RPC_STATUS_ERROR, NULL);
rsp.op_ret = -1;
rsp.op_errno = ENOTCONN;
goto out;
@@ -672,25 +417,22 @@ client4_0_reopendir_cbk(struct rpc_req *req, struct iovec *iov, int count,
ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_open_rsp);
if (ret < 0) {
- gf_msg(frame->this->name, GF_LOG_ERROR, EINVAL,
- PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed");
+ gf_smsg(frame->this->name, GF_LOG_ERROR, EINVAL,
+ PC_MSG_XDR_DECODING_FAILED, NULL);
rsp.op_ret = -1;
rsp.op_errno = EINVAL;
goto out;
}
if (rsp.op_ret < 0) {
- gf_msg(frame->this->name, GF_LOG_WARNING, rsp.op_errno,
- PC_MSG_DIR_OP_FAILED, "reopendir on %s failed", local->loc.path);
+ gf_smsg(frame->this->name, GF_LOG_WARNING, rsp.op_errno,
+ PC_MSG_DIR_OP_FAILED, "dir-path=%s", local->loc.path, NULL);
} else {
- gf_msg(frame->this->name, GF_LOG_INFO, 0, PC_MSG_DIR_OP_SUCCESS,
- "reopendir on %s succeeded "
- "(fd = %" PRId64 ")",
- local->loc.path, rsp.fd);
+ gf_smsg(frame->this->name, GF_LOG_INFO, 0, PC_MSG_DIR_OP_SUCCESS,
+ "path=%s", local->loc.path, "fd=%" PRId64, rsp.fd, NULL);
}
if (-1 == rsp.op_ret) {
- ret = -1;
goto out;
}
@@ -713,13 +455,10 @@ protocol_client_reopendir_v2(clnt_fd_ctx_t *fdctx, xlator_t *this)
0,
},
};
- clnt_local_t *local = NULL;
call_frame_t *frame = NULL;
- clnt_conf_t *conf = NULL;
-
- conf = this->private;
+ clnt_conf_t *conf = this->private;
+ clnt_local_t *local = mem_get0(this->local_pool);
- local = mem_get0(this->local_pool);
if (!local) {
ret = -1;
goto out;
@@ -745,11 +484,10 @@ protocol_client_reopendir_v2(clnt_fd_ctx_t *fdctx, xlator_t *this)
frame->local = local;
ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_OPENDIR,
- client4_0_reopendir_cbk, NULL, NULL, 0, NULL, 0,
- NULL, (xdrproc_t)xdr_gfx_opendir_req);
+ client4_0_reopendir_cbk, NULL,
+ (xdrproc_t)xdr_gfx_opendir_req);
if (ret) {
- gf_msg(this->name, GF_LOG_ERROR, 0, PC_MSG_DIR_OP_FAILED,
- "failed to send the re-opendir request");
+ gf_smsg(this->name, GF_LOG_ERROR, 0, PC_MSG_DIR_OP_FAILED, NULL);
}
return 0;
@@ -773,12 +511,9 @@ protocol_client_reopenfile_v2(clnt_fd_ctx_t *fdctx, xlator_t *this)
},
};
clnt_local_t *local = NULL;
- call_frame_t *frame = NULL;
- clnt_conf_t *conf = NULL;
+ clnt_conf_t *conf = this->private;
+ call_frame_t *frame = create_frame(this, this->ctx->pool);
- conf = this->private;
-
- frame = create_frame(this, this->ctx->pool);
if (!frame) {
ret = -1;
goto out;
@@ -806,11 +541,10 @@ protocol_client_reopenfile_v2(clnt_fd_ctx_t *fdctx, xlator_t *this)
local->loc.path);
ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_OPEN,
- client4_0_reopen_cbk, NULL, NULL, 0, NULL, 0,
- NULL, (xdrproc_t)xdr_gfx_open_req);
+ client4_0_reopen_cbk, NULL,
+ (xdrproc_t)xdr_gfx_open_req);
if (ret) {
- gf_msg(this->name, GF_LOG_ERROR, 0, PC_MSG_DIR_OP_FAILED,
- "failed to send the re-open request");
+ gf_smsg(this->name, GF_LOG_ERROR, 0, PC_MSG_DIR_OP_FAILED, NULL);
}
return 0;
@@ -849,14 +583,12 @@ __is_fd_reopen_in_progress(clnt_fd_ctx_t *fdctx)
void
client_attempt_reopen(fd_t *fd, xlator_t *this)
{
- clnt_conf_t *conf = NULL;
- clnt_fd_ctx_t *fdctx = NULL;
- gf_boolean_t reopen = _gf_false;
-
if (!fd || !this)
goto out;
- conf = this->private;
+ clnt_conf_t *conf = this->private;
+ clnt_fd_ctx_t *fdctx = NULL;
+ gf_boolean_t reopen = _gf_false;
pthread_spin_lock(&conf->fd_lock);
{
@@ -891,7 +623,7 @@ out:
return;
}
-int
+static int
client_post_handshake(call_frame_t *frame, xlator_t *this)
{
clnt_conf_t *conf = NULL;
@@ -911,7 +643,8 @@ client_post_handshake(call_frame_t *frame, xlator_t *this)
{
list_for_each_entry_safe(fdctx, tmp, &conf->saved_fds, sfd_pos)
{
- if (fdctx->remote_fd != -1)
+ if (fdctx->remote_fd != -1 ||
+ (!list_empty(&fdctx->lock_list) && conf->strict_locks))
continue;
fdctx->reopen_done = client_child_up_reopen_done;
@@ -925,10 +658,8 @@ client_post_handshake(call_frame_t *frame, xlator_t *this)
/* Delay notifying CHILD_UP to parents
until all locks are recovered */
if (count > 0) {
- gf_msg(this->name, GF_LOG_INFO, 0, PC_MSG_CHILD_UP_NOTIFY_DELAY,
- "%d fds open - Delaying "
- "child_up until they are re-opened",
- count);
+ gf_smsg(this->name, GF_LOG_INFO, 0, PC_MSG_CHILD_UP_NOTIFY_DELAY,
+ "count=%d", count, NULL);
client_save_number_fds(conf, count);
list_for_each_entry_safe(fdctx, tmp, &reopen_head, sfd_pos)
@@ -954,11 +685,12 @@ int
client_setvolume_cbk(struct rpc_req *req, struct iovec *iov, int count,
void *myframe)
{
- call_frame_t *frame = NULL;
- clnt_conf_t *conf = NULL;
- xlator_t *this = NULL;
+ call_frame_t *frame = myframe;
+ xlator_t *this = frame->this;
+ clnt_conf_t *conf = this->private;
dict_t *reply = NULL;
char *process_uuid = NULL;
+ char *volume_id = NULL;
char *remote_error = NULL;
char *remote_subvol = NULL;
gf_setvolume_rsp rsp = {
@@ -970,32 +702,29 @@ client_setvolume_cbk(struct rpc_req *req, struct iovec *iov, int count,
gf_boolean_t auth_fail = _gf_false;
glusterfs_ctx_t *ctx = NULL;
- frame = myframe;
- this = frame->this;
- conf = this->private;
GF_VALIDATE_OR_GOTO(this->name, conf, out);
ctx = this->ctx;
GF_VALIDATE_OR_GOTO(this->name, ctx, out);
if (-1 == req->rpc_status) {
- gf_msg(frame->this->name, GF_LOG_WARNING, ENOTCONN,
- PC_MSG_RPC_STATUS_ERROR, "received RPC status error");
+ gf_smsg(frame->this->name, GF_LOG_WARNING, ENOTCONN,
+ PC_MSG_RPC_STATUS_ERROR, NULL);
op_ret = -1;
goto out;
}
ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gf_setvolume_rsp);
if (ret < 0) {
- gf_msg(this->name, GF_LOG_ERROR, EINVAL, PC_MSG_XDR_DECODING_FAILED,
- "XDR decoding failed");
+ gf_smsg(this->name, GF_LOG_ERROR, EINVAL, PC_MSG_XDR_DECODING_FAILED,
+ NULL);
op_ret = -1;
goto out;
}
op_ret = rsp.op_ret;
op_errno = gf_error_to_errno(rsp.op_errno);
if (-1 == rsp.op_ret) {
- gf_msg(frame->this->name, GF_LOG_WARNING, op_errno, PC_MSG_VOL_SET_FAIL,
- "failed to set the volume");
+ gf_smsg(frame->this->name, GF_LOG_WARNING, op_errno,
+ PC_MSG_VOL_SET_FAIL, NULL);
}
reply = dict_new();
@@ -1005,35 +734,30 @@ client_setvolume_cbk(struct rpc_req *req, struct iovec *iov, int count,
if (rsp.dict.dict_len) {
ret = dict_unserialize(rsp.dict.dict_val, rsp.dict.dict_len, &reply);
if (ret < 0) {
- gf_msg(frame->this->name, GF_LOG_WARNING, 0,
- PC_MSG_DICT_UNSERIALIZE_FAIL,
- "failed to "
- "unserialize buffer to dict");
+ gf_smsg(frame->this->name, GF_LOG_WARNING, 0,
+ PC_MSG_DICT_UNSERIALIZE_FAIL, NULL);
goto out;
}
}
- ret = dict_get_str(reply, "ERROR", &remote_error);
+ ret = dict_get_str_sizen(reply, "ERROR", &remote_error);
if (ret < 0) {
- gf_msg(this->name, GF_LOG_WARNING, EINVAL, PC_MSG_DICT_GET_FAILED,
- "failed to get ERROR "
- "string from reply dict");
+ gf_smsg(this->name, GF_LOG_WARNING, EINVAL, PC_MSG_DICT_GET_FAILED,
+ "ERROR string", NULL);
}
- ret = dict_get_str(reply, "process-uuid", &process_uuid);
+ ret = dict_get_str_sizen(reply, "process-uuid", &process_uuid);
if (ret < 0) {
- gf_msg(this->name, GF_LOG_WARNING, EINVAL, PC_MSG_DICT_GET_FAILED,
- "failed to get "
- "'process-uuid' from reply dict");
+ gf_smsg(this->name, GF_LOG_WARNING, EINVAL, PC_MSG_DICT_GET_FAILED,
+ "process-uuid", NULL);
}
if (op_ret < 0) {
- gf_msg(this->name, GF_LOG_ERROR, op_errno, PC_MSG_SETVOLUME_FAIL,
- "SETVOLUME on remote-host failed: %s", remote_error);
+ gf_smsg(this->name, GF_LOG_ERROR, op_errno, PC_MSG_SETVOLUME_FAIL,
+ "remote-error=%s", remote_error, NULL);
errno = op_errno;
- if (remote_error &&
- (strcmp("Authentication failed", remote_error) == 0)) {
+ if (remote_error && (op_errno == EACCES)) {
auth_fail = _gf_true;
op_ret = 0;
}
@@ -1050,19 +774,45 @@ client_setvolume_cbk(struct rpc_req *req, struct iovec *iov, int count,
if (op_errno == ESTALE) {
ret = client_notify_dispatch(this, GF_EVENT_VOLFILE_MODIFIED, NULL);
if (ret)
- gf_msg(this->name, GF_LOG_INFO, 0, PC_MSG_VOLFILE_NOTIFY_FAILED,
- "notify of VOLFILE_MODIFIED failed");
+ gf_smsg(this->name, GF_LOG_INFO, 0,
+ PC_MSG_VOLFILE_NOTIFY_FAILED, NULL);
}
goto out;
}
- ret = dict_get_str(this->options, "remote-subvolume", &remote_subvol);
+ ret = dict_get_str_sizen(this->options, "remote-subvolume", &remote_subvol);
if (ret || !remote_subvol) {
- gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_DICT_GET_FAILED,
- "failed to find key 'remote-subvolume' in the options");
+ gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FIND_KEY_FAILED,
+ "remote-subvolume", NULL);
goto out;
}
+ ret = dict_get_str_sizen(reply, "volume-id", &volume_id);
+ if (ret < 0) {
+ /* this can happen if the server is of old version, so treat it as
+ just debug message */
+ gf_msg_debug(this->name, EINVAL,
+ "failed to get 'volume-id' from reply dict");
+ } else if (ctx->master && strncmp("snapd", remote_subvol, 5)) {
+ /* TODO: if it is a fuse mount or a snapshot enabled client, don't
+ bother */
+ /* If any value is set, the first element will be non-0.
+ It would be '0', but not '\0' :-) */
+ if (ctx->volume_id[0]) {
+ if (strcmp(ctx->volume_id, volume_id)) {
+ /* Ideally it shouldn't even come here, as server itself
+ should fail the handshake in that case */
+ gf_smsg(this->name, GF_LOG_ERROR, EINVAL, PC_MSG_VOL_ID_CHANGED,
+ "vol-id=%s", volume_id, "ctx->vol-id=%s",
+ ctx->volume_id, NULL);
+ op_ret = -1;
+ goto out;
+ }
+ } else {
+ strncpy(ctx->volume_id, volume_id, GF_UUID_BUF_SIZE);
+ }
+ }
+
uint32_t child_up_int;
ret = dict_get_uint32(reply, "child_up", &child_up_int);
if (ret) {
@@ -1071,8 +821,8 @@ client_setvolume_cbk(struct rpc_req *req, struct iovec *iov, int count,
* connect to this client is running an older version. Hence *
* setting the child_up to _gf_true in this case. *
*/
- gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_DICT_GET_FAILED,
- "failed to find key 'child_up' in the options");
+ gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FIND_KEY_FAILED,
+ "child_up", NULL);
conf->child_up = _gf_true;
} else {
conf->child_up = (child_up_int != 0);
@@ -1102,9 +852,9 @@ client_setvolume_cbk(struct rpc_req *req, struct iovec *iov, int count,
conf->client_id = glusterfs_leaf_position(this);
- gf_msg(this->name, GF_LOG_INFO, 0, PC_MSG_REMOTE_VOL_CONNECTED,
- "Connected to %s, attached to remote volume '%s'.",
- conf->rpc->conn.name, remote_subvol);
+ gf_smsg(this->name, GF_LOG_INFO, 0, PC_MSG_REMOTE_VOL_CONNECTED,
+ "conn-name=%s", conf->rpc->conn.name, "remote_subvol=%s",
+ remote_subvol, NULL);
op_ret = 0;
conf->connected = 1;
@@ -1112,13 +862,11 @@ client_setvolume_cbk(struct rpc_req *req, struct iovec *iov, int count,
client_post_handshake(frame, frame->this);
out:
if (auth_fail) {
- gf_msg(this->name, GF_LOG_INFO, 0, PC_MSG_AUTH_FAILED,
- "sending AUTH_FAILED event");
+ gf_smsg(this->name, GF_LOG_INFO, 0, PC_MSG_AUTH_FAILED, NULL);
ret = client_notify_dispatch(this, GF_EVENT_AUTH_FAILED, NULL);
if (ret)
- gf_msg(this->name, GF_LOG_INFO, 0, PC_MSG_AUTH_FAILED_NOTIFY_FAILED,
- "notify of "
- "AUTH_FAILED failed");
+ gf_smsg(this->name, GF_LOG_INFO, 0,
+ PC_MSG_AUTH_FAILED_NOTIFY_FAILED, NULL);
conf->connected = 0;
ret = -1;
}
@@ -1127,14 +875,12 @@ out:
* background, for now, don't hang here,
* tell the parents that i am all ok..
*/
- gf_msg(this->name, GF_LOG_INFO, 0, PC_MSG_CHILD_CONNECTING_EVENT,
- "sending "
- "CHILD_CONNECTING event");
+ gf_smsg(this->name, GF_LOG_INFO, 0, PC_MSG_CHILD_CONNECTING_EVENT,
+ NULL);
ret = client_notify_dispatch(this, GF_EVENT_CHILD_CONNECTING, NULL);
if (ret)
- gf_msg(this->name, GF_LOG_INFO, 0,
- PC_MSG_CHILD_CONNECTING_NOTIFY_FAILED,
- "notify of CHILD_CONNECTING failed");
+ gf_smsg(this->name, GF_LOG_INFO, 0,
+ PC_MSG_CHILD_CONNECTING_NOTIFY_FAILED, NULL);
/*
* The reconnection *won't* happen in the background (see
* previous comment) unless we kill the current connection.
@@ -1164,34 +910,30 @@ client_setvolume(xlator_t *this, struct rpc_clnt *rpc)
};
call_frame_t *fr = NULL;
char *process_uuid_xl = NULL;
- clnt_conf_t *conf = NULL;
- dict_t *options = NULL;
+ char *remote_subvol = NULL;
+ clnt_conf_t *conf = this->private;
+ dict_t *options = this->options;
char counter_str[32] = {0};
char hostname[256] = {
0,
};
- options = this->options;
- conf = this->private;
-
if (conf->fops) {
- ret = dict_set_int32(options, "fops-version", conf->fops->prognum);
+ ret = dict_set_int32_sizen(options, "fops-version",
+ conf->fops->prognum);
if (ret < 0) {
- gf_msg(this->name, GF_LOG_ERROR, 0, PC_MSG_DICT_SET_FAILED,
- "failed to set "
- "version-fops(%d) in handshake msg",
- conf->fops->prognum);
+ gf_smsg(this->name, GF_LOG_ERROR, 0, PC_MSG_DICT_SET_FAILED,
+ "version-fops=%d", conf->fops->prognum, NULL);
goto fail;
}
}
if (conf->mgmt) {
- ret = dict_set_int32(options, "mgmt-version", conf->mgmt->prognum);
+ ret = dict_set_int32_sizen(options, "mgmt-version",
+ conf->mgmt->prognum);
if (ret < 0) {
- gf_msg(this->name, GF_LOG_ERROR, 0, PC_MSG_DICT_SET_FAILED,
- "failed to set "
- "version-mgmt(%d) in handshake msg",
- conf->mgmt->prognum);
+ gf_smsg(this->name, GF_LOG_ERROR, 0, PC_MSG_DICT_SET_FAILED,
+ "version-mgmt=%d", conf->mgmt->prognum, NULL);
goto fail;
}
}
@@ -1207,8 +949,8 @@ client_setvolume(xlator_t *this, struct rpc_clnt *rpc)
conf->setvol_count++;
if (gethostname(hostname, 256) == -1) {
- gf_msg(this->name, GF_LOG_ERROR, errno, LG_MSG_GETHOSTNAME_FAILED,
- "gethostname: failed");
+ gf_smsg(this->name, GF_LOG_ERROR, errno, PC_MSG_GETHOSTNAME_FAILED,
+ NULL);
goto fail;
}
@@ -1217,54 +959,75 @@ client_setvolume(xlator_t *this, struct rpc_clnt *rpc)
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 "
- "setting process_uuid");
+ gf_smsg(this->name, GF_LOG_ERROR, 0, PC_MSG_PROCESS_UUID_SET_FAIL,
+ NULL);
goto fail;
}
- ret = dict_set_dynstr(options, "process-uuid", process_uuid_xl);
+ ret = dict_set_dynstr_sizen(options, "process-uuid", process_uuid_xl);
if (ret < 0) {
- gf_msg(this->name, GF_LOG_ERROR, 0, PC_MSG_DICT_SET_FAILED,
- "failed to set process-uuid(%s) in handshake msg",
- process_uuid_xl);
+ gf_smsg(this->name, GF_LOG_ERROR, 0, PC_MSG_DICT_SET_FAILED,
+ "process-uuid=%s", process_uuid_xl, NULL);
goto fail;
}
- ret = dict_set_str(options, "process-name",
- this->ctx->cmd_args.process_name);
- if (ret < 0) {
- gf_msg(this->name, GF_LOG_INFO, 0, PC_MSG_DICT_SET_FAILED,
- "failed to set process-name in handshake msg");
+ if (this->ctx->cmd_args.process_name) {
+ ret = dict_set_str_sizen(options, "process-name",
+ this->ctx->cmd_args.process_name);
+ if (ret < 0) {
+ gf_smsg(this->name, GF_LOG_INFO, 0, PC_MSG_DICT_SET_FAILED,
+ "process-name", NULL);
+ }
}
- ret = dict_set_str(options, "client-version", PACKAGE_VERSION);
+ ret = dict_set_str_sizen(options, "client-version", PACKAGE_VERSION);
if (ret < 0) {
- gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_DICT_SET_FAILED,
- "failed to set client-version(%s) in handshake msg",
- PACKAGE_VERSION);
+ gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_DICT_SET_FAILED,
+ "client-version=%s", PACKAGE_VERSION, NULL);
+ }
+
+ ret = dict_get_str_sizen(this->options, "remote-subvolume", &remote_subvol);
+ if (ret || !remote_subvol) {
+ gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FIND_KEY_FAILED,
+ "remote-subvolume", NULL);
+ goto fail;
+ }
+
+ /* volume-id to be sent only for regular volume, not snap volume */
+ 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) {
+ gf_smsg(this->name, GF_LOG_INFO, 0, PC_MSG_DICT_SET_FAILED,
+ "volume-id", NULL);
+ }
+ }
}
if (this->ctx->cmd_args.volfile_server) {
if (this->ctx->cmd_args.volfile_id) {
- ret = dict_set_str(options, "volfile-key",
- this->ctx->cmd_args.volfile_id);
+ ret = dict_set_str_sizen(options, "volfile-key",
+ this->ctx->cmd_args.volfile_id);
if (ret)
- gf_msg(this->name, GF_LOG_ERROR, 0, PC_MSG_DICT_SET_FAILED,
- "failed to "
- "set 'volfile-key'");
+ gf_smsg(this->name, GF_LOG_ERROR, 0,
+ PC_MSG_VOLFILE_KEY_SET_FAILED, NULL);
}
ret = dict_set_uint32(options, "volfile-checksum",
this->graph->volfile_checksum);
if (ret)
- gf_msg(this->name, GF_LOG_ERROR, 0, PC_MSG_DICT_SET_FAILED,
- "failed to set "
- "'volfile-checksum'");
+ gf_smsg(this->name, GF_LOG_ERROR, 0, PC_MSG_VOLFILE_CHECKSUM_FAILED,
+ NULL);
}
if (this->ctx->cmd_args.subdir_mount) {
- ret = dict_set_str(options, "subdir-mount",
- this->ctx->cmd_args.subdir_mount);
+ ret = dict_set_str_sizen(options, "subdir-mount",
+ this->ctx->cmd_args.subdir_mount);
if (ret) {
gf_log(THIS->name, GF_LOG_ERROR, "Failed to set subdir_mount");
/* It makes sense to fail, as per the CLI, we
@@ -1278,31 +1041,21 @@ client_setvolume(xlator_t *this, struct rpc_clnt *rpc)
*/
ret = dict_set_uint32(options, "clnt-lk-version", 1);
if (ret < 0) {
- gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_DICT_SET_FAILED,
- "failed to set clnt-lk-version(1) in handshake msg");
+ gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_DICT_SET_FAILED,
+ "clnt-lk-version(1)", NULL);
}
- ret = dict_set_int32(options, "opversion", GD_OP_VERSION_MAX);
+ ret = dict_set_int32_sizen(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");
+ gf_smsg(this->name, GF_LOG_ERROR, 0, PC_MSG_DICT_SET_FAILED,
+ "client opversion", NULL);
}
- ret = dict_serialized_length(options);
- if (ret < 0) {
- gf_msg(this->name, GF_LOG_ERROR, 0, PC_MSG_DICT_ERROR,
- "failed to get serialized length of dict");
+ ret = dict_allocate_and_serialize(options, (char **)&req.dict.dict_val,
+ &req.dict.dict_len);
+ if (ret != 0) {
ret = -1;
- goto fail;
- }
- req.dict.dict_len = ret;
- req.dict.dict_val = GF_CALLOC(1, req.dict.dict_len,
- gf_client_mt_clnt_req_buf_t);
- ret = dict_serialize(options, req.dict.dict_val);
- if (ret < 0) {
- gf_msg(this->name, GF_LOG_ERROR, 0, PC_MSG_DICT_SERIALIZE_FAIL,
- "failed to serialize "
- "dictionary");
+ gf_smsg(this->name, GF_LOG_ERROR, 0, PC_MSG_DICT_SERIALIZE_FAIL, NULL);
goto fail;
}
@@ -1312,7 +1065,6 @@ client_setvolume(xlator_t *this, struct rpc_clnt *rpc)
ret = client_submit_request(this, &req, fr, conf->handshake,
GF_HNDSK_SETVOLUME, client_setvolume_cbk, NULL,
- NULL, 0, NULL, 0, NULL,
(xdrproc_t)xdr_gf_setvolume_req);
fail:
@@ -1321,7 +1073,7 @@ fail:
return ret;
}
-int
+static int
select_server_supported_programs(xlator_t *this, gf_prog_detail *prog)
{
gf_prog_detail *trav = NULL;
@@ -1329,8 +1081,7 @@ select_server_supported_programs(xlator_t *this, gf_prog_detail *prog)
int ret = -1;
if (!this || !prog) {
- gf_msg(THIS->name, GF_LOG_WARNING, 0, PC_MSG_PGM_NOT_FOUND,
- "xlator not found OR RPC program not found");
+ gf_smsg(THIS->name, GF_LOG_WARNING, 0, PC_MSG_PGM_NOT_FOUND, NULL);
goto out;
}
@@ -1340,11 +1091,15 @@ select_server_supported_programs(xlator_t *this, gf_prog_detail *prog)
while (trav) {
/* Select 'programs' */
if ((clnt3_3_fop_prog.prognum == trav->prognum) &&
- (clnt3_3_fop_prog.progver == trav->progver) && !conf->fops) {
+ (clnt3_3_fop_prog.progver == trav->progver)) {
conf->fops = &clnt3_3_fop_prog;
if (conf->rpc)
conf->rpc->auth_value = AUTH_GLUSTERFS_v2;
ret = 0;
+ /* In normal flow, we don't want to use old protocol type.
+ but if it is for testing, lets use it */
+ if (conf->old_protocol)
+ goto done;
}
if ((clnt4_0_fop_prog.prognum == trav->prognum) &&
@@ -1353,8 +1108,10 @@ select_server_supported_programs(xlator_t *this, gf_prog_detail *prog)
if (conf->rpc)
conf->rpc->auth_value = AUTH_GLUSTERFS_v3;
ret = 0;
- /* this is latest program, lets use it */
- goto out;
+ /* this is latest program, lets use this program only */
+ /* if we are testing for old-protocol, lets not break this */
+ if (!conf->old_protocol)
+ goto done;
}
if (ret) {
@@ -1364,11 +1121,11 @@ select_server_supported_programs(xlator_t *this, gf_prog_detail *prog)
trav = trav->next;
}
+done:
if (!ret)
- gf_msg(this->name, GF_LOG_INFO, 0, PC_MSG_VERSION_INFO,
- "Using Program %s,"
- " Num (%d), Version (%d)",
- conf->fops->progname, conf->fops->prognum, conf->fops->progver);
+ gf_smsg(this->name, GF_LOG_INFO, 0, PC_MSG_VERSION_INFO,
+ "Program-name=%s", conf->fops->progname, "Num=%d",
+ conf->fops->prognum, "Version=%d", conf->fops->progver, NULL);
out:
return ret;
@@ -1381,8 +1138,7 @@ server_has_portmap(xlator_t *this, gf_prog_detail *prog)
int ret = -1;
if (!this || !prog) {
- gf_msg(THIS->name, GF_LOG_WARNING, 0, PC_MSG_PGM_NOT_FOUND,
- "xlator not found OR RPC program not found");
+ gf_smsg(THIS->name, GF_LOG_WARNING, 0, PC_MSG_PGM_NOT_FOUND, NULL);
goto out;
}
@@ -1419,36 +1175,30 @@ client_query_portmap_cbk(struct rpc_req *req, struct iovec *iov, int count,
frame = myframe;
if (!frame || !frame->this || !frame->this->private) {
- gf_msg(THIS->name, GF_LOG_WARNING, EINVAL, PC_MSG_INVALID_ENTRY,
- "frame not found with rpc "
- "request");
+ gf_smsg(THIS->name, GF_LOG_WARNING, EINVAL, PC_MSG_FRAME_NOT_FOUND,
+ NULL);
goto out;
}
this = frame->this;
conf = frame->this->private;
if (-1 == req->rpc_status) {
- gf_msg(this->name, GF_LOG_WARNING, ENOTCONN, PC_MSG_RPC_STATUS_ERROR,
- "received RPC status error, "
- "try again later");
+ gf_smsg(this->name, GF_LOG_WARNING, ENOTCONN, PC_MSG_RPC_STATUS_ERROR,
+ NULL);
goto out;
}
ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_pmap_port_by_brick_rsp);
if (ret < 0) {
- gf_msg(this->name, GF_LOG_ERROR, EINVAL, PC_MSG_XDR_DECODING_FAILED,
- "XDR decoding failed");
+ gf_smsg(this->name, GF_LOG_ERROR, EINVAL, PC_MSG_XDR_DECODING_FAILED,
+ NULL);
goto out;
}
if (-1 == rsp.op_ret) {
ret = -1;
if (!conf->portmap_err_logged) {
- gf_msg(this->name, GF_LOG_ERROR, 0, PC_MSG_PORT_NUM_ERROR,
- "failed to get the "
- "port number for remote subvolume. Please run "
- "'gluster volume status' on server to see if "
- "brick process is running.");
+ gf_smsg(this->name, GF_LOG_ERROR, 0, PC_MSG_PORT_NUM_ERROR, NULL);
} else {
gf_msg_debug(this->name, 0,
"failed to get the port number for "
@@ -1498,16 +1248,16 @@ client_query_portmap(xlator_t *this, struct rpc_clnt *rpc)
options = this->options;
- ret = dict_get_str(options, "remote-subvolume", &remote_subvol);
+ ret = dict_get_str_sizen(options, "remote-subvolume", &remote_subvol);
if (ret < 0) {
- gf_msg(this->name, GF_LOG_ERROR, 0, PC_MSG_VOL_SET_FAIL,
- "remote-subvolume not set in volfile");
+ gf_smsg(this->name, GF_LOG_ERROR, 0, PC_MSG_REMOTE_SUBVOL_SET_FAIL,
+ NULL);
goto fail;
}
req.brick = remote_subvol;
- if (!dict_get_str(options, "transport-type", &xprt)) {
+ if (!dict_get_str_sizen(options, "transport-type", &xprt)) {
if (!strcmp(xprt, "rdma")) {
snprintf(brick_name, sizeof(brick_name), "%s.rdma", remote_subvol);
req.brick = brick_name;
@@ -1522,14 +1272,13 @@ client_query_portmap(xlator_t *this, struct rpc_clnt *rpc)
ret = client_submit_request(this, &req, fr, &clnt_pmap_prog,
GF_PMAP_PORTBYBRICK, client_query_portmap_cbk,
- NULL, NULL, 0, NULL, 0, NULL,
- (xdrproc_t)xdr_pmap_port_by_brick_req);
+ NULL, (xdrproc_t)xdr_pmap_port_by_brick_req);
fail:
return ret;
}
-int
+static int
client_dump_version_cbk(struct rpc_req *req, struct iovec *iov, int count,
void *myframe)
{
@@ -1546,21 +1295,20 @@ client_dump_version_cbk(struct rpc_req *req, struct iovec *iov, int count,
conf = frame->this->private;
if (-1 == req->rpc_status) {
- gf_msg(frame->this->name, GF_LOG_WARNING, ENOTCONN,
- PC_MSG_RPC_STATUS_ERROR, "received RPC status error");
+ gf_smsg(frame->this->name, GF_LOG_WARNING, ENOTCONN,
+ PC_MSG_RPC_STATUS_ERROR, NULL);
goto out;
}
ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gf_dump_rsp);
if (ret < 0) {
- gf_msg(frame->this->name, GF_LOG_ERROR, EINVAL,
- PC_MSG_XDR_DECODING_FAILED, "XDR decoding failed");
+ gf_smsg(frame->this->name, GF_LOG_ERROR, EINVAL,
+ PC_MSG_XDR_DECODING_FAILED, NULL);
goto out;
}
if (-1 == rsp.op_ret) {
- gf_msg(frame->this->name, GF_LOG_WARNING, 0, PC_MSG_VERSION_ERROR,
- "failed to get the 'versions' "
- "from server");
+ gf_smsg(frame->this->name, GF_LOG_WARNING, 0, PC_MSG_VERSION_ERROR,
+ NULL);
goto out;
}
@@ -1573,9 +1321,7 @@ client_dump_version_cbk(struct rpc_req *req, struct iovec *iov, int count,
/* Reply in "Name:Program-Number:Program-Version,..." format */
ret = select_server_supported_programs(frame->this, rsp.prog);
if (ret) {
- gf_msg(frame->this->name, GF_LOG_ERROR, 0, PC_MSG_VERSION_ERROR,
- "server doesn't support the "
- "version");
+ gf_smsg(frame->this->name, GF_LOG_ERROR, 0, PC_MSG_VERSION_ERROR, NULL);
goto out;
}
@@ -1613,8 +1359,8 @@ client_handshake(xlator_t *this, struct rpc_clnt *rpc)
conf = this->private;
if (!conf->handshake) {
- gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_PGM_NOT_FOUND,
- "handshake program not found");
+ gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_HANDSHAKE_PGM_NOT_FOUND,
+ NULL);
goto out;
}
@@ -1624,8 +1370,8 @@ client_handshake(xlator_t *this, struct rpc_clnt *rpc)
req.gfs_id = 0xbabe;
ret = client_submit_request(this, &req, frame, conf->dump, GF_DUMP_DUMP,
- client_dump_version_cbk, NULL, NULL, 0, NULL, 0,
- NULL, (xdrproc_t)xdr_gf_dump_req);
+ client_dump_version_cbk, NULL,
+ (xdrproc_t)xdr_gf_dump_req);
out:
return ret;