diff options
Diffstat (limited to 'xlators/protocol/client')
| -rw-r--r-- | xlators/protocol/client/src/client-callback.c | 91 | ||||
| -rw-r--r-- | xlators/protocol/client/src/client-common.c | 66 | ||||
| -rw-r--r-- | xlators/protocol/client/src/client-common.h | 10 | ||||
| -rw-r--r-- | xlators/protocol/client/src/client-handshake.c | 762 | ||||
| -rw-r--r-- | xlators/protocol/client/src/client-helpers.c | 2355 | ||||
| -rw-r--r-- | xlators/protocol/client/src/client-lk.c | 47 | ||||
| -rw-r--r-- | xlators/protocol/client/src/client-mem-types.h | 3 | ||||
| -rw-r--r-- | xlators/protocol/client/src/client-messages.h | 125 | ||||
| -rw-r--r-- | xlators/protocol/client/src/client-rpc-fops.c | 1137 | ||||
| -rw-r--r-- | xlators/protocol/client/src/client-rpc-fops_v2.c | 1276 | ||||
| -rw-r--r-- | xlators/protocol/client/src/client.c | 1358 | ||||
| -rw-r--r-- | xlators/protocol/client/src/client.h | 222 |
12 files changed, 2352 insertions, 5100 deletions
diff --git a/xlators/protocol/client/src/client-callback.c b/xlators/protocol/client/src/client-callback.c index 352a1130e14..d83d9c14899 100644 --- a/xlators/protocol/client/src/client-callback.c +++ b/xlators/protocol/client/src/client-callback.c @@ -10,34 +10,31 @@ #include "client.h" #include "rpc-clnt.h" -#include "defaults.h" +#include <glusterfs/defaults.h> #include "client-messages.h" -int +static int client_cbk_null(struct rpc_clnt *rpc, void *mydata, void *data) { - gf_msg(THIS->name, GF_LOG_WARNING, 0, PC_MSG_FUNCTION_CALL_ERROR, - "this function should not be called"); + gf_smsg(THIS->name, GF_LOG_WARNING, 0, PC_MSG_FUNCTION_CALL_ERROR, NULL); return 0; } -int +static int client_cbk_fetchspec(struct rpc_clnt *rpc, void *mydata, void *data) { - gf_msg(THIS->name, GF_LOG_WARNING, 0, PC_MSG_FUNCTION_CALL_ERROR, - "this function should not be called"); + gf_smsg(THIS->name, GF_LOG_WARNING, 0, PC_MSG_FUNCTION_CALL_ERROR, NULL); return 0; } -int +static int client_cbk_ino_flush(struct rpc_clnt *rpc, void *mydata, void *data) { - gf_msg(THIS->name, GF_LOG_WARNING, 0, PC_MSG_FUNCTION_CALL_ERROR, - "this function should not be called"); + gf_smsg(THIS->name, GF_LOG_WARNING, 0, PC_MSG_FUNCTION_CALL_ERROR, NULL); return 0; } -int +static int client_cbk_recall_lease(struct rpc_clnt *rpc, void *mydata, void *data) { int ret = -1; @@ -54,8 +51,6 @@ client_cbk_recall_lease(struct rpc_clnt *rpc, void *mydata, void *data) }, }; - GF_VALIDATE_OR_GOTO("client-callback", rpc, out); - GF_VALIDATE_OR_GOTO("client-callback", mydata, out); GF_VALIDATE_OR_GOTO("client-callback", data, out); iov = (struct iovec *)data; @@ -63,8 +58,8 @@ client_cbk_recall_lease(struct rpc_clnt *rpc, void *mydata, void *data) (xdrproc_t)xdr_gfs3_recall_lease_req); if (ret < 0) { - gf_msg(THIS->name, GF_LOG_WARNING, -ret, PC_MSG_RECALL_LEASE_FAIL, - "XDR decode of recall lease failed."); + gf_smsg(THIS->name, GF_LOG_WARNING, -ret, PC_MSG_RECALL_LEASE_FAIL, + NULL); goto out; } @@ -90,7 +85,7 @@ out: return ret; } -int +static int client_cbk_cache_invalidation(struct rpc_clnt *rpc, void *mydata, void *data) { int ret = -1; @@ -107,7 +102,7 @@ client_cbk_cache_invalidation(struct rpc_clnt *rpc, void *mydata, void *data) gf_msg_trace(THIS->name, 0, "Upcall callback is called"); - if (!rpc || !mydata || !data) + if (!data) goto out; iov = (struct iovec *)data; @@ -115,8 +110,8 @@ client_cbk_cache_invalidation(struct rpc_clnt *rpc, void *mydata, void *data) (xdrproc_t)xdr_gfs3_cbk_cache_invalidation_req); if (ret < 0) { - gf_msg(THIS->name, GF_LOG_WARNING, -ret, PC_MSG_CACHE_INVALIDATION_FAIL, - "XDR decode of cache_invalidation failed."); + gf_smsg(THIS->name, GF_LOG_WARNING, -ret, + PC_MSG_CACHE_INVALIDATION_FAIL, NULL); goto out; } @@ -145,15 +140,13 @@ out: return 0; } -int +static int client_cbk_child_up(struct rpc_clnt *rpc, void *mydata, void *data) { clnt_conf_t *conf = NULL; - xlator_t *this = NULL; + xlator_t *this = THIS; - this = THIS; GF_VALIDATE_OR_GOTO("client", this, out); - GF_VALIDATE_OR_GOTO(this->name, rpc, out); conf = this->private; GF_VALIDATE_OR_GOTO(this->name, conf, out); @@ -165,15 +158,13 @@ out: return 0; } -int +static int client_cbk_child_down(struct rpc_clnt *rpc, void *mydata, void *data) { clnt_conf_t *conf = NULL; - xlator_t *this = NULL; + xlator_t *this = THIS; - this = THIS; GF_VALIDATE_OR_GOTO("client", this, out); - GF_VALIDATE_OR_GOTO(this->name, rpc, out); conf = this->private; GF_VALIDATE_OR_GOTO(this->name, conf, out); @@ -185,7 +176,7 @@ out: return 0; } -int +static int client_cbk_inodelk_contention(struct rpc_clnt *rpc, void *mydata, void *data) { int ret = -1; @@ -204,8 +195,6 @@ client_cbk_inodelk_contention(struct rpc_clnt *rpc, void *mydata, void *data) }, }; - GF_VALIDATE_OR_GOTO("client-callback", rpc, out); - GF_VALIDATE_OR_GOTO("client-callback", mydata, out); GF_VALIDATE_OR_GOTO("client-callback", data, out); iov = (struct iovec *)data; @@ -213,8 +202,8 @@ client_cbk_inodelk_contention(struct rpc_clnt *rpc, void *mydata, void *data) (xdrproc_t)xdr_gfs4_inodelk_contention_req); if (ret < 0) { - gf_msg(THIS->name, GF_LOG_WARNING, -ret, PC_MSG_INODELK_CONTENTION_FAIL, - "XDR decode of inodelk contention failed."); + gf_smsg(THIS->name, GF_LOG_WARNING, -ret, + PC_MSG_INODELK_CONTENTION_FAIL, NULL); goto out; } @@ -240,7 +229,7 @@ out: return ret; } -int +static int client_cbk_entrylk_contention(struct rpc_clnt *rpc, void *mydata, void *data) { int ret = -1; @@ -257,8 +246,6 @@ client_cbk_entrylk_contention(struct rpc_clnt *rpc, void *mydata, void *data) }, }; - GF_VALIDATE_OR_GOTO("client-callback", rpc, out); - GF_VALIDATE_OR_GOTO("client-callback", mydata, out); GF_VALIDATE_OR_GOTO("client-callback", data, out); iov = (struct iovec *)data; @@ -266,8 +253,8 @@ client_cbk_entrylk_contention(struct rpc_clnt *rpc, void *mydata, void *data) (xdrproc_t)xdr_gfs4_entrylk_contention_req); if (ret < 0) { - gf_msg(THIS->name, GF_LOG_WARNING, -ret, PC_MSG_ENTRYLK_CONTENTION_FAIL, - "XDR decode of entrylk contention failed."); + gf_smsg(THIS->name, GF_LOG_WARNING, -ret, + PC_MSG_ENTRYLK_CONTENTION_FAIL, NULL); goto out; } @@ -296,24 +283,24 @@ out: return ret; } -rpcclnt_cb_actor_t gluster_cbk_actors[GF_CBK_MAXVALUE] = { - [GF_CBK_NULL] = {"NULL", GF_CBK_NULL, client_cbk_null}, - [GF_CBK_FETCHSPEC] = {"FETCHSPEC", GF_CBK_FETCHSPEC, client_cbk_fetchspec}, - [GF_CBK_INO_FLUSH] = {"INO_FLUSH", GF_CBK_INO_FLUSH, client_cbk_ino_flush}, +static rpcclnt_cb_actor_t gluster_cbk_actors[GF_CBK_MAXVALUE] = { + [GF_CBK_NULL] = {"NULL", client_cbk_null, GF_CBK_NULL}, + [GF_CBK_FETCHSPEC] = {"FETCHSPEC", client_cbk_fetchspec, GF_CBK_FETCHSPEC}, + [GF_CBK_INO_FLUSH] = {"INO_FLUSH", client_cbk_ino_flush, GF_CBK_INO_FLUSH}, [GF_CBK_CACHE_INVALIDATION] = {"CACHE_INVALIDATION", - GF_CBK_CACHE_INVALIDATION, - client_cbk_cache_invalidation}, - [GF_CBK_CHILD_UP] = {"CHILD_UP", GF_CBK_CHILD_UP, client_cbk_child_up}, - [GF_CBK_CHILD_DOWN] = {"CHILD_DOWN", GF_CBK_CHILD_DOWN, - client_cbk_child_down}, - [GF_CBK_RECALL_LEASE] = {"RECALL_LEASE", GF_CBK_RECALL_LEASE, - client_cbk_recall_lease}, + client_cbk_cache_invalidation, + GF_CBK_CACHE_INVALIDATION}, + [GF_CBK_CHILD_UP] = {"CHILD_UP", client_cbk_child_up, GF_CBK_CHILD_UP}, + [GF_CBK_CHILD_DOWN] = {"CHILD_DOWN", client_cbk_child_down, + GF_CBK_CHILD_DOWN}, + [GF_CBK_RECALL_LEASE] = {"RECALL_LEASE", client_cbk_recall_lease, + GF_CBK_RECALL_LEASE}, [GF_CBK_INODELK_CONTENTION] = {"INODELK_CONTENTION", - GF_CBK_INODELK_CONTENTION, - client_cbk_inodelk_contention}, + client_cbk_inodelk_contention, + GF_CBK_INODELK_CONTENTION}, [GF_CBK_ENTRYLK_CONTENTION] = {"ENTRYLK_CONTENTION", - GF_CBK_ENTRYLK_CONTENTION, - client_cbk_entrylk_contention}, + client_cbk_entrylk_contention, + GF_CBK_ENTRYLK_CONTENTION}, }; struct rpcclnt_cb_program gluster_cbk_prog = { diff --git a/xlators/protocol/client/src/client-common.c b/xlators/protocol/client/src/client-common.c index 31615516fcf..c112820e407 100644 --- a/xlators/protocol/client/src/client-common.c +++ b/xlators/protocol/client/src/client-common.c @@ -8,8 +8,8 @@ cases as published by the Free Software Foundation. */ -#include "dict.h" -#include "xlator.h" +#include <glusterfs/dict.h> +#include <glusterfs/xlator.h> #include "rpc-common-xdr.h" #include "glusterfs3-xdr.h" #include "glusterfs4-xdr.h" @@ -449,7 +449,8 @@ client_pre_fsync(xlator_t *this, gfs3_fsync_req *req, fd_t *fd, int32_t flags, int64_t remote_fd = -1; int op_errno = 0; - CLIENT_GET_REMOTE_FD(this, fd, DEFAULT_REMOTE_FD, remote_fd, op_errno, out); + CLIENT_GET_REMOTE_FD(this, fd, FALLBACK_TO_ANON_FD, remote_fd, op_errno, + out); req->fd = remote_fd; req->data = flags; @@ -714,8 +715,8 @@ client_pre_lk(xlator_t *this, gfs3_lk_req *req, int32_t cmd, ret = client_cmd_to_gf_cmd(cmd, &gf_cmd); if (ret) { op_errno = EINVAL; - gf_msg(this->name, GF_LOG_WARNING, EINVAL, PC_MSG_INVALID_ENTRY, - "Unknown cmd (%d)!", gf_cmd); + gf_smsg(this->name, GF_LOG_WARNING, EINVAL, PC_MSG_UNKNOWN_CMD, + "gf_cmd=%d", gf_cmd, NULL); goto out; } @@ -827,8 +828,8 @@ client_pre_inodelk(xlator_t *this, gfs3_inodelk_req *req, loc_t *loc, int cmd, else if (cmd == F_SETLKW || cmd == F_SETLKW64) gf_cmd = GF_LK_SETLKW; else { - gf_msg(this->name, GF_LOG_WARNING, EINVAL, PC_MSG_INVALID_ENTRY, - "Unknown cmd (%d)!", gf_cmd); + gf_smsg(this->name, GF_LOG_WARNING, EINVAL, PC_MSG_UNKNOWN_CMD, + "gf_cmd=%d", gf_cmd, NULL); op_errno = EINVAL; goto out; } @@ -877,8 +878,8 @@ client_pre_finodelk(xlator_t *this, gfs3_finodelk_req *req, fd_t *fd, int cmd, else if (cmd == F_SETLKW || cmd == F_SETLKW64) gf_cmd = GF_LK_SETLKW; else { - gf_msg(this->name, GF_LOG_WARNING, EINVAL, PC_MSG_INVALID_ENTRY, - "Unknown cmd (%d)!", gf_cmd); + gf_smsg(this->name, GF_LOG_WARNING, EINVAL, PC_MSG_UNKNOWN_CMD, + "gf_cmd=%d", gf_cmd, NULL); goto out; } @@ -2556,6 +2557,38 @@ out: } int +client_pre_copy_file_range_v2(xlator_t *this, gfx_copy_file_range_req *req, + fd_t *fd_in, off64_t off_in, fd_t *fd_out, + off64_t off_out, size_t size, int32_t flags, + dict_t **xdata) +{ + int64_t remote_fd_in = -1; + int64_t remote_fd_out = -1; + int op_errno = ESTALE; + + CLIENT_GET_REMOTE_FD(this, fd_in, FALLBACK_TO_ANON_FD, remote_fd_in, + op_errno, out); + + CLIENT_GET_REMOTE_FD(this, fd_out, FALLBACK_TO_ANON_FD, remote_fd_out, + op_errno, out); + req->size = size; + req->off_in = off_in; + req->off_out = off_out; + req->fd_in = remote_fd_in; + req->fd_out = remote_fd_out; + req->flag = flags; + + memcpy(req->gfid1, fd_in->inode->gfid, 16); + memcpy(req->gfid2, fd_out->inode->gfid, 16); + + dict_to_xdr(*xdata, &req->xdata); + + return 0; +out: + return -op_errno; +} + +int client_pre_statfs_v2(xlator_t *this, gfx_statfs_req *req, loc_t *loc, dict_t *xdata) { @@ -2609,7 +2642,8 @@ client_pre_fsync_v2(xlator_t *this, gfx_fsync_req *req, fd_t *fd, int32_t flags, int64_t remote_fd = -1; int op_errno = 0; - CLIENT_GET_REMOTE_FD(this, fd, DEFAULT_REMOTE_FD, remote_fd, op_errno, out); + CLIENT_GET_REMOTE_FD(this, fd, FALLBACK_TO_ANON_FD, remote_fd, op_errno, + out); req->fd = remote_fd; req->data = flags; @@ -2863,8 +2897,8 @@ client_pre_lk_v2(xlator_t *this, gfx_lk_req *req, int32_t cmd, ret = client_cmd_to_gf_cmd(cmd, &gf_cmd); if (ret) { op_errno = EINVAL; - gf_msg(this->name, GF_LOG_WARNING, EINVAL, PC_MSG_INVALID_ENTRY, - "Unknown cmd (%d)!", gf_cmd); + gf_smsg(this->name, GF_LOG_WARNING, EINVAL, PC_MSG_UNKNOWN_CMD, + "gf_cmd=%d", gf_cmd, NULL); goto out; } @@ -2973,8 +3007,8 @@ client_pre_inodelk_v2(xlator_t *this, gfx_inodelk_req *req, loc_t *loc, int cmd, else if (cmd == F_SETLKW || cmd == F_SETLKW64) gf_cmd = GF_LK_SETLKW; else { - gf_msg(this->name, GF_LOG_WARNING, EINVAL, PC_MSG_INVALID_ENTRY, - "Unknown cmd (%d)!", gf_cmd); + gf_smsg(this->name, GF_LOG_WARNING, EINVAL, PC_MSG_UNKNOWN_CMD, + "gf_cmd=%d", gf_cmd, NULL); op_errno = EINVAL; goto out; } @@ -3023,8 +3057,8 @@ client_pre_finodelk_v2(xlator_t *this, gfx_finodelk_req *req, fd_t *fd, int cmd, else if (cmd == F_SETLKW || cmd == F_SETLKW64) gf_cmd = GF_LK_SETLKW; else { - gf_msg(this->name, GF_LOG_WARNING, EINVAL, PC_MSG_INVALID_ENTRY, - "Unknown cmd (%d)!", gf_cmd); + gf_smsg(this->name, GF_LOG_WARNING, EINVAL, PC_MSG_UNKNOWN_CMD, + "gf_cmd=%d", gf_cmd, NULL); goto out; } diff --git a/xlators/protocol/client/src/client-common.h b/xlators/protocol/client/src/client-common.h index 21d416d9f27..a2043d8742a 100644 --- a/xlators/protocol/client/src/client-common.h +++ b/xlators/protocol/client/src/client-common.h @@ -11,8 +11,8 @@ #ifndef __CLIENT_COMMON_H__ #define __CLIENT_COMMON_H__ -#include "dict.h" -#include "xlator.h" +#include <glusterfs/dict.h> +#include <glusterfs/xlator.h> #include "rpc-common-xdr.h" #include "glusterfs3-xdr.h" #include "glusterfs4-xdr.h" @@ -621,4 +621,10 @@ client_post_rename_v2(xlator_t *this, gfx_rename_rsp *rsp, struct iatt *stbuf, struct iatt *prenewparent, struct iatt *postnewparent, dict_t **xdata); +int +client_pre_copy_file_range_v2(xlator_t *this, gfx_copy_file_range_req *req, + fd_t *fd_in, off64_t off_in, fd_t *fd_out, + off64_t off_out, size_t size, int32_t flags, + dict_t **xdata); + #endif /* __CLIENT_COMMON_H__ */ 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; diff --git a/xlators/protocol/client/src/client-helpers.c b/xlators/protocol/client/src/client-helpers.c index e81f166ba46..189dfddd021 100644 --- a/xlators/protocol/client/src/client-helpers.c +++ b/xlators/protocol/client/src/client-helpers.c @@ -9,11 +9,11 @@ */ #include "client.h" -#include "fd.h" +#include <glusterfs/fd.h> #include "client-messages.h" #include "client-common.h" -#include "compat-errno.h" -#include "common-utils.h" +#include <glusterfs/compat-errno.h> +#include <glusterfs/common-utils.h> int client_fd_lk_list_empty(fd_lk_ctx_t *lk_ctx, gf_boolean_t try_lock) @@ -91,23 +91,23 @@ this_fd_set_ctx(fd_t *file, xlator_t *this, loc_t *loc, clnt_fd_ctx_t *ctx) ret = fd_ctx_get(file, this, &oldaddr); if (ret >= 0) { if (loc) - gf_msg(this->name, GF_LOG_INFO, 0, PC_MSG_FD_DUPLICATE_TRY, - "%s (%s): trying duplicate remote fd set. ", loc->path, - uuid_utoa(loc->inode->gfid)); + gf_smsg(this->name, GF_LOG_INFO, 0, PC_MSG_FD_DUPLICATE_TRY, + "path=%s", loc->path, "gfid=%s", + uuid_utoa(loc->inode->gfid), NULL); else - gf_msg(this->name, GF_LOG_INFO, 0, PC_MSG_FD_DUPLICATE_TRY, - "%p: trying duplicate remote fd set. ", file); + gf_smsg(this->name, GF_LOG_INFO, 0, PC_MSG_FD_DUPLICATE_TRY, + "file=%p", file, NULL); } ret = fd_ctx_set(file, this, (uint64_t)(unsigned long)ctx); if (ret < 0) { if (loc) - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FD_SET_FAIL, - "%s (%s): failed to set remote fd", loc->path, - uuid_utoa(loc->inode->gfid)); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FD_SET_FAIL, + "path=%s", loc->path, "gfid=%s", + uuid_utoa(loc->inode->gfid), NULL); else - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FD_SET_FAIL, - "%p: failed to set remote fd", file); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FD_SET_FAIL, + "file=%p", file, NULL); } out: return; @@ -129,7 +129,6 @@ client_local_wipe(clnt_local_t *local) } GF_FREE(local->name); - local->compound_args = NULL; mem_put(local); } @@ -176,7 +175,6 @@ unserialize_rsp_direntp(xlator_t *this, fd_t *fd, struct gfs3_readdirp_rsp *rsp, gf_dirent_t *entries) { struct gfs3_dirplist *trav = NULL; - char *buf = NULL; gf_dirent_t *entry = NULL; inode_table_t *itable = NULL; int entry_len = 0; @@ -208,22 +206,17 @@ unserialize_rsp_direntp(xlator_t *this, fd_t *fd, struct gfs3_readdirp_rsp *rsp, strcpy(entry->d_name, trav->name); if (trav->dict.dict_val) { - /* Dictionary is sent along with response */ - buf = memdup(trav->dict.dict_val, trav->dict.dict_len); - if (!buf) - goto out; - entry->dict = dict_new(); + if (!entry->dict) + goto out; - ret = dict_unserialize(buf, trav->dict.dict_len, &entry->dict); + ret = dict_unserialize(trav->dict.dict_val, trav->dict.dict_len, + &entry->dict); if (ret < 0) { - gf_msg(THIS->name, GF_LOG_WARNING, EINVAL, - PC_MSG_DICT_UNSERIALIZE_FAIL, - "failed to unserialize xattr dict"); + gf_smsg(THIS->name, GF_LOG_WARNING, EINVAL, + PC_MSG_DICT_UNSERIALIZE_FAIL, "xattr", NULL); goto out; } - GF_FREE(buf); - buf = NULL; } entry->inode = inode_find(itable, entry->d_stat.ia_gfid); @@ -233,12 +226,13 @@ unserialize_rsp_direntp(xlator_t *this, fd_t *fd, struct gfs3_readdirp_rsp *rsp, list_add_tail(&entry->list, &entries->list); trav = trav->nextentry; + entry = NULL; } ret = 0; out: - if (buf) - GF_FREE(buf); + if (entry) + gf_dirent_entry_free(entry); return ret; } @@ -410,6 +404,7 @@ client_get_remote_fd(xlator_t *this, fd_t *fd, int flags, int64_t *remote_fd) { clnt_fd_ctx_t *fdctx = NULL; clnt_conf_t *conf = NULL; + gf_boolean_t locks_held = _gf_false; GF_VALIDATE_OR_GOTO(this->name, fd, out); GF_VALIDATE_OR_GOTO(this->name, remote_fd, out); @@ -419,17 +414,25 @@ client_get_remote_fd(xlator_t *this, fd_t *fd, int flags, int64_t *remote_fd) { fdctx = this_fd_get_ctx(fd, this); if (!fdctx) { - *remote_fd = GF_ANON_FD_NO; + if (fd->anonymous) { + *remote_fd = GF_ANON_FD_NO; + } else { + *remote_fd = -1; + gf_msg_debug(this->name, EBADF, "not a valid fd for gfid: %s", + uuid_utoa(fd->inode->gfid)); + } } else { if (__is_fd_reopen_in_progress(fdctx)) *remote_fd = -1; else *remote_fd = fdctx->remote_fd; + + locks_held = !list_empty(&fdctx->lock_list); } } pthread_spin_unlock(&conf->fd_lock); - if ((flags & FALLBACK_TO_ANON_FD) && (*remote_fd == -1)) + if ((flags & FALLBACK_TO_ANON_FD) && (*remote_fd == -1) && (!locks_held)) *remote_fd = GF_ANON_FD_NO; return 0; @@ -485,1140 +488,6 @@ out: return ret; } -int -client_process_response(call_frame_t *frame, xlator_t *this, - struct rpc_req *req, gfs3_compound_rsp *rsp, - compound_args_cbk_t *args_cbk, int index) -{ - int ret = 0; - dict_t *xdata = NULL; - dict_t *xattr = NULL; - struct iovec vector[MAX_IOVEC] = { - {0}, - }; - gf_dirent_t entries; - default_args_cbk_t *this_args_cbk = &args_cbk->rsp_list[index]; - clnt_local_t *local = frame->local; - compound_rsp *this_rsp = NULL; - compound_args_t *args = local->compound_args; - - this_rsp = &rsp->compound_rsp_array.compound_rsp_array_val[index]; - args_cbk->enum_list[index] = this_rsp->fop_enum; - - INIT_LIST_HEAD(&entries.list); - - switch (args_cbk->enum_list[index]) { - case GF_FOP_STAT: { - gfs3_stat_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_stat_rsp; - - client_post_stat(this, tmp_rsp, &this_args_cbk->stat, &xdata); - - CLIENT_POST_FOP_TYPE(stat, this_rsp, this_args_cbk, - &this_args_cbk->stat, xdata); - break; - } - case GF_FOP_READLINK: { - gfs3_readlink_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_readlink_rsp; - - client_post_readlink(this, tmp_rsp, &this_args_cbk->stat, &xdata); - CLIENT_POST_FOP_TYPE(readlink, this_rsp, this_args_cbk, - tmp_rsp->path, &this_args_cbk->stat, xdata); - break; - } - case GF_FOP_MKNOD: { - gfs3_mknod_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_mknod_rsp; - - client_post_mknod(this, tmp_rsp, &this_args_cbk->stat, - &this_args_cbk->preparent, - &this_args_cbk->postparent, &xdata); - CLIENT_POST_FOP_TYPE(mknod, this_rsp, this_args_cbk, - local->loc.inode, &this_args_cbk->stat, - &this_args_cbk->preparent, - &this_args_cbk->postparent, xdata); - break; - } - case GF_FOP_MKDIR: { - gfs3_mkdir_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_mkdir_rsp; - - client_post_mkdir(this, tmp_rsp, &this_args_cbk->stat, - &this_args_cbk->preparent, - &this_args_cbk->postparent, &xdata); - CLIENT_POST_FOP_TYPE(mkdir, this_rsp, this_args_cbk, - local->loc.inode, &this_args_cbk->stat, - &this_args_cbk->preparent, - &this_args_cbk->postparent, xdata); - break; - } - case GF_FOP_UNLINK: { - gfs3_unlink_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_unlink_rsp; - - client_post_unlink(this, tmp_rsp, &this_args_cbk->preparent, - &this_args_cbk->postparent, &xdata); - CLIENT_POST_FOP_TYPE(unlink, this_rsp, this_args_cbk, - &this_args_cbk->preparent, - &this_args_cbk->postparent, xdata); - break; - } - case GF_FOP_RMDIR: { - gfs3_rmdir_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_rmdir_rsp; - - client_post_rmdir(this, tmp_rsp, &this_args_cbk->preparent, - &this_args_cbk->postparent, &xdata); - CLIENT_POST_FOP_TYPE(rmdir, this_rsp, this_args_cbk, - &this_args_cbk->preparent, - &this_args_cbk->postparent, xdata); - break; - } - case GF_FOP_SYMLINK: { - gfs3_symlink_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_symlink_rsp; - - client_post_symlink(this, tmp_rsp, &this_args_cbk->stat, - &this_args_cbk->preparent, - &this_args_cbk->postparent, &xdata); - CLIENT_POST_FOP_TYPE( - symlink, this_rsp, this_args_cbk, NULL, &this_args_cbk->stat, - &this_args_cbk->preparent, &this_args_cbk->postparent, xdata); - break; - } - case GF_FOP_RENAME: { - gfs3_rename_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_rename_rsp; - - client_post_rename( - this, tmp_rsp, &this_args_cbk->stat, &this_args_cbk->preparent, - &this_args_cbk->postparent, &this_args_cbk->preparent2, - &this_args_cbk->postparent2, &xdata); - CLIENT_POST_FOP_TYPE( - rename, this_rsp, this_args_cbk, &this_args_cbk->stat, - &this_args_cbk->preparent, &this_args_cbk->postparent, - &this_args_cbk->preparent2, &this_args_cbk->postparent2, xdata); - break; - } - case GF_FOP_LINK: { - gfs3_link_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_link_rsp; - - client_post_link(this, tmp_rsp, &this_args_cbk->stat, - &this_args_cbk->preparent, - &this_args_cbk->postparent, &xdata); - CLIENT_POST_FOP_TYPE( - link, this_rsp, this_args_cbk, NULL, &this_args_cbk->stat, - &this_args_cbk->preparent, &this_args_cbk->postparent, xdata); - break; - } - case GF_FOP_TRUNCATE: { - gfs3_truncate_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_truncate_rsp; - - client_post_truncate(this, tmp_rsp, &this_args_cbk->prestat, - &this_args_cbk->poststat, &xdata); - CLIENT_POST_FOP_TYPE(truncate, this_rsp, this_args_cbk, - &this_args_cbk->prestat, - &this_args_cbk->poststat, xdata); - break; - } - case GF_FOP_OPEN: { - gfs3_open_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_open_rsp; - - client_post_open(this, tmp_rsp, &xdata); - CLIENT_POST_FOP_TYPE(open, this_rsp, this_args_cbk, local->fd, - xdata); - if (-1 != this_args_cbk->op_ret) - ret = client_add_fd_to_saved_fds(this, local->fd, &local->loc, - args->req_list[index].flags, - tmp_rsp->fd, 0); - break; - } - case GF_FOP_READ: { - gfs3_read_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_read_rsp; - - client_post_readv(this, tmp_rsp, &this_args_cbk->iobref, - req->rsp_iobref, &this_args_cbk->stat, vector, - &req->rsp[1], &this_args_cbk->count, &xdata); - - /* Each read should be given read response that only - * corresponds to its request. - * Modify the iovecs accordingly. - * After each read, store the length of data already read - * so that the next ones can continue from there. - */ - if (local->read_length) { - vector[0].iov_base += local->read_length; - local->read_length += tmp_rsp->op_ret; - } else { - local->read_length = tmp_rsp->op_ret; - } - - args_readv_cbk_store(this_args_cbk, tmp_rsp->op_ret, - gf_error_to_errno(tmp_rsp->op_errno), vector, - this_args_cbk->count, &this_args_cbk->stat, - this_args_cbk->iobref, xdata); - - if (tmp_rsp->op_ret >= 0) - if (local->attempt_reopen) - client_attempt_reopen(local->fd, this); - - break; - } - case GF_FOP_WRITE: { - gfs3_write_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_write_rsp; - - client_post_writev(this, tmp_rsp, &this_args_cbk->prestat, - &this_args_cbk->poststat, &xdata); - args_writev_cbk_store(this_args_cbk, tmp_rsp->op_ret, - gf_error_to_errno(tmp_rsp->op_errno), - &this_args_cbk->prestat, - &this_args_cbk->poststat, xdata); - - if (tmp_rsp->op_ret == 0) - if (local->attempt_reopen) - client_attempt_reopen(local->fd, this); - break; - } - case GF_FOP_STATFS: { - gfs3_statfs_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_statfs_rsp; - - client_post_statfs(this, tmp_rsp, &this_args_cbk->statvfs, &xdata); - - CLIENT_POST_FOP_TYPE(statfs, this_rsp, this_args_cbk, - &this_args_cbk->statvfs, xdata); - break; - } - case GF_FOP_FLUSH: { - gf_common_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_flush_rsp; - - client_post_flush(this, tmp_rsp, &xdata); - - CLIENT_POST_FOP(flush, this_rsp, this_args_cbk, xdata); - if (this_args_cbk->op_ret >= 0 && !fd_is_anonymous(local->fd)) { - /* Delete all saved locks of the owner issuing flush */ - ret = delete_granted_locks_owner(local->fd, &local->owner); - gf_msg_trace(this->name, 0, - "deleting locks of owner (%s) returned %d", - lkowner_utoa(&local->owner), ret); - } - break; - } - case GF_FOP_FSYNC: { - gfs3_fsync_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_fsync_rsp; - - client_post_fsync(this, tmp_rsp, &this_args_cbk->prestat, - &this_args_cbk->poststat, &xdata); - - CLIENT_POST_FOP_TYPE(fsync, this_rsp, this_args_cbk, - &this_args_cbk->prestat, - &this_args_cbk->poststat, xdata); - break; - } - case GF_FOP_SETXATTR: { - gf_common_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_setxattr_rsp; - - client_post_setxattr(this, tmp_rsp, &xdata); - - CLIENT_POST_FOP(setxattr, this_rsp, this_args_cbk, xdata); - break; - } - case GF_FOP_GETXATTR: { - gfs3_getxattr_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_getxattr_rsp; - - client_post_getxattr(this, tmp_rsp, &xattr, &xdata); - - CLIENT_POST_FOP_TYPE(getxattr, this_rsp, this_args_cbk, xattr, - xdata); - break; - } - case GF_FOP_REMOVEXATTR: { - gf_common_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_removexattr_rsp; - - client_post_removexattr(this, tmp_rsp, &xdata); - - CLIENT_POST_FOP(removexattr, this_rsp, this_args_cbk, xdata); - break; - } - case GF_FOP_OPENDIR: { - gfs3_opendir_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_opendir_rsp; - - client_post_opendir(this, tmp_rsp, &xdata); - - CLIENT_POST_FOP_TYPE(opendir, this_rsp, this_args_cbk, local->fd, - xdata); - if (-1 != this_args_cbk->op_ret) - ret = client_add_fd_to_saved_fds(this, local->fd, &local->loc, - args->req_list[index].flags, - tmp_rsp->fd, 0); - break; - } - case GF_FOP_FSYNCDIR: { - gf_common_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_fsyncdir_rsp; - - client_post_fsyncdir(this, tmp_rsp, &xdata); - - CLIENT_POST_FOP(fsyncdir, this_rsp, this_args_cbk, xdata); - break; - } - case GF_FOP_ACCESS: { - gf_common_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_access_rsp; - - client_post_access(this, tmp_rsp, &xdata); - - CLIENT_POST_FOP(access, this_rsp, this_args_cbk, xdata); - break; - } - case GF_FOP_CREATE: { - gfs3_create_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_create_rsp; - - client_post_create(this, tmp_rsp, &this_args_cbk->stat, - &this_args_cbk->preparent, - &this_args_cbk->postparent, local, &xdata); - - CLIENT_POST_FOP_TYPE(create, this_rsp, this_args_cbk, local->fd, - local->loc.inode, &this_args_cbk->stat, - &this_args_cbk->preparent, - &this_args_cbk->postparent, xdata); - if (-1 != this_args_cbk->op_ret) - ret = client_add_fd_to_saved_fds(this, local->fd, &local->loc, - args->req_list[index].flags, - tmp_rsp->fd, 0); - break; - } - case GF_FOP_FTRUNCATE: { - gfs3_ftruncate_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_ftruncate_rsp; - - client_post_ftruncate(this, tmp_rsp, &this_args_cbk->prestat, - &this_args_cbk->poststat, &xdata); - CLIENT_POST_FOP_TYPE(ftruncate, this_rsp, this_args_cbk, - &this_args_cbk->prestat, - &this_args_cbk->poststat, xdata); - break; - } - case GF_FOP_FSTAT: { - gfs3_fstat_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_fstat_rsp; - - client_post_fstat(this, tmp_rsp, &this_args_cbk->stat, &xdata); - - CLIENT_POST_FOP_TYPE(fstat, this_rsp, this_args_cbk, - &this_args_cbk->stat, xdata); - break; - } - case GF_FOP_LK: { - gfs3_lk_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_lk_rsp; - - client_post_lk(this, tmp_rsp, &this_args_cbk->lock, &xdata); - - CLIENT_POST_FOP_TYPE(lk, this_rsp, this_args_cbk, - &this_args_cbk->lock, xdata); - break; - } - case GF_FOP_LOOKUP: { - gfs3_lookup_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_lookup_rsp; - - client_post_lookup(this, tmp_rsp, &this_args_cbk->stat, - &this_args_cbk->postparent, &xdata); - CLIENT_POST_FOP_TYPE(lookup, this_rsp, this_args_cbk, - local->loc.inode, &this_args_cbk->stat, xdata, - &this_args_cbk->postparent); - break; - } - case GF_FOP_READDIR: { - gfs3_readdir_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_readdir_rsp; - - client_post_readdir(this, tmp_rsp, &entries, &xdata); - - CLIENT_POST_FOP_TYPE(readdir, this_rsp, this_args_cbk, &entries, - xdata); - break; - } - case GF_FOP_INODELK: { - gf_common_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_inodelk_rsp; - - client_post_inodelk(this, tmp_rsp, &xdata); - - CLIENT_POST_FOP(inodelk, this_rsp, this_args_cbk, xdata); - break; - } - case GF_FOP_FINODELK: { - gf_common_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_finodelk_rsp; - - client_post_finodelk(this, tmp_rsp, &xdata); - - CLIENT_POST_FOP(finodelk, this_rsp, this_args_cbk, xdata); - if (tmp_rsp->op_ret == 0) - if (local->attempt_reopen) - client_attempt_reopen(local->fd, this); - break; - } - case GF_FOP_ENTRYLK: { - gf_common_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_entrylk_rsp; - - client_post_entrylk(this, tmp_rsp, &xdata); - - CLIENT_POST_FOP(entrylk, this_rsp, this_args_cbk, xdata); - break; - } - case GF_FOP_FENTRYLK: { - gf_common_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_fentrylk_rsp; - - client_post_fentrylk(this, tmp_rsp, &xdata); - - CLIENT_POST_FOP(fentrylk, this_rsp, this_args_cbk, xdata); - break; - } - case GF_FOP_XATTROP: { - gfs3_xattrop_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_xattrop_rsp; - - client_post_xattrop(this, tmp_rsp, &xattr, &xdata); - - CLIENT_POST_FOP_TYPE(xattrop, this_rsp, this_args_cbk, xattr, - xdata); - break; - } - case GF_FOP_FXATTROP: { - gfs3_fxattrop_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_fxattrop_rsp; - - client_post_fxattrop(this, tmp_rsp, &xattr, &xdata); - - CLIENT_POST_FOP_TYPE(fxattrop, this_rsp, this_args_cbk, xattr, - xdata); - if (rsp->op_ret == 0) - if (local->attempt_reopen) - client_attempt_reopen(local->fd, this); - break; - } - case GF_FOP_FGETXATTR: { - gfs3_fgetxattr_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_fgetxattr_rsp; - - client_post_fgetxattr(this, tmp_rsp, &xattr, &xdata); - - CLIENT_POST_FOP_TYPE(fgetxattr, this_rsp, this_args_cbk, xattr, - xdata); - break; - } - case GF_FOP_FSETXATTR: { - gf_common_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_fsetxattr_rsp; - - client_post_fsetxattr(this, tmp_rsp, &xdata); - - CLIENT_POST_FOP(fsetxattr, this_rsp, this_args_cbk, xdata); - break; - } - case GF_FOP_RCHECKSUM: { - gfs3_rchecksum_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_rchecksum_rsp; - - client_post_rchecksum(this, tmp_rsp, &xdata); - - break; - CLIENT_POST_FOP_TYPE( - rchecksum, this_rsp, this_args_cbk, tmp_rsp->weak_checksum, - (uint8_t *)tmp_rsp->strong_checksum.strong_checksum_val, xdata); - break; - } - case GF_FOP_SETATTR: { - gfs3_setattr_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_setattr_rsp; - - client_post_setattr(this, tmp_rsp, &this_args_cbk->prestat, - &this_args_cbk->poststat, &xdata); - - CLIENT_POST_FOP_TYPE(setattr, this_rsp, this_args_cbk, - &this_args_cbk->prestat, - &this_args_cbk->poststat, xdata); - break; - } - case GF_FOP_FSETATTR: { - gfs3_fsetattr_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_fsetattr_rsp; - - client_post_fsetattr(this, tmp_rsp, &this_args_cbk->prestat, - &this_args_cbk->poststat, &xdata); - - CLIENT_POST_FOP_TYPE(fsetattr, this_rsp, this_args_cbk, - &this_args_cbk->prestat, - &this_args_cbk->poststat, xdata); - break; - } - case GF_FOP_READDIRP: { - gfs3_readdirp_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_readdirp_rsp; - - client_post_readdirp(this, tmp_rsp, local->fd, &entries, &xdata); - - CLIENT_POST_FOP_TYPE(readdirp, this_rsp, this_args_cbk, &entries, - xdata); - break; - } - case GF_FOP_FREMOVEXATTR: { - gf_common_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_fremovexattr_rsp; - - client_post_fremovexattr(this, tmp_rsp, &xdata); - - CLIENT_POST_FOP(fremovexattr, this_rsp, this_args_cbk, xdata); - break; - } - case GF_FOP_FALLOCATE: { - gfs3_fallocate_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_fallocate_rsp; - - client_post_fallocate(this, tmp_rsp, &this_args_cbk->prestat, - &this_args_cbk->poststat, &xdata); - - CLIENT_POST_FOP_TYPE(fallocate, this_rsp, this_args_cbk, - &this_args_cbk->prestat, - &this_args_cbk->poststat, xdata); - break; - } - case GF_FOP_DISCARD: { - gfs3_discard_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_discard_rsp; - - client_post_discard(this, tmp_rsp, &this_args_cbk->prestat, - &this_args_cbk->poststat, &xdata); - - CLIENT_POST_FOP_TYPE(discard, this_rsp, this_args_cbk, - &this_args_cbk->prestat, - &this_args_cbk->poststat, xdata); - break; - } - case GF_FOP_ZEROFILL: { - gfs3_zerofill_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_zerofill_rsp; - - client_post_zerofill(this, tmp_rsp, &this_args_cbk->prestat, - &this_args_cbk->poststat, &xdata); - - CLIENT_POST_FOP_TYPE(zerofill, this_rsp, this_args_cbk, - &this_args_cbk->prestat, - &this_args_cbk->poststat, xdata); - break; - } - case GF_FOP_IPC: { - gfs3_ipc_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_ipc_rsp; - - client_post_ipc(this, tmp_rsp, &xdata); - - CLIENT_POST_FOP_TYPE(ipc, this_rsp, this_args_cbk, xdata); - break; - } - case GF_FOP_SEEK: { - gfs3_seek_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_seek_rsp; - - client_post_seek(this, tmp_rsp, &xdata); - - CLIENT_POST_FOP_TYPE(seek, this_rsp, this_args_cbk, tmp_rsp->offset, - xdata); - break; - } - case GF_FOP_LEASE: { - gfs3_lease_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_u.compound_lease_rsp; - - client_post_lease(this, tmp_rsp, &this_args_cbk->lease, &xdata); - - CLIENT_POST_FOP_TYPE(lease, this_rsp, this_args_cbk, - &this_args_cbk->lease, xdata); - break; - } - default: - return -ENOTSUP; - } - - if (xdata) - dict_unref(xdata); - if (xattr) - dict_unref(xattr); - gf_dirent_free(&entries); - return 0; -} - -int -client_handle_fop_requirements( - xlator_t *this, call_frame_t *frame, gfs3_compound_req *req, - clnt_local_t *local, struct iobref **req_iobref, struct iobref **rsp_iobref, - struct iovec *req_vector, struct iovec *rsp_vector, int *req_count, - int *rsp_count, default_args_t *args, int fop_enum, int index) -{ - int ret = 0; - int op_errno = ENOMEM; - struct iobuf *rsp_iobuf = NULL; - int64_t remote_fd = -1; - compound_req *this_req = &req->compound_req_array - .compound_req_array_val[index]; - - this_req->fop_enum = fop_enum; - - switch (fop_enum) { - case GF_FOP_STAT: - CLIENT_PRE_FOP(stat, this, - &this_req->compound_req_u.compound_stat_req, - op_errno, out, &args->loc, args->xdata); - break; - case GF_FOP_READLINK: - CLIENT_PRE_FOP(readlink, this, - &this_req->compound_req_u.compound_readlink_req, - op_errno, out, &args->loc, args->size, args->xdata); - break; - case GF_FOP_MKNOD: - CLIENT_PRE_FOP(mknod, this, - &this_req->compound_req_u.compound_mknod_req, - op_errno, out, &args->loc, args->mode, args->rdev, - args->umask, args->xdata); - loc_copy(&local->loc, &args->loc); - loc_path(&local->loc, NULL); - break; - case GF_FOP_MKDIR: - CLIENT_PRE_FOP(mkdir, this, - &this_req->compound_req_u.compound_mkdir_req, - op_errno, out, &args->loc, args->mode, args->umask, - args->xdata); - loc_copy(&local->loc, &args->loc); - loc_path(&local->loc, NULL); - break; - case GF_FOP_UNLINK: - CLIENT_PRE_FOP(unlink, this, - &this_req->compound_req_u.compound_unlink_req, - op_errno, out, &args->loc, args->xflag, args->xdata); - break; - case GF_FOP_RMDIR: - CLIENT_PRE_FOP(rmdir, this, - &this_req->compound_req_u.compound_rmdir_req, - op_errno, out, &args->loc, args->flags, args->xdata); - break; - case GF_FOP_SYMLINK: - CLIENT_PRE_FOP(symlink, this, - &this_req->compound_req_u.compound_symlink_req, - op_errno, out, &args->loc, args->linkname, - args->umask, args->xdata); - loc_copy(&local->loc, &args->loc); - loc_path(&local->loc, NULL); - break; - case GF_FOP_RENAME: - CLIENT_PRE_FOP(rename, this, - &this_req->compound_req_u.compound_rename_req, - op_errno, out, &args->loc, &args->loc2, args->xdata); - break; - case GF_FOP_LINK: - CLIENT_PRE_FOP(link, this, - &this_req->compound_req_u.compound_link_req, - op_errno, out, &args->loc, &args->loc2, args->xdata); - break; - case GF_FOP_TRUNCATE: - CLIENT_PRE_FOP( - truncate, this, &this_req->compound_req_u.compound_truncate_req, - op_errno, out, &args->loc, args->offset, args->xdata); - break; - case GF_FOP_OPEN: - CLIENT_PRE_FOP( - open, this, &this_req->compound_req_u.compound_open_req, - op_errno, out, &args->loc, args->fd, args->flags, args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - break; - case GF_FOP_READ: - op_errno = client_pre_readv( - this, &this_req->compound_req_u.compound_read_req, args->fd, - args->size, args->offset, args->flags, args->xdata); - - if (op_errno) { - op_errno = -op_errno; - goto out; - } - if (!local->fd) - local->fd = fd_ref(args->fd); - local->attempt_reopen = client_is_reopen_needed(args->fd, this, - remote_fd); - rsp_iobuf = iobuf_get2(this->ctx->iobuf_pool, args->size); - if (rsp_iobuf == NULL) { - op_errno = ENOMEM; - goto out; - } - - if (!*rsp_iobref) { - *rsp_iobref = iobref_new(); - if (*rsp_iobref == NULL) { - op_errno = ENOMEM; - goto out; - } - } - - if (*rsp_count + 1 >= MAX_IOVEC) { - op_errno = ENOMEM; - goto out; - } - rsp_vector[*rsp_count].iov_base = iobuf_ptr(rsp_iobuf); - rsp_vector[*rsp_count].iov_len = iobuf_pagesize(rsp_iobuf); - iobref_add(*rsp_iobref, rsp_iobuf); - iobuf_unref(rsp_iobuf); - rsp_iobuf = NULL; - if (args->size > rsp_vector[*rsp_count].iov_len) { - gf_msg(this->name, GF_LOG_WARNING, ENOMEM, PC_MSG_NO_MEMORY, - "read-size (%lu) is bigger than iobuf size " - "(%lu)", - (unsigned long)args->size, - (unsigned long)rsp_vector[*rsp_count].iov_len); - op_errno = EINVAL; - goto out; - } - *rsp_count += 1; - - break; - case GF_FOP_WRITE: - op_errno = client_pre_writev( - this, &this_req->compound_req_u.compound_write_req, args->fd, - iov_length(args->vector, args->count), args->offset, - args->flags, &args->xdata); - - if (op_errno) { - op_errno = -op_errno; - goto out; - } - if (!local->fd) - local->fd = fd_ref(args->fd); - local->attempt_reopen = client_is_reopen_needed(args->fd, this, - remote_fd); - - if (*req_count + args->count >= MAX_IOVEC) { - op_errno = ENOMEM; - goto out; - } - memcpy(&req_vector[*req_count], args->vector, - (args->count * sizeof(req_vector[0]))); - *req_count += args->count; - - if (!*req_iobref) - *req_iobref = args->iobref; - else if (iobref_merge(*req_iobref, args->iobref)) - goto out; - break; - case GF_FOP_STATFS: - CLIENT_PRE_FOP(statfs, this, - &this_req->compound_req_u.compound_statfs_req, - op_errno, out, &args->loc, args->xdata); - break; - case GF_FOP_FLUSH: - CLIENT_PRE_FOP(flush, this, - &this_req->compound_req_u.compound_flush_req, - op_errno, out, args->fd, args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - local->owner = frame->root->lk_owner; - break; - case GF_FOP_FSYNC: - CLIENT_PRE_FOP( - fsync, this, &this_req->compound_req_u.compound_fsync_req, - op_errno, out, args->fd, args->datasync, args->xdata); - break; - case GF_FOP_SETXATTR: - CLIENT_PRE_FOP(setxattr, this, - &this_req->compound_req_u.compound_setxattr_req, - op_errno, out, &args->loc, args->xattr, args->flags, - args->xdata); - break; - case GF_FOP_GETXATTR: - CLIENT_PRE_FOP(getxattr, this, - &this_req->compound_req_u.compound_getxattr_req, - op_errno, out, &args->loc, args->name, args->xdata); - loc_copy(&local->loc, &args->loc); - loc_path(&local->loc, NULL); - break; - case GF_FOP_REMOVEXATTR: - CLIENT_PRE_FOP(removexattr, this, - &this_req->compound_req_u.compound_removexattr_req, - op_errno, out, &args->loc, args->name, args->xdata); - break; - case GF_FOP_OPENDIR: - CLIENT_PRE_FOP(opendir, this, - &this_req->compound_req_u.compound_opendir_req, - op_errno, out, &args->loc, args->fd, args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - loc_copy(&local->loc, &args->loc); - loc_path(&local->loc, NULL); - break; - case GF_FOP_FSYNCDIR: - CLIENT_PRE_FOP( - fsyncdir, this, &this_req->compound_req_u.compound_fsyncdir_req, - op_errno, out, args->fd, args->datasync, args->xdata); - break; - case GF_FOP_ACCESS: - CLIENT_PRE_FOP(access, this, - &this_req->compound_req_u.compound_access_req, - op_errno, out, &args->loc, args->mask, args->xdata); - break; - case GF_FOP_CREATE: - CLIENT_PRE_FOP(create, this, - &this_req->compound_req_u.compound_create_req, - op_errno, out, &args->loc, args->fd, args->mode, - args->flags, args->umask, args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - - loc_copy(&local->loc, &args->loc); - loc_path(&local->loc, NULL); - break; - case GF_FOP_FTRUNCATE: - CLIENT_PRE_FOP(ftruncate, this, - &this_req->compound_req_u.compound_ftruncate_req, - op_errno, out, args->fd, args->offset, args->xdata); - break; - case GF_FOP_FSTAT: - CLIENT_PRE_FOP(fstat, this, - &this_req->compound_req_u.compound_fstat_req, - op_errno, out, args->fd, args->xdata); - break; - case GF_FOP_LK: - CLIENT_PRE_FOP(lk, this, &this_req->compound_req_u.compound_lk_req, - op_errno, out, args->cmd, &args->lock, args->fd, - args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - local->owner = frame->root->lk_owner; - break; - case GF_FOP_LOOKUP: - CLIENT_PRE_FOP(lookup, this, - &this_req->compound_req_u.compound_lookup_req, - op_errno, out, &args->loc, args->xdata); - loc_copy(&local->loc, &args->loc); - loc_path(&local->loc, NULL); - break; - case GF_FOP_READDIR: - CLIENT_PRE_FOP( - readdir, this, &this_req->compound_req_u.compound_readdir_req, - op_errno, out, args->fd, args->size, args->offset, args->xdata); - break; - case GF_FOP_INODELK: - CLIENT_PRE_FOP(inodelk, this, - &this_req->compound_req_u.compound_inodelk_req, - op_errno, out, &args->loc, args->cmd, &args->lock, - args->volume, args->xdata); - break; - case GF_FOP_FINODELK: - CLIENT_PRE_FOP(finodelk, this, - &this_req->compound_req_u.compound_finodelk_req, - op_errno, out, args->fd, args->cmd, &args->lock, - args->volume, args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - local->attempt_reopen = client_is_reopen_needed(args->fd, this, - remote_fd); - break; - case GF_FOP_ENTRYLK: - CLIENT_PRE_FOP( - entrylk, this, &this_req->compound_req_u.compound_entrylk_req, - op_errno, out, &args->loc, args->entrylkcmd, args->entrylktype, - args->volume, args->name, args->xdata); - break; - case GF_FOP_FENTRYLK: - CLIENT_PRE_FOP( - fentrylk, this, &this_req->compound_req_u.compound_fentrylk_req, - op_errno, out, args->fd, args->entrylkcmd, args->entrylktype, - args->volume, args->name, args->xdata); - break; - case GF_FOP_XATTROP: - CLIENT_PRE_FOP(xattrop, this, - &this_req->compound_req_u.compound_xattrop_req, - op_errno, out, &args->loc, args->xattr, args->optype, - args->xdata); - break; - case GF_FOP_FXATTROP: - CLIENT_PRE_FOP(fxattrop, this, - &this_req->compound_req_u.compound_fxattrop_req, - op_errno, out, args->fd, args->xattr, args->optype, - args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - local->attempt_reopen = client_is_reopen_needed(args->fd, this, - remote_fd); - break; - case GF_FOP_FGETXATTR: - CLIENT_PRE_FOP(fgetxattr, this, - &this_req->compound_req_u.compound_fgetxattr_req, - op_errno, out, args->fd, args->name, args->xdata); - break; - case GF_FOP_FSETXATTR: - CLIENT_PRE_FOP(fsetxattr, this, - &this_req->compound_req_u.compound_fsetxattr_req, - op_errno, out, args->fd, args->flags, args->xattr, - args->xdata); - break; - case GF_FOP_RCHECKSUM: - CLIENT_PRE_FOP(rchecksum, this, - &this_req->compound_req_u.compound_rchecksum_req, - op_errno, out, args->fd, args->size, args->offset, - args->xdata); - break; - case GF_FOP_SETATTR: - CLIENT_PRE_FOP(setattr, this, - &this_req->compound_req_u.compound_setattr_req, - op_errno, out, &args->loc, args->valid, &args->stat, - args->xdata); - break; - case GF_FOP_FSETATTR: - CLIENT_PRE_FOP( - fsetattr, this, &this_req->compound_req_u.compound_fsetattr_req, - op_errno, out, args->fd, args->valid, &args->stat, args->xdata); - break; - case GF_FOP_READDIRP: - CLIENT_PRE_FOP( - readdirp, this, &this_req->compound_req_u.compound_readdirp_req, - op_errno, out, args->fd, args->size, args->offset, args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - break; - case GF_FOP_FREMOVEXATTR: - CLIENT_PRE_FOP(fremovexattr, this, - &this_req->compound_req_u.compound_fremovexattr_req, - op_errno, out, args->fd, args->name, args->xdata); - break; - case GF_FOP_FALLOCATE: - CLIENT_PRE_FOP(fallocate, this, - &this_req->compound_req_u.compound_fallocate_req, - op_errno, out, args->fd, args->flags, args->offset, - args->size, args->xdata); - break; - case GF_FOP_DISCARD: - CLIENT_PRE_FOP( - discard, this, &this_req->compound_req_u.compound_discard_req, - op_errno, out, args->fd, args->offset, args->size, args->xdata); - break; - case GF_FOP_ZEROFILL: - CLIENT_PRE_FOP( - zerofill, this, &this_req->compound_req_u.compound_zerofill_req, - op_errno, out, args->fd, args->offset, args->size, args->xdata); - break; - case GF_FOP_IPC: - CLIENT_PRE_FOP(ipc, this, - &this_req->compound_req_u.compound_ipc_req, op_errno, - out, args->cmd, args->xdata); - break; - case GF_FOP_SEEK: - CLIENT_PRE_FOP( - seek, this, &this_req->compound_req_u.compound_seek_req, - op_errno, out, args->fd, args->offset, args->what, args->xdata); - break; - case GF_FOP_LEASE: - CLIENT_PRE_FOP( - lease, this, &this_req->compound_req_u.compound_lease_req, - op_errno, out, &args->loc, &args->lease, args->xdata); - break; - default: - return ENOTSUP; - } - return 0; -out: - return op_errno; -} - -void -compound_request_cleanup(gfs3_compound_req *req) -{ - int i = 0; - int length = req->compound_req_array.compound_req_array_len; - compound_req *curr_req = NULL; - - if (!req->compound_req_array.compound_req_array_val) - return; - - for (i = 0; i < length; i++) { - curr_req = &req->compound_req_array.compound_req_array_val[i]; - - switch (curr_req->fop_enum) { - case GF_FOP_STAT: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, stat); - break; - case GF_FOP_READLINK: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, readlink); - break; - case GF_FOP_MKNOD: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, mknod); - break; - case GF_FOP_MKDIR: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, mkdir); - break; - case GF_FOP_UNLINK: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, unlink); - break; - case GF_FOP_RMDIR: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, rmdir); - break; - case GF_FOP_SYMLINK: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, symlink); - break; - case GF_FOP_RENAME: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, rename); - break; - case GF_FOP_LINK: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, link); - break; - case GF_FOP_TRUNCATE: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, truncate); - break; - case GF_FOP_OPEN: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, open); - break; - case GF_FOP_READ: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, read); - break; - case GF_FOP_WRITE: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, write); - break; - case GF_FOP_STATFS: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, statfs); - break; - case GF_FOP_FLUSH: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, flush); - break; - case GF_FOP_FSYNC: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, fsync); - break; - case GF_FOP_SETXATTR: { - gfs3_setxattr_req *args = &CPD_REQ_FIELD(curr_req, setxattr); - GF_FREE(args->dict.dict_val); - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, setxattr); - break; - } - case GF_FOP_GETXATTR: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, getxattr); - break; - case GF_FOP_REMOVEXATTR: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, removexattr); - break; - case GF_FOP_OPENDIR: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, opendir); - break; - case GF_FOP_FSYNCDIR: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, fsyncdir); - break; - case GF_FOP_ACCESS: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, access); - break; - case GF_FOP_CREATE: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, create); - break; - case GF_FOP_FTRUNCATE: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, ftruncate); - break; - case GF_FOP_FSTAT: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, fstat); - break; - case GF_FOP_LK: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, lk); - break; - case GF_FOP_LOOKUP: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, lookup); - break; - case GF_FOP_READDIR: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, readdir); - break; - case GF_FOP_INODELK: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, inodelk); - break; - case GF_FOP_FINODELK: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, finodelk); - break; - case GF_FOP_ENTRYLK: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, entrylk); - break; - case GF_FOP_FENTRYLK: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, fentrylk); - break; - case GF_FOP_XATTROP: { - gfs3_xattrop_req *args = &CPD_REQ_FIELD(curr_req, xattrop); - GF_FREE(args->dict.dict_val); - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, xattrop); - break; - } - case GF_FOP_FXATTROP: { - gfs3_fxattrop_req *args = &CPD_REQ_FIELD(curr_req, fxattrop); - GF_FREE(args->dict.dict_val); - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, fxattrop); - break; - } - case GF_FOP_FGETXATTR: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, fgetxattr); - break; - case GF_FOP_FSETXATTR: { - gfs3_fsetxattr_req *args = &CPD_REQ_FIELD(curr_req, fsetxattr); - GF_FREE(args->dict.dict_val); - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, fsetxattr); - break; - } - case GF_FOP_RCHECKSUM: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, rchecksum); - break; - case GF_FOP_SETATTR: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, setattr); - break; - case GF_FOP_FSETATTR: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, fsetattr); - break; - case GF_FOP_READDIRP: { - gfs3_readdirp_req *args = &CPD_REQ_FIELD(curr_req, readdirp); - GF_FREE(args->dict.dict_val); - break; - } - case GF_FOP_FREMOVEXATTR: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, fremovexattr); - break; - case GF_FOP_FALLOCATE: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, fallocate); - break; - case GF_FOP_DISCARD: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, discard); - break; - case GF_FOP_ZEROFILL: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, zerofill); - break; - case GF_FOP_IPC: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, ipc); - break; - case GF_FOP_SEEK: - CLIENT_COMPOUND_FOP_CLEANUP(curr_req, seek); - break; - default: - break; - } - } - - GF_FREE(req->compound_req_array.compound_req_array_val); - return; -} - void clnt_getactivelk_rsp_cleanup(gfs3_getactivelk_rsp *rsp) { @@ -1668,7 +537,7 @@ clnt_unserialize_rsp_locklist(xlator_t *this, struct gfs3_getactivelk_rsp *rsp, while (trav) { temp = GF_CALLOC(1, sizeof(*lmi), gf_common_mt_lock_mig); if (temp == NULL) { - gf_msg(this->name, GF_LOG_ERROR, 0, 0, "No memory"); + gf_smsg(this->name, GF_LOG_ERROR, 0, PC_MSG_NO_MEM, NULL); goto out; } @@ -1708,7 +577,7 @@ clnt_unserialize_rsp_locklist_v2(xlator_t *this, while (trav) { temp = GF_CALLOC(1, sizeof(*lmi), gf_common_mt_lock_mig); if (temp == NULL) { - gf_msg(this->name, GF_LOG_ERROR, 0, 0, "No memory"); + gf_smsg(this->name, GF_LOG_ERROR, 0, PC_MSG_NO_MEM, NULL); goto out; } @@ -1792,8 +661,8 @@ serialize_req_locklist(lock_migration_info_t *locklist, break; default: - gf_msg(THIS->name, GF_LOG_ERROR, 0, 0, - "Unknown lock type: %" PRId32 "!", tmp->flock.l_type); + gf_smsg(THIS->name, GF_LOG_ERROR, 0, PC_MSG_UNKNOWN_LOCK_TYPE, + "type=%" PRId32, tmp->flock.l_type, NULL); break; } @@ -1803,8 +672,8 @@ serialize_req_locklist(lock_migration_info_t *locklist, trav->client_uid = gf_strdup(tmp->client_uid); if (!trav->client_uid) { - gf_msg(THIS->name, GF_LOG_ERROR, 0, 0, - "client_uid could not be allocated"); + gf_smsg(THIS->name, GF_LOG_ERROR, 0, PC_MSG_CLIENT_UID_ALLOC_FAILED, + NULL); ret = -1; goto out; } @@ -1855,8 +724,8 @@ serialize_req_locklist_v2(lock_migration_info_t *locklist, break; default: - gf_msg(THIS->name, GF_LOG_ERROR, 0, 0, - "Unknown lock type: %" PRId32 "!", tmp->flock.l_type); + gf_smsg(THIS->name, GF_LOG_ERROR, 0, PC_MSG_UNKNOWN_LOCK_TYPE, + "type=%" PRId32, tmp->flock.l_type, NULL); break; } @@ -1866,8 +735,8 @@ serialize_req_locklist_v2(lock_migration_info_t *locklist, trav->client_uid = gf_strdup(tmp->client_uid); if (!trav->client_uid) { - gf_msg(THIS->name, GF_LOG_ERROR, 0, 0, - "client_uid could not be allocated"); + gf_smsg(THIS->name, GF_LOG_ERROR, 0, PC_MSG_CLIENT_UID_ALLOC_FAILED, + NULL); ret = -1; goto out; } @@ -1888,1130 +757,6 @@ out: return ret; } -void -client_compound_rsp_cleanup(gfs3_compound_rsp *rsp, int len) -{ - int i = 0; - compound_rsp *this_rsp = NULL; - - for (i = 0; i < len; i++) { - this_rsp = &rsp->compound_rsp_array.compound_rsp_array_val[i]; - switch (this_rsp->fop_enum) { - case GF_FOP_STAT: - CLIENT_FOP_RSP_CLEANUP(rsp, stat, i); - break; - case GF_FOP_MKNOD: - CLIENT_FOP_RSP_CLEANUP(rsp, mknod, i); - break; - case GF_FOP_MKDIR: - CLIENT_FOP_RSP_CLEANUP(rsp, mkdir, i); - break; - case GF_FOP_UNLINK: - CLIENT_FOP_RSP_CLEANUP(rsp, unlink, i); - break; - case GF_FOP_RMDIR: - CLIENT_FOP_RSP_CLEANUP(rsp, rmdir, i); - break; - case GF_FOP_SYMLINK: - CLIENT_FOP_RSP_CLEANUP(rsp, symlink, i); - break; - case GF_FOP_RENAME: - CLIENT_FOP_RSP_CLEANUP(rsp, rename, i); - break; - case GF_FOP_LINK: - CLIENT_FOP_RSP_CLEANUP(rsp, link, i); - break; - case GF_FOP_TRUNCATE: - CLIENT_FOP_RSP_CLEANUP(rsp, truncate, i); - break; - case GF_FOP_OPEN: - CLIENT_FOP_RSP_CLEANUP(rsp, open, i); - break; - case GF_FOP_READ: - CLIENT_FOP_RSP_CLEANUP(rsp, read, i); - break; - case GF_FOP_WRITE: - CLIENT_FOP_RSP_CLEANUP(rsp, write, i); - break; - case GF_FOP_STATFS: - CLIENT_FOP_RSP_CLEANUP(rsp, statfs, i); - break; - case GF_FOP_FSYNC: - CLIENT_FOP_RSP_CLEANUP(rsp, fsync, i); - break; - case GF_FOP_OPENDIR: - CLIENT_FOP_RSP_CLEANUP(rsp, opendir, i); - break; - case GF_FOP_CREATE: - CLIENT_FOP_RSP_CLEANUP(rsp, create, i); - break; - case GF_FOP_FTRUNCATE: - CLIENT_FOP_RSP_CLEANUP(rsp, ftruncate, i); - break; - case GF_FOP_FSTAT: - CLIENT_FOP_RSP_CLEANUP(rsp, fstat, i); - break; - case GF_FOP_LOOKUP: - CLIENT_FOP_RSP_CLEANUP(rsp, lookup, i); - break; - case GF_FOP_SETATTR: - CLIENT_FOP_RSP_CLEANUP(rsp, setattr, i); - break; - case GF_FOP_FSETATTR: - CLIENT_FOP_RSP_CLEANUP(rsp, fsetattr, i); - break; - case GF_FOP_FALLOCATE: - CLIENT_FOP_RSP_CLEANUP(rsp, fallocate, i); - break; - case GF_FOP_DISCARD: - CLIENT_FOP_RSP_CLEANUP(rsp, discard, i); - break; - case GF_FOP_ZEROFILL: - CLIENT_FOP_RSP_CLEANUP(rsp, zerofill, i); - break; - case GF_FOP_IPC: - CLIENT_FOP_RSP_CLEANUP(rsp, ipc, i); - break; - case GF_FOP_SEEK: - CLIENT_FOP_RSP_CLEANUP(rsp, seek, i); - break; - case GF_FOP_LEASE: - CLIENT_FOP_RSP_CLEANUP(rsp, lease, i); - break; - /* fops that use gf_common_rsp */ - case GF_FOP_FLUSH: - CLIENT_COMMON_RSP_CLEANUP(rsp, flush, i); - break; - case GF_FOP_SETXATTR: - CLIENT_COMMON_RSP_CLEANUP(rsp, setxattr, i); - break; - case GF_FOP_REMOVEXATTR: - CLIENT_COMMON_RSP_CLEANUP(rsp, removexattr, i); - break; - case GF_FOP_FSETXATTR: - CLIENT_COMMON_RSP_CLEANUP(rsp, fsetxattr, i); - break; - case GF_FOP_FREMOVEXATTR: - CLIENT_COMMON_RSP_CLEANUP(rsp, fremovexattr, i); - break; - case GF_FOP_FSYNCDIR: - CLIENT_COMMON_RSP_CLEANUP(rsp, fsyncdir, i); - break; - case GF_FOP_ACCESS: - CLIENT_COMMON_RSP_CLEANUP(rsp, access, i); - break; - case GF_FOP_INODELK: - CLIENT_COMMON_RSP_CLEANUP(rsp, inodelk, i); - break; - case GF_FOP_FINODELK: - CLIENT_COMMON_RSP_CLEANUP(rsp, finodelk, i); - break; - case GF_FOP_ENTRYLK: - CLIENT_COMMON_RSP_CLEANUP(rsp, entrylk, i); - break; - case GF_FOP_FENTRYLK: - CLIENT_COMMON_RSP_CLEANUP(rsp, fentrylk, i); - break; - /* fops that need extra cleanup */ - case GF_FOP_LK: { - CLIENT_FOP_RSP_CLEANUP(rsp, lk, i); - gfs3_lk_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp, lk); - free(tmp_rsp->flock.lk_owner.lk_owner_val); - break; - } - case GF_FOP_READLINK: { - CLIENT_FOP_RSP_CLEANUP(rsp, readlink, i); - gfs3_readlink_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp, readlink); - free(tmp_rsp->path); - break; - } - case GF_FOP_XATTROP: { - CLIENT_FOP_RSP_CLEANUP(rsp, xattrop, i); - gfs3_xattrop_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp, xattrop); - free(tmp_rsp->dict.dict_val); - break; - } - case GF_FOP_FXATTROP: { - CLIENT_FOP_RSP_CLEANUP(rsp, fxattrop, i); - gfs3_fxattrop_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp, fxattrop); - free(tmp_rsp->dict.dict_val); - break; - } - case GF_FOP_READDIR: { - CLIENT_FOP_RSP_CLEANUP(rsp, readdir, i); - gfs3_readdir_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp, readdir); - clnt_readdir_rsp_cleanup(tmp_rsp); - break; - } - case GF_FOP_READDIRP: { - CLIENT_FOP_RSP_CLEANUP(rsp, readdirp, i); - gfs3_readdirp_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp, readdirp); - clnt_readdirp_rsp_cleanup(tmp_rsp); - break; - } - case GF_FOP_GETXATTR: { - CLIENT_FOP_RSP_CLEANUP(rsp, getxattr, i); - gfs3_getxattr_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp, getxattr); - free(tmp_rsp->dict.dict_val); - break; - } - case GF_FOP_FGETXATTR: { - CLIENT_FOP_RSP_CLEANUP(rsp, fgetxattr, i); - gfs3_fgetxattr_rsp *tmp_rsp = &CPD_RSP_FIELD(this_rsp, - fgetxattr); - free(tmp_rsp->dict.dict_val); - break; - } - case GF_FOP_RCHECKSUM: { - CLIENT_FOP_RSP_CLEANUP(rsp, rchecksum, i); - gfs3_rchecksum_rsp *rck = &CPD_RSP_FIELD(this_rsp, rchecksum); - if (rck->strong_checksum.strong_checksum_val) { - free(rck->strong_checksum.strong_checksum_val); - } - break; - } - default: - break; - } - } - return; -} - -/* compound v2 */ -int -client_handle_fop_requirements_v2( - xlator_t *this, call_frame_t *frame, gfx_compound_req *req, - clnt_local_t *local, struct iobref **req_iobref, struct iobref **rsp_iobref, - struct iovec *req_vector, struct iovec *rsp_vector, int *req_count, - int *rsp_count, default_args_t *args, int fop_enum, int index) -{ - int ret = 0; - int op_errno = ENOMEM; - struct iobuf *rsp_iobuf = NULL; - int64_t remote_fd = -1; - compound_req_v2 *this_req = &req->compound_req_array - .compound_req_array_val[index]; - - this_req->fop_enum = fop_enum; - - switch (fop_enum) { - case GF_FOP_STAT: - CLIENT4_PRE_FOP(stat, this, - &this_req->compound_req_v2_u.compound_stat_req, - op_errno, out, &args->loc, args->xdata); - break; - case GF_FOP_READLINK: - CLIENT4_PRE_FOP(readlink, this, - &this_req->compound_req_v2_u.compound_readlink_req, - op_errno, out, &args->loc, args->size, args->xdata); - break; - case GF_FOP_MKNOD: - CLIENT4_PRE_FOP(mknod, this, - &this_req->compound_req_v2_u.compound_mknod_req, - op_errno, out, &args->loc, args->mode, args->rdev, - args->umask, args->xdata); - loc_copy(&local->loc, &args->loc); - loc_path(&local->loc, NULL); - break; - case GF_FOP_MKDIR: - CLIENT4_PRE_FOP(mkdir, this, - &this_req->compound_req_v2_u.compound_mkdir_req, - op_errno, out, &args->loc, args->mode, args->umask, - args->xdata); - loc_copy(&local->loc, &args->loc); - loc_path(&local->loc, NULL); - break; - case GF_FOP_UNLINK: - CLIENT4_PRE_FOP( - unlink, this, &this_req->compound_req_v2_u.compound_unlink_req, - op_errno, out, &args->loc, args->xflag, args->xdata); - break; - case GF_FOP_RMDIR: - CLIENT4_PRE_FOP( - rmdir, this, &this_req->compound_req_v2_u.compound_rmdir_req, - op_errno, out, &args->loc, args->flags, args->xdata); - break; - case GF_FOP_SYMLINK: - CLIENT4_PRE_FOP(symlink, this, - &this_req->compound_req_v2_u.compound_symlink_req, - op_errno, out, &args->loc, args->linkname, - args->umask, args->xdata); - loc_copy(&local->loc, &args->loc); - loc_path(&local->loc, NULL); - break; - case GF_FOP_RENAME: - CLIENT4_PRE_FOP( - rename, this, &this_req->compound_req_v2_u.compound_rename_req, - op_errno, out, &args->loc, &args->loc2, args->xdata); - break; - case GF_FOP_LINK: - CLIENT4_PRE_FOP( - link, this, &this_req->compound_req_v2_u.compound_link_req, - op_errno, out, &args->loc, &args->loc2, args->xdata); - break; - case GF_FOP_TRUNCATE: - CLIENT4_PRE_FOP(truncate, this, - &this_req->compound_req_v2_u.compound_truncate_req, - op_errno, out, &args->loc, args->offset, - args->xdata); - break; - case GF_FOP_OPEN: - CLIENT4_PRE_FOP( - open, this, &this_req->compound_req_v2_u.compound_open_req, - op_errno, out, &args->loc, args->fd, args->flags, args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - break; - case GF_FOP_READ: - op_errno = client_pre_readv_v2( - this, &this_req->compound_req_v2_u.compound_read_req, args->fd, - args->size, args->offset, args->flags, args->xdata); - - if (op_errno) { - op_errno = -op_errno; - goto out; - } - if (!local->fd) - local->fd = fd_ref(args->fd); - local->attempt_reopen = client_is_reopen_needed(args->fd, this, - remote_fd); - rsp_iobuf = iobuf_get2(this->ctx->iobuf_pool, args->size); - if (rsp_iobuf == NULL) { - op_errno = ENOMEM; - goto out; - } - - if (!*rsp_iobref) { - *rsp_iobref = iobref_new(); - if (*rsp_iobref == NULL) { - op_errno = ENOMEM; - goto out; - } - } - - if (*rsp_count + 1 >= MAX_IOVEC) { - op_errno = ENOMEM; - goto out; - } - rsp_vector[*rsp_count].iov_base = iobuf_ptr(rsp_iobuf); - rsp_vector[*rsp_count].iov_len = iobuf_pagesize(rsp_iobuf); - iobref_add(*rsp_iobref, rsp_iobuf); - iobuf_unref(rsp_iobuf); - rsp_iobuf = NULL; - if (args->size > rsp_vector[*rsp_count].iov_len) { - gf_msg(this->name, GF_LOG_WARNING, ENOMEM, PC_MSG_NO_MEMORY, - "read-size (%lu) is bigger than iobuf size " - "(%lu)", - (unsigned long)args->size, - (unsigned long)rsp_vector[*rsp_count].iov_len); - op_errno = EINVAL; - goto out; - } - *rsp_count += 1; - - break; - case GF_FOP_WRITE: - op_errno = client_pre_writev_v2( - this, &this_req->compound_req_v2_u.compound_write_req, args->fd, - iov_length(args->vector, args->count), args->offset, - args->flags, &args->xdata); - - if (op_errno) { - op_errno = -op_errno; - goto out; - } - if (!local->fd) - local->fd = fd_ref(args->fd); - local->attempt_reopen = client_is_reopen_needed(args->fd, this, - remote_fd); - - if (*req_count + args->count >= MAX_IOVEC) { - op_errno = ENOMEM; - goto out; - } - memcpy(&req_vector[*req_count], args->vector, - (args->count * sizeof(req_vector[0]))); - *req_count += args->count; - - if (!*req_iobref) - *req_iobref = args->iobref; - else if (iobref_merge(*req_iobref, args->iobref)) - goto out; - break; - case GF_FOP_STATFS: - CLIENT4_PRE_FOP(statfs, this, - &this_req->compound_req_v2_u.compound_statfs_req, - op_errno, out, &args->loc, args->xdata); - break; - case GF_FOP_FLUSH: - CLIENT4_PRE_FOP(flush, this, - &this_req->compound_req_v2_u.compound_flush_req, - op_errno, out, args->fd, args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - local->owner = frame->root->lk_owner; - break; - case GF_FOP_FSYNC: - CLIENT4_PRE_FOP( - fsync, this, &this_req->compound_req_v2_u.compound_fsync_req, - op_errno, out, args->fd, args->datasync, args->xdata); - break; - case GF_FOP_SETXATTR: - CLIENT4_PRE_FOP(setxattr, this, - &this_req->compound_req_v2_u.compound_setxattr_req, - op_errno, out, &args->loc, args->xattr, args->flags, - args->xdata); - break; - case GF_FOP_GETXATTR: - CLIENT4_PRE_FOP(getxattr, this, - &this_req->compound_req_v2_u.compound_getxattr_req, - op_errno, out, &args->loc, args->name, args->xdata); - loc_copy(&local->loc, &args->loc); - loc_path(&local->loc, NULL); - break; - case GF_FOP_REMOVEXATTR: - CLIENT4_PRE_FOP( - removexattr, this, - &this_req->compound_req_v2_u.compound_removexattr_req, op_errno, - out, &args->loc, args->name, args->xdata); - break; - case GF_FOP_OPENDIR: - CLIENT4_PRE_FOP(opendir, this, - &this_req->compound_req_v2_u.compound_opendir_req, - op_errno, out, &args->loc, args->fd, args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - loc_copy(&local->loc, &args->loc); - loc_path(&local->loc, NULL); - break; - case GF_FOP_FSYNCDIR: - CLIENT4_PRE_FOP(fsyncdir, this, - &this_req->compound_req_v2_u.compound_fsyncdir_req, - op_errno, out, args->fd, args->datasync, - args->xdata); - break; - case GF_FOP_ACCESS: - CLIENT4_PRE_FOP(access, this, - &this_req->compound_req_v2_u.compound_access_req, - op_errno, out, &args->loc, args->mask, args->xdata); - break; - case GF_FOP_CREATE: - CLIENT4_PRE_FOP(create, this, - &this_req->compound_req_v2_u.compound_create_req, - op_errno, out, &args->loc, args->fd, args->mode, - args->flags, args->umask, args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - - loc_copy(&local->loc, &args->loc); - loc_path(&local->loc, NULL); - break; - case GF_FOP_FTRUNCATE: - CLIENT4_PRE_FOP(ftruncate, this, - &this_req->compound_req_v2_u.compound_ftruncate_req, - op_errno, out, args->fd, args->offset, args->xdata); - break; - case GF_FOP_FSTAT: - CLIENT4_PRE_FOP(fstat, this, - &this_req->compound_req_v2_u.compound_fstat_req, - op_errno, out, args->fd, args->xdata); - break; - case GF_FOP_LK: - CLIENT4_PRE_FOP( - lk, this, &this_req->compound_req_v2_u.compound_lk_req, - op_errno, out, args->cmd, &args->lock, args->fd, args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - local->owner = frame->root->lk_owner; - break; - case GF_FOP_LOOKUP: - CLIENT4_PRE_FOP(lookup, this, - &this_req->compound_req_v2_u.compound_lookup_req, - op_errno, out, &args->loc, args->xdata); - loc_copy(&local->loc, &args->loc); - loc_path(&local->loc, NULL); - break; - case GF_FOP_READDIR: - CLIENT4_PRE_FOP(readdir, this, - &this_req->compound_req_v2_u.compound_readdir_req, - op_errno, out, args->fd, args->size, args->offset, - args->xdata); - break; - case GF_FOP_INODELK: - CLIENT4_PRE_FOP(inodelk, this, - &this_req->compound_req_v2_u.compound_inodelk_req, - op_errno, out, &args->loc, args->cmd, &args->lock, - args->volume, args->xdata); - break; - case GF_FOP_FINODELK: - CLIENT4_PRE_FOP(finodelk, this, - &this_req->compound_req_v2_u.compound_finodelk_req, - op_errno, out, args->fd, args->cmd, &args->lock, - args->volume, args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - local->attempt_reopen = client_is_reopen_needed(args->fd, this, - remote_fd); - break; - case GF_FOP_ENTRYLK: - CLIENT4_PRE_FOP(entrylk, this, - &this_req->compound_req_v2_u.compound_entrylk_req, - op_errno, out, &args->loc, args->entrylkcmd, - args->entrylktype, args->volume, args->name, - args->xdata); - break; - case GF_FOP_FENTRYLK: - CLIENT4_PRE_FOP(fentrylk, this, - &this_req->compound_req_v2_u.compound_fentrylk_req, - op_errno, out, args->fd, args->entrylkcmd, - args->entrylktype, args->volume, args->name, - args->xdata); - break; - case GF_FOP_XATTROP: - CLIENT4_PRE_FOP(xattrop, this, - &this_req->compound_req_v2_u.compound_xattrop_req, - op_errno, out, &args->loc, args->xattr, - args->optype, args->xdata); - break; - case GF_FOP_FXATTROP: - CLIENT4_PRE_FOP(fxattrop, this, - &this_req->compound_req_v2_u.compound_fxattrop_req, - op_errno, out, args->fd, args->xattr, args->optype, - args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - local->attempt_reopen = client_is_reopen_needed(args->fd, this, - remote_fd); - break; - case GF_FOP_FGETXATTR: - CLIENT4_PRE_FOP(fgetxattr, this, - &this_req->compound_req_v2_u.compound_fgetxattr_req, - op_errno, out, args->fd, args->name, args->xdata); - break; - case GF_FOP_FSETXATTR: - CLIENT4_PRE_FOP(fsetxattr, this, - &this_req->compound_req_v2_u.compound_fsetxattr_req, - op_errno, out, args->fd, args->flags, args->xattr, - args->xdata); - break; - case GF_FOP_RCHECKSUM: - CLIENT4_PRE_FOP(rchecksum, this, - &this_req->compound_req_v2_u.compound_rchecksum_req, - op_errno, out, args->fd, args->size, args->offset, - args->xdata); - break; - case GF_FOP_SETATTR: - CLIENT4_PRE_FOP(setattr, this, - &this_req->compound_req_v2_u.compound_setattr_req, - op_errno, out, &args->loc, args->valid, &args->stat, - args->xdata); - break; - case GF_FOP_FSETATTR: - CLIENT4_PRE_FOP(fsetattr, this, - &this_req->compound_req_v2_u.compound_fsetattr_req, - op_errno, out, args->fd, args->valid, &args->stat, - args->xdata); - break; - case GF_FOP_READDIRP: - CLIENT4_PRE_FOP(readdirp, this, - &this_req->compound_req_v2_u.compound_readdirp_req, - op_errno, out, args->fd, args->size, args->offset, - args->xdata); - if (!local->fd) - local->fd = fd_ref(args->fd); - break; - case GF_FOP_FREMOVEXATTR: - CLIENT4_PRE_FOP( - fremovexattr, this, - &this_req->compound_req_v2_u.compound_fremovexattr_req, - op_errno, out, args->fd, args->name, args->xdata); - break; - case GF_FOP_FALLOCATE: - CLIENT4_PRE_FOP(fallocate, this, - &this_req->compound_req_v2_u.compound_fallocate_req, - op_errno, out, args->fd, args->flags, args->offset, - args->size, args->xdata); - break; - case GF_FOP_DISCARD: - CLIENT4_PRE_FOP(discard, this, - &this_req->compound_req_v2_u.compound_discard_req, - op_errno, out, args->fd, args->offset, args->size, - args->xdata); - break; - case GF_FOP_ZEROFILL: - CLIENT4_PRE_FOP(zerofill, this, - &this_req->compound_req_v2_u.compound_zerofill_req, - op_errno, out, args->fd, args->offset, args->size, - args->xdata); - break; - case GF_FOP_IPC: - CLIENT4_PRE_FOP(ipc, this, - &this_req->compound_req_v2_u.compound_ipc_req, - op_errno, out, args->cmd, args->xdata); - break; - case GF_FOP_SEEK: - CLIENT4_PRE_FOP( - seek, this, &this_req->compound_req_v2_u.compound_seek_req, - op_errno, out, args->fd, args->offset, args->what, args->xdata); - break; - case GF_FOP_LEASE: - CLIENT4_PRE_FOP( - lease, this, &this_req->compound_req_v2_u.compound_lease_req, - op_errno, out, &args->loc, &args->lease, args->xdata); - break; - default: - return ENOTSUP; - } - return 0; -out: - return op_errno; -} - -void -compound_request_cleanup_v2(gfx_compound_req *req) -{ - int i = 0; - int length = req->compound_req_array.compound_req_array_len; - compound_req_v2 *curr_req = NULL; - - if (!req->compound_req_array.compound_req_array_val) - return; - - for (i = 0; i < length; i++) { - curr_req = &req->compound_req_array.compound_req_array_val[i]; - - switch (curr_req->fop_enum) { - case GF_FOP_STAT: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, stat); - break; - case GF_FOP_READLINK: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, readlink); - break; - case GF_FOP_MKNOD: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, mknod); - break; - case GF_FOP_MKDIR: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, mkdir); - break; - case GF_FOP_UNLINK: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, unlink); - break; - case GF_FOP_RMDIR: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, rmdir); - break; - case GF_FOP_SYMLINK: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, symlink); - break; - case GF_FOP_RENAME: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, rename); - break; - case GF_FOP_LINK: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, link); - break; - case GF_FOP_TRUNCATE: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, truncate); - break; - case GF_FOP_OPEN: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, open); - break; - case GF_FOP_READ: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, read); - break; - case GF_FOP_WRITE: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, write); - break; - case GF_FOP_STATFS: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, statfs); - break; - case GF_FOP_FLUSH: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, flush); - break; - case GF_FOP_FSYNC: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, fsync); - break; - case GF_FOP_SETXATTR: { - gfx_setxattr_req *args = &CPD4_REQ_FIELD(curr_req, setxattr); - GF_FREE(args->dict.pairs.pairs_val); - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, setxattr); - break; - } - case GF_FOP_GETXATTR: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, getxattr); - break; - case GF_FOP_REMOVEXATTR: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, removexattr); - break; - case GF_FOP_OPENDIR: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, opendir); - break; - case GF_FOP_FSYNCDIR: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, fsyncdir); - break; - case GF_FOP_ACCESS: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, access); - break; - case GF_FOP_CREATE: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, create); - break; - case GF_FOP_FTRUNCATE: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, ftruncate); - break; - case GF_FOP_FSTAT: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, fstat); - break; - case GF_FOP_LK: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, lk); - break; - case GF_FOP_LOOKUP: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, lookup); - break; - case GF_FOP_READDIR: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, readdir); - break; - case GF_FOP_INODELK: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, inodelk); - break; - case GF_FOP_FINODELK: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, finodelk); - break; - case GF_FOP_ENTRYLK: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, entrylk); - break; - case GF_FOP_FENTRYLK: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, fentrylk); - break; - case GF_FOP_XATTROP: { - gfx_xattrop_req *args = &CPD4_REQ_FIELD(curr_req, xattrop); - GF_FREE(args->dict.pairs.pairs_val); - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, xattrop); - break; - } - case GF_FOP_FXATTROP: { - gfx_fxattrop_req *args = &CPD4_REQ_FIELD(curr_req, fxattrop); - GF_FREE(args->dict.pairs.pairs_val); - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, fxattrop); - break; - } - case GF_FOP_FGETXATTR: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, fgetxattr); - break; - case GF_FOP_FSETXATTR: { - gfx_fsetxattr_req *args = &CPD4_REQ_FIELD(curr_req, fsetxattr); - GF_FREE(args->dict.pairs.pairs_val); - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, fsetxattr); - break; - } - case GF_FOP_RCHECKSUM: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, rchecksum); - break; - case GF_FOP_SETATTR: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, setattr); - break; - case GF_FOP_FSETATTR: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, fsetattr); - break; - case GF_FOP_READDIRP: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, readdirp); - break; - case GF_FOP_FREMOVEXATTR: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, fremovexattr); - break; - case GF_FOP_FALLOCATE: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, fallocate); - break; - case GF_FOP_DISCARD: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, discard); - break; - case GF_FOP_ZEROFILL: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, zerofill); - break; - case GF_FOP_IPC: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, ipc); - break; - case GF_FOP_SEEK: - CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, seek); - break; - default: - break; - } - } - - GF_FREE(req->compound_req_array.compound_req_array_val); - return; -} - -void -client_compound_rsp_cleanup_v2(gfx_compound_rsp *rsp, int len) -{ - int i = 0; - compound_rsp_v2 *this_rsp = NULL; - - for (i = 0; i < len; i++) { - this_rsp = &rsp->compound_rsp_array.compound_rsp_array_val[i]; - switch (this_rsp->fop_enum) { - /* fops that need extra cleanup */ - case GF_FOP_LK: { - gfx_lk_rsp *tmp_rsp = &CPD4_RSP_FIELD(this_rsp, lk); - free(tmp_rsp->flock.lk_owner.lk_owner_val); - break; - } - case GF_FOP_READLINK: { - gfx_readlink_rsp *tmp_rsp = &CPD4_RSP_FIELD(this_rsp, readlink); - free(tmp_rsp->path); - break; - } - case GF_FOP_READDIR: { - gfx_readdir_rsp *tmp_rsp = &CPD4_RSP_FIELD(this_rsp, readdir); - clnt_readdir_rsp_cleanup_v2(tmp_rsp); - break; - } - case GF_FOP_READDIRP: { - gfx_readdirp_rsp *tmp_rsp = &CPD4_RSP_FIELD(this_rsp, readdirp); - clnt_readdirp_rsp_cleanup_v2(tmp_rsp); - break; - } - case GF_FOP_RCHECKSUM: { - gfx_rchecksum_rsp *rck = &CPD4_RSP_FIELD(this_rsp, rchecksum); - if (rck->strong_checksum.strong_checksum_val) { - free(rck->strong_checksum.strong_checksum_val); - } - break; - } - default: - break; - } - } - return; -} - -int -client_process_response_v2(call_frame_t *frame, xlator_t *this, - struct rpc_req *req, gfx_compound_rsp *rsp, - compound_args_cbk_t *args_cbk, int index) -{ - int ret = 0; - dict_t *xdata = NULL; - dict_t *xattr = NULL; - struct iovec vector[MAX_IOVEC] = { - {0}, - }; - gf_dirent_t entries; - default_args_cbk_t *this_args_cbk = &args_cbk->rsp_list[index]; - clnt_local_t *local = frame->local; - compound_rsp_v2 *this_rsp = NULL; - compound_args_t *args = local->compound_args; - - this_rsp = &rsp->compound_rsp_array.compound_rsp_array_val[index]; - args_cbk->enum_list[index] = this_rsp->fop_enum; - - INIT_LIST_HEAD(&entries.list); - - switch (args_cbk->enum_list[index]) { - case GF_FOP_STAT: - case GF_FOP_FSTAT: { - gfx_common_iatt_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_stat_rsp; - - client_post_common_iatt(this, tmp_rsp, &this_args_cbk->stat, - &xdata); - - CLIENT4_POST_FOP_TYPE(stat, common_iatt, this_rsp, this_args_cbk, - &this_args_cbk->stat, xdata); - break; - } - case GF_FOP_READLINK: { - gfx_readlink_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_readlink_rsp; - - gfx_stat_to_iattx(&tmp_rsp->buf, &this_args_cbk->stat); - xdr_to_dict(&tmp_rsp->xdata, &xdata); - - CLIENT4_POST_FOP_TYPE(readlink, readlink, this_rsp, this_args_cbk, - tmp_rsp->path, &this_args_cbk->stat, xdata); - break; - } - case GF_FOP_MKDIR: - case GF_FOP_MKNOD: - case GF_FOP_SYMLINK: - case GF_FOP_LINK: { - gfx_common_3iatt_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_mknod_rsp; - - client_post_common_3iatt(this, tmp_rsp, &this_args_cbk->stat, - &this_args_cbk->preparent, - &this_args_cbk->postparent, &xdata); - CLIENT4_POST_FOP_TYPE(mknod, common_3iatt, this_rsp, this_args_cbk, - local->loc.inode, &this_args_cbk->stat, - &this_args_cbk->preparent, - &this_args_cbk->postparent, xdata); - break; - } - case GF_FOP_UNLINK: - case GF_FOP_RMDIR: { - gfx_common_2iatt_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_unlink_rsp; - - client_post_common_2iatt(this, tmp_rsp, &this_args_cbk->preparent, - &this_args_cbk->postparent, &xdata); - CLIENT4_POST_FOP_TYPE(unlink, common_2iatt, this_rsp, this_args_cbk, - &this_args_cbk->preparent, - &this_args_cbk->postparent, xdata); - break; - } - case GF_FOP_RENAME: { - gfx_rename_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_rename_rsp; - - client_post_rename_v2( - this, tmp_rsp, &this_args_cbk->stat, &this_args_cbk->preparent, - &this_args_cbk->postparent, &this_args_cbk->preparent2, - &this_args_cbk->postparent2, &xdata); - CLIENT4_POST_FOP_TYPE( - rename, rename, this_rsp, this_args_cbk, &this_args_cbk->stat, - &this_args_cbk->preparent, &this_args_cbk->postparent, - &this_args_cbk->preparent2, &this_args_cbk->postparent2, xdata); - break; - } - case GF_FOP_WRITE: - case GF_FOP_TRUNCATE: - case GF_FOP_FTRUNCATE: - case GF_FOP_FSYNC: - case GF_FOP_ZEROFILL: - case GF_FOP_DISCARD: - case GF_FOP_FALLOCATE: - case GF_FOP_FSETATTR: - case GF_FOP_SETATTR: { - gfx_common_2iatt_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_truncate_rsp; - - client_post_common_2iatt(this, tmp_rsp, &this_args_cbk->prestat, - &this_args_cbk->poststat, &xdata); - CLIENT4_POST_FOP_TYPE(truncate, common_2iatt, this_rsp, - this_args_cbk, &this_args_cbk->prestat, - &this_args_cbk->poststat, xdata); - break; - } - case GF_FOP_OPEN: { - gfx_open_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_open_rsp; - - xdr_to_dict(&tmp_rsp->xdata, &xdata); - CLIENT4_POST_FOP_TYPE(open, open, this_rsp, this_args_cbk, - local->fd, xdata); - if (-1 != this_args_cbk->op_ret) - ret = client_add_fd_to_saved_fds(this, local->fd, &local->loc, - args->req_list[index].flags, - tmp_rsp->fd, 0); - break; - } - case GF_FOP_READ: { - gfx_read_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_read_rsp; - - client_post_readv_v2(this, tmp_rsp, &this_args_cbk->iobref, - req->rsp_iobref, &this_args_cbk->stat, vector, - &req->rsp[1], &this_args_cbk->count, &xdata); - - /* Each read should be given read response that only - * corresponds to its request. - * Modify the iovecs accordingly. - * After each read, store the length of data already read - * so that the next ones can continue from there. - */ - if (local->read_length) { - vector[0].iov_base += local->read_length; - local->read_length += tmp_rsp->op_ret; - } else { - local->read_length = tmp_rsp->op_ret; - } - - args_readv_cbk_store(this_args_cbk, tmp_rsp->op_ret, - gf_error_to_errno(tmp_rsp->op_errno), vector, - this_args_cbk->count, &this_args_cbk->stat, - this_args_cbk->iobref, xdata); - - if (tmp_rsp->op_ret >= 0) - if (local->attempt_reopen) - client_attempt_reopen(local->fd, this); - - break; - } - case GF_FOP_STATFS: { - gfx_statfs_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_statfs_rsp; - - gf_statfs_to_statfs(&tmp_rsp->statfs, &this_args_cbk->statvfs); - xdr_to_dict(&tmp_rsp->xdata, &xdata); - - CLIENT4_POST_FOP_TYPE(statfs, statfs, this_rsp, this_args_cbk, - &this_args_cbk->statvfs, xdata); - break; - } - case GF_FOP_FLUSH: { - gfx_common_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_flush_rsp; - - xdr_to_dict(&tmp_rsp->xdata, &xdata); - - CLIENT4_POST_FOP(flush, this_rsp, this_args_cbk, xdata); - if (this_args_cbk->op_ret >= 0 && !fd_is_anonymous(local->fd)) { - /* Delete all saved locks of the owner issuing flush */ - ret = delete_granted_locks_owner(local->fd, &local->owner); - gf_msg_trace(this->name, 0, - "deleting locks of owner (%s) returned %d", - lkowner_utoa(&local->owner), ret); - } - break; - } - case GF_FOP_FSYNCDIR: - case GF_FOP_ACCESS: - case GF_FOP_REMOVEXATTR: - case GF_FOP_FREMOVEXATTR: - case GF_FOP_FSETXATTR: - case GF_FOP_SETXATTR: - case GF_FOP_INODELK: - case GF_FOP_FINODELK: - case GF_FOP_ENTRYLK: - case GF_FOP_FENTRYLK: - case GF_FOP_IPC: { - gfx_common_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_setxattr_rsp; - - xdr_to_dict(&tmp_rsp->xdata, &xdata); - - CLIENT4_POST_FOP(setxattr, this_rsp, this_args_cbk, xdata); - break; - } - case GF_FOP_GETXATTR: - case GF_FOP_FGETXATTR: - case GF_FOP_XATTROP: - case GF_FOP_FXATTROP: { - gfx_common_dict_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_getxattr_rsp; - - client_post_common_dict(this, tmp_rsp, &xattr, &xdata); - - CLIENT4_POST_FOP_TYPE(getxattr, common_dict, this_rsp, - this_args_cbk, xattr, xdata); - break; - } - case GF_FOP_OPENDIR: { - gfx_open_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_opendir_rsp; - - xdr_to_dict(&tmp_rsp->xdata, &xdata); - - CLIENT4_POST_FOP_TYPE(opendir, open, this_rsp, this_args_cbk, - local->fd, xdata); - if (-1 != this_args_cbk->op_ret) - ret = client_add_fd_to_saved_fds(this, local->fd, &local->loc, - args->req_list[index].flags, - tmp_rsp->fd, 0); - break; - } - case GF_FOP_CREATE: { - gfx_create_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_create_rsp; - - client_post_create_v2(this, tmp_rsp, &this_args_cbk->stat, - &this_args_cbk->preparent, - &this_args_cbk->postparent, local, &xdata); - - CLIENT4_POST_FOP_TYPE( - create, create, this_rsp, this_args_cbk, local->fd, - local->loc.inode, &this_args_cbk->stat, - &this_args_cbk->preparent, &this_args_cbk->postparent, xdata); - if (-1 != this_args_cbk->op_ret) - ret = client_add_fd_to_saved_fds(this, local->fd, &local->loc, - args->req_list[index].flags, - tmp_rsp->fd, 0); - break; - } - case GF_FOP_LK: { - gfx_lk_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_lk_rsp; - - client_post_lk_v2(this, tmp_rsp, &this_args_cbk->lock, &xdata); - - CLIENT4_POST_FOP_TYPE(lk, lk, this_rsp, this_args_cbk, - &this_args_cbk->lock, xdata); - break; - } - case GF_FOP_LOOKUP: { - gfx_common_2iatt_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_lookup_rsp; - - client_post_common_2iatt(this, tmp_rsp, &this_args_cbk->stat, - &this_args_cbk->postparent, &xdata); - CLIENT4_POST_FOP_TYPE(lookup, common_2iatt, this_rsp, this_args_cbk, - local->loc.inode, &this_args_cbk->stat, xdata, - &this_args_cbk->postparent); - break; - } - case GF_FOP_READDIR: { - gfx_readdir_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_readdir_rsp; - - client_post_readdir_v2(this, tmp_rsp, &entries, &xdata); - - CLIENT4_POST_FOP_TYPE(readdir, readdir, this_rsp, this_args_cbk, - &entries, xdata); - break; - } - case GF_FOP_RCHECKSUM: { - gfx_rchecksum_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_rchecksum_rsp; - - xdr_to_dict(&tmp_rsp->xdata, &xdata); - - CLIENT4_POST_FOP_TYPE( - rchecksum, rchecksum, this_rsp, this_args_cbk, - tmp_rsp->weak_checksum, - (uint8_t *)tmp_rsp->strong_checksum.strong_checksum_val, xdata); - break; - } - case GF_FOP_READDIRP: { - gfx_readdirp_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_readdirp_rsp; - - client_post_readdirp_v2(this, tmp_rsp, local->fd, &entries, &xdata); - - CLIENT4_POST_FOP_TYPE(readdirp, readdirp, this_rsp, this_args_cbk, - &entries, xdata); - break; - } - case GF_FOP_SEEK: { - gfx_seek_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_seek_rsp; - - xdr_to_dict(&tmp_rsp->xdata, &xdata); - - CLIENT4_POST_FOP_TYPE(seek, seek, this_rsp, this_args_cbk, - tmp_rsp->offset, xdata); - break; - } - case GF_FOP_LEASE: { - gfx_lease_rsp *tmp_rsp = NULL; - tmp_rsp = &this_rsp->compound_rsp_v2_u.compound_lease_rsp; - - client_post_lease_v2(this, tmp_rsp, &this_args_cbk->lease, &xdata); - - CLIENT4_POST_FOP_TYPE(lease, lease, this_rsp, this_args_cbk, - &this_args_cbk->lease, xdata); - break; - } - default: - return -ENOTSUP; - } - - if (xdata) - dict_unref(xdata); - if (xattr) - dict_unref(xattr); - gf_dirent_free(&entries); - return 0; -} - extern int client3_3_releasedir_cbk(struct rpc_req *req, struct iovec *iov, int count, void *myframe); @@ -3043,8 +788,7 @@ send_release4_0_over_wire(xlator_t *this, clnt_fd_ctx_t *fdctx, gf_msg_trace(this->name, 0, "sending releasedir on fd"); (void)client_submit_request( this, &req, fr, conf->fops, GFS3_OP_RELEASEDIR, - client4_0_releasedir_cbk, NULL, NULL, 0, NULL, 0, NULL, - (xdrproc_t)xdr_gfx_releasedir_req); + client4_0_releasedir_cbk, NULL, (xdrproc_t)xdr_gfx_releasedir_req); } else { gfx_release_req req = { { @@ -3055,8 +799,8 @@ send_release4_0_over_wire(xlator_t *this, clnt_fd_ctx_t *fdctx, req.fd = fdctx->remote_fd; gf_msg_trace(this->name, 0, "sending release on fd"); (void)client_submit_request(this, &req, fr, conf->fops, GFS3_OP_RELEASE, - client4_0_release_cbk, NULL, NULL, 0, NULL, - 0, NULL, (xdrproc_t)xdr_gfx_release_req); + client4_0_release_cbk, NULL, + (xdrproc_t)xdr_gfx_release_req); } return 0; @@ -3079,8 +823,7 @@ send_release3_3_over_wire(xlator_t *this, clnt_fd_ctx_t *fdctx, gf_msg_trace(this->name, 0, "sending releasedir on fd"); (void)client_submit_request( this, &req, fr, conf->fops, GFS3_OP_RELEASEDIR, - client3_3_releasedir_cbk, NULL, NULL, 0, NULL, 0, NULL, - (xdrproc_t)xdr_gfs3_releasedir_req); + client3_3_releasedir_cbk, NULL, (xdrproc_t)xdr_gfs3_releasedir_req); } else { gfs3_release_req req = { { @@ -3091,8 +834,8 @@ send_release3_3_over_wire(xlator_t *this, clnt_fd_ctx_t *fdctx, req.fd = fdctx->remote_fd; gf_msg_trace(this->name, 0, "sending release on fd"); (void)client_submit_request(this, &req, fr, conf->fops, GFS3_OP_RELEASE, - client3_3_release_cbk, NULL, NULL, 0, NULL, - 0, NULL, (xdrproc_t)xdr_gfs3_release_req); + client3_3_release_cbk, NULL, + (xdrproc_t)xdr_gfs3_release_req); } return 0; diff --git a/xlators/protocol/client/src/client-lk.c b/xlators/protocol/client/src/client-lk.c index 48f32116de9..795839734c5 100644 --- a/xlators/protocol/client/src/client-lk.c +++ b/xlators/protocol/client/src/client-lk.c @@ -8,10 +8,10 @@ cases as published by the Free Software Foundation. */ -#include "common-utils.h" -#include "xlator.h" +#include <glusterfs/common-utils.h> +#include <glusterfs/xlator.h> #include "client.h" -#include "lkowner.h" +#include <glusterfs/lkowner.h> #include "client-messages.h" static void @@ -24,14 +24,12 @@ __dump_client_lock(client_posix_lock_t *lock) this = THIS; - gf_msg(this->name, GF_LOG_INFO, 0, PC_MSG_CLIENT_LOCK_INFO, - "{fd=%p}" - "{%s lk-owner:%s %" PRId64 " - %" PRId64 - "}" - "{start=%" PRId64 " end=%" PRId64 "}", - lock->fd, lock->fl_type == F_WRLCK ? "Write-Lock" : "Read-Lock", - lkowner_utoa(&lock->owner), lock->user_flock.l_start, - lock->user_flock.l_len, lock->fl_start, lock->fl_end); + gf_smsg( + this->name, GF_LOG_INFO, 0, PC_MSG_CLIENT_LOCK_INFO, "fd=%p", lock->fd, + "fl_type=%s", lock->fl_type == F_WRLCK ? "Write-Lock" : "Read-Lock", + "lk-owner=%s", lkowner_utoa(&lock->owner), "l_start=%" PRId64, + lock->user_flock.l_start, "l_len=%" PRId64, lock->user_flock.l_len, + "start=%" PRId64, lock->fl_start, "end=%" PRId64, lock->fl_end, NULL); } static int @@ -203,9 +201,7 @@ subtract_locks(client_posix_lock_t *big, client_posix_lock_t *small) memcpy(v.locks[1], small, sizeof(client_posix_lock_t)); } else { /* LOG-TODO : decide what more info is required here*/ - gf_msg("client-protocol", GF_LOG_CRITICAL, 0, PC_MSG_LOCK_ERROR, - "Unexpected case in subtract_locks. Please send " - "a bug report to gluster-devel@gluster.org"); + gf_smsg("client-protocol", GF_LOG_CRITICAL, 0, PC_MSG_LOCK_ERROR, NULL); } return v; @@ -343,15 +339,15 @@ delete_granted_locks_owner(fd_t *fd, gf_lkowner_t *owner) if (!fdctx) { pthread_spin_unlock(&conf->fd_lock); - gf_msg(this->name, GF_LOG_WARNING, EINVAL, PC_MSG_FD_CTX_INVALID, - "fdctx not valid"); + gf_smsg(this->name, GF_LOG_WARNING, EINVAL, PC_MSG_FD_CTX_INVALID, + NULL); ret = -1; goto out; } list_for_each_entry_safe(lock, tmp, &fdctx->lock_list, list) { - if (!is_same_lkowner(&lock->owner, owner)) { + if (is_same_lkowner(&lock->owner, owner)) { list_del_init(&lock->list); list_add_tail(&lock->list, &delete_list); count++; @@ -360,10 +356,12 @@ delete_granted_locks_owner(fd_t *fd, gf_lkowner_t *owner) pthread_spin_unlock(&conf->fd_lock); - list_for_each_entry_safe(lock, tmp, &delete_list, list) - { - list_del_init(&lock->list); - destroy_client_lock(lock); + if (!list_empty(&delete_list)) { + list_for_each_entry_safe(lock, tmp, &delete_list, list) + { + list_del_init(&lock->list); + destroy_client_lock(lock); + } } /* FIXME: Need to actually print the locks instead of count */ @@ -459,8 +457,7 @@ client_add_lock_for_recovery(fd_t *fd, struct gf_flock *flock, if (!fdctx) { pthread_spin_unlock(&conf->fd_lock); - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FD_GET_FAIL, - "failed to get fd context. sending EBADFD"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FD_GET_FAIL, NULL); ret = -EBADFD; goto out; } @@ -496,8 +493,8 @@ client_dump_locks(char *name, inode_t *inode, dict_t *dict) ret = dict_set_dynstr(new_dict, CLIENT_DUMP_LOCKS, dict_string); if (ret) { - gf_msg(THIS->name, GF_LOG_WARNING, 0, PC_MSG_DICT_SET_FAILED, - "could not set dict with %s", CLIENT_DUMP_LOCKS); + gf_smsg(THIS->name, GF_LOG_WARNING, 0, PC_MSG_DICT_SET_FAIL, "lock=%s", + CLIENT_DUMP_LOCKS, NULL); goto out; } diff --git a/xlators/protocol/client/src/client-mem-types.h b/xlators/protocol/client/src/client-mem-types.h index bf01a90abb9..f61fa0c1828 100644 --- a/xlators/protocol/client/src/client-mem-types.h +++ b/xlators/protocol/client/src/client-mem-types.h @@ -11,7 +11,7 @@ #ifndef __CLIENT_MEM_TYPES_H__ #define __CLIENT_MEM_TYPES_H__ -#include "mem-types.h" +#include <glusterfs/mem-types.h> enum gf_client_mem_types_ { gf_client_mt_clnt_conf_t = gf_common_mt_end + 1, @@ -19,7 +19,6 @@ enum gf_client_mem_types_ { gf_client_mt_clnt_fdctx_t, gf_client_mt_clnt_lock_t, gf_client_mt_clnt_fd_lk_local_t, - gf_client_mt_clnt_args_t, gf_client_mt_compound_req_t, gf_client_mt_clnt_lock_request_t, gf_client_mt_end, diff --git a/xlators/protocol/client/src/client-messages.h b/xlators/protocol/client/src/client-messages.h index 879d53741d1..25a851d80b9 100644 --- a/xlators/protocol/client/src/client-messages.h +++ b/xlators/protocol/client/src/client-messages.h @@ -11,7 +11,7 @@ #ifndef _PC_MESSAGES_H__ #define _PC_MESSAGES_H__ -#include "glfs-message-id.h" +#include <glusterfs/glfs-message-id.h> /* To add new message IDs, append new identifiers at the end of the list. * @@ -48,6 +48,127 @@ GLFS_MSGID( PC_MSG_VERSION_ERROR, PC_MSG_DIR_OP_SUCCESS, PC_MSG_BAD_FD, PC_MSG_CLIENT_LOCK_INFO, PC_MSG_CACHE_INVALIDATION_FAIL, PC_MSG_CHILD_STATUS, PC_MSG_GFID_NULL, PC_MSG_RECALL_LEASE_FAIL, - PC_MSG_INODELK_CONTENTION_FAIL, PC_MSG_ENTRYLK_CONTENTION_FAIL); + PC_MSG_INODELK_CONTENTION_FAIL, PC_MSG_ENTRYLK_CONTENTION_FAIL, + PC_MSG_BIGGER_SIZE, PC_MSG_CLIENT_DUMP_LOCKS_FAILED, PC_MSG_UNKNOWN_CMD, + PC_MSG_REOPEN_FAILED, PC_MSG_FIND_KEY_FAILED, PC_MSG_VOL_ID_CHANGED, + PC_MSG_GETHOSTNAME_FAILED, PC_MSG_VOLFILE_KEY_SET_FAILED, + PC_MSG_VOLFILE_CHECKSUM_FAILED, PC_MSG_FRAME_NOT_FOUND, + PC_MSG_REMOTE_SUBVOL_SET_FAIL, PC_MSG_HANDSHAKE_PGM_NOT_FOUND, + PC_MSG_MERGE_IOBREF_FAILED, PC_MSG_ADD_IOBUF_FAILED, + PC_MSG_RELEASE_DIR_OP_FAILED, PC_MSG_REMOTE_HOST_SET_FAILED, + PC_MSG_REMOTE_PORT_SET_FAILED, PC_MSG_REMOTE_HOST_NOT_SET, + PC_MSG_NOREMOTE_HOST, PC_MSG_REMOTE_SUBVOL_NOT_GIVEN, + PC_MSG_FATAL_CLIENT_PROTOCOL, PC_MSG_VOL_DANGLING, + PC_MSG_CREATE_MEM_POOL_FAILED, PC_MSG_PVT_XLATOR_NULL, PC_MSG_XLATOR_NULL, + PC_MSG_LEASE_FOP_FAILED, PC_MSG_DICT_SET_FAIL, PC_MSG_NO_MEM, + PC_MSG_UNKNOWN_LOCK_TYPE, PC_MSG_CLIENT_UID_ALLOC_FAILED); + +#define PC_MSG_REMOTE_OP_FAILED_STR "remote operation failed." +#define PC_MSG_XDR_DECODING_FAILED_STR "XDR decoding failed" +#define PC_MSG_FOP_SEND_FAILED_STR "failed to send the fop" +#define PC_MSG_BIGGER_SIZE_STR "read-size is bigger than iobuf isze" +#define PC_MSG_CLIENT_DUMP_LOCKS_FAILED_STR "client dump locks failed" +#define PC_MSG_UNKNOWN_CMD_STR "Unknown cmd" +#define PC_MSG_CHILD_UP_NOTIFY_FAILED_STR "notify of CHILD_UP failed" +#define PC_MSG_CHILD_STATUS_STR \ + "Defering sending CHILD_UP message as the client translators are not yet " \ + "ready to serve" +#define PC_MSG_CHILD_UP_NOTIFY_STR "last fd open'd - notifying CHILD_UP" +#define PC_MSG_RPC_STATUS_ERROR_STR \ + "received RPC status error, returning ENOTCONN" +#define PC_MSG_REOPEN_FAILED_STR "reopen failed" +#define PC_MSG_DIR_OP_SUCCESS_STR "reopen dir succeeded" +#define PC_MSG_DIR_OP_FAILED_STR "failed to send the re-opendir request" +#define PC_MSG_CHILD_UP_NOTIFY_DELAY_STR \ + "fds open - Delaying child_up until they are re-opened" +#define PC_MSG_VOL_SET_FAIL_STR "failed to set the volume" +#define PC_MSG_DICT_UNSERIALIZE_FAIL_STR "failed to unserialize buffer to dict" +#define PC_MSG_DICT_GET_FAILED_STR "failed to get from reply dict" +#define PC_MSG_SETVOLUME_FAIL_STR "SETVOLUME on remote-host failed" +#define PC_MSG_VOLFILE_NOTIFY_FAILED_STR "notify of VOLFILE_MODIFIED failed" +#define PC_MSG_FIND_KEY_FAILED_STR "failed to find key in the options" +#define PC_MSG_VOL_ID_CHANGED_STR \ + "volume-id changed, can't connect to server. Needs remount" +#define PC_MSG_REMOTE_VOL_CONNECTED_STR "Connected, attached to remote volume" +#define PC_MSG_AUTH_FAILED_STR "sending AUTH_FAILED event" +#define PC_MSG_AUTH_FAILED_NOTIFY_FAILED_STR "notify of AUTH_FAILED failed" +#define PC_MSG_CHILD_CONNECTING_EVENT_STR "sending CHILD_CONNECTING event" +#define PC_MSG_CHILD_CONNECTING_NOTIFY_FAILED_STR \ + "notify of CHILD_CONNECTING failed" +#define PC_MSG_DICT_SET_FAILED_STR "failed to set in handshake msg" +#define PC_MSG_GETHOSTNAME_FAILED_STR "gethostname: failed" +#define PC_MSG_PROCESS_UUID_SET_FAIL_STR \ + "asprintf failed while setting process_uuid" +#define PC_MSG_VOLFILE_KEY_SET_FAILED_STR "failed to set volfile-key" +#define PC_MSG_VOLFILE_CHECKSUM_FAILED_STR "failed to set volfile-checksum" +#define PC_MSG_DICT_SERIALIZE_FAIL_STR "failed to serialize dictionary" +#define PC_MSG_PGM_NOT_FOUND_STR "xlator not found OR RPC program not found" +#define PC_MSG_VERSION_INFO_STR "Using Program" +#define PC_MSG_FRAME_NOT_FOUND_STR "frame not found with rpc request" +#define PC_MSG_PORT_NUM_ERROR_STR \ + "failed to get the port number for remote subvolume. Please run gluster " \ + "volume status on server to see if brick process is running" +#define PC_MSG_REMOTE_SUBVOL_SET_FAIL_STR "remote-subvolume not set in volfile" +#define PC_MSG_VERSION_ERROR_STR "failed to get the version from server" +#define PC_MSG_NO_VERSION_SUPPORT_STR "server doesn't support the version" +#define PC_MSG_HANDSHAKE_PGM_NOT_FOUND_STR "handshake program not found" +#define PC_MSG_MERGE_IOBREF_FAILED_STR \ + "cannot merge iobref passed from caller into new_iobref" +#define PC_MSG_ADD_IOBUF_FAILED_STR "cannot add iobuf into iobref" +#define PC_MSG_RELEASE_DIR_OP_FAILED_STR "release dir op failed" +#define PC_MSG_FILE_OP_FAILED_STR "release fop failed" +#define PC_MSG_REMOTE_HOST_SET_FAILED_STR "failed to set remote-host" +#define PC_MSG_REMOTE_PORT_SET_FAILED_STR "failed to set remote-port" +#define PC_MSG_RPC_INIT_STR "client rpc init command" +#define PC_MSG_RPC_DESTROY_STR "client rpc destroy command" +#define PC_MSG_HANDSHAKE_RETURN_STR "handshake msg returned" +#define PC_MSG_CLIENT_DISCONNECTED_STR \ + "disconnected from client, process will keep trying to connect glusterd " \ + "until brick's port is available" +#define PC_MSG_CHILD_DOWN_NOTIFY_FAILED_STR "CHILD_DOWN notify failed" +#define PC_MSG_PARENT_UP_STR \ + "parent translators are ready, attempting connect on transport" +#define PC_MSG_PARENT_DOWN_STR \ + "current graph is no longer active, destroying rpc_client" +#define PC_MSG_REMOTE_HOST_NOT_SET_STR \ + "Remote host is not set. Assuming the volfile server as remote host" +#define PC_MSG_NOREMOTE_HOST_STR "No remote host to connect" +#define PC_MSG_REMOTE_SUBVOL_NOT_GIVEN_STR "option 'remote-subvolume' not given" +#define PC_MSG_NO_MEMORY_STR "Memory accounting init failed" +#define PC_MSG_RPC_INVALID_CALL_STR \ + "RPC destroy called on already destroyed connection" +#define PC_MSG_RPC_INITED_ALREADY_STR "client rpc already init'ed" +#define PC_MSG_RPC_INIT_FAILED_STR "failed to initialize RPC" +#define PC_MSG_RPC_NOTIFY_FAILED_STR "failed to register notify" +#define PC_MSG_RPC_CBK_FAILED_STR "failed to reister callback program" +#define PC_MSG_FATAL_CLIENT_PROTOCOL_STR \ + "FATAL: client protocol, translator cannot have any subvolumes" +#define PC_MSG_VOL_DANGLING_STR "Volume is dangling" +#define PC_MSG_CREATE_MEM_POOL_FAILED_STR \ + "failed to create local_t's memory pool" +#define PC_MSG_XLATOR_NULL_STR "xlator is NULL" +#define PC_MSG_PVT_XLATOR_NULL_STR "private structure of the xlator is NULL" +#define PC_MSG_LEASE_FOP_FAILED_STR "Lease fop failed" +#define PC_MSG_LOCK_ERROR_STR \ + "Unexpected case in subtract_locks. Please send a bug report to " \ + "gluster-devel@gluster.org" +#define PC_MSG_FD_CTX_INVALID_STR "fdctx not valid" +#define PC_MSG_FD_GET_FAIL_STR "failed to get fd context. sending EBADFD" +#define PC_MSG_DICT_SET_FAIL_STR "could not set dict" +#define PC_MSG_CLIENT_LOCK_INFO_STR "client lock info" +#define PC_MSG_BAD_FD_STR "remote_fd is -1. EBADFD" +#define PC_MSG_FUNCTION_CALL_ERROR_STR "this function should not be called" +#define PC_MSG_RECALL_LEASE_FAIL_STR "XDR decode of recall lease failed" +#define PC_MSG_CACHE_INVALIDATION_FAIL_STR \ + "XDR decode of cache_invalidation failed" +#define PC_MSG_INODELK_CONTENTION_FAIL_STR \ + "XDR decode of inodelk contention failed" +#define PC_MSG_ENTRYLK_CONTENTION_FAIL_STR \ + "XDR decode of entrylk contention failed" +#define PC_MSG_FD_DUPLICATE_TRY_STR "trying duplicate remote fd set" +#define PC_MSG_FD_SET_FAIL_STR "failed to set remote-fd" +#define PC_MSG_NO_MEM_STR "No memory" +#define PC_MSG_UNKNOWN_LOCK_TYPE_STR "Unknown lock type" +#define PC_MSG_CLIENT_UID_ALLOC_FAILED_STR "client-uid could not be allocated" #endif /* !_PC_MESSAGES_H__ */ diff --git a/xlators/protocol/client/src/client-rpc-fops.c b/xlators/protocol/client/src/client-rpc-fops.c index 9e5a5b44c69..f402121c15b 100644 --- a/xlators/protocol/client/src/client-rpc-fops.c +++ b/xlators/protocol/client/src/client-rpc-fops.c @@ -12,18 +12,27 @@ #include "rpc-common-xdr.h" #include "glusterfs3-xdr.h" #include "glusterfs3.h" -#include "compat-errno.h" +#include <glusterfs/compat-errno.h> #include "client-messages.h" -#include "defaults.h" +#include <glusterfs/defaults.h> #include "client-common.h" -#include "compound-fop-utils.h" int32_t client3_getspec(call_frame_t *frame, xlator_t *this, void *data); rpc_clnt_prog_t clnt3_3_fop_prog; -/* CBK */ +int +client_is_setlk(int32_t cmd) +{ + if ((cmd == F_SETLK) || (cmd == F_SETLK64) || (cmd == F_SETLKW) || + (cmd == F_SETLKW64)) { + return 1; + } + return 0; +} + +/* CBK */ int client3_3_symlink_cbk(struct rpc_req *req, struct iovec *iov, int count, void *myframe) @@ -61,8 +70,8 @@ client3_3_symlink_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_symlink_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -77,10 +86,9 @@ out: /* no need to print the gfid, because it will be null, * since symlink operation failed. */ - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, - "remote operation failed. Path: (%s to %s)", local->loc.path, - local->loc2.path); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, "loc1=%s", local->loc.path, + "loc2=%s", local->loc2.path, NULL); } } @@ -134,8 +142,8 @@ client3_3_mknod_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_mknod_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -147,10 +155,10 @@ client3_3_mknod_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1 && GF_IGNORE_IF_GSYNCD_SAFE_ERROR(frame, rsp.op_errno)) { - gf_msg(this->name, - fop_log_level(GF_FOP_MKNOD, gf_error_to_errno(rsp.op_errno)), - gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, - "remote operation failed. Path: %s", local->loc.path); + gf_smsg(this->name, + fop_log_level(GF_FOP_MKNOD, gf_error_to_errno(rsp.op_errno)), + gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, + "path=%s", local->loc.path, NULL); } CLIENT_STACK_UNWIND(mknod, frame, rsp.op_ret, @@ -202,8 +210,8 @@ client3_3_mkdir_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_mkdir_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -215,10 +223,10 @@ client3_3_mkdir_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1 && GF_IGNORE_IF_GSYNCD_SAFE_ERROR(frame, rsp.op_errno)) { - gf_msg(this->name, - fop_log_level(GF_FOP_MKDIR, gf_error_to_errno(rsp.op_errno)), - gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, - "remote operation failed. Path: %s", local->loc.path); + gf_smsg(this->name, + fop_log_level(GF_FOP_MKDIR, gf_error_to_errno(rsp.op_errno)), + gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, + "Path=%s", local->loc.path, NULL); } CLIENT_STACK_UNWIND(mkdir, frame, rsp.op_ret, @@ -332,8 +340,8 @@ client3_3_open_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(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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -352,11 +360,11 @@ client3_3_open_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = client_post_open(this, &rsp, &xdata); out: if (rsp.op_ret == -1) { - gf_msg(this->name, - fop_log_level(GF_FOP_OPEN, gf_error_to_errno(rsp.op_errno)), - gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, - "remote operation failed. Path: %s (%s)", local->loc.path, - loc_gfid_utoa(&local->loc)); + gf_smsg(this->name, + fop_log_level(GF_FOP_OPEN, gf_error_to_errno(rsp.op_errno)), + gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, + "Path=%s", local->loc.path, "gfid=%s", + loc_gfid_utoa(&local->loc), NULL); } CLIENT_STACK_UNWIND(open, frame, rsp.op_ret, @@ -396,8 +404,8 @@ client3_3_stat_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_stat_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -412,8 +420,8 @@ out: gf_msg_debug(this->name, 0, "remote operation failed: %s", strerror(gf_error_to_errno(rsp.op_errno))); } else { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } } @@ -454,8 +462,8 @@ client3_3_readlink_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_readlink_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -471,10 +479,8 @@ out: " %s", strerror(gf_error_to_errno(rsp.op_errno))); } else { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, - "remote operation " - "failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } } @@ -523,8 +529,8 @@ client3_3_unlink_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_unlink_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -540,10 +546,8 @@ out: " %s", strerror(gf_error_to_errno(rsp.op_errno))); } else { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, - "remote operation " - "failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } } @@ -588,8 +592,8 @@ client3_3_rmdir_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_rmdir_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -600,8 +604,8 @@ client3_3_rmdir_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { if (GF_IGNORE_IF_GSYNCD_SAFE_ERROR(frame, rsp.op_errno)) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } } CLIENT_STACK_UNWIND(rmdir, frame, rsp.op_ret, @@ -645,8 +649,8 @@ client3_3_truncate_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_truncate_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -656,8 +660,8 @@ client3_3_truncate_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(truncate, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), &prestat, &poststat, @@ -697,8 +701,8 @@ client3_3_statfs_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_statfs_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -708,8 +712,8 @@ client3_3_statfs_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(statfs, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), &statfs, xdata); @@ -754,8 +758,8 @@ client3_3_writev_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_write_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -766,8 +770,8 @@ client3_3_writev_cbk(struct rpc_req *req, struct iovec *iov, int count, goto out; out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } else if (rsp.op_ret >= 0) { if (local->attempt_reopen) client_attempt_reopen(local->fd, this); @@ -809,14 +813,15 @@ client3_3_flush_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gf_common_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; } - if (rsp.op_ret >= 0 && !fd_is_anonymous(local->fd)) { + if ((rsp.op_ret >= 0 || (rsp.op_errno == ENOTCONN)) && + !fd_is_anonymous(local->fd)) { /* Delete all saved locks of the owner issuing flush */ ret = delete_granted_locks_owner(local->fd, &local->owner); gf_msg_trace(this->name, 0, "deleting locks of owner (%s) returned %d", @@ -827,10 +832,9 @@ client3_3_flush_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, - fop_log_level(GF_FOP_FLUSH, gf_error_to_errno(rsp.op_errno)), - gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, - "remote operation failed"); + gf_smsg(this->name, + fop_log_level(GF_FOP_FLUSH, gf_error_to_errno(rsp.op_errno)), + gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(flush, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), xdata); @@ -873,8 +877,8 @@ client3_3_fsync_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_fsync_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -886,8 +890,8 @@ client3_3_fsync_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(fsync, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), &prestat, &poststat, @@ -926,8 +930,8 @@ client3_3_setxattr_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gf_common_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -946,10 +950,8 @@ out: " %s", strerror(op_errno)); } else { - gf_msg(this->name, GF_LOG_WARNING, op_errno, - PC_MSG_REMOTE_OP_FAILED, - "remote operation " - "failed"); + gf_smsg(this->name, GF_LOG_WARNING, op_errno, + PC_MSG_REMOTE_OP_FAILED, NULL); } } @@ -991,8 +993,8 @@ client3_3_getxattr_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_getxattr_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); rsp.op_ret = -1; op_errno = EINVAL; goto out; @@ -1016,12 +1018,10 @@ out: loc_gfid_utoa(&local->loc), (local->name) ? local->name : "(null)"); } else { - gf_msg(this->name, GF_LOG_WARNING, op_errno, - PC_MSG_REMOTE_OP_FAILED, - "remote operation " - "failed. Path: %s (%s). Key: %s", - local->loc.path, loc_gfid_utoa(&local->loc), - (local->name) ? local->name : "(null)"); + gf_smsg(this->name, GF_LOG_WARNING, op_errno, + PC_MSG_REMOTE_OP_FAILED, "Path=%s", local->loc.path, + "gfid=%s", loc_gfid_utoa(&local->loc), "Key=%s", + (local->name) ? local->name : "(null)", NULL); } } @@ -1066,8 +1066,8 @@ client3_3_fgetxattr_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_fgetxattr_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); rsp.op_ret = -1; op_errno = EINVAL; goto out; @@ -1086,10 +1086,8 @@ out: gf_msg_debug(this->name, 0, "remote operation failed: %s", strerror(op_errno)); } else { - gf_msg(this->name, GF_LOG_WARNING, op_errno, - PC_MSG_REMOTE_OP_FAILED, - "remote operation " - "failed"); + gf_smsg(this->name, GF_LOG_WARNING, op_errno, + PC_MSG_REMOTE_OP_FAILED, NULL); } } @@ -1133,8 +1131,8 @@ client3_3_removexattr_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gf_common_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -1153,8 +1151,8 @@ out: else loglevel = GF_LOG_WARNING; - gf_msg(this->name, loglevel, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, loglevel, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(removexattr, frame, rsp.op_ret, @@ -1192,8 +1190,8 @@ client3_3_fremovexattr_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gf_common_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -1202,8 +1200,8 @@ client3_3_fremovexattr_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = client_post_fremovexattr(this, &rsp, &xdata); out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(fremovexattr, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), xdata); @@ -1239,8 +1237,8 @@ client3_3_fsyncdir_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gf_common_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -1250,8 +1248,8 @@ client3_3_fsyncdir_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(fsyncdir, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), xdata); @@ -1287,8 +1285,8 @@ client3_3_access_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gf_common_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -1298,8 +1296,8 @@ client3_3_access_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(access, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), xdata); @@ -1341,8 +1339,8 @@ client3_3_ftruncate_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_ftruncate_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -1352,8 +1350,8 @@ client3_3_ftruncate_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(ftruncate, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), &prestat, &poststat, @@ -1393,8 +1391,8 @@ client3_3_fstat_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_fstat_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -1404,8 +1402,8 @@ client3_3_fstat_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(fstat, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), &stat, xdata); @@ -1441,8 +1439,8 @@ client3_3_inodelk_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gf_common_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -1451,10 +1449,9 @@ client3_3_inodelk_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = client_post_inodelk(this, &rsp, &xdata); out: if (rsp.op_ret == -1) { - gf_msg(this->name, - fop_log_level(GF_FOP_INODELK, gf_error_to_errno(rsp.op_errno)), - gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, - "remote operation failed"); + gf_smsg(this->name, + fop_log_level(GF_FOP_INODELK, gf_error_to_errno(rsp.op_errno)), + gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(inodelk, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), xdata); @@ -1491,8 +1488,8 @@ client3_3_finodelk_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gf_common_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -1501,10 +1498,9 @@ client3_3_finodelk_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = client_post_finodelk(this, &rsp, &xdata); out: if (rsp.op_ret == -1) { - gf_msg(this->name, - fop_log_level(GF_FOP_FINODELK, gf_error_to_errno(rsp.op_errno)), - gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, - "remote operation failed"); + gf_smsg(this->name, + fop_log_level(GF_FOP_FINODELK, gf_error_to_errno(rsp.op_errno)), + gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, NULL); } else if (rsp.op_ret == 0) { if (local->attempt_reopen) client_attempt_reopen(local->fd, this); @@ -1543,8 +1539,8 @@ client3_3_entrylk_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gf_common_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -1553,10 +1549,9 @@ client3_3_entrylk_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = client_post_entrylk(this, &rsp, &xdata); out: if (rsp.op_ret == -1) { - gf_msg(this->name, - fop_log_level(GF_FOP_ENTRYLK, gf_error_to_errno(rsp.op_errno)), - gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, - "remote operation failed"); + gf_smsg(this->name, + fop_log_level(GF_FOP_ENTRYLK, gf_error_to_errno(rsp.op_errno)), + gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(entrylk, frame, rsp.op_ret, @@ -1593,8 +1588,8 @@ client3_3_fentrylk_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gf_common_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -1604,8 +1599,8 @@ client3_3_fentrylk_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if ((rsp.op_ret == -1) && (EAGAIN != gf_error_to_errno(rsp.op_errno))) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(fentrylk, frame, rsp.op_ret, @@ -1646,8 +1641,8 @@ client3_3_xattrop_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_xattrop_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); rsp.op_ret = -1; op_errno = EINVAL; goto out; @@ -1661,11 +1656,10 @@ client3_3_xattrop_cbk(struct rpc_req *req, struct iovec *iov, int count, } out: if (rsp.op_ret == -1) { - gf_msg(this->name, fop_log_level(GF_FOP_XATTROP, op_errno), - gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, - "remote operation failed. " - "Path: %s (%s)", - local->loc.path, loc_gfid_utoa(&local->loc)); + gf_smsg(this->name, fop_log_level(GF_FOP_XATTROP, op_errno), + gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, + "Path=%s", local->loc.path, "gfid=%s", + loc_gfid_utoa(&local->loc), NULL); } CLIENT_STACK_UNWIND(xattrop, frame, rsp.op_ret, gf_error_to_errno(op_errno), @@ -1714,8 +1708,8 @@ client3_3_fxattrop_cbk(struct rpc_req *req, struct iovec *iov, int count, if (ret < 0) { rsp.op_ret = -1; op_errno = EINVAL; - 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; } op_errno = rsp.op_errno; @@ -1728,8 +1722,8 @@ client3_3_fxattrop_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } else if (rsp.op_ret == 0) { if (local->attempt_reopen) client_attempt_reopen(local->fd, this); @@ -1774,8 +1768,8 @@ client3_3_fsetxattr_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gf_common_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -1792,10 +1786,8 @@ out: " %s", strerror(op_errno)); } else { - gf_msg(this->name, GF_LOG_WARNING, rsp.op_errno, - PC_MSG_REMOTE_OP_FAILED, - "remote operation " - "failed"); + gf_smsg(this->name, GF_LOG_WARNING, rsp.op_errno, + PC_MSG_REMOTE_OP_FAILED, NULL); } } @@ -1838,8 +1830,8 @@ client3_3_fsetattr_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_fsetattr_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -1848,8 +1840,8 @@ client3_3_fsetattr_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = client_post_fsetattr(this, &rsp, &prestat, &poststat, &xdata); out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(fsetattr, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), &prestat, &poststat, @@ -1892,8 +1884,8 @@ client3_3_fallocate_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_fallocate_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -1908,8 +1900,8 @@ client3_3_fallocate_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(fallocate, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), &prestat, &poststat, @@ -1952,8 +1944,8 @@ client3_3_discard_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_discard_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -1963,8 +1955,8 @@ client3_3_discard_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(discard, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), &prestat, &poststat, @@ -2007,8 +1999,8 @@ client3_3_zerofill_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_zerofill_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -2017,8 +2009,8 @@ client3_3_zerofill_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = client_post_zerofill(this, &rsp, &prestat, &poststat, &xdata); out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(zerofill, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), &prestat, &poststat, @@ -2055,8 +2047,8 @@ client3_3_ipc_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_ipc_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -2065,8 +2057,8 @@ client3_3_ipc_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = client_post_ipc(this, &rsp, &xdata); out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(ipc, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), xdata); @@ -2102,8 +2094,8 @@ client3_3_seek_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_seek_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -2113,8 +2105,8 @@ client3_3_seek_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(seek, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), rsp.offset, xdata); @@ -2157,8 +2149,8 @@ client3_3_setattr_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_setattr_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -2168,8 +2160,8 @@ client3_3_setattr_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(setattr, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), &prestat, &poststat, @@ -2222,8 +2214,8 @@ client3_3_create_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_create_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -2245,9 +2237,8 @@ client3_3_create_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed. Path: %s", - local->loc.path); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, "Path=%s", local->loc.path, NULL); } CLIENT_STACK_UNWIND(create, frame, rsp.op_ret, @@ -2286,8 +2277,8 @@ client3_3_rchecksum_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_rchecksum_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -2297,8 +2288,8 @@ client3_3_rchecksum_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(rchecksum, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), rsp.weak_checksum, @@ -2339,8 +2330,8 @@ client3_3_lease_cbk(struct rpc_req *req, struct iovec *iov, int count, frame = myframe; if (-1 == req->rpc_status) { - gf_msg(this->name, GF_LOG_ERROR, ENOTCONN, PC_MSG_REMOTE_OP_FAILED, - "Lease fop failed"); + gf_smsg(this->name, GF_LOG_ERROR, ENOTCONN, PC_MSG_LEASE_FOP_FAILED, + NULL); rsp.op_ret = -1; rsp.op_errno = ENOTCONN; goto out; @@ -2348,8 +2339,8 @@ client3_3_lease_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_lease_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -2359,8 +2350,8 @@ client3_3_lease_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(lease, frame, rsp.op_ret, @@ -2388,10 +2379,12 @@ client3_3_lk_cbk(struct rpc_req *req, struct iovec *iov, int count, int ret = 0; xlator_t *this = NULL; dict_t *xdata = NULL; + clnt_local_t *local = NULL; this = THIS; frame = myframe; + local = frame->local; if (-1 == req->rpc_status) { rsp.op_ret = -1; @@ -2401,8 +2394,8 @@ client3_3_lk_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_lk_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -2412,12 +2405,24 @@ client3_3_lk_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = client_post_lk(this, &rsp, &lock, &xdata); if (ret < 0) goto out; + + /* Save the lock to the client lock cache to be able + to recover in the case of server reboot.*/ + + if (client_is_setlk(local->cmd)) { + ret = client_add_lock_for_recovery(local->fd, &lock, &local->owner, + local->cmd); + if (ret < 0) { + rsp.op_ret = -1; + rsp.op_errno = -ret; + } + } } out: if ((rsp.op_ret == -1) && (EAGAIN != gf_error_to_errno(rsp.op_errno))) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(lk, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), @@ -2462,8 +2467,8 @@ client3_3_readdir_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_readdir_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -2473,9 +2478,8 @@ client3_3_readdir_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, - "remote operation failed: remote_fd = %d", local->cmd); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, "remote_fd=%d", local->cmd, NULL); } CLIENT_STACK_UNWIND(readdir, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), &entries, xdata); @@ -2523,8 +2527,8 @@ client3_3_readdirp_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_readdirp_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -2533,8 +2537,8 @@ client3_3_readdirp_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = client_post_readdirp(this, &rsp, local->fd, &entries, &xdata); out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(readdirp, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), &entries, xdata); @@ -2591,8 +2595,8 @@ client3_3_rename_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_rename_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -2603,8 +2607,8 @@ client3_3_rename_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(rename, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), &stbuf, &preoldparent, @@ -2656,8 +2660,8 @@ client3_3_link_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_link_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -2667,10 +2671,9 @@ client3_3_link_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { if (GF_IGNORE_IF_GSYNCD_SAFE_ERROR(frame, rsp.op_errno)) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, - "remote operation failed: (%s -> %s)", local->loc.path, - local->loc2.path); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, "loc1=%s", local->loc.path, + "loc2=%s", local->loc2.path, NULL); } } @@ -2715,8 +2718,8 @@ client3_3_opendir_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(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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -2735,12 +2738,11 @@ client3_3_opendir_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = client_post_opendir(this, &rsp, &xdata); out: if (rsp.op_ret == -1) { - gf_msg(this->name, - fop_log_level(GF_FOP_OPENDIR, gf_error_to_errno(rsp.op_errno)), - gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, - "remote operation failed." - " Path: %s (%s)", - local->loc.path, loc_gfid_utoa(&local->loc)); + gf_smsg(this->name, + fop_log_level(GF_FOP_OPENDIR, gf_error_to_errno(rsp.op_errno)), + gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, + "Path=%s", local->loc.path, "gfid=%s", + loc_gfid_utoa(&local->loc), NULL); } CLIENT_STACK_UNWIND(opendir, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), fd, xdata); @@ -2788,8 +2790,8 @@ client3_3_lookup_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_lookup_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); rsp.op_ret = -1; op_errno = EINVAL; goto out; @@ -2832,11 +2834,9 @@ out: /* any error other than ENOENT */ if (!(local->loc.name && rsp.op_errno == ENOENT) && !(rsp.op_errno == ESTALE)) - gf_msg(this->name, GF_LOG_WARNING, rsp.op_errno, - PC_MSG_REMOTE_OP_FAILED, - "remote operation " - "failed. Path: %s (%s)", - local->loc.path, loc_gfid_utoa(&local->loc)); + gf_smsg(this->name, GF_LOG_WARNING, rsp.op_errno, + PC_MSG_REMOTE_OP_FAILED, "Path=%s", local->loc.path, + "gfid=%s", loc_gfid_utoa(&local->loc), NULL); else gf_msg_trace(this->name, 0, "not found on remote " @@ -2876,8 +2876,6 @@ client3_3_readv_cbk(struct rpc_req *req, struct iovec *iov, int count, this = THIS; - memset(vector, 0, sizeof(vector)); - frame = myframe; local = frame->local; @@ -2889,19 +2887,21 @@ client3_3_readv_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_read_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; } + memset(vector, 0, sizeof(vector)); + ret = client_post_readv(this, &rsp, &iobref, req->rsp_iobref, &stat, vector, &req->rsp[1], &rspcount, &xdata); out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } else if (rsp.op_ret >= 0) { if (local->attempt_reopen) client_attempt_reopen(local->fd, this); @@ -2964,8 +2964,8 @@ client3_3_getactivelk_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_getactivelk_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -2982,8 +2982,8 @@ client3_3_getactivelk_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(getactivelk, frame, rsp.op_ret, @@ -3023,8 +3023,8 @@ client3_3_setactivelk_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_setactivelk_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -3035,8 +3035,8 @@ client3_3_setactivelk_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(setactivelk, frame, rsp.op_ret, @@ -3050,84 +3050,6 @@ out: return 0; } -int -client3_3_compound_cbk(struct rpc_req *req, struct iovec *iov, int count, - void *myframe) -{ - gfs3_compound_rsp rsp = { - 0, - }; - compound_args_cbk_t *args_cbk = NULL; - call_frame_t *frame = NULL; - xlator_t *this = NULL; - dict_t *xdata = NULL; - clnt_local_t *local = NULL; - int i = 0; - int length = 0; - int ret = -1; - - this = THIS; - - frame = myframe; - local = frame->local; - - if (-1 == req->rpc_status) { - rsp.op_ret = -1; - rsp.op_errno = ENOTCONN; - goto out; - } - - ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfs3_compound_rsp); - if (ret < 0) { - gf_msg(this->name, GF_LOG_ERROR, EINVAL, PC_MSG_XDR_DECODING_FAILED, - "XDR decoding failed"); - rsp.op_ret = -1; - rsp.op_errno = EINVAL; - goto out; - } - - length = local->length; - - GF_PROTOCOL_DICT_UNSERIALIZE(this, xdata, (rsp.xdata.xdata_val), - (rsp.xdata.xdata_len), rsp.op_ret, - rsp.op_errno, out); - - args_cbk = compound_args_cbk_alloc(length, xdata); - if (!args_cbk) { - rsp.op_ret = -1; - rsp.op_errno = ENOMEM; - goto out; - } - - /* TODO: see https://bugzilla.redhat.com/show_bug.cgi?id=1376328 */ - for (i = 0; i < args_cbk->fop_length; i++) { - ret = client_process_response(frame, this, req, &rsp, args_cbk, i); - if (ret) { - rsp.op_ret = -1; - rsp.op_errno = -ret; - goto out; - } - } - rsp.op_ret = 0; -out: - if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); - } - CLIENT_STACK_UNWIND(compound, frame, rsp.op_ret, - gf_error_to_errno(rsp.op_errno), args_cbk, xdata); - - free(rsp.xdata.xdata_val); - client_compound_rsp_cleanup(&rsp, length); - free(rsp.compound_rsp_array.compound_rsp_array_val); - - if (xdata) - dict_unref(xdata); - - compound_args_cbk_cleanup(args_cbk); - return 0; -} - int32_t client3_3_releasedir(call_frame_t *frame, xlator_t *this, void *data) { @@ -3234,12 +3156,11 @@ client3_3_lookup(call_frame_t *frame, xlator_t *this, void *data) struct iobref *rsp_iobref = NULL; struct iobuf *rsp_iobuf = NULL; struct iovec *rsphdr = NULL; + client_payload_t cp; if (!frame || !this || !data) goto unwind; - memset(vector, 0, sizeof(vector)); - conf = this->private; args = data; local = mem_get0(this->local_pool); @@ -3256,7 +3177,7 @@ client3_3_lookup(call_frame_t *frame, xlator_t *this, void *data) loc_path(&local->loc, NULL); if (args->xdata) { - content = dict_get(args->xdata, GF_CONTENT_KEY); + content = dict_get_sizen(args->xdata, GF_CONTENT_KEY); if (content != NULL) { rsp_iobref = iobref_new(); if (rsp_iobref == NULL) { @@ -3272,6 +3193,7 @@ client3_3_lookup(call_frame_t *frame, xlator_t *this, void *data) } iobref_add(rsp_iobref, rsp_iobuf); + memset(vector, 0, sizeof(vector)); rsphdr = &vector[0]; rsphdr->iov_base = iobuf_ptr(rsp_iobuf); rsphdr->iov_len = iobuf_pagesize(rsp_iobuf); @@ -3288,14 +3210,17 @@ client3_3_lookup(call_frame_t *frame, xlator_t *this, void *data) op_errno = -ret; goto unwind; } + + memset(&cp, 0, sizeof(client_payload_t)); + cp.rsphdr = rsphdr; + cp.rsphdr_cnt = count; + cp.rsp_iobref = local->iobref; ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_LOOKUP, - client3_3_lookup_cbk, NULL, rsphdr, count, NULL, - 0, local->iobref, + client3_3_lookup_cbk, &cp, (xdrproc_t)xdr_gfs3_lookup_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -3338,11 +3263,10 @@ client3_3_stat(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_STAT, - client3_3_stat_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfs3_stat_req); + client3_3_stat_cbk, NULL, + (xdrproc_t)xdr_gfs3_stat_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -3381,11 +3305,10 @@ client3_3_truncate(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_TRUNCATE, - client3_3_truncate_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfs3_truncate_req); + client3_3_truncate_cbk, NULL, + (xdrproc_t)xdr_gfs3_truncate_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -3425,11 +3348,9 @@ client3_3_ftruncate(call_frame_t *frame, xlator_t *this, void *data) } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_FTRUNCATE, client3_3_ftruncate_cbk, - NULL, NULL, 0, NULL, 0, NULL, - (xdrproc_t)xdr_gfs3_ftruncate_req); + NULL, (xdrproc_t)xdr_gfs3_ftruncate_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -3468,11 +3389,10 @@ client3_3_access(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_ACCESS, - client3_3_access_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfs3_access_req); + client3_3_access_cbk, NULL, + (xdrproc_t)xdr_gfs3_access_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -3505,6 +3425,7 @@ client3_3_readlink(call_frame_t *frame, xlator_t *this, void *data) struct iovec vector[MAX_IOVEC] = { {0}, }; + client_payload_t cp; if (!frame || !this || !data) goto unwind; @@ -3547,13 +3468,15 @@ client3_3_readlink(call_frame_t *frame, xlator_t *this, void *data) rsp_iobuf = NULL; rsp_iobref = NULL; + memset(&cp, 0, sizeof(client_payload_t)); + cp.rsphdr = rsphdr; + cp.rsphdr_cnt = count; + cp.rsp_iobref = local->iobref; ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_READLINK, - client3_3_readlink_cbk, NULL, rsphdr, count, - NULL, 0, local->iobref, + client3_3_readlink_cbk, &cp, (xdrproc_t)xdr_gfs3_readlink_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -3595,11 +3518,10 @@ client3_3_unlink(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_UNLINK, - client3_3_unlink_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfs3_unlink_req); + client3_3_unlink_cbk, NULL, + (xdrproc_t)xdr_gfs3_unlink_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -3638,11 +3560,10 @@ client3_3_rmdir(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_RMDIR, - client3_3_rmdir_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfs3_rmdir_req); + client3_3_rmdir_cbk, NULL, + (xdrproc_t)xdr_gfs3_rmdir_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -3697,11 +3618,10 @@ client3_3_symlink(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_SYMLINK, - client3_3_symlink_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfs3_symlink_req); + client3_3_symlink_cbk, NULL, + (xdrproc_t)xdr_gfs3_symlink_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -3743,11 +3663,10 @@ client3_3_rename(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_RENAME, - client3_3_rename_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfs3_rename_req); + client3_3_rename_cbk, NULL, + (xdrproc_t)xdr_gfs3_rename_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -3802,11 +3721,10 @@ client3_3_link(call_frame_t *frame, xlator_t *this, void *data) loc_path(&local->loc2, NULL); ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_LINK, - client3_3_link_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfs3_link_req); + client3_3_link_cbk, NULL, + (xdrproc_t)xdr_gfs3_link_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -3857,11 +3775,10 @@ client3_3_mknod(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_MKNOD, - client3_3_mknod_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfs3_mknod_req); + client3_3_mknod_cbk, NULL, + (xdrproc_t)xdr_gfs3_mknod_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -3895,7 +3812,7 @@ client3_3_mkdir(call_frame_t *frame, xlator_t *this, void *data) args = data; conf = this->private; - if (!args->xdata || !dict_get(args->xdata, "gfid-req")) { + if (!args->xdata || !dict_get_sizen(args->xdata, "gfid-req")) { op_errno = EPERM; gf_msg_callingfn(this->name, GF_LOG_WARNING, op_errno, PC_MSG_GFID_NULL, "mkdir: %s is received " @@ -3924,11 +3841,10 @@ client3_3_mkdir(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_MKDIR, - client3_3_mkdir_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfs3_mkdir_req); + client3_3_mkdir_cbk, NULL, + (xdrproc_t)xdr_gfs3_mkdir_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -3982,11 +3898,10 @@ client3_3_create(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_CREATE, - client3_3_create_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfs3_create_req); + client3_3_create_cbk, NULL, + (xdrproc_t)xdr_gfs3_create_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -4043,11 +3958,10 @@ client3_3_open(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_OPEN, - client3_3_open_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfs3_open_req); + client3_3_open_cbk, NULL, + (xdrproc_t)xdr_gfs3_open_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -4079,6 +3993,7 @@ client3_3_readv(call_frame_t *frame, xlator_t *this, void *data) }; struct iobuf *rsp_iobuf = NULL; struct iobref *rsp_iobref = NULL; + client_payload_t cp; if (!frame || !this || !data) goto unwind; @@ -4120,9 +4035,9 @@ client3_3_readv(call_frame_t *frame, xlator_t *this, void *data) rsp_iobuf = NULL; if (args->size > rsp_vec.iov_len) { - gf_msg(this->name, GF_LOG_WARNING, ENOMEM, PC_MSG_NO_MEMORY, - "read-size (%lu) is bigger than iobuf size (%lu)", - (unsigned long)args->size, (unsigned long)rsp_vec.iov_len); + gf_smsg(this->name, GF_LOG_WARNING, ENOMEM, PC_MSG_BIGGER_SIZE, + "read-size=%lu", (unsigned long)args->size, "iobuf size=%lu", + (unsigned long)rsp_vec.iov_len, NULL); op_errno = EINVAL; goto unwind; } @@ -4130,13 +4045,16 @@ client3_3_readv(call_frame_t *frame, xlator_t *this, void *data) local->iobref = rsp_iobref; rsp_iobref = NULL; + memset(&cp, 0, sizeof(client_payload_t)); + cp.rsp_payload = &rsp_vec; + cp.rsp_payload_cnt = 1; + cp.rsp_iobref = local->iobref; ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_READ, - client3_3_readv_cbk, NULL, NULL, 0, &rsp_vec, 1, - local->iobref, (xdrproc_t)xdr_gfs3_read_req); + client3_3_readv_cbk, &cp, + (xdrproc_t)xdr_gfs3_read_req); if (ret) { // unwind is done in the cbk - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -4167,6 +4085,7 @@ client3_3_writev(call_frame_t *frame, xlator_t *this, void *data) }; int op_errno = ESTALE; int ret = 0; + client_payload_t cp; if (!frame || !this || !data) goto unwind; @@ -4187,9 +4106,13 @@ client3_3_writev(call_frame_t *frame, xlator_t *this, void *data) op_errno = -ret; goto unwind; } + + memset(&cp, 0, sizeof(client_payload_t)); + cp.iobref = args->iobref; + cp.payload = args->vector; + cp.payload_cnt = args->count; ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_WRITE, - client3_3_writev_cbk, args->iobref, - args->vector, args->count, NULL, 0, NULL, + client3_3_writev_cbk, &cp, (xdrproc_t)xdr_gfs3_write_req); if (ret) { /* @@ -4197,8 +4120,7 @@ client3_3_writev(call_frame_t *frame, xlator_t *this, void *data) * do the unwind for us (see rpc_clnt_submit), so don't unwind * here in such cases. */ - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -4245,14 +4167,21 @@ client3_3_flush(call_frame_t *frame, xlator_t *this, void *data) ret = client_pre_flush(this, &req, args->fd, args->xdata); if (ret) { op_errno = -ret; + if (op_errno == EBADF) { + ret = delete_granted_locks_owner(local->fd, &local->owner); + gf_msg_trace(this->name, 0, + "deleting locks of owner (%s) returned %d", + lkowner_utoa(&local->owner), ret); + } + goto unwind; } + ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_FLUSH, - client3_3_flush_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfs3_flush_req); + client3_3_flush_cbk, NULL, + (xdrproc_t)xdr_gfs3_flush_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -4291,11 +4220,10 @@ client3_3_fsync(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_FSYNC, - client3_3_fsync_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfs3_fsync_req); + client3_3_fsync_cbk, NULL, + (xdrproc_t)xdr_gfs3_fsync_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -4336,11 +4264,10 @@ client3_3_fstat(call_frame_t *frame, xlator_t *this, void *data) } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_FSTAT, - client3_3_fstat_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfs3_fstat_req); + client3_3_fstat_cbk, NULL, + (xdrproc_t)xdr_gfs3_fstat_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -4391,11 +4318,10 @@ client3_3_opendir(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_OPENDIR, - client3_3_opendir_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfs3_opendir_req); + client3_3_opendir_cbk, NULL, + (xdrproc_t)xdr_gfs3_opendir_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -4435,11 +4361,10 @@ client3_3_fsyncdir(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_FSYNCDIR, - client3_3_fsyncdir_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfs3_fsyncdir_req); + client3_3_fsyncdir_cbk, NULL, + (xdrproc_t)xdr_gfs3_fsyncdir_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -4479,11 +4404,10 @@ client3_3_statfs(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_STATFS, - client3_3_statfs_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfs3_statfs_req); + client3_3_statfs_cbk, NULL, + (xdrproc_t)xdr_gfs3_statfs_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -4523,11 +4447,10 @@ client3_3_setxattr(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_SETXATTR, - client3_3_setxattr_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfs3_setxattr_req); + client3_3_setxattr_cbk, NULL, + (xdrproc_t)xdr_gfs3_setxattr_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.dict.dict_val); @@ -4570,11 +4493,9 @@ client3_3_fsetxattr(call_frame_t *frame, xlator_t *this, void *data) } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_FSETXATTR, client3_3_fsetxattr_cbk, - NULL, NULL, 0, NULL, 0, NULL, - (xdrproc_t)xdr_gfs3_fsetxattr_req); + NULL, (xdrproc_t)xdr_gfs3_fsetxattr_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.dict.dict_val); @@ -4611,6 +4532,7 @@ client3_3_fgetxattr(call_frame_t *frame, xlator_t *this, void *data) struct iovec vector[MAX_IOVEC] = { {0}, }; + client_payload_t cp; if (!frame || !this || !data) goto unwind; @@ -4654,13 +4576,16 @@ client3_3_fgetxattr(call_frame_t *frame, xlator_t *this, void *data) op_errno = -ret; goto unwind; } + + memset(&cp, 0, sizeof(client_payload_t)); + cp.rsphdr = rsphdr; + cp.rsphdr_cnt = count; + cp.rsp_iobref = local->iobref; ret = client_submit_request(this, &req, frame, conf->fops, - GFS3_OP_FGETXATTR, client3_3_fgetxattr_cbk, - NULL, rsphdr, count, NULL, 0, local->iobref, + GFS3_OP_FGETXATTR, client3_3_fgetxattr_cbk, &cp, (xdrproc_t)xdr_gfs3_fgetxattr_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -4699,11 +4624,13 @@ client3_3_getxattr(call_frame_t *frame, xlator_t *this, void *data) struct iovec vector[MAX_IOVEC] = { {0}, }; + client_payload_t cp; if (!frame || !this || !data) { op_errno = 0; goto unwind; } + args = data; local = mem_get0(this->local_pool); @@ -4756,9 +4683,8 @@ client3_3_getxattr(call_frame_t *frame, xlator_t *this, void *data) ret = client_dump_locks((char *)args->name, args->loc->inode, dict); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, EINVAL, PC_MSG_INVALID_ENTRY, - "Client dump " - "locks failed"); + gf_smsg(this->name, GF_LOG_WARNING, EINVAL, + PC_MSG_CLIENT_DUMP_LOCKS_FAILED, NULL); op_errno = ENOMEM; goto unwind; } @@ -4775,13 +4701,16 @@ client3_3_getxattr(call_frame_t *frame, xlator_t *this, void *data) op_errno = -ret; goto unwind; } + + memset(&cp, 0, sizeof(client_payload_t)); + cp.rsphdr = rsphdr; + cp.rsphdr_cnt = count; + cp.rsp_iobref = local->iobref; ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_GETXATTR, - client3_3_getxattr_cbk, NULL, rsphdr, count, - NULL, 0, local->iobref, + client3_3_getxattr_cbk, &cp, (xdrproc_t)xdr_gfs3_getxattr_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -4822,6 +4751,7 @@ client3_3_xattrop(call_frame_t *frame, xlator_t *this, void *data) struct iovec vector[MAX_IOVEC] = { {0}, }; + client_payload_t cp; if (!frame || !this || !data) goto unwind; @@ -4871,13 +4801,16 @@ client3_3_xattrop(call_frame_t *frame, xlator_t *this, void *data) op_errno = -ret; goto unwind; } + + memset(&cp, 0, sizeof(client_payload_t)); + cp.rsphdr = rsphdr; + cp.rsphdr_cnt = count; + cp.rsp_iobref = local->iobref; ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_XATTROP, - client3_3_xattrop_cbk, NULL, rsphdr, count, - NULL, 0, local->iobref, + client3_3_xattrop_cbk, &cp, (xdrproc_t)xdr_gfs3_xattrop_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.dict.dict_val); @@ -4918,6 +4851,7 @@ client3_3_fxattrop(call_frame_t *frame, xlator_t *this, void *data) struct iovec vector[MAX_IOVEC] = { {0}, }; + client_payload_t cp; if (!frame || !this || !data) goto unwind; @@ -4962,13 +4896,15 @@ client3_3_fxattrop(call_frame_t *frame, xlator_t *this, void *data) rsp_iobuf = NULL; rsp_iobref = NULL; + memset(&cp, 0, sizeof(client_payload_t)); + cp.rsphdr = rsphdr; + cp.rsphdr_cnt = count; + cp.rsp_iobref = local->iobref; ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_FXATTROP, - client3_3_fxattrop_cbk, NULL, rsphdr, count, - NULL, 0, local->iobref, + client3_3_fxattrop_cbk, &cp, (xdrproc_t)xdr_gfs3_fxattrop_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.dict.dict_val); @@ -5016,11 +4952,9 @@ client3_3_removexattr(call_frame_t *frame, xlator_t *this, void *data) } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_REMOVEXATTR, client3_3_removexattr_cbk, - NULL, NULL, 0, NULL, 0, NULL, - (xdrproc_t)xdr_gfs3_removexattr_req); + NULL, (xdrproc_t)xdr_gfs3_removexattr_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -5059,13 +4993,11 @@ client3_3_fremovexattr(call_frame_t *frame, xlator_t *this, void *data) op_errno = -ret; goto unwind; } - ret = client_submit_request(this, &req, frame, conf->fops, - GFS3_OP_FREMOVEXATTR, - client3_3_fremovexattr_cbk, NULL, NULL, 0, NULL, - 0, NULL, (xdrproc_t)xdr_gfs3_fremovexattr_req); + ret = client_submit_request( + this, &req, frame, conf->fops, GFS3_OP_FREMOVEXATTR, + client3_3_fremovexattr_cbk, NULL, (xdrproc_t)xdr_gfs3_fremovexattr_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -5104,11 +5036,10 @@ client3_3_lease(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_LEASE, - client3_3_lease_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfs3_lease_req); + client3_3_lease_cbk, NULL, + (xdrproc_t)xdr_gfs3_lease_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -5151,8 +5082,8 @@ client3_3_lk(call_frame_t *frame, xlator_t *this, void *data) ret = client_cmd_to_gf_cmd(args->cmd, &gf_cmd); if (ret) { op_errno = EINVAL; - gf_msg(this->name, GF_LOG_WARNING, EINVAL, PC_MSG_INVALID_ENTRY, - "Unknown cmd (%d)!", gf_cmd); + gf_smsg(this->name, GF_LOG_WARNING, EINVAL, PC_MSG_UNKNOWN_CMD, + "gf_cmd=%d", gf_cmd, NULL); goto unwind; } @@ -5164,14 +5095,21 @@ client3_3_lk(call_frame_t *frame, xlator_t *this, void *data) args->xdata); if (ret) { op_errno = -ret; + + if ((op_errno == EBADF) && (args->flock->l_type == F_UNLCK) && + client_is_setlk(local->cmd)) { + client_add_lock_for_recovery(local->fd, args->flock, &local->owner, + local->cmd); + } + goto unwind; } + ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_LK, - client3_3_lk_cbk, NULL, NULL, 0, NULL, 0, NULL, + client3_3_lk_cbk, NULL, (xdrproc_t)xdr_gfs3_lk_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -5210,11 +5148,10 @@ client3_3_inodelk(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_INODELK, - client3_3_inodelk_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfs3_inodelk_req); + client3_3_inodelk_cbk, NULL, + (xdrproc_t)xdr_gfs3_inodelk_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -5260,11 +5197,10 @@ client3_3_finodelk(call_frame_t *frame, xlator_t *this, void *data) } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_FINODELK, - client3_3_finodelk_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfs3_finodelk_req); + client3_3_finodelk_cbk, NULL, + (xdrproc_t)xdr_gfs3_finodelk_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -5305,11 +5241,10 @@ client3_3_entrylk(call_frame_t *frame, xlator_t *this, void *data) } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_ENTRYLK, - client3_3_entrylk_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfs3_entrylk_req); + client3_3_entrylk_cbk, NULL, + (xdrproc_t)xdr_gfs3_entrylk_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -5349,11 +5284,10 @@ client3_3_fentrylk(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_FENTRYLK, - client3_3_fentrylk_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfs3_fentrylk_req); + client3_3_fentrylk_cbk, NULL, + (xdrproc_t)xdr_gfs3_fentrylk_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -5391,11 +5325,9 @@ client3_3_rchecksum(call_frame_t *frame, xlator_t *this, void *data) } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_RCHECKSUM, client3_3_rchecksum_cbk, - NULL, NULL, 0, NULL, 0, NULL, - (xdrproc_t)xdr_gfs3_rchecksum_req); + NULL, (xdrproc_t)xdr_gfs3_rchecksum_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -5433,6 +5365,7 @@ client3_3_readdir(call_frame_t *frame, xlator_t *this, void *data) {0}, }; int readdir_rsp_size = 0; + client_payload_t cp; if (!frame || !this || !data) goto unwind; @@ -5486,14 +5419,16 @@ client3_3_readdir(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } + memset(&cp, 0, sizeof(client_payload_t)); + cp.rsphdr = rsphdr; + cp.rsphdr_cnt = count; + cp.rsp_iobref = rsp_iobref; ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_READDIR, - client3_3_readdir_cbk, NULL, rsphdr, count, - NULL, 0, rsp_iobref, + client3_3_readdir_cbk, &cp, (xdrproc_t)xdr_gfs3_readdir_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -5534,6 +5469,7 @@ client3_3_readdirp(call_frame_t *frame, xlator_t *this, void *data) {0}, }; clnt_local_t *local = NULL; + client_payload_t cp; if (!frame || !this || !data) goto unwind; @@ -5587,13 +5523,15 @@ client3_3_readdirp(call_frame_t *frame, xlator_t *this, void *data) local->fd = fd_ref(args->fd); + memset(&cp, 0, sizeof(client_payload_t)); + cp.rsphdr = rsphdr; + cp.rsphdr_cnt = count; + cp.rsp_iobref = rsp_iobref; ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_READDIRP, - client3_3_readdirp_cbk, NULL, rsphdr, count, - NULL, 0, rsp_iobref, + client3_3_readdirp_cbk, &cp, (xdrproc_t)xdr_gfs3_readdirp_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.dict.dict_val); @@ -5637,11 +5575,10 @@ client3_3_setattr(call_frame_t *frame, xlator_t *this, void *data) } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_SETATTR, - client3_3_setattr_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfs3_setattr_req); + client3_3_setattr_cbk, NULL, + (xdrproc_t)xdr_gfs3_setattr_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -5679,11 +5616,10 @@ client3_3_fsetattr(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_FSETATTR, - client3_3_fsetattr_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfs3_fsetattr_req); + client3_3_fsetattr_cbk, NULL, + (xdrproc_t)xdr_gfs3_fsetattr_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -5722,11 +5658,9 @@ client3_3_fallocate(call_frame_t *frame, xlator_t *this, void *data) ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_FALLOCATE, client3_3_fallocate_cbk, - NULL, NULL, 0, NULL, 0, NULL, - (xdrproc_t)xdr_gfs3_fallocate_req); + NULL, (xdrproc_t)xdr_gfs3_fallocate_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -5764,11 +5698,10 @@ client3_3_discard(call_frame_t *frame, xlator_t *this, void *data) } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_DISCARD, - client3_3_discard_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfs3_discard_req); + client3_3_discard_cbk, NULL, + (xdrproc_t)xdr_gfs3_discard_req); if (ret) - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); GF_FREE(req.xdata.xdata_val); @@ -5807,11 +5740,10 @@ client3_3_zerofill(call_frame_t *frame, xlator_t *this, void *data) } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_ZEROFILL, - client3_3_zerofill_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfs3_zerofill_req); + client3_3_zerofill_cbk, NULL, + (xdrproc_t)xdr_gfs3_zerofill_req); if (ret) - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); GF_FREE(req.xdata.xdata_val); @@ -5850,11 +5782,10 @@ client3_3_ipc(call_frame_t *frame, xlator_t *this, void *data) } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_IPC, - client3_3_ipc_cbk, NULL, NULL, 0, NULL, 0, NULL, + client3_3_ipc_cbk, NULL, (xdrproc_t)xdr_gfs3_ipc_req); if (ret) - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); GF_FREE(req.xdata.xdata_val); @@ -5895,11 +5826,10 @@ client3_3_seek(call_frame_t *frame, xlator_t *this, void *data) } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_SEEK, - client3_3_seek_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfs3_seek_req); + client3_3_seek_cbk, NULL, + (xdrproc_t)xdr_gfs3_seek_req); if (ret) - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); GF_FREE(req.xdata.xdata_val); @@ -5911,143 +5841,6 @@ unwind: return 0; } -/* Brief explanation of gfs3_compound_req structure : - * 1) It consists of version of compounding. - * 2) A compound-fop enum, new enum for compound fops - * 3) A 'compound_req_arrray' structure that has - * a) array len - based on the number of fops compounded - * b) compound_req_array_val - pointer to an array of compound_req's - * 4) compound_req - structure that contains: - * a) fop enum of type glusterfs_fop_t - * b) union of structures of xdr requests of all fops. - */ - -int32_t -client3_3_compound(call_frame_t *frame, xlator_t *this, void *data) -{ - clnt_conf_t *conf = NULL; - compound_args_t *c_args = data; - gfs3_compound_req req = { - 0, - }; - clnt_local_t *local = NULL; - int op_errno = ENOMEM; - int ret = 0; - int i = 0; - int rsp_count = 0; - struct iovec rsp_vector[MAX_IOVEC] = { - {0}, - }; - struct iovec req_vector[MAX_IOVEC] = { - {0}, - }; - struct iovec vector[MAX_IOVEC] = { - {0}, - }; - struct iovec *rsphdr = NULL; - struct iobref *req_iobref = NULL; - struct iobref *rsp_iobref = NULL; - struct iobref *rsphdr_iobref = NULL; - struct iobuf *rsphdr_iobuf = NULL; - int rsphdr_count = 0; - int req_count = 0; - dict_t *xdata = c_args->xdata; - - GF_ASSERT(frame); - - if (!this) - goto unwind; - - memset(req_vector, 0, sizeof(req_vector)); - memset(rsp_vector, 0, sizeof(rsp_vector)); - - conf = this->private; - - local = mem_get0(this->local_pool); - if (!local) { - op_errno = ENOMEM; - goto unwind; - } - frame->local = local; - - local->length = c_args->fop_length; - local->compound_args = c_args; - - rsphdr_iobref = iobref_new(); - if (rsphdr_iobref == NULL) { - goto unwind; - } - - /* TODO: what is the size we should send ? */ - rsphdr_iobuf = iobuf_get(this->ctx->iobuf_pool); - if (rsphdr_iobuf == NULL) { - goto unwind; - } - - rsphdr = &vector[0]; - rsphdr->iov_base = iobuf_ptr(rsphdr_iobuf); - rsphdr->iov_len = iobuf_pagesize(rsphdr_iobuf); - rsphdr_count = 1; - iobref_add(rsphdr_iobref, rsphdr_iobuf); - iobuf_unref(rsphdr_iobuf); - rsphdr_iobuf = NULL; - - req.compound_fop_enum = c_args->fop_enum; - req.compound_req_array.compound_req_array_len = c_args->fop_length; - req.compound_version = 0; - if (xdata) { - GF_PROTOCOL_DICT_SERIALIZE(this, xdata, (&req.xdata.xdata_val), - req.xdata.xdata_len, op_errno, unwind); - } - - req.compound_req_array.compound_req_array_val = GF_CALLOC( - local->length, sizeof(compound_req), gf_client_mt_compound_req_t); - - if (!req.compound_req_array.compound_req_array_val) { - op_errno = ENOMEM; - goto unwind; - } - - for (i = 0; i < local->length; i++) { - ret = client_handle_fop_requirements( - this, frame, &req, local, &req_iobref, &rsp_iobref, req_vector, - rsp_vector, &req_count, &rsp_count, &c_args->req_list[i], - c_args->enum_list[i], i); - if (ret) { - op_errno = ret; - goto unwind; - } - } - - local->iobref = rsp_iobref; - rsp_iobref = NULL; - - ret = client_submit_compound_request( - this, &req, frame, conf->fops, GFS3_OP_COMPOUND, client3_3_compound_cbk, - req_vector, req_count, req_iobref, rsphdr, rsphdr_count, rsp_vector, - rsp_count, local->iobref, (xdrproc_t)xdr_gfs3_compound_req); - - GF_FREE(req.xdata.xdata_val); - - iobref_unref(rsphdr_iobref); - - compound_request_cleanup(&req); - return 0; -unwind: - CLIENT_STACK_UNWIND(compound, frame, -1, op_errno, NULL, NULL); - - if (rsp_iobref) - iobref_unref(rsp_iobref); - - if (rsphdr_iobref) - iobref_unref(rsphdr_iobref); - - GF_FREE(req.xdata.xdata_val); - - compound_request_cleanup(&req); - return 0; -} - static int32_t client3_3_getactivelk(call_frame_t *frame, xlator_t *this, void *data) { @@ -6083,11 +5876,9 @@ client3_3_getactivelk(call_frame_t *frame, xlator_t *this, void *data) ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_GETACTIVELK, client3_3_getactivelk_cbk, - NULL, NULL, 0, NULL, 0, NULL, - (xdrproc_t)xdr_gfs3_getactivelk_req); + NULL, (xdrproc_t)xdr_gfs3_getactivelk_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.xdata_val); @@ -6141,11 +5932,9 @@ client3_3_setactivelk(call_frame_t *frame, xlator_t *this, void *data) ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_SETACTIVELK, client3_3_setactivelk_cbk, - NULL, NULL, 0, NULL, 0, NULL, - (xdrproc_t)xdr_gfs3_setactivelk_req); + NULL, (xdrproc_t)xdr_gfs3_setactivelk_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } clnt_setactivelk_req_cleanup(&req); @@ -6220,7 +6009,7 @@ rpc_clnt_procedure_t clnt3_3_fop_actors[GF_FOP_MAXVALUE] = { [GF_FOP_LEASE] = {"LEASE", client3_3_lease}, [GF_FOP_GETACTIVELK] = {"GETACTIVELK", client3_3_getactivelk}, [GF_FOP_SETACTIVELK] = {"SETACTIVELK", client3_3_setactivelk}, - [GF_FOP_COMPOUND] = {"COMPOUND", client3_3_compound}, + [GF_FOP_COMPOUND] = {"COMPOUND", NULL}, }; /* Used From RPC-CLNT library to log proper name of procedure based on number */ diff --git a/xlators/protocol/client/src/client-rpc-fops_v2.c b/xlators/protocol/client/src/client-rpc-fops_v2.c index 55a9fd04a6a..0d80d4e8efb 100644 --- a/xlators/protocol/client/src/client-rpc-fops_v2.c +++ b/xlators/protocol/client/src/client-rpc-fops_v2.c @@ -12,11 +12,10 @@ #include "rpc-common-xdr.h" #include "glusterfs4-xdr.h" #include "glusterfs3.h" -#include "compat-errno.h" +#include <glusterfs/compat-errno.h> #include "client-messages.h" -#include "defaults.h" +#include <glusterfs/defaults.h> #include "client-common.h" -#include "compound-fop-utils.h" extern int32_t client3_getspec(call_frame_t *frame, xlator_t *this, void *data); @@ -60,8 +59,8 @@ client4_0_symlink_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_3iatt_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -76,10 +75,9 @@ out: /* no need to print the gfid, because it will be null, * since symlink operation failed. */ - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, - "remote operation failed. Path: (%s to %s)", local->loc.path, - local->loc2.path); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, "source=%s", local->loc.path, + "target=%s", local->loc2.path, NULL); } } @@ -131,8 +129,8 @@ client4_0_mknod_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_3iatt_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -144,10 +142,10 @@ client4_0_mknod_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1 && GF_IGNORE_IF_GSYNCD_SAFE_ERROR(frame, rsp.op_errno)) { - gf_msg(this->name, - fop_log_level(GF_FOP_MKNOD, gf_error_to_errno(rsp.op_errno)), - gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, - "remote operation failed. Path: %s", local->loc.path); + gf_smsg(this->name, + fop_log_level(GF_FOP_MKNOD, gf_error_to_errno(rsp.op_errno)), + gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, + "path=%s", local->loc.path, NULL); } CLIENT_STACK_UNWIND(mknod, frame, rsp.op_ret, @@ -197,8 +195,8 @@ client4_0_mkdir_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_3iatt_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -210,10 +208,10 @@ client4_0_mkdir_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1 && GF_IGNORE_IF_GSYNCD_SAFE_ERROR(frame, rsp.op_errno)) { - gf_msg(this->name, - fop_log_level(GF_FOP_MKDIR, gf_error_to_errno(rsp.op_errno)), - gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, - "remote operation failed. Path: %s", local->loc.path); + gf_smsg(this->name, + fop_log_level(GF_FOP_MKDIR, gf_error_to_errno(rsp.op_errno)), + gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, + "path=%s", local->loc.path, NULL); } CLIENT_STACK_UNWIND(mkdir, frame, rsp.op_ret, @@ -254,8 +252,8 @@ client4_0_open_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(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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -274,11 +272,11 @@ client4_0_open_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_dict(&rsp.xdata, &xdata); out: if (rsp.op_ret == -1) { - gf_msg(this->name, - fop_log_level(GF_FOP_OPEN, gf_error_to_errno(rsp.op_errno)), - gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, - "remote operation failed. Path: %s (%s)", local->loc.path, - loc_gfid_utoa(&local->loc)); + gf_smsg(this->name, + fop_log_level(GF_FOP_OPEN, gf_error_to_errno(rsp.op_errno)), + gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, + "path=%s", local->loc.path, "gfid=%s", + loc_gfid_utoa(&local->loc), NULL); } CLIENT_STACK_UNWIND(open, frame, rsp.op_ret, @@ -316,8 +314,8 @@ client4_0_stat_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_iatt_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -332,8 +330,8 @@ out: gf_msg_debug(this->name, 0, "remote operation failed: %s", strerror(gf_error_to_errno(rsp.op_errno))); } else { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } } @@ -372,8 +370,8 @@ client4_0_readlink_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_readlink_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -389,10 +387,8 @@ out: " %s", strerror(gf_error_to_errno(rsp.op_errno))); } else { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, - "remote operation " - "failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } } @@ -439,8 +435,8 @@ client4_0_unlink_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_2iatt_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -456,10 +452,8 @@ out: " %s", strerror(gf_error_to_errno(rsp.op_errno))); } else { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, - "remote operation " - "failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } } @@ -502,8 +496,8 @@ client4_0_rmdir_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_2iatt_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -514,8 +508,8 @@ client4_0_rmdir_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { if (GF_IGNORE_IF_GSYNCD_SAFE_ERROR(frame, rsp.op_errno)) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } } CLIENT_STACK_UNWIND(rmdir, frame, rsp.op_ret, @@ -557,8 +551,8 @@ client4_0_truncate_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_2iatt_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -568,8 +562,8 @@ client4_0_truncate_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(truncate, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), &prestat, &poststat, @@ -607,8 +601,8 @@ client4_0_statfs_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_statfs_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -620,8 +614,8 @@ client4_0_statfs_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_dict(&rsp.xdata, &xdata); out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(statfs, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), &statfs, xdata); @@ -664,8 +658,8 @@ client4_0_writev_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_2iatt_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -676,8 +670,8 @@ client4_0_writev_cbk(struct rpc_req *req, struct iovec *iov, int count, goto out; out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } else if (rsp.op_ret >= 0) { if (local->attempt_reopen) client_attempt_reopen(local->fd, this); @@ -716,14 +710,15 @@ client4_0_flush_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; } - if (rsp.op_ret >= 0 && !fd_is_anonymous(local->fd)) { + if ((rsp.op_ret >= 0 || (rsp.op_errno == ENOTCONN)) && + !fd_is_anonymous(local->fd)) { /* Delete all saved locks of the owner issuing flush */ ret = delete_granted_locks_owner(local->fd, &local->owner); gf_msg_trace(this->name, 0, "deleting locks of owner (%s) returned %d", @@ -734,10 +729,9 @@ client4_0_flush_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, - fop_log_level(GF_FOP_FLUSH, gf_error_to_errno(rsp.op_errno)), - gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, - "remote operation failed"); + gf_smsg(this->name, + fop_log_level(GF_FOP_FLUSH, gf_error_to_errno(rsp.op_errno)), + gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(flush, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), xdata); @@ -778,8 +772,8 @@ client4_0_fsync_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_2iatt_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -791,8 +785,8 @@ client4_0_fsync_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(fsync, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), &prestat, &poststat, @@ -828,8 +822,8 @@ client4_0_setxattr_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -845,10 +839,8 @@ out: " %s", strerror(op_errno)); } else { - gf_msg(this->name, GF_LOG_WARNING, op_errno, - PC_MSG_REMOTE_OP_FAILED, - "remote operation " - "failed"); + gf_smsg(this->name, GF_LOG_WARNING, op_errno, + PC_MSG_REMOTE_OP_FAILED, NULL); } } @@ -888,8 +880,8 @@ client4_0_getxattr_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_dict_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); rsp.op_ret = -1; op_errno = EINVAL; goto out; @@ -913,12 +905,10 @@ out: loc_gfid_utoa(&local->loc), (local->name) ? local->name : "(null)"); } else { - gf_msg(this->name, GF_LOG_WARNING, op_errno, - PC_MSG_REMOTE_OP_FAILED, - "remote operation " - "failed. Path: %s (%s). Key: %s", - local->loc.path, loc_gfid_utoa(&local->loc), - (local->name) ? local->name : "(null)"); + gf_smsg(this->name, GF_LOG_WARNING, op_errno, + PC_MSG_REMOTE_OP_FAILED, "path=%s", local->loc.path, + "gfid=%s", loc_gfid_utoa(&local->loc), "key=%s", + (local->name) ? local->name : "(null)", NULL); } } else { /* This is required as many places, `if (ret)` is checked @@ -964,8 +954,8 @@ client4_0_fgetxattr_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_dict_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); rsp.op_ret = -1; op_errno = EINVAL; goto out; @@ -984,10 +974,8 @@ out: gf_msg_debug(this->name, 0, "remote operation failed: %s", strerror(op_errno)); } else { - gf_msg(this->name, GF_LOG_WARNING, op_errno, - PC_MSG_REMOTE_OP_FAILED, - "remote operation " - "failed"); + gf_smsg(this->name, GF_LOG_WARNING, op_errno, + PC_MSG_REMOTE_OP_FAILED, NULL); } } else { /* This is required as many places, `if (ret)` is checked @@ -1033,8 +1021,8 @@ client4_0_removexattr_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -1053,8 +1041,8 @@ out: else loglevel = GF_LOG_WARNING; - gf_msg(this->name, loglevel, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, loglevel, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(removexattr, frame, rsp.op_ret, @@ -1090,8 +1078,8 @@ client4_0_fremovexattr_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -1100,8 +1088,8 @@ client4_0_fremovexattr_cbk(struct rpc_req *req, struct iovec *iov, int count, xdr_to_dict(&rsp.xdata, &xdata); out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(fremovexattr, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), xdata); @@ -1135,8 +1123,8 @@ client4_0_fsyncdir_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -1146,8 +1134,8 @@ client4_0_fsyncdir_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(fsyncdir, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), xdata); @@ -1181,8 +1169,8 @@ client4_0_access_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -1192,8 +1180,8 @@ client4_0_access_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(access, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), xdata); @@ -1233,8 +1221,8 @@ client4_0_ftruncate_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_2iatt_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -1244,8 +1232,8 @@ client4_0_ftruncate_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(ftruncate, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), &prestat, &poststat, @@ -1283,8 +1271,8 @@ client4_0_fstat_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_iatt_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -1294,8 +1282,8 @@ client4_0_fstat_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(fstat, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), &stat, xdata); @@ -1329,8 +1317,8 @@ client4_0_inodelk_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -1339,10 +1327,9 @@ client4_0_inodelk_cbk(struct rpc_req *req, struct iovec *iov, int count, xdr_to_dict(&rsp.xdata, &xdata); out: if (rsp.op_ret == -1) { - gf_msg(this->name, - fop_log_level(GF_FOP_INODELK, gf_error_to_errno(rsp.op_errno)), - gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, - "remote operation failed"); + gf_smsg(this->name, + fop_log_level(GF_FOP_INODELK, gf_error_to_errno(rsp.op_errno)), + gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(inodelk, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), xdata); @@ -1377,8 +1364,8 @@ client4_0_finodelk_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -1387,10 +1374,9 @@ client4_0_finodelk_cbk(struct rpc_req *req, struct iovec *iov, int count, xdr_to_dict(&rsp.xdata, &xdata); out: if (rsp.op_ret == -1) { - gf_msg(this->name, - fop_log_level(GF_FOP_FINODELK, gf_error_to_errno(rsp.op_errno)), - gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, - "remote operation failed"); + gf_smsg(this->name, + fop_log_level(GF_FOP_FINODELK, gf_error_to_errno(rsp.op_errno)), + gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, NULL); } else if (rsp.op_ret == 0) { if (local->attempt_reopen) client_attempt_reopen(local->fd, this); @@ -1427,8 +1413,8 @@ client4_0_entrylk_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -1437,10 +1423,9 @@ client4_0_entrylk_cbk(struct rpc_req *req, struct iovec *iov, int count, xdr_to_dict(&rsp.xdata, &xdata); out: if (rsp.op_ret == -1) { - gf_msg(this->name, - fop_log_level(GF_FOP_ENTRYLK, gf_error_to_errno(rsp.op_errno)), - gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, - "remote operation failed"); + gf_smsg(this->name, + fop_log_level(GF_FOP_ENTRYLK, gf_error_to_errno(rsp.op_errno)), + gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(entrylk, frame, rsp.op_ret, @@ -1475,8 +1460,8 @@ client4_0_fentrylk_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -1486,8 +1471,8 @@ client4_0_fentrylk_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if ((rsp.op_ret == -1) && (EAGAIN != gf_error_to_errno(rsp.op_errno))) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(fentrylk, frame, rsp.op_ret, @@ -1526,8 +1511,8 @@ client4_0_xattrop_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_dict_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); rsp.op_ret = -1; op_errno = EINVAL; goto out; @@ -1541,11 +1526,10 @@ client4_0_xattrop_cbk(struct rpc_req *req, struct iovec *iov, int count, } out: if (rsp.op_ret == -1) { - gf_msg(this->name, fop_log_level(GF_FOP_XATTROP, op_errno), - gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, - "remote operation failed. " - "Path: %s (%s)", - local->loc.path, loc_gfid_utoa(&local->loc)); + gf_smsg(this->name, fop_log_level(GF_FOP_XATTROP, op_errno), + gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, + "Path=%s", local->loc.path, "gfid=%s", + loc_gfid_utoa(&local->loc), NULL); } else { /* This is required as many places, `if (ret)` is checked for syncop_xattrop() */ @@ -1596,8 +1580,8 @@ client4_0_fxattrop_cbk(struct rpc_req *req, struct iovec *iov, int count, if (ret < 0) { rsp.op_ret = -1; op_errno = EINVAL; - 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; } op_errno = rsp.op_errno; @@ -1610,8 +1594,8 @@ client4_0_fxattrop_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } else { /* This is required as many places, `if (ret)` is checked for syncop_fxattrop() */ @@ -1658,8 +1642,8 @@ client4_0_fsetxattr_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -1676,10 +1660,8 @@ out: " %s", strerror(op_errno)); } else { - gf_msg(this->name, GF_LOG_WARNING, rsp.op_errno, - PC_MSG_REMOTE_OP_FAILED, - "remote operation " - "failed"); + gf_smsg(this->name, GF_LOG_WARNING, rsp.op_errno, + PC_MSG_REMOTE_OP_FAILED, NULL); } } @@ -1720,8 +1702,8 @@ client4_0_fallocate_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_2iatt_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -1733,8 +1715,8 @@ client4_0_fallocate_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(fallocate, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), &prestat, &poststat, @@ -1775,8 +1757,8 @@ client4_0_discard_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_2iatt_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -1786,8 +1768,8 @@ client4_0_discard_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(discard, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), &prestat, &poststat, @@ -1827,8 +1809,8 @@ client4_0_zerofill_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_2iatt_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -1837,8 +1819,8 @@ client4_0_zerofill_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = client_post_common_2iatt(this, &rsp, &prestat, &poststat, &xdata); out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(zerofill, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), &prestat, &poststat, @@ -1873,8 +1855,8 @@ client4_0_ipc_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -1883,8 +1865,8 @@ client4_0_ipc_cbk(struct rpc_req *req, struct iovec *iov, int count, xdr_to_dict(&rsp.xdata, &xdata); out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(ipc, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), xdata); @@ -1918,8 +1900,8 @@ client4_0_seek_cbk(struct rpc_req *req, struct iovec *iov, int count, } ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_seek_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -1928,8 +1910,8 @@ client4_0_seek_cbk(struct rpc_req *req, struct iovec *iov, int count, xdr_to_dict(&rsp.xdata, &xdata); out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(seek, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), rsp.offset, xdata); @@ -1970,8 +1952,8 @@ client4_0_setattr_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_2iatt_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -1981,8 +1963,8 @@ client4_0_setattr_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(setattr, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), &prestat, &poststat, @@ -2024,8 +2006,8 @@ client4_0_fsetattr_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_2iatt_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -2035,8 +2017,8 @@ client4_0_fsetattr_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(fsetattr, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), &prestat, &poststat, @@ -2087,18 +2069,19 @@ client4_0_create_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_create_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; } + ret = client_post_create_v2(this, &rsp, &stbuf, &preparent, &postparent, + local, &xdata); + if (ret < 0) + goto out; + if (-1 != rsp.op_ret) { - ret = client_post_create_v2(this, &rsp, &stbuf, &preparent, &postparent, - local, &xdata); - if (ret < 0) - goto out; ret = client_add_fd_to_saved_fds(frame->this, fd, &local->loc, local->flags, rsp.fd, 0); if (ret) { @@ -2110,9 +2093,8 @@ client4_0_create_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed. Path: %s", - local->loc.path); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, "path=%s", local->loc.path, NULL); } CLIENT_STACK_UNWIND(create, frame, rsp.op_ret, @@ -2145,8 +2127,8 @@ client4_0_lease_cbk(struct rpc_req *req, struct iovec *iov, int count, frame = myframe; if (-1 == req->rpc_status) { - gf_msg(this->name, GF_LOG_ERROR, ENOTCONN, PC_MSG_REMOTE_OP_FAILED, - "Lease fop failed"); + gf_smsg(this->name, GF_LOG_ERROR, ENOTCONN, PC_MSG_REMOTE_OP_FAILED, + NULL); rsp.op_ret = -1; rsp.op_errno = ENOTCONN; goto out; @@ -2154,8 +2136,8 @@ client4_0_lease_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_lease_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -2165,8 +2147,8 @@ client4_0_lease_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(lease, frame, rsp.op_ret, @@ -2192,10 +2174,12 @@ client4_0_lk_cbk(struct rpc_req *req, struct iovec *iov, int count, int ret = 0; xlator_t *this = NULL; dict_t *xdata = NULL; + clnt_local_t *local = NULL; this = THIS; frame = myframe; + local = frame->local; if (-1 == req->rpc_status) { rsp.op_ret = -1; @@ -2205,8 +2189,8 @@ client4_0_lk_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_lk_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -2216,12 +2200,24 @@ client4_0_lk_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = client_post_lk_v2(this, &rsp, &lock, &xdata); if (ret < 0) goto out; + + /* Save the lock to the client lock cache to be able + to recover in the case of server reboot.*/ + + if (client_is_setlk(local->cmd)) { + ret = client_add_lock_for_recovery(local->fd, &lock, &local->owner, + local->cmd); + if (ret < 0) { + rsp.op_ret = -1; + rsp.op_errno = -ret; + } + } } out: if ((rsp.op_ret == -1) && (EAGAIN != gf_error_to_errno(rsp.op_errno))) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(lk, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), @@ -2264,8 +2260,8 @@ client4_0_readdir_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_readdir_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -2275,9 +2271,8 @@ client4_0_readdir_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, - "remote operation failed: remote_fd = %d", local->cmd); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, "remote_fd=%d", local->cmd, NULL); } CLIENT_STACK_UNWIND(readdir, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), &entries, xdata); @@ -2323,8 +2318,8 @@ client4_0_readdirp_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_readdirp_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -2333,8 +2328,8 @@ client4_0_readdirp_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = client_post_readdirp_v2(this, &rsp, local->fd, &entries, &xdata); out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(readdirp, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), &entries, xdata); @@ -2390,8 +2385,8 @@ client4_0_rename_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_rename_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -2401,8 +2396,8 @@ client4_0_rename_cbk(struct rpc_req *req, struct iovec *iov, int count, &prenewparent, &postnewparent, &xdata); out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(rename, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), &stbuf, &preoldparent, @@ -2452,8 +2447,8 @@ client4_0_link_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_3iatt_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -2464,10 +2459,9 @@ client4_0_link_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { if (GF_IGNORE_IF_GSYNCD_SAFE_ERROR(frame, rsp.op_errno)) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, - "remote operation failed: (%s -> %s)", local->loc.path, - local->loc2.path); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, "source=%s", local->loc.path, + "target=%s", local->loc2.path, NULL); } } @@ -2512,8 +2506,8 @@ client4_0_opendir_cbk(struct rpc_req *req, struct iovec *iov, int count, but separated by fop number only */ ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_open_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -2532,12 +2526,11 @@ client4_0_opendir_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_dict(&rsp.xdata, &xdata); out: if (rsp.op_ret == -1) { - gf_msg(this->name, - fop_log_level(GF_FOP_OPENDIR, gf_error_to_errno(rsp.op_errno)), - gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, - "remote operation failed." - " Path: %s (%s)", - local->loc.path, loc_gfid_utoa(&local->loc)); + gf_smsg(this->name, + fop_log_level(GF_FOP_OPENDIR, gf_error_to_errno(rsp.op_errno)), + gf_error_to_errno(rsp.op_errno), PC_MSG_REMOTE_OP_FAILED, + "path=%s", local->loc.path, "gfid=%s", + loc_gfid_utoa(&local->loc), NULL); } CLIENT_STACK_UNWIND(opendir, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), fd, xdata); @@ -2583,8 +2576,8 @@ client4_0_lookup_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_2iatt_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); rsp.op_ret = -1; op_errno = EINVAL; goto out; @@ -2613,7 +2606,7 @@ client4_0_lookup_cbk(struct rpc_req *req, struct iovec *iov, int count, rsp.op_ret = -1; op_errno = ESTALE; if (xdata) - ret = dict_set_int32(xdata, "gfid-changed", 1); + ret = dict_set_int32_sizen(xdata, "gfid-changed", 1); goto out; } @@ -2627,11 +2620,9 @@ out: /* any error other than ENOENT */ if (!(local->loc.name && rsp.op_errno == ENOENT) && !(rsp.op_errno == ESTALE)) - gf_msg(this->name, GF_LOG_WARNING, rsp.op_errno, - PC_MSG_REMOTE_OP_FAILED, - "remote operation " - "failed. Path: %s (%s)", - local->loc.path, loc_gfid_utoa(&local->loc)); + gf_smsg(this->name, GF_LOG_WARNING, rsp.op_errno, + PC_MSG_REMOTE_OP_FAILED, "path=%s", local->loc.path, + "gfid=%s", loc_gfid_utoa(&local->loc), NULL); else gf_msg_trace(this->name, 0, "not found on remote " @@ -2669,8 +2660,6 @@ client4_0_readv_cbk(struct rpc_req *req, struct iovec *iov, int count, this = THIS; - memset(vector, 0, sizeof(vector)); - frame = myframe; local = frame->local; @@ -2682,19 +2671,21 @@ client4_0_readv_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_read_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; } + memset(vector, 0, sizeof(vector)); + ret = client_post_readv_v2(this, &rsp, &iobref, req->rsp_iobref, &stat, vector, &req->rsp[1], &rspcount, &xdata); out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } else if (rsp.op_ret >= 0) { if (local->attempt_reopen) client_attempt_reopen(local->fd, this); @@ -2755,8 +2746,8 @@ client4_0_getactivelk_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_getactivelk_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -2772,8 +2763,8 @@ client4_0_getactivelk_cbk(struct rpc_req *req, struct iovec *iov, int count, out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(getactivelk, frame, rsp.op_ret, @@ -2810,8 +2801,8 @@ client4_0_setactivelk_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -2820,8 +2811,8 @@ client4_0_setactivelk_cbk(struct rpc_req *req, struct iovec *iov, int count, xdr_to_dict(&rsp.xdata, &xdata); out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(setactivelk, frame, rsp.op_ret, @@ -2833,6 +2824,72 @@ out: return 0; } +int +client4_0_copy_file_range_cbk(struct rpc_req *req, struct iovec *iov, int count, + void *myframe) +{ + gfx_common_3iatt_rsp rsp = { + 0, + }; + call_frame_t *frame = NULL; + struct iatt stbuf = { + 0, + }; + struct iatt prestat = { + 0, + }; + struct iatt poststat = { + 0, + }; + int ret = 0; + xlator_t *this = NULL; + dict_t *xdata = NULL; + clnt_local_t *local = NULL; + + this = THIS; + + frame = myframe; + local = frame->local; + + if (-1 == req->rpc_status) { + rsp.op_ret = -1; + rsp.op_errno = ENOTCONN; + goto out; + } + + ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_3iatt_rsp); + if (ret < 0) { + gf_smsg(this->name, GF_LOG_ERROR, EINVAL, PC_MSG_XDR_DECODING_FAILED, + NULL); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; + } + + ret = client_post_common_3iatt(this, &rsp, &stbuf, &prestat, &poststat, + &xdata); + if (ret < 0) + goto out; +out: + if (rsp.op_ret == -1) { + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); + } else if (rsp.op_ret >= 0) { + if (local->attempt_reopen) + client_attempt_reopen(local->fd, this); + if (local->attempt_reopen_out) + client_attempt_reopen(local->fd_out, this); + } + CLIENT_STACK_UNWIND(copy_file_range, frame, rsp.op_ret, + gf_error_to_errno(rsp.op_errno), &stbuf, &prestat, + &poststat, xdata); + + if (xdata) + dict_unref(xdata); + + return 0; +} + int32_t client4_0_releasedir(call_frame_t *frame, xlator_t *this, void *data) { @@ -2939,12 +2996,11 @@ client4_0_lookup(call_frame_t *frame, xlator_t *this, void *data) struct iobref *rsp_iobref = NULL; struct iobuf *rsp_iobuf = NULL; struct iovec *rsphdr = NULL; + client_payload_t cp; if (!frame || !this || !data) goto unwind; - memset(vector, 0, sizeof(vector)); - conf = this->private; args = data; local = mem_get0(this->local_pool); @@ -2961,7 +3017,7 @@ client4_0_lookup(call_frame_t *frame, xlator_t *this, void *data) loc_path(&local->loc, NULL); if (args->xdata) { - content = dict_get(args->xdata, GF_CONTENT_KEY); + content = dict_get_sizen(args->xdata, GF_CONTENT_KEY); if (content != NULL) { rsp_iobref = iobref_new(); if (rsp_iobref == NULL) { @@ -2977,6 +3033,7 @@ client4_0_lookup(call_frame_t *frame, xlator_t *this, void *data) } iobref_add(rsp_iobref, rsp_iobuf); + memset(vector, 0, sizeof(vector)); rsphdr = &vector[0]; rsphdr->iov_base = iobuf_ptr(rsp_iobuf); rsphdr->iov_len = iobuf_pagesize(rsp_iobuf); @@ -2993,14 +3050,18 @@ client4_0_lookup(call_frame_t *frame, xlator_t *this, void *data) op_errno = -ret; goto unwind; } + + memset(&cp, 0, sizeof(client_payload_t)); + + cp.rsphdr = rsphdr; + cp.rsphdr_cnt = count; + cp.rsp_iobref = local->iobref; ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_LOOKUP, - client4_0_lookup_cbk, NULL, rsphdr, count, NULL, - 0, local->iobref, + client4_0_lookup_cbk, &cp, (xdrproc_t)xdr_gfx_lookup_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -3043,11 +3104,10 @@ client4_0_stat(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_STAT, - client4_0_stat_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_stat_req); + client4_0_stat_cbk, NULL, + (xdrproc_t)xdr_gfx_stat_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -3087,11 +3147,10 @@ client4_0_truncate(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_TRUNCATE, - client4_0_truncate_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_truncate_req); + client4_0_truncate_cbk, NULL, + (xdrproc_t)xdr_gfx_truncate_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -3132,11 +3191,9 @@ client4_0_ftruncate(call_frame_t *frame, xlator_t *this, void *data) } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_FTRUNCATE, client4_0_ftruncate_cbk, - NULL, NULL, 0, NULL, 0, NULL, - (xdrproc_t)xdr_gfx_ftruncate_req); + NULL, (xdrproc_t)xdr_gfx_ftruncate_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -3175,11 +3232,10 @@ client4_0_access(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_ACCESS, - client4_0_access_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_access_req); + client4_0_access_cbk, NULL, + (xdrproc_t)xdr_gfx_access_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -3229,11 +3285,10 @@ client4_0_readlink(call_frame_t *frame, xlator_t *this, void *data) } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_READLINK, - client4_0_readlink_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_readlink_req); + client4_0_readlink_cbk, NULL, + (xdrproc_t)xdr_gfx_readlink_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -3272,11 +3327,10 @@ client4_0_unlink(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_UNLINK, - client4_0_unlink_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_unlink_req); + client4_0_unlink_cbk, NULL, + (xdrproc_t)xdr_gfx_unlink_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -3315,11 +3369,10 @@ client4_0_rmdir(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_RMDIR, - client4_0_rmdir_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_rmdir_req); + client4_0_rmdir_cbk, NULL, + (xdrproc_t)xdr_gfx_rmdir_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -3374,11 +3427,10 @@ client4_0_symlink(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_SYMLINK, - client4_0_symlink_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_symlink_req); + client4_0_symlink_cbk, NULL, + (xdrproc_t)xdr_gfx_symlink_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -3420,11 +3472,10 @@ client4_0_rename(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_RENAME, - client4_0_rename_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_rename_req); + client4_0_rename_cbk, NULL, + (xdrproc_t)xdr_gfx_rename_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -3480,11 +3531,10 @@ client4_0_link(call_frame_t *frame, xlator_t *this, void *data) loc_path(&local->loc2, NULL); ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_LINK, - client4_0_link_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_link_req); + client4_0_link_cbk, NULL, + (xdrproc_t)xdr_gfx_link_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -3535,11 +3585,10 @@ client4_0_mknod(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_MKNOD, - client4_0_mknod_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_mknod_req); + client4_0_mknod_cbk, NULL, + (xdrproc_t)xdr_gfx_mknod_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -3573,7 +3622,7 @@ client4_0_mkdir(call_frame_t *frame, xlator_t *this, void *data) args = data; conf = this->private; - if (!args->xdata || !dict_get(args->xdata, "gfid-req")) { + if (!args->xdata || !dict_get_sizen(args->xdata, "gfid-req")) { op_errno = EPERM; gf_msg_callingfn(this->name, GF_LOG_WARNING, op_errno, PC_MSG_GFID_NULL, "mkdir: %s is received " @@ -3602,11 +3651,10 @@ client4_0_mkdir(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_MKDIR, - client4_0_mkdir_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_mkdir_req); + client4_0_mkdir_cbk, NULL, + (xdrproc_t)xdr_gfx_mkdir_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -3660,11 +3708,10 @@ client4_0_create(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_CREATE, - client4_0_create_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_create_req); + client4_0_create_cbk, NULL, + (xdrproc_t)xdr_gfx_create_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -3721,11 +3768,10 @@ client4_0_open(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_OPEN, - client4_0_open_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_open_req); + client4_0_open_cbk, NULL, + (xdrproc_t)xdr_gfx_open_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -3757,6 +3803,7 @@ client4_0_readv(call_frame_t *frame, xlator_t *this, void *data) }; struct iobuf *rsp_iobuf = NULL; struct iobref *rsp_iobref = NULL; + client_payload_t cp; if (!frame || !this || !data) goto unwind; @@ -3799,19 +3846,23 @@ client4_0_readv(call_frame_t *frame, xlator_t *this, void *data) rsp_iobuf = NULL; if (args->size > rsp_vec.iov_len) { - gf_msg(this->name, GF_LOG_WARNING, ENOMEM, PC_MSG_NO_MEMORY, - "read-size (%lu) is bigger than iobuf size (%lu)", - (unsigned long)args->size, (unsigned long)rsp_vec.iov_len); + gf_smsg(this->name, GF_LOG_WARNING, ENOMEM, PC_MSG_BIGGER_SIZE, + "read-size=%lu", (unsigned long)args->size, "iobuf-size=%lu", + (unsigned long)rsp_vec.iov_len, NULL); op_errno = EINVAL; goto unwind; } + memset(&cp, 0, sizeof(client_payload_t)); + + cp.rsp_payload = &rsp_vec; + cp.rsp_payload_cnt = 1; + cp.rsp_iobref = local->iobref; ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_READ, - client4_0_readv_cbk, NULL, NULL, 0, &rsp_vec, 1, - local->iobref, (xdrproc_t)xdr_gfx_read_req); + client4_0_readv_cbk, &cp, + (xdrproc_t)xdr_gfx_read_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -3839,6 +3890,7 @@ client4_0_writev(call_frame_t *frame, xlator_t *this, void *data) }; int op_errno = ESTALE; int ret = 0; + client_payload_t cp; if (!frame || !this || !data) goto unwind; @@ -3860,9 +3912,13 @@ client4_0_writev(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } + memset(&cp, 0, sizeof(client_payload_t)); + + cp.iobref = args->iobref; + cp.payload = args->vector; + cp.payload_cnt = args->count; ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_WRITE, - client4_0_writev_cbk, args->iobref, - args->vector, args->count, NULL, 0, NULL, + client4_0_writev_cbk, &cp, (xdrproc_t)xdr_gfx_write_req); if (ret) { /* @@ -3870,8 +3926,7 @@ client4_0_writev(call_frame_t *frame, xlator_t *this, void *data) * do the unwind for us (see rpc_clnt_submit), so don't unwind * here in such cases. */ - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -3918,14 +3973,20 @@ client4_0_flush(call_frame_t *frame, xlator_t *this, void *data) ret = client_pre_flush_v2(this, &req, args->fd, args->xdata); if (ret) { op_errno = -ret; + if (op_errno == EBADF) { + ret = delete_granted_locks_owner(local->fd, &local->owner); + gf_msg_trace(this->name, 0, + "deleting locks of owner (%s) returned %d", + lkowner_utoa(&local->owner), ret); + } + goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_FLUSH, - client4_0_flush_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_flush_req); + client4_0_flush_cbk, NULL, + (xdrproc_t)xdr_gfx_flush_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -3964,11 +4025,10 @@ client4_0_fsync(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_FSYNC, - client4_0_fsync_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_fsync_req); + client4_0_fsync_cbk, NULL, + (xdrproc_t)xdr_gfx_fsync_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -4009,11 +4069,10 @@ client4_0_fstat(call_frame_t *frame, xlator_t *this, void *data) } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_FSTAT, - client4_0_fstat_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_fstat_req); + client4_0_fstat_cbk, NULL, + (xdrproc_t)xdr_gfx_fstat_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -4064,11 +4123,10 @@ client4_0_opendir(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_OPENDIR, - client4_0_opendir_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_opendir_req); + client4_0_opendir_cbk, NULL, + (xdrproc_t)xdr_gfx_opendir_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -4109,11 +4167,10 @@ client4_0_fsyncdir(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_FSYNCDIR, - client4_0_fsyncdir_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_fsyncdir_req); + client4_0_fsyncdir_cbk, NULL, + (xdrproc_t)xdr_gfx_fsyncdir_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -4153,11 +4210,10 @@ client4_0_statfs(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_STATFS, - client4_0_statfs_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_statfs_req); + client4_0_statfs_cbk, NULL, + (xdrproc_t)xdr_gfx_statfs_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -4197,11 +4253,10 @@ client4_0_setxattr(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_SETXATTR, - client4_0_setxattr_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_setxattr_req); + client4_0_setxattr_cbk, NULL, + (xdrproc_t)xdr_gfx_setxattr_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.dict.pairs.pairs_val); @@ -4244,11 +4299,9 @@ client4_0_fsetxattr(call_frame_t *frame, xlator_t *this, void *data) } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_FSETXATTR, client4_0_fsetxattr_cbk, - NULL, NULL, 0, NULL, 0, NULL, - (xdrproc_t)xdr_gfx_fsetxattr_req); + NULL, (xdrproc_t)xdr_gfx_fsetxattr_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.dict.pairs.pairs_val); @@ -4298,11 +4351,9 @@ client4_0_fgetxattr(call_frame_t *frame, xlator_t *this, void *data) } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_FGETXATTR, client4_0_fgetxattr_cbk, - NULL, NULL, 0, NULL, 0, NULL, - (xdrproc_t)xdr_gfx_fgetxattr_req); + NULL, (xdrproc_t)xdr_gfx_fgetxattr_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -4365,9 +4416,8 @@ client4_0_getxattr(call_frame_t *frame, xlator_t *this, void *data) ret = client_dump_locks((char *)args->name, args->loc->inode, dict); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, EINVAL, PC_MSG_INVALID_ENTRY, - "Client dump " - "locks failed"); + gf_smsg(this->name, GF_LOG_WARNING, EINVAL, + PC_MSG_CLIENT_DUMP_LOCKS_FAILED, NULL); op_errno = ENOMEM; goto unwind; } @@ -4386,11 +4436,10 @@ client4_0_getxattr(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_GETXATTR, - client4_0_getxattr_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_getxattr_req); + client4_0_getxattr_cbk, NULL, + (xdrproc_t)xdr_gfx_getxattr_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -4448,11 +4497,10 @@ client4_0_xattrop(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_XATTROP, - client4_0_xattrop_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_xattrop_req); + client4_0_xattrop_cbk, NULL, + (xdrproc_t)xdr_gfx_xattrop_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.dict.pairs.pairs_val); @@ -4500,11 +4548,10 @@ client4_0_fxattrop(call_frame_t *frame, xlator_t *this, void *data) } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_FXATTROP, - client4_0_fxattrop_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_fxattrop_req); + client4_0_fxattrop_cbk, NULL, + (xdrproc_t)xdr_gfx_fxattrop_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.dict.pairs.pairs_val); @@ -4547,11 +4594,9 @@ client4_0_removexattr(call_frame_t *frame, xlator_t *this, void *data) } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_REMOVEXATTR, client4_0_removexattr_cbk, - NULL, NULL, 0, NULL, 0, NULL, - (xdrproc_t)xdr_gfx_removexattr_req); + NULL, (xdrproc_t)xdr_gfx_removexattr_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -4590,13 +4635,11 @@ client4_0_fremovexattr(call_frame_t *frame, xlator_t *this, void *data) op_errno = -ret; goto unwind; } - ret = client_submit_request(this, &req, frame, conf->fops, - GFS3_OP_FREMOVEXATTR, - client4_0_fremovexattr_cbk, NULL, NULL, 0, NULL, - 0, NULL, (xdrproc_t)xdr_gfx_fremovexattr_req); + ret = client_submit_request( + this, &req, frame, conf->fops, GFS3_OP_FREMOVEXATTR, + client4_0_fremovexattr_cbk, NULL, (xdrproc_t)xdr_gfx_fremovexattr_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -4635,11 +4678,10 @@ client4_0_lease(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_LEASE, - client4_0_lease_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_lease_req); + client4_0_lease_cbk, NULL, + (xdrproc_t)xdr_gfx_lease_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -4682,8 +4724,8 @@ client4_0_lk(call_frame_t *frame, xlator_t *this, void *data) ret = client_cmd_to_gf_cmd(args->cmd, &gf_cmd); if (ret) { op_errno = EINVAL; - gf_msg(this->name, GF_LOG_WARNING, EINVAL, PC_MSG_INVALID_ENTRY, - "Unknown cmd (%d)!", gf_cmd); + gf_smsg(this->name, GF_LOG_WARNING, EINVAL, PC_MSG_UNKNOWN_CMD, + "gf_cmd=%d", gf_cmd, NULL); goto unwind; } @@ -4695,14 +4737,21 @@ client4_0_lk(call_frame_t *frame, xlator_t *this, void *data) args->xdata); if (ret) { op_errno = -ret; + + if ((op_errno == EBADF) && (args->flock->l_type == F_UNLCK) && + client_is_setlk(local->cmd)) { + client_add_lock_for_recovery(local->fd, args->flock, &local->owner, + local->cmd); + } + goto unwind; } + ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_LK, - client4_0_lk_cbk, NULL, NULL, 0, NULL, 0, NULL, + client4_0_lk_cbk, NULL, (xdrproc_t)xdr_gfx_lk_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -4741,11 +4790,10 @@ client4_0_inodelk(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_INODELK, - client4_0_inodelk_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_inodelk_req); + client4_0_inodelk_cbk, NULL, + (xdrproc_t)xdr_gfx_inodelk_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -4791,11 +4839,10 @@ client4_0_finodelk(call_frame_t *frame, xlator_t *this, void *data) } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_FINODELK, - client4_0_finodelk_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_finodelk_req); + client4_0_finodelk_cbk, NULL, + (xdrproc_t)xdr_gfx_finodelk_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -4836,11 +4883,10 @@ client4_0_entrylk(call_frame_t *frame, xlator_t *this, void *data) } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_ENTRYLK, - client4_0_entrylk_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_entrylk_req); + client4_0_entrylk_cbk, NULL, + (xdrproc_t)xdr_gfx_entrylk_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -4880,11 +4926,10 @@ client4_0_fentrylk(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_FENTRYLK, - client4_0_fentrylk_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_fentrylk_req); + client4_0_fentrylk_cbk, NULL, + (xdrproc_t)xdr_gfx_fentrylk_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -4922,6 +4967,7 @@ client4_0_readdir(call_frame_t *frame, xlator_t *this, void *data) {0}, }; int readdir_rsp_size = 0; + client_payload_t cp; if (!frame || !this || !data) goto unwind; @@ -4975,14 +5021,17 @@ client4_0_readdir(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } + memset(&cp, 0, sizeof(client_payload_t)); + + cp.rsphdr = rsphdr; + cp.rsphdr_cnt = count; + cp.rsp_iobref = rsp_iobref; ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_READDIR, - client4_0_readdir_cbk, NULL, rsphdr, count, - NULL, 0, rsp_iobref, + client4_0_readdir_cbk, &cp, (xdrproc_t)xdr_gfx_readdir_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -5023,6 +5072,7 @@ client4_0_readdirp(call_frame_t *frame, xlator_t *this, void *data) {0}, }; clnt_local_t *local = NULL; + client_payload_t cp; if (!frame || !this || !data) goto unwind; @@ -5076,13 +5126,16 @@ client4_0_readdirp(call_frame_t *frame, xlator_t *this, void *data) local->fd = fd_ref(args->fd); + memset(&cp, 0, sizeof(client_payload_t)); + + cp.rsphdr = rsphdr; + cp.rsphdr_cnt = count; + cp.rsp_iobref = rsp_iobref; ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_READDIRP, - client4_0_readdirp_cbk, NULL, rsphdr, count, - NULL, 0, rsp_iobref, + client4_0_readdirp_cbk, &cp, (xdrproc_t)xdr_gfx_readdirp_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -5126,11 +5179,10 @@ client4_0_setattr(call_frame_t *frame, xlator_t *this, void *data) } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_SETATTR, - client4_0_setattr_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_setattr_req); + client4_0_setattr_cbk, NULL, + (xdrproc_t)xdr_gfx_setattr_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -5169,11 +5221,9 @@ client4_0_fallocate(call_frame_t *frame, xlator_t *this, void *data) ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_FALLOCATE, client4_0_fallocate_cbk, - NULL, NULL, 0, NULL, 0, NULL, - (xdrproc_t)xdr_gfx_fallocate_req); + NULL, (xdrproc_t)xdr_gfx_fallocate_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -5211,11 +5261,10 @@ client4_0_discard(call_frame_t *frame, xlator_t *this, void *data) } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_DISCARD, - client4_0_discard_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_discard_req); + client4_0_discard_cbk, NULL, + (xdrproc_t)xdr_gfx_discard_req); if (ret) - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); GF_FREE(req.xdata.pairs.pairs_val); @@ -5254,11 +5303,10 @@ client4_0_zerofill(call_frame_t *frame, xlator_t *this, void *data) } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_ZEROFILL, - client4_0_zerofill_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_zerofill_req); + client4_0_zerofill_cbk, NULL, + (xdrproc_t)xdr_gfx_zerofill_req); if (ret) - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); GF_FREE(req.xdata.pairs.pairs_val); @@ -5297,11 +5345,10 @@ client4_0_ipc(call_frame_t *frame, xlator_t *this, void *data) } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_IPC, - client4_0_ipc_cbk, NULL, NULL, 0, NULL, 0, NULL, + client4_0_ipc_cbk, NULL, (xdrproc_t)xdr_gfx_ipc_req); if (ret) - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); GF_FREE(req.xdata.pairs.pairs_val); @@ -5342,11 +5389,10 @@ client4_0_seek(call_frame_t *frame, xlator_t *this, void *data) } ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_SEEK, - client4_0_seek_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_seek_req); + client4_0_seek_cbk, NULL, + (xdrproc_t)xdr_gfx_seek_req); if (ret) - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); GF_FREE(req.xdata.pairs.pairs_val); @@ -5392,11 +5438,9 @@ client4_0_getactivelk(call_frame_t *frame, xlator_t *this, void *data) ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_GETACTIVELK, client4_0_getactivelk_cbk, - NULL, NULL, 0, NULL, 0, NULL, - (xdrproc_t)xdr_gfx_getactivelk_req); + NULL, (xdrproc_t)xdr_gfx_getactivelk_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -5448,11 +5492,9 @@ client4_0_setactivelk(call_frame_t *frame, xlator_t *this, void *data) ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_SETACTIVELK, client4_0_setactivelk_cbk, - NULL, NULL, 0, NULL, 0, NULL, - (xdrproc_t)xdr_gfx_setactivelk_req); + NULL, (xdrproc_t)xdr_gfx_setactivelk_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } clnt_setactivelk_req_cleanup_v2(&req); @@ -5496,8 +5538,8 @@ client4_rchecksum_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_rchecksum_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -5506,8 +5548,8 @@ client4_rchecksum_cbk(struct rpc_req *req, struct iovec *iov, int count, xdr_to_dict(&rsp.xdata, &xdata); out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(rchecksum, frame, rsp.op_ret, @@ -5657,8 +5699,8 @@ client4_0_put_cbk(struct rpc_req *req, struct iovec *iov, int count, ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_common_3iatt_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); rsp.op_ret = -1; rsp.op_errno = EINVAL; goto out; @@ -5672,8 +5714,8 @@ client4_0_put_cbk(struct rpc_req *req, struct iovec *iov, int count, } out: if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); + gf_smsg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), + PC_MSG_REMOTE_OP_FAILED, NULL); } CLIENT_STACK_UNWIND(put, frame, rsp.op_ret, gf_error_to_errno(rsp.op_errno), @@ -5719,11 +5761,10 @@ client4_0_namelink(call_frame_t *frame, xlator_t *this, void *data) dict_to_xdr(args->xdata, &req.xdata); ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_NAMELINK, - client4_namelink_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_namelink_req); + client4_namelink_cbk, NULL, + (xdrproc_t)xdr_gfx_namelink_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); @@ -5771,8 +5812,8 @@ client4_0_icreate(call_frame_t *frame, xlator_t *this, void *data) op_errno = ESTALE; dict_to_xdr(args->xdata, &req.xdata); ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_ICREATE, - client4_icreate_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_icreate_req); + client4_icreate_cbk, NULL, + (xdrproc_t)xdr_gfx_icreate_req); if (ret) goto free_reqdata; GF_FREE(req.xdata.pairs.pairs_val); @@ -5798,6 +5839,7 @@ client4_0_put(call_frame_t *frame, xlator_t *this, void *data) int op_errno = ESTALE; int ret = 0; clnt_local_t *local = NULL; + client_payload_t cp; if (!frame || !this || !data) goto unwind; @@ -5824,9 +5866,13 @@ client4_0_put(call_frame_t *frame, xlator_t *this, void *data) goto unwind; } + memset(&cp, 0, sizeof(client_payload_t)); + + cp.iobref = args->iobref; + cp.payload = args->vector; + cp.payload_cnt = args->count; ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_PUT, - client4_0_put_cbk, args->iobref, args->vector, - args->count, NULL, 0, NULL, + client4_0_put_cbk, &cp, (xdrproc_t)xdr_gfx_put_req); if (ret) { /* @@ -5834,8 +5880,7 @@ client4_0_put(call_frame_t *frame, xlator_t *this, void *data) * do the unwind for us (see rpc_clnt_submit), so don't unwind * here in such cases. */ - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } return 0; @@ -5846,12 +5891,15 @@ unwind: } int32_t -client4_0_fsetattr(call_frame_t *frame, xlator_t *this, void *data) +client4_0_copy_file_range(call_frame_t *frame, xlator_t *this, void *data) { clnt_args_t *args = NULL; clnt_conf_t *conf = NULL; - gfx_fsetattr_req req = { - {0}, + clnt_local_t *local = NULL; + gfx_copy_file_range_req req = { + { + 0, + }, }; int op_errno = ESTALE; int ret = 0; @@ -5862,37 +5910,65 @@ client4_0_fsetattr(call_frame_t *frame, xlator_t *this, void *data) args = data; conf = this->private; - ret = client_pre_fsetattr_v2(this, &req, args->fd, args->valid, args->stbuf, - args->xdata); + ret = client_pre_copy_file_range_v2(this, &req, args->fd, args->off_in, + args->fd_out, args->off_out, args->size, + args->flags, &args->xdata); + if (ret) { op_errno = -ret; goto unwind; } - ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_FSETATTR, - client4_0_fsetattr_cbk, NULL, NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfx_fsetattr_req); + + ret = client_fd_fop_prepare_local(frame, args->fd, req.fd_in); + if (ret) { + op_errno = -ret; + goto unwind; + } + + /* + * Since frame->local is allocated in above function call + * itself, better to use it (with the assumption that it + * has been allocated) directly instead of again calling + * client_fd_fop_prepare_local or modifying it, as doing + * so requires changes in other places as well. + */ + + local = frame->local; + local->fd_out = fd_ref(args->fd_out); + local->attempt_reopen_out = client_is_reopen_needed(args->fd_out, this, + req.fd_out); + + ret = client_submit_request(this, &req, frame, conf->fops, + GFS3_OP_COPY_FILE_RANGE, + client4_0_copy_file_range_cbk, NULL, + (xdrproc_t)xdr_gfx_copy_file_range_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + /* + * If the lower layers fail to submit a request, they'll also + * do the unwind for us (see rpc_clnt_submit), so don't unwind + * here in such cases. + */ + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); return 0; + unwind: - CLIENT_STACK_UNWIND(fsetattr, frame, -1, op_errno, NULL, NULL, NULL); + CLIENT_STACK_UNWIND(copy_file_range, frame, -1, op_errno, NULL, NULL, NULL, + NULL); GF_FREE(req.xdata.pairs.pairs_val); return 0; } int32_t -client4_0_rchecksum(call_frame_t *frame, xlator_t *this, void *data) +client4_0_fsetattr(call_frame_t *frame, xlator_t *this, void *data) { clnt_args_t *args = NULL; - int64_t remote_fd = -1; clnt_conf_t *conf = NULL; - gfx_rchecksum_req req = { + gfx_fsetattr_req req = { {0}, }; int op_errno = ESTALE; @@ -5904,240 +5980,71 @@ client4_0_rchecksum(call_frame_t *frame, xlator_t *this, void *data) args = data; conf = this->private; - CLIENT_GET_REMOTE_FD(this, args->fd, DEFAULT_REMOTE_FD, remote_fd, op_errno, - unwind); - - req.len = args->len; - req.offset = args->offset; - req.fd = remote_fd; - memcpy(req.gfid, args->fd->inode->gfid, 16); - - dict_to_xdr(args->xdata, &req.xdata); - - ret = client_submit_request( - this, &req, frame, conf->fops, GFS3_OP_RCHECKSUM, client4_rchecksum_cbk, - NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfx_rchecksum_req); + ret = client_pre_fsetattr_v2(this, &req, args->fd, args->valid, args->stbuf, + args->xdata); + if (ret) { + op_errno = -ret; + goto unwind; + } + ret = client_submit_request(this, &req, frame, conf->fops, GFS3_OP_FSETATTR, + client4_0_fsetattr_cbk, NULL, + (xdrproc_t)xdr_gfx_fsetattr_req); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, - "failed to send the fop"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } GF_FREE(req.xdata.pairs.pairs_val); return 0; unwind: - CLIENT_STACK_UNWIND(rchecksum, frame, -1, op_errno, 0, NULL, NULL); + CLIENT_STACK_UNWIND(fsetattr, frame, -1, op_errno, NULL, NULL, NULL); GF_FREE(req.xdata.pairs.pairs_val); return 0; } -int -client4_0_compound_cbk(struct rpc_req *req, struct iovec *iov, int count, - void *myframe) -{ - gfx_compound_rsp rsp = { - 0, - }; - compound_args_cbk_t *args_cbk = NULL; - call_frame_t *frame = NULL; - xlator_t *this = NULL; - dict_t *xdata = NULL; - clnt_local_t *local = NULL; - int i = 0; - int length = 0; - int ret = -1; - - this = THIS; - - frame = myframe; - local = frame->local; - - if (-1 == req->rpc_status) { - rsp.op_ret = -1; - rsp.op_errno = ENOTCONN; - goto out; - } - - ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gfx_compound_rsp); - if (ret < 0) { - gf_msg(this->name, GF_LOG_ERROR, EINVAL, PC_MSG_XDR_DECODING_FAILED, - "XDR decoding failed"); - rsp.op_ret = -1; - rsp.op_errno = EINVAL; - goto out; - } - - length = local->length; - - xdr_to_dict(&rsp.xdata, &xdata); - - args_cbk = compound_args_cbk_alloc(length, xdata); - if (!args_cbk) { - rsp.op_ret = -1; - rsp.op_errno = ENOMEM; - goto out; - } - - /* TODO: see https://bugzilla.redhat.com/show_bug.cgi?id=1376328 */ - for (i = 0; i < args_cbk->fop_length; i++) { - ret = client_process_response_v2(frame, this, req, &rsp, args_cbk, i); - if (ret) { - rsp.op_ret = -1; - rsp.op_errno = -ret; - goto out; - } - } - rsp.op_ret = 0; -out: - if (rsp.op_ret == -1) { - gf_msg(this->name, GF_LOG_WARNING, gf_error_to_errno(rsp.op_errno), - PC_MSG_REMOTE_OP_FAILED, "remote operation failed"); - } - CLIENT_STACK_UNWIND(compound, frame, rsp.op_ret, - gf_error_to_errno(rsp.op_errno), args_cbk, xdata); - - client_compound_rsp_cleanup_v2(&rsp, length); - free(rsp.compound_rsp_array.compound_rsp_array_val); - - if (xdata) - dict_unref(xdata); - - compound_args_cbk_cleanup(args_cbk); - return 0; -} - -/* Brief explanation of gfs3_compound_req structure : - * 1) It consists of version of compounding. - * 2) A compound-fop enum, new enum for compound fops - * 3) A 'compound_req_arrray' structure that has - * a) array len - based on the number of fops compounded - * b) compound_req_array_val - pointer to an array of compound_req's - * 4) compound_req - structure that contains: - * a) fop enum of type glusterfs_fop_t - * b) union of structures of xdr requests of all fops. - */ - int32_t -client4_0_compound(call_frame_t *frame, xlator_t *this, void *data) +client4_0_rchecksum(call_frame_t *frame, xlator_t *this, void *data) { + clnt_args_t *args = NULL; + int64_t remote_fd = -1; clnt_conf_t *conf = NULL; - compound_args_t *c_args = data; - gfx_compound_req req = { - 0, - }; - clnt_local_t *local = NULL; - int op_errno = ENOMEM; - int ret = 0; - int i = 0; - int rsp_count = 0; - struct iovec rsp_vector[MAX_IOVEC] = { - {0}, - }; - struct iovec req_vector[MAX_IOVEC] = { - {0}, - }; - struct iovec vector[MAX_IOVEC] = { + gfx_rchecksum_req req = { {0}, }; - struct iovec *rsphdr = NULL; - struct iobref *req_iobref = NULL; - struct iobref *rsp_iobref = NULL; - struct iobref *rsphdr_iobref = NULL; - struct iobuf *rsphdr_iobuf = NULL; - int rsphdr_count = 0; - int req_count = 0; - dict_t *xdata = c_args->xdata; - - GF_ASSERT(frame); + int op_errno = ESTALE; + int ret = 0; - if (!this) + if (!frame || !this || !data) goto unwind; - memset(req_vector, 0, sizeof(req_vector)); - memset(rsp_vector, 0, sizeof(rsp_vector)); - + args = data; conf = this->private; - local = mem_get0(this->local_pool); - if (!local) { - op_errno = ENOMEM; - goto unwind; - } - frame->local = local; - - local->length = c_args->fop_length; - local->compound_args = c_args; - - rsphdr_iobref = iobref_new(); - if (rsphdr_iobref == NULL) { - goto unwind; - } - - /* TODO: what is the size we should send ? */ - rsphdr_iobuf = iobuf_get(this->ctx->iobuf_pool); - if (rsphdr_iobuf == NULL) { - goto unwind; - } - - rsphdr = &vector[0]; - rsphdr->iov_base = iobuf_ptr(rsphdr_iobuf); - rsphdr->iov_len = iobuf_pagesize(rsphdr_iobuf); - rsphdr_count = 1; - iobref_add(rsphdr_iobref, rsphdr_iobuf); - iobuf_unref(rsphdr_iobuf); - rsphdr_iobuf = NULL; - - req.compound_fop_enum = c_args->fop_enum; - req.compound_req_array.compound_req_array_len = c_args->fop_length; - req.compound_version = 0; - dict_to_xdr(xdata, &req.xdata); + CLIENT_GET_REMOTE_FD(this, args->fd, DEFAULT_REMOTE_FD, remote_fd, op_errno, + unwind); - req.compound_req_array.compound_req_array_val = GF_CALLOC( - local->length, sizeof(compound_req_v2), gf_client_mt_compound_req_t); + req.len = args->len; + req.offset = args->offset; + req.fd = remote_fd; + memcpy(req.gfid, args->fd->inode->gfid, 16); - if (!req.compound_req_array.compound_req_array_val) { - op_errno = ENOMEM; - goto unwind; - } + dict_to_xdr(args->xdata, &req.xdata); - for (i = 0; i < local->length; i++) { - ret = client_handle_fop_requirements_v2( - this, frame, &req, local, &req_iobref, &rsp_iobref, req_vector, - rsp_vector, &req_count, &rsp_count, &c_args->req_list[i], - c_args->enum_list[i], i); - if (ret) { - op_errno = ret; - goto unwind; - } + ret = client_submit_request(this, &req, frame, conf->fops, + GFS3_OP_RCHECKSUM, client4_rchecksum_cbk, NULL, + (xdrproc_t)xdr_gfx_rchecksum_req); + if (ret) { + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FOP_SEND_FAILED, NULL); } - local->iobref = rsp_iobref; - rsp_iobref = NULL; - - ret = client_submit_compound_request( - this, &req, frame, conf->fops, GFS3_OP_COMPOUND, client4_0_compound_cbk, - req_vector, req_count, req_iobref, rsphdr, rsphdr_count, rsp_vector, - rsp_count, local->iobref, (xdrproc_t)xdr_gfx_compound_req); - GF_FREE(req.xdata.pairs.pairs_val); - iobref_unref(rsphdr_iobref); - - compound_request_cleanup_v2(&req); return 0; unwind: - CLIENT_STACK_UNWIND(compound, frame, -1, op_errno, NULL, NULL); - - if (rsp_iobref) - iobref_unref(rsp_iobref); - - if (rsphdr_iobref) - iobref_unref(rsphdr_iobref); - + CLIENT_STACK_UNWIND(rchecksum, frame, -1, op_errno, 0, NULL, NULL); GF_FREE(req.xdata.pairs.pairs_val); - compound_request_cleanup_v2(&req); return 0; } @@ -6254,9 +6161,10 @@ rpc_clnt_procedure_t clnt4_0_fop_actors[GF_FOP_MAXVALUE] = { [GF_FOP_LEASE] = {"LEASE", client4_0_lease}, [GF_FOP_GETACTIVELK] = {"GETACTIVELK", client4_0_getactivelk}, [GF_FOP_SETACTIVELK] = {"SETACTIVELK", client4_0_setactivelk}, - [GF_FOP_COMPOUND] = {"COMPOUND", client4_0_compound}, + [GF_FOP_COMPOUND] = {"COMPOUND", NULL}, [GF_FOP_ICREATE] = {"ICREATE", client4_0_icreate}, [GF_FOP_NAMELINK] = {"NAMELINK", client4_0_namelink}, + [GF_FOP_COPY_FILE_RANGE] = {"COPY-FILE-RANGE", client4_0_copy_file_range}, }; rpc_clnt_prog_t clnt4_0_fop_prog = { diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c index c5bf28dcfb6..0f31fea9511 100644 --- a/xlators/protocol/client/src/client.c +++ b/xlators/protocol/client/src/client.c @@ -9,12 +9,12 @@ */ #include "client.h" -#include "xlator.h" -#include "defaults.h" -#include "glusterfs.h" -#include "statedump.h" -#include "compat-errno.h" -#include "gf-event.h" +#include <glusterfs/xlator.h> +#include <glusterfs/defaults.h> +#include <glusterfs/glusterfs.h> +#include <glusterfs/statedump.h> +#include <glusterfs/compat-errno.h> +#include <glusterfs/gf-event.h> #include "xdr-rpc.h" #include "glusterfs3.h" @@ -26,12 +26,8 @@ extern struct rpcclnt_cb_program gluster_cbk_prog; int client_handshake(xlator_t *this, struct rpc_clnt *rpc); -int -client_init_rpc(xlator_t *this); -int +static int client_destroy_rpc(xlator_t *this); -int -client_mark_fd_bad(xlator_t *this); static void client_filter_o_direct(clnt_conf_t *conf, int32_t *flags) @@ -46,29 +42,87 @@ client_fini_complete(xlator_t *this) GF_VALIDATE_OR_GOTO(this->name, this->private, out); clnt_conf_t *conf = this->private; - if (!conf->destroy) return 0; - this->private = NULL; - - pthread_spin_destroy(&conf->fd_lock); - pthread_mutex_destroy(&conf->lock); - GF_FREE(conf); + pthread_mutex_lock(&conf->lock); + { + conf->fini_completed = _gf_true; + pthread_cond_broadcast(&conf->fini_complete_cond); + } + pthread_mutex_unlock(&conf->lock); out: return 0; } +static int +client_is_last_child_down(xlator_t *this, int32_t event, struct rpc_clnt *rpc) +{ + rpc_clnt_connection_t *conn = NULL; + clnt_conf_t *conf = NULL; + int ret = 0; + + if (!this || !rpc) + goto out; + + conf = this->private; + if (!conf) + goto out; + + if (!conf->parent_down) + goto out; + + if (event != GF_EVENT_CHILD_DOWN) + goto out; + + conn = &rpc->conn; + pthread_mutex_lock(&conn->lock); + { + if (!conn->reconnect && rpc->disabled) { + ret = 1; + } + } + pthread_mutex_unlock(&conn->lock); +out: + return ret; +} + int client_notify_dispatch_uniq(xlator_t *this, int32_t event, void *data, ...) { clnt_conf_t *conf = this->private; + glusterfs_ctx_t *ctx = this->ctx; + glusterfs_graph_t *graph = this->graph; + + pthread_mutex_lock(&ctx->notify_lock); + { + while (ctx->notifying) + pthread_cond_wait(&ctx->notify_cond, &ctx->notify_lock); + + if (client_is_last_child_down(this, event, data) && graph) { + pthread_mutex_lock(&graph->mutex); + { + graph->parent_down++; + if (graph->parent_down == graph_total_client_xlator(graph)) { + graph->used = 0; + pthread_cond_broadcast(&graph->child_down_cond); + } + } + pthread_mutex_unlock(&graph->mutex); + } + } + pthread_mutex_unlock(&ctx->notify_lock); if (conf->last_sent_event == event) return 0; return client_notify_dispatch(this, event, data); + + /* Please avoid any code that access xlator object here + * Because for a child down event, once we do the signal + * we will start cleanup. + */ } int @@ -76,6 +130,7 @@ client_notify_dispatch(xlator_t *this, int32_t event, void *data, ...) { int ret = -1; glusterfs_ctx_t *ctx = this->ctx; + clnt_conf_t *conf = this->private; pthread_mutex_lock(&ctx->notify_lock); @@ -89,6 +144,7 @@ client_notify_dispatch(xlator_t *this, int32_t event, void *data, ...) /* We assume that all translators in the graph handle notification * events in sequence. * */ + ret = default_notify(this, event, data); /* NB (Even) with MT-epoll and EPOLLET|EPOLLONESHOT we are guaranteed @@ -105,36 +161,18 @@ client_notify_dispatch(xlator_t *this, int32_t event, void *data, ...) } pthread_mutex_unlock(&ctx->notify_lock); - return ret; -} - -int32_t -client_type_to_gf_type(short l_type) -{ - int32_t gf_type = GF_LK_EOL; - - switch (l_type) { - case F_RDLCK: - gf_type = GF_LK_F_RDLCK; - break; - case F_WRLCK: - gf_type = GF_LK_F_WRLCK; - break; - case F_UNLCK: - gf_type = GF_LK_F_UNLCK; - break; - } + /* Please avoid any code that access xlator object here + * Because for a child down event, once we do the signal + * we will start cleanup. + */ - return gf_type; + return ret; } int client_submit_request(xlator_t *this, void *req, call_frame_t *frame, rpc_clnt_prog_t *prog, int procnum, fop_cbk_fn_t cbkfn, - struct iobref *iobref, struct iovec *payload, - int payloadcnt, struct iovec *rsp_payload, - int rsp_payload_count, struct iobref *rsp_iobref, - xdrproc_t xdrproc) + client_payload_t *cp, xdrproc_t xdrproc) { int ret = -1; clnt_conf_t *conf = NULL; @@ -180,21 +218,18 @@ client_submit_request(xlator_t *this, void *req, call_frame_t *frame, goto out; } - if (iobref != NULL) { - ret = iobref_merge(new_iobref, iobref); + if (cp && cp->iobref != NULL) { + ret = iobref_merge(new_iobref, cp->iobref); if (ret != 0) { - gf_msg(this->name, GF_LOG_WARNING, ENOMEM, PC_MSG_NO_MEMORY, - "cannot merge " - "iobref passed from caller into " - "new_iobref"); + gf_smsg(this->name, GF_LOG_WARNING, ENOMEM, + PC_MSG_MERGE_IOBREF_FAILED, NULL); } } ret = iobref_add(new_iobref, iobuf); if (ret != 0) { - gf_msg(this->name, GF_LOG_WARNING, ENOMEM, PC_MSG_NO_MEMORY, - "cannot add iobuf into " - "iobref"); + gf_smsg(this->name, GF_LOG_WARNING, ENOMEM, PC_MSG_ADD_IOBUF_FAILED, + NULL); goto out; } @@ -224,130 +259,17 @@ client_submit_request(xlator_t *this, void *req, call_frame_t *frame, } /* Send the msg */ - ret = rpc_clnt_submit(conf->rpc, prog, procnum, cbkfn, &iov, count, payload, - payloadcnt, new_iobref, frame, payload, payloadcnt, - rsp_payload, rsp_payload_count, rsp_iobref); - - if (ret < 0) { - gf_msg_debug(this->name, 0, "rpc_clnt_submit failed"); - } - - ret = 0; - - if (new_iobref) - iobref_unref(new_iobref); - - if (iobuf) - iobuf_unref(iobuf); - - return ret; - -out: - rpcreq.rpc_status = -1; - - cbkfn(&rpcreq, NULL, 0, frame); - - if (new_iobref) - iobref_unref(new_iobref); - - if (iobuf) - iobuf_unref(iobuf); - - return ret; -} - -int -client_submit_compound_request(xlator_t *this, void *req, call_frame_t *frame, - rpc_clnt_prog_t *prog, int procnum, - fop_cbk_fn_t cbkfn, struct iovec *req_payload, - int req_count, struct iobref *iobref, - struct iovec *rsphdr, int rsphdr_count, - struct iovec *rsp_payload, int rsp_payload_count, - struct iobref *rsp_iobref, xdrproc_t xdrproc) -{ - int ret = -1; - clnt_conf_t *conf = NULL; - struct iovec iov = { - 0, - }; - struct iobuf *iobuf = NULL; - int count = 0; - struct iobref *new_iobref = NULL; - ssize_t xdr_size = 0; - struct rpc_req rpcreq = { - 0, - }; - - GF_VALIDATE_OR_GOTO("client", this, out); - GF_VALIDATE_OR_GOTO(this->name, prog, out); - GF_VALIDATE_OR_GOTO(this->name, frame, out); - - conf = this->private; - - /* If 'setvolume' is not successful, we should not send frames to - * server - */ - - if (!conf->connected) { - gf_msg_debug(this->name, 0, "connection in disconnected state"); - goto out; + if (cp) { + ret = rpc_clnt_submit(conf->rpc, prog, procnum, cbkfn, &iov, count, + cp->payload, cp->payload_cnt, new_iobref, frame, + cp->rsphdr, cp->rsphdr_cnt, cp->rsp_payload, + cp->rsp_payload_cnt, cp->rsp_iobref); + } else { + ret = rpc_clnt_submit(conf->rpc, prog, procnum, cbkfn, &iov, count, + NULL, 0, new_iobref, frame, NULL, 0, NULL, 0, + NULL); } - if (req && xdrproc) { - xdr_size = xdr_sizeof(xdrproc, req); - iobuf = iobuf_get2(this->ctx->iobuf_pool, xdr_size); - if (!iobuf) { - goto out; - }; - - new_iobref = iobref_new(); - if (!new_iobref) { - goto out; - } - - if (iobref != NULL) { - ret = iobref_merge(new_iobref, iobref); - if (ret != 0) { - goto out; - } - } - - ret = iobref_add(new_iobref, iobuf); - if (ret != 0) { - goto out; - } - - iov.iov_base = iobuf->ptr; - iov.iov_len = iobuf_size(iobuf); - - /* Create the xdr payload */ - ret = xdr_serialize_generic(iov, req, xdrproc); - if (ret == -1) { - /* callingfn so that, we can get to know which xdr - function was called */ - gf_log_callingfn(this->name, GF_LOG_WARNING, - "XDR payload creation failed"); - goto out; - } - iov.iov_len = ret; - count = 1; - } - - /* do not send all groups if they are resolved server-side */ - if (!conf->send_gids) { - if (frame->root->ngrps <= SMALL_GROUP_COUNT) { - frame->root->groups_small[0] = frame->root->gid; - frame->root->groups = frame->root->groups_small; - } - frame->root->ngrps = 1; - } - - /* Send the msg */ - ret = rpc_clnt_submit(conf->rpc, prog, procnum, cbkfn, &iov, count, - req_payload, req_count, new_iobref, frame, rsphdr, - rsphdr_count, rsp_payload, rsp_payload_count, - rsp_iobref); - if (ret < 0) { gf_msg_debug(this->name, 0, "rpc_clnt_submit failed"); } @@ -373,17 +295,17 @@ out: if (iobuf) iobuf_unref(iobuf); - return 0; + return ret; } -int32_t +static int32_t client_forget(xlator_t *this, inode_t *inode) { /* Nothing here */ return 0; } -int32_t +static int32_t client_releasedir(xlator_t *this, fd_t *fd) { int ret = -1; @@ -397,20 +319,19 @@ client_releasedir(xlator_t *this, fd_t *fd) if (!conf || !conf->fops) goto out; - args.fd = fd; - proc = &conf->fops->proctable[GF_FOP_RELEASEDIR]; if (proc->fn) { + args.fd = fd; ret = proc->fn(NULL, this, &args); } out: if (ret) - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_DIR_OP_FAILED, - "releasedir fop failed"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_RELEASE_DIR_OP_FAILED, + NULL); return 0; } -int32_t +static int32_t client_release(xlator_t *this, fd_t *fd) { int ret = -1; @@ -424,19 +345,18 @@ client_release(xlator_t *this, fd_t *fd) if (!conf || !conf->fops) goto out; - args.fd = fd; proc = &conf->fops->proctable[GF_FOP_RELEASE]; if (proc->fn) { + args.fd = fd; ret = proc->fn(NULL, this, &args); } out: if (ret) - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_FILE_OP_FAILED, - "release fop failed"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_FILE_OP_FAILED, NULL); return 0; } -int32_t +static int32_t client_lookup(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) { int ret = -1; @@ -450,12 +370,12 @@ client_lookup(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) if (!conf || !conf->fops) goto out; - args.loc = loc; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_LOOKUP]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: /* think of avoiding a missing frame */ if (ret) @@ -465,7 +385,7 @@ out: return 0; } -int32_t +static int32_t client_stat(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) { int ret = -1; @@ -479,12 +399,12 @@ client_stat(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) if (!conf || !conf->fops) goto out; - args.loc = loc; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_STAT]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(stat, frame, -1, ENOTCONN, NULL, NULL); @@ -492,7 +412,7 @@ out: return 0; } -int32_t +static int32_t client_truncate(call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset, dict_t *xdata) { @@ -507,13 +427,13 @@ client_truncate(call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.offset = offset; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_TRUNCATE]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.offset = offset; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(truncate, frame, -1, ENOTCONN, NULL, NULL, NULL); @@ -521,7 +441,7 @@ out: return 0; } -int32_t +static int32_t client_ftruncate(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, dict_t *xdata) { @@ -536,13 +456,13 @@ client_ftruncate(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.offset = offset; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_FTRUNCATE]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.offset = offset; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(ftruncate, frame, -1, ENOTCONN, NULL, NULL, NULL); @@ -550,7 +470,7 @@ out: return 0; } -int32_t +static int32_t client_access(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t mask, dict_t *xdata) { @@ -565,13 +485,13 @@ client_access(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t mask, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.mask = mask; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_ACCESS]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.mask = mask; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(access, frame, -1, ENOTCONN, NULL); @@ -579,7 +499,7 @@ out: return 0; } -int32_t +static int32_t client_readlink(call_frame_t *frame, xlator_t *this, loc_t *loc, size_t size, dict_t *xdata) { @@ -594,13 +514,13 @@ client_readlink(call_frame_t *frame, xlator_t *this, loc_t *loc, size_t size, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.size = size; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_READLINK]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.size = size; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(readlink, frame, -1, ENOTCONN, NULL, NULL, NULL); @@ -608,7 +528,7 @@ out: return 0; } -int +static int client_mknod(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, dev_t rdev, mode_t umask, dict_t *xdata) { @@ -623,15 +543,15 @@ client_mknod(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.mode = mode; - args.rdev = rdev; - args.umask = umask; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_MKNOD]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.mode = mode; + args.rdev = rdev; + args.umask = umask; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(mknod, frame, -1, ENOTCONN, NULL, NULL, NULL, NULL, @@ -640,7 +560,7 @@ out: return 0; } -int +static int client_mkdir(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, mode_t umask, dict_t *xdata) { @@ -655,14 +575,14 @@ client_mkdir(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.mode = mode; - args.umask = umask; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_MKDIR]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.mode = mode; + args.umask = umask; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(mkdir, frame, -1, ENOTCONN, NULL, NULL, NULL, NULL, @@ -671,7 +591,7 @@ out: return 0; } -int32_t +static int32_t client_unlink(call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag, dict_t *xdata) { @@ -686,13 +606,13 @@ client_unlink(call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.xdata = xdata; - args.flags = xflag; - proc = &conf->fops->proctable[GF_FOP_UNLINK]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.xdata = xdata; + args.flags = xflag; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(unlink, frame, -1, ENOTCONN, NULL, NULL, NULL); @@ -700,7 +620,7 @@ out: return 0; } -int32_t +static int32_t client_rmdir(call_frame_t *frame, xlator_t *this, loc_t *loc, int flags, dict_t *xdata) { @@ -715,13 +635,13 @@ client_rmdir(call_frame_t *frame, xlator_t *this, loc_t *loc, int flags, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.flags = flags; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_RMDIR]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.flags = flags; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: /* think of avoiding a missing frame */ if (ret) @@ -730,7 +650,7 @@ out: return 0; } -int +static int client_symlink(call_frame_t *frame, xlator_t *this, const char *linkpath, loc_t *loc, mode_t umask, dict_t *xdata) { @@ -745,14 +665,14 @@ client_symlink(call_frame_t *frame, xlator_t *this, const char *linkpath, if (!conf || !conf->fops) goto out; - args.linkname = linkpath; - args.loc = loc; - args.umask = umask; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_SYMLINK]; - if (proc->fn) + if (proc->fn) { + args.linkname = linkpath; + args.loc = loc; + args.umask = umask; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(symlink, frame, -1, ENOTCONN, NULL, NULL, NULL, @@ -761,7 +681,7 @@ out: return 0; } -int32_t +static int32_t client_rename(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, dict_t *xdata) { @@ -776,13 +696,13 @@ client_rename(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, if (!conf || !conf->fops) goto out; - args.oldloc = oldloc; - args.newloc = newloc; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_RENAME]; - if (proc->fn) + if (proc->fn) { + args.oldloc = oldloc; + args.newloc = newloc; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(rename, frame, -1, ENOTCONN, NULL, NULL, NULL, NULL, @@ -791,7 +711,7 @@ out: return 0; } -int32_t +static int32_t client_link(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, dict_t *xdata) { @@ -806,13 +726,13 @@ client_link(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, if (!conf || !conf->fops) goto out; - args.oldloc = oldloc; - args.newloc = newloc; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_LINK]; - if (proc->fn) + if (proc->fn) { + args.oldloc = oldloc; + args.newloc = newloc; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(link, frame, -1, ENOTCONN, NULL, NULL, NULL, NULL, @@ -821,7 +741,7 @@ out: return 0; } -int32_t +static int32_t client_create(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, mode_t mode, mode_t umask, fd_t *fd, dict_t *xdata) { @@ -836,18 +756,17 @@ client_create(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.mode = mode; - args.fd = fd; - args.umask = umask; - args.xdata = xdata; - args.flags = flags; - - client_filter_o_direct(conf, &args.flags); - proc = &conf->fops->proctable[GF_FOP_CREATE]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.mode = mode; + args.fd = fd; + args.umask = umask; + args.xdata = xdata; + args.flags = flags; + client_filter_o_direct(conf, &args.flags); ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(create, frame, -1, ENOTCONN, NULL, NULL, NULL, NULL, @@ -856,7 +775,7 @@ out: return 0; } -int32_t +static int32_t client_open(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, fd_t *fd, dict_t *xdata) { @@ -871,17 +790,15 @@ client_open(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.fd = fd; - args.xdata = xdata; - args.flags = flags; - - client_filter_o_direct(conf, &args.flags); - proc = &conf->fops->proctable[GF_FOP_OPEN]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.fd = fd; + args.xdata = xdata; + args.flags = flags; + client_filter_o_direct(conf, &args.flags); ret = proc->fn(frame, this, &args); - + } out: if (ret) STACK_UNWIND_STRICT(open, frame, -1, ENOTCONN, NULL, NULL); @@ -889,7 +806,7 @@ out: return 0; } -int32_t +static int32_t client_readv(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, off_t offset, uint32_t flags, dict_t *xdata) { @@ -904,18 +821,17 @@ client_readv(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.size = size; - args.offset = offset; - args.flags = flags; - args.xdata = xdata; - - client_filter_o_direct(conf, &args.flags); - proc = &conf->fops->proctable[GF_FOP_READ]; - if (proc->fn) - ret = proc->fn(frame, this, &args); + if (proc->fn) { + args.fd = fd; + args.size = size; + args.offset = offset; + args.flags = flags; + args.xdata = xdata; + client_filter_o_direct(conf, &args.flags); + ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(readv, frame, -1, ENOTCONN, NULL, 0, NULL, NULL, @@ -924,7 +840,7 @@ out: return 0; } -int32_t +static int32_t client_writev(call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, int32_t count, off_t off, uint32_t flags, struct iobref *iobref, dict_t *xdata) @@ -940,20 +856,19 @@ client_writev(call_frame_t *frame, xlator_t *this, fd_t *fd, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.vector = vector; - args.count = count; - args.offset = off; - args.size = iov_length(vector, count); - args.flags = flags; - args.iobref = iobref; - args.xdata = xdata; - - client_filter_o_direct(conf, &args.flags); - proc = &conf->fops->proctable[GF_FOP_WRITE]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.vector = vector; + args.count = count; + args.offset = off; + args.size = iov_length(vector, count); + args.flags = flags; + args.iobref = iobref; + args.xdata = xdata; + client_filter_o_direct(conf, &args.flags); ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(writev, frame, -1, ENOTCONN, NULL, NULL, NULL); @@ -961,7 +876,7 @@ out: return 0; } -int32_t +static int32_t client_flush(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata) { int ret = -1; @@ -975,12 +890,12 @@ client_flush(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata) if (!conf || !conf->fops) goto out; - args.fd = fd; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_FLUSH]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(flush, frame, -1, ENOTCONN, NULL); @@ -988,7 +903,7 @@ out: return 0; } -int32_t +static int32_t client_fsync(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags, dict_t *xdata) { @@ -1003,13 +918,13 @@ client_fsync(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.flags = flags; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_FSYNC]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.flags = flags; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(fsync, frame, -1, ENOTCONN, NULL, NULL, NULL); @@ -1017,7 +932,7 @@ out: return 0; } -int32_t +static int32_t client_fstat(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata) { int ret = -1; @@ -1031,12 +946,12 @@ client_fstat(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata) if (!conf || !conf->fops) goto out; - args.fd = fd; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_FSTAT]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(fstat, frame, -1, ENOTCONN, NULL, NULL); @@ -1044,7 +959,7 @@ out: return 0; } -int32_t +static int32_t client_opendir(call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd, dict_t *xdata) { @@ -1059,13 +974,13 @@ client_opendir(call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.fd = fd; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_OPENDIR]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.fd = fd; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(opendir, frame, -1, ENOTCONN, NULL, NULL); @@ -1088,13 +1003,13 @@ client_fsyncdir(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.flags = flags; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_FSYNCDIR]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.flags = flags; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(fsyncdir, frame, -1, ENOTCONN, NULL); @@ -1102,7 +1017,7 @@ out: return 0; } -int32_t +static int32_t client_statfs(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) { int ret = -1; @@ -1116,12 +1031,12 @@ client_statfs(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) if (!conf || !conf->fops) goto out; - args.loc = loc; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_STATFS]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(statfs, frame, -1, ENOTCONN, NULL, NULL); @@ -1129,13 +1044,47 @@ out: return 0; } +static int32_t +client_copy_file_range(call_frame_t *frame, xlator_t *this, fd_t *fd_in, + off_t off_in, fd_t *fd_out, off_t off_out, size_t len, + uint32_t flags, dict_t *xdata) +{ + int ret = -1; + clnt_conf_t *conf = NULL; + rpc_clnt_procedure_t *proc = NULL; + clnt_args_t args = { + 0, + }; + + conf = this->private; + if (!conf || !conf->fops) + goto out; + + proc = &conf->fops->proctable[GF_FOP_COPY_FILE_RANGE]; + if (proc->fn) { + args.fd = fd_in; + args.fd_out = fd_out; + args.offset = off_in; + args.off_out = off_out; + args.size = len; + args.flags = flags; + args.xdata = xdata; + ret = proc->fn(frame, this, &args); + } +out: + if (ret) + STACK_UNWIND_STRICT(copy_file_range, frame, -1, ENOTCONN, NULL, NULL, + NULL, NULL); + + return 0; +} + static gf_boolean_t is_client_rpc_init_command(dict_t *dict, xlator_t *this, char **value) { gf_boolean_t ret = _gf_false; - int dict_ret = -1; - dict_ret = dict_get_str(dict, CLIENT_CMD_CONNECT, value); + int dict_ret = dict_get_str_sizen(dict, CLIENT_CMD_CONNECT, value); if (dict_ret) { gf_msg_trace(this->name, 0, "key %s not present", CLIENT_CMD_CONNECT); goto out; @@ -1159,7 +1108,7 @@ is_client_rpc_destroy_command(dict_t *dict, xlator_t *this) goto out; } - dict_ret = dict_get_str(dict, CLIENT_CMD_DISCONNECT, &dummy); + dict_ret = dict_get_str_sizen(dict, CLIENT_CMD_DISCONNECT, &dummy); if (dict_ret) { gf_msg_trace(this->name, 0, "key %s not present", CLIENT_CMD_DISCONNECT); @@ -1183,9 +1132,12 @@ client_set_remote_options(char *value, xlator_t *this) char *remote_port_str = NULL; char *tmp = NULL; int remote_port = 0; - int ret = 0; + int ret = -1; dup_value = gf_strdup(value); + if (dup_value == NULL) { + goto out; + } host = strtok_r(dup_value, ":", &tmp); subvol = strtok_r(NULL, ":", &tmp); remote_port_str = strtok_r(NULL, ":", &tmp); @@ -1195,10 +1147,11 @@ client_set_remote_options(char *value, xlator_t *this) if (!host_dup) { goto out; } - ret = dict_set_dynstr(this->options, "remote-host", host_dup); + ret = dict_set_dynstr_sizen(this->options, "remote-host", host_dup); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_DICT_SET_FAILED, - "failed to set remote-host with %s", host); + gf_smsg(this->name, GF_LOG_WARNING, 0, + PC_MSG_REMOTE_HOST_SET_FAILED, "host=%s", host, NULL); + GF_FREE(host_dup); goto out; } } @@ -1209,10 +1162,12 @@ client_set_remote_options(char *value, xlator_t *this) goto out; } - ret = dict_set_dynstr(this->options, "remote-subvolume", subvol_dup); + ret = dict_set_dynstr_sizen(this->options, "remote-subvolume", + subvol_dup); if (ret) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_DICT_SET_FAILED, - "failed to set remote-host with %s", host); + gf_smsg(this->name, GF_LOG_WARNING, 0, + PC_MSG_REMOTE_HOST_SET_FAILED, "host=%s", host, NULL); + GF_FREE(subvol_dup); goto out; } } @@ -1220,10 +1175,10 @@ client_set_remote_options(char *value, xlator_t *this) if (remote_port_str) { remote_port = atoi(remote_port_str); - ret = dict_set_int32(this->options, "remote-port", remote_port); + ret = dict_set_int32_sizen(this->options, "remote-port", remote_port); if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, PC_MSG_DICT_SET_FAILED, - "failed to set remote-port to %d", remote_port); + gf_smsg(this->name, GF_LOG_ERROR, 0, PC_MSG_REMOTE_PORT_SET_FAILED, + "remote-port=%d", remote_port, NULL); goto out; } } @@ -1235,7 +1190,7 @@ out: return ret; } -int32_t +static int32_t client_setxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict, int32_t flags, dict_t *xdata) { @@ -1252,8 +1207,7 @@ client_setxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict, if (is_client_rpc_init_command(dict, this, &value) == _gf_true) { GF_ASSERT(value); - gf_msg(this->name, GF_LOG_INFO, 0, PC_MSG_RPC_INIT, - "client rpc init command"); + gf_smsg(this->name, GF_LOG_INFO, 0, PC_MSG_RPC_INIT, NULL); ret = client_set_remote_options(value, this); if (!ret) { op_ret = 0; @@ -1264,8 +1218,7 @@ client_setxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict, } if (is_client_rpc_destroy_command(dict, this) == _gf_true) { - gf_msg(this->name, GF_LOG_INFO, 0, PC_MSG_RPC_DESTROY, - "client rpc destroy command"); + gf_smsg(this->name, GF_LOG_INFO, 0, PC_MSG_RPC_DESTROY, NULL); ret = client_destroy_rpc(this); if (ret) { op_ret = 0; @@ -1282,13 +1235,12 @@ client_setxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict, goto out; } - args.loc = loc; - args.xattr = dict; - args.flags = flags; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_SETXATTR]; if (proc->fn) { + args.loc = loc; + args.xattr = dict; + args.flags = flags; + args.xdata = xdata; ret = proc->fn(frame, this, &args); if (ret) { need_unwind = 1; @@ -1301,7 +1253,7 @@ out: return 0; } -int32_t +static int32_t client_fsetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *dict, int32_t flags, dict_t *xdata) { @@ -1316,14 +1268,14 @@ client_fsetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *dict, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.xattr = dict; - args.flags = flags; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_FSETXATTR]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.xattr = dict; + args.flags = flags; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(fsetxattr, frame, -1, ENOTCONN, NULL); @@ -1331,7 +1283,7 @@ out: return 0; } -int32_t +static int32_t client_fgetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd, const char *name, dict_t *xdata) { @@ -1346,13 +1298,13 @@ client_fgetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.name = name; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_FGETXATTR]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.name = name; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(fgetxattr, frame, -1, ENOTCONN, NULL, NULL); @@ -1360,7 +1312,7 @@ out: return 0; } -int32_t +static int32_t client_getxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, const char *name, dict_t *xdata) { @@ -1375,13 +1327,13 @@ client_getxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, if (!conf || !conf->fops) goto out; - args.name = name; - args.loc = loc; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_GETXATTR]; - if (proc->fn) + if (proc->fn) { + args.name = name; + args.loc = loc; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(getxattr, frame, -1, ENOTCONN, NULL, NULL); @@ -1389,7 +1341,7 @@ out: return 0; } -int32_t +static int32_t client_xattrop(call_frame_t *frame, xlator_t *this, loc_t *loc, gf_xattrop_flags_t flags, dict_t *dict, dict_t *xdata) { @@ -1404,14 +1356,14 @@ client_xattrop(call_frame_t *frame, xlator_t *this, loc_t *loc, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.flags = flags; - args.xattr = dict; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_XATTROP]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.flags = flags; + args.xattr = dict; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(xattrop, frame, -1, ENOTCONN, NULL, NULL); @@ -1419,7 +1371,7 @@ out: return 0; } -int32_t +static int32_t client_fxattrop(call_frame_t *frame, xlator_t *this, fd_t *fd, gf_xattrop_flags_t flags, dict_t *dict, dict_t *xdata) { @@ -1434,14 +1386,14 @@ client_fxattrop(call_frame_t *frame, xlator_t *this, fd_t *fd, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.flags = flags; - args.xattr = dict; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_FXATTROP]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.flags = flags; + args.xattr = dict; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(fxattrop, frame, -1, ENOTCONN, NULL, NULL); @@ -1449,7 +1401,7 @@ out: return 0; } -int32_t +static int32_t client_removexattr(call_frame_t *frame, xlator_t *this, loc_t *loc, const char *name, dict_t *xdata) { @@ -1464,13 +1416,13 @@ client_removexattr(call_frame_t *frame, xlator_t *this, loc_t *loc, if (!conf || !conf->fops) goto out; - args.name = name; - args.loc = loc; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_REMOVEXATTR]; - if (proc->fn) + if (proc->fn) { + args.name = name; + args.loc = loc; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(removexattr, frame, -1, ENOTCONN, NULL); @@ -1478,7 +1430,7 @@ out: return 0; } -int32_t +static int32_t client_fremovexattr(call_frame_t *frame, xlator_t *this, fd_t *fd, const char *name, dict_t *xdata) { @@ -1493,13 +1445,13 @@ client_fremovexattr(call_frame_t *frame, xlator_t *this, fd_t *fd, if (!conf || !conf->fops) goto out; - args.name = name; - args.fd = fd; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_FREMOVEXATTR]; - if (proc->fn) + if (proc->fn) { + args.name = name; + args.fd = fd; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(fremovexattr, frame, -1, ENOTCONN, NULL); @@ -1507,7 +1459,7 @@ out: return 0; } -int32_t +static int32_t client_lease(call_frame_t *frame, xlator_t *this, loc_t *loc, struct gf_lease *lease, dict_t *xdata) { @@ -1522,13 +1474,13 @@ client_lease(call_frame_t *frame, xlator_t *this, loc_t *loc, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.lease = lease; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_LEASE]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.lease = lease; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(lk, frame, -1, ENOTCONN, NULL, NULL); @@ -1536,7 +1488,7 @@ out: return 0; } -int32_t +static int32_t client_lk(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd, struct gf_flock *lock, dict_t *xdata) { @@ -1551,14 +1503,14 @@ client_lk(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.cmd = cmd; - args.flock = lock; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_LK]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.cmd = cmd; + args.flock = lock; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(lk, frame, -1, ENOTCONN, NULL, NULL); @@ -1566,7 +1518,7 @@ out: return 0; } -int32_t +static int32_t client_inodelk(call_frame_t *frame, xlator_t *this, const char *volume, loc_t *loc, int32_t cmd, struct gf_flock *lock, dict_t *xdata) { @@ -1581,15 +1533,15 @@ client_inodelk(call_frame_t *frame, xlator_t *this, const char *volume, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.cmd = cmd; - args.flock = lock; - args.volume = volume; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_INODELK]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.cmd = cmd; + args.flock = lock; + args.volume = volume; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(inodelk, frame, -1, ENOTCONN, NULL); @@ -1597,7 +1549,7 @@ out: return 0; } -int32_t +static int32_t client_finodelk(call_frame_t *frame, xlator_t *this, const char *volume, fd_t *fd, int32_t cmd, struct gf_flock *lock, dict_t *xdata) { @@ -1612,15 +1564,15 @@ client_finodelk(call_frame_t *frame, xlator_t *this, const char *volume, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.cmd = cmd; - args.flock = lock; - args.volume = volume; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_FINODELK]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.cmd = cmd; + args.flock = lock; + args.volume = volume; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(finodelk, frame, -1, ENOTCONN, NULL); @@ -1628,7 +1580,7 @@ out: return 0; } -int32_t +static int32_t client_entrylk(call_frame_t *frame, xlator_t *this, const char *volume, loc_t *loc, const char *basename, entrylk_cmd cmd, entrylk_type type, dict_t *xdata) @@ -1644,16 +1596,16 @@ client_entrylk(call_frame_t *frame, xlator_t *this, const char *volume, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.basename = basename; - args.type = type; - args.volume = volume; - args.cmd_entrylk = cmd; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_ENTRYLK]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.basename = basename; + args.type = type; + args.volume = volume; + args.cmd_entrylk = cmd; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(entrylk, frame, -1, ENOTCONN, NULL); @@ -1661,7 +1613,7 @@ out: return 0; } -int32_t +static int32_t client_fentrylk(call_frame_t *frame, xlator_t *this, const char *volume, fd_t *fd, const char *basename, entrylk_cmd cmd, entrylk_type type, dict_t *xdata) @@ -1677,16 +1629,16 @@ client_fentrylk(call_frame_t *frame, xlator_t *this, const char *volume, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.basename = basename; - args.type = type; - args.volume = volume; - args.cmd_entrylk = cmd; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_FENTRYLK]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.basename = basename; + args.type = type; + args.volume = volume; + args.cmd_entrylk = cmd; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(fentrylk, frame, -1, ENOTCONN, NULL); @@ -1694,7 +1646,7 @@ out: return 0; } -int32_t +static int32_t client_rchecksum(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, int32_t len, dict_t *xdata) { @@ -1709,14 +1661,14 @@ client_rchecksum(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.offset = offset; - args.len = len; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_RCHECKSUM]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.offset = offset; + args.len = len; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(rchecksum, frame, -1, ENOTCONN, 0, NULL, NULL); @@ -1739,17 +1691,17 @@ client_readdir(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, if (!conf || !conf->fops) goto out; - if (off != 0) - off = gf_dirent_orig_offset(this, off); - - args.fd = fd; - args.size = size; - args.offset = off; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_READDIR]; - if (proc->fn) + if (proc->fn) { + if (off != 0) + off = gf_dirent_orig_offset(this, off); + + args.fd = fd; + args.size = size; + args.offset = off; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(readdir, frame, -1, ENOTCONN, NULL, NULL); @@ -1757,7 +1709,7 @@ out: return 0; } -int32_t +static int32_t client_readdirp(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, off_t off, dict_t *dict) { @@ -1772,17 +1724,17 @@ client_readdirp(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, if (!conf || !conf->fops) goto out; - if (off != 0) - off = gf_dirent_orig_offset(this, off); - - args.fd = fd; - args.size = size; - args.offset = off; - args.xdata = dict; - proc = &conf->fops->proctable[GF_FOP_READDIRP]; - if (proc->fn) + if (proc->fn) { + if (off != 0) + off = gf_dirent_orig_offset(this, off); + + args.fd = fd; + args.size = size; + args.offset = off; + args.xdata = dict; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(readdirp, frame, -1, ENOTCONN, NULL, NULL); @@ -1790,7 +1742,7 @@ out: return 0; } -int32_t +static int32_t client_setattr(call_frame_t *frame, xlator_t *this, loc_t *loc, struct iatt *stbuf, int32_t valid, dict_t *xdata) { @@ -1805,14 +1757,14 @@ client_setattr(call_frame_t *frame, xlator_t *this, loc_t *loc, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.stbuf = stbuf; - args.valid = valid; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_SETATTR]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.stbuf = stbuf; + args.valid = valid; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(setattr, frame, -1, ENOTCONN, NULL, NULL, NULL); @@ -1820,7 +1772,7 @@ out: return 0; } -int32_t +static int32_t client_fsetattr(call_frame_t *frame, xlator_t *this, fd_t *fd, struct iatt *stbuf, int32_t valid, dict_t *xdata) { @@ -1835,14 +1787,14 @@ client_fsetattr(call_frame_t *frame, xlator_t *this, fd_t *fd, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.stbuf = stbuf; - args.valid = valid; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_FSETATTR]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.stbuf = stbuf; + args.valid = valid; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(fsetattr, frame, -1, ENOTCONN, NULL, NULL, NULL); @@ -1850,7 +1802,7 @@ out: return 0; } -int32_t +static int32_t client_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode, off_t offset, size_t len, dict_t *xdata) { @@ -1865,15 +1817,15 @@ client_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.flags = mode; - args.offset = offset; - args.size = len; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_FALLOCATE]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.flags = mode; + args.offset = offset; + args.size = len; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(fallocate, frame, -1, ENOTCONN, NULL, NULL, NULL); @@ -1881,7 +1833,7 @@ out: return 0; } -int32_t +static int32_t client_discard(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, size_t len, dict_t *xdata) { @@ -1896,14 +1848,14 @@ client_discard(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.offset = offset; - args.size = len; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_DISCARD]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.offset = offset; + args.size = len; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(discard, frame, -1, ENOTCONN, NULL, NULL, NULL); @@ -1911,7 +1863,7 @@ out: return 0; } -int32_t +static int32_t client_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, off_t len, dict_t *xdata) { @@ -1926,14 +1878,14 @@ client_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.offset = offset; - args.size = len; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_ZEROFILL]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.offset = offset; + args.size = len; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(zerofill, frame, -1, ENOTCONN, NULL, NULL, NULL); @@ -1941,7 +1893,7 @@ out: return 0; } -int32_t +static int32_t client_ipc(call_frame_t *frame, xlator_t *this, int32_t op, dict_t *xdata) { int ret = -1; @@ -1955,12 +1907,12 @@ client_ipc(call_frame_t *frame, xlator_t *this, int32_t op, dict_t *xdata) if (!conf || !conf->fops) goto out; - args.cmd = op; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_IPC]; - if (proc->fn) + if (proc->fn) { + args.cmd = op; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(ipc, frame, -1, ENOTCONN, NULL); @@ -1968,7 +1920,7 @@ out: return 0; } -int32_t +static int32_t client_seek(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, gf_seek_what_t what, dict_t *xdata) { @@ -1983,14 +1935,14 @@ client_seek(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.offset = offset; - args.what = what; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_SEEK]; - if (proc->fn) + if (proc->fn) { + args.fd = fd; + args.offset = offset; + args.what = what; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(seek, frame, -1, ENOTCONN, 0, NULL); @@ -1998,7 +1950,7 @@ out: return 0; } -int32_t +static int32_t client_getactivelk(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) { @@ -2013,12 +1965,12 @@ client_getactivelk(call_frame_t *frame, xlator_t *this, loc_t *loc, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_GETACTIVELK]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.xdata = xdata; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(getactivelk, frame, -1, ENOTCONN, NULL, NULL); @@ -2026,7 +1978,7 @@ out: return 0; } -int32_t +static int32_t client_setactivelk(call_frame_t *frame, xlator_t *this, loc_t *loc, lock_migration_info_t *locklist, dict_t *xdata) { @@ -2041,13 +1993,13 @@ client_setactivelk(call_frame_t *frame, xlator_t *this, loc_t *loc, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.xdata = xdata; - args.locklist = locklist; - proc = &conf->fops->proctable[GF_FOP_SETACTIVELK]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.xdata = xdata; + args.locklist = locklist; ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(setactivelk, frame, -1, ENOTCONN, NULL); @@ -2055,7 +2007,7 @@ out: return 0; } -int32_t +static int32_t client_getspec(call_frame_t *frame, xlator_t *this, const char *key, int32_t flags) { @@ -2070,12 +2022,11 @@ client_getspec(call_frame_t *frame, xlator_t *this, const char *key, if (!conf || !conf->fops || !conf->handshake) goto out; - args.name = key; - args.flags = flags; - /* For all other xlators, getspec is an fop, hence its in fops table */ proc = &conf->fops->proctable[GF_FOP_GETSPEC]; if (proc->fn) { + args.name = key; + args.flags = flags; /* But at protocol level, this is handshake */ ret = proc->fn(frame, this, &args); } @@ -2086,7 +2037,7 @@ out: return 0; } -int32_t +static int32_t client_compound(call_frame_t *frame, xlator_t *this, void *data, dict_t *xdata) { int ret = -1; @@ -2098,11 +2049,11 @@ client_compound(call_frame_t *frame, xlator_t *this, void *data, dict_t *xdata) if (!conf || !conf->fops) goto out; - args->xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_COMPOUND]; - if (proc->fn) + if (proc->fn) { + args->xdata = xdata; ret = proc->fn(frame, this, args); + } out: if (ret) STACK_UNWIND_STRICT(compound, frame, -1, ENOTCONN, NULL, NULL); @@ -2124,20 +2075,19 @@ client_namelink(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) if (!conf || !conf->fops || !conf->handshake) goto out; - args.loc = loc; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_NAMELINK]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.xdata = xdata; ret = proc->fn(frame, this, &args); - + } out: if (ret) STACK_UNWIND_STRICT(namelink, frame, -1, EINVAL, NULL, NULL, NULL); return 0; } -int32_t +static int32_t client_icreate(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, dict_t *xdata) { @@ -2152,21 +2102,20 @@ client_icreate(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, if (!conf || !conf->fops || !conf->handshake) goto out; - args.loc = loc; - args.mode = mode; - args.xdata = xdata; - proc = &conf->fops->proctable[GF_FOP_ICREATE]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.mode = mode; + args.xdata = xdata; ret = proc->fn(frame, this, &args); - + } out: if (ret) STACK_UNWIND_STRICT(icreate, frame, -1, EINVAL, NULL, NULL, NULL); return 0; } -int32_t +static int32_t client_put(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, mode_t umask, uint32_t flags, struct iovec *vector, int32_t count, off_t off, struct iobref *iobref, dict_t *xattr, dict_t *xdata) @@ -2182,23 +2131,23 @@ client_put(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, if (!conf || !conf->fops) goto out; - args.loc = loc; - args.mode = mode; - args.umask = umask; - args.flags = flags; - args.vector = vector; - args.count = count; - args.offset = off; - args.size = iov_length(vector, count); - args.iobref = iobref; - args.xattr = xattr; - args.xdata = xdata; - - client_filter_o_direct(conf, &args.flags); - proc = &conf->fops->proctable[GF_FOP_PUT]; - if (proc->fn) + if (proc->fn) { + args.loc = loc; + args.mode = mode; + args.umask = umask; + args.flags = flags; + args.vector = vector; + args.count = count; + args.offset = off; + args.size = iov_length(vector, count); + args.iobref = iobref; + args.xattr = xattr; + args.xdata = xdata; + + client_filter_o_direct(conf, &args.flags); ret = proc->fn(frame, this, &args); + } out: if (ret) STACK_UNWIND_STRICT(put, frame, -1, ENOTCONN, NULL, NULL, NULL, NULL, @@ -2207,14 +2156,12 @@ out: return 0; } -int +static void client_mark_fd_bad(xlator_t *this) { - clnt_conf_t *conf = NULL; + clnt_conf_t *conf = this->private; clnt_fd_ctx_t *tmp = NULL, *fdctx = NULL; - conf = this->private; - pthread_spin_lock(&conf->fd_lock); { list_for_each_entry_safe(fdctx, tmp, &conf->saved_fds, sfd_pos) @@ -2223,8 +2170,6 @@ client_mark_fd_bad(xlator_t *this) } } pthread_spin_unlock(&conf->fd_lock); - - return 0; } int @@ -2233,13 +2178,13 @@ client_rpc_notify(struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, { xlator_t *this = NULL; clnt_conf_t *conf = NULL; + gf_boolean_t is_parent_down = _gf_false; int ret = 0; this = mydata; if (!this || !this->private) { - gf_msg("client", GF_LOG_ERROR, EINVAL, PC_MSG_INVALID_ENTRY, - (this != NULL) ? "private structure of the xlator is NULL" - : "xlator is NULL"); + gf_smsg("client", GF_LOG_ERROR, EINVAL, PC_MSG_XLATOR_NULL, + (this != NULL) ? "private structue" : "", NULL); goto out; } @@ -2247,10 +2192,12 @@ client_rpc_notify(struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, switch (event) { case RPC_CLNT_PING: { - ret = default_notify(this, GF_EVENT_CHILD_PING, data); - if (ret) - gf_log(this->name, GF_LOG_INFO, "CHILD_PING notify failed"); - conf->last_sent_event = GF_EVENT_CHILD_PING; + if (conf->connection_to_brick) { + ret = default_notify(this, GF_EVENT_CHILD_PING, data); + if (ret) + gf_log(this->name, GF_LOG_INFO, "CHILD_PING notify failed"); + conf->last_sent_event = GF_EVENT_CHILD_PING; + } break; } case RPC_CLNT_CONNECT: { @@ -2261,10 +2208,8 @@ client_rpc_notify(struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, ret = client_handshake(this, rpc); if (ret) - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_HANDSHAKE_RETURN, - "handshake " - "msg returned %d", - ret); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_HANDSHAKE_RETURN, + "ret=%d", ret, NULL); break; } case RPC_CLNT_DISCONNECT: @@ -2275,13 +2220,9 @@ client_rpc_notify(struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, if (!conf->skip_notify) { if (conf->can_log_disconnect) { if (!conf->disconnect_err_logged) { - gf_msg(this->name, GF_LOG_INFO, 0, - PC_MSG_CLIENT_DISCONNECTED, - "disconnected from %s. Client " - "process will keep trying to " - "connect to glusterd until " - "brick's port is available", - conf->rpc->conn.name); + gf_smsg(this->name, GF_LOG_INFO, 0, + PC_MSG_CLIENT_DISCONNECTED, "conn-name=%s", + conf->rpc->conn.name, NULL); } else { gf_msg_debug(this->name, 0, "disconnected from %s. " @@ -2294,17 +2235,35 @@ client_rpc_notify(struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, if (conf->portmap_err_logged) conf->disconnect_err_logged = 1; } + /* + * Once we complete the child down notification, + * There is a chance that the graph might get freed, + * So it is not safe to access any xlator contens + * So here we are checking whether the parent is down + * or not. + */ + pthread_mutex_lock(&conf->lock); + { + is_parent_down = conf->parent_down; + } + pthread_mutex_unlock(&conf->lock); + /* If the CHILD_DOWN event goes to parent xlator multiple times, the logic of parent xlator notify may get screwed up.. (eg. CHILD_MODIFIED event in replicate), hence make sure events which are passed to parent are genuine */ ret = client_notify_dispatch_uniq(this, GF_EVENT_CHILD_DOWN, - NULL); + rpc); + if (is_parent_down) { + /* If parent is down, then there should not be any + * operation after a child down. + */ + goto out; + } if (ret) - gf_msg(this->name, GF_LOG_INFO, 0, - PC_MSG_CHILD_DOWN_NOTIFY_FAILED, - "CHILD_DOWN notify failed"); + gf_smsg(this->name, GF_LOG_INFO, 0, + PC_MSG_CHILD_DOWN_NOTIFY_FAILED, NULL); } else { if (conf->can_log_disconnect) @@ -2317,11 +2276,13 @@ client_rpc_notify(struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, conf->skip_notify = 0; if (conf->quick_reconnect) { + conf->connection_to_brick = _gf_true; conf->quick_reconnect = 0; rpc_clnt_cleanup_and_start(rpc); } else { rpc->conn.config.remote_port = 0; + conf->connection_to_brick = _gf_false; } break; case RPC_CLNT_DESTROY: @@ -2342,6 +2303,8 @@ int notify(xlator_t *this, int32_t event, void *data, ...) { clnt_conf_t *conf = NULL; + glusterfs_graph_t *graph = this->graph; + int ret = -1; conf = this->private; if (!conf) @@ -2349,18 +2312,14 @@ notify(xlator_t *this, int32_t event, void *data, ...) switch (event) { case GF_EVENT_PARENT_UP: { - gf_msg(this->name, GF_LOG_INFO, 0, PC_MSG_PARENT_UP, - "parent translators are ready, attempting connect " - "on transport"); + gf_smsg(this->name, GF_LOG_INFO, 0, PC_MSG_PARENT_UP, NULL); rpc_clnt_start(conf->rpc); break; } case GF_EVENT_PARENT_DOWN: - gf_msg(this->name, GF_LOG_INFO, 0, PC_MSG_PARENT_DOWN, - "current graph is no longer active, destroying " - "rpc_client "); + gf_smsg(this->name, GF_LOG_INFO, 0, PC_MSG_PARENT_DOWN, NULL); pthread_mutex_lock(&conf->lock); { @@ -2368,7 +2327,19 @@ notify(xlator_t *this, int32_t event, void *data, ...) } pthread_mutex_unlock(&conf->lock); - rpc_clnt_disable(conf->rpc); + ret = rpc_clnt_disable(conf->rpc); + if (ret == -1 && graph) { + pthread_mutex_lock(&graph->mutex); + { + graph->parent_down++; + if (graph->parent_down == + graph_total_client_xlator(graph)) { + graph->used = 0; + pthread_cond_broadcast(&graph->child_down_cond); + } + } + pthread_mutex_unlock(&graph->mutex); + } break; default: @@ -2383,31 +2354,28 @@ notify(xlator_t *this, int32_t event, void *data, ...) return 0; } -int +static int client_check_remote_host(xlator_t *this, dict_t *options) { char *remote_host = NULL; int ret = -1; - ret = dict_get_str(options, "remote-host", &remote_host); + ret = dict_get_str_sizen(options, "remote-host", &remote_host); if (ret < 0) { - gf_msg(this->name, GF_LOG_INFO, EINVAL, PC_MSG_DICT_GET_FAILED, - "Remote host is not set. " - "Assuming the volfile server as remote host"); + gf_smsg(this->name, GF_LOG_INFO, EINVAL, PC_MSG_REMOTE_HOST_NOT_SET, + NULL); if (!this->ctx->cmd_args.volfile_server) { - gf_msg(this->name, GF_LOG_ERROR, EINVAL, PC_MSG_DICT_GET_FAILED, - "No remote host to " - "connect."); + gf_smsg(this->name, GF_LOG_ERROR, EINVAL, PC_MSG_NOREMOTE_HOST, + NULL); goto out; } - ret = dict_set_str(options, "remote-host", - this->ctx->cmd_args.volfile_server); + ret = dict_set_str_sizen(options, "remote-host", + this->ctx->cmd_args.volfile_server); if (ret == -1) { - gf_msg(this->name, GF_LOG_ERROR, 0, PC_MSG_DICT_GET_FAILED, - "Failed to set the " - "remote host"); + gf_smsg(this->name, GF_LOG_ERROR, 0, PC_MSG_REMOTE_HOST_SET_FAILED, + NULL); goto out; } } @@ -2417,14 +2385,11 @@ out: return ret; } -int +static int build_client_config(xlator_t *this, clnt_conf_t *conf) { int ret = -1; - if (!conf) - goto out; - GF_OPTION_INIT("frame-timeout", conf->rpc_conf.rpc_timeout, int32, out); GF_OPTION_INIT("remote-port", conf->rpc_conf.remote_port, int32, out); @@ -2433,13 +2398,16 @@ build_client_config(xlator_t *this, clnt_conf_t *conf) GF_OPTION_INIT("remote-subvolume", conf->opt.remote_subvolume, path, out); if (!conf->opt.remote_subvolume) - gf_msg(this->name, GF_LOG_WARNING, EINVAL, PC_MSG_INVALID_ENTRY, - "option 'remote-subvolume' not given"); + gf_smsg(this->name, GF_LOG_WARNING, EINVAL, + PC_MSG_REMOTE_SUBVOL_NOT_GIVEN, NULL); GF_OPTION_INIT("filter-O_DIRECT", conf->filter_o_direct, bool, out); GF_OPTION_INIT("send-gids", conf->send_gids, bool, out); + GF_OPTION_INIT("testing.old-protocol", conf->old_protocol, bool, out); + GF_OPTION_INIT("strict-locks", conf->strict_locks, bool, out); + conf->client_id = glusterfs_leaf_position(this); ret = client_check_remote_host(this, this->options); @@ -2462,15 +2430,14 @@ mem_acct_init(xlator_t *this) ret = xlator_mem_acct_init(this, gf_client_mt_end + 1); if (ret != 0) { - gf_msg(this->name, GF_LOG_ERROR, ENOMEM, PC_MSG_NO_MEMORY, - "Memory accounting init failed"); + gf_smsg(this->name, GF_LOG_ERROR, ENOMEM, PC_MSG_NO_MEMORY, NULL); return ret; } return ret; } -int +static int client_destroy_rpc(xlator_t *this) { int ret = -1; @@ -2490,15 +2457,13 @@ client_destroy_rpc(xlator_t *this) goto out; } - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_RPC_INVALID_CALL, - "RPC destroy called on already destroyed " - "connection"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_RPC_INVALID_CALL, NULL); out: return ret; } -int +static int client_init_rpc(xlator_t *this) { int ret = -1; @@ -2507,24 +2472,20 @@ client_init_rpc(xlator_t *this) conf = this->private; if (conf->rpc) { - gf_msg(this->name, GF_LOG_WARNING, 0, PC_MSG_RPC_INITED_ALREADY, - "client rpc already " - "init'ed"); + gf_smsg(this->name, GF_LOG_WARNING, 0, PC_MSG_RPC_INITED_ALREADY, NULL); ret = -1; goto out; } conf->rpc = rpc_clnt_new(this->options, this, this->name, 0); if (!conf->rpc) { - gf_msg(this->name, GF_LOG_ERROR, 0, PC_MSG_RPC_INIT_FAILED, - "failed to initialize RPC"); + gf_smsg(this->name, GF_LOG_ERROR, 0, PC_MSG_RPC_INIT_FAILED, NULL); goto out; } ret = rpc_clnt_register_notify(conf->rpc, client_rpc_notify, this); if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, PC_MSG_RPC_NOTIFY_FAILED, - "failed to register notify"); + gf_smsg(this->name, GF_LOG_ERROR, 0, PC_MSG_RPC_NOTIFY_FAILED, NULL); goto out; } @@ -2533,8 +2494,7 @@ client_init_rpc(xlator_t *this) ret = rpcclnt_cbk_program_register(conf->rpc, &gluster_cbk_prog, this); if (ret) { - gf_msg(this->name, GF_LOG_ERROR, 0, PC_MSG_RPC_CBK_FAILED, - "failed to register callback program"); + gf_smsg(this->name, GF_LOG_ERROR, 0, PC_MSG_RPC_CBK_FAILED, NULL); goto out; } @@ -2545,7 +2505,7 @@ out: return ret; } -int +static int client_check_event_threads(xlator_t *this, clnt_conf_t *conf, int32_t old, int32_t new) { @@ -2553,8 +2513,8 @@ client_check_event_threads(xlator_t *this, clnt_conf_t *conf, int32_t old, return 0; conf->event_threads = new; - return event_reconfigure_threads(this->ctx->event_pool, - conf->event_threads); + return gf_event_reconfigure_threads(this->ctx->event_pool, + conf->event_threads); } int @@ -2590,10 +2550,12 @@ reconfigure(xlator_t *this, dict_t *options) if (ret) goto out; - subvol_ret = dict_get_str(this->options, "remote-host", &old_remote_host); + subvol_ret = dict_get_str_sizen(this->options, "remote-host", + &old_remote_host); if (subvol_ret == 0) { - subvol_ret = dict_get_str(options, "remote-host", &new_remote_host); + subvol_ret = dict_get_str_sizen(options, "remote-host", + &new_remote_host); if (subvol_ret == 0) { if (strcmp(old_remote_host, new_remote_host)) { ret = 1; @@ -2602,12 +2564,12 @@ reconfigure(xlator_t *this, dict_t *options) } } - subvol_ret = dict_get_str(this->options, "remote-subvolume", - &old_remote_subvol); + subvol_ret = dict_get_str_sizen(this->options, "remote-subvolume", + &old_remote_subvol); if (subvol_ret == 0) { - subvol_ret = dict_get_str(options, "remote-subvolume", - &new_remote_subvol); + subvol_ret = dict_get_str_sizen(options, "remote-subvolume", + &new_remote_subvol); if (subvol_ret == 0) { if (strcmp(old_remote_subvol, new_remote_subvol)) { ret = 1; @@ -2624,6 +2586,7 @@ reconfigure(xlator_t *this, dict_t *options) out); GF_OPTION_RECONF("send-gids", conf->send_gids, options, bool, out); + GF_OPTION_RECONF("strict-locks", conf->strict_locks, options, bool, out); ret = 0; out: @@ -2637,15 +2600,13 @@ init(xlator_t *this) clnt_conf_t *conf = NULL; if (this->children) { - gf_msg(this->name, GF_LOG_ERROR, EINVAL, PC_MSG_INVALID_ENTRY, - "FATAL: client protocol " - "translator cannot have any subvolumes"); + gf_smsg(this->name, GF_LOG_ERROR, EINVAL, PC_MSG_FATAL_CLIENT_PROTOCOL, + NULL); goto out; } if (!this->parents) { - gf_msg(this->name, GF_LOG_WARNING, EINVAL, PC_MSG_INVALID_ENTRY, - "Volume is dangling. "); + gf_smsg(this->name, GF_LOG_WARNING, EINVAL, PC_MSG_VOL_DANGLING, NULL); } conf = GF_CALLOC(1, sizeof(*conf), gf_client_mt_clnt_conf_t); @@ -2653,6 +2614,7 @@ init(xlator_t *this) goto out; pthread_mutex_init(&conf->lock, NULL); + pthread_cond_init(&conf->fini_complete_cond, NULL); pthread_spin_init(&conf->fd_lock, 0); INIT_LIST_HEAD(&conf->saved_fds); @@ -2689,8 +2651,8 @@ init(xlator_t *this) this->local_pool = mem_pool_new(clnt_local_t, 64); if (!this->local_pool) { ret = -1; - gf_msg(this->name, GF_LOG_ERROR, ENOMEM, PC_MSG_NO_MEMORY, - "failed to create local_t's memory pool"); + gf_smsg(this->name, GF_LOG_ERROR, ENOMEM, PC_MSG_CREATE_MEM_POOL_FAILED, + NULL); goto out; } @@ -2711,6 +2673,7 @@ fini(xlator_t *this) if (!conf) return; + conf->fini_completed = _gf_false; conf->destroy = 1; if (conf->rpc) { /* cleanup the saved-frames before last unref */ @@ -2718,6 +2681,18 @@ fini(xlator_t *this) rpc_clnt_unref(conf->rpc); } + pthread_mutex_lock(&conf->lock); + { + while (!conf->fini_completed) + pthread_cond_wait(&conf->fini_complete_cond, &conf->lock); + } + pthread_mutex_unlock(&conf->lock); + + pthread_spin_destroy(&conf->fd_lock); + pthread_mutex_destroy(&conf->lock); + pthread_cond_destroy(&conf->fini_complete_cond); + GF_FREE(conf); + /* Saved Fds */ /* TODO: */ @@ -2744,13 +2719,14 @@ client_fd_lk_ctx_dump(xlator_t *this, fd_lk_ctx_t *lk_ctx, int nth_fd) if (ret != 0) return; + gf_proc_dump_write("------", "------"); + + lock_no = 0; + ret = TRY_LOCK(&lk_ctx_ref->lock); if (ret) return; - gf_proc_dump_write("------", "------"); - - lock_no = 0; list_for_each_entry(plock, &lk_ctx_ref->lk_list, next) { snprintf(key, sizeof(key), "granted-posix-lock[%d]", lock_no++); @@ -2765,13 +2741,14 @@ client_fd_lk_ctx_dump(xlator_t *this, fd_lk_ctx_t *lk_ctx, int nth_fd) get_lk_type(plock->user_flock.l_type), plock->user_flock.l_start, plock->user_flock.l_len); } + UNLOCK(&lk_ctx_ref->lock); + gf_proc_dump_write("------", "------"); - UNLOCK(&lk_ctx_ref->lock); fd_lk_ctx_unref(lk_ctx_ref); } -int +static int client_priv_dump(xlator_t *this) { clnt_conf_t *conf = NULL; @@ -2789,15 +2766,15 @@ client_priv_dump(xlator_t *this) if (!conf) return -1; - ret = pthread_mutex_trylock(&conf->lock); - if (ret) - return -1; - gf_proc_dump_build_key(key_prefix, "xlator.protocol.client", "%s.priv", this->name); gf_proc_dump_add_section("%s", key_prefix); + ret = pthread_mutex_trylock(&conf->lock); + if (ret) + return -1; + pthread_spin_lock(&conf->fd_lock); list_for_each_entry(tmp, &conf->saved_fds, sfd_pos) { @@ -2898,6 +2875,7 @@ struct xlator_fops fops = { .icreate = client_icreate, .namelink = client_namelink, .put = client_put, + .copy_file_range = client_copy_file_range, }; struct xlator_dumpops dumpops = { @@ -2939,7 +2917,7 @@ struct volume_options options[] = { .type = GF_OPTION_TYPE_TIME, .min = 0, .max = 1013, - .default_value = "42", + .default_value = TOSTRING(GF_NETWORK_TIMEOUT), .description = "Time duration for which the client waits to " "check if the server is responsive.", .op_version = {1}, @@ -2979,5 +2957,41 @@ struct volume_options options[] = { " power. Range 1-32 threads.", .op_version = {GD_OP_VERSION_3_7_0}, .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC}, + + /* This option is required for running code-coverage tests with + old protocol */ + { + .key = {"testing.old-protocol"}, + .type = GF_OPTION_TYPE_BOOL, + .default_value = "off", + .op_version = {GD_OP_VERSION_7_0}, + .flags = OPT_FLAG_SETTABLE, + }, + {.key = {"strict-locks"}, + .type = GF_OPTION_TYPE_BOOL, + .default_value = "off", + .op_version = {GD_OP_VERSION_7_0}, + .flags = OPT_FLAG_SETTABLE, + .description = "When set, doesn't reopen saved fds after reconnect " + "if POSIX locks are held on them. Hence subsequent " + "operations on these fds will fail. This is " + "necessary for stricter lock complaince as bricks " + "cleanup any granted locks when a client " + "disconnects."}, {.key = {NULL}}, }; + +xlator_api_t xlator_api = { + .init = init, + .fini = fini, + .notify = notify, + .reconfigure = reconfigure, + .mem_acct_init = mem_acct_init, + .op_version = {1}, /* Present from the initial version */ + .dumpops = &dumpops, + .fops = &fops, + .cbks = &cbks, + .options = options, + .identifier = "client", + .category = GF_MAINTAINED, +}; diff --git a/xlators/protocol/client/src/client.h b/xlators/protocol/client/src/client.h index c63e3a290d6..ab799c41755 100644 --- a/xlators/protocol/client/src/client.h +++ b/xlators/protocol/client/src/client.h @@ -15,15 +15,15 @@ #include <stdint.h> #include "rpc-clnt.h" -#include "list.h" -#include "inode.h" +#include <glusterfs/list.h> +#include <glusterfs/inode.h> #include "client-mem-types.h" #include "protocol-common.h" #include "glusterfs3.h" #include "glusterfs3-xdr.h" -#include "fd-lk.h" -#include "defaults.h" -#include "default-args.h" +#include <glusterfs/fd-lk.h> +#include <glusterfs/defaults.h> +#include <glusterfs/default-args.h> #include "client-messages.h" /* FIXME: Needs to be defined in a common file */ @@ -36,68 +36,24 @@ typedef enum { FALLBACK_TO_ANON_FD = 1 } clnt_remote_fd_flags_t; -#define CPD_REQ_FIELD(v, f) (v)->compound_req_u.compound_##f##_req -#define CPD_RSP_FIELD(v, f) (v)->compound_rsp_u.compound_##f##_rsp - #define CLIENT_POST_FOP(fop, this_rsp_u, this_args_cbk, params...) \ do { \ gf_common_rsp *_this_rsp = &CPD_RSP_FIELD(this_rsp_u, fop); \ - int _op_ret = 0; \ - int _op_errno = 0; \ \ - _op_ret = _this_rsp->op_ret; \ - _op_errno = gf_error_to_errno(_this_rsp->op_errno); \ + int _op_ret = _this_rsp->op_ret; \ + int _op_errno = gf_error_to_errno(_this_rsp->op_errno); \ args_##fop##_cbk_store(this_args_cbk, _op_ret, _op_errno, params); \ } while (0) #define CLIENT_POST_FOP_TYPE(fop, this_rsp_u, this_args_cbk, params...) \ do { \ gfs3_##fop##_rsp *_this_rsp = &CPD_RSP_FIELD(this_rsp_u, fop); \ - int _op_ret = 0; \ - int _op_errno = 0; \ \ - _op_ret = _this_rsp->op_ret; \ - _op_errno = gf_error_to_errno(_this_rsp->op_errno); \ + int _op_ret = _this_rsp->op_ret; \ + int _op_errno = gf_error_to_errno(_this_rsp->op_errno); \ args_##fop##_cbk_store(this_args_cbk, _op_ret, _op_errno, params); \ } while (0) -#define CLIENT_PRE_FOP(fop, xl, compound_req, op_errno, label, params...) \ - do { \ - gfs3_##fop##_req *_req = (gfs3_##fop##_req *)compound_req; \ - int _ret = 0; \ - \ - _ret = client_pre_##fop(xl, _req, params); \ - if (_ret < 0) { \ - op_errno = -ret; \ - goto label; \ - } \ - } while (0) - -#define CLIENT_COMPOUND_FOP_CLEANUP(curr_req, fop) \ - do { \ - gfs3_##fop##_req *_req = &CPD_REQ_FIELD(curr_req, fop); \ - \ - GF_FREE(_req->xdata.xdata_val); \ - } while (0) - -#define CLIENT_COMMON_RSP_CLEANUP(rsp, fop, i) \ - do { \ - compound_rsp *this_rsp = NULL; \ - this_rsp = &rsp->compound_rsp_array.compound_rsp_array_val[i]; \ - gf_common_rsp *_this_rsp = &CPD_RSP_FIELD(this_rsp, fop); \ - \ - free(_this_rsp->xdata.xdata_val); \ - } while (0) - -#define CLIENT_FOP_RSP_CLEANUP(rsp, fop, i) \ - do { \ - compound_rsp *this_rsp = NULL; \ - this_rsp = &rsp->compound_rsp_array.compound_rsp_array_val[i]; \ - gfs3_##fop##_rsp *_this_rsp = &CPD_RSP_FIELD(this_rsp, fop); \ - \ - free(_this_rsp->xdata.xdata_val); \ - } while (0) - #define CLIENT_GET_REMOTE_FD(xl, fd, flags, remote_fd, op_errno, label) \ do { \ int _ret = 0; \ @@ -107,10 +63,8 @@ typedef enum { goto label; \ } \ if (remote_fd == -1) { \ - gf_msg(xl->name, GF_LOG_WARNING, EBADFD, PC_MSG_BAD_FD, \ - " (%s) " \ - "remote_fd is -1. EBADFD", \ - uuid_utoa(fd->inode->gfid)); \ + gf_smsg(xl->name, GF_LOG_WARNING, EBADFD, PC_MSG_BAD_FD, \ + "gfid=%s", uuid_utoa(fd->inode->gfid), NULL); \ op_errno = EBADFD; \ goto label; \ } \ @@ -126,52 +80,6 @@ typedef enum { client_local_wipe(__local); \ } while (0) -/* compound v2 */ -#define CPD4_REQ_FIELD(v, f) ((v)->compound_req_v2_u.compound_##f##_req) -#define CPD4_RSP_FIELD(v, f) ((v)->compound_rsp_v2_u.compound_##f##_rsp) - -#define CLIENT4_POST_FOP(fop, this_rsp_u, this_args_cbk, params...) \ - do { \ - gfx_common_rsp *_this_rsp = &CPD4_RSP_FIELD(this_rsp_u, fop); \ - int _op_ret = 0; \ - int _op_errno = 0; \ - \ - _op_ret = _this_rsp->op_ret; \ - _op_errno = gf_error_to_errno(_this_rsp->op_errno); \ - args_##fop##_cbk_store(this_args_cbk, _op_ret, _op_errno, params); \ - } while (0) - -#define CLIENT4_POST_FOP_TYPE(fop, rsp_type, this_rsp_u, this_args_cbk, \ - params...) \ - do { \ - gfx_##rsp_type##_rsp *_this_rsp = &CPD4_RSP_FIELD(this_rsp_u, fop); \ - int _op_ret = 0; \ - int _op_errno = 0; \ - \ - _op_ret = _this_rsp->op_ret; \ - _op_errno = gf_error_to_errno(_this_rsp->op_errno); \ - args_##fop##_cbk_store(this_args_cbk, _op_ret, _op_errno, params); \ - } while (0) - -#define CLIENT4_PRE_FOP(fop, xl, compound_req, op_errno, label, params...) \ - do { \ - gfx_##fop##_req *_req = (gfx_##fop##_req *)compound_req; \ - int _ret = 0; \ - \ - _ret = client_pre_##fop##_v2(xl, _req, params); \ - if (_ret < 0) { \ - op_errno = -ret; \ - goto label; \ - } \ - } while (0) - -#define CLIENT4_COMPOUND_FOP_CLEANUP(curr_req, fop) \ - do { \ - gfx_##fop##_req *_req = &CPD4_REQ_FIELD(curr_req, fop); \ - \ - GF_FREE(_req->xdata.pairs.pairs_val); \ - } while (0) - struct clnt_options { char *remote_subvolume; int ping_timeout; @@ -235,6 +143,22 @@ typedef struct clnt_conf { * up, disconnects can be * logged */ + + gf_boolean_t old_protocol; /* used only for old-protocol testing */ + pthread_cond_t fini_complete_cond; /* Used to wait till we finsh the fini + compltely, ie client_fini_complete + to return*/ + gf_boolean_t fini_completed; + gf_boolean_t strict_locks; /* When set, doesn't reopen saved fds after + reconnect if POSIX locks are held on them. + Hence subsequent operations on these fds will + fail. This is necessary for stricter lock + complaince as bricks cleanup any granted + locks when a client disconnects. + */ + + gf_boolean_t connection_to_brick; /*True from attempt to connect to brick + till disconnection to brick*/ } clnt_conf_t; typedef struct _client_fd_ctx { @@ -269,6 +193,7 @@ typedef struct client_local { loc_t loc; loc_t loc2; fd_t *fd; + fd_t *fd_out; /* used in copy_file_range */ clnt_fd_ctx_t *fdctx; uint32_t flags; struct iobref *iobref; @@ -280,16 +205,22 @@ typedef struct client_local { pthread_mutex_t mutex; char *name; gf_boolean_t attempt_reopen; - /* required for compound fops */ - compound_args_t *compound_args; - unsigned int length; /* length of a compound fop */ - unsigned int - read_length; /* defines the last processed length for a compound read */ + /* + * The below boolean variable is used + * only for copy_file_range fop + */ + gf_boolean_t attempt_reopen_out; } clnt_local_t; typedef struct client_args { loc_t *loc; + /* + * This is the source fd for copy_file_range and + * the default fd for any other fd based fop which + * requires only one fd (i.e. opetates on one fd) + */ fd_t *fd; + fd_t *fd_out; /* this is the destination fd for copy_file_range */ const char *linkname; struct iobref *iobref; struct iovec *vector; @@ -301,7 +232,17 @@ typedef struct client_args { struct gf_flock *flock; const char *volume; const char *basename; + off_t offset; + /* + * According to the man page of copy_file_range, + * the offsets for source and destination file + * are of type loff_t. But the type loff_t is + * linux specific and is actual a typedef of + * off64_t. + */ + off64_t off_in; /* used in copy_file_range for source fd */ + off64_t off_out; /* used in copy_file_range for dst fd */ int32_t mask; int32_t cmd; size_t size; @@ -323,6 +264,17 @@ typedef struct client_args { lock_migration_info_t *locklist; } clnt_args_t; +typedef struct client_payload { + struct iobref *iobref; + struct iovec *payload; + struct iovec *rsphdr; + struct iovec *rsp_payload; + struct iobref *rsp_iobref; + int payload_cnt; + int rsphdr_cnt; + int rsp_payload_cnt; +} client_payload_t; + typedef ssize_t (*gfs_serialize_t)(struct iovec outmsg, void *args); clnt_fd_ctx_t * @@ -337,19 +289,7 @@ client_local_wipe(clnt_local_t *local); int client_submit_request(xlator_t *this, void *req, call_frame_t *frame, rpc_clnt_prog_t *prog, int procnum, fop_cbk_fn_t cbk, - struct iobref *iobref, struct iovec *rsphdr, - int rsphdr_count, struct iovec *rsp_payload, - int rsp_count, struct iobref *rsp_iobref, - xdrproc_t xdrproc); - -int -client_submit_compound_request(xlator_t *this, void *req, call_frame_t *frame, - rpc_clnt_prog_t *prog, int procnum, - fop_cbk_fn_t cbkfn, struct iovec *req_vector, - int req_count, struct iobref *iobref, - struct iovec *rsphdr, int rsphdr_count, - struct iovec *rsp_payload, int rsp_payload_count, - struct iobref *rsp_iobref, xdrproc_t xdrproc); + client_payload_t *cp, xdrproc_t xdrproc); int unserialize_rsp_dirent(xlator_t *this, struct gfs3_readdir_rsp *rsp, @@ -374,8 +314,6 @@ void client_save_number_fds(clnt_conf_t *conf, int count); int dump_client_locks(inode_t *inode); -int -client_notify_parents_child_up(xlator_t *this); int32_t is_client_dump_locks_cmd(char *name); int32_t @@ -383,12 +321,6 @@ client_dump_locks(char *name, inode_t *inode, dict_t *dict); int client_fdctx_destroy(xlator_t *this, clnt_fd_ctx_t *fdctx); -int32_t -client_type_to_gf_type(short l_type); - -int -client_mark_fd_bad(xlator_t *this); - int client_fd_lk_list_empty(fd_lk_ctx_t *lk_ctx, gf_boolean_t use_try_lock); void @@ -413,19 +345,6 @@ int client_add_fd_to_saved_fds(xlator_t *this, fd_t *fd, loc_t *loc, int32_t flags, int64_t remote_fd, int is_dir); int -client_handle_fop_requirements( - xlator_t *this, call_frame_t *frame, gfs3_compound_req *req, - clnt_local_t *local, struct iobref **req_iobref, struct iobref **rsp_iobref, - struct iovec *req_vector, struct iovec *rsp_vector, int *req_count, - int *rsp_count, default_args_t *args, int fop_enum, int index); -int -client_process_response(call_frame_t *frame, xlator_t *this, - struct rpc_req *req, gfs3_compound_rsp *rsp, - compound_args_cbk_t *args_cbk, int index); -void -compound_request_cleanup(gfs3_compound_req *req); - -int clnt_unserialize_rsp_locklist(xlator_t *this, struct gfs3_getactivelk_rsp *rsp, lock_migration_info_t *lmi); void @@ -439,9 +358,6 @@ serialize_req_locklist(lock_migration_info_t *locklist, gfs3_setactivelk_req *req); void -client_compound_rsp_cleanup(gfs3_compound_rsp *rsp, int len); - -void clnt_getactivelk_rsp_cleanup_v2(gfx_getactivelk_rsp *rsp); void @@ -469,18 +385,10 @@ int clnt_readdirp_rsp_cleanup_v2(gfx_readdirp_rsp *rsp); int -client_handle_fop_requirements_v2( - xlator_t *this, call_frame_t *frame, gfx_compound_req *req, - clnt_local_t *local, struct iobref **req_iobref, struct iobref **rsp_iobref, - struct iovec *req_vector, struct iovec *rsp_vector, int *req_count, - int *rsp_count, default_args_t *args, int fop_enum, int index); +client_add_lock_for_recovery(fd_t *fd, struct gf_flock *flock, + gf_lkowner_t *owner, int32_t cmd); + int -client_process_response_v2(call_frame_t *frame, xlator_t *this, - struct rpc_req *req, gfx_compound_rsp *rsp, - compound_args_cbk_t *args_cbk, int index); -void -compound_request_cleanup_v2(gfx_compound_req *req); -void -client_compound_rsp_cleanup_v2(gfx_compound_rsp *rsp, int len); +client_is_setlk(int32_t cmd); #endif /* !_CLIENT_H */ |
