diff options
Diffstat (limited to 'xlators/protocol/client/src')
| -rw-r--r-- | xlators/protocol/client/src/Makefile.am | 13 | ||||
| -rw-r--r-- | xlators/protocol/client/src/client-callback.c | 25 | ||||
| -rw-r--r-- | xlators/protocol/client/src/client-handshake.c | 441 | ||||
| -rw-r--r-- | xlators/protocol/client/src/client-helpers.c | 97 | ||||
| -rw-r--r-- | xlators/protocol/client/src/client-lk.c | 379 | ||||
| -rw-r--r-- | xlators/protocol/client/src/client-mem-types.h | 21 | ||||
| -rw-r--r-- | xlators/protocol/client/src/client-rpc-fops.c (renamed from xlators/protocol/client/src/client3_1-fops.c) | 2427 | ||||
| -rw-r--r-- | xlators/protocol/client/src/client.c | 449 | ||||
| -rw-r--r-- | xlators/protocol/client/src/client.h | 90 |
9 files changed, 2470 insertions, 1472 deletions
diff --git a/xlators/protocol/client/src/Makefile.am b/xlators/protocol/client/src/Makefile.am index 29c6e9dde..cf89d42da 100644 --- a/xlators/protocol/client/src/Makefile.am +++ b/xlators/protocol/client/src/Makefile.am @@ -2,16 +2,19 @@ xlator_LTLIBRARIES = client.la xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/protocol -client_la_LDFLAGS = -module -avoidversion +client_la_LDFLAGS = -module -avoid-version client_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la \ $(top_builddir)/rpc/rpc-lib/src/libgfrpc.la \ $(top_builddir)/rpc/xdr/src/libgfxdr.la -client_la_SOURCES = client.c client-helpers.c client3_1-fops.c \ +client_la_SOURCES = client.c client-helpers.c client-rpc-fops.c \ client-handshake.c client-callback.c client-lk.c + noinst_HEADERS = client.h client-mem-types.h -AM_CFLAGS = -fPIC -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -Wall -D$(GF_HOST_OS) \ - -I$(top_srcdir)/libglusterfs/src -shared -nostartfiles $(GF_CFLAGS) \ - -I$(top_srcdir)/rpc/xdr/src -I$(top_srcdir)/rpc/rpc-lib/src/
\ No newline at end of file +AM_CPPFLAGS = $(GF_CPPFLAGS) \ + -I$(top_srcdir)/libglusterfs/src \ + -I$(top_srcdir)/rpc/xdr/src -I$(top_srcdir)/rpc/rpc-lib/src/ + +AM_CFLAGS = -Wall $(GF_CFLAGS) diff --git a/xlators/protocol/client/src/client-callback.c b/xlators/protocol/client/src/client-callback.c index 2d960ab1a..d886862f7 100644 --- a/xlators/protocol/client/src/client-callback.c +++ b/xlators/protocol/client/src/client-callback.c @@ -1,20 +1,11 @@ /* - Copyright (c) 2010-2011 Gluster, Inc. <http://www.gluster.com> + Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com> This file is part of GlusterFS. - GlusterFS is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - GlusterFS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see - <http://www.gnu.org/licenses/>. + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. */ #ifndef _CONFIG_H @@ -26,7 +17,7 @@ #include "rpc-clnt.h" int -client_cbk_null (void *data) +client_cbk_null (struct rpc_clnt *rpc, void *mydata, void *data) { gf_log (THIS->name, GF_LOG_WARNING, "this function should not be called"); @@ -34,7 +25,7 @@ client_cbk_null (void *data) } int -client_cbk_fetchspec (void *data) +client_cbk_fetchspec (struct rpc_clnt *rpc, void *mydata, void *data) { gf_log (THIS->name, GF_LOG_WARNING, "this function should not be called"); @@ -42,7 +33,7 @@ client_cbk_fetchspec (void *data) } int -client_cbk_ino_flush (void *data) +client_cbk_ino_flush (struct rpc_clnt *rpc, void *mydata, void *data) { gf_log (THIS->name, GF_LOG_WARNING, "this function should not be called"); diff --git a/xlators/protocol/client/src/client-handshake.c b/xlators/protocol/client/src/client-handshake.c index 0a8759af5..5668fea53 100644 --- a/xlators/protocol/client/src/client-handshake.c +++ b/xlators/protocol/client/src/client-handshake.c @@ -1,20 +1,11 @@ /* - Copyright (c) 2010-2011 Gluster, Inc. <http://www.gluster.com> + Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com> This file is part of GlusterFS. - GlusterFS is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - GlusterFS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see - <http://www.gnu.org/licenses/>. + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. */ #ifndef _CONFIG_H @@ -34,7 +25,8 @@ #include "portmap-xdr.h" #include "rpc-common-xdr.h" -extern rpc_clnt_prog_t clnt3_1_fop_prog; +#define CLIENT_REOPEN_MAX_ATTEMPTS 1024 +extern rpc_clnt_prog_t clnt3_3_fop_prog; extern rpc_clnt_prog_t clnt_pmap_prog; int client_ping_cbk (struct rpc_req *req, struct iovec *iov, int count, @@ -61,7 +53,7 @@ rpc_client_ping_timer_expired (void *data) rpc_clnt_connection_t *conn = NULL; int disconnect = 0; int transport_activity = 0; - struct timeval timeout = {0, }; + struct timespec timeout = {0, }; struct timeval current = {0, }; struct rpc_clnt *clnt = NULL; xlator_t *this = NULL; @@ -109,7 +101,7 @@ rpc_client_ping_timer_expired (void *data) "ping timer expired but transport activity " "detected - not bailing transport"); timeout.tv_sec = conf->opt.ping_timeout; - timeout.tv_usec = 0; + timeout.tv_nsec = 0; conn->ping_timer = gf_timer_call_after (this->ctx, timeout, @@ -148,7 +140,7 @@ client_start_ping (void *data) clnt_conf_t *conf = NULL; rpc_clnt_connection_t *conn = NULL; int32_t ret = -1; - struct timeval timeout = {0, }; + struct timespec timeout = {0, }; call_frame_t *frame = NULL; int frame_count = 0; @@ -204,7 +196,7 @@ client_start_ping (void *data) } timeout.tv_sec = conf->opt.ping_timeout; - timeout.tv_usec = 0; + timeout.tv_nsec = 0; conn->ping_timer = gf_timer_call_after (this->ctx, timeout, @@ -249,42 +241,47 @@ client_ping_cbk (struct rpc_req *req, struct iovec *iov, int count, { xlator_t *this = NULL; rpc_clnt_connection_t *conn = NULL; - struct timeval timeout = {0, }; + struct timespec timeout = {0, }; call_frame_t *frame = NULL; clnt_conf_t *conf = NULL; if (!myframe) { - gf_log (THIS->name, GF_LOG_WARNING, "frame with the request is NULL"); + gf_log (THIS->name, GF_LOG_WARNING, + "frame with the request is NULL"); goto out; } frame = myframe; this = frame->this; if (!this || !this->private) { - gf_log (THIS->name, GF_LOG_WARNING, "xlator private is not set"); + gf_log (THIS->name, GF_LOG_WARNING, + "xlator private is not set"); goto out; } conf = this->private; conn = &conf->rpc->conn; - if (req->rpc_status == -1) { - if (conn->ping_timer != NULL) { - gf_log (this->name, GF_LOG_WARNING, "socket or ib" - " related error"); - gf_timer_call_cancel (this->ctx, conn->ping_timer); - conn->ping_timer = NULL; - } else { - /* timer expired and transport bailed out */ - gf_log (this->name, GF_LOG_WARNING, "timer must have " - "expired"); - } - goto out; - } - pthread_mutex_lock (&conn->lock); { + if (req->rpc_status == -1) { + if (conn->ping_timer != NULL) { + gf_log (this->name, GF_LOG_WARNING, + "socket or ib related error"); + gf_timer_call_cancel (this->ctx, + conn->ping_timer); + conn->ping_timer = NULL; + } else { + /* timer expired and transport bailed out */ + gf_log (this->name, GF_LOG_WARNING, + "timer must have expired"); + } + + goto unlock; + } + + timeout.tv_sec = conf->opt.ping_timeout; - timeout.tv_usec = 0; + timeout.tv_nsec = 0; gf_timer_call_cancel (this->ctx, conn->ping_timer); @@ -297,6 +294,7 @@ client_ping_cbk (struct rpc_req *req, struct iovec *iov, int count, gf_log (this->name, GF_LOG_WARNING, "failed to set the ping timer"); } +unlock: pthread_mutex_unlock (&conn->lock); out: if (frame) @@ -350,8 +348,7 @@ out: rsp.spec); /* Don't use 'GF_FREE', this is allocated by libc */ - if (rsp.spec) - free (rsp.spec); + free (rsp.spec); return 0; } @@ -419,9 +416,6 @@ clnt_fd_lk_reacquire_failed (xlator_t *this, clnt_fd_ctx_t *fdctx, { fdctx->remote_fd = -1; fdctx->lk_heal_state = GF_LK_HEAL_DONE; - - list_add_tail (&fdctx->sfd_pos, - &conf->saved_fds); } pthread_mutex_unlock (&conf->lock); @@ -457,13 +451,13 @@ client_set_lk_version_cbk (struct rpc_req *req, struct iovec *iov, ret = 0; out: - //TODO: Check for all released fdctx and destroy them if (fr) STACK_DESTROY (fr->root); return ret; } +//TODO: Check for all released fdctx and destroy them int client_set_lk_version (xlator_t *this) { @@ -472,16 +466,24 @@ client_set_lk_version (xlator_t *this) call_frame_t *frame = NULL; gf_set_lk_ver_req req = {0, }; + GF_VALIDATE_OR_GOTO ("client", this, err); + conf = (clnt_conf_t *) this->private; req.lk_ver = client_get_lk_ver (conf); - req.uid = this->ctx->process_uuid; - - gf_log (this->name, GF_LOG_DEBUG, "Sending SET_LK_VERSION"); + ret = gf_asprintf (&req.uid, "%s-%s-%d", + this->ctx->process_uuid, this->name, + this->graph->id); + if (ret == -1) + goto err; frame = create_frame (this, this->ctx->pool); - if (!frame) + if (!frame) { + ret = -1; goto out; + } + + gf_log (this->name, GF_LOG_DEBUG, "Sending SET_LK_VERSION"); ret = client_submit_request (this, &req, frame, conf->handshake, @@ -490,11 +492,11 @@ client_set_lk_version (xlator_t *this) NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gf_set_lk_ver_req); out: - if (ret < 0) { - //TODO: Check for all released fdctx and destroy them - gf_log (this->name, GF_LOG_WARNING, - "Failed to send SET_LK_VERSION to server"); - } + GF_FREE (req.uid); + return ret; +err: + gf_log (this->name, GF_LOG_WARNING, + "Failed to send SET_LK_VERSION to server"); return ret; } @@ -599,7 +601,7 @@ clnt_release_reopen_fd_cbk (struct rpc_req *req, struct iovec *iov, clnt_fd_lk_reacquire_failed (this, fdctx, conf); - decrement_reopen_fd_count (this, conf); + fdctx->reopen_done (fdctx, this); frame->local = NULL; STACK_DESTROY (frame->root); @@ -617,7 +619,7 @@ clnt_release_reopen_fd (xlator_t *this, clnt_fd_ctx_t *fdctx) conf = (clnt_conf_t *) this->private; - frame = create_frame (THIS, THIS->ctx->pool); + frame = create_frame (this, this->ctx->pool); if (!frame) goto out; @@ -629,10 +631,11 @@ clnt_release_reopen_fd (xlator_t *this, clnt_fd_ctx_t *fdctx) clnt_release_reopen_fd_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_releasedir_req); + return 0; out: if (ret) { - decrement_reopen_fd_count (this, conf); clnt_fd_lk_reacquire_failed (this, fdctx, conf); + fdctx->reopen_done (fdctx, this); if (frame) { frame->local = NULL; STACK_DESTROY (frame->root); @@ -742,21 +745,18 @@ client_reacquire_lock_cbk (struct rpc_req *req, struct iovec *iov, gf_log (this->name, GF_LOG_DEBUG, "%s type lock reacquired on file " "with gfid %s from %"PRIu64 " to %"PRIu64, - get_lk_type (lock.l_type), uuid_utoa (fdctx->inode->gfid), + get_lk_type (lock.l_type), uuid_utoa (fdctx->gfid), lock.l_start, lock.l_start + lock.l_len); - if (clnt_fd_lk_local_unref (this, local) == 0 && - !clnt_fd_lk_local_error_status (this, local)) { + if (!clnt_fd_lk_local_error_status (this, local) && + clnt_fd_lk_local_unref (this, local) == 0) { pthread_mutex_lock (&conf->lock); { fdctx->lk_heal_state = GF_LK_HEAL_DONE; - - list_add_tail (&fdctx->sfd_pos, - &conf->saved_fds); } pthread_mutex_unlock (&conf->lock); - decrement_reopen_fd_count (this, conf); + fdctx->reopen_done (fdctx, this); } ret = 0; @@ -794,7 +794,7 @@ _client_reacquire_lock (xlator_t *this, clnt_fd_ctx_t *fdctx) if (!local) { gf_log (this->name, GF_LOG_WARNING, "clnt_fd_lk_local_create " "failed, aborting reacquring of locks on %s.", - uuid_utoa (fdctx->inode->gfid)); + uuid_utoa (fdctx->gfid)); clnt_reacquire_lock_error (this, fdctx, conf); goto out; } @@ -820,9 +820,9 @@ _client_reacquire_lock (xlator_t *this, clnt_fd_ctx_t *fdctx) (void) gf_proto_flock_from_flock (&req.flock, &flock); - memcpy (req.gfid, fdctx->inode->gfid, 16); + memcpy (req.gfid, fdctx->gfid, 16); - frame = create_frame (THIS, THIS->ctx->pool); + frame = create_frame (this, this->ctx->pool); if (!frame) { ret = -1; break; @@ -839,7 +839,7 @@ _client_reacquire_lock (xlator_t *this, clnt_fd_ctx_t *fdctx) if (ret) { gf_log (this->name, GF_LOG_WARNING, "reacquiring locks failed on file with gfid %s", - uuid_utoa (fdctx->inode->gfid)); + uuid_utoa (fdctx->gfid)); break; } @@ -865,8 +865,7 @@ client_reacquire_lock (xlator_t *this, clnt_fd_ctx_t *fdctx) if (client_fd_lk_list_empty (fdctx->lk_ctx, _gf_false)) { gf_log (this->name, GF_LOG_DEBUG, "fd lock list is empty"); - decrement_reopen_fd_count (this, - (clnt_conf_t *)this->private); + fdctx->reopen_done (fdctx, this); } else { lk_ctx = fdctx->lk_ctx; @@ -881,14 +880,66 @@ out: return ret; } +void +client_default_reopen_done (clnt_fd_ctx_t *fdctx, xlator_t *this) +{ + gf_log_callingfn (this->name, GF_LOG_WARNING, + "This function should never be called"); +} + +void +client_reopen_done (clnt_fd_ctx_t *fdctx, xlator_t *this) +{ + clnt_conf_t *conf = NULL; + gf_boolean_t destroy = _gf_false; + + conf = this->private; + + pthread_mutex_lock (&conf->lock); + { + fdctx->reopen_attempts = 0; + if (!fdctx->released) + list_add_tail (&fdctx->sfd_pos, &conf->saved_fds); + else + destroy = _gf_true; + fdctx->reopen_done = client_default_reopen_done; + } + pthread_mutex_unlock (&conf->lock); + + if (destroy) + client_fdctx_destroy (this, fdctx); +} + +void +client_child_up_reopen_done (clnt_fd_ctx_t *fdctx, xlator_t *this) +{ + clnt_conf_t *conf = NULL; + uint64_t fd_count = 0; + + conf = this->private; + + LOCK (&conf->rec_lock); + { + fd_count = --(conf->reopen_fd_count); + } + UNLOCK (&conf->rec_lock); + + client_reopen_done (fdctx, this); + if (fd_count == 0) { + gf_log (this->name, GF_LOG_INFO, + "last fd open'd/lock-self-heal'd - notifying CHILD-UP"); + client_set_lk_version (this); + client_notify_parents_child_up (this); + } +} + int -client3_1_reopen_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_reopen_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { int32_t ret = -1; gfs3_open_rsp rsp = {0,}; - int attempt_lock_recovery = _gf_false; - uint64_t fd_count = 0; + gf_boolean_t attempt_lock_recovery = _gf_false; clnt_local_t *local = NULL; clnt_conf_t *conf = NULL; clnt_fd_ctx_t *fdctx = NULL; @@ -896,12 +947,10 @@ client3_1_reopen_cbk (struct rpc_req *req, struct iovec *iov, int count, xlator_t *this = NULL; frame = myframe; - if (!frame || !frame->this) - goto out; - this = frame->this; + conf = this->private; local = frame->local; - conf = frame->this->private; + fdctx = local->fdctx; if (-1 == req->rpc_status) { gf_log (frame->this->name, GF_LOG_WARNING, @@ -934,32 +983,23 @@ client3_1_reopen_cbk (struct rpc_req *req, struct iovec *iov, int count, goto out; } - fdctx = local->fdctx; - if (!fdctx) { - gf_log (frame->this->name, GF_LOG_WARNING, "fdctx not found"); - ret = -1; - goto out; - } - pthread_mutex_lock (&conf->lock); { fdctx->remote_fd = rsp.fd; if (!fdctx->released) { - if (!client_fd_lk_list_empty (fdctx->lk_ctx, _gf_false)) { + if (conf->lk_heal && + !client_fd_lk_list_empty (fdctx->lk_ctx, + _gf_false)) { attempt_lock_recovery = _gf_true; fdctx->lk_heal_state = GF_LK_HEAL_IN_PROGRESS; - } else { - list_add_tail (&fdctx->sfd_pos, - &conf->saved_fds); } - fdctx = NULL; } } pthread_mutex_unlock (&conf->lock); ret = 0; - if (conf->lk_heal && attempt_lock_recovery) { + if (attempt_lock_recovery) { /* Delay decrementing the reopen fd count untill all the locks corresponding to this fd are acquired.*/ gf_log (this->name, GF_LOG_DEBUG, "acquiring locks " @@ -969,23 +1009,15 @@ client3_1_reopen_cbk (struct rpc_req *req, struct iovec *iov, int count, clnt_reacquire_lock_error (this, local->fdctx, conf); gf_log (this->name, GF_LOG_WARNING, "acquiring locks " "failed on %s", local->loc.path); - ret = 0; } - } else { - fd_count = decrement_reopen_fd_count (frame->this, conf); } out: - if (fdctx) { - clnt_release_reopen_fd (this, fdctx); - } else if ((ret < 0) && frame && frame->this && conf) { - decrement_reopen_fd_count (frame->this, conf); - } + if (!attempt_lock_recovery) + fdctx->reopen_done (fdctx, this); - if (frame) { - frame->local = NULL; - STACK_DESTROY (frame->root); - } + frame->local = NULL; + STACK_DESTROY (frame->root); client_local_wipe (local); @@ -993,7 +1025,7 @@ out: } int -client3_1_reopendir_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_reopendir_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { int32_t ret = -1; @@ -1004,11 +1036,10 @@ client3_1_reopendir_cbk (struct rpc_req *req, struct iovec *iov, int count, call_frame_t *frame = NULL; frame = myframe; - if (!frame || !frame->this) - goto out; + local = frame->local; + fdctx = local->fdctx; + conf = frame->this->private; - local = frame->local; - conf = frame->this->private; if (-1 == req->rpc_status) { gf_log (frame->this->name, GF_LOG_WARNING, @@ -1041,78 +1072,44 @@ client3_1_reopendir_cbk (struct rpc_req *req, struct iovec *iov, int count, goto out; } - fdctx = local->fdctx; - if (!fdctx) { - gf_log (frame->this->name, GF_LOG_WARNING, "fdctx not found"); - ret = -1; - goto out; - } - pthread_mutex_lock (&conf->lock); { fdctx->remote_fd = rsp.fd; - - if (!fdctx->released) { - list_add_tail (&fdctx->sfd_pos, &conf->saved_fds); - fdctx = NULL; - } } pthread_mutex_unlock (&conf->lock); - decrement_reopen_fd_count (frame->this, conf); - ret = 0; - out: - if (fdctx) - client_fdctx_destroy (frame->this, fdctx); - - if ((ret < 0) && frame && frame->this && conf) - decrement_reopen_fd_count (frame->this, conf); - - if (frame) { - frame->local = NULL; - STACK_DESTROY (frame->root); - } + fdctx->reopen_done (fdctx, frame->this); + frame->local = NULL; + STACK_DESTROY (frame->root); client_local_wipe (local); return 0; } -int -protocol_client_reopendir (xlator_t *this, clnt_fd_ctx_t *fdctx) +static int +protocol_client_reopendir (clnt_fd_ctx_t *fdctx, xlator_t *this) { int ret = -1; gfs3_opendir_req req = {{0,},}; clnt_local_t *local = NULL; - inode_t *inode = NULL; - char *path = NULL; call_frame_t *frame = NULL; clnt_conf_t *conf = NULL; - if (!this || !fdctx) - goto out; - - inode = fdctx->inode; conf = this->private; - ret = inode_path (inode, NULL, &path); - if (ret < 0) { - gf_log (this->name, GF_LOG_WARNING, - "couldn't build path from inode %s", - uuid_utoa (inode->gfid)); - goto out; - } - local = mem_get0 (this->local_pool); if (!local) { ret = -1; goto out; } - local->fdctx = fdctx; - local->loc.path = path; - path = NULL; + + uuid_copy (local->loc.gfid, fdctx->gfid); + ret = loc_path (&local->loc, NULL); + if (ret < 0) + goto out; frame = create_frame (this, this->ctx->pool); if (!frame) { @@ -1120,24 +1117,24 @@ protocol_client_reopendir (xlator_t *this, clnt_fd_ctx_t *fdctx) goto out; } - memcpy (req.gfid, inode->gfid, 16); + memcpy (req.gfid, fdctx->gfid, 16); gf_log (frame->this->name, GF_LOG_DEBUG, "attempting reopen on %s", local->loc.path); - frame->local = local; local = NULL; + frame->local = local; ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_OPENDIR, - client3_1_reopendir_cbk, NULL, + client3_3_reopendir_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_opendir_req); if (ret) { - gf_log (THIS->name, GF_LOG_ERROR, + gf_log (this->name, GF_LOG_ERROR, "failed to send the re-opendir request"); } - return ret; + return 0; out: if (frame) { @@ -1148,41 +1145,23 @@ out: if (local) client_local_wipe (local); - if (path) - GF_FREE (path); - if ((ret < 0) && this && conf) { - decrement_reopen_fd_count (this, conf); - } + fdctx->reopen_done (fdctx, this); return 0; } -int -protocol_client_reopen (xlator_t *this, clnt_fd_ctx_t *fdctx) +static int +protocol_client_reopenfile (clnt_fd_ctx_t *fdctx, xlator_t *this) { int ret = -1; gfs3_open_req req = {{0,},}; clnt_local_t *local = NULL; - inode_t *inode = NULL; - char *path = NULL; call_frame_t *frame = NULL; clnt_conf_t *conf = NULL; - if (!this || !fdctx) - goto out; - - inode = fdctx->inode; conf = this->private; - ret = inode_path (inode, NULL, &path); - if (ret < 0) { - gf_log (this->name, GF_LOG_WARNING, - "couldn't build path from inode %s", - uuid_utoa (inode->gfid)); - goto out; - } - frame = create_frame (this, this->ctx->pool); if (!frame) { ret = -1; @@ -1196,28 +1175,30 @@ protocol_client_reopen (xlator_t *this, clnt_fd_ctx_t *fdctx) } local->fdctx = fdctx; - local->loc.path = path; - path = NULL; + uuid_copy (local->loc.gfid, fdctx->gfid); + ret = loc_path (&local->loc, NULL); + if (ret < 0) + goto out; + frame->local = local; - memcpy (req.gfid, inode->gfid, 16); + memcpy (req.gfid, fdctx->gfid, 16); req.flags = gf_flags_from_flags (fdctx->flags); - req.wbflags = fdctx->wbflags; + req.flags = req.flags & (~(O_TRUNC|O_CREAT|O_EXCL)); gf_log (frame->this->name, GF_LOG_DEBUG, "attempting reopen on %s", local->loc.path); - local = NULL; ret = client_submit_request (this, &req, frame, conf->fops, - GFS3_OP_OPEN, client3_1_reopen_cbk, NULL, + GFS3_OP_OPEN, client3_3_reopen_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_open_req); if (ret) { - gf_log (THIS->name, GF_LOG_ERROR, + gf_log (this->name, GF_LOG_ERROR, "failed to send the re-open request"); } - return ret; + return 0; out: if (frame) { @@ -1228,17 +1209,65 @@ out: if (local) client_local_wipe (local); - if (path) - GF_FREE (path); - - if ((ret < 0) && this && conf) { - decrement_reopen_fd_count (this, conf); - } + fdctx->reopen_done (fdctx, this); return 0; } +static void +protocol_client_reopen (clnt_fd_ctx_t *fdctx, xlator_t *this) +{ + if (fdctx->is_dir) + protocol_client_reopendir (fdctx, this); + else + protocol_client_reopenfile (fdctx, this); +} + +gf_boolean_t +__is_fd_reopen_in_progress (clnt_fd_ctx_t *fdctx) +{ + if (fdctx->reopen_done == client_default_reopen_done) + return _gf_false; + return _gf_true; +} + +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; + pthread_mutex_lock (&conf->lock); + { + fdctx = this_fd_get_ctx (fd, this); + if (!fdctx) + goto unlock; + if (__is_fd_reopen_in_progress (fdctx)) + goto unlock; + if (fdctx->remote_fd != -1) + goto unlock; + + if (fdctx->reopen_attempts == CLIENT_REOPEN_MAX_ATTEMPTS) { + reopen = _gf_true; + fdctx->reopen_done = client_reopen_done; + list_del_init (&fdctx->sfd_pos); + } else { + fdctx->reopen_attempts++; + } + } +unlock: + pthread_mutex_unlock (&conf->lock); + if (reopen) + protocol_client_reopen (fdctx, this); +out: + return; +} int client_post_handshake (call_frame_t *frame, xlator_t *this) @@ -1263,6 +1292,7 @@ client_post_handshake (call_frame_t *frame, xlator_t *this) if (fdctx->remote_fd != -1) continue; + fdctx->reopen_done = client_child_up_reopen_done; list_del_init (&fdctx->sfd_pos); list_add_tail (&fdctx->sfd_pos, &reopen_head); count++; @@ -1281,10 +1311,7 @@ client_post_handshake (call_frame_t *frame, xlator_t *this) list_for_each_entry_safe (fdctx, tmp, &reopen_head, sfd_pos) { list_del_init (&fdctx->sfd_pos); - if (fdctx->is_dir) - protocol_client_reopendir (this, fdctx); - else - protocol_client_reopen (this, fdctx); + protocol_client_reopen (fdctx, this); } } else { gf_log (this->name, GF_LOG_DEBUG, @@ -1370,8 +1397,7 @@ client_setvolume_cbk (struct rpc_req *req, struct iovec *iov, int count, void *m remote_error ? remote_error : strerror (op_errno)); errno = op_errno; if (remote_error && - (strncmp ("Authentication failed",remote_error, - sizeof (remote_error)) == 0)) { + (strcmp ("Authentication failed", remote_error) == 0)) { auth_fail = _gf_true; op_ret = 0; } @@ -1478,8 +1504,7 @@ out: ret = 0; } - if (rsp.dict.dict_val) - free (rsp.dict.dict_val); + free (rsp.dict.dict_val); STACK_DESTROY (frame->root); @@ -1574,13 +1599,14 @@ client_setvolume (xlator_t *this, struct rpc_clnt *rpc) client_get_lk_ver (conf)); } - req.dict.dict_len = dict_serialized_length (options); - if (req.dict.dict_len < 0) { + ret = dict_serialized_length (options); + if (ret < 0) { gf_log (this->name, GF_LOG_ERROR, "failed to get serialized length of dict"); 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); @@ -1600,8 +1626,7 @@ client_setvolume (xlator_t *this, struct rpc_clnt *rpc) (xdrproc_t)xdr_gf_setvolume_req); fail: - if (req.dict.dict_val) - GF_FREE (req.dict.dict_val); + GF_FREE (req.dict.dict_val); return ret; } @@ -1624,9 +1649,9 @@ select_server_supported_programs (xlator_t *this, gf_prog_detail *prog) while (trav) { /* Select 'programs' */ - if ((clnt3_1_fop_prog.prognum == trav->prognum) && - (clnt3_1_fop_prog.progver == trav->progver)) { - conf->fops = &clnt3_1_fop_prog; + if ((clnt3_3_fop_prog.prognum == trav->prognum) && + (clnt3_3_fop_prog.progver == trav->progver)) { + conf->fops = &clnt3_3_fop_prog; gf_log (this->name, GF_LOG_INFO, "Using Program %s, Num (%"PRId64"), " "Version (%"PRId64")", @@ -1711,16 +1736,21 @@ client_query_portmap_cbk (struct rpc_req *req, struct iovec *iov, int count, voi ret = -1; gf_log (this->name, ((!conf->portmap_err_logged) ? GF_LOG_ERROR : GF_LOG_DEBUG), - "failed to get the port number for remote subvolume"); + "failed to get the port number for remote subvolume. " + "Please run 'gluster volume status' on server to see " + "if brick process is running."); conf->portmap_err_logged = 1; goto out; } conf->portmap_err_logged = 0; + conf->disconnect_err_logged = 0; config.remote_port = rsp.port; rpc_clnt_reconfig (conf->rpc, &config); + conf->skip_notify = 1; + conf->quick_reconnect = 1; out: if (frame) @@ -1730,7 +1760,6 @@ out: /* Need this to connect the same transport on different port */ /* ie, glusterd to glusterfsd */ rpc_transport_disconnect (conf->rpc->conn.trans); - rpc_clnt_reconnect (conf->rpc->conn.trans); } return ret; diff --git a/xlators/protocol/client/src/client-helpers.c b/xlators/protocol/client/src/client-helpers.c index 8cf83fe30..5d9f00fdc 100644 --- a/xlators/protocol/client/src/client-helpers.c +++ b/xlators/protocol/client/src/client-helpers.c @@ -1,20 +1,11 @@ /* - Copyright (c) 2010-2011 Gluster, Inc. <http://www.gluster.com> + Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com> This file is part of GlusterFS. - GlusterFS is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - GlusterFS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see - <http://www.gnu.org/licenses/>. + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. */ #ifndef _CONFIG_H @@ -25,7 +16,6 @@ #include "client.h" #include "fd.h" - int client_fd_lk_list_empty (fd_lk_ctx_t *lk_ctx, gf_boolean_t try_lock) { @@ -132,6 +122,7 @@ client_local_wipe (clnt_local_t *local) { if (local) { loc_wipe (&local->loc); + loc_wipe (&local->loc2); if (local->fd) { fd_unref (local->fd); @@ -141,7 +132,9 @@ client_local_wipe (clnt_local_t *local) iobref_unref (local->iobref); } - mem_put (local); + GF_FREE (local->name); + + mem_put (local); } return 0; @@ -282,3 +275,75 @@ clnt_readdir_rsp_cleanup (gfs3_readdir_rsp *rsp) return 0; } + +int +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_VALIDATE_OR_GOTO (this->name, fd, out); + GF_VALIDATE_OR_GOTO (this->name, remote_fd, out); + + conf = this->private; + pthread_mutex_lock (&conf->lock); + { + fdctx = this_fd_get_ctx (fd, this); + if (!fdctx) + *remote_fd = GF_ANON_FD_NO; + else if (__is_fd_reopen_in_progress (fdctx)) + *remote_fd = -1; + else + *remote_fd = fdctx->remote_fd; + } + pthread_mutex_unlock (&conf->lock); + + if ((flags & FALLBACK_TO_ANON_FD) && (*remote_fd == -1)) + *remote_fd = GF_ANON_FD_NO; + + return 0; +out: + return -1; +} + +gf_boolean_t +client_is_reopen_needed (fd_t *fd, xlator_t *this, int64_t remote_fd) +{ + clnt_fd_ctx_t *fdctx = NULL; + + fdctx = this_fd_get_ctx (fd, this); + if (fdctx && (fdctx->remote_fd == -1) && + (remote_fd == GF_ANON_FD_NO)) + return _gf_true; + return _gf_false; +} + +int +client_fd_fop_prepare_local (call_frame_t *frame, fd_t *fd, int64_t remote_fd) +{ + xlator_t *this = NULL; + clnt_conf_t *conf = NULL; + clnt_local_t *local = NULL; + int ret = 0; + + this = frame->this; + conf = this->private; + + if (!frame || !fd) { + ret = -EINVAL; + goto out; + } + + frame->local = mem_get0 (this->local_pool); + if (frame->local == NULL) { + ret = -ENOMEM; + goto out; + } + + local = frame->local; + local->fd = fd_ref (fd); + local->attempt_reopen = client_is_reopen_needed (fd, this, remote_fd); + return 0; +out: + return ret; +} diff --git a/xlators/protocol/client/src/client-lk.c b/xlators/protocol/client/src/client-lk.c index 4e87f7fcd..1fd8f0d50 100644 --- a/xlators/protocol/client/src/client-lk.c +++ b/xlators/protocol/client/src/client-lk.c @@ -1,20 +1,11 @@ /* - Copyright (c) 2008-2011 Gluster, Inc. <http://www.gluster.com> + Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com> This file is part of GlusterFS. - GlusterFS is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - GlusterFS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see - <http://www.gnu.org/licenses/>. + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. */ #include "common-utils.h" @@ -25,9 +16,6 @@ static void __insert_and_merge (clnt_fd_ctx_t *fdctx, client_posix_lock_t *lock); -static int -client_send_recovery_lock (call_frame_t *frame, xlator_t *this, - client_posix_lock_t *lock); static void __dump_client_lock (client_posix_lock_t *lock) { @@ -439,21 +427,6 @@ delete_granted_locks_fd (clnt_fd_ctx_t *fdctx) return ret; } -static void -client_mark_bad_fd (fd_t *fd, clnt_fd_ctx_t *fdctx) -{ - xlator_t *this = NULL; - - this = THIS; - if (fdctx) - fdctx->remote_fd = -1; - - gf_log (this->name, GF_LOG_WARNING, - "marking the file descriptor (%p) bad", fd); - - this_fd_set_ctx (fd, this, NULL, fdctx); -} - int32_t client_cmd_to_gf_cmd (int32_t cmd, int32_t *gf_cmd) { @@ -562,348 +535,6 @@ out: } -static int -construct_reserve_unlock (struct gf_flock *lock, call_frame_t *frame, - client_posix_lock_t *client_lock) -{ - GF_ASSERT (lock); - GF_ASSERT (frame); - - lock->l_type = F_UNLCK; - lock->l_start = 0; - lock->l_whence = SEEK_SET; - lock->l_len = 0; /* Whole file */ - lock->l_pid = (uint64_t)(unsigned long)frame->root; - lock->l_owner = client_lock->owner; - - frame->root->lk_owner = client_lock->owner; - - return 0; -} - -static int -construct_reserve_lock (client_posix_lock_t *client_lock, call_frame_t *frame, - struct gf_flock *lock) -{ - GF_ASSERT (client_lock); - - memcpy (lock, &(client_lock->user_flock), sizeof (struct gf_flock)); - - frame->root->lk_owner = client_lock->owner; - - return 0; -} - -uint64_t -decrement_reopen_fd_count (xlator_t *this, clnt_conf_t *conf) -{ - uint64_t fd_count = 0; - - LOCK (&conf->rec_lock); - { - fd_count = --(conf->reopen_fd_count); - } - UNLOCK (&conf->rec_lock); - - if (fd_count == 0) { - gf_log (this->name, GF_LOG_INFO, - "last fd open'd/lock-self-heal'd - notifying CHILD-UP"); - client_set_lk_version (this); - client_notify_parents_child_up (this); - } - - return fd_count; -} - -int32_t -client_remove_reserve_lock_cbk (call_frame_t *frame, - void *cookie, - xlator_t *this, - int32_t op_ret, - int32_t op_errno, - struct gf_flock *lock) -{ - clnt_local_t *local = NULL; - clnt_conf_t *conf = NULL; - - uint64_t fd_count = 0; - - local = frame->local; - conf = this->private; - - if (op_ret < 0) { - gf_log (this->name, GF_LOG_WARNING, - "removing reserver lock on fd failed: %s", - strerror(op_errno)); - goto cleanup; - } - - gf_log (this->name, GF_LOG_DEBUG, - "Removing reserve lock was successful."); - -cleanup: - frame->local = NULL; - - client_mark_bad_fd (local->client_lock->fd, local->fdctx); - - destroy_client_lock (local->client_lock); - client_local_wipe (local); - STACK_DESTROY (frame->root); - - fd_count = decrement_reopen_fd_count (this, conf); - gf_log (this->name, GF_LOG_TRACE, - "Need to attempt lock recovery on %lld open fds", - (unsigned long long) fd_count); - return 0; -} - -static void -client_remove_reserve_lock (xlator_t *this, call_frame_t *frame, - client_posix_lock_t *lock) -{ - struct gf_flock unlock; - - construct_reserve_unlock (&unlock, frame, lock); - - STACK_WIND (frame, client_remove_reserve_lock_cbk, - this, this->fops->lk, - lock->fd, F_RESLK_UNLCK, &unlock); -} - -static client_posix_lock_t * -get_next_recovery_lock (xlator_t *this, clnt_local_t *local) -{ - client_posix_lock_t *lock = NULL; - - pthread_mutex_lock (&local->mutex); - { - if (list_empty (&local->lock_list)) { - gf_log (this->name, GF_LOG_DEBUG, - "lock-list empty"); - goto unlock; - } - - lock = list_entry ((local->lock_list).next, typeof (*lock), list); - list_del_init (&lock->list); - } -unlock: - pthread_mutex_unlock (&local->mutex); - - return lock; - -} - -int32_t -client_reserve_lock_cbk (call_frame_t *frame, - void *cookie, - xlator_t *this, - int32_t op_ret, - int32_t op_errno, - struct gf_flock *lock) -{ - - clnt_local_t *local = NULL; - clnt_conf_t *conf = NULL; - - uint64_t fd_count = 0; - - local = frame->local; - conf = this->private; - - /* Got the reserve lock. Check if lock is grantable and proceed - with the real lk call */ - - if (op_ret >= 0) { - /* Lock is grantable if flock reflects a successful getlk() call*/ - if (lock->l_type == F_UNLCK && lock->l_pid) { - gf_log (this->name, GF_LOG_INFO, - "Got the reservelk, but the lock is not grantable. "); - client_remove_reserve_lock (this, frame, local->client_lock); - goto out; - } - - gf_log (this->name, GF_LOG_DEBUG, "reserve lock succeeded"); - client_send_recovery_lock (frame, this, local->client_lock); - goto out; - } - - /* Somebody else has a reserve lk. Lock conflict detected. - Mark fd as bad */ - - gf_log (this->name, GF_LOG_WARNING, - "reservelk OP failed. aborting lock recovery"); - - client_mark_bad_fd (local->client_lock->fd, - local->fdctx); - destroy_client_lock (local->client_lock); - frame->local = NULL; - client_local_wipe (local); - STACK_DESTROY (frame->root); - - fd_count = decrement_reopen_fd_count (this, conf); - gf_log (this->name, GF_LOG_DEBUG, - "need to attempt lock recovery on %"PRIu64" open fds", - fd_count); - -out: - return 0; -} - -int32_t -client_recovery_lock_cbk (call_frame_t *frame, - void *cookie, - xlator_t *this, - int32_t op_ret, - int32_t op_errno, - struct gf_flock *lock) -{ - clnt_local_t *local = NULL; - clnt_fd_ctx_t *fdctx = NULL; - clnt_conf_t *conf = NULL; - client_posix_lock_t *next_lock = NULL; - - struct gf_flock reserve_flock; - uint64_t fd_count = 0; - - local = frame->local; - conf = this->private; - - if (op_ret < 0) { - gf_log (this->name, GF_LOG_ERROR, - "lock recovery failed: %s", - strerror(op_errno)); - - client_mark_bad_fd (local->client_lock->fd, - local->fdctx); - goto cleanup; - - /* Lock recovered. Continue with reserve lock for next lock */ - } else { - gf_log (this->name, GF_LOG_DEBUG, - "lock recovered successfully - continuing with next lock."); - - next_lock = get_next_recovery_lock (this, local); - if (!next_lock) { - gf_log (this->name, GF_LOG_DEBUG, - "all locks recovered on fd"); - goto cleanup; - } - - construct_reserve_lock (next_lock, frame, &reserve_flock); - local->fdctx = fdctx; - local->client_lock = next_lock; - - STACK_WIND (frame, client_reserve_lock_cbk, - this, this->fops->lk, - next_lock->fd, F_RESLK_LCK, &reserve_flock); - goto out; - - } - -cleanup: - - frame->local = NULL; - client_local_wipe (local); - - if (local->client_lock) - destroy_client_lock (local->client_lock); - - STACK_DESTROY (frame->root); - - fd_count = decrement_reopen_fd_count (this, conf); - - gf_log (this->name, GF_LOG_DEBUG, - "need to attempt lock recovery on %"PRIu64" open fds", - fd_count); - -out: - return 0; -} - -static int -client_send_recovery_lock (call_frame_t *frame, xlator_t *this, - client_posix_lock_t *lock) -{ - frame->root->lk_owner = lock->owner; - - /* Send all locks as F_SETLK to prevent the frame - from blocking if there is a conflict */ - - STACK_WIND (frame, client_recovery_lock_cbk, - this, this->fops->lk, - lock->fd, F_SETLK, - &(lock->user_flock)); - - return 0; -} - -static int -client_lockrec_init (clnt_fd_ctx_t *fdctx, clnt_local_t *local) -{ - - INIT_LIST_HEAD (&local->lock_list); - pthread_mutex_init (&local->mutex, NULL); - - pthread_mutex_lock (&fdctx->mutex); - { - list_splice_init (&fdctx->lock_list, &local->lock_list); - } - pthread_mutex_unlock (&fdctx->mutex); - - return 0; -} - - -int -client_attempt_lock_recovery (xlator_t *this, clnt_fd_ctx_t *fdctx) -{ - call_frame_t *frame = NULL; - clnt_local_t *local = NULL; - client_posix_lock_t *lock = NULL; - - struct gf_flock reserve_flock; - int ret = 0; - - local = mem_get0 (this->local_pool); - if (!local) { - ret = -ENOMEM; - goto out; - } - - client_lockrec_init (fdctx, local); - - lock = get_next_recovery_lock (this, local); - if (!lock) { - gf_log (this->name, GF_LOG_DEBUG, - "no locks found on fd"); - ret = -1; - goto out; - } - - frame = create_frame (this, this->ctx->pool); - if (!frame) { - gf_log (this->name, GF_LOG_ERROR, - "creating of frame failed, lock recovery failed"); - ret = -1; - goto out; - } - - construct_reserve_lock (lock, frame, &reserve_flock); - - frame->local = local; - local->fdctx = fdctx; - local->client_lock = lock; - - STACK_WIND (frame, client_reserve_lock_cbk, - this, this->fops->lk, - lock->fd, F_RESLK_LCK, &reserve_flock); - -out: - return ret; - - -} - int32_t client_dump_locks (char *name, inode_t *inode, dict_t *dict) diff --git a/xlators/protocol/client/src/client-mem-types.h b/xlators/protocol/client/src/client-mem-types.h index e6e2c8e9f..f6573da2d 100644 --- a/xlators/protocol/client/src/client-mem-types.h +++ b/xlators/protocol/client/src/client-mem-types.h @@ -1,20 +1,11 @@ /* - Copyright (c) 2010-2011 Gluster, Inc. <http://www.gluster.com> - This file is part of GlusterFS. + Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com> + This file is part of GlusterFS. - GlusterFS is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - GlusterFS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see - <http://www.gnu.org/licenses/>. + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. */ diff --git a/xlators/protocol/client/src/client3_1-fops.c b/xlators/protocol/client/src/client-rpc-fops.c index fa9b93039..6355450c3 100644 --- a/xlators/protocol/client/src/client3_1-fops.c +++ b/xlators/protocol/client/src/client-rpc-fops.c @@ -1,20 +1,11 @@ /* - Copyright (c) 2010-2011 Gluster, Inc. <http://www.gluster.com> + Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com> This file is part of GlusterFS. - GlusterFS is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - GlusterFS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see - <http://www.gnu.org/licenses/>. + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. */ #ifndef _CONFIG_H @@ -29,7 +20,7 @@ int32_t client3_getspec (call_frame_t *frame, xlator_t *this, void *data); void client_start_ping (void *data); -rpc_clnt_prog_t clnt3_1_fop_prog; +rpc_clnt_prog_t clnt3_3_fop_prog; int @@ -117,11 +108,11 @@ client_submit_vec_request (xlator_t *this, void *req, call_frame_t *frame, if (start_ping) client_start_ping ((void *) this); - if (new_iobref != NULL) { + if (new_iobref) iobref_unref (new_iobref); - } - iobuf_unref (iobuf); + if (iobuf) + iobuf_unref (iobuf); return ret; @@ -129,11 +120,11 @@ unwind: rpcreq.rpc_status = -1; cbkfn (&rpcreq, NULL, 0, frame); - if (new_iobref != NULL) { + if (new_iobref) iobref_unref (new_iobref); - } - iobuf_unref (iobuf); + if (iobuf) + iobuf_unref (iobuf); return ret; } @@ -141,7 +132,7 @@ unwind: /* CBK */ int -client3_1_symlink_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_symlink_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { call_frame_t *frame = NULL; @@ -153,6 +144,7 @@ client3_1_symlink_cbk (struct rpc_req *req, struct iovec *iov, int count, clnt_local_t *local = NULL; inode_t *inode = NULL; xlator_t *this = NULL; + dict_t *xdata = NULL; this = THIS; @@ -181,24 +173,36 @@ client3_1_symlink_cbk (struct rpc_req *req, struct iovec *iov, int count, gf_stat_to_iatt (&rsp.postparent, &postparent); } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: if (rsp.op_ret == -1) { + /* no need to print the gfid, because it will be null, since + * symlink operation failed. + */ gf_log (this->name, GF_LOG_WARNING, - "remote operation failed: %s. Path: %s", + "remote operation failed: %s. Path: (%s to %s)", strerror (gf_error_to_errno (rsp.op_errno)), - (local) ? local->loc.path : "--"); + local->loc.path, local->loc2.path); } CLIENT_STACK_UNWIND (symlink, frame, rsp.op_ret, gf_error_to_errno (rsp.op_errno), inode, &stbuf, - &preparent, &postparent); + &preparent, &postparent, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); return 0; } int -client3_1_mknod_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_mknod_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { call_frame_t *frame = NULL; @@ -210,6 +214,7 @@ client3_1_mknod_cbk (struct rpc_req *req, struct iovec *iov, int count, clnt_local_t *local = NULL; inode_t *inode = NULL; xlator_t *this = NULL; + dict_t *xdata = NULL; this = THIS; @@ -239,22 +244,32 @@ client3_1_mknod_cbk (struct rpc_req *req, struct iovec *iov, int count, gf_stat_to_iatt (&rsp.postparent, &postparent); } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s. Path: %s", strerror (gf_error_to_errno (rsp.op_errno)), - (local) ? local->loc.path : "--"); + local->loc.path); } CLIENT_STACK_UNWIND (mknod, frame, rsp.op_ret, gf_error_to_errno (rsp.op_errno), inode, - &stbuf, &preparent, &postparent); + &stbuf, &preparent, &postparent, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); + return 0; } int -client3_1_mkdir_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_mkdir_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { call_frame_t *frame = NULL; @@ -266,6 +281,7 @@ client3_1_mkdir_cbk (struct rpc_req *req, struct iovec *iov, int count, clnt_local_t *local = NULL; inode_t *inode = NULL; xlator_t *this = NULL; + dict_t *xdata = NULL; this = THIS; @@ -294,33 +310,116 @@ client3_1_mkdir_cbk (struct rpc_req *req, struct iovec *iov, int count, gf_stat_to_iatt (&rsp.postparent, &postparent); } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s. Path: %s", strerror (gf_error_to_errno (rsp.op_errno)), - (local) ? local->loc.path : "--"); + local->loc.path); } CLIENT_STACK_UNWIND (mkdir, frame, rsp.op_ret, gf_error_to_errno (rsp.op_errno), inode, - &stbuf, &preparent, &postparent); + &stbuf, &preparent, &postparent, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); return 0; } int -client3_1_open_cbk (struct rpc_req *req, struct iovec *iov, int count, +_copy_gfid_from_inode_holders (uuid_t gfid, loc_t *loc, fd_t *fd) +{ + int ret = 0; + + if (fd && fd->inode && !uuid_is_null (fd->inode->gfid)) { + uuid_copy (gfid, fd->inode->gfid); + goto out; + } + + if (!loc) { + GF_ASSERT (0); + ret = -1; + goto out; + } + + if (loc->inode && !uuid_is_null (loc->inode->gfid)) { + uuid_copy (gfid, loc->inode->gfid); + } else if (!uuid_is_null (loc->gfid)) { + uuid_copy (gfid, loc->gfid); + } else { + GF_ASSERT (0); + ret = -1; + } +out: + return ret; +} + +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 ret = 0; + uuid_t gfid = {0}; + clnt_conf_t *conf = NULL; + clnt_fd_ctx_t *fdctx = NULL; + + conf = this->private; + ret = _copy_gfid_from_inode_holders (gfid, loc, fd); + if (ret) { + ret = -EINVAL; + goto out; + } + + fdctx = GF_CALLOC (1, sizeof (*fdctx), + gf_client_mt_clnt_fdctx_t); + if (!fdctx) { + ret = -ENOMEM; + goto out; + } + + uuid_copy (fdctx->gfid, gfid); + fdctx->is_dir = is_dir; + fdctx->remote_fd = remote_fd; + fdctx->flags = flags; + fdctx->lk_ctx = fd_lk_ctx_ref (fd->lk_ctx); + fdctx->lk_heal_state = GF_LK_HEAL_DONE; + fdctx->reopen_done = client_default_reopen_done; + + INIT_LIST_HEAD (&fdctx->sfd_pos); + INIT_LIST_HEAD (&fdctx->lock_list); + + this_fd_set_ctx (fd, this, loc, fdctx); + + pthread_mutex_lock (&conf->lock); + { + list_add_tail (&fdctx->sfd_pos, &conf->saved_fds); + } + pthread_mutex_unlock (&conf->lock); +out: + return ret; +} + +int +client3_3_open_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { clnt_local_t *local = NULL; clnt_conf_t *conf = NULL; - clnt_fd_ctx_t *fdctx = NULL; call_frame_t *frame = NULL; fd_t *fd = NULL; int ret = 0; gfs3_open_rsp rsp = {0,}; - xlator_t *this = NULL; + xlator_t *this = NULL; + dict_t *xdata = NULL; + this = THIS; @@ -344,57 +443,50 @@ client3_1_open_cbk (struct rpc_req *req, struct iovec *iov, int count, } if (-1 != rsp.op_ret) { - fdctx = GF_CALLOC (1, sizeof (*fdctx), - gf_client_mt_clnt_fdctx_t); - if (!fdctx) { + ret = client_add_fd_to_saved_fds (frame->this, fd, &local->loc, + local->flags, rsp.fd, 0); + if (ret) { rsp.op_ret = -1; - rsp.op_errno = ENOMEM; + rsp.op_errno = -ret; goto out; } - - fdctx->remote_fd = rsp.fd; - fdctx->inode = inode_ref (fd->inode); - fdctx->flags = local->flags; - fdctx->wbflags = local->wbflags; - fdctx->lk_ctx = fd_lk_ctx_ref (fd->lk_ctx); - fdctx->lk_heal_state = GF_LK_HEAL_DONE; - - INIT_LIST_HEAD (&fdctx->sfd_pos); - INIT_LIST_HEAD (&fdctx->lock_list); - - this_fd_set_ctx (fd, frame->this, &local->loc, fdctx); - - pthread_mutex_lock (&conf->lock); - { - list_add_tail (&fdctx->sfd_pos, &conf->saved_fds); - } - pthread_mutex_unlock (&conf->lock); } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, - "remote operation failed: %s. Path: %s", + "remote operation failed: %s. Path: %s (%s)", strerror (gf_error_to_errno (rsp.op_errno)), - (local) ? local->loc.path : "--"); + local->loc.path, loc_gfid_utoa (&local->loc)); } CLIENT_STACK_UNWIND (open, frame, rsp.op_ret, - gf_error_to_errno (rsp.op_errno), fd); + gf_error_to_errno (rsp.op_errno), fd, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); return 0; } int -client3_1_stat_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_stat_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { gfs3_stat_rsp rsp = {0,}; call_frame_t *frame = NULL; struct iatt iatt = {0,}; int ret = 0; - xlator_t *this = NULL; + xlator_t *this = NULL; + dict_t *xdata = NULL; + this = THIS; @@ -417,26 +509,38 @@ client3_1_stat_cbk (struct rpc_req *req, struct iovec *iov, int count, gf_stat_to_iatt (&rsp.stat, &iatt); } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", strerror (gf_error_to_errno (rsp.op_errno))); } + CLIENT_STACK_UNWIND (stat, frame, rsp.op_ret, - gf_error_to_errno (rsp.op_errno), &iatt); + gf_error_to_errno (rsp.op_errno), &iatt, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); return 0; } int -client3_1_readlink_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_readlink_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { gfs3_readlink_rsp rsp = {0,}; call_frame_t *frame = NULL; struct iatt iatt = {0,}; int ret = 0; - xlator_t *this = NULL; + xlator_t *this = NULL; + dict_t *xdata = NULL; + this = THIS; @@ -459,24 +563,35 @@ client3_1_readlink_cbk (struct rpc_req *req, struct iovec *iov, int count, gf_stat_to_iatt (&rsp.buf, &iatt); } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: if (rsp.op_ret == -1) { - gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", - strerror (gf_error_to_errno (rsp.op_errno))); + gf_log (this->name, (gf_error_to_errno(rsp.op_errno) == ENOENT)? + GF_LOG_DEBUG:GF_LOG_WARNING, "remote operation failed:" + " %s", strerror (gf_error_to_errno (rsp.op_errno))); } + CLIENT_STACK_UNWIND (readlink, frame, rsp.op_ret, - gf_error_to_errno (rsp.op_errno), rsp.path, &iatt); + gf_error_to_errno (rsp.op_errno), rsp.path, + &iatt, xdata); /* This is allocated by the libc while decoding RPC msg */ /* Hence no 'GF_FREE', but just 'free' */ - if (rsp.path) - free (rsp.path); + free (rsp.path); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); return 0; } int -client3_1_unlink_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_unlink_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { call_frame_t *frame = NULL; @@ -484,7 +599,9 @@ client3_1_unlink_cbk (struct rpc_req *req, struct iovec *iov, int count, struct iatt preparent = {0,}; struct iatt postparent = {0,}; int ret = 0; - xlator_t *this = NULL; + xlator_t *this = NULL; + dict_t *xdata = NULL; + this = THIS; @@ -508,20 +625,33 @@ client3_1_unlink_cbk (struct rpc_req *req, struct iovec *iov, int count, gf_stat_to_iatt (&rsp.postparent, &postparent); } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: if (rsp.op_ret == -1) { - gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", + gf_log (this->name, + ((gf_error_to_errno (rsp.op_errno) == ENOENT) + ? GF_LOG_DEBUG : GF_LOG_WARNING), + "remote operation failed: %s", strerror (gf_error_to_errno (rsp.op_errno))); } + CLIENT_STACK_UNWIND (unlink, frame, rsp.op_ret, gf_error_to_errno (rsp.op_errno), &preparent, - &postparent); + &postparent, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); return 0; } int -client3_1_rmdir_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_rmdir_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { gfs3_rmdir_rsp rsp = {0,}; @@ -529,7 +659,9 @@ client3_1_rmdir_cbk (struct rpc_req *req, struct iovec *iov, int count, struct iatt preparent = {0,}; struct iatt postparent = {0,}; int ret = 0; - xlator_t *this = NULL; + xlator_t *this = NULL; + dict_t *xdata = NULL; + this = THIS; @@ -553,6 +685,10 @@ client3_1_rmdir_cbk (struct rpc_req *req, struct iovec *iov, int count, gf_stat_to_iatt (&rsp.postparent, &postparent); } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", @@ -560,14 +696,19 @@ out: } CLIENT_STACK_UNWIND (rmdir, frame, rsp.op_ret, gf_error_to_errno (rsp.op_errno), &preparent, - &postparent); + &postparent, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); return 0; } int -client3_1_truncate_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_truncate_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { gfs3_truncate_rsp rsp = {0,}; @@ -575,7 +716,9 @@ client3_1_truncate_cbk (struct rpc_req *req, struct iovec *iov, int count, struct iatt prestat = {0,}; struct iatt poststat = {0,}; int ret = 0; - xlator_t *this = NULL; + xlator_t *this = NULL; + dict_t *xdata = NULL; + this = THIS; @@ -599,6 +742,10 @@ client3_1_truncate_cbk (struct rpc_req *req, struct iovec *iov, int count, gf_stat_to_iatt (&rsp.poststat, &poststat); } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", @@ -606,21 +753,28 @@ out: } CLIENT_STACK_UNWIND (truncate, frame, rsp.op_ret, gf_error_to_errno (rsp.op_errno), &prestat, - &poststat); + &poststat, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); return 0; } int -client3_1_statfs_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_statfs_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { gfs3_statfs_rsp rsp = {0,}; call_frame_t *frame = NULL; struct statvfs statfs = {0,}; int ret = 0; - xlator_t *this = NULL; + xlator_t *this = NULL; + dict_t *xdata = NULL; + this = THIS; @@ -643,20 +797,29 @@ client3_1_statfs_cbk (struct rpc_req *req, struct iovec *iov, int count, gf_statfs_to_statfs (&rsp.statfs, &statfs); } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", strerror (gf_error_to_errno (rsp.op_errno))); } CLIENT_STACK_UNWIND (statfs, frame, rsp.op_ret, - gf_error_to_errno (rsp.op_errno), &statfs); + gf_error_to_errno (rsp.op_errno), &statfs, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); return 0; } int -client3_1_writev_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_writev_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { gfs3_write_rsp rsp = {0,}; @@ -664,11 +827,15 @@ client3_1_writev_cbk (struct rpc_req *req, struct iovec *iov, int count, struct iatt prestat = {0,}; struct iatt poststat = {0,}; int ret = 0; - xlator_t *this = NULL; + 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; @@ -689,25 +856,39 @@ client3_1_writev_cbk (struct rpc_req *req, struct iovec *iov, int count, gf_stat_to_iatt (&rsp.poststat, &poststat); } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", strerror (gf_error_to_errno (rsp.op_errno))); + } else if (rsp.op_ret >= 0) { + if (local->attempt_reopen) + client_attempt_reopen (local->fd, this); } CLIENT_STACK_UNWIND (writev, frame, rsp.op_ret, gf_error_to_errno (rsp.op_errno), &prestat, - &poststat); + &poststat, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); return 0; } int -client3_1_flush_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_flush_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { call_frame_t *frame = NULL; clnt_local_t *local = NULL; - xlator_t *this = NULL; + xlator_t *this = NULL; + dict_t *xdata = NULL; + gf_common_rsp rsp = {0,}; int ret = 0; @@ -736,6 +917,10 @@ client3_1_flush_cbk (struct rpc_req *req, struct iovec *iov, int count, lkowner_utoa (&local->owner), ret); } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, @@ -743,13 +928,18 @@ out: strerror (gf_error_to_errno (rsp.op_errno))); } CLIENT_STACK_UNWIND (flush, frame, rsp.op_ret, - gf_error_to_errno (rsp.op_errno)); + gf_error_to_errno (rsp.op_errno), xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); return 0; } int -client3_1_fsync_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_fsync_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { gfs3_fsync_rsp rsp = {0,}; @@ -757,7 +947,9 @@ client3_1_fsync_cbk (struct rpc_req *req, struct iovec *iov, int count, struct iatt prestat = {0,}; struct iatt poststat = {0,}; int ret = 0; - xlator_t *this = NULL; + xlator_t *this = NULL; + dict_t *xdata = NULL; + this = THIS; @@ -782,6 +974,10 @@ client3_1_fsync_cbk (struct rpc_req *req, struct iovec *iov, int count, gf_stat_to_iatt (&rsp.poststat, &poststat); } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", @@ -789,19 +985,26 @@ out: } CLIENT_STACK_UNWIND (fsync, frame, rsp.op_ret, gf_error_to_errno (rsp.op_errno), &prestat, - &poststat); + &poststat, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); return 0; } int -client3_1_setxattr_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_setxattr_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { - call_frame_t *frame = NULL; - gf_common_rsp rsp = {0,}; - int ret = 0; - xlator_t *this = NULL; + call_frame_t *frame = NULL; + gf_common_rsp rsp = {0,}; + int ret = 0; + xlator_t *this = NULL; + dict_t *xdata = NULL; + int op_errno = EINVAL; this = THIS; @@ -821,19 +1024,30 @@ client3_1_setxattr_cbk (struct rpc_req *req, struct iovec *iov, int count, goto out; } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: + op_errno = gf_error_to_errno (rsp.op_errno); if (rsp.op_ret == -1) { - gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", - strerror (gf_error_to_errno (rsp.op_errno))); + gf_log (this->name, ((op_errno == ENOTSUP) ? + GF_LOG_DEBUG : GF_LOG_WARNING), + "remote operation failed: %s", + strerror (op_errno)); } - CLIENT_STACK_UNWIND (setxattr, frame, rsp.op_ret, - gf_error_to_errno (rsp.op_errno)); + CLIENT_STACK_UNWIND (setxattr, frame, rsp.op_ret, op_errno, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); return 0; } int -client3_1_getxattr_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_getxattr_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { call_frame_t *frame = NULL; @@ -842,7 +1056,9 @@ client3_1_getxattr_cbk (struct rpc_req *req, struct iovec *iov, int count, gfs3_getxattr_rsp rsp = {0,}; int ret = 0; clnt_local_t *local = NULL; - xlator_t *this = NULL; + xlator_t *this = NULL; + dict_t *xdata = NULL; + this = THIS; @@ -871,22 +1087,31 @@ client3_1_getxattr_cbk (struct rpc_req *req, struct iovec *iov, int count, op_errno, out); } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + op_errno, out); + out: if (rsp.op_ret == -1) { - gf_log (this->name, GF_LOG_WARNING, - "remote operation failed: %s. Path: %s", + gf_log (this->name, (((op_errno == ENOTSUP) || + (op_errno == ENODATA) || + (op_errno == ENOENT)) ? + GF_LOG_DEBUG : GF_LOG_WARNING), + "remote operation failed: %s. Path: %s (%s). Key: %s", strerror (op_errno), - (local) ? local->loc.path : "--"); + local->loc.path, loc_gfid_utoa (&local->loc), + (local->name) ? local->name : "(null)"); } - CLIENT_STACK_UNWIND (getxattr, frame, rsp.op_ret, op_errno, dict); + CLIENT_STACK_UNWIND (getxattr, frame, rsp.op_ret, op_errno, dict, xdata); - if (rsp.dict.dict_val) { - /* don't use GF_FREE, this memory was allocated by libc - */ - free (rsp.dict.dict_val); - rsp.dict.dict_val = NULL; - } + /* don't use GF_FREE, this memory was allocated by libc */ + free (rsp.dict.dict_val); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); if (dict) dict_unref (dict); @@ -895,7 +1120,7 @@ out: } int -client3_1_fgetxattr_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_fgetxattr_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { call_frame_t *frame = NULL; @@ -904,7 +1129,9 @@ client3_1_fgetxattr_cbk (struct rpc_req *req, struct iovec *iov, int count, int ret = 0; int op_errno = EINVAL; clnt_local_t *local = NULL; - xlator_t *this = NULL; + xlator_t *this = NULL; + dict_t *xdata = NULL; + this = THIS; @@ -931,20 +1158,26 @@ client3_1_fgetxattr_cbk (struct rpc_req *req, struct iovec *iov, int count, (rsp.dict.dict_len), rsp.op_ret, op_errno, out); } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + op_errno, out); + out: if (rsp.op_ret == -1) { - gf_log (this->name, GF_LOG_WARNING, + gf_log (this->name, ((op_errno == ENOTSUP) ? + GF_LOG_DEBUG : GF_LOG_WARNING), "remote operation failed: %s", strerror (op_errno)); } - CLIENT_STACK_UNWIND (fgetxattr, frame, rsp.op_ret, op_errno, dict); - if (rsp.dict.dict_val) { - /* don't use GF_FREE, this memory was allocated by libc - */ - free (rsp.dict.dict_val); - rsp.dict.dict_val = NULL; - } + CLIENT_STACK_UNWIND (fgetxattr, frame, rsp.op_ret, op_errno, dict, xdata); + + free (rsp.dict.dict_val); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); if (dict) dict_unref (dict); @@ -953,13 +1186,14 @@ out: } int -client3_1_removexattr_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_removexattr_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { call_frame_t *frame = NULL; gf_common_rsp rsp = {0,}; int ret = 0; - xlator_t *this = NULL; + xlator_t *this = NULL; + dict_t *xdata = NULL; this = THIS; @@ -979,25 +1213,37 @@ client3_1_removexattr_cbk (struct rpc_req *req, struct iovec *iov, int count, goto out; } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", strerror (gf_error_to_errno (rsp.op_errno))); } + CLIENT_STACK_UNWIND (removexattr, frame, rsp.op_ret, - gf_error_to_errno (rsp.op_errno)); + gf_error_to_errno (rsp.op_errno), xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); return 0; } int -client3_1_fremovexattr_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_fremovexattr_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { call_frame_t *frame = NULL; gf_common_rsp rsp = {0,}; int ret = 0; - xlator_t *this = NULL; + xlator_t *this = NULL; + dict_t *xdata = NULL; + this = THIS; @@ -1017,25 +1263,36 @@ client3_1_fremovexattr_cbk (struct rpc_req *req, struct iovec *iov, int count, goto out; } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", strerror (gf_error_to_errno (rsp.op_errno))); } CLIENT_STACK_UNWIND (fremovexattr, frame, rsp.op_ret, - gf_error_to_errno (rsp.op_errno)); + gf_error_to_errno (rsp.op_errno), xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); return 0; } int -client3_1_fsyncdir_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_fsyncdir_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { call_frame_t *frame = NULL; gf_common_rsp rsp = {0,}; int ret = 0; - xlator_t *this = NULL; + xlator_t *this = NULL; + dict_t *xdata = NULL; + this = THIS; @@ -1054,25 +1311,36 @@ client3_1_fsyncdir_cbk (struct rpc_req *req, struct iovec *iov, int count, goto out; } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", strerror (gf_error_to_errno (rsp.op_errno))); } CLIENT_STACK_UNWIND (fsyncdir, frame, rsp.op_ret, - gf_error_to_errno (rsp.op_errno)); + gf_error_to_errno (rsp.op_errno), xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); return 0; } int -client3_1_access_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_access_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { call_frame_t *frame = NULL; gf_common_rsp rsp = {0,}; int ret = 0; - xlator_t *this = NULL; + xlator_t *this = NULL; + dict_t *xdata = NULL; + this = THIS; @@ -1091,20 +1359,29 @@ client3_1_access_cbk (struct rpc_req *req, struct iovec *iov, int count, goto out; } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", strerror (gf_error_to_errno (rsp.op_errno))); } CLIENT_STACK_UNWIND (access, frame, rsp.op_ret, - gf_error_to_errno (rsp.op_errno)); + gf_error_to_errno (rsp.op_errno), xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); return 0; } int -client3_1_ftruncate_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_ftruncate_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { gfs3_ftruncate_rsp rsp = {0,}; @@ -1112,7 +1389,9 @@ client3_1_ftruncate_cbk (struct rpc_req *req, struct iovec *iov, int count, struct iatt prestat = {0,}; struct iatt poststat = {0,}; int ret = 0; - xlator_t *this = NULL; + xlator_t *this = NULL; + dict_t *xdata = NULL; + this = THIS; @@ -1136,6 +1415,10 @@ client3_1_ftruncate_cbk (struct rpc_req *req, struct iovec *iov, int count, gf_stat_to_iatt (&rsp.poststat, &poststat); } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", @@ -1143,20 +1426,27 @@ out: } CLIENT_STACK_UNWIND (ftruncate, frame, rsp.op_ret, gf_error_to_errno (rsp.op_errno), &prestat, - &poststat); + &poststat, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); return 0; } int -client3_1_fstat_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_fstat_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { gfs3_fstat_rsp rsp = {0,}; call_frame_t *frame = NULL; struct iatt stat = {0,}; int ret = 0; - xlator_t *this = NULL; + xlator_t *this = NULL; + dict_t *xdata = NULL; + this = THIS; @@ -1179,26 +1469,37 @@ client3_1_fstat_cbk (struct rpc_req *req, struct iovec *iov, int count, gf_stat_to_iatt (&rsp.stat, &stat); } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", strerror (gf_error_to_errno (rsp.op_errno))); } CLIENT_STACK_UNWIND (fstat, frame, rsp.op_ret, - gf_error_to_errno (rsp.op_errno), &stat); + gf_error_to_errno (rsp.op_errno), &stat, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); return 0; } int -client3_1_inodelk_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_inodelk_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { call_frame_t *frame = NULL; gf_common_rsp rsp = {0,}; int ret = 0; - xlator_t *this = NULL; + xlator_t *this = NULL; + dict_t *xdata = NULL; + this = THIS; @@ -1217,6 +1518,10 @@ client3_1_inodelk_cbk (struct rpc_req *req, struct iovec *iov, int count, goto out; } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: if ((rsp.op_ret == -1) && (EAGAIN != gf_error_to_errno (rsp.op_errno))) { @@ -1224,23 +1529,31 @@ out: strerror (gf_error_to_errno (rsp.op_errno))); } CLIENT_STACK_UNWIND (inodelk, frame, rsp.op_ret, - gf_error_to_errno (rsp.op_errno)); + gf_error_to_errno (rsp.op_errno), xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); return 0; } int -client3_1_finodelk_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_finodelk_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { - call_frame_t *frame = NULL; - gf_common_rsp rsp = {0,}; - int ret = 0; - xlator_t *this = NULL; + call_frame_t *frame = NULL; + gf_common_rsp rsp = {0,}; + int ret = 0; + xlator_t *this = NULL; + dict_t *xdata = NULL; + clnt_local_t *local = NULL; - this = THIS; frame = myframe; + this = frame->this; + local = frame->local; if (-1 == req->rpc_status) { rsp.op_ret = -1; @@ -1255,26 +1568,40 @@ client3_1_finodelk_cbk (struct rpc_req *req, struct iovec *iov, int count, goto out; } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: if ((rsp.op_ret == -1) && (EAGAIN != gf_error_to_errno (rsp.op_errno))) { gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", strerror (gf_error_to_errno (rsp.op_errno))); + } else if (rsp.op_ret == 0) { + if (local->attempt_reopen) + client_attempt_reopen (local->fd, this); } CLIENT_STACK_UNWIND (finodelk, frame, rsp.op_ret, - gf_error_to_errno (rsp.op_errno)); + gf_error_to_errno (rsp.op_errno), xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); return 0; } int -client3_1_entrylk_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_entrylk_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { call_frame_t *frame = NULL; gf_common_rsp rsp = {0,}; int ret = 0; - xlator_t *this = NULL; + xlator_t *this = NULL; + dict_t *xdata = NULL; + this = THIS; @@ -1293,27 +1620,38 @@ client3_1_entrylk_cbk (struct rpc_req *req, struct iovec *iov, int count, goto out; } -out: + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); +out: if ((rsp.op_ret == -1) && (EAGAIN != gf_error_to_errno (rsp.op_errno))) { gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", strerror (gf_error_to_errno (rsp.op_errno))); } + CLIENT_STACK_UNWIND (entrylk, frame, rsp.op_ret, - gf_error_to_errno (rsp.op_errno)); + gf_error_to_errno (rsp.op_errno), xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); return 0; } int -client3_1_fentrylk_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_fentrylk_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { call_frame_t *frame = NULL; gf_common_rsp rsp = {0,}; int ret = 0; - xlator_t *this = NULL; + xlator_t *this = NULL; + dict_t *xdata = NULL; + this = THIS; @@ -1332,20 +1670,30 @@ client3_1_fentrylk_cbk (struct rpc_req *req, struct iovec *iov, int count, goto out; } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: if ((rsp.op_ret == -1) && (EAGAIN != gf_error_to_errno (rsp.op_errno))) { gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", strerror (gf_error_to_errno (rsp.op_errno))); } + CLIENT_STACK_UNWIND (fentrylk, frame, rsp.op_ret, - gf_error_to_errno (rsp.op_errno)); + gf_error_to_errno (rsp.op_errno), xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); return 0; } int -client3_1_xattrop_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_xattrop_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { call_frame_t *frame = NULL; @@ -1354,7 +1702,9 @@ client3_1_xattrop_cbk (struct rpc_req *req, struct iovec *iov, int count, int ret = 0; int op_errno = EINVAL; clnt_local_t *local = NULL; - xlator_t *this = NULL; + xlator_t *this = NULL; + dict_t *xdata = NULL; + this = THIS; @@ -1382,23 +1732,27 @@ client3_1_xattrop_cbk (struct rpc_req *req, struct iovec *iov, int count, op_errno, out); } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + op_errno, out); + out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, - "remote operation failed: %s. Path: %s", + "remote operation failed: %s. Path: %s (%s)", strerror (gf_error_to_errno (rsp.op_errno)), - (local) ? local->loc.path : "--"); + local->loc.path, loc_gfid_utoa (&local->loc)); } CLIENT_STACK_UNWIND (xattrop, frame, rsp.op_ret, - gf_error_to_errno (op_errno), dict); + gf_error_to_errno (op_errno), dict, xdata); - if (rsp.dict.dict_val) { - /* don't use GF_FREE, this memory was allocated by libc - */ - free (rsp.dict.dict_val); - rsp.dict.dict_val = NULL; - } + free (rsp.dict.dict_val); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); if (dict) dict_unref (dict); @@ -1407,16 +1761,17 @@ out: } int -client3_1_fxattrop_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_fxattrop_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { call_frame_t *frame = NULL; dict_t *dict = NULL; + dict_t *xdata = NULL; gfs3_fxattrop_rsp rsp = {0,}; int ret = 0; int op_errno = 0; clnt_local_t *local = NULL; - xlator_t *this = NULL; + xlator_t *this = NULL; this = THIS; @@ -1444,22 +1799,29 @@ client3_1_fxattrop_cbk (struct rpc_req *req, struct iovec *iov, int count, op_errno, out); } + GF_PROTOCOL_DICT_UNSERIALIZE (frame->this, xdata, + (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), rsp.op_ret, + op_errno, out); out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", strerror (gf_error_to_errno (op_errno))); + } else if (rsp.op_ret == 0) { + if (local->attempt_reopen) + client_attempt_reopen (local->fd, this); } CLIENT_STACK_UNWIND (fxattrop, frame, rsp.op_ret, - gf_error_to_errno (op_errno), dict); + gf_error_to_errno (op_errno), dict, xdata); - if (rsp.dict.dict_val) { - /* don't use GF_FREE, this memory was allocated by libc - */ - free (rsp.dict.dict_val); - rsp.dict.dict_val = NULL; - } + free (rsp.dict.dict_val); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); if (dict) dict_unref (dict); @@ -1468,13 +1830,15 @@ out: } int -client3_1_fsetxattr_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_fsetxattr_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { - call_frame_t *frame = NULL; - gf_common_rsp rsp = {0,}; - int ret = 0; - xlator_t *this = NULL; + call_frame_t *frame = NULL; + gf_common_rsp rsp = {0,}; + int ret = 0; + xlator_t *this = NULL; + dict_t *xdata = NULL; + int op_errno = EINVAL; this = THIS; @@ -1493,19 +1857,31 @@ client3_1_fsetxattr_cbk (struct rpc_req *req, struct iovec *iov, int count, goto out; } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: + op_errno = gf_error_to_errno (rsp.op_errno); if (rsp.op_ret == -1) { - gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", - strerror (gf_error_to_errno (rsp.op_errno))); + gf_log (this->name, ((op_errno == ENOTSUP) ? + GF_LOG_DEBUG : GF_LOG_WARNING), + "remote operation failed: %s", + strerror (op_errno)); } - CLIENT_STACK_UNWIND (fsetxattr, frame, rsp.op_ret, - gf_error_to_errno (rsp.op_errno)); + + CLIENT_STACK_UNWIND (fsetxattr, frame, rsp.op_ret, op_errno, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); return 0; } int -client3_1_fsetattr_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_fsetattr_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { call_frame_t *frame = NULL; @@ -1513,7 +1889,9 @@ client3_1_fsetattr_cbk (struct rpc_req *req, struct iovec *iov, int count, struct iatt prestat = {0,}; struct iatt poststat = {0,}; int ret = 0; - xlator_t *this = NULL; + xlator_t *this = NULL; + dict_t *xdata = NULL; + this = THIS; @@ -1537,6 +1915,10 @@ client3_1_fsetattr_cbk (struct rpc_req *req, struct iovec *iov, int count, gf_stat_to_iatt (&rsp.statpost, &poststat); } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", @@ -1544,14 +1926,185 @@ out: } CLIENT_STACK_UNWIND (fsetattr, frame, rsp.op_ret, gf_error_to_errno (rsp.op_errno), &prestat, - &poststat); + &poststat, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); return 0; } +int +client3_3_fallocate_cbk (struct rpc_req *req, struct iovec *iov, int count, + void *myframe) +{ + call_frame_t *frame = NULL; + gfs3_fallocate_rsp rsp = {0,}; + struct iatt prestat = {0,}; + struct iatt poststat = {0,}; + int ret = 0; + xlator_t *this = NULL; + dict_t *xdata = NULL; + + + this = THIS; + + frame = myframe; + + 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_fallocate_rsp); + if (ret < 0) { + gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; + } + + if (-1 != rsp.op_ret) { + gf_stat_to_iatt (&rsp.statpre, &prestat); + gf_stat_to_iatt (&rsp.statpost, &poststat); + } + + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + +out: + if (rsp.op_ret == -1) { + gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } + CLIENT_STACK_UNWIND (fallocate, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno), &prestat, + &poststat, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); + + return 0; +} int -client3_1_setattr_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_discard_cbk(struct rpc_req *req, struct iovec *iov, int count, + void *myframe) +{ + call_frame_t *frame = NULL; + gfs3_discard_rsp rsp = {0,}; + struct iatt prestat = {0,}; + struct iatt poststat = {0,}; + int ret = 0; + xlator_t *this = NULL; + dict_t *xdata = NULL; + + this = THIS; + + frame = myframe; + + 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_discard_rsp); + if (ret < 0) { + gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; + } + + if (-1 != rsp.op_ret) { + gf_stat_to_iatt (&rsp.statpre, &prestat); + gf_stat_to_iatt (&rsp.statpost, &poststat); + } + + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + +out: + if (rsp.op_ret == -1) { + gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } + CLIENT_STACK_UNWIND (discard, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno), &prestat, + &poststat, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); + + return 0; +} + +int +client3_3_zerofill_cbk(struct rpc_req *req, struct iovec *iov, int count, + void *myframe) +{ + call_frame_t *frame = NULL; + gfs3_zerofill_rsp rsp = {0,}; + struct iatt prestat = {0,}; + struct iatt poststat = {0,}; + int ret = 0; + xlator_t *this = NULL; + dict_t *xdata = NULL; + + this = THIS; + + frame = myframe; + + 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_zerofill_rsp); + if (ret < 0) { + gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed"); + rsp.op_ret = -1; + rsp.op_errno = EINVAL; + goto out; + } + + if (-1 != rsp.op_ret) { + gf_stat_to_iatt (&rsp.statpre, &prestat); + gf_stat_to_iatt (&rsp.statpost, &poststat); + } + + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + +out: + if (rsp.op_ret == -1) { + gf_log (this->name, GF_LOG_WARNING, + "remote operation failed: %s", + strerror (gf_error_to_errno (rsp.op_errno))); + } + CLIENT_STACK_UNWIND (zerofill, frame, rsp.op_ret, + gf_error_to_errno (rsp.op_errno), &prestat, + &poststat, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); + + return 0; +} + +int +client3_3_setattr_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { call_frame_t *frame = NULL; @@ -1559,7 +2112,9 @@ client3_1_setattr_cbk (struct rpc_req *req, struct iovec *iov, int count, struct iatt prestat = {0,}; struct iatt poststat = {0,}; int ret = 0; - xlator_t *this = NULL; + xlator_t *this = NULL; + dict_t *xdata = NULL; + this = THIS; @@ -1584,6 +2139,10 @@ client3_1_setattr_cbk (struct rpc_req *req, struct iovec *iov, int count, gf_stat_to_iatt (&rsp.statpost, &poststat); } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", @@ -1591,13 +2150,18 @@ out: } CLIENT_STACK_UNWIND (setattr, frame, rsp.op_ret, gf_error_to_errno (rsp.op_errno), &prestat, - &poststat); + &poststat, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); return 0; } int -client3_1_create_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_create_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { call_frame_t *frame = NULL; @@ -1608,16 +2172,14 @@ client3_1_create_cbk (struct rpc_req *req, struct iovec *iov, int count, struct iatt postparent = {0, }; int32_t ret = -1; clnt_local_t *local = NULL; - clnt_conf_t *conf = NULL; - clnt_fd_ctx_t *fdctx = NULL; gfs3_create_rsp rsp = {0,}; - xlator_t *this = NULL; + xlator_t *this = NULL; + dict_t *xdata = NULL; this = THIS; frame = myframe; local = frame->local; - conf = frame->this->private; fd = local->fd; inode = local->loc.inode; @@ -1640,57 +2202,51 @@ client3_1_create_cbk (struct rpc_req *req, struct iovec *iov, int count, gf_stat_to_iatt (&rsp.preparent, &preparent); gf_stat_to_iatt (&rsp.postparent, &postparent); - - fdctx = GF_CALLOC (1, sizeof (*fdctx), - gf_client_mt_clnt_fdctx_t); - if (!fdctx) { + uuid_copy (local->loc.gfid, stbuf.ia_gfid); + ret = client_add_fd_to_saved_fds (frame->this, fd, &local->loc, + local->flags, rsp.fd, 0); + if (ret) { rsp.op_ret = -1; - rsp.op_errno = ENOMEM; + rsp.op_errno = -ret; goto out; } - - fdctx->remote_fd = rsp.fd; - fdctx->inode = inode_ref (inode); - fdctx->flags = local->flags; - fdctx->lk_ctx = fd_lk_ctx_ref (fd->lk_ctx); - fdctx->lk_heal_state = GF_LK_HEAL_DONE; - - INIT_LIST_HEAD (&fdctx->sfd_pos); - INIT_LIST_HEAD (&fdctx->lock_list); - - this_fd_set_ctx (fd, frame->this, &local->loc, fdctx); - - pthread_mutex_lock (&conf->lock); - { - list_add_tail (&fdctx->sfd_pos, &conf->saved_fds); - } - pthread_mutex_unlock (&conf->lock); } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s. Path: %s", strerror (gf_error_to_errno (rsp.op_errno)), - (local) ? local->loc.path : "--"); + local->loc.path); } CLIENT_STACK_UNWIND (create, frame, rsp.op_ret, gf_error_to_errno (rsp.op_errno), fd, inode, - &stbuf, &preparent, &postparent); + &stbuf, &preparent, &postparent, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); return 0; } int -client3_1_rchecksum_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_rchecksum_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { call_frame_t *frame = NULL; gfs3_rchecksum_rsp rsp = {0,}; int ret = 0; - xlator_t *this = NULL; + xlator_t *this = NULL; + dict_t *xdata = NULL; + this = THIS; @@ -1710,6 +2266,10 @@ client3_1_rchecksum_cbk (struct rpc_req *req, struct iovec *iov, int count, goto out; } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", @@ -1718,7 +2278,8 @@ out: CLIENT_STACK_UNWIND (rchecksum, frame, rsp.op_ret, gf_error_to_errno (rsp.op_errno), rsp.weak_checksum, - (uint8_t *)rsp.strong_checksum.strong_checksum_val); + (uint8_t *)rsp.strong_checksum.strong_checksum_val, + xdata); if (rsp.strong_checksum.strong_checksum_val) { /* This is allocated by the libc while decoding RPC msg */ @@ -1726,11 +2287,16 @@ out: free (rsp.strong_checksum.strong_checksum_val); } + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); + return 0; } int -client3_1_lk_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_lk_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { call_frame_t *frame = NULL; @@ -1738,7 +2304,8 @@ client3_1_lk_cbk (struct rpc_req *req, struct iovec *iov, int count, struct gf_flock lock = {0,}; gfs3_lk_rsp rsp = {0,}; int ret = 0; - xlator_t *this = NULL; + xlator_t *this = NULL; + dict_t *xdata = NULL; this = THIS; @@ -1777,6 +2344,10 @@ client3_1_lk_cbk (struct rpc_req *req, struct iovec *iov, int count, } */ + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: if ((rsp.op_ret == -1) && (EAGAIN != gf_error_to_errno (rsp.op_errno))) { @@ -1786,21 +2357,29 @@ out: } CLIENT_STACK_UNWIND (lk, frame, rsp.op_ret, - gf_error_to_errno (rsp.op_errno), &lock); + gf_error_to_errno (rsp.op_errno), &lock, xdata); + + free (rsp.xdata.xdata_val); + + free (rsp.flock.lk_owner.lk_owner_val); + + if (xdata) + dict_unref (xdata); return 0; } int -client3_1_readdir_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_readdir_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { - call_frame_t *frame = NULL; - gfs3_readdir_rsp rsp = {0,}; - int32_t ret = 0; - clnt_local_t *local = NULL; - gf_dirent_t entries; - xlator_t *this = NULL; + call_frame_t *frame = NULL; + gfs3_readdir_rsp rsp = {0,}; + int32_t ret = 0; + clnt_local_t *local = NULL; + gf_dirent_t entries; + xlator_t *this = NULL; + dict_t *xdata = NULL; this = THIS; @@ -1826,6 +2405,11 @@ client3_1_readdir_cbk (struct rpc_req *req, struct iovec *iov, int count, unserialize_rsp_dirent (&rsp, &entries); } + GF_PROTOCOL_DICT_UNSERIALIZE (frame->this, xdata, + (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), rsp.op_ret, + rsp.op_errno, out); + out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, @@ -1834,12 +2418,17 @@ out: local->cmd); } CLIENT_STACK_UNWIND (readdir, frame, rsp.op_ret, - gf_error_to_errno (rsp.op_errno), &entries); + gf_error_to_errno (rsp.op_errno), &entries, xdata); if (rsp.op_ret != -1) { gf_dirent_free (&entries); } + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); + clnt_readdir_rsp_cleanup (&rsp); return 0; @@ -1847,7 +2436,7 @@ out: int -client3_1_readdirp_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_readdirp_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { call_frame_t *frame = NULL; @@ -1856,6 +2445,7 @@ client3_1_readdirp_cbk (struct rpc_req *req, struct iovec *iov, int count, clnt_local_t *local = NULL; gf_dirent_t entries; xlator_t *this = NULL; + dict_t *xdata = NULL; this = THIS; @@ -1881,6 +2471,10 @@ client3_1_readdirp_cbk (struct rpc_req *req, struct iovec *iov, int count, unserialize_rsp_direntp (this, local->fd, &rsp, &entries); } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, @@ -1888,11 +2482,15 @@ out: strerror (gf_error_to_errno (rsp.op_errno))); } CLIENT_STACK_UNWIND (readdirp, frame, rsp.op_ret, - gf_error_to_errno (rsp.op_errno), &entries); + gf_error_to_errno (rsp.op_errno), &entries, xdata); if (rsp.op_ret != -1) { gf_dirent_free (&entries); } + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); clnt_readdirp_rsp_cleanup (&rsp); @@ -1901,7 +2499,7 @@ out: int -client3_1_rename_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_rename_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { call_frame_t *frame = NULL; @@ -1912,7 +2510,8 @@ client3_1_rename_cbk (struct rpc_req *req, struct iovec *iov, int count, struct iatt prenewparent = {0,}; struct iatt postnewparent = {0,}; int ret = 0; - xlator_t *this = NULL; + xlator_t *this = NULL; + dict_t *xdata = NULL; this = THIS; @@ -1942,6 +2541,10 @@ client3_1_rename_cbk (struct rpc_req *req, struct iovec *iov, int count, gf_stat_to_iatt (&rsp.postnewparent, &postnewparent); } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", @@ -1950,13 +2553,18 @@ out: CLIENT_STACK_UNWIND (rename, frame, rsp.op_ret, gf_error_to_errno (rsp.op_errno), &stbuf, &preoldparent, &postoldparent, - &prenewparent, &postnewparent); + &prenewparent, &postnewparent, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); return 0; } int -client3_1_link_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_link_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { call_frame_t *frame = NULL; @@ -1967,7 +2575,9 @@ client3_1_link_cbk (struct rpc_req *req, struct iovec *iov, int count, int ret = 0; clnt_local_t *local = NULL; inode_t *inode = NULL; - xlator_t *this = NULL; + xlator_t *this = NULL; + dict_t *xdata = NULL; + this = THIS; @@ -1997,34 +2607,43 @@ client3_1_link_cbk (struct rpc_req *req, struct iovec *iov, int count, gf_stat_to_iatt (&rsp.postparent, &postparent); } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, - "remote operation failed: %s. Path: %s", + "remote operation failed: %s (%s -> %s)", strerror (gf_error_to_errno (rsp.op_errno)), - (local) ? local->loc.path : "--"); + local->loc.path, local->loc2.path); } CLIENT_STACK_UNWIND (link, frame, rsp.op_ret, gf_error_to_errno (rsp.op_errno), inode, - &stbuf, &preparent, &postparent); + &stbuf, &preparent, &postparent, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); return 0; } int -client3_1_opendir_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_opendir_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { clnt_local_t *local = NULL; clnt_conf_t *conf = NULL; - clnt_fd_ctx_t *fdctx = NULL; - call_frame_t *frame = NULL; - fd_t *fd = NULL; + call_frame_t *frame = NULL; + fd_t *fd = NULL; int ret = 0; gfs3_opendir_rsp rsp = {0,}; - xlator_t *this = NULL; + xlator_t *this = NULL; + dict_t *xdata = NULL; this = THIS; @@ -2049,46 +2668,40 @@ client3_1_opendir_cbk (struct rpc_req *req, struct iovec *iov, int count, } if (-1 != rsp.op_ret) { - fdctx = GF_CALLOC (1, sizeof (*fdctx), - gf_client_mt_clnt_fdctx_t); - if (!fdctx) { + ret = client_add_fd_to_saved_fds (frame->this, fd, &local->loc, + 0, rsp.fd, 1); + if (ret) { rsp.op_ret = -1; - rsp.op_errno = ENOMEM; + rsp.op_errno = -ret; goto out; } - - fdctx->remote_fd = rsp.fd; - fdctx->inode = inode_ref (fd->inode); - fdctx->is_dir = 1; - - INIT_LIST_HEAD (&fdctx->sfd_pos); - INIT_LIST_HEAD (&fdctx->lock_list); - - this_fd_set_ctx (fd, frame->this, &local->loc, fdctx); - - pthread_mutex_lock (&conf->lock); - { - list_add_tail (&fdctx->sfd_pos, &conf->saved_fds); - } - pthread_mutex_unlock (&conf->lock); } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, - "remote operation failed: %s. Path: %s", + "remote operation failed: %s. Path: %s (%s)", strerror (gf_error_to_errno (rsp.op_errno)), - (local) ? local->loc.path : "--"); + local->loc.path, loc_gfid_utoa (&local->loc)); } CLIENT_STACK_UNWIND (opendir, frame, rsp.op_ret, - gf_error_to_errno (rsp.op_errno), fd); + gf_error_to_errno (rsp.op_errno), fd, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); return 0; } int -client3_1_lookup_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_lookup_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { clnt_local_t *local = NULL; @@ -2098,7 +2711,7 @@ client3_1_lookup_cbk (struct rpc_req *req, struct iovec *iov, int count, struct iatt stbuf = {0,}; struct iatt postparent = {0,}; int op_errno = EINVAL; - dict_t *xattr = NULL; + dict_t *xdata = NULL; inode_t *inode = NULL; xlator_t *this = NULL; @@ -2131,8 +2744,8 @@ client3_1_lookup_cbk (struct rpc_req *req, struct iovec *iov, int count, rsp.op_ret = -1; gf_stat_to_iatt (&rsp.stat, &stbuf); - GF_PROTOCOL_DICT_UNSERIALIZE (frame->this, xattr, (rsp.dict.dict_val), - (rsp.dict.dict_len), rsp.op_ret, + GF_PROTOCOL_DICT_UNSERIALIZE (frame->this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), rsp.op_ret, op_errno, out); if ((!uuid_is_null (inode->gfid)) @@ -2152,31 +2765,27 @@ out: /* any error other than ENOENT */ if (rsp.op_errno != ENOENT) gf_log (this->name, GF_LOG_WARNING, - "remote operation failed: %s. Path: %s", - strerror (rsp.op_errno), - (local) ? local->loc.path : "--"); + "remote operation failed: %s. Path: %s (%s)", + strerror (rsp.op_errno), local->loc.path, + loc_gfid_utoa (&local->loc)); else gf_log (this->name, GF_LOG_TRACE, "not found on remote node"); } CLIENT_STACK_UNWIND (lookup, frame, rsp.op_ret, rsp.op_errno, inode, - &stbuf, xattr, &postparent); + &stbuf, xdata, &postparent); - if (xattr) - dict_unref (xattr); + if (xdata) + dict_unref (xdata); - if (rsp.dict.dict_val) { - /* don't use GF_FREE, this memory was allocated by libc - */ - free (rsp.dict.dict_val); - } + free (rsp.xdata.xdata_val); return 0; } int -client3_1_readv_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_readv_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { call_frame_t *frame = NULL; @@ -2186,7 +2795,8 @@ client3_1_readv_cbk (struct rpc_req *req, struct iovec *iov, int count, gfs3_read_rsp rsp = {0,}; int ret = 0, rspcount = 0; clnt_local_t *local = NULL; - xlator_t *this = NULL; + xlator_t *this = NULL; + dict_t *xdata = NULL; this = THIS; @@ -2218,21 +2828,37 @@ client3_1_readv_cbk (struct rpc_req *req, struct iovec *iov, int count, vector[0].iov_base = req->rsp[1].iov_base; rspcount = 1; } + GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), + (rsp.xdata.xdata_len), ret, + rsp.op_errno, out); + +#ifdef GF_TESTING_IO_XDATA + dict_dump (xdata); +#endif + out: if (rsp.op_ret == -1) { gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s", strerror (gf_error_to_errno (rsp.op_errno))); + } else if (rsp.op_ret >= 0) { + if (local->attempt_reopen) + client_attempt_reopen (local->fd, this); } CLIENT_STACK_UNWIND (readv, frame, rsp.op_ret, gf_error_to_errno (rsp.op_errno), vector, rspcount, - &stat, iobref); + &stat, iobref, xdata); + + free (rsp.xdata.xdata_val); + + if (xdata) + dict_unref (xdata); return 0; } int -client3_1_release_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_release_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { call_frame_t *frame = NULL; @@ -2242,7 +2868,7 @@ client3_1_release_cbk (struct rpc_req *req, struct iovec *iov, int count, return 0; } int -client3_1_releasedir_cbk (struct rpc_req *req, struct iovec *iov, int count, +client3_3_releasedir_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe) { call_frame_t *frame = NULL; @@ -2297,19 +2923,19 @@ client_fdctx_destroy (xlator_t *this, clnt_fd_ctx_t *fdctx) if (fdctx->is_dir) { gfs3_releasedir_req req = {{0,},}; req.fd = fdctx->remote_fd; - gf_log (this->name, GF_LOG_DEBUG, "sending releasedir on fd"); - client_submit_request (this, &req, fr, &clnt3_1_fop_prog, + gf_log (this->name, GF_LOG_TRACE, "sending releasedir on fd"); + client_submit_request (this, &req, fr, &clnt3_3_fop_prog, GFS3_OP_RELEASEDIR, - client3_1_releasedir_cbk, + client3_3_releasedir_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_releasedir_req); } else { gfs3_release_req req = {{0,},}; req.fd = fdctx->remote_fd; - gf_log (this->name, GF_LOG_DEBUG, "sending release on fd"); - client_submit_request (this, &req, fr, &clnt3_1_fop_prog, + gf_log (this->name, GF_LOG_TRACE, "sending release on fd"); + client_submit_request (this, &req, fr, &clnt3_3_fop_prog, GFS3_OP_RELEASE, - client3_1_release_cbk, NULL, + client3_3_release_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_release_req); } @@ -2318,7 +2944,6 @@ client_fdctx_destroy (xlator_t *this, clnt_fd_ctx_t *fdctx) out: if (fdctx) { fdctx->remote_fd = -1; - inode_unref (fdctx->inode); GF_FREE (fdctx); } @@ -2329,7 +2954,7 @@ out: } int32_t -client3_1_releasedir (call_frame_t *frame, xlator_t *this, +client3_3_releasedir (call_frame_t *frame, xlator_t *this, void *data) { clnt_conf_t *conf = NULL; @@ -2370,7 +2995,7 @@ out: } int32_t -client3_1_release (call_frame_t *frame, xlator_t *this, +client3_3_release (call_frame_t *frame, xlator_t *this, void *data) { int64_t remote_fd = -1; @@ -2414,7 +3039,7 @@ out: int32_t -client3_1_lookup (call_frame_t *frame, xlator_t *this, +client3_3_lookup (call_frame_t *frame, xlator_t *this, void *data) { clnt_conf_t *conf = NULL; @@ -2447,6 +3072,7 @@ client3_1_lookup (call_frame_t *frame, xlator_t *this, goto unwind; loc_copy (&local->loc, args->loc); + loc_path (&local->loc, NULL); frame->local = local; if (args->loc->parent) { @@ -2461,8 +3087,8 @@ client3_1_lookup (call_frame_t *frame, xlator_t *this, memcpy (req.gfid, args->loc->gfid, 16); } - if (args->dict) { - content = dict_get (args->dict, GF_CONTENT_KEY); + if (args->xdata) { + content = dict_get (args->xdata, GF_CONTENT_KEY); if (content != NULL) { rsp_iobref = iobref_new (); if (rsp_iobref == NULL) { @@ -2481,27 +3107,26 @@ client3_1_lookup (call_frame_t *frame, xlator_t *this, iobuf_unref (rsp_iobuf); rsphdr = &vector[0]; rsphdr->iov_base = iobuf_ptr (rsp_iobuf); - rsphdr->iov_len - = iobuf_pagesize (rsp_iobuf); + rsphdr->iov_len = iobuf_pagesize (rsp_iobuf); count = 1; - rsp_iobuf = NULL; local->iobref = rsp_iobref; + rsp_iobuf = NULL; rsp_iobref = NULL; } - GF_PROTOCOL_DICT_SERIALIZE (this, args->dict, - (&req.dict.dict_val), - req.dict.dict_len, + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, + (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); } if (args->loc->name) - req.bname = (char *)args->loc->name; + req.bname = (char *)args->loc->name; else req.bname = ""; ret = client_submit_request (this, &req, frame, conf->fops, - GFS3_OP_LOOKUP, client3_1_lookup_cbk, + GFS3_OP_LOOKUP, client3_3_lookup_cbk, NULL, rsphdr, count, NULL, 0, local->iobref, (xdrproc_t)xdr_gfs3_lookup_req); @@ -2510,13 +3135,13 @@ client3_1_lookup (call_frame_t *frame, xlator_t *this, gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } - if (req.dict.dict_val) { - GF_FREE (req.dict.dict_val); - } + GF_FREE (req.xdata.xdata_val); - if (rsp_iobref != NULL) { + if (rsp_iobref) iobref_unref (rsp_iobref); - } + + if (rsp_iobuf) + iobuf_unref (rsp_iobuf); return 0; @@ -2524,24 +3149,19 @@ unwind: CLIENT_STACK_UNWIND (lookup, frame, -1, op_errno, NULL, NULL, NULL, NULL); - if (req.dict.dict_val) - GF_FREE (req.dict.dict_val); + GF_FREE (req.xdata.xdata_val); - if (rsp_iobref != NULL) { + if (rsp_iobref) iobref_unref (rsp_iobref); - } - if (rsp_iobuf != NULL) { + if (rsp_iobuf) iobuf_unref (rsp_iobuf); - } return 0; } - - int32_t -client3_1_stat (call_frame_t *frame, xlator_t *this, +client3_3_stat (call_frame_t *frame, xlator_t *this, void *data) { clnt_conf_t *conf = NULL; @@ -2567,23 +3187,31 @@ client3_1_stat (call_frame_t *frame, xlator_t *this, unwind, op_errno, EINVAL); conf = this->private; + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, - GFS3_OP_STAT, client3_1_stat_cbk, NULL, + GFS3_OP_STAT, client3_3_stat_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_stat_req); if (ret) { gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } + GF_FREE (req.xdata.xdata_val); + return 0; unwind: - CLIENT_STACK_UNWIND (stat, frame, -1, op_errno, NULL); + CLIENT_STACK_UNWIND (stat, frame, -1, op_errno, NULL, NULL); + + GF_FREE (req.xdata.xdata_val); + return 0; } int32_t -client3_1_truncate (call_frame_t *frame, xlator_t *this, +client3_3_truncate (call_frame_t *frame, xlator_t *this, void *data) { clnt_conf_t *conf = NULL; @@ -2612,24 +3240,31 @@ client3_1_truncate (call_frame_t *frame, xlator_t *this, conf = this->private; + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_TRUNCATE, - client3_1_truncate_cbk, NULL, + client3_3_truncate_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_truncate_req); if (ret) { gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } + GF_FREE (req.xdata.xdata_val); + return 0; unwind: - CLIENT_STACK_UNWIND (truncate, frame, -1, op_errno, NULL, NULL); + CLIENT_STACK_UNWIND (truncate, frame, -1, op_errno, NULL, NULL, NULL); + GF_FREE (req.xdata.xdata_val); + return 0; } int32_t -client3_1_ftruncate (call_frame_t *frame, xlator_t *this, +client3_3_ftruncate (call_frame_t *frame, xlator_t *this, void *data) { clnt_args_t *args = NULL; @@ -2646,31 +3281,39 @@ client3_1_ftruncate (call_frame_t *frame, xlator_t *this, conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); req.offset = args->offset; req.fd = remote_fd; memcpy (req.gfid, args->fd->inode->gfid, 16); + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_FTRUNCATE, - client3_1_ftruncate_cbk, NULL, + client3_3_ftruncate_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_ftruncate_req); if (ret) { gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } + GF_FREE (req.xdata.xdata_val); + return 0; unwind: - CLIENT_STACK_UNWIND (ftruncate, frame, -1, op_errno, NULL, NULL); + CLIENT_STACK_UNWIND (ftruncate, frame, -1, op_errno, NULL, NULL, NULL); + GF_FREE (req.xdata.xdata_val); + return 0; } int32_t -client3_1_access (call_frame_t *frame, xlator_t *this, +client3_3_access (call_frame_t *frame, xlator_t *this, void *data) { clnt_conf_t *conf = NULL; @@ -2699,30 +3342,43 @@ client3_1_access (call_frame_t *frame, xlator_t *this, conf = this->private; + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_ACCESS, - client3_1_access_cbk, NULL, + client3_3_access_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_access_req); if (ret) { gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } + GF_FREE (req.xdata.xdata_val); + return 0; unwind: - CLIENT_STACK_UNWIND (access, frame, -1, op_errno); + CLIENT_STACK_UNWIND (access, frame, -1, op_errno, NULL); + GF_FREE (req.xdata.xdata_val); + return 0; } int32_t -client3_1_readlink (call_frame_t *frame, xlator_t *this, +client3_3_readlink (call_frame_t *frame, xlator_t *this, void *data) { - clnt_conf_t *conf = NULL; - clnt_args_t *args = NULL; - gfs3_readlink_req req = {{0,},}; - int ret = 0; - int op_errno = ESTALE; + clnt_conf_t *conf = NULL; + clnt_args_t *args = NULL; + gfs3_readlink_req req = {{0,},}; + int ret = 0; + int op_errno = ESTALE; + clnt_local_t *local = NULL; + struct iobuf *rsp_iobuf = NULL; + struct iobref *rsp_iobref = NULL; + struct iovec *rsphdr = NULL; + int count = 0; + struct iovec vector[MAX_IOVEC] = {{0}, }; if (!frame || !this || !data) goto unwind; @@ -2743,18 +3399,58 @@ client3_1_readlink (call_frame_t *frame, xlator_t *this, req.size = args->size; conf = this->private; + local = mem_get0 (this->local_pool); + if (!local) { + op_errno = ENOMEM; + goto unwind; + } + + frame->local = local; + + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + + rsp_iobref = iobref_new (); + if (rsp_iobref == NULL) { + goto unwind; + } + + rsp_iobuf = iobuf_get (this->ctx->iobuf_pool); + if (rsp_iobuf == NULL) { + goto unwind; + } + + iobref_add (rsp_iobref, rsp_iobuf); + iobuf_unref (rsp_iobuf); + rsphdr = &vector[0]; + rsphdr->iov_base = iobuf_ptr (rsp_iobuf); + rsphdr->iov_len = iobuf_pagesize (rsp_iobuf); + count = 1; + local->iobref = rsp_iobref; + rsp_iobuf = NULL; + rsp_iobref = NULL; + ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_READLINK, - client3_1_readlink_cbk, NULL, - NULL, 0, NULL, 0, - NULL, (xdrproc_t)xdr_gfs3_readlink_req); + client3_3_readlink_cbk, NULL, + rsphdr, count, NULL, 0, + local->iobref, + (xdrproc_t)xdr_gfs3_readlink_req); if (ret) { gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } + GF_FREE (req.xdata.xdata_val); + return 0; unwind: - CLIENT_STACK_UNWIND (readlink, frame, -1, op_errno, NULL, NULL); + if (rsp_iobref != NULL) { + iobref_unref (rsp_iobref); + } + + CLIENT_STACK_UNWIND (readlink, frame, -1, op_errno, NULL, NULL, NULL); + GF_FREE (req.xdata.xdata_val); + return 0; } @@ -2762,7 +3458,7 @@ unwind: int32_t -client3_1_unlink (call_frame_t *frame, xlator_t *this, +client3_3_unlink (call_frame_t *frame, xlator_t *this, void *data) { clnt_conf_t *conf = NULL; @@ -2790,24 +3486,32 @@ client3_1_unlink (call_frame_t *frame, xlator_t *this, req.bname = (char *)args->loc->name; conf = this->private; + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_UNLINK, - client3_1_unlink_cbk, NULL, + client3_3_unlink_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_unlink_req); if (ret) { gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } + + GF_FREE (req.xdata.xdata_val); + return 0; unwind: - CLIENT_STACK_UNWIND (unlink, frame, -1, op_errno, NULL, NULL); + CLIENT_STACK_UNWIND (unlink, frame, -1, op_errno, NULL, NULL, NULL); + GF_FREE (req.xdata.xdata_val); + return 0; } int32_t -client3_1_rmdir (call_frame_t *frame, xlator_t *this, +client3_3_rmdir (call_frame_t *frame, xlator_t *this, void *data) { clnt_conf_t *conf = NULL; @@ -2833,26 +3537,33 @@ client3_1_rmdir (call_frame_t *frame, xlator_t *this, !uuid_is_null (*((uuid_t*)req.pargfid)), unwind, op_errno, EINVAL); req.bname = (char *)args->loc->name; - req.flags = args->flags; + req.xflags = args->flags; conf = this->private; + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, - GFS3_OP_RMDIR, client3_1_rmdir_cbk, NULL, + GFS3_OP_RMDIR, client3_3_rmdir_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_rmdir_req); if (ret) { gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } + GF_FREE (req.xdata.xdata_val); + return 0; unwind: - CLIENT_STACK_UNWIND (rmdir, frame, -1, op_errno, NULL, NULL); + CLIENT_STACK_UNWIND (rmdir, frame, -1, op_errno, NULL, NULL, NULL); + GF_FREE (req.xdata.xdata_val); + return 0; } int32_t -client3_1_symlink (call_frame_t *frame, xlator_t *this, +client3_3_symlink (call_frame_t *frame, xlator_t *this, void *data) { clnt_local_t *local = NULL; @@ -2878,6 +3589,7 @@ client3_1_symlink (call_frame_t *frame, xlator_t *this, goto unwind; loc_copy (&local->loc, args->loc); + loc_path (&local->loc, NULL); if (!uuid_is_null (args->loc->parent->gfid)) memcpy (req.pargfid, args->loc->parent->gfid, 16); @@ -2889,39 +3601,39 @@ client3_1_symlink (call_frame_t *frame, xlator_t *this, unwind, op_errno, EINVAL); req.linkname = (char *)args->linkname; req.bname = (char *)args->loc->name; - - GF_PROTOCOL_DICT_SERIALIZE (this, args->dict, (&req.dict.dict_val), - req.dict.dict_len, op_errno, unwind); + req.umask = args->umask; + local->loc2.path = gf_strdup (req.linkname); conf = this->private; + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, - GFS3_OP_SYMLINK, client3_1_symlink_cbk, + GFS3_OP_SYMLINK, client3_3_symlink_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_symlink_req); if (ret) { gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } - if (req.dict.dict_val) { - GF_FREE (req.dict.dict_val); - } + GF_FREE (req.xdata.xdata_val); + return 0; unwind: CLIENT_STACK_UNWIND (symlink, frame, -1, op_errno, NULL, NULL, NULL, - NULL); + NULL, NULL); + + GF_FREE (req.xdata.xdata_val); - if (req.dict.dict_val) { - GF_FREE (req.dict.dict_val); - } return 0; } int32_t -client3_1_rename (call_frame_t *frame, xlator_t *this, +client3_3_rename (call_frame_t *frame, xlator_t *this, void *data) { clnt_conf_t *conf = NULL; @@ -2959,25 +3671,33 @@ client3_1_rename (call_frame_t *frame, xlator_t *this, req.newbname = (char *)args->newloc->name; conf = this->private; + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, - GFS3_OP_RENAME, client3_1_rename_cbk, NULL, + GFS3_OP_RENAME, client3_3_rename_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_rename_req); if (ret) { gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } + GF_FREE (req.xdata.xdata_val); + return 0; unwind: CLIENT_STACK_UNWIND (rename, frame, -1, op_errno, NULL, NULL, NULL, - NULL, NULL); + NULL, NULL, NULL); + + GF_FREE (req.xdata.xdata_val); + return 0; } int32_t -client3_1_link (call_frame_t *frame, xlator_t *this, +client3_3_link (call_frame_t *frame, xlator_t *this, void *data) { clnt_local_t *local = NULL; @@ -3019,29 +3739,39 @@ client3_1_link (call_frame_t *frame, xlator_t *this, } loc_copy (&local->loc, args->oldloc); + loc_path (&local->loc, NULL); + loc_copy (&local->loc2, args->newloc); + loc_path (&local->loc2, NULL); frame->local = local; req.newbname = (char *)args->newloc->name; conf = this->private; + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, - GFS3_OP_LINK, client3_1_link_cbk, NULL, + GFS3_OP_LINK, client3_3_link_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_link_req); if (ret) { gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } + GF_FREE (req.xdata.xdata_val); + return 0; unwind: - CLIENT_STACK_UNWIND (link, frame, -1, op_errno, NULL, NULL, NULL, NULL); + CLIENT_STACK_UNWIND (link, frame, -1, op_errno, NULL, NULL, NULL, NULL, NULL); + GF_FREE (req.xdata.xdata_val); + return 0; } int32_t -client3_1_mknod (call_frame_t *frame, xlator_t *this, +client3_3_mknod (call_frame_t *frame, xlator_t *this, void *data) { clnt_local_t *local = NULL; @@ -3066,6 +3796,7 @@ client3_1_mknod (call_frame_t *frame, xlator_t *this, goto unwind; loc_copy (&local->loc, args->loc); + loc_path (&local->loc, NULL); frame->local = local; if (!uuid_is_null (args->loc->parent->gfid)) @@ -3079,40 +3810,36 @@ client3_1_mknod (call_frame_t *frame, xlator_t *this, req.bname = (char *)args->loc->name; req.mode = args->mode; req.dev = args->rdev; - if (args->dict) { - GF_PROTOCOL_DICT_SERIALIZE (this, args->dict, - (&req.dict.dict_val), - req.dict.dict_len, - op_errno, unwind); - } + req.umask = args->umask; conf = this->private; + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, - GFS3_OP_MKNOD, client3_1_mknod_cbk, NULL, + GFS3_OP_MKNOD, client3_3_mknod_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_mknod_req); if (ret) { gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } - if (req.dict.dict_val) { - GF_FREE (req.dict.dict_val); - } + GF_FREE (req.xdata.xdata_val); + return 0; unwind: CLIENT_STACK_UNWIND (mknod, frame, -1, op_errno, NULL, NULL, NULL, - NULL); + NULL, NULL); + + GF_FREE (req.xdata.xdata_val); - if (req.dict.dict_val) { - GF_FREE (req.dict.dict_val); - } return 0; } int32_t -client3_1_mkdir (call_frame_t *frame, xlator_t *this, +client3_3_mkdir (call_frame_t *frame, xlator_t *this, void *data) { clnt_local_t *local = NULL; @@ -3137,6 +3864,7 @@ client3_1_mkdir (call_frame_t *frame, xlator_t *this, goto unwind; loc_copy (&local->loc, args->loc); + loc_path (&local->loc, NULL); frame->local = local; if (!uuid_is_null (args->loc->parent->gfid)) @@ -3150,39 +3878,35 @@ client3_1_mkdir (call_frame_t *frame, xlator_t *this, req.bname = (char *)args->loc->name; req.mode = args->mode; - if (args->dict) { - GF_PROTOCOL_DICT_SERIALIZE (this, args->dict, - (&req.dict.dict_val), - req.dict.dict_len, - op_errno, unwind); - } + req.umask = args->umask; conf = this->private; + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, - GFS3_OP_MKDIR, client3_1_mkdir_cbk, NULL, + GFS3_OP_MKDIR, client3_3_mkdir_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_mkdir_req); if (ret) { gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } - if (req.dict.dict_val) { - GF_FREE (req.dict.dict_val); - } + GF_FREE (req.xdata.xdata_val); + return 0; unwind: CLIENT_STACK_UNWIND (mkdir, frame, -1, op_errno, NULL, NULL, NULL, - NULL); + NULL, NULL); + + GF_FREE (req.xdata.xdata_val); - if (req.dict.dict_val) { - GF_FREE (req.dict.dict_val); - } return 0; } int32_t -client3_1_create (call_frame_t *frame, xlator_t *this, +client3_3_create (call_frame_t *frame, xlator_t *this, void *data) { clnt_local_t *local = NULL; @@ -3209,6 +3933,7 @@ client3_1_create (call_frame_t *frame, xlator_t *this, local->flags = args->flags; loc_copy (&local->loc, args->loc); + loc_path (&local->loc, NULL); frame->local = local; if (!uuid_is_null (args->loc->parent->gfid)) @@ -3222,41 +3947,37 @@ client3_1_create (call_frame_t *frame, xlator_t *this, req.bname = (char *)args->loc->name; req.mode = args->mode; req.flags = gf_flags_from_flags (args->flags); - if (args->dict) { - GF_PROTOCOL_DICT_SERIALIZE (this, args->dict, - (&req.dict.dict_val), - req.dict.dict_len, - op_errno, unwind); - } + req.umask = args->umask; conf = this->private; + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, - GFS3_OP_CREATE, client3_1_create_cbk, NULL, + GFS3_OP_CREATE, client3_3_create_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_create_req); if (ret) { gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } - if (req.dict.dict_val) { - GF_FREE (req.dict.dict_val); - } + GF_FREE (req.xdata.xdata_val); + return 0; unwind: CLIENT_STACK_UNWIND (create, frame, -1, op_errno, NULL, NULL, NULL, - NULL, NULL); + NULL, NULL, NULL); + + GF_FREE (req.xdata.xdata_val); - if (req.dict.dict_val) { - GF_FREE (req.dict.dict_val); - } return 0; } int32_t -client3_1_open (call_frame_t *frame, xlator_t *this, +client3_3_open (call_frame_t *frame, xlator_t *this, void *data) { clnt_local_t *local = NULL; @@ -3281,8 +4002,8 @@ client3_1_open (call_frame_t *frame, xlator_t *this, local->fd = fd_ref (args->fd); local->flags = args->flags; - local->wbflags = args->wbflags; loc_copy (&local->loc, args->loc); + loc_path (&local->loc, NULL); frame->local = local; if (!uuid_is_null (args->loc->inode->gfid)) @@ -3294,21 +4015,27 @@ client3_1_open (call_frame_t *frame, xlator_t *this, !uuid_is_null (*((uuid_t*)req.gfid)), unwind, op_errno, EINVAL); req.flags = gf_flags_from_flags (args->flags); - req.wbflags = args->wbflags; conf = this->private; + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, - GFS3_OP_OPEN, client3_1_open_cbk, NULL, + GFS3_OP_OPEN, client3_3_open_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_open_req); if (ret) { gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } + GF_FREE (req.xdata.xdata_val); + return 0; unwind: - CLIENT_STACK_UNWIND (open, frame, -1, op_errno, NULL); + CLIENT_STACK_UNWIND (open, frame, -1, op_errno, NULL, NULL); + + GF_FREE (req.xdata.xdata_val); return 0; } @@ -3316,19 +4043,19 @@ unwind: int32_t -client3_1_readv (call_frame_t *frame, xlator_t *this, +client3_3_readv (call_frame_t *frame, xlator_t *this, void *data) { clnt_args_t *args = NULL; int64_t remote_fd = -1; clnt_conf_t *conf = NULL; + clnt_local_t *local = NULL; int op_errno = ESTALE; gfs3_read_req req = {{0,},}; int ret = 0; struct iovec rsp_vec = {0, }; struct iobuf *rsp_iobuf = NULL; struct iobref *rsp_iobref = NULL; - clnt_local_t *local = NULL; if (!frame || !this || !data) goto unwind; @@ -3336,7 +4063,14 @@ client3_1_readv (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, FALLBACK_TO_ANON_FD, + remote_fd, op_errno, unwind); + ret = client_fd_fop_prepare_local (frame, args->fd, remote_fd); + if (ret) { + op_errno = -ret; + goto unwind; + } + local = frame->local; req.size = args->size; req.offset = args->offset; @@ -3359,6 +4093,7 @@ client3_1_readv (call_frame_t *frame, xlator_t *this, iobref_add (rsp_iobref, rsp_iobuf); iobuf_unref (rsp_iobuf); + rsp_vec.iov_base = iobuf_ptr (rsp_iobuf); rsp_vec.iov_len = iobuf_pagesize (rsp_iobuf); @@ -3373,49 +4108,48 @@ client3_1_readv (call_frame_t *frame, xlator_t *this, goto unwind; } - local = mem_get0 (this->local_pool); - if (local == NULL) { - op_errno = ENOMEM; - goto unwind; - } - local->iobref = rsp_iobref; rsp_iobref = NULL; - frame->local = local; + + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); ret = client_submit_request (this, &req, frame, conf->fops, - GFS3_OP_READ, client3_1_readv_cbk, NULL, + GFS3_OP_READ, client3_3_readv_cbk, NULL, NULL, 0, &rsp_vec, 1, local->iobref, (xdrproc_t)xdr_gfs3_read_req); if (ret) { + //unwind is done in the cbk gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } + GF_FREE (req.xdata.xdata_val); + return 0; unwind: - if (rsp_iobuf) { + if (rsp_iobuf) iobuf_unref (rsp_iobuf); - } - if (rsp_iobref) { + if (rsp_iobref) iobref_unref (rsp_iobref); - } - CLIENT_STACK_UNWIND (readv, frame, -1, op_errno, NULL, 0, NULL, NULL); + CLIENT_STACK_UNWIND (readv, frame, -1, op_errno, NULL, 0, NULL, NULL, NULL); + GF_FREE (req.xdata.xdata_val); + return 0; } int32_t -client3_1_writev (call_frame_t *frame, xlator_t *this, void *data) +client3_3_writev (call_frame_t *frame, xlator_t *this, void *data) { clnt_args_t *args = NULL; int64_t remote_fd = -1; clnt_conf_t *conf = NULL; gfs3_write_req req = {{0,},}; int op_errno = ESTALE; - int ret = 0; + int ret = 0; if (!frame || !this || !data) goto unwind; @@ -3423,7 +4157,13 @@ client3_1_writev (call_frame_t *frame, xlator_t *this, void *data) args = data; conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, FALLBACK_TO_ANON_FD, + remote_fd, op_errno, unwind); + ret = client_fd_fop_prepare_local (frame, args->fd, remote_fd); + if (ret) { + op_errno = -ret; + goto unwind; + } req.size = args->size; req.offset = args->offset; @@ -3432,8 +4172,19 @@ client3_1_writev (call_frame_t *frame, xlator_t *this, void *data) memcpy (req.gfid, args->fd->inode->gfid, 16); +#ifdef GF_TESTING_IO_XDATA + if (!args->xdata) + args->xdata = dict_new (); + + ret = dict_set_str (args->xdata, "testing-the-xdata-key", + "testing-the-xdata-value"); +#endif + + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_vec_request (this, &req, frame, conf->fops, - GFS3_OP_WRITE, client3_1_writev_cbk, + GFS3_OP_WRITE, client3_3_writev_cbk, args->vector, args->count, args->iobref, (xdrproc_t)xdr_gfs3_write_req); @@ -3446,16 +4197,20 @@ client3_1_writev (call_frame_t *frame, xlator_t *this, void *data) gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } + GF_FREE (req.xdata.xdata_val); + return 0; unwind: - CLIENT_STACK_UNWIND (writev, frame, -1, op_errno, NULL, NULL); + CLIENT_STACK_UNWIND (writev, frame, -1, op_errno, NULL, NULL, NULL); + GF_FREE (req.xdata.xdata_val); + return 0; } int32_t -client3_1_flush (call_frame_t *frame, xlator_t *this, +client3_3_flush (call_frame_t *frame, xlator_t *this, void *data) { clnt_args_t *args = NULL; @@ -3472,7 +4227,8 @@ client3_1_flush (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); conf = this->private; @@ -3489,24 +4245,33 @@ client3_1_flush (call_frame_t *frame, xlator_t *this, req.fd = remote_fd; memcpy (req.gfid, args->fd->inode->gfid, 16); + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, - GFS3_OP_FLUSH, client3_1_flush_cbk, NULL, + GFS3_OP_FLUSH, client3_3_flush_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_flush_req); if (ret) { gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } + + GF_FREE (req.xdata.xdata_val); + + return 0; unwind: - CLIENT_STACK_UNWIND (flush, frame, -1, op_errno); + CLIENT_STACK_UNWIND (flush, frame, -1, op_errno, NULL); + GF_FREE (req.xdata.xdata_val); + return 0; } int32_t -client3_1_fsync (call_frame_t *frame, xlator_t *this, +client3_3_fsync (call_frame_t *frame, xlator_t *this, void *data) { clnt_args_t *args = NULL; @@ -3522,32 +4287,40 @@ client3_1_fsync (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); req.fd = remote_fd; req.data = args->flags; memcpy (req.gfid, args->fd->inode->gfid, 16); + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); ret = client_submit_request (this, &req, frame, conf->fops, - GFS3_OP_FSYNC, client3_1_fsync_cbk, NULL, + GFS3_OP_FSYNC, client3_3_fsync_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_fsync_req); if (ret) { gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } + + GF_FREE (req.xdata.xdata_val); + return 0; unwind: - CLIENT_STACK_UNWIND (fsync, frame, -1, op_errno, NULL, NULL); + CLIENT_STACK_UNWIND (fsync, frame, -1, op_errno, NULL, NULL, NULL); + GF_FREE (req.xdata.xdata_val); + return 0; } int32_t -client3_1_fstat (call_frame_t *frame, xlator_t *this, +client3_3_fstat (call_frame_t *frame, xlator_t *this, void *data) { clnt_args_t *args = NULL; @@ -3563,30 +4336,38 @@ client3_1_fstat (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); req.fd = remote_fd; memcpy (req.gfid, args->fd->inode->gfid, 16); + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, - GFS3_OP_FSTAT, client3_1_fstat_cbk, NULL, + GFS3_OP_FSTAT, client3_3_fstat_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_fstat_req); if (ret) { gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } + GF_FREE (req.xdata.xdata_val); + return 0; unwind: - CLIENT_STACK_UNWIND (fstat, frame, -1, op_errno, NULL); + CLIENT_STACK_UNWIND (fstat, frame, -1, op_errno, NULL, NULL); + GF_FREE (req.xdata.xdata_val); + return 0; } int32_t -client3_1_opendir (call_frame_t *frame, xlator_t *this, +client3_3_opendir (call_frame_t *frame, xlator_t *this, void *data) { clnt_local_t *local = NULL; @@ -3611,6 +4392,7 @@ client3_1_opendir (call_frame_t *frame, xlator_t *this, local->fd = fd_ref (args->fd); loc_copy (&local->loc, args->loc); + loc_path (&local->loc, NULL); frame->local = local; if (!uuid_is_null (args->loc->inode->gfid)) @@ -3624,18 +4406,25 @@ client3_1_opendir (call_frame_t *frame, xlator_t *this, conf = this->private; + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, - GFS3_OP_OPENDIR, client3_1_opendir_cbk, + GFS3_OP_OPENDIR, client3_3_opendir_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_opendir_req); if (ret) { gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } + GF_FREE (req.xdata.xdata_val); + return 0; unwind: - CLIENT_STACK_UNWIND (opendir, frame, -1, op_errno, NULL); + CLIENT_STACK_UNWIND (opendir, frame, -1, op_errno, NULL, NULL); + + GF_FREE (req.xdata.xdata_val); return 0; } @@ -3643,7 +4432,7 @@ unwind: int32_t -client3_1_fsyncdir (call_frame_t *frame, xlator_t *this, void *data) +client3_3_fsyncdir (call_frame_t *frame, xlator_t *this, void *data) { clnt_args_t *args = NULL; int64_t remote_fd = -1; @@ -3658,7 +4447,8 @@ client3_1_fsyncdir (call_frame_t *frame, xlator_t *this, void *data) args = data; conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); req.fd = remote_fd; req.data = args->flags; @@ -3666,8 +4456,11 @@ client3_1_fsyncdir (call_frame_t *frame, xlator_t *this, void *data) conf = this->private; + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, - GFS3_OP_FSYNCDIR, client3_1_fsyncdir_cbk, + GFS3_OP_FSYNCDIR, client3_3_fsyncdir_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_fsyncdir_req); @@ -3675,17 +4468,21 @@ client3_1_fsyncdir (call_frame_t *frame, xlator_t *this, void *data) gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } + GF_FREE (req.xdata.xdata_val); + return 0; unwind: - CLIENT_STACK_UNWIND (fsyncdir, frame, -1, op_errno); + CLIENT_STACK_UNWIND (fsyncdir, frame, -1, op_errno, NULL); + GF_FREE (req.xdata.xdata_val); + return 0; } int32_t -client3_1_statfs (call_frame_t *frame, xlator_t *this, +client3_3_statfs (call_frame_t *frame, xlator_t *this, void *data) { clnt_conf_t *conf = NULL; @@ -3716,24 +4513,32 @@ client3_1_statfs (call_frame_t *frame, xlator_t *this, conf = this->private; + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, - GFS3_OP_STATFS, client3_1_statfs_cbk, NULL, + GFS3_OP_STATFS, client3_3_statfs_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_statfs_req); if (ret) { gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } + + GF_FREE (req.xdata.xdata_val); + return 0; unwind: - CLIENT_STACK_UNWIND (statfs, frame, -1, op_errno, NULL); + CLIENT_STACK_UNWIND (statfs, frame, -1, op_errno, NULL, NULL); + GF_FREE (req.xdata.xdata_val); + return 0; } int32_t -client3_1_setxattr (call_frame_t *frame, xlator_t *this, +client3_3_setxattr (call_frame_t *frame, xlator_t *this, void *data) { clnt_conf_t *conf = NULL; @@ -3758,8 +4563,8 @@ client3_1_setxattr (call_frame_t *frame, xlator_t *this, GF_ASSERT_AND_GOTO_WITH_ERROR (this->name, !uuid_is_null (*((uuid_t*)req.gfid)), unwind, op_errno, EINVAL); - if (args->dict) { - GF_PROTOCOL_DICT_SERIALIZE (this, args->dict, + if (args->xattr) { + GF_PROTOCOL_DICT_SERIALIZE (this, args->xattr, (&req.dict.dict_val), req.dict.dict_len, op_errno, unwind); @@ -3769,30 +4574,34 @@ client3_1_setxattr (call_frame_t *frame, xlator_t *this, conf = this->private; + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, - GFS3_OP_SETXATTR, client3_1_setxattr_cbk, + GFS3_OP_SETXATTR, client3_3_setxattr_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_setxattr_req); if (ret) { gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } - if (req.dict.dict_val) { - GF_FREE (req.dict.dict_val); - } + GF_FREE (req.dict.dict_val); + + GF_FREE (req.xdata.xdata_val); return 0; unwind: - CLIENT_STACK_UNWIND (setxattr, frame, -1, op_errno); - if (req.dict.dict_val) { - GF_FREE (req.dict.dict_val); - } + CLIENT_STACK_UNWIND (setxattr, frame, -1, op_errno, NULL); + GF_FREE (req.dict.dict_val); + + GF_FREE (req.xdata.xdata_val); + return 0; } int32_t -client3_1_fsetxattr (call_frame_t *frame, xlator_t *this, +client3_3_fsetxattr (call_frame_t *frame, xlator_t *this, void *data) { clnt_args_t *args = NULL; @@ -3808,37 +4617,42 @@ client3_1_fsetxattr (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); req.fd = remote_fd; req.flags = args->flags; memcpy (req.gfid, args->fd->inode->gfid, 16); - if (args->dict) { - GF_PROTOCOL_DICT_SERIALIZE (this, args->dict, + if (args->xattr) { + GF_PROTOCOL_DICT_SERIALIZE (this, args->xattr, (&req.dict.dict_val), req.dict.dict_len, op_errno, unwind); } + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, - GFS3_OP_FSETXATTR, client3_1_fsetxattr_cbk, + GFS3_OP_FSETXATTR, client3_3_fsetxattr_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_fsetxattr_req); if (ret) { gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } - if (req.dict.dict_val) { - GF_FREE (req.dict.dict_val); - } + GF_FREE (req.dict.dict_val); + + GF_FREE (req.xdata.xdata_val); return 0; unwind: - CLIENT_STACK_UNWIND (fsetxattr, frame, -1, op_errno); - if (req.dict.dict_val) { - GF_FREE (req.dict.dict_val); - } + CLIENT_STACK_UNWIND (fsetxattr, frame, -1, op_errno, NULL); + GF_FREE (req.dict.dict_val); + + GF_FREE (req.xdata.xdata_val); + return 0; } @@ -3846,7 +4660,7 @@ unwind: int32_t -client3_1_fgetxattr (call_frame_t *frame, xlator_t *this, +client3_3_fgetxattr (call_frame_t *frame, xlator_t *this, void *data) { clnt_args_t *args = NULL; @@ -3868,7 +4682,8 @@ client3_1_fgetxattr (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); local = mem_get0 (this->local_pool); if (!local) { @@ -3892,12 +4707,13 @@ client3_1_fgetxattr (call_frame_t *frame, xlator_t *this, iobref_add (rsp_iobref, rsp_iobuf); iobuf_unref (rsp_iobuf); + rsphdr = &vector[0]; rsphdr->iov_base = iobuf_ptr (rsp_iobuf); rsphdr->iov_len = iobuf_pagesize (rsp_iobuf);; count = 1; - rsp_iobuf = NULL; local->iobref = rsp_iobref; + rsp_iobuf = NULL; rsp_iobref = NULL; req.namelen = 1; /* Use it as a flag */ @@ -3909,9 +4725,12 @@ client3_1_fgetxattr (call_frame_t *frame, xlator_t *this, } memcpy (req.gfid, args->fd->inode->gfid, 16); + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_FGETXATTR, - client3_1_fgetxattr_cbk, NULL, + client3_3_fgetxattr_cbk, NULL, rsphdr, count, NULL, 0, local->iobref, (xdrproc_t)xdr_gfs3_fgetxattr_req); @@ -3919,17 +4738,25 @@ client3_1_fgetxattr (call_frame_t *frame, xlator_t *this, gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } + GF_FREE (req.xdata.xdata_val); + + if (rsp_iobuf) + iobuf_unref (rsp_iobuf); + + if (rsp_iobref) + iobref_unref (rsp_iobref); + return 0; unwind: - CLIENT_STACK_UNWIND (fgetxattr, frame, -1, op_errno, NULL); + CLIENT_STACK_UNWIND (fgetxattr, frame, -1, op_errno, NULL, NULL); - if (rsp_iobuf) { + if (rsp_iobuf) iobuf_unref (rsp_iobuf); - } - if (rsp_iobref) { + if (rsp_iobref) iobref_unref (rsp_iobref); - } + + GF_FREE (req.xdata.xdata_val); return 0; } @@ -3937,7 +4764,7 @@ unwind: int32_t -client3_1_getxattr (call_frame_t *frame, xlator_t *this, +client3_3_getxattr (call_frame_t *frame, xlator_t *this, void *data) { clnt_conf_t *conf = NULL; @@ -3960,7 +4787,7 @@ client3_1_getxattr (call_frame_t *frame, xlator_t *this, } args = data; - if (!(args->loc && args->loc->inode)) { + if (!args->loc) { op_errno = EINVAL; goto unwind; } @@ -3970,6 +4797,12 @@ client3_1_getxattr (call_frame_t *frame, xlator_t *this, op_errno = ENOMEM; goto unwind; } + + loc_copy (&local->loc, args->loc); + loc_path (&local->loc, NULL); + if (args->name) + local->name = gf_strdup (args->name); + frame->local = local; rsp_iobref = iobref_new (); @@ -3987,15 +4820,16 @@ client3_1_getxattr (call_frame_t *frame, xlator_t *this, iobref_add (rsp_iobref, rsp_iobuf); iobuf_unref (rsp_iobuf); + rsphdr = &vector[0]; rsphdr->iov_base = iobuf_ptr (rsp_iobuf); rsphdr->iov_len = iobuf_pagesize (rsp_iobuf); count = 1; - rsp_iobuf = NULL; local->iobref = rsp_iobref; + rsp_iobuf = NULL; rsp_iobref = NULL; - if (!uuid_is_null (args->loc->inode->gfid)) + if (args->loc->inode && !uuid_is_null (args->loc->inode->gfid)) memcpy (req.gfid, args->loc->inode->gfid, 16); else memcpy (req.gfid, args->loc->gfid, 16); @@ -4032,9 +4866,12 @@ client3_1_getxattr (call_frame_t *frame, xlator_t *this, } } + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_GETXATTR, - client3_1_getxattr_cbk, NULL, + client3_3_getxattr_cbk, NULL, rsphdr, count, NULL, 0, local->iobref, (xdrproc_t)xdr_gfs3_getxattr_req); @@ -4042,17 +4879,25 @@ client3_1_getxattr (call_frame_t *frame, xlator_t *this, gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } + GF_FREE (req.xdata.xdata_val); + + if (rsp_iobuf) + iobuf_unref (rsp_iobuf); + + if (rsp_iobref) + iobref_unref (rsp_iobref); + return 0; unwind: - if (rsp_iobuf) { + if (rsp_iobuf) iobuf_unref (rsp_iobuf); - } - if (rsp_iobref) { + if (rsp_iobref) iobref_unref (rsp_iobref); - } - CLIENT_STACK_UNWIND (getxattr, frame, op_ret, op_errno, dict); + CLIENT_STACK_UNWIND (getxattr, frame, op_ret, op_errno, dict, NULL); + + GF_FREE (req.xdata.xdata_val); return 0; } @@ -4060,7 +4905,7 @@ unwind: int32_t -client3_1_xattrop (call_frame_t *frame, xlator_t *this, +client3_3_xattrop (call_frame_t *frame, xlator_t *this, void *data) { clnt_conf_t *conf = NULL; @@ -4105,12 +4950,13 @@ client3_1_xattrop (call_frame_t *frame, xlator_t *this, iobref_add (rsp_iobref, rsp_iobuf); iobuf_unref (rsp_iobuf); + rsphdr = &vector[0]; rsphdr->iov_base = iobuf_ptr (rsp_iobuf); rsphdr->iov_len = iobuf_pagesize (rsp_iobuf); count = 1; - rsp_iobuf = NULL; local->iobref = rsp_iobref; + rsp_iobuf = NULL; rsp_iobref = NULL; if (!uuid_is_null (args->loc->inode->gfid)) @@ -4118,11 +4964,13 @@ client3_1_xattrop (call_frame_t *frame, xlator_t *this, else memcpy (req.gfid, args->loc->gfid, 16); + loc_copy (&local->loc, args->loc); + loc_path (&local->loc, NULL); GF_ASSERT_AND_GOTO_WITH_ERROR (this->name, !uuid_is_null (*((uuid_t*)req.gfid)), unwind, op_errno, EINVAL); - if (args->dict) { - GF_PROTOCOL_DICT_SERIALIZE (this, args->dict, + if (args->xattr) { + GF_PROTOCOL_DICT_SERIALIZE (this, args->xattr, (&req.dict.dict_val), req.dict.dict_len, op_errno, unwind); @@ -4132,9 +4980,12 @@ client3_1_xattrop (call_frame_t *frame, xlator_t *this, conf = this->private; + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_XATTROP, - client3_1_xattrop_cbk, NULL, + client3_3_xattrop_cbk, NULL, rsphdr, count, NULL, 0, local->iobref, (xdrproc_t)xdr_gfs3_xattrop_req); @@ -4142,24 +4993,29 @@ client3_1_xattrop (call_frame_t *frame, xlator_t *this, gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } - if (req.dict.dict_val) { - GF_FREE (req.dict.dict_val); - } + GF_FREE (req.dict.dict_val); + + GF_FREE (req.xdata.xdata_val); + + if (rsp_iobuf) + iobuf_unref (rsp_iobuf); + + if (rsp_iobref) + iobref_unref (rsp_iobref); + return 0; unwind: - CLIENT_STACK_UNWIND (xattrop, frame, -1, op_errno, NULL); + CLIENT_STACK_UNWIND (xattrop, frame, -1, op_errno, NULL, NULL); - if (req.dict.dict_val) { - GF_FREE (req.dict.dict_val); - } + GF_FREE (req.dict.dict_val); - if (rsp_iobuf) { + if (rsp_iobuf) iobuf_unref (rsp_iobuf); - } - if (rsp_iobref) { + if (rsp_iobref) iobref_unref (rsp_iobref); - } + + GF_FREE (req.xdata.xdata_val); return 0; } @@ -4167,17 +5023,17 @@ unwind: int32_t -client3_1_fxattrop (call_frame_t *frame, xlator_t *this, +client3_3_fxattrop (call_frame_t *frame, xlator_t *this, void *data) { clnt_args_t *args = NULL; int64_t remote_fd = -1; clnt_conf_t *conf = NULL; + clnt_local_t *local = NULL; gfs3_fxattrop_req req = {{0,},}; int op_errno = ESTALE; int ret = 0; int count = 0; - clnt_local_t *local = NULL; struct iobref *rsp_iobref = NULL; struct iobuf *rsp_iobuf = NULL; struct iovec *rsphdr = NULL; @@ -4189,19 +5045,20 @@ client3_1_fxattrop (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, FALLBACK_TO_ANON_FD, + remote_fd, op_errno, unwind); + ret = client_fd_fop_prepare_local (frame, args->fd, remote_fd); + if (ret) { + op_errno = -ret; + goto unwind; + } + + local = frame->local; req.fd = remote_fd; req.flags = args->flags; memcpy (req.gfid, args->fd->inode->gfid, 16); - local = mem_get0 (this->local_pool); - if (!local) { - op_errno = ENOMEM; - goto unwind; - } - frame->local = local; - rsp_iobref = iobref_new (); if (rsp_iobref == NULL) { op_errno = ENOMEM; @@ -4221,20 +5078,23 @@ client3_1_fxattrop (call_frame_t *frame, xlator_t *this, rsphdr->iov_base = iobuf_ptr (rsp_iobuf); rsphdr->iov_len = iobuf_pagesize (rsp_iobuf); count = 1; - rsp_iobuf = NULL; local->iobref = rsp_iobref; + rsp_iobuf = NULL; rsp_iobref = NULL; - if (args->dict) { - GF_PROTOCOL_DICT_SERIALIZE (this, args->dict, + if (args->xattr) { + GF_PROTOCOL_DICT_SERIALIZE (this, args->xattr, (&req.dict.dict_val), req.dict.dict_len, op_errno, unwind); } + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_FXATTROP, - client3_1_fxattrop_cbk, NULL, + client3_3_fxattrop_cbk, NULL, rsphdr, count, NULL, 0, local->iobref, (xdrproc_t)xdr_gfs3_fxattrop_req); @@ -4242,33 +5102,30 @@ client3_1_fxattrop (call_frame_t *frame, xlator_t *this, gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } - if (req.dict.dict_val) { - GF_FREE (req.dict.dict_val); - } + GF_FREE (req.dict.dict_val); + + GF_FREE (req.xdata.xdata_val); return 0; unwind: - CLIENT_STACK_UNWIND (fxattrop, frame, -1, op_errno, NULL); + CLIENT_STACK_UNWIND (fxattrop, frame, -1, op_errno, NULL, NULL); - if (req.dict.dict_val) { - GF_FREE (req.dict.dict_val); - } + GF_FREE (req.dict.dict_val); - if (rsp_iobref) { + if (rsp_iobref) iobref_unref (rsp_iobref); - } - if (rsp_iobuf) { + if (rsp_iobuf) iobuf_unref (rsp_iobuf); - } + + GF_FREE (req.xdata.xdata_val); return 0; } - int32_t -client3_1_removexattr (call_frame_t *frame, xlator_t *this, +client3_3_removexattr (call_frame_t *frame, xlator_t *this, void *data) { clnt_conf_t *conf = NULL; @@ -4297,23 +5154,30 @@ client3_1_removexattr (call_frame_t *frame, xlator_t *this, conf = this->private; + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_REMOVEXATTR, - client3_1_removexattr_cbk, NULL, + client3_3_removexattr_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_removexattr_req); if (ret) { gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } + GF_FREE (req.xdata.xdata_val); + return 0; unwind: - CLIENT_STACK_UNWIND (removexattr, frame, -1, op_errno); + CLIENT_STACK_UNWIND (removexattr, frame, -1, op_errno, NULL); + GF_FREE (req.xdata.xdata_val); + return 0; } int32_t -client3_1_fremovexattr (call_frame_t *frame, xlator_t *this, +client3_3_fremovexattr (call_frame_t *frame, xlator_t *this, void *data) { clnt_conf_t *conf = NULL; @@ -4333,29 +5197,37 @@ client3_1_fremovexattr (call_frame_t *frame, xlator_t *this, conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); memcpy (req.gfid, args->fd->inode->gfid, 16); req.name = (char *)args->name; req.fd = remote_fd; + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_FREMOVEXATTR, - client3_1_fremovexattr_cbk, NULL, + client3_3_fremovexattr_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_fremovexattr_req); if (ret) { gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } + GF_FREE (req.xdata.xdata_val); + return 0; unwind: - CLIENT_STACK_UNWIND (fremovexattr, frame, -1, op_errno); + CLIENT_STACK_UNWIND (fremovexattr, frame, -1, op_errno, NULL); + GF_FREE (req.xdata.xdata_val); + return 0; } int32_t -client3_1_lk (call_frame_t *frame, xlator_t *this, +client3_3_lk (call_frame_t *frame, xlator_t *this, void *data) { clnt_args_t *args = NULL; @@ -4379,7 +5251,8 @@ client3_1_lk (call_frame_t *frame, xlator_t *this, goto unwind; } - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); ret = client_cmd_to_gf_cmd (args->cmd, &gf_cmd); if (ret) { @@ -4413,23 +5286,30 @@ client3_1_lk (call_frame_t *frame, xlator_t *this, memcpy (req.gfid, args->fd->inode->gfid, 16); + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_LK, - client3_1_lk_cbk, NULL, + client3_3_lk_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_lk_req); if (ret) { gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } + GF_FREE (req.xdata.xdata_val); + return 0; unwind: - CLIENT_STACK_UNWIND (lk, frame, -1, op_errno, NULL); + CLIENT_STACK_UNWIND (lk, frame, -1, op_errno, NULL, NULL); + GF_FREE (req.xdata.xdata_val); + return 0; } int32_t -client3_1_inodelk (call_frame_t *frame, xlator_t *this, +client3_3_inodelk (call_frame_t *frame, xlator_t *this, void *data) { clnt_conf_t *conf = NULL; @@ -4487,25 +5367,32 @@ client3_1_inodelk (call_frame_t *frame, xlator_t *this, conf = this->private; + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_INODELK, - client3_1_inodelk_cbk, NULL, + client3_3_inodelk_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_inodelk_req); if (ret) { gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } + GF_FREE (req.xdata.xdata_val); + return 0; unwind: - CLIENT_STACK_UNWIND (inodelk, frame, -1, op_errno); + CLIENT_STACK_UNWIND (inodelk, frame, -1, op_errno, NULL); + GF_FREE (req.xdata.xdata_val); + return 0; } int32_t -client3_1_finodelk (call_frame_t *frame, xlator_t *this, +client3_3_finodelk (call_frame_t *frame, xlator_t *this, void *data) { clnt_args_t *args = NULL; @@ -4515,15 +5402,20 @@ client3_1_finodelk (call_frame_t *frame, xlator_t *this, int64_t remote_fd = -1; clnt_conf_t *conf = NULL; int op_errno = ESTALE; - int ret = 0; + int ret = 0; if (!frame || !this || !data) goto unwind; args = data; conf = this->private; - - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, FALLBACK_TO_ANON_FD, + remote_fd, op_errno, unwind); + ret = client_fd_fop_prepare_local (frame, args->fd, remote_fd); + if (ret) { + op_errno = -ret; + goto unwind; + } if (args->cmd == F_GETLK || args->cmd == F_GETLK64) gf_cmd = GF_LK_GETLK; @@ -4556,24 +5448,30 @@ client3_1_finodelk (call_frame_t *frame, xlator_t *this, gf_proto_flock_from_flock (&req.flock, args->flock); memcpy (req.gfid, args->fd->inode->gfid, 16); + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_FINODELK, - client3_1_finodelk_cbk, NULL, + client3_3_finodelk_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_finodelk_req); if (ret) { gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } + GF_FREE (req.xdata.xdata_val); return 0; unwind: - CLIENT_STACK_UNWIND (finodelk, frame, -1, op_errno); + CLIENT_STACK_UNWIND (finodelk, frame, -1, op_errno, NULL); + GF_FREE (req.xdata.xdata_val); + return 0; } int32_t -client3_1_entrylk (call_frame_t *frame, xlator_t *this, +client3_3_entrylk (call_frame_t *frame, xlator_t *this, void *data) { clnt_conf_t *conf = NULL; @@ -4609,25 +5507,32 @@ client3_1_entrylk (call_frame_t *frame, xlator_t *this, conf = this->private; + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_ENTRYLK, - client3_1_entrylk_cbk, NULL, + client3_3_entrylk_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_entrylk_req); if (ret) { gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } + GF_FREE (req.xdata.xdata_val); + return 0; unwind: - CLIENT_STACK_UNWIND (entrylk, frame, -1, op_errno); + CLIENT_STACK_UNWIND (entrylk, frame, -1, op_errno, NULL); + GF_FREE (req.xdata.xdata_val); + return 0; } int32_t -client3_1_fentrylk (call_frame_t *frame, xlator_t *this, +client3_3_fentrylk (call_frame_t *frame, xlator_t *this, void *data) { clnt_args_t *args = NULL; @@ -4643,7 +5548,8 @@ client3_1_fentrylk (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); req.fd = remote_fd; req.cmd = args->cmd_entrylk; @@ -4656,24 +5562,31 @@ client3_1_fentrylk (call_frame_t *frame, xlator_t *this, } memcpy (req.gfid, args->fd->inode->gfid, 16); + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_FENTRYLK, - client3_1_fentrylk_cbk, NULL, + client3_3_fentrylk_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_fentrylk_req); if (ret) { gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } + GF_FREE (req.xdata.xdata_val); + return 0; unwind: - CLIENT_STACK_UNWIND (fentrylk, frame, -1, op_errno); + CLIENT_STACK_UNWIND (fentrylk, frame, -1, op_errno, NULL); + GF_FREE (req.xdata.xdata_val); + return 0; } int32_t -client3_1_rchecksum (call_frame_t *frame, xlator_t *this, +client3_3_rchecksum (call_frame_t *frame, xlator_t *this, void *data) { clnt_args_t *args = NULL; @@ -4689,15 +5602,19 @@ client3_1_rchecksum (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + 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; + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_RCHECKSUM, - client3_1_rchecksum_cbk, NULL, + client3_3_rchecksum_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_rchecksum_req); @@ -4705,16 +5622,20 @@ client3_1_rchecksum (call_frame_t *frame, xlator_t *this, gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } + GF_FREE (req.xdata.xdata_val); + return 0; unwind: - CLIENT_STACK_UNWIND (rchecksum, frame, -1, op_errno, 0, NULL); + CLIENT_STACK_UNWIND (rchecksum, frame, -1, op_errno, 0, NULL, NULL); + GF_FREE (req.xdata.xdata_val); + return 0; } int32_t -client3_1_readdir (call_frame_t *frame, xlator_t *this, +client3_3_readdir (call_frame_t *frame, xlator_t *this, void *data) { clnt_args_t *args = NULL; @@ -4738,7 +5659,8 @@ client3_1_readdir (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); readdir_rsp_size = xdr_sizeof ((xdrproc_t) xdr_gfs3_readdir_rsp, &rsp) + args->size; @@ -4767,12 +5689,14 @@ client3_1_readdir (call_frame_t *frame, xlator_t *this, iobref_add (rsp_iobref, rsp_iobuf); iobuf_unref (rsp_iobuf); + rsphdr = &vector[0]; rsphdr->iov_base = iobuf_ptr (rsp_iobuf); rsphdr->iov_len = iobuf_pagesize (rsp_iobuf); count = 1; - rsp_iobuf = NULL; local->iobref = rsp_iobref; + rsp_iobuf = NULL; + rsp_iobref = NULL; } req.size = args->size; @@ -4782,37 +5706,46 @@ client3_1_readdir (call_frame_t *frame, xlator_t *this, local->cmd = remote_fd; memcpy (req.gfid, args->fd->inode->gfid, 16); + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_READDIR, - client3_1_readdir_cbk, NULL, + client3_3_readdir_cbk, NULL, rsphdr, count, NULL, 0, rsp_iobref, (xdrproc_t)xdr_gfs3_readdir_req); - rsp_iobref = NULL; if (ret) { gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } + GF_FREE (req.xdata.xdata_val); + + if (rsp_iobuf) + iobuf_unref (rsp_iobuf); + + if (rsp_iobref) + iobref_unref (rsp_iobref); + return 0; unwind: - if (rsp_iobref != NULL) { + if (rsp_iobref) iobref_unref (rsp_iobref); - } - if (rsp_iobuf != NULL) { + if (rsp_iobuf) iobuf_unref (rsp_iobuf); - } - CLIENT_STACK_UNWIND (readdir, frame, -1, op_errno, NULL); + CLIENT_STACK_UNWIND (readdir, frame, -1, op_errno, NULL, NULL); + GF_FREE (req.xdata.xdata_val); + return 0; } int32_t -client3_1_readdirp (call_frame_t *frame, xlator_t *this, +client3_3_readdirp (call_frame_t *frame, xlator_t *this, void *data) { clnt_args_t *args = NULL; @@ -4836,7 +5769,8 @@ client3_1_readdirp (call_frame_t *frame, xlator_t *this, args = data; conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); readdirp_rsp_size = xdr_sizeof ((xdrproc_t) xdr_gfs3_readdirp_rsp, &rsp) + args->size; @@ -4866,12 +5800,13 @@ client3_1_readdirp (call_frame_t *frame, xlator_t *this, iobref_add (rsp_iobref, rsp_iobuf); iobuf_unref (rsp_iobuf); + rsphdr = &vector[0]; rsphdr->iov_base = iobuf_ptr (rsp_iobuf); rsphdr->iov_len = iobuf_pagesize (rsp_iobuf); count = 1; - rsp_iobuf = NULL; local->iobref = rsp_iobref; + rsp_iobuf = NULL; rsp_iobref = NULL; } @@ -4882,16 +5817,13 @@ client3_1_readdirp (call_frame_t *frame, xlator_t *this, req.fd = remote_fd; memcpy (req.gfid, args->fd->inode->gfid, 16); - if (args->dict) { - GF_PROTOCOL_DICT_SERIALIZE (this, args->dict, - (&req.dict.dict_val), - req.dict.dict_len, - op_errno, unwind); - } + /* dict itself is 'xdata' here */ + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.dict.dict_val), + req.dict.dict_len, op_errno, unwind); ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_READDIRP, - client3_1_readdirp_cbk, NULL, + client3_3_readdirp_cbk, NULL, rsphdr, count, NULL, 0, rsp_iobref, (xdrproc_t)xdr_gfs3_readdirp_req); @@ -4899,29 +5831,31 @@ client3_1_readdirp (call_frame_t *frame, xlator_t *this, gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } - if (req.dict.dict_val) - GF_FREE (req.dict.dict_val); + GF_FREE (req.dict.dict_val); + + if (rsp_iobuf) + iobuf_unref (rsp_iobuf); + + if (rsp_iobref) + iobref_unref (rsp_iobref); return 0; unwind: - if (rsp_iobref) { + if (rsp_iobref) iobref_unref (rsp_iobref); - } - if (rsp_iobuf) { + if (rsp_iobuf) iobuf_unref (rsp_iobuf); - } - if (req.dict.dict_val) - GF_FREE (req.dict.dict_val); + GF_FREE (req.dict.dict_val); - CLIENT_STACK_UNWIND (readdirp, frame, -1, op_errno, NULL); + CLIENT_STACK_UNWIND (readdirp, frame, -1, op_errno, NULL, NULL); return 0; } int32_t -client3_1_setattr (call_frame_t *frame, xlator_t *this, +client3_3_setattr (call_frame_t *frame, xlator_t *this, void *data) { clnt_conf_t *conf = NULL; @@ -4951,23 +5885,30 @@ client3_1_setattr (call_frame_t *frame, xlator_t *this, conf = this->private; + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_SETATTR, - client3_1_setattr_cbk, NULL, + client3_3_setattr_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_setattr_req); if (ret) { gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } + GF_FREE (req.xdata.xdata_val); + return 0; unwind: - CLIENT_STACK_UNWIND (setattr, frame, -1, op_errno, NULL, NULL); + CLIENT_STACK_UNWIND (setattr, frame, -1, op_errno, NULL, NULL, NULL); + GF_FREE (req.xdata.xdata_val); + return 0; } int32_t -client3_1_fsetattr (call_frame_t *frame, xlator_t *this, void *data) +client3_3_fsetattr (call_frame_t *frame, xlator_t *this, void *data) { clnt_args_t *args = NULL; int64_t remote_fd = -1; @@ -4982,82 +5923,226 @@ client3_1_fsetattr (call_frame_t *frame, xlator_t *this, void *data) args = data; conf = this->private; - CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind); + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); req.fd = remote_fd; req.valid = args->valid; gf_stat_from_iatt (&req.stbuf, args->stbuf); + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_FSETATTR, - client3_1_fsetattr_cbk, NULL, + client3_3_fsetattr_cbk, NULL, NULL, 0, NULL, 0, NULL, (xdrproc_t)xdr_gfs3_fsetattr_req); if (ret) { gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); } + GF_FREE (req.xdata.xdata_val); + + return 0; +unwind: + CLIENT_STACK_UNWIND (fsetattr, frame, -1, op_errno, NULL, NULL, NULL); + GF_FREE (req.xdata.xdata_val); + + return 0; +} + +int32_t +client3_3_fallocate(call_frame_t *frame, xlator_t *this, void *data) +{ + clnt_args_t *args = NULL; + int64_t remote_fd = -1; + clnt_conf_t *conf = NULL; + gfs3_fallocate_req req = {{0},}; + int op_errno = ESTALE; + int ret = 0; + + if (!frame || !this || !data) + goto unwind; + + args = data; + conf = this->private; + + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); + + req.fd = remote_fd; + req.flags = args->flags; + req.offset = args->offset; + req.size = args->size; + memcpy(req.gfid, args->fd->inode->gfid, 16); + + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + + 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); + if (ret) { + gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); + } + + GF_FREE (req.xdata.xdata_val); + + return 0; +unwind: + CLIENT_STACK_UNWIND (fallocate, frame, -1, op_errno, NULL, NULL, NULL); + GF_FREE (req.xdata.xdata_val); + + return 0; +} + +int32_t +client3_3_discard(call_frame_t *frame, xlator_t *this, void *data) +{ + clnt_args_t *args = NULL; + int64_t remote_fd = -1; + clnt_conf_t *conf = NULL; + gfs3_discard_req req = {{0},}; + int op_errno = ESTALE; + int ret = 0; + + if (!frame || !this || !data) + goto unwind; + + args = data; + conf = this->private; + + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); + + req.fd = remote_fd; + req.offset = args->offset; + req.size = args->size; + memcpy(req.gfid, args->fd->inode->gfid, 16); + + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + + 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); + if (ret) + gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); + + GF_FREE (req.xdata.xdata_val); + return 0; unwind: - CLIENT_STACK_UNWIND (fsetattr, frame, -1, op_errno, NULL, NULL); + CLIENT_STACK_UNWIND(discard, frame, -1, op_errno, NULL, NULL, NULL); + GF_FREE (req.xdata.xdata_val); + return 0; } +int32_t +client3_3_zerofill(call_frame_t *frame, xlator_t *this, void *data) +{ + clnt_args_t *args = NULL; + int64_t remote_fd = -1; + clnt_conf_t *conf = NULL; + gfs3_zerofill_req req = {{0},}; + int op_errno = ESTALE; + int ret = 0; + + if (!frame || !this || !data) + goto unwind; + + args = data; + conf = this->private; + + CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, + remote_fd, op_errno, unwind); + + req.fd = remote_fd; + req.offset = args->offset; + req.size = args->size; + memcpy(req.gfid, args->fd->inode->gfid, 16); + GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val), + req.xdata.xdata_len, op_errno, unwind); + + 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); + if (ret) + gf_log (this->name, GF_LOG_WARNING, "failed to send the fop"); + + GF_FREE (req.xdata.xdata_val); + + return 0; +unwind: + CLIENT_STACK_UNWIND(zerofill, frame, -1, op_errno, NULL, NULL, NULL); + GF_FREE (req.xdata.xdata_val); + + return 0; +} /* Table Specific to FOPS */ -rpc_clnt_procedure_t clnt3_1_fop_actors[GF_FOP_MAXVALUE] = { +rpc_clnt_procedure_t clnt3_3_fop_actors[GF_FOP_MAXVALUE] = { [GF_FOP_NULL] = { "NULL", NULL}, - [GF_FOP_STAT] = { "STAT", client3_1_stat }, - [GF_FOP_READLINK] = { "READLINK", client3_1_readlink }, - [GF_FOP_MKNOD] = { "MKNOD", client3_1_mknod }, - [GF_FOP_MKDIR] = { "MKDIR", client3_1_mkdir }, - [GF_FOP_UNLINK] = { "UNLINK", client3_1_unlink }, - [GF_FOP_RMDIR] = { "RMDIR", client3_1_rmdir }, - [GF_FOP_SYMLINK] = { "SYMLINK", client3_1_symlink }, - [GF_FOP_RENAME] = { "RENAME", client3_1_rename }, - [GF_FOP_LINK] = { "LINK", client3_1_link }, - [GF_FOP_TRUNCATE] = { "TRUNCATE", client3_1_truncate }, - [GF_FOP_OPEN] = { "OPEN", client3_1_open }, - [GF_FOP_READ] = { "READ", client3_1_readv }, - [GF_FOP_WRITE] = { "WRITE", client3_1_writev }, - [GF_FOP_STATFS] = { "STATFS", client3_1_statfs }, - [GF_FOP_FLUSH] = { "FLUSH", client3_1_flush }, - [GF_FOP_FSYNC] = { "FSYNC", client3_1_fsync }, - [GF_FOP_SETXATTR] = { "SETXATTR", client3_1_setxattr }, - [GF_FOP_GETXATTR] = { "GETXATTR", client3_1_getxattr }, - [GF_FOP_REMOVEXATTR] = { "REMOVEXATTR", client3_1_removexattr }, - [GF_FOP_OPENDIR] = { "OPENDIR", client3_1_opendir }, - [GF_FOP_FSYNCDIR] = { "FSYNCDIR", client3_1_fsyncdir }, - [GF_FOP_ACCESS] = { "ACCESS", client3_1_access }, - [GF_FOP_CREATE] = { "CREATE", client3_1_create }, - [GF_FOP_FTRUNCATE] = { "FTRUNCATE", client3_1_ftruncate }, - [GF_FOP_FSTAT] = { "FSTAT", client3_1_fstat }, - [GF_FOP_LK] = { "LK", client3_1_lk }, - [GF_FOP_LOOKUP] = { "LOOKUP", client3_1_lookup }, - [GF_FOP_READDIR] = { "READDIR", client3_1_readdir }, - [GF_FOP_INODELK] = { "INODELK", client3_1_inodelk }, - [GF_FOP_FINODELK] = { "FINODELK", client3_1_finodelk }, - [GF_FOP_ENTRYLK] = { "ENTRYLK", client3_1_entrylk }, - [GF_FOP_FENTRYLK] = { "FENTRYLK", client3_1_fentrylk }, - [GF_FOP_XATTROP] = { "XATTROP", client3_1_xattrop }, - [GF_FOP_FXATTROP] = { "FXATTROP", client3_1_fxattrop }, - [GF_FOP_FGETXATTR] = { "FGETXATTR", client3_1_fgetxattr }, - [GF_FOP_FSETXATTR] = { "FSETXATTR", client3_1_fsetxattr }, - [GF_FOP_RCHECKSUM] = { "RCHECKSUM", client3_1_rchecksum }, - [GF_FOP_SETATTR] = { "SETATTR", client3_1_setattr }, - [GF_FOP_FSETATTR] = { "FSETATTR", client3_1_fsetattr }, - [GF_FOP_READDIRP] = { "READDIRP", client3_1_readdirp }, - [GF_FOP_RELEASE] = { "RELEASE", client3_1_release }, - [GF_FOP_RELEASEDIR] = { "RELEASEDIR", client3_1_releasedir }, + [GF_FOP_STAT] = { "STAT", client3_3_stat }, + [GF_FOP_READLINK] = { "READLINK", client3_3_readlink }, + [GF_FOP_MKNOD] = { "MKNOD", client3_3_mknod }, + [GF_FOP_MKDIR] = { "MKDIR", client3_3_mkdir }, + [GF_FOP_UNLINK] = { "UNLINK", client3_3_unlink }, + [GF_FOP_RMDIR] = { "RMDIR", client3_3_rmdir }, + [GF_FOP_SYMLINK] = { "SYMLINK", client3_3_symlink }, + [GF_FOP_RENAME] = { "RENAME", client3_3_rename }, + [GF_FOP_LINK] = { "LINK", client3_3_link }, + [GF_FOP_TRUNCATE] = { "TRUNCATE", client3_3_truncate }, + [GF_FOP_OPEN] = { "OPEN", client3_3_open }, + [GF_FOP_READ] = { "READ", client3_3_readv }, + [GF_FOP_WRITE] = { "WRITE", client3_3_writev }, + [GF_FOP_STATFS] = { "STATFS", client3_3_statfs }, + [GF_FOP_FLUSH] = { "FLUSH", client3_3_flush }, + [GF_FOP_FSYNC] = { "FSYNC", client3_3_fsync }, + [GF_FOP_SETXATTR] = { "SETXATTR", client3_3_setxattr }, + [GF_FOP_GETXATTR] = { "GETXATTR", client3_3_getxattr }, + [GF_FOP_REMOVEXATTR] = { "REMOVEXATTR", client3_3_removexattr }, + [GF_FOP_OPENDIR] = { "OPENDIR", client3_3_opendir }, + [GF_FOP_FSYNCDIR] = { "FSYNCDIR", client3_3_fsyncdir }, + [GF_FOP_ACCESS] = { "ACCESS", client3_3_access }, + [GF_FOP_CREATE] = { "CREATE", client3_3_create }, + [GF_FOP_FTRUNCATE] = { "FTRUNCATE", client3_3_ftruncate }, + [GF_FOP_FSTAT] = { "FSTAT", client3_3_fstat }, + [GF_FOP_LK] = { "LK", client3_3_lk }, + [GF_FOP_LOOKUP] = { "LOOKUP", client3_3_lookup }, + [GF_FOP_READDIR] = { "READDIR", client3_3_readdir }, + [GF_FOP_INODELK] = { "INODELK", client3_3_inodelk }, + [GF_FOP_FINODELK] = { "FINODELK", client3_3_finodelk }, + [GF_FOP_ENTRYLK] = { "ENTRYLK", client3_3_entrylk }, + [GF_FOP_FENTRYLK] = { "FENTRYLK", client3_3_fentrylk }, + [GF_FOP_XATTROP] = { "XATTROP", client3_3_xattrop }, + [GF_FOP_FXATTROP] = { "FXATTROP", client3_3_fxattrop }, + [GF_FOP_FGETXATTR] = { "FGETXATTR", client3_3_fgetxattr }, + [GF_FOP_FSETXATTR] = { "FSETXATTR", client3_3_fsetxattr }, + [GF_FOP_RCHECKSUM] = { "RCHECKSUM", client3_3_rchecksum }, + [GF_FOP_SETATTR] = { "SETATTR", client3_3_setattr }, + [GF_FOP_FSETATTR] = { "FSETATTR", client3_3_fsetattr }, + [GF_FOP_READDIRP] = { "READDIRP", client3_3_readdirp }, + [GF_FOP_FALLOCATE] = { "FALLOCATE", client3_3_fallocate }, + [GF_FOP_DISCARD] = { "DISCARD", client3_3_discard }, + [GF_FOP_ZEROFILL] = { "ZEROFILL", client3_3_zerofill}, + [GF_FOP_RELEASE] = { "RELEASE", client3_3_release }, + [GF_FOP_RELEASEDIR] = { "RELEASEDIR", client3_3_releasedir }, [GF_FOP_GETSPEC] = { "GETSPEC", client3_getspec }, - [GF_FOP_FREMOVEXATTR] = { "FREMOVEXATTR", client3_1_fremovexattr }, + [GF_FOP_FREMOVEXATTR] = { "FREMOVEXATTR", client3_3_fremovexattr }, }; /* Used From RPC-CLNT library to log proper name of procedure based on number */ -char *clnt3_1_fop_names[GFS3_OP_MAXVALUE] = { +char *clnt3_3_fop_names[GFS3_OP_MAXVALUE] = { [GFS3_OP_NULL] = "NULL", [GFS3_OP_STAT] = "STAT", [GFS3_OP_READLINK] = "READLINK", @@ -5102,13 +6187,17 @@ char *clnt3_1_fop_names[GFS3_OP_MAXVALUE] = { [GFS3_OP_RELEASE] = "RELEASE", [GFS3_OP_RELEASEDIR] = "RELEASEDIR", [GFS3_OP_FREMOVEXATTR] = "FREMOVEXATTR", + [GFS3_OP_FALLOCATE] = "FALLOCATE", + [GFS3_OP_DISCARD] = "DISCARD", + [GFS3_OP_ZEROFILL] = "ZEROFILL", + }; -rpc_clnt_prog_t clnt3_1_fop_prog = { - .progname = "GlusterFS 3.1", - .prognum = GLUSTER3_1_FOP_PROGRAM, - .progver = GLUSTER3_1_FOP_VERSION, - .numproc = GLUSTER3_1_FOP_PROCCNT, - .proctable = clnt3_1_fop_actors, - .procnames = clnt3_1_fop_names, +rpc_clnt_prog_t clnt3_3_fop_prog = { + .progname = "GlusterFS 3.3", + .prognum = GLUSTER_FOP_PROGRAM, + .progver = GLUSTER_FOP_VERSION, + .numproc = GLUSTER_FOP_PROCCNT, + .proctable = clnt3_3_fop_actors, + .procnames = clnt3_3_fop_names, }; diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c index 82d90d257..1f7d13ea4 100644 --- a/xlators/protocol/client/src/client.c +++ b/xlators/protocol/client/src/client.c @@ -1,20 +1,11 @@ /* - Copyright (c) 2010-2011 Gluster, Inc. <http://www.gluster.com> + Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com> This file is part of GlusterFS. - GlusterFS is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - GlusterFS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see - <http://www.gnu.org/licenses/>. + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. */ @@ -134,9 +125,12 @@ client_register_grace_timer (xlator_t *this, clnt_conf_t *conf) } else { gf_log (this->name, GF_LOG_INFO, "Registering a grace timer"); + + conf->grace_timer_needed = _gf_false; + conf->grace_timer = gf_timer_call_after (this->ctx, - conf->grace_tv, + conf->grace_ts, client_grace_timeout, conf->rpc); } @@ -255,7 +249,7 @@ client_submit_request (xlator_t *this, void *req, call_frame_t *frame, ret = 0; - if (new_iobref != NULL) + if (new_iobref) iobref_unref (new_iobref); if (iobuf) @@ -268,11 +262,11 @@ out: cbkfn (&rpcreq, NULL, 0, frame); - if (new_iobref != NULL) { + if (new_iobref) iobref_unref (new_iobref); - } - iobuf_unref (iobuf); + if (iobuf) + iobuf_unref (iobuf); return 0; } @@ -349,7 +343,7 @@ out: int32_t client_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, - dict_t *xattr_req) + dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -361,7 +355,7 @@ client_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, goto out; args.loc = loc; - args.dict = xattr_req; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_LOOKUP]; if (!proc) { @@ -383,7 +377,7 @@ out: int32_t -client_stat (call_frame_t *frame, xlator_t *this, loc_t *loc) +client_stat (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -395,6 +389,7 @@ client_stat (call_frame_t *frame, xlator_t *this, loc_t *loc) goto out; args.loc = loc; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_STAT]; if (!proc) { @@ -407,14 +402,15 @@ client_stat (call_frame_t *frame, xlator_t *this, loc_t *loc) ret = proc->fn (frame, this, &args); out: if (ret) - STACK_UNWIND_STRICT (stat, frame, -1, ENOTCONN, NULL); + STACK_UNWIND_STRICT (stat, frame, -1, ENOTCONN, NULL, NULL); return 0; } int32_t -client_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset) +client_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, + off_t offset, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -427,6 +423,7 @@ client_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset) args.loc = loc; args.offset = offset; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_TRUNCATE]; if (!proc) { @@ -439,7 +436,7 @@ client_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset) ret = proc->fn (frame, this, &args); out: if (ret) - STACK_UNWIND_STRICT (truncate, frame, -1, ENOTCONN, NULL, NULL); + STACK_UNWIND_STRICT (truncate, frame, -1, ENOTCONN, NULL, NULL, NULL); return 0; @@ -447,7 +444,8 @@ out: int32_t -client_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset) +client_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, + off_t offset, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -460,6 +458,7 @@ client_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset) args.fd = fd; args.offset = offset; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_FTRUNCATE]; if (!proc) { @@ -472,7 +471,7 @@ client_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset) ret = proc->fn (frame, this, &args); out: if (ret) - STACK_UNWIND_STRICT (ftruncate, frame, -1, ENOTCONN, NULL, NULL); + STACK_UNWIND_STRICT (ftruncate, frame, -1, ENOTCONN, NULL, NULL, NULL); return 0; } @@ -480,7 +479,8 @@ out: int32_t -client_access (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t mask) +client_access (call_frame_t *frame, xlator_t *this, loc_t *loc, + int32_t mask, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -493,6 +493,7 @@ client_access (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t mask) args.loc = loc; args.mask = mask; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_ACCESS]; if (!proc) { @@ -505,7 +506,7 @@ client_access (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t mask) ret = proc->fn (frame, this, &args); out: if (ret) - STACK_UNWIND_STRICT (access, frame, -1, ENOTCONN); + STACK_UNWIND_STRICT (access, frame, -1, ENOTCONN, NULL); return 0; } @@ -514,7 +515,8 @@ out: int32_t -client_readlink (call_frame_t *frame, xlator_t *this, loc_t *loc, size_t size) +client_readlink (call_frame_t *frame, xlator_t *this, loc_t *loc, + size_t size, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -527,6 +529,7 @@ client_readlink (call_frame_t *frame, xlator_t *this, loc_t *loc, size_t size) args.loc = loc; args.size = size; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_READLINK]; if (!proc) { @@ -539,7 +542,7 @@ client_readlink (call_frame_t *frame, xlator_t *this, loc_t *loc, size_t size) ret = proc->fn (frame, this, &args); out: if (ret) - STACK_UNWIND_STRICT (readlink, frame, -1, ENOTCONN, NULL, NULL); + STACK_UNWIND_STRICT (readlink, frame, -1, ENOTCONN, NULL, NULL, NULL); return 0; } @@ -547,7 +550,7 @@ out: int client_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, - dev_t rdev, dict_t *params) + dev_t rdev, mode_t umask, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -561,7 +564,8 @@ client_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, args.loc = loc; args.mode = mode; args.rdev = rdev; - args.dict = params; + args.umask = umask; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_MKNOD]; if (!proc) { @@ -575,7 +579,7 @@ client_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, out: if (ret) STACK_UNWIND_STRICT (mknod, frame, -1, ENOTCONN, - NULL, NULL, NULL, NULL); + NULL, NULL, NULL, NULL, NULL); return 0; } @@ -583,7 +587,7 @@ out: int client_mkdir (call_frame_t *frame, xlator_t *this, loc_t *loc, - mode_t mode, dict_t *params) + mode_t mode, mode_t umask, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -596,7 +600,8 @@ client_mkdir (call_frame_t *frame, xlator_t *this, loc_t *loc, args.loc = loc; args.mode = mode; - args.dict = params; + args.umask = umask; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_MKDIR]; if (!proc) { @@ -610,7 +615,7 @@ client_mkdir (call_frame_t *frame, xlator_t *this, loc_t *loc, out: if (ret) STACK_UNWIND_STRICT (mkdir, frame, -1, ENOTCONN, - NULL, NULL, NULL, NULL); + NULL, NULL, NULL, NULL, NULL); return 0; } @@ -618,7 +623,8 @@ out: int32_t -client_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc) +client_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc, + int xflag, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -630,6 +636,8 @@ client_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc) goto out; args.loc = loc; + args.xdata = xdata; + args.flags = xflag; proc = &conf->fops->proctable[GF_FOP_UNLINK]; if (!proc) { @@ -643,13 +651,14 @@ client_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc) out: if (ret) STACK_UNWIND_STRICT (unlink, frame, -1, ENOTCONN, - NULL, NULL); + NULL, NULL, NULL); return 0; } int32_t -client_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags) +client_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags, + dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -662,6 +671,7 @@ client_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags) args.loc = loc; args.flags = flags; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_RMDIR]; if (!proc) { @@ -676,7 +686,7 @@ out: /* think of avoiding a missing frame */ if (ret) STACK_UNWIND_STRICT (rmdir, frame, -1, ENOTCONN, - NULL, NULL); + NULL, NULL, NULL); return 0; } @@ -684,7 +694,7 @@ out: int client_symlink (call_frame_t *frame, xlator_t *this, const char *linkpath, - loc_t *loc, dict_t *params) + loc_t *loc, mode_t umask, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -697,7 +707,8 @@ client_symlink (call_frame_t *frame, xlator_t *this, const char *linkpath, args.linkname = linkpath; args.loc = loc; - args.dict = params; + args.umask = umask; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_SYMLINK]; if (!proc) { @@ -711,7 +722,7 @@ client_symlink (call_frame_t *frame, xlator_t *this, const char *linkpath, out: if (ret) STACK_UNWIND_STRICT (symlink, frame, -1, ENOTCONN, - NULL, NULL, NULL, NULL); + NULL, NULL, NULL, NULL, NULL); return 0; } @@ -720,7 +731,7 @@ out: int32_t client_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc, - loc_t *newloc) + loc_t *newloc, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -733,6 +744,8 @@ client_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc, args.oldloc = oldloc; args.newloc = newloc; + args.xdata = xdata; + proc = &conf->fops->proctable[GF_FOP_RENAME]; if (!proc) { gf_log (this->name, GF_LOG_ERROR, @@ -745,7 +758,7 @@ client_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc, out: if (ret) STACK_UNWIND_STRICT (rename, frame, -1, ENOTCONN, - NULL, NULL, NULL, NULL, NULL); + NULL, NULL, NULL, NULL, NULL, NULL); return 0; } @@ -754,7 +767,7 @@ out: int32_t client_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, - loc_t *newloc) + loc_t *newloc, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -767,6 +780,7 @@ client_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, args.oldloc = oldloc; args.newloc = newloc; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_LINK]; if (!proc) { @@ -780,7 +794,7 @@ client_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, out: if (ret) STACK_UNWIND_STRICT (link, frame, -1, ENOTCONN, - NULL, NULL, NULL, NULL); + NULL, NULL, NULL, NULL, NULL); return 0; } @@ -788,8 +802,8 @@ out: int32_t -client_create (call_frame_t *frame, xlator_t *this, loc_t *loc, - int32_t flags, mode_t mode, fd_t *fd, dict_t *params) +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) { int ret = -1; clnt_conf_t *conf = NULL; @@ -801,10 +815,15 @@ client_create (call_frame_t *frame, xlator_t *this, loc_t *loc, goto out; args.loc = loc; - args.flags = flags; args.mode = mode; args.fd = fd; - args.dict = params; + args.umask = umask; + args.xdata = xdata; + + if (!conf->filter_o_direct) + args.flags = flags; + else + args.flags = (flags & ~O_DIRECT); proc = &conf->fops->proctable[GF_FOP_CREATE]; if (!proc) { @@ -818,7 +837,7 @@ client_create (call_frame_t *frame, xlator_t *this, loc_t *loc, out: if (ret) STACK_UNWIND_STRICT (create, frame, -1, ENOTCONN, - NULL, NULL, NULL, NULL, NULL); + NULL, NULL, NULL, NULL, NULL, NULL); return 0; } @@ -827,7 +846,7 @@ out: int32_t client_open (call_frame_t *frame, xlator_t *this, loc_t *loc, - int32_t flags, fd_t *fd, int32_t wbflags) + int32_t flags, fd_t *fd, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -839,9 +858,13 @@ client_open (call_frame_t *frame, xlator_t *this, loc_t *loc, goto out; args.loc = loc; - args.flags = flags; args.fd = fd; - args.wbflags = wbflags; + args.xdata = xdata; + + if (!conf->filter_o_direct) + args.flags = flags; + else + args.flags = (flags & ~O_DIRECT); proc = &conf->fops->proctable[GF_FOP_OPEN]; if (!proc) { @@ -855,7 +878,7 @@ client_open (call_frame_t *frame, xlator_t *this, loc_t *loc, out: if (ret) - STACK_UNWIND_STRICT (open, frame, -1, ENOTCONN, NULL); + STACK_UNWIND_STRICT (open, frame, -1, ENOTCONN, NULL, NULL); return 0; } @@ -864,7 +887,7 @@ out: int32_t client_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, - off_t offset, uint32_t flags) + off_t offset, uint32_t flags, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -879,6 +902,7 @@ client_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, args.size = size; args.offset = offset; args.flags = flags; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_READ]; if (!proc) { @@ -893,7 +917,7 @@ client_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, out: if (ret) STACK_UNWIND_STRICT (readv, frame, -1, ENOTCONN, - NULL, 0, NULL, NULL); + NULL, 0, NULL, NULL, NULL); return 0; } @@ -904,7 +928,7 @@ out: 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) + uint32_t flags, struct iobref *iobref, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -921,6 +945,7 @@ client_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, args.offset = off; args.flags = flags; args.iobref = iobref; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_WRITE]; if (!proc) { @@ -933,14 +958,14 @@ client_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, ret = proc->fn (frame, this, &args); out: if (ret) - STACK_UNWIND_STRICT (writev, frame, -1, ENOTCONN, NULL, NULL); + STACK_UNWIND_STRICT (writev, frame, -1, ENOTCONN, NULL, NULL, NULL); return 0; } int32_t -client_flush (call_frame_t *frame, xlator_t *this, fd_t *fd) +client_flush (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -952,6 +977,7 @@ client_flush (call_frame_t *frame, xlator_t *this, fd_t *fd) goto out; args.fd = fd; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_FLUSH]; if (!proc) { @@ -964,7 +990,7 @@ client_flush (call_frame_t *frame, xlator_t *this, fd_t *fd) ret = proc->fn (frame, this, &args); out: if (ret) - STACK_UNWIND_STRICT (flush, frame, -1, ENOTCONN); + STACK_UNWIND_STRICT (flush, frame, -1, ENOTCONN, NULL); return 0; } @@ -973,7 +999,7 @@ out: int32_t client_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd, - int32_t flags) + int32_t flags, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -986,6 +1012,7 @@ client_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd, args.fd = fd; args.flags = flags; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_FSYNC]; if (!proc) { @@ -998,7 +1025,7 @@ client_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd, ret = proc->fn (frame, this, &args); out: if (ret) - STACK_UNWIND_STRICT (fsync, frame, -1, ENOTCONN, NULL, NULL); + STACK_UNWIND_STRICT (fsync, frame, -1, ENOTCONN, NULL, NULL, NULL); return 0; } @@ -1006,7 +1033,7 @@ out: int32_t -client_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd) +client_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -1018,6 +1045,7 @@ client_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd) goto out; args.fd = fd; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_FSTAT]; if (!proc) { @@ -1030,7 +1058,7 @@ client_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd) ret = proc->fn (frame, this, &args); out: if (ret) - STACK_UNWIND_STRICT (fstat, frame, -1, ENOTCONN, NULL); + STACK_UNWIND_STRICT (fstat, frame, -1, ENOTCONN, NULL, NULL); return 0; } @@ -1038,7 +1066,8 @@ out: int32_t -client_opendir (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd) +client_opendir (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd, + dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -1051,6 +1080,7 @@ client_opendir (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd) args.loc = loc; args.fd = fd; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_OPENDIR]; if (!proc) { @@ -1063,7 +1093,7 @@ client_opendir (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd) ret = proc->fn (frame, this, &args); out: if (ret) - STACK_UNWIND_STRICT (opendir, frame, -1, ENOTCONN, NULL); + STACK_UNWIND_STRICT (opendir, frame, -1, ENOTCONN, NULL, NULL); return 0; } @@ -1071,7 +1101,7 @@ out: int32_t -client_fsyncdir (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags) +client_fsyncdir (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -1084,6 +1114,7 @@ client_fsyncdir (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags) args.fd = fd; args.flags = flags; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_FSYNCDIR]; if (!proc) { @@ -1096,7 +1127,7 @@ client_fsyncdir (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags) ret = proc->fn (frame, this, &args); out: if (ret) - STACK_UNWIND_STRICT (fsyncdir, frame, -1, ENOTCONN); + STACK_UNWIND_STRICT (fsyncdir, frame, -1, ENOTCONN, NULL); return 0; } @@ -1104,7 +1135,7 @@ out: int32_t -client_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc) +client_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -1116,6 +1147,7 @@ client_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc) goto out; args.loc = loc; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_STATFS]; if (!proc) { @@ -1128,7 +1160,7 @@ client_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc) ret = proc->fn (frame, this, &args); out: if (ret) - STACK_UNWIND_STRICT (statfs, frame, -1, ENOTCONN, NULL); + STACK_UNWIND_STRICT (statfs, frame, -1, ENOTCONN, NULL, NULL); return 0; } @@ -1245,8 +1277,7 @@ client_set_remote_options (char *value, xlator_t *this) ret = _gf_true; out: - if (dup_value) - GF_FREE (dup_value); + GF_FREE (dup_value); return ret; } @@ -1254,7 +1285,7 @@ out: int32_t client_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict, - int32_t flags) + int32_t flags, dict_t *xdata) { int ret = -1; int op_ret = -1; @@ -1302,8 +1333,9 @@ client_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict, } args.loc = loc; - args.dict = dict; + args.xattr = dict; args.flags = flags; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_SETXATTR]; if (!proc) { @@ -1320,7 +1352,7 @@ client_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict, } out: if (need_unwind) - STACK_UNWIND_STRICT (setxattr, frame, op_ret, op_errno); + STACK_UNWIND_STRICT (setxattr, frame, op_ret, op_errno, NULL); return 0; } @@ -1329,7 +1361,7 @@ out: int32_t client_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, - dict_t *dict, int32_t flags) + dict_t *dict, int32_t flags, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -1340,9 +1372,10 @@ client_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, if (!conf || !conf->fops) goto out; - args.fd = fd; - args.dict = dict; + args.fd = fd; + args.xattr = dict; args.flags = flags; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_FSETXATTR]; if (!proc) { @@ -1355,7 +1388,7 @@ client_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, ret = proc->fn (frame, this, &args); out: if (ret) - STACK_UNWIND_STRICT (fsetxattr, frame, -1, ENOTCONN); + STACK_UNWIND_STRICT (fsetxattr, frame, -1, ENOTCONN, NULL); return 0; } @@ -1365,7 +1398,7 @@ out: int32_t client_fgetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, - const char *name) + const char *name, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -1378,6 +1411,7 @@ client_fgetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, args.fd = fd; args.name = name; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_FGETXATTR]; if (!proc) { @@ -1390,7 +1424,7 @@ client_fgetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, ret = proc->fn (frame, this, &args); out: if (ret) - STACK_UNWIND_STRICT (fgetxattr, frame, -1, ENOTCONN, NULL); + STACK_UNWIND_STRICT (fgetxattr, frame, -1, ENOTCONN, NULL, NULL); return 0; } @@ -1399,7 +1433,7 @@ out: int32_t client_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, - const char *name) + const char *name, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -1412,6 +1446,7 @@ client_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, args.name = name; args.loc = loc; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_GETXATTR]; if (!proc) { @@ -1424,7 +1459,7 @@ client_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, ret = proc->fn (frame, this, &args); out: if (ret) - STACK_UNWIND_STRICT (getxattr, frame, -1, ENOTCONN, NULL); + STACK_UNWIND_STRICT (getxattr, frame, -1, ENOTCONN, NULL, NULL); return 0; } @@ -1433,7 +1468,7 @@ out: int32_t client_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, - gf_xattrop_flags_t flags, dict_t *dict) + gf_xattrop_flags_t flags, dict_t *dict, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -1446,7 +1481,8 @@ client_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, args.loc = loc; args.flags = flags; - args.dict = dict; + args.xattr = dict; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_XATTROP]; if (!proc) { @@ -1459,7 +1495,7 @@ client_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, ret = proc->fn (frame, this, &args); out: if (ret) - STACK_UNWIND_STRICT (xattrop, frame, -1, ENOTCONN, NULL); + STACK_UNWIND_STRICT (xattrop, frame, -1, ENOTCONN, NULL, NULL); return 0; } @@ -1468,7 +1504,7 @@ out: int32_t client_fxattrop (call_frame_t *frame, xlator_t *this, fd_t *fd, - gf_xattrop_flags_t flags, dict_t *dict) + gf_xattrop_flags_t flags, dict_t *dict, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -1481,7 +1517,8 @@ client_fxattrop (call_frame_t *frame, xlator_t *this, fd_t *fd, args.fd = fd; args.flags = flags; - args.dict = dict; + args.xattr = dict; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_FXATTROP]; if (!proc) { @@ -1494,7 +1531,7 @@ client_fxattrop (call_frame_t *frame, xlator_t *this, fd_t *fd, ret = proc->fn (frame, this, &args); out: if (ret) - STACK_UNWIND_STRICT (fxattrop, frame, -1, ENOTCONN, NULL); + STACK_UNWIND_STRICT (fxattrop, frame, -1, ENOTCONN, NULL, NULL); return 0; } @@ -1503,7 +1540,7 @@ out: int32_t client_removexattr (call_frame_t *frame, xlator_t *this, loc_t *loc, - const char *name) + const char *name, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -1516,6 +1553,7 @@ client_removexattr (call_frame_t *frame, xlator_t *this, loc_t *loc, args.name = name; args.loc = loc; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_REMOVEXATTR]; if (!proc) { @@ -1528,14 +1566,14 @@ client_removexattr (call_frame_t *frame, xlator_t *this, loc_t *loc, ret = proc->fn (frame, this, &args); out: if (ret) - STACK_UNWIND_STRICT (removexattr, frame, -1, ENOTCONN); + STACK_UNWIND_STRICT (removexattr, frame, -1, ENOTCONN, NULL); return 0; } int32_t client_fremovexattr (call_frame_t *frame, xlator_t *this, fd_t *fd, - const char *name) + const char *name, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -1548,6 +1586,7 @@ client_fremovexattr (call_frame_t *frame, xlator_t *this, fd_t *fd, args.name = name; args.fd = fd; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_FREMOVEXATTR]; if (!proc) { @@ -1560,14 +1599,14 @@ client_fremovexattr (call_frame_t *frame, xlator_t *this, fd_t *fd, ret = proc->fn (frame, this, &args); out: if (ret) - STACK_UNWIND_STRICT (fremovexattr, frame, -1, ENOTCONN); + STACK_UNWIND_STRICT (fremovexattr, frame, -1, ENOTCONN, NULL); return 0; } int32_t client_lk (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd, - struct gf_flock *lock) + struct gf_flock *lock, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -1581,6 +1620,7 @@ client_lk (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd, args.fd = fd; args.cmd = cmd; args.flock = lock; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_LK]; if (!proc) { @@ -1593,7 +1633,7 @@ client_lk (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd, ret = proc->fn (frame, this, &args); out: if (ret) - STACK_UNWIND_STRICT (lk, frame, -1, ENOTCONN, NULL); + STACK_UNWIND_STRICT (lk, frame, -1, ENOTCONN, NULL, NULL); return 0; } @@ -1601,7 +1641,7 @@ out: int32_t client_inodelk (call_frame_t *frame, xlator_t *this, const char *volume, - loc_t *loc, int32_t cmd, struct gf_flock *lock) + loc_t *loc, int32_t cmd, struct gf_flock *lock, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -1616,6 +1656,7 @@ client_inodelk (call_frame_t *frame, xlator_t *this, const char *volume, args.cmd = cmd; args.flock = lock; args.volume = volume; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_INODELK]; if (!proc) { @@ -1628,7 +1669,7 @@ client_inodelk (call_frame_t *frame, xlator_t *this, const char *volume, ret = proc->fn (frame, this, &args); out: if (ret) - STACK_UNWIND_STRICT (inodelk, frame, -1, ENOTCONN); + STACK_UNWIND_STRICT (inodelk, frame, -1, ENOTCONN, NULL); return 0; } @@ -1637,7 +1678,7 @@ out: int32_t client_finodelk (call_frame_t *frame, xlator_t *this, const char *volume, - fd_t *fd, int32_t cmd, struct gf_flock *lock) + fd_t *fd, int32_t cmd, struct gf_flock *lock, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -1652,6 +1693,7 @@ client_finodelk (call_frame_t *frame, xlator_t *this, const char *volume, args.cmd = cmd; args.flock = lock; args.volume = volume; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_FINODELK]; if (!proc) { @@ -1664,7 +1706,7 @@ client_finodelk (call_frame_t *frame, xlator_t *this, const char *volume, ret = proc->fn (frame, this, &args); out: if (ret) - STACK_UNWIND_STRICT (finodelk, frame, -1, ENOTCONN); + STACK_UNWIND_STRICT (finodelk, frame, -1, ENOTCONN, NULL); return 0; } @@ -1673,7 +1715,7 @@ out: 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) + entrylk_type type, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -1689,6 +1731,7 @@ client_entrylk (call_frame_t *frame, xlator_t *this, const char *volume, args.type = type; args.volume = volume; args.cmd_entrylk = cmd; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_ENTRYLK]; if (!proc) { @@ -1701,7 +1744,7 @@ client_entrylk (call_frame_t *frame, xlator_t *this, const char *volume, ret = proc->fn (frame, this, &args); out: if (ret) - STACK_UNWIND_STRICT (entrylk, frame, -1, ENOTCONN); + STACK_UNWIND_STRICT (entrylk, frame, -1, ENOTCONN, NULL); return 0; } @@ -1711,7 +1754,7 @@ out: 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) + entrylk_type type, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -1727,6 +1770,7 @@ client_fentrylk (call_frame_t *frame, xlator_t *this, const char *volume, args.type = type; args.volume = volume; args.cmd_entrylk = cmd; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_FENTRYLK]; if (!proc) { @@ -1739,7 +1783,7 @@ client_fentrylk (call_frame_t *frame, xlator_t *this, const char *volume, ret = proc->fn (frame, this, &args); out: if (ret) - STACK_UNWIND_STRICT (fentrylk, frame, -1, ENOTCONN); + STACK_UNWIND_STRICT (fentrylk, frame, -1, ENOTCONN, NULL); return 0; } @@ -1747,7 +1791,7 @@ out: int32_t client_rchecksum (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, - int32_t len) + int32_t len, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -1761,6 +1805,7 @@ client_rchecksum (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, args.fd = fd; args.offset = offset; args.len = len; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_RCHECKSUM]; if (!proc) { @@ -1773,14 +1818,14 @@ client_rchecksum (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, ret = proc->fn (frame, this, &args); out: if (ret) - STACK_UNWIND_STRICT (rchecksum, frame, -1, ENOTCONN, 0, NULL); + STACK_UNWIND_STRICT (rchecksum, frame, -1, ENOTCONN, 0, NULL, NULL); return 0; } int32_t client_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd, - size_t size, off_t off) + size_t size, off_t off, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -1794,6 +1839,7 @@ client_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd, args.fd = fd; args.size = size; args.offset = off; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_READDIR]; if (!proc) { @@ -1806,7 +1852,7 @@ client_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd, ret = proc->fn (frame, this, &args); out: if (ret) - STACK_UNWIND_STRICT (readdir, frame, -1, ENOTCONN, NULL); + STACK_UNWIND_STRICT (readdir, frame, -1, ENOTCONN, NULL, NULL); return 0; } @@ -1828,7 +1874,7 @@ client_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, args.fd = fd; args.size = size; args.offset = off; - args.dict = dict; + args.xdata = dict; proc = &conf->fops->proctable[GF_FOP_READDIRP]; if (!proc) { @@ -1841,7 +1887,7 @@ client_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, ret = proc->fn (frame, this, &args); out: if (ret) - STACK_UNWIND_STRICT (readdirp, frame, -1, ENOTCONN, NULL); + STACK_UNWIND_STRICT (readdirp, frame, -1, ENOTCONN, NULL, NULL); return 0; } @@ -1849,7 +1895,7 @@ out: int32_t client_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc, - struct iatt *stbuf, int32_t valid) + struct iatt *stbuf, int32_t valid, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -1863,6 +1909,7 @@ client_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc, args.loc = loc; args.stbuf = stbuf; args.valid = valid; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_SETATTR]; if (!proc) { @@ -1875,14 +1922,14 @@ client_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc, ret = proc->fn (frame, this, &args); out: if (ret) - STACK_UNWIND_STRICT (setattr, frame, -1, ENOTCONN, NULL, NULL); + STACK_UNWIND_STRICT (setattr, frame, -1, ENOTCONN, NULL, NULL, NULL); return 0; } int32_t client_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd, - struct iatt *stbuf, int32_t valid) + struct iatt *stbuf, int32_t valid, dict_t *xdata) { int ret = -1; clnt_conf_t *conf = NULL; @@ -1896,6 +1943,7 @@ client_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd, args.fd = fd; args.stbuf = stbuf; args.valid = valid; + args.xdata = xdata; proc = &conf->fops->proctable[GF_FOP_FSETATTR]; if (!proc) { @@ -1908,11 +1956,115 @@ client_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd, ret = proc->fn (frame, this, &args); out: if (ret) - STACK_UNWIND_STRICT (fsetattr, frame, -1, ENOTCONN, NULL, NULL); + STACK_UNWIND_STRICT (fsetattr, frame, -1, ENOTCONN, NULL, NULL, NULL); + + return 0; +} + +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) +{ + 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; + + args.fd = fd; + args.flags = mode; + args.offset = offset; + args.size = len; + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_FALLOCATE]; + if (!proc) { + gf_log (this->name, GF_LOG_ERROR, + "rpc procedure not found for %s", + gf_fop_list[GF_FOP_FALLOCATE]); + goto out; + } + if (proc->fn) + ret = proc->fn (frame, this, &args); +out: + if (ret) + STACK_UNWIND_STRICT (fallocate, frame, -1, ENOTCONN, NULL, NULL, NULL); + + return 0; +} + +int32_t +client_discard(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, + size_t len, 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; + + args.fd = fd; + args.offset = offset; + args.size = len; + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_DISCARD]; + if (!proc) { + gf_log (this->name, GF_LOG_ERROR, + "rpc procedure not found for %s", + gf_fop_list[GF_FOP_DISCARD]); + goto out; + } + if (proc->fn) + ret = proc->fn (frame, this, &args); +out: + if (ret) + STACK_UNWIND_STRICT(discard, frame, -1, ENOTCONN, NULL, NULL, NULL); return 0; } +int32_t +client_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, + size_t len, 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; + + args.fd = fd; + args.offset = offset; + args.size = len; + args.xdata = xdata; + + proc = &conf->fops->proctable[GF_FOP_ZEROFILL]; + if (!proc) { + gf_log (this->name, GF_LOG_ERROR, + "rpc procedure not found for %s", + gf_fop_list[GF_FOP_ZEROFILL]); + goto out; + } + if (proc->fn) + ret = proc->fn (frame, this, &args); +out: + if (ret) + STACK_UNWIND_STRICT(zerofill, frame, -1, ENOTCONN, + NULL, NULL, NULL); + + return 0; +} + int32_t client_getspec (call_frame_t *frame, xlator_t *this, const char *key, @@ -2002,7 +2154,7 @@ client_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, gf_log (this->name, GF_LOG_DEBUG, "got RPC_CLNT_CONNECT"); if ((ret < 0) || (strcasecmp (handshake, "on"))) { - ret = client_handshake (this, conf->rpc); + ret = client_handshake (this, rpc); if (ret) gf_log (this->name, GF_LOG_WARNING, "handshake msg returned %d", ret); @@ -2044,9 +2196,19 @@ client_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, client_register_grace_timer (this, conf); if (!conf->skip_notify) { - if (conf->connected) - gf_log (this->name, GF_LOG_INFO, - "disconnected"); + if (conf->connected) { + gf_log (this->name, + ((!conf->disconnect_err_logged) + ? GF_LOG_INFO : GF_LOG_DEBUG), + "disconnected from %s. Client process " + "will keep trying to connect to " + "glusterd until brick's port is " + "available", + conf->rpc->conn.trans->peerinfo.identifier); + + if (conf->portmap_err_logged) + conf->disconnect_err_logged = 1; + } /* If the CHILD_DOWN event goes to parent xlator multiple times, the logic of parent xlator notify @@ -2070,6 +2232,15 @@ client_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, conf->connected = 0; conf->skip_notify = 0; + if (conf->quick_reconnect) { + conf->quick_reconnect = 0; + rpc_clnt_start (rpc); + + } else { + rpc->conn.config.remote_port = 0; + + } + break; default: @@ -2153,6 +2324,9 @@ build_client_config (xlator_t *this, clnt_conf_t *conf) gf_log (this->name, GF_LOG_WARNING, "option 'remote-subvolume' not given"); + GF_OPTION_INIT ("filter-O_DIRECT", conf->filter_o_direct, + bool, out); + ret = 0; out: return ret; @@ -2237,7 +2411,8 @@ client_init_rpc (xlator_t *this) conf->handshake = &clnt_handshake_prog; conf->dump = &clnt_dump_prog; - ret = rpcclnt_cbk_program_register (conf->rpc, &gluster_cbk_prog); + ret = rpcclnt_cbk_program_register (conf->rpc, &gluster_cbk_prog, + this); if (ret) { gf_log (this->name, GF_LOG_ERROR, "failed to register callback program"); @@ -2264,7 +2439,7 @@ client_init_grace_timer (xlator_t *this, dict_t *options, GF_VALIDATE_OR_GOTO (this->name, options, out); GF_VALIDATE_OR_GOTO (this->name, conf, out); - conf->lk_heal = _gf_true; + conf->lk_heal = _gf_false; ret = dict_get_str (options, "lk-heal", &lk_heal); if (!ret) @@ -2275,14 +2450,14 @@ client_init_grace_timer (xlator_t *this, dict_t *options, ret = dict_get_int32 (options, "grace-timeout", &grace_timeout); if (!ret) - conf->grace_tv.tv_sec = grace_timeout; + conf->grace_ts.tv_sec = grace_timeout; else - conf->grace_tv.tv_sec = 10; + conf->grace_ts.tv_sec = 10; - conf->grace_tv.tv_usec = 0; + conf->grace_ts.tv_nsec = 0; gf_log (this->name, GF_LOG_DEBUG, "Client grace timeout " - "value = %"PRIu64, conf->grace_tv.tv_sec); + "value = %"PRIu64, conf->grace_ts.tv_sec); ret = 0; out: @@ -2336,6 +2511,9 @@ reconfigure (xlator_t *this, dict_t *options) } } + GF_OPTION_RECONF ("filter-O_DIRECT", conf->filter_o_direct, + options, bool, out); + ret = client_init_grace_timer (this, options, conf); if (ret) goto out; @@ -2605,6 +2783,9 @@ struct xlator_fops fops = { .fxattrop = client_fxattrop, .setattr = client_setattr, .fsetattr = client_fsetattr, + .fallocate = client_fallocate, + .discard = client_discard, + .zerofill = client_zerofill, .getspec = client_getspec, }; @@ -2659,16 +2840,28 @@ struct volume_options options[] = { }, { .key = {"lk-heal"}, .type = GF_OPTION_TYPE_BOOL, + .default_value = "off", + .description = "Enables or disables the lock heal." }, { .key = {"grace-timeout"}, .type = GF_OPTION_TYPE_INT, .min = 10, - .max = 1800 + .max = 1800, + .description = "Sets the grace-timeout value. Valid range 10-1800." }, {.key = {"tcp-window-size"}, .type = GF_OPTION_TYPE_SIZET, .min = GF_MIN_SOCKET_WINDOW_SIZE, - .max = GF_MAX_SOCKET_WINDOW_SIZE + .max = GF_MAX_SOCKET_WINDOW_SIZE, + .description = "Specifies the window size for tcp socket." + }, + { .key = {"filter-O_DIRECT"}, + .type = GF_OPTION_TYPE_BOOL, + .default_value = "disable", + .description = "If enabled, in open() and creat() calls, O_DIRECT " + "flag will be filtered at the client protocol level so server will " + "still continue to cache the file. This works similar to NFS's " + "behavior of O_DIRECT", }, { .key = {NULL} }, }; diff --git a/xlators/protocol/client/src/client.h b/xlators/protocol/client/src/client.h index 91a411e8a..afab2d74f 100644 --- a/xlators/protocol/client/src/client.h +++ b/xlators/protocol/client/src/client.h @@ -1,20 +1,11 @@ /* - Copyright (c) 2010-2011 Gluster, Inc. <http://www.gluster.com> - This file is part of GlusterFS. - - GlusterFS is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - GlusterFS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see - <http://www.gnu.org/licenses/>. + Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com> + This file is part of GlusterFS. + + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. */ #ifndef _CLIENT_H @@ -43,27 +34,27 @@ typedef enum { GF_LK_HEAL_DONE, } lk_heal_state_t; -#define CLIENT_GET_REMOTE_FD(conf, fd, remote_fd, op_errno, label) \ +typedef enum { + DEFAULT_REMOTE_FD = 0, + FALLBACK_TO_ANON_FD = 1 +} clnt_remote_fd_flags_t; + +#define CLIENT_GET_REMOTE_FD(xl, fd, flags, remote_fd, op_errno, label) \ do { \ - clnt_fd_ctx_t *fdctx = NULL; \ - pthread_mutex_lock (&conf->lock); \ - { \ - fdctx = this_fd_get_ctx (fd, THIS); \ - } \ - pthread_mutex_unlock (&conf->lock); \ - if (!fdctx) { \ - remote_fd = -2; \ - } else { \ - remote_fd = fdctx->remote_fd; \ + int _ret = 0; \ + _ret = client_get_remote_fd (xl, fd, flags, &remote_fd);\ + if (_ret < 0) { \ + op_errno = errno; \ + goto label; \ } \ if (remote_fd == -1) { \ - gf_log (THIS->name, GF_LOG_WARNING, " (%s) " \ + gf_log (xl->name, GF_LOG_WARNING, " (%s) " \ "remote_fd is -1. EBADFD", \ uuid_utoa (fd->inode->gfid)); \ op_errno = EBADFD; \ goto label; \ } \ - } while (0); + } while (0) #define CLIENT_STACK_UNWIND(op, frame, params ...) do { \ clnt_local_t *__local = frame->local; \ @@ -102,6 +93,10 @@ typedef struct clnt_conf { which was sent earlier */ char portmap_err_logged; /* flag used to prevent excessive logging */ + char disconnect_err_logged; /* flag used to prevent + excessive disconnect + logging */ + char need_different_port; /* flag used to change the portmap path in case of 'tcp,rdma' on server */ @@ -109,7 +104,7 @@ typedef struct clnt_conf { uint16_t lk_version; /* this variable is used to distinguish client-server transaction while performing lock healing */ - struct timeval grace_tv; + struct timespec grace_ts; gf_timer_t *grace_timer; gf_boolean_t grace_timer_needed; /* The state of this flag will be used to decide whether @@ -118,6 +113,13 @@ typedef struct clnt_conf { means dont register, true means register */ char parent_down; + gf_boolean_t quick_reconnect; /* When reconnecting after + portmap query, do not let + the reconnection happen after + the usual 3-second wait + */ + gf_boolean_t filter_o_direct; /* if set, filter O_DIRECT from + the flags list of open() */ } clnt_conf_t; typedef struct _client_fd_ctx { @@ -125,17 +127,16 @@ typedef struct _client_fd_ctx { fd's position in the saved_fds list. */ int64_t remote_fd; - inode_t *inode; - uint64_t ino; - uint64_t gen; char is_dir; char released; int32_t flags; - int32_t wbflags; fd_lk_ctx_t *lk_ctx; pthread_mutex_t mutex; lk_heal_state_t lk_heal_state; + uuid_t gfid; + void (*reopen_done) (struct _client_fd_ctx*, xlator_t *); struct list_head lock_list; /* List of all granted locks on this fd */ + int32_t reopen_attempts; } clnt_fd_ctx_t; typedef struct _client_posix_lock { @@ -156,7 +157,6 @@ typedef struct client_local { fd_t *fd; clnt_fd_ctx_t *fdctx; uint32_t flags; - uint32_t wbflags; struct iobref *iobref; client_posix_lock_t *client_lock; @@ -164,18 +164,18 @@ typedef struct client_local { int32_t cmd; struct list_head lock_list; pthread_mutex_t mutex; + char *name; + gf_boolean_t attempt_reopen; } clnt_local_t; typedef struct client_args { loc_t *loc; fd_t *fd; - dict_t *xattr_req; const char *linkname; struct iobref *iobref; struct iovec *vector; dict_t *xattr; struct iatt *stbuf; - dict_t *dict; loc_t *oldloc; loc_t *newloc; const char *name; @@ -189,7 +189,6 @@ typedef struct client_args { mode_t mode; dev_t rdev; int32_t flags; - int32_t wbflags; int32_t count; int32_t datasync; entrylk_cmd cmd_entrylk; @@ -197,6 +196,9 @@ typedef struct client_args { gf_xattrop_flags_t optype; int32_t valid; int32_t len; + + mode_t umask; + dict_t *xdata; } clnt_args_t; typedef ssize_t (*gfs_serialize_t) (struct iovec outmsg, void *args); @@ -215,9 +217,6 @@ int client_submit_request (xlator_t *this, void *req, struct iovec *rsp_payload, int rsp_count, struct iobref *rsp_iobref, xdrproc_t xdrproc); -int protocol_client_reopendir (xlator_t *this, clnt_fd_ctx_t *fdctx); -int protocol_client_reopen (xlator_t *this, clnt_fd_ctx_t *fdctx); - int unserialize_rsp_dirent (struct gfs3_readdir_rsp *rsp, gf_dirent_t *entries); int unserialize_rsp_direntp (xlator_t *this, fd_t *fd, struct gfs3_readdirp_rsp *rsp, gf_dirent_t *entries); @@ -228,7 +227,6 @@ int client_attempt_lock_recovery (xlator_t *this, clnt_fd_ctx_t *fdctx); int32_t delete_granted_locks_owner (fd_t *fd, gf_lkowner_t *owner); int client_add_lock_for_recovery (fd_t *fd, struct gf_flock *flock, gf_lkowner_t *owner, int32_t cmd); -uint64_t decrement_reopen_fd_count (xlator_t *this, clnt_conf_t *conf); int32_t delete_granted_locks_fd (clnt_fd_ctx_t *fdctx); int32_t client_cmd_to_gf_cmd (int32_t cmd, int32_t *gf_cmd); void client_save_number_fds (clnt_conf_t *conf, int count); @@ -248,4 +246,12 @@ int client_mark_fd_bad (xlator_t *this); int client_set_lk_version (xlator_t *this); int client_fd_lk_list_empty (fd_lk_ctx_t *lk_ctx, gf_boolean_t use_try_lock); +void client_default_reopen_done (clnt_fd_ctx_t *fdctx, xlator_t *this); +void client_attempt_reopen (fd_t *fd, xlator_t *this); +int client_get_remote_fd (xlator_t *this, fd_t *fd, int flags, + int64_t *remote_fd); +int client_fd_fop_prepare_local (call_frame_t *frame, fd_t *fd, + int64_t remote_fd); +gf_boolean_t +__is_fd_reopen_in_progress (clnt_fd_ctx_t *fdctx); #endif /* !_CLIENT_H */ |
