summaryrefslogtreecommitdiffstats
path: root/xlators/protocol/client
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/protocol/client')
-rw-r--r--xlators/protocol/client/src/Makefile.am13
-rw-r--r--xlators/protocol/client/src/client-callback.c25
-rw-r--r--xlators/protocol/client/src/client-handshake.c672
-rw-r--r--xlators/protocol/client/src/client-helpers.c124
-rw-r--r--xlators/protocol/client/src/client-lk.c379
-rw-r--r--xlators/protocol/client/src/client-mem-types.h21
-rw-r--r--xlators/protocol/client/src/client-rpc-fops.c (renamed from xlators/protocol/client/src/client3_1-fops.c)2999
-rw-r--r--xlators/protocol/client/src/client.c651
-rw-r--r--xlators/protocol/client/src/client.h117
9 files changed, 3021 insertions, 1980 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 e1bcd4e1c..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,
@@ -227,14 +219,14 @@ client_start_ping (void *data)
ret = client_submit_request (this, NULL, frame, conf->handshake,
GF_HNDSK_PING, client_ping_cbk, NULL,
NULL, 0, NULL, 0, NULL, (xdrproc_t)NULL);
- if (ret)
- goto fail;
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_ERROR,
+ "failed to start ping timer");
+ }
return;
-fail:
- gf_log (THIS->name, GF_LOG_ERROR,
- "failed to start ping timer");
+fail:
if (frame) {
STACK_DESTROY (frame->root);
}
@@ -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)
@@ -346,11 +344,11 @@ client3_getspec_cbk (struct rpc_req *req, struct iovec *iov, int count,
}
out:
- STACK_UNWIND_STRICT (getspec, frame, rsp.op_ret, rsp.op_errno, rsp.spec);
+ CLIENT_STACK_UNWIND (getspec, frame, rsp.op_ret, rsp.op_errno,
+ rsp.spec);
/* Don't use 'GF_FREE', this is allocated by libc */
- if (rsp.spec)
- free (rsp.spec);
+ free (rsp.spec);
return 0;
}
@@ -376,13 +374,14 @@ int32_t client3_getspec (call_frame_t *frame, xlator_t *this, void *data)
NULL, NULL, 0, NULL, 0, NULL,
(xdrproc_t)xdr_gf_getspec_req);
- if (ret)
- goto unwind;
+ if (ret) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "failed to send the request");
+ }
return 0;
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the request");
- STACK_UNWIND_STRICT (getspec, frame, -1, op_errno, NULL);
+ CLIENT_STACK_UNWIND (getspec, frame, -1, op_errno, NULL);
return 0;
}
@@ -404,6 +403,28 @@ client_notify_parents_child_up (xlator_t *this)
}
int
+clnt_fd_lk_reacquire_failed (xlator_t *this, clnt_fd_ctx_t *fdctx,
+ clnt_conf_t *conf)
+{
+ int ret = -1;
+
+ GF_VALIDATE_OR_GOTO ("client", this, out);
+ GF_VALIDATE_OR_GOTO (this->name, conf, out);
+ GF_VALIDATE_OR_GOTO (this->name, fdctx, out);
+
+ pthread_mutex_lock (&conf->lock);
+ {
+ fdctx->remote_fd = -1;
+ fdctx->lk_heal_state = GF_LK_HEAL_DONE;
+ }
+ pthread_mutex_unlock (&conf->lock);
+
+ ret = 0;
+out:
+ return ret;
+}
+
+int
client_set_lk_version_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
@@ -425,7 +446,7 @@ client_set_lk_version_cbk (struct rpc_req *req, struct iovec *iov,
gf_log (fr->this->name, GF_LOG_WARNING,
"xdr decoding failed");
else
- gf_log (fr->this->name, GF_LOG_DEBUG,
+ gf_log (fr->this->name, GF_LOG_INFO,
"Server lk version = %d", rsp.lk_ver);
ret = 0;
@@ -436,6 +457,7 @@ out:
return ret;
}
+//TODO: Check for all released fdctx and destroy them
int
client_set_lk_version (xlator_t *this)
{
@@ -444,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,
@@ -462,26 +492,12 @@ 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)
- gf_log (this->name, GF_LOG_WARNING,
- "Failed to send SET_LK_VERSION to server");
-
+ GF_FREE (req.uid);
return ret;
-}
-
-int
-client_fd_lk_list_empty (fd_lk_ctx_t *lk_ctx)
-{
- int ret = 1;
-
- GF_VALIDATE_OR_GOTO ("client", lk_ctx, out);
+err:
+ gf_log (this->name, GF_LOG_WARNING,
+ "Failed to send SET_LK_VERSION to server");
- LOCK (&lk_ctx->lock);
- {
- ret = list_empty (&lk_ctx->lk_list);
- }
- UNLOCK (&lk_ctx->lock);
-out:
return ret;
}
@@ -534,9 +550,8 @@ clnt_fd_lk_local_unref (xlator_t *this, clnt_fd_lk_local_t *local)
if (ref == 0) {
LOCK_DESTROY (&local->lock);
- mem_put (local);
+ GF_FREE (local);
}
- ref = 0;
out:
return ref;
}
@@ -570,7 +585,6 @@ clnt_mark_fd_bad (clnt_conf_t *conf, clnt_fd_ctx_t *fdctx)
pthread_mutex_unlock (&conf->lock);
}
-// call decrement_reopen_fd_count
int
clnt_release_reopen_fd_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
@@ -585,9 +599,9 @@ clnt_release_reopen_fd_cbk (struct rpc_req *req, struct iovec *iov,
fdctx = (clnt_fd_ctx_t *) frame->local;
conf = (clnt_conf_t *) this->private;
- clnt_mark_fd_bad (conf, fdctx);
+ 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);
@@ -605,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;
@@ -617,25 +631,64 @@ 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);
-out:
+ return 0;
+ out:
if (ret) {
- decrement_reopen_fd_count (this, conf);
- clnt_mark_fd_bad (conf, fdctx);
+ clnt_fd_lk_reacquire_failed (this, fdctx, conf);
+ fdctx->reopen_done (fdctx, this);
if (frame) {
frame->local = NULL;
STACK_DESTROY (frame->root);
}
}
-
return 0;
}
int
+clnt_reacquire_lock_error (xlator_t *this, clnt_fd_ctx_t *fdctx,
+ clnt_conf_t *conf)
+{
+ int32_t ret = -1;
+
+ GF_VALIDATE_OR_GOTO ("client", this, out);
+ GF_VALIDATE_OR_GOTO (this->name, fdctx, out);
+ GF_VALIDATE_OR_GOTO (this->name, conf, out);
+
+ clnt_release_reopen_fd (this, fdctx);
+
+ ret = 0;
+out:
+ return ret;
+}
+
+gf_boolean_t
+clnt_fd_lk_local_error_status (xlator_t *this,
+ clnt_fd_lk_local_t *local)
+{
+ gf_boolean_t error = _gf_false;
+
+ LOCK (&local->lock);
+ {
+ error = local->error;
+ }
+ UNLOCK (&local->lock);
+
+ return error;
+}
+
+int
clnt_fd_lk_local_mark_error (xlator_t *this,
clnt_fd_lk_local_t *local)
{
+ int32_t ret = -1;
+ clnt_conf_t *conf = NULL;
gf_boolean_t error = _gf_false;
+ GF_VALIDATE_OR_GOTO ("client", this, out);
+ GF_VALIDATE_OR_GOTO (this->name, local, out);
+
+ conf = (clnt_conf_t *) this->private;
+
LOCK (&local->lock);
{
error = local->error;
@@ -643,30 +696,30 @@ clnt_fd_lk_local_mark_error (xlator_t *this,
}
UNLOCK (&local->lock);
- if (error)
- clnt_release_reopen_fd (this, local->fdctx);
-
- return 0;
+ if (!error)
+ clnt_reacquire_lock_error (this, local->fdctx, conf);
+ ret = 0;
+out:
+ return ret;
}
-// Also, I think in reopen_cbk, the fdctx is added to
-// saved_fd list.. avoid that, may cause a problem
-// Reason: While the locks on the fd are reacquired, a release
-// fop may be received by the client-protocol translator
-// which will free the fdctx datastructure.
int
client_reacquire_lock_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
{
int32_t ret = -1;
xlator_t *this = NULL;
- gf_common_rsp rsp = {0,};
+ gfs3_lk_rsp rsp = {0,};
call_frame_t *frame = NULL;
+ clnt_conf_t *conf = NULL;
+ clnt_fd_ctx_t *fdctx = NULL;
clnt_fd_lk_local_t *local = NULL;
+ struct gf_flock lock = {0,};
frame = (call_frame_t *) myframe;
this = frame->this;
local = (clnt_fd_lk_local_t *) frame->local;
+ conf = (clnt_conf_t *) this->private;
if (req->rpc_status == -1) {
gf_log ("client", GF_LOG_WARNING,
@@ -674,7 +727,7 @@ client_reacquire_lock_cbk (struct rpc_req *req, struct iovec *iov,
goto out;
}
- ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_common_rsp);
+ ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_lk_rsp);
if (ret < 0) {
gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed");
goto out;
@@ -686,15 +739,34 @@ client_reacquire_lock_cbk (struct rpc_req *req, struct iovec *iov,
goto out;
}
- // TODO: Add more info to log.
- gf_log (this->name, GF_LOG_DEBUG, "Reacquired lock");
+ fdctx = local->fdctx;
+
+ gf_proto_flock_to_flock (&rsp.flock, &lock);
+
+ 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->gfid),
+ lock.l_start, lock.l_start + lock.l_len);
+
+ 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;
+ }
+ pthread_mutex_unlock (&conf->lock);
+
+ fdctx->reopen_done (fdctx, this);
+ }
ret = 0;
out:
- if (ret < 0)
+ if (ret < 0) {
clnt_fd_lk_local_mark_error (this, local);
- (void) clnt_fd_lk_local_unref (this, local);
+ clnt_fd_lk_local_unref (this, local);
+ }
+
frame->local = NULL;
STACK_DESTROY (frame->root);
@@ -720,7 +792,10 @@ _client_reacquire_lock (xlator_t *this, clnt_fd_ctx_t *fdctx)
local = clnt_fd_lk_local_create (fdctx);
if (!local) {
- clnt_release_reopen_fd (this, fdctx);
+ gf_log (this->name, GF_LOG_WARNING, "clnt_fd_lk_local_create "
+ "failed, aborting reacquring of locks on %s.",
+ uuid_utoa (fdctx->gfid));
+ clnt_reacquire_lock_error (this, fdctx, conf);
goto out;
}
@@ -728,7 +803,9 @@ _client_reacquire_lock (xlator_t *this, clnt_fd_ctx_t *fdctx)
memcpy (&flock, &fd_lk->user_flock,
sizeof (struct gf_flock));
- ret = client_cmd_to_gf_cmd (fd_lk->cmd, &gf_cmd);
+ /* Always send F_SETLK even if the cmd was F_SETLKW */
+ /* to avoid frame being blocked if lock cannot be granted. */
+ ret = client_cmd_to_gf_cmd (F_SETLK, &gf_cmd);
if (ret) {
gf_log (this->name, GF_LOG_WARNING,
"client_cmd_to_gf_cmd failed, "
@@ -743,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;
@@ -759,24 +836,17 @@ _client_reacquire_lock (xlator_t *this, clnt_fd_ctx_t *fdctx)
client_reacquire_lock_cbk,
NULL, NULL, 0, NULL, 0, NULL,
(xdrproc_t)xdr_gfs3_lk_req);
- if (ret)
+ if (ret) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "reacquiring locks failed on file with gfid %s",
+ uuid_utoa (fdctx->gfid));
break;
+ }
ret = 0;
frame = NULL;
}
- if (ret) {
- clnt_fd_lk_local_mark_error (this, local);
-
- if (frame) {
- if (frame->local) {
- clnt_fd_lk_local_unref (this, frame->local);
- frame->local = NULL;
- }
- STACK_DESTROY (frame->root);
- }
- }
if (local)
(void) clnt_fd_lk_local_unref (this, local);
out:
@@ -789,33 +859,87 @@ client_reacquire_lock (xlator_t *this, clnt_fd_ctx_t *fdctx)
int32_t ret = -1;
fd_lk_ctx_t *lk_ctx = NULL;
- if (client_fd_lk_list_empty (fdctx->lk_ctx)) {
- gf_log (this->name, GF_LOG_WARNING,
+ GF_VALIDATE_OR_GOTO ("client", this, out);
+ GF_VALIDATE_OR_GOTO (this->name, fdctx, out);
+
+ 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);
- ret = 0;
- goto out;
+ fdctx->reopen_done (fdctx, this);
+ } else {
+ lk_ctx = fdctx->lk_ctx;
+
+ LOCK (&lk_ctx->lock);
+ {
+ (void) _client_reacquire_lock (this, fdctx);
+ }
+ UNLOCK (&lk_ctx->lock);
}
+ ret = 0;
+out:
+ return ret;
+}
- lk_ctx = fdctx->lk_ctx;
+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");
+}
- LOCK (&lk_ctx->lock);
+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);
{
- ret = _client_reacquire_lock (this, fdctx);
+ 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);
}
- UNLOCK (&lk_ctx->lock);
-out:
- return ret;
}
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;
@@ -823,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,
@@ -861,49 +983,41 @@ 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) {
- list_add_tail (&fdctx->sfd_pos, &conf->saved_fds);
- if (!client_fd_lk_list_empty (fdctx->lk_ctx))
+ if (conf->lk_heal &&
+ !client_fd_lk_list_empty (fdctx->lk_ctx,
+ _gf_false)) {
attempt_lock_recovery = _gf_true;
- fdctx = NULL;
+ fdctx->lk_heal_state = GF_LK_HEAL_IN_PROGRESS;
+ }
}
}
pthread_mutex_unlock (&conf->lock);
ret = 0;
- if (conf->lk_heal && attempt_lock_recovery) {
- /* Delay decrement the reopen fd count untill all the
+ if (attempt_lock_recovery) {
+ /* Delay decrementing the reopen fd count untill all the
locks corresponding to this fd are acquired.*/
- gf_log (frame->this->name, GF_LOG_WARNING, "acquiring locks on "
- "%s", local->loc.path);
+ gf_log (this->name, GF_LOG_DEBUG, "acquiring locks "
+ "on %s", local->loc.path);
ret = client_reacquire_lock (frame->this, local->fdctx);
- } else {
- fd_count = decrement_reopen_fd_count (frame->this, conf);
+ if (ret) {
+ clnt_reacquire_lock_error (this, local->fdctx, conf);
+ gf_log (this->name, GF_LOG_WARNING, "acquiring locks "
+ "failed on %s", local->loc.path);
+ }
}
-out:
- if (fdctx)
- client_fdctx_destroy (this, fdctx);
-
- if ((ret < 0) && frame && frame->this && conf)
- decrement_reopen_fd_count (frame->this, conf);
+out:
+ 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);
@@ -911,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;
@@ -922,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,
@@ -959,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) {
@@ -1038,27 +1117,26 @@ 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)
- goto out;
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "failed to send the re-opendir request");
+ }
- return ret;
+ return 0;
out:
- gf_log (THIS->name, GF_LOG_ERROR,
- "failed to send the re-opendir request");
-
if (frame) {
frame->local = NULL;
STACK_DESTROY (frame->root);
@@ -1067,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;
@@ -1115,31 +1175,32 @@ 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)
- goto out;
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "failed to send the re-open request");
+ }
- return ret;
+ return 0;
out:
- gf_log (THIS->name, GF_LOG_ERROR,
- "failed to send the re-open request");
-
if (frame) {
frame->local = NULL;
STACK_DESTROY (frame->root);
@@ -1148,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)
@@ -1183,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++;
@@ -1201,14 +1311,11 @@ 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,
- "no fds to open - notifying all parents child up");
+ "No fds to open - notifying all parents child up");
client_set_lk_version (this);
client_notify_parents_child_up (this);
}
@@ -1290,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;
}
@@ -1320,7 +1426,7 @@ client_setvolume_cbk (struct rpc_req *req, struct iovec *iov, int count, void *m
goto out;
}
- gf_log (this->name, GF_LOG_INFO, "clnt-lk-version = %d, "
+ gf_log (this->name, GF_LOG_DEBUG, "clnt-lk-version = %d, "
"server-lk-version = %d", client_get_lk_ver (conf), lk_ver);
/* TODO: currently setpeer path is broken */
/*
@@ -1358,13 +1464,17 @@ client_setvolume_cbk (struct rpc_req *req, struct iovec *iov, int count, void *m
conf->need_different_port = 0;
if (lk_ver != client_get_lk_ver (conf)) {
+ gf_log (this->name, GF_LOG_INFO, "Server and Client "
+ "lk-version numbers are not same, reopening the fds");
client_mark_fd_bad (this);
client_post_handshake (frame, frame->this);
} else {
/*TODO: Traverse the saved fd list, and send
release to the server on fd's that were closed
during grace period */
- ;
+ gf_log (this->name, GF_LOG_INFO, "Server and Client "
+ "lk-version numbers are same, no need to "
+ "reopen the fds");
}
out:
@@ -1394,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);
@@ -1439,8 +1548,13 @@ client_setvolume (xlator_t *this, struct rpc_clnt *rpc)
}
}
- ret = gf_asprintf (&process_uuid_xl, "%s-%s", this->ctx->process_uuid,
- this->name);
+ /* With multiple graphs possible in the same process, we need a
+ field to bring the uniqueness. Graph-ID should be enough to get the
+ job done
+ */
+ ret = gf_asprintf (&process_uuid_xl, "%s-%s-%d",
+ this->ctx->process_uuid, this->name,
+ this->graph->id);
if (-1 == ret) {
gf_log (this->name, GF_LOG_ERROR,
"asprintf failed while setting process_uuid");
@@ -1485,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);
@@ -1511,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;
}
@@ -1535,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")",
@@ -1622,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)
@@ -1641,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 4c1ac1baa..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,6 +16,31 @@
#include "client.h"
#include "fd.h"
+int
+client_fd_lk_list_empty (fd_lk_ctx_t *lk_ctx, gf_boolean_t try_lock)
+{
+ int ret = 1;
+
+ if (!lk_ctx) {
+ ret = -1;
+ goto out;
+ }
+
+ if (try_lock) {
+ ret = TRY_LOCK (&lk_ctx->lock);
+ if (ret != 0) {
+ ret = -1;
+ goto out;
+ }
+ } else {
+ LOCK (&lk_ctx->lock);
+ }
+
+ ret = list_empty (&lk_ctx->lk_list);
+ UNLOCK (&lk_ctx->lock);
+out:
+ return ret;
+}
clnt_fd_ctx_t *
this_fd_del_ctx (fd_t *file, xlator_t *this)
@@ -106,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);
@@ -115,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;
@@ -190,6 +209,8 @@ unserialize_rsp_direntp (xlator_t *this, fd_t *fd,
if (!buf)
goto out;
+ entry->dict = dict_new ();
+
ret = dict_unserialize (buf, trav->dict.dict_len,
&entry->dict);
if (ret < 0) {
@@ -227,6 +248,7 @@ clnt_readdirp_rsp_cleanup (gfs3_readdirp_rsp *rsp)
while (trav) {
trav = trav->nextentry;
/* on client, the rpc lib allocates this */
+ free (prev->dict.dict_val);
free (prev->name);
free (prev);
prev = trav;
@@ -253,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 800761662..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,23 +20,25 @@
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
client_submit_vec_request (xlator_t *this, void *req, call_frame_t *frame,
- rpc_clnt_prog_t *prog, int procnum, fop_cbk_fn_t cbk,
+ rpc_clnt_prog_t *prog, int procnum,
+ fop_cbk_fn_t cbkfn,
struct iovec *payload, int payloadcnt,
struct iobref *iobref, xdrproc_t xdrproc)
{
- int ret = 0;
- clnt_conf_t *conf = NULL;
- struct iovec iov = {0, };
- struct iobuf *iobuf = NULL;
- int count = 0;
- int start_ping = 0;
- struct iobref *new_iobref = NULL;
- ssize_t xdr_size = 0;
+ int ret = 0;
+ clnt_conf_t *conf = NULL;
+ struct iovec iov = {0, };
+ struct iobuf *iobuf = NULL;
+ int count = 0;
+ int start_ping = 0;
+ struct iobref *new_iobref = NULL;
+ ssize_t xdr_size = 0;
+ struct rpc_req rpcreq = {0, };
start_ping = 0;
@@ -55,12 +48,12 @@ client_submit_vec_request (xlator_t *this, void *req, call_frame_t *frame,
xdr_size = xdr_sizeof (xdrproc, req);
iobuf = iobuf_get2 (this->ctx->iobuf_pool, xdr_size);
if (!iobuf) {
- goto out;
+ goto unwind;
};
new_iobref = iobref_new ();
if (!new_iobref) {
- goto out;
+ goto unwind;
}
if (iobref != NULL) {
@@ -76,7 +69,7 @@ client_submit_vec_request (xlator_t *this, void *req, call_frame_t *frame,
if (ret != 0) {
gf_log (this->name, GF_LOG_WARNING,
"cannot add iobuf into iobref");
- goto out;
+ goto unwind;
}
iov.iov_base = iobuf->ptr;
@@ -87,7 +80,7 @@ client_submit_vec_request (xlator_t *this, void *req, call_frame_t *frame,
if (ret == -1) {
gf_log_callingfn ("", GF_LOG_WARNING,
"XDR function failed");
- goto out;
+ goto unwind;
}
iov.iov_len = ret;
@@ -95,7 +88,7 @@ client_submit_vec_request (xlator_t *this, void *req, call_frame_t *frame,
}
/* Send the msg */
- ret = rpc_clnt_submit (conf->rpc, prog, procnum, cbk, &iov, count,
+ ret = rpc_clnt_submit (conf->rpc, prog, procnum, cbkfn, &iov, count,
payload, payloadcnt, new_iobref, frame, NULL, 0,
NULL, 0, NULL);
if (ret < 0) {
@@ -115,12 +108,23 @@ client_submit_vec_request (xlator_t *this, void *req, call_frame_t *frame,
if (start_ping)
client_start_ping ((void *) this);
-out:
- if (new_iobref != NULL) {
+ if (new_iobref)
iobref_unref (new_iobref);
- }
- iobuf_unref (iobuf);
+ if (iobuf)
+ iobuf_unref (iobuf);
+
+ return ret;
+
+unwind:
+ rpcreq.rpc_status = -1;
+ cbkfn (&rpcreq, NULL, 0, frame);
+
+ if (new_iobref)
+ iobref_unref (new_iobref);
+
+ if (iobuf)
+ iobuf_unref (iobuf);
return ret;
}
@@ -128,7 +132,7 @@ out:
/* 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;
@@ -140,13 +144,13 @@ 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;
frame = myframe;
local = frame->local;
- frame->local = NULL;
inode = local->loc.inode;
if (-1 == req->rpc_status) {
@@ -169,26 +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:
- frame->local = NULL;
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);
}
- STACK_UNWIND_STRICT (symlink, frame, rsp.op_ret,
+
+ CLIENT_STACK_UNWIND (symlink, frame, rsp.op_ret,
gf_error_to_errno (rsp.op_errno), inode, &stbuf,
- &preparent, &postparent);
+ &preparent, &postparent, xdata);
- client_local_wipe (local);
+ 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;
@@ -200,13 +214,14 @@ 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;
frame = myframe;
local = frame->local;
- frame->local = NULL;
+
inode = local->loc.inode;
if (-1 == req->rpc_status) {
@@ -229,25 +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:
- frame->local = NULL;
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);
}
- STACK_UNWIND_STRICT (mknod, frame, rsp.op_ret,
+
+ CLIENT_STACK_UNWIND (mknod, frame, rsp.op_ret,
gf_error_to_errno (rsp.op_errno), inode,
- &stbuf, &preparent, &postparent);
+ &stbuf, &preparent, &postparent, xdata);
- client_local_wipe (local);
+ 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;
@@ -259,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;
@@ -287,42 +310,122 @@ 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:
- frame->local = NULL;
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);
}
- STACK_UNWIND_STRICT (mkdir, frame, rsp.op_ret,
+
+ 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);
- client_local_wipe (local);
+ 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;
frame = myframe;
local = frame->local;
- frame->local = NULL;
conf = frame->this->private;
fd = local->fd;
@@ -340,58 +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);
-
- 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:
- frame->local = NULL;
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));
}
- STACK_UNWIND_STRICT (open, frame, rsp.op_ret,
- gf_error_to_errno (rsp.op_errno), fd);
- client_local_wipe (local);
+ CLIENT_STACK_UNWIND (open, frame, rsp.op_ret,
+ 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;
@@ -414,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)));
}
- STACK_UNWIND_STRICT (stat, frame, rsp.op_ret,
- gf_error_to_errno (rsp.op_errno), &iatt);
+
+ CLIENT_STACK_UNWIND (stat, frame, rsp.op_ret,
+ 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;
@@ -456,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)));
}
- STACK_UNWIND_STRICT (readlink, frame, rsp.op_ret,
- gf_error_to_errno (rsp.op_errno), rsp.path, &iatt);
+
+ CLIENT_STACK_UNWIND (readlink, frame, rsp.op_ret,
+ 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;
@@ -481,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;
@@ -505,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)));
}
- STACK_UNWIND_STRICT (unlink, frame, rsp.op_ret,
+
+ 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,};
@@ -526,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;
@@ -550,21 +685,30 @@ 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",
strerror (gf_error_to_errno (rsp.op_errno)));
}
- STACK_UNWIND_STRICT (rmdir, frame, rsp.op_ret,
+ 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,};
@@ -572,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;
@@ -596,28 +742,39 @@ 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",
strerror (gf_error_to_errno (rsp.op_errno)));
}
- STACK_UNWIND_STRICT (truncate, frame, rsp.op_ret,
+ 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;
@@ -640,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)));
}
- STACK_UNWIND_STRICT (statfs, frame, rsp.op_ret,
- gf_error_to_errno (rsp.op_errno), &statfs);
+ CLIENT_STACK_UNWIND (statfs, frame, rsp.op_ret,
+ 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,};
@@ -661,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;
@@ -686,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);
}
- STACK_UNWIND_STRICT (writev, frame, rsp.op_ret,
+ 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;
@@ -733,23 +917,29 @@ 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:
- frame->local = NULL;
if (rsp.op_ret == -1) {
gf_log (this->name, GF_LOG_WARNING,
"remote operation failed: %s",
strerror (gf_error_to_errno (rsp.op_errno)));
}
- STACK_UNWIND_STRICT (flush, frame, rsp.op_ret,
- gf_error_to_errno (rsp.op_errno));
+ CLIENT_STACK_UNWIND (flush, frame, rsp.op_ret,
+ gf_error_to_errno (rsp.op_errno), xdata);
+
+ free (rsp.xdata.xdata_val);
- client_local_wipe (local);
+ 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,26 +974,37 @@ 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",
strerror (gf_error_to_errno (rsp.op_errno)));
}
- STACK_UNWIND_STRICT (fsync, frame, rsp.op_ret,
+ 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));
}
- STACK_UNWIND_STRICT (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,13 +1056,14 @@ 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;
frame = myframe;
local = frame->local;
- frame->local = NULL;
if (-1 == req->rpc_status) {
rsp.op_ret = -1;
@@ -872,32 +1087,40 @@ 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)");
}
- STACK_UNWIND_STRICT (getxattr, 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 (getxattr, frame, rsp.op_ret, op_errno, dict, xdata);
+
+ /* 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);
- client_local_wipe (local);
-
return 0;
}
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;
@@ -906,13 +1129,14 @@ 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;
frame = myframe;
local = frame->local;
- frame->local = NULL;
if (-1 == req->rpc_status) {
rsp.op_ret = -1;
@@ -934,36 +1158,42 @@ 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));
}
- STACK_UNWIND_STRICT (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);
- client_local_wipe (local);
-
return 0;
}
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;
@@ -983,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)));
}
- STACK_UNWIND_STRICT (removexattr, frame, rsp.op_ret,
- gf_error_to_errno (rsp.op_errno));
+
+ CLIENT_STACK_UNWIND (removexattr, frame, rsp.op_ret,
+ 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;
@@ -1021,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)));
}
- STACK_UNWIND_STRICT (fremovexattr, frame, rsp.op_ret,
- gf_error_to_errno (rsp.op_errno));
+ CLIENT_STACK_UNWIND (fremovexattr, frame, rsp.op_ret,
+ 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;
@@ -1058,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)));
}
- STACK_UNWIND_STRICT (fsyncdir, frame, rsp.op_ret,
- gf_error_to_errno (rsp.op_errno));
+ CLIENT_STACK_UNWIND (fsyncdir, frame, rsp.op_ret,
+ 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;
@@ -1095,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)));
}
- STACK_UNWIND_STRICT (access, frame, rsp.op_ret,
- gf_error_to_errno (rsp.op_errno));
+ CLIENT_STACK_UNWIND (access, frame, rsp.op_ret,
+ 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,};
@@ -1116,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;
@@ -1140,27 +1415,38 @@ 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",
strerror (gf_error_to_errno (rsp.op_errno)));
}
- STACK_UNWIND_STRICT (ftruncate, frame, rsp.op_ret,
+ 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;
@@ -1183,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)));
}
- STACK_UNWIND_STRICT (fstat, frame, rsp.op_ret,
- gf_error_to_errno (rsp.op_errno), &stat);
+ CLIENT_STACK_UNWIND (fstat, frame, rsp.op_ret,
+ 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;
@@ -1221,30 +1518,42 @@ 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))) {
gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s",
strerror (gf_error_to_errno (rsp.op_errno)));
}
- STACK_UNWIND_STRICT (inodelk, frame, rsp.op_ret,
- gf_error_to_errno (rsp.op_errno));
+ CLIENT_STACK_UNWIND (inodelk, frame, rsp.op_ret,
+ 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;
@@ -1259,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);
}
- STACK_UNWIND_STRICT (finodelk, frame, rsp.op_ret,
- gf_error_to_errno (rsp.op_errno));
+ CLIENT_STACK_UNWIND (finodelk, frame, rsp.op_ret,
+ 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;
@@ -1297,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)));
}
- STACK_UNWIND_STRICT (entrylk, frame, rsp.op_ret,
- gf_error_to_errno (rsp.op_errno));
+
+ CLIENT_STACK_UNWIND (entrylk, frame, rsp.op_ret,
+ 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;
@@ -1336,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)));
}
- STACK_UNWIND_STRICT (fentrylk, frame, rsp.op_ret,
- gf_error_to_errno (rsp.op_errno));
+
+ CLIENT_STACK_UNWIND (fentrylk, frame, rsp.op_ret,
+ 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;
@@ -1358,13 +1702,14 @@ 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;
frame = myframe;
local = frame->local;
- frame->local = NULL;
if (-1 == req->rpc_status) {
rsp.op_ret = -1;
@@ -1387,49 +1732,51 @@ client3_1_xattrop_cbk (struct rpc_req *req, struct iovec *iov, int count,
op_errno, out);
}
-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));
}
- STACK_UNWIND_STRICT (xattrop, frame, rsp.op_ret,
- gf_error_to_errno (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 (xattrop, frame, rsp.op_ret,
+ gf_error_to_errno (op_errno), dict, xdata);
+
+ free (rsp.dict.dict_val);
+
+ free (rsp.xdata.xdata_val);
+
+ if (xdata)
+ dict_unref (xdata);
if (dict)
dict_unref (dict);
- client_local_wipe (local);
-
return 0;
}
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;
frame = myframe;
local = frame->local;
- frame->local = NULL;
if (-1 == req->rpc_status) {
rsp.op_ret = -1;
@@ -1452,38 +1799,99 @@ 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 (rsp.op_errno)));
+ strerror (gf_error_to_errno (op_errno)));
+ } else if (rsp.op_ret == 0) {
+ if (local->attempt_reopen)
+ client_attempt_reopen (local->fd, this);
}
- STACK_UNWIND_STRICT (fxattrop, frame, rsp.op_ret,
- gf_error_to_errno (op_errno), dict);
+ CLIENT_STACK_UNWIND (fxattrop, frame, rsp.op_ret,
+ 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);
- client_local_wipe (local);
return 0;
}
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;
+ dict_t *xdata = NULL;
+ int op_errno = EINVAL;
+
+ 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_gf_common_rsp);
+ if (ret < 0) {
+ gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed");
+ rsp.op_ret = -1;
+ rsp.op_errno = EINVAL;
+ 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, ((op_errno == ENOTSUP) ?
+ GF_LOG_DEBUG : GF_LOG_WARNING),
+ "remote operation failed: %s",
+ strerror (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_3_fsetattr_cbk (struct rpc_req *req, struct iovec *iov, int count,
+ void *myframe)
+{
call_frame_t *frame = NULL;
- gf_common_rsp rsp = {0,};
+ gfs3_fsetattr_rsp rsp = {0,};
+ 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;
@@ -1494,7 +1902,7 @@ client3_1_fsetxattr_cbk (struct rpc_req *req, struct iovec *iov, int count,
rsp.op_errno = ENOTCONN;
goto out;
}
- ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_common_rsp);
+ ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_fsetattr_rsp);
if (ret < 0) {
gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed");
rsp.op_ret = -1;
@@ -1502,27 +1910,44 @@ client3_1_fsetxattr_cbk (struct rpc_req *req, struct iovec *iov, int count,
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)));
}
- STACK_UNWIND_STRICT (fsetxattr, frame, rsp.op_ret,
- gf_error_to_errno (rsp.op_errno));
+ CLIENT_STACK_UNWIND (fsetattr, 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_fsetattr_cbk (struct rpc_req *req, struct iovec *iov, int count,
+client3_3_fallocate_cbk (struct rpc_req *req, struct iovec *iov, int count,
void *myframe)
{
call_frame_t *frame = NULL;
- gfs3_fsetattr_rsp rsp = {0,};
+ gfs3_fallocate_rsp rsp = {0,};
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;
@@ -1533,7 +1958,7 @@ client3_1_fsetattr_cbk (struct rpc_req *req, struct iovec *iov, int count,
rsp.op_errno = ENOTCONN;
goto out;
}
- ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_fsetattr_rsp);
+ 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;
@@ -1546,21 +1971,140 @@ 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",
strerror (gf_error_to_errno (rsp.op_errno)));
}
- STACK_UNWIND_STRICT (fsetattr, frame, rsp.op_ret,
+ CLIENT_STACK_UNWIND (fallocate, 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_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_1_setattr_cbk (struct rpc_req *req, struct iovec *iov, int count,
+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;
@@ -1568,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;
@@ -1593,20 +2139,29 @@ 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",
strerror (gf_error_to_errno (rsp.op_errno)));
}
- STACK_UNWIND_STRICT (setattr, frame, rsp.op_ret,
+ 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;
@@ -1617,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; frame->local = NULL;
- conf = frame->this->private;
+ local = frame->local;
fd = local->fd;
inode = local->loc.inode;
@@ -1649,56 +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;
-
- 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:
- frame->local = NULL;
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);
}
- STACK_UNWIND_STRICT (create, frame, rsp.op_ret,
+
+ 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);
- client_local_wipe (local);
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;
@@ -1718,15 +2266,20 @@ 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",
strerror (gf_error_to_errno (rsp.op_errno)));
}
- STACK_UNWIND_STRICT (rchecksum, frame, rsp.op_ret,
+ 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 */
@@ -1734,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;
@@ -1746,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;
@@ -1785,37 +2344,47 @@ 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:
- frame->local = NULL;
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)));
}
- STACK_UNWIND_STRICT (lk, frame, rsp.op_ret,
- gf_error_to_errno (rsp.op_errno), &lock);
- client_local_wipe (local);
+ CLIENT_STACK_UNWIND (lk, frame, rsp.op_ret,
+ 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;
frame = myframe;
local = frame->local;
- frame->local = NULL;
if (-1 == req->rpc_status) {
rsp.op_ret = -1;
@@ -1836,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,
@@ -1843,15 +2417,18 @@ out:
strerror (gf_error_to_errno (rsp.op_errno)),
local->cmd);
}
- STACK_UNWIND_STRICT (readdir, frame, rsp.op_ret,
- gf_error_to_errno (rsp.op_errno), &entries);
-
- client_local_wipe (local);
+ CLIENT_STACK_UNWIND (readdir, frame, rsp.op_ret,
+ 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;
@@ -1859,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;
@@ -1868,12 +2445,12 @@ 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;
frame = myframe;
local = frame->local;
- frame->local = NULL;
if (-1 == req->rpc_status) {
rsp.op_ret = -1;
@@ -1894,20 +2471,26 @@ 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,
"remote operation failed: %s",
strerror (gf_error_to_errno (rsp.op_errno)));
}
- STACK_UNWIND_STRICT (readdirp, frame, rsp.op_ret,
- gf_error_to_errno (rsp.op_errno), &entries);
-
- client_local_wipe (local);
+ CLIENT_STACK_UNWIND (readdirp, frame, rsp.op_ret,
+ 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);
@@ -1916,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;
@@ -1927,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;
@@ -1957,21 +2541,30 @@ 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",
strerror (gf_error_to_errno (rsp.op_errno)));
}
- STACK_UNWIND_STRICT (rename, frame, rsp.op_ret,
+ 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;
@@ -1982,14 +2575,15 @@ 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;
frame = myframe;
local = frame->local;
- frame->local = NULL;
inode = local->loc.inode;
if (-1 == req->rpc_status) {
@@ -2013,42 +2607,49 @@ 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:
- frame->local = NULL;
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);
}
- STACK_UNWIND_STRICT (link, frame, rsp.op_ret,
+
+ 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);
- client_local_wipe (local);
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;
frame = myframe;
local = frame->local;
- frame->local = NULL;
conf = frame->this->private;
fd = local->fd;
@@ -2067,49 +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:
- frame->local = NULL;
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));
}
- STACK_UNWIND_STRICT (opendir, frame, rsp.op_ret,
- gf_error_to_errno (rsp.op_errno), fd);
+ CLIENT_STACK_UNWIND (opendir, frame, rsp.op_ret,
+ gf_error_to_errno (rsp.op_errno), fd, xdata);
+
+ free (rsp.xdata.xdata_val);
- client_local_wipe (local);
+ 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;
@@ -2119,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;
@@ -2128,7 +2720,6 @@ client3_1_lookup_cbk (struct rpc_req *req, struct iovec *iov, int count,
frame = myframe;
local = frame->local;
inode = local->loc.inode;
- frame->local = NULL;
if (-1 == req->rpc_status) {
rsp.op_ret = -1;
@@ -2153,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))
@@ -2170,37 +2761,31 @@ client3_1_lookup_cbk (struct rpc_req *req, struct iovec *iov, int count,
out:
rsp.op_errno = op_errno;
- frame->local = NULL;
if (rsp.op_ret == -1) {
/* 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");
}
- STACK_UNWIND_STRICT (lookup, frame, rsp.op_ret, rsp.op_errno, inode,
- &stbuf, xattr, &postparent);
- client_local_wipe (local);
+ CLIENT_STACK_UNWIND (lookup, frame, rsp.op_ret, rsp.op_errno, inode,
+ &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;
@@ -2210,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,7 +2804,6 @@ client3_1_readv_cbk (struct rpc_req *req, struct iovec *iov, int count,
frame = myframe;
local = frame->local;
- frame->local = NULL;
if (-1 == req->rpc_status) {
rsp.op_ret = -1;
@@ -2243,23 +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);
}
- STACK_UNWIND_STRICT (readv, frame, rsp.op_ret,
+ CLIENT_STACK_UNWIND (readv, frame, rsp.op_ret,
gf_error_to_errno (rsp.op_errno), vector, rspcount,
- &stat, iobref);
+ &stat, iobref, xdata);
- client_local_wipe (local);
+ 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;
@@ -2269,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;
@@ -2282,13 +2881,14 @@ client3_1_releasedir_cbk (struct rpc_req *req, struct iovec *iov, int count,
int
client_fdctx_destroy (xlator_t *this, clnt_fd_ctx_t *fdctx)
{
- clnt_conf_t *conf = NULL;
- call_frame_t *fr = NULL;
- int32_t ret = -1;
- fd_lk_ctx_t *lk_ctx = NULL;
+ clnt_conf_t *conf = NULL;
+ call_frame_t *fr = NULL;
+ int32_t ret = -1;
+ char parent_down = 0;
+ fd_lk_ctx_t *lk_ctx = NULL;
- if (!fdctx)
- goto out;
+ GF_VALIDATE_OR_GOTO ("client", this, out);
+ GF_VALIDATE_OR_GOTO (this->name, fdctx, out);
conf = (clnt_conf_t *) this->private;
@@ -2299,39 +2899,51 @@ client_fdctx_destroy (xlator_t *this, clnt_fd_ctx_t *fdctx)
pthread_mutex_lock (&conf->lock);
{
- lk_ctx = fdctx->lk_ctx;
+ parent_down = conf->parent_down;
+ lk_ctx = fdctx->lk_ctx;
fdctx->lk_ctx = NULL;
}
pthread_mutex_unlock (&conf->lock);
- fd_lk_ctx_unref (lk_ctx);
+ if (lk_ctx)
+ fd_lk_ctx_unref (lk_ctx);
+
+ if (!parent_down)
+ rpc_clnt_ref (conf->rpc);
+ else
+ goto out;
fr = create_frame (this, this->ctx->pool);
+ if (fr == NULL) {
+ goto out;
+ }
+
+ ret = 0;
if (fdctx->is_dir) {
gfs3_releasedir_req req = {{0,},};
req.fd = fdctx->remote_fd;
- gf_log (this->name, GF_LOG_INFO, "sending releasedir on fd");
- ret = client_submit_request (this, &req, fr, &clnt3_1_fop_prog,
- GFS3_OP_RELEASEDIR,
- client3_1_releasedir_cbk,
- NULL, NULL, 0, NULL, 0, NULL,
- (xdrproc_t)xdr_gfs3_releasedir_req);
+ 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_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_INFO, "sending release on fd");
- ret = client_submit_request (this, &req, fr, &clnt3_1_fop_prog,
- GFS3_OP_RELEASE,
- client3_1_release_cbk, NULL,
- NULL, 0, NULL, 0, NULL,
- (xdrproc_t)xdr_gfs3_release_req);
+ 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_3_release_cbk, NULL,
+ NULL, 0, NULL, 0, NULL,
+ (xdrproc_t)xdr_gfs3_release_req);
}
+ rpc_clnt_unref (conf->rpc);
out:
- if (!ret && fdctx) {
+ if (fdctx) {
fdctx->remote_fd = -1;
- inode_unref (fdctx->inode);
GF_FREE (fdctx);
}
@@ -2342,19 +2954,16 @@ 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;
clnt_fd_ctx_t *fdctx = NULL;
clnt_args_t *args = NULL;
- gfs3_releasedir_req req = {{0,},};
int64_t remote_fd = -1;
- int ret = 0;
- char parent_down = 0;
- if (!frame || !this || !data)
- goto unwind;
+ if (!this || !data)
+ goto out;
args = data;
conf = this->private;
@@ -2378,55 +2987,25 @@ client3_1_releasedir (call_frame_t *frame, xlator_t *this,
}
pthread_mutex_unlock (&conf->lock);
- if (remote_fd != -1) {
- pthread_mutex_lock (&conf->lock);
- {
- parent_down = conf->parent_down;
- if (!parent_down) {
- rpc_clnt_ref (conf->rpc);
- }
- }
- pthread_mutex_unlock (&conf->lock);
-
- if (!parent_down) {
- req.fd = remote_fd;
-
- ret = client_submit_request (this, &req, frame,
- conf->fops,
- GFS3_OP_RELEASEDIR,
- client3_1_releasedir_cbk,
- NULL, NULL, 0, NULL, 0,
- NULL,
- (xdrproc_t)xdr_gfs3_releasedir_req);
-
- rpc_clnt_unref (conf->rpc);
- }
-
- inode_unref (fdctx->inode);
- GF_FREE (fdctx);
- }
-
-unwind:
- if (ret)
- STACK_DESTROY (frame->root);
+ if (remote_fd != -1)
+ client_fdctx_destroy (this, fdctx);
+out:
return 0;
}
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;
- clnt_conf_t *conf = NULL;
- clnt_fd_ctx_t *fdctx = NULL;
- clnt_args_t *args = NULL;
- gfs3_release_req req = {{0,},};
- int ret = 0;
- char parent_down = 0;
+ int64_t remote_fd = -1;
+ clnt_conf_t *conf = NULL;
+ clnt_fd_ctx_t *fdctx = NULL;
+ clnt_args_t *args = NULL;
+ lk_heal_state_t lk_heal_state = GF_LK_HEAL_DONE;
- if (!frame || !this || !data)
- goto unwind;
+ if (!this || !data)
+ goto out;
args = data;
conf = this->private;
@@ -2435,14 +3014,16 @@ client3_1_release (call_frame_t *frame, xlator_t *this,
{
fdctx = this_fd_del_ctx (args->fd, this);
if (fdctx != NULL) {
- remote_fd = fdctx->remote_fd;
+ remote_fd = fdctx->remote_fd;
+ lk_heal_state = fdctx->lk_heal_state;
/* fdctx->remote_fd == -1 indicates a reopen attempt
in progress. Just mark ->released = 1 and let
reopen_cbk handle releasing
*/
- if (remote_fd != -1)
+ if (remote_fd != -1 &&
+ lk_heal_state == GF_LK_HEAL_DONE)
list_del_init (&fdctx->sfd_pos);
fdctx->released = 1;
@@ -2450,44 +3031,15 @@ client3_1_release (call_frame_t *frame, xlator_t *this,
}
pthread_mutex_unlock (&conf->lock);
- if (remote_fd != -1) {
- req.fd = remote_fd;
-
- delete_granted_locks_fd (fdctx);
-
- pthread_mutex_lock (&conf->lock);
- {
- parent_down = conf->parent_down;
- if (!parent_down) {
- rpc_clnt_ref (conf->rpc);
- }
- }
- pthread_mutex_unlock (&conf->lock);
-
- if (!parent_down) {
- ret = client_submit_request (this, &req, frame,
- conf->fops,
- GFS3_OP_RELEASE,
- client3_1_release_cbk,
- NULL, NULL,
- 0, NULL, 0, NULL,
- (xdrproc_t)xdr_gfs3_release_req);
- rpc_clnt_unref (conf->rpc);
- }
-
- inode_unref (fdctx->inode);
- GF_FREE (fdctx);
- }
-unwind:
- if (ret)
- STACK_DESTROY (frame->root);
-
+ if (remote_fd != -1 && lk_heal_state == GF_LK_HEAL_DONE)
+ client_fdctx_destroy (this, fdctx);
+out:
return 0;
}
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;
@@ -2520,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) {
@@ -2534,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) {
@@ -2554,75 +3107,61 @@ 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);
if (ret) {
- op_errno = ENOTCONN;
- goto unwind;
+ 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;
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
-
- if (frame)
- frame->local = NULL;
-
- STACK_UNWIND_STRICT (lookup, frame, -1, op_errno, NULL, NULL, NULL,
+ CLIENT_STACK_UNWIND (lookup, frame, -1, op_errno, NULL, NULL, NULL,
NULL);
- client_local_wipe (local);
-
- 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;
@@ -2648,26 +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) {
- op_errno = ENOTCONN;
- goto unwind;
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
+ GF_FREE (req.xdata.xdata_val);
+
return 0;
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop %s",
- strerror (op_errno));
- STACK_UNWIND_STRICT (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;
@@ -2696,25 +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) {
- op_errno = ENOTCONN;
- goto unwind;
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
+
+ GF_FREE (req.xdata.xdata_val);
+
return 0;
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop %s", strerror (op_errno));
- STACK_UNWIND_STRICT (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;
@@ -2731,32 +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) {
- op_errno = ENOTCONN;
- goto unwind;
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
+
+ GF_FREE (req.xdata.xdata_val);
+
return 0;
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- STACK_UNWIND_STRICT (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;
@@ -2785,32 +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) {
- op_errno = ENOTCONN;
- goto unwind;
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
+ GF_FREE (req.xdata.xdata_val);
+
return 0;
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- STACK_UNWIND_STRICT (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;
@@ -2831,20 +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) {
- op_errno = ENOTCONN;
- goto unwind;
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
+ GF_FREE (req.xdata.xdata_val);
+
return 0;
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- STACK_UNWIND_STRICT (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;
}
@@ -2852,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;
@@ -2880,26 +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) {
- op_errno = ENOTCONN;
- goto unwind;
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
+
+ GF_FREE (req.xdata.xdata_val);
+
return 0;
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- STACK_UNWIND_STRICT (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;
@@ -2925,28 +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) {
- op_errno = ENOTCONN;
- goto unwind;
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
+ GF_FREE (req.xdata.xdata_val);
+
return 0;
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- STACK_UNWIND_STRICT (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;
@@ -2966,11 +3583,13 @@ client3_1_symlink (call_frame_t *frame, xlator_t *this,
goto unwind;
}
+ frame->local = local;
+
if (!(args->loc && args->loc->parent))
goto unwind;
loc_copy (&local->loc, args->loc);
- frame->local = local;
+ loc_path (&local->loc, NULL);
if (!uuid_is_null (args->loc->parent->gfid))
memcpy (req.pargfid, args->loc->parent->gfid, 16);
@@ -2982,42 +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) {
- op_errno = ENOTCONN;
- goto unwind;
- }
- if (req.dict.dict_val) {
- GF_FREE (req.dict.dict_val);
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
+
+ GF_FREE (req.xdata.xdata_val);
+
return 0;
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- if (frame)
- frame->local = NULL;
- STACK_UNWIND_STRICT (symlink, frame, -1, op_errno, NULL, NULL, NULL, NULL);
+ CLIENT_STACK_UNWIND (symlink, frame, -1, op_errno, NULL, NULL, NULL,
+ NULL, NULL);
+
+ GF_FREE (req.xdata.xdata_val);
- client_local_wipe (local);
- 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;
@@ -3055,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) {
- op_errno = ENOTCONN;
- goto unwind;
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
+
+ GF_FREE (req.xdata.xdata_val);
+
return 0;
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- STACK_UNWIND_STRICT (rename, frame, -1, op_errno, NULL, NULL, NULL, NULL, NULL);
+ CLIENT_STACK_UNWIND (rename, frame, -1, op_errno, 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;
@@ -3115,30 +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) {
- op_errno = ENOTCONN;
- goto unwind;
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
+
+ GF_FREE (req.xdata.xdata_val);
+
return 0;
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- STACK_UNWIND_STRICT (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;
@@ -3163,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))
@@ -3176,45 +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) {
- op_errno = ENOTCONN;
- goto unwind;
- }
- if (req.dict.dict_val) {
- GF_FREE (req.dict.dict_val);
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
+ GF_FREE (req.xdata.xdata_val);
+
return 0;
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- if (frame)
- frame->local = NULL;
+ CLIENT_STACK_UNWIND (mknod, frame, -1, op_errno, NULL, NULL, NULL,
+ NULL, NULL);
- STACK_UNWIND_STRICT (mknod, frame, -1, op_errno, NULL, NULL, NULL, NULL);
+ GF_FREE (req.xdata.xdata_val);
- client_local_wipe (local);
- 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;
@@ -3239,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))
@@ -3252,44 +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) {
- op_errno = ENOTCONN;
- goto unwind;
- }
- if (req.dict.dict_val) {
- GF_FREE (req.dict.dict_val);
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
+ GF_FREE (req.xdata.xdata_val);
+
return 0;
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- if (frame)
- frame->local = NULL;
+ CLIENT_STACK_UNWIND (mkdir, frame, -1, op_errno, NULL, NULL, NULL,
+ NULL, NULL);
- STACK_UNWIND_STRICT (mkdir, frame, -1, op_errno, NULL, NULL, NULL, NULL);
+ GF_FREE (req.xdata.xdata_val);
- client_local_wipe (local);
- 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;
@@ -3316,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))
@@ -3329,45 +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) {
- op_errno = ENOTCONN;
- goto unwind;
- }
- if (req.dict.dict_val) {
- GF_FREE (req.dict.dict_val);
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
+
+ GF_FREE (req.xdata.xdata_val);
+
return 0;
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- if (frame)
- frame->local = NULL;
+ CLIENT_STACK_UNWIND (create, frame, -1, op_errno, NULL, NULL, NULL,
+ NULL, NULL, NULL);
+
+ GF_FREE (req.xdata.xdata_val);
- STACK_UNWIND_STRICT (create, frame, -1, op_errno, NULL, NULL, NULL,
- NULL, NULL);
- client_local_wipe (local);
- 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;
@@ -3392,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))
@@ -3405,46 +4015,47 @@ 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) {
- op_errno = ENOTCONN;
- goto unwind;
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
+
+ GF_FREE (req.xdata.xdata_val);
+
return 0;
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- if (frame)
- frame->local = NULL;
+ CLIENT_STACK_UNWIND (open, frame, -1, op_errno, NULL, NULL);
- STACK_UNWIND_STRICT (open, frame, -1, op_errno, NULL);
+ GF_FREE (req.xdata.xdata_val);
- client_local_wipe (local);
return 0;
}
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;
@@ -3452,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;
@@ -3475,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);
@@ -3489,51 +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) {
- op_errno = ENOTCONN;
- goto unwind;
+ //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:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- if (rsp_iobuf) {
+ if (rsp_iobuf)
iobuf_unref (rsp_iobuf);
- }
- if (rsp_iobref) {
+ if (rsp_iobref)
iobref_unref (rsp_iobref);
- }
- STACK_UNWIND_STRICT (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;
@@ -3541,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;
@@ -3550,9 +4172,21 @@ client3_1_writev (call_frame_t *frame, xlator_t *this, void *data)
memcpy (req.gfid, args->fd->inode->gfid, 16);
- ret = client_submit_vec_request (this, &req, frame, conf->fops, GFS3_OP_WRITE,
- client3_1_writev_cbk, args->vector,
- args->count, args->iobref,
+#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_3_writev_cbk,
+ args->vector, args->count,
+ args->iobref,
(xdrproc_t)xdr_gfs3_write_req);
if (ret) {
/*
@@ -3560,20 +4194,23 @@ client3_1_writev (call_frame_t *frame, xlator_t *this, void *data)
* do the unwind for us (see rpc_clnt_submit), so don't unwind
* here in such cases.
*/
- gf_log (this->name, GF_LOG_WARNING,
- "failed to send the fop: %s", strerror (op_errno));
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
+ GF_FREE (req.xdata.xdata_val);
+
return 0;
unwind:
- STACK_UNWIND_STRICT (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;
@@ -3590,15 +4227,15 @@ 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;
local = mem_get0 (this->local_pool);
if (!local) {
- STACK_UNWIND (frame, -1, ENOMEM);
- return 0;
-
+ op_errno = ENOMEM;
+ goto unwind;
}
local->fd = fd_ref (args->fd);
@@ -3608,33 +4245,41 @@ 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) {
- op_errno = ENOTCONN;
- goto unwind;
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
+
+ GF_FREE (req.xdata.xdata_val);
+
+
return 0;
+
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- STACK_UNWIND_STRICT (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;
- gfs3_fsync_req req = {{0,},};
+ clnt_args_t *args = NULL;
+ gfs3_fsync_req req = {{0,},};
int64_t remote_fd = -1;
- clnt_conf_t *conf = NULL;
- int op_errno = 0;
- int ret = 0;
+ clnt_conf_t *conf = NULL;
+ int op_errno = 0;
+ int ret = 0;
if (!frame || !this || !data)
goto unwind;
@@ -3642,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) {
- op_errno = ENOTCONN;
- goto unwind;
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
+
}
+
+ GF_FREE (req.xdata.xdata_val);
+
return 0;
+
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- STACK_UNWIND_STRICT (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;
@@ -3683,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) {
- op_errno = ENOTCONN;
- goto unwind;
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
+
+ GF_FREE (req.xdata.xdata_val);
+
return 0;
+
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- STACK_UNWIND_STRICT (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;
@@ -3731,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))
@@ -3744,35 +4406,40 @@ 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) {
- op_errno = ENOTCONN;
- goto unwind;
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
+
+ GF_FREE (req.xdata.xdata_val);
+
return 0;
+
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- if (frame)
- frame->local = NULL;
- STACK_UNWIND_STRICT (opendir, frame, -1, op_errno, NULL);
- client_local_wipe (local);
+ CLIENT_STACK_UNWIND (opendir, frame, -1, op_errno, NULL, NULL);
+
+ GF_FREE (req.xdata.xdata_val);
+
return 0;
}
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;
+ clnt_args_t *args = NULL;
int64_t remote_fd = -1;
- clnt_conf_t *conf = NULL;
- int op_errno = ESTALE;
- gfs3_fsyncdir_req req = {{0,},};
- int ret = 0;
+ clnt_conf_t *conf = NULL;
+ gfs3_fsyncdir_req req = {{0,},};
+ int ret = 0;
+ int32_t op_errno = ESTALE;
if (!frame || !this || !data)
goto unwind;
@@ -3780,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;
@@ -3788,26 +4456,33 @@ 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);
if (ret) {
- op_errno = ENOTCONN;
- goto unwind;
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
+
+ GF_FREE (req.xdata.xdata_val);
+
return 0;
+
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- STACK_UNWIND_STRICT (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;
@@ -3838,25 +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) {
- op_errno = ENOTCONN;
- goto unwind;
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
+
+ GF_FREE (req.xdata.xdata_val);
+
return 0;
+
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- STACK_UNWIND_STRICT (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;
@@ -3881,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);
@@ -3892,32 +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) {
- op_errno = ENOTCONN;
- goto unwind;
- }
- if (req.dict.dict_val) {
- GF_FREE (req.dict.dict_val);
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
+ GF_FREE (req.dict.dict_val);
+
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- STACK_UNWIND_STRICT (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;
@@ -3933,39 +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) {
- op_errno = ENOTCONN;
- goto unwind;
+ 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:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- STACK_UNWIND_STRICT (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;
}
@@ -3973,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;
@@ -3995,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) {
@@ -4019,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 */
@@ -4036,34 +4725,38 @@ 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);
if (ret) {
- op_errno = ENOTCONN;
- goto unwind;
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- return 0;
-unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- local = frame->local;
- frame->local = NULL;
+ GF_FREE (req.xdata.xdata_val);
- STACK_UNWIND_STRICT (fgetxattr, frame, -1, op_errno, NULL);
+ if (rsp_iobuf)
+ iobuf_unref (rsp_iobuf);
- client_local_wipe (local);
+ if (rsp_iobref)
+ iobref_unref (rsp_iobref);
+
+ return 0;
+unwind:
+ 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;
}
@@ -4071,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;
@@ -4094,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;
}
@@ -4104,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 ();
@@ -4121,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);
@@ -4166,34 +4866,38 @@ 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);
if (ret) {
- op_errno = ENOTCONN;
- goto unwind;
+ 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:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s",
- strerror (op_errno));
- local = frame->local;
- frame->local = NULL;
- client_local_wipe (local);
-
- if (rsp_iobuf) {
+ if (rsp_iobuf)
iobuf_unref (rsp_iobuf);
- }
- if (rsp_iobref) {
+ if (rsp_iobref)
iobref_unref (rsp_iobref);
- }
- STACK_UNWIND_STRICT (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;
}
@@ -4201,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;
@@ -4246,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))
@@ -4259,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);
@@ -4273,41 +4980,42 @@ 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);
if (ret) {
- op_errno = ENOTCONN;
- goto unwind;
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.dict.dict_val) {
- GF_FREE (req.dict.dict_val);
- }
- return 0;
-unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- local = frame->local;
- frame->local = NULL;
+ GF_FREE (req.dict.dict_val);
- STACK_UNWIND_STRICT (xattrop, frame, -1, op_errno, NULL);
+ GF_FREE (req.xdata.xdata_val);
- if (req.dict.dict_val) {
- GF_FREE (req.dict.dict_val);
- }
+ if (rsp_iobuf)
+ iobuf_unref (rsp_iobuf);
- client_local_wipe (local);
+ if (rsp_iobref)
+ iobref_unref (rsp_iobref);
+
+ return 0;
+unwind:
+ CLIENT_STACK_UNWIND (xattrop, frame, -1, op_errno, NULL, NULL);
- if (rsp_iobuf) {
+ GF_FREE (req.dict.dict_val);
+
+ 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;
}
@@ -4315,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;
@@ -4337,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;
@@ -4369,61 +5078,54 @@ 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);
if (ret) {
- op_errno = ENOTCONN;
- goto unwind;
+ 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:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- local = frame->local;
- frame->local = NULL;
-
- STACK_UNWIND_STRICT (fxattrop, frame, -1, op_errno, NULL);
-
- if (req.dict.dict_val) {
- GF_FREE (req.dict.dict_val);
- }
+ CLIENT_STACK_UNWIND (fxattrop, frame, -1, op_errno, NULL, NULL);
- client_local_wipe (local);
+ 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;
@@ -4452,25 +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) {
- op_errno = ENOTCONN;
- goto unwind;
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
+ GF_FREE (req.xdata.xdata_val);
+
return 0;
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- STACK_UNWIND_STRICT (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;
@@ -4490,31 +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) {
- op_errno = ENOTCONN;
- goto unwind;
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
+ GF_FREE (req.xdata.xdata_val);
+
return 0;
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- STACK_UNWIND_STRICT (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;
@@ -4538,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) {
@@ -4572,25 +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) {
- op_errno = ENOTCONN;
- goto unwind;
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
+ GF_FREE (req.xdata.xdata_val);
+
return 0;
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- STACK_UNWIND_STRICT (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;
@@ -4648,27 +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) {
- op_errno = ENOTCONN;
- goto unwind;
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
+ GF_FREE (req.xdata.xdata_val);
+
return 0;
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- STACK_UNWIND_STRICT (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;
@@ -4678,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;
@@ -4719,26 +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) {
- op_errno = ENOTCONN;
- goto unwind;
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- STACK_UNWIND_STRICT (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;
@@ -4774,27 +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) {
- op_errno = ENOTCONN;
- goto unwind;
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
+ GF_FREE (req.xdata.xdata_val);
+
return 0;
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- STACK_UNWIND_STRICT (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;
@@ -4810,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;
@@ -4823,26 +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) {
- op_errno = ENOTCONN;
- goto unwind;
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
+ GF_FREE (req.xdata.xdata_val);
+
return 0;
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- STACK_UNWIND_STRICT (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;
@@ -4858,33 +5602,40 @@ 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);
+ 0, NULL,
+ (xdrproc_t)xdr_gfs3_rchecksum_req);
if (ret) {
- op_errno = ENOTCONN;
- goto unwind;
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
+ GF_FREE (req.xdata.xdata_val);
+
return 0;
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- STACK_UNWIND_STRICT (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;
@@ -4908,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;
@@ -4937,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;
@@ -4952,43 +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) {
- op_errno = ENOTCONN;
- goto unwind;
+ 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:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- local = frame->local;
- frame->local = NULL;
- client_local_wipe (local);
-
- if (rsp_iobref != NULL) {
+ if (rsp_iobref)
iobref_unref (rsp_iobref);
- }
- if (rsp_iobuf != NULL) {
+ if (rsp_iobuf)
iobuf_unref (rsp_iobuf);
- }
- STACK_UNWIND_STRICT (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;
@@ -5012,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;
@@ -5042,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;
}
@@ -5058,46 +5817,45 @@ 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);
if (ret) {
- op_errno = ENOTCONN;
- goto unwind;
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
+ GF_FREE (req.dict.dict_val);
+
+ if (rsp_iobuf)
+ iobuf_unref (rsp_iobuf);
+
+ if (rsp_iobref)
+ iobref_unref (rsp_iobref);
+
return 0;
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- local = frame->local;
- frame->local = NULL;
- client_local_wipe (local);
-
- if (rsp_iobref) {
+ if (rsp_iobref)
iobref_unref (rsp_iobref);
- }
- if (rsp_iobuf) {
+ if (rsp_iobuf)
iobuf_unref (rsp_iobuf);
- }
- STACK_UNWIND_STRICT (readdirp, frame, -1, op_errno, NULL);
+ GF_FREE (req.dict.dict_val);
+
+ 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;
@@ -5127,25 +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) {
- op_errno = ENOTCONN;
- goto unwind;
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
+ GF_FREE (req.xdata.xdata_val);
+
return 0;
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- STACK_UNWIND_STRICT (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;
@@ -5160,84 +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) {
- op_errno = ENOTCONN;
+ 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:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
- STACK_UNWIND_STRICT (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",
@@ -5282,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 1386a2a1b..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.
*/
@@ -45,7 +36,7 @@ int client_mark_fd_bad (xlator_t *this);
int32_t
client_type_to_gf_type (short l_type)
{
- int32_t gf_type;
+ int32_t gf_type = GF_LK_EOL;
switch (l_type) {
case F_RDLCK:
@@ -116,22 +107,58 @@ out:
return;
}
+int32_t
+client_register_grace_timer (xlator_t *this, clnt_conf_t *conf)
+{
+ int32_t ret = -1;
+
+ GF_VALIDATE_OR_GOTO ("client", this, out);
+ GF_VALIDATE_OR_GOTO (this->name, conf, out);
+
+ pthread_mutex_lock (&conf->lock);
+ {
+ if (conf->grace_timer || !conf->grace_timer_needed) {
+ gf_log (this->name, GF_LOG_TRACE,
+ "Client grace timer is already set "
+ "or a grace-timer has already time out, "
+ "not registering a new timer");
+ } 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_ts,
+ client_grace_timeout,
+ conf->rpc);
+ }
+ }
+ pthread_mutex_unlock (&conf->lock);
+
+ ret = 0;
+out:
+ return ret;
+}
+
int
client_submit_request (xlator_t *this, void *req, call_frame_t *frame,
- rpc_clnt_prog_t *prog, int procnum, fop_cbk_fn_t cbk,
+ rpc_clnt_prog_t *prog, int procnum, fop_cbk_fn_t cbkfn,
struct iobref *iobref, struct iovec *rsphdr,
int rsphdr_count, struct iovec *rsp_payload,
int rsp_payload_count, struct iobref *rsp_iobref,
xdrproc_t xdrproc)
{
- int ret = -1;
- clnt_conf_t *conf = NULL;
- struct iovec iov = {0, };
- struct iobuf *iobuf = NULL;
- int count = 0;
- char start_ping = 0;
- struct iobref *new_iobref = NULL;
- ssize_t xdr_size = 0;
+ int ret = -1;
+ clnt_conf_t *conf = NULL;
+ struct iovec iov = {0, };
+ struct iobuf *iobuf = NULL;
+ int count = 0;
+ char start_ping = 0;
+ struct iobref *new_iobref = NULL;
+ ssize_t xdr_size = 0;
+ struct rpc_req rpcreq = {0, };
GF_VALIDATE_OR_GOTO ("client", this, out);
GF_VALIDATE_OR_GOTO (this->name, prog, out);
@@ -199,8 +226,8 @@ client_submit_request (xlator_t *this, void *req, call_frame_t *frame,
}
/* Send the msg */
- ret = rpc_clnt_submit (conf->rpc, prog, procnum, cbk, &iov, count, NULL,
- 0, new_iobref, frame, rsphdr, rsphdr_count,
+ ret = rpc_clnt_submit (conf->rpc, prog, procnum, cbkfn, &iov, count,
+ NULL, 0, new_iobref, frame, rsphdr, rsphdr_count,
rsp_payload, rsp_payload_count, rsp_iobref);
if (ret < 0) {
@@ -221,14 +248,27 @@ client_submit_request (xlator_t *this, void *req, call_frame_t *frame,
client_start_ping ((void *) this);
ret = 0;
-out:
- if (new_iobref != NULL)
+
+ if (new_iobref)
iobref_unref (new_iobref);
if (iobuf)
iobuf_unref (iobuf);
return ret;
+
+out:
+ rpcreq.rpc_status = -1;
+
+ cbkfn (&rpcreq, NULL, 0, frame);
+
+ if (new_iobref)
+ iobref_unref (new_iobref);
+
+ if (iobuf)
+ iobuf_unref (iobuf);
+
+ return 0;
}
@@ -246,7 +286,6 @@ client_releasedir (xlator_t *this, fd_t *fd)
clnt_conf_t *conf = NULL;
rpc_clnt_procedure_t *proc = NULL;
clnt_args_t args = {0,};
- call_frame_t *frame = NULL;
conf = this->private;
if (!conf || !conf->fops)
@@ -262,11 +301,7 @@ client_releasedir (xlator_t *this, fd_t *fd)
goto out;
}
if (proc->fn) {
- frame = create_frame (this, this->ctx->pool);
- if (!frame) {
- goto out;
- }
- ret = proc->fn (frame, this, &args);
+ ret = proc->fn (NULL, this, &args);
}
out:
if (ret)
@@ -282,7 +317,6 @@ client_release (xlator_t *this, fd_t *fd)
clnt_conf_t *conf = NULL;
rpc_clnt_procedure_t *proc = NULL;
clnt_args_t args = {0,};
- call_frame_t *frame = NULL;
conf = this->private;
if (!conf || !conf->fops)
@@ -297,11 +331,7 @@ client_release (xlator_t *this, fd_t *fd)
goto out;
}
if (proc->fn) {
- frame = create_frame (this, this->ctx->pool);
- if (!frame) {
- goto out;
- }
- ret = proc->fn (frame, this, &args);
+ ret = proc->fn (NULL, this, &args);
}
out:
if (ret)
@@ -313,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;
@@ -325,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) {
@@ -347,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;
@@ -359,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) {
@@ -371,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;
@@ -391,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) {
@@ -403,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;
@@ -411,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;
@@ -424,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) {
@@ -436,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;
}
@@ -444,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;
@@ -457,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) {
@@ -469,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;
}
@@ -478,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;
@@ -491,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) {
@@ -503,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;
}
@@ -511,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;
@@ -525,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) {
@@ -539,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;
}
@@ -547,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;
@@ -560,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) {
@@ -574,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;
}
@@ -582,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;
@@ -594,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) {
@@ -607,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;
@@ -626,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) {
@@ -640,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;
}
@@ -648,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;
@@ -661,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) {
@@ -675,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;
}
@@ -684,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;
@@ -697,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,
@@ -709,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;
}
@@ -718,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;
@@ -731,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) {
@@ -744,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;
}
@@ -752,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;
@@ -765,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) {
@@ -782,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;
}
@@ -791,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;
@@ -803,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) {
@@ -819,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;
}
@@ -828,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;
@@ -843,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) {
@@ -857,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;
}
@@ -868,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;
@@ -885,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) {
@@ -897,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;
@@ -916,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) {
@@ -928,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;
}
@@ -937,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;
@@ -950,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) {
@@ -962,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;
}
@@ -970,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;
@@ -982,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) {
@@ -994,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;
}
@@ -1002,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;
@@ -1015,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) {
@@ -1027,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;
}
@@ -1035,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;
@@ -1048,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) {
@@ -1060,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;
}
@@ -1068,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;
@@ -1080,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) {
@@ -1092,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;
}
@@ -1209,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;
}
@@ -1218,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;
@@ -1266,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) {
@@ -1284,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;
}
@@ -1293,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;
@@ -1304,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) {
@@ -1319,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;
}
@@ -1329,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;
@@ -1342,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) {
@@ -1354,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;
}
@@ -1363,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;
@@ -1376,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) {
@@ -1388,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;
}
@@ -1397,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;
@@ -1410,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) {
@@ -1423,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;
}
@@ -1432,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;
@@ -1445,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) {
@@ -1458,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;
}
@@ -1467,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;
@@ -1480,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) {
@@ -1492,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;
@@ -1512,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) {
@@ -1524,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;
@@ -1545,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) {
@@ -1557,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;
}
@@ -1565,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;
@@ -1580,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) {
@@ -1592,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;
}
@@ -1601,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;
@@ -1616,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) {
@@ -1628,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;
}
@@ -1637,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;
@@ -1653,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) {
@@ -1665,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;
}
@@ -1675,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;
@@ -1691,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) {
@@ -1703,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;
}
@@ -1711,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;
@@ -1725,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) {
@@ -1737,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;
@@ -1758,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) {
@@ -1770,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;
}
@@ -1792,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.xattr_req = dict;
+ args.xdata = dict;
proc = &conf->fops->proctable[GF_FOP_READDIRP];
if (!proc) {
@@ -1805,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;
}
@@ -1813,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;
@@ -1827,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) {
@@ -1839,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;
@@ -1860,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) {
@@ -1872,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,
@@ -1966,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);
@@ -1985,13 +2173,16 @@ client_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,
/* Cancel grace timer if set */
pthread_mutex_lock (&conf->lock);
{
+ conf->grace_timer_needed = _gf_true;
+
if (conf->grace_timer) {
gf_log (this->name, GF_LOG_WARNING,
"Cancelling the grace timer");
gf_timer_call_cancel (this->ctx,
conf->grace_timer);
- conf->grace_timer = NULL;
+
+ conf->grace_timer = NULL;
}
}
pthread_mutex_unlock (&conf->lock);
@@ -1999,29 +2190,25 @@ client_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,
break;
}
case RPC_CLNT_DISCONNECT:
- /* client_mark_fd_bad (this); */
-
- pthread_mutex_lock (&conf->lock);
- {
- if (conf->grace_timer) {
- gf_log (this->name, GF_LOG_DEBUG,
- "Client grace timer is already set");
- } else {
- gf_log (this->name, GF_LOG_WARNING,
- "Registering a grace timer");
- conf->grace_timer =
- gf_timer_call_after (this->ctx,
- conf->grace_tv,
- client_grace_timeout,
- conf->rpc);
- }
- }
- pthread_mutex_unlock (&conf->lock);
+ if (!conf->lk_heal)
+ client_mark_fd_bad (this);
+ else
+ 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
@@ -2045,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:
@@ -2128,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;
@@ -2164,6 +2363,9 @@ client_destroy_rpc (xlator_t *this)
goto out;
if (conf->rpc) {
+ /* cleanup the saved-frames before last unref */
+ rpc_clnt_connection_cleanup (&conf->rpc->conn);
+
conf->rpc = rpc_clnt_unref (conf->rpc);
ret = 0;
gf_log (this->name, GF_LOG_DEBUG,
@@ -2194,7 +2396,7 @@ client_init_rpc (xlator_t *this)
goto out;
}
- conf->rpc = rpc_clnt_new (this->options, this->ctx, this->name);
+ conf->rpc = rpc_clnt_new (this->options, this->ctx, this->name, 0);
if (!conf->rpc) {
gf_log (this->name, GF_LOG_ERROR, "failed to initialize RPC");
goto out;
@@ -2209,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");
@@ -2236,22 +2439,25 @@ 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)
gf_string2boolean (lk_heal, &conf->lk_heal);
+ gf_log (this->name, GF_LOG_DEBUG, "lk-heal = %s",
+ (conf->lk_heal) ? "on" : "off");
+
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_INFO, "lk-heal = %s",
- (conf->lk_heal) ? "on" : "off");
+ gf_log (this->name, GF_LOG_DEBUG, "Client grace timeout "
+ "value = %"PRIu64, conf->grace_ts.tv_sec);
ret = 0;
out:
@@ -2305,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;
@@ -2322,7 +2531,6 @@ init (xlator_t *this)
int ret = -1;
clnt_conf_t *conf = NULL;
- /* */
if (this->children) {
gf_log (this->name, GF_LOG_ERROR,
"FATAL: client protocol translator cannot have any "
@@ -2343,8 +2551,9 @@ init (xlator_t *this)
INIT_LIST_HEAD (&conf->saved_fds);
/* Initialize parameters for lock self healing*/
- conf->lk_version = 1;
- conf->grace_timer = NULL;
+ conf->lk_version = 1;
+ conf->grace_timer = NULL;
+ conf->grace_timer_needed = _gf_true;
ret = client_init_grace_timer (this, this->options, conf);
if (ret)
@@ -2371,7 +2580,7 @@ init (xlator_t *this)
goto out;
}
- this->local_pool = mem_pool_new (clnt_local_t, 1024);
+ this->local_pool = mem_pool_new (clnt_local_t, 64);
if (!this->local_pool) {
ret = -1;
gf_log (this->name, GF_LOG_ERROR,
@@ -2396,8 +2605,12 @@ fini (xlator_t *this)
this->private = NULL;
if (conf) {
- if (conf->rpc)
- rpc_clnt_unref (conf->rpc);
+ if (conf->rpc) {
+ /* cleanup the saved-frames before last unref */
+ rpc_clnt_connection_cleanup (&conf->rpc->conn);
+
+ rpc_clnt_unref (conf->rpc);
+ }
/* Saved Fds */
/* TODO: */
@@ -2409,6 +2622,54 @@ fini (xlator_t *this)
return;
}
+static void
+client_fd_lk_ctx_dump (xlator_t *this, fd_lk_ctx_t *lk_ctx, int nth_fd)
+{
+ gf_boolean_t use_try_lock = _gf_true;
+ int ret = -1;
+ int lock_no = 0;
+ fd_lk_ctx_t *lk_ctx_ref = NULL;
+ fd_lk_ctx_node_t *plock = NULL;
+ char key[GF_DUMP_MAX_BUF_LEN] = {0,};
+
+ lk_ctx_ref = fd_lk_ctx_try_ref (lk_ctx);
+ if (!lk_ctx_ref)
+ return;
+
+ ret = client_fd_lk_list_empty (lk_ctx_ref, (use_try_lock = _gf_true));
+ if (ret != 0)
+ return;
+
+ ret = TRY_LOCK (&lk_ctx_ref->lock);
+ if (ret)
+ return;
+
+ gf_proc_dump_write ("------","------");
+
+ lock_no = 0;
+ list_for_each_entry (plock, &lk_ctx_ref->lk_list, next) {
+ snprintf (key, sizeof (key), "granted-posix-lock[%d]",
+ lock_no++);
+ gf_proc_dump_write (key, "owner = %s, cmd = %s "
+ "fl_type = %s, fl_start = %"
+ PRId64", fl_end = %"PRId64
+ ", user_flock: l_type = %s, "
+ "l_start = %"PRId64", l_len = %"PRId64,
+ lkowner_utoa (&plock->user_flock.l_owner),
+ get_lk_cmd (plock->cmd),
+ get_lk_type (plock->fl_type),
+ plock->fl_start, plock->fl_end,
+ get_lk_type (plock->user_flock.l_type),
+ plock->user_flock.l_start,
+ plock->user_flock.l_len);
+ }
+ gf_proc_dump_write ("------","------");
+
+ UNLOCK (&lk_ctx_ref->lock);
+ fd_lk_ctx_unref (lk_ctx_ref);
+
+}
+
int
client_priv_dump (xlator_t *this)
{
@@ -2423,18 +2684,12 @@ client_priv_dump (xlator_t *this)
return -1;
conf = this->private;
- if (!conf) {
- gf_log (this->name, GF_LOG_WARNING,
- "conf null in xlator");
+ if (!conf)
return -1;
- }
ret = pthread_mutex_trylock(&conf->lock);
- if (ret) {
- gf_log(this->name, GF_LOG_WARNING, "Unable to lock client %s"
- " errno: %d", this->name, errno);
+ if (ret)
return -1;
- }
gf_proc_dump_build_key(key_prefix, "xlator.protocol.client",
"%s.priv", this->name);
@@ -2442,13 +2697,13 @@ client_priv_dump (xlator_t *this)
gf_proc_dump_add_section(key_prefix);
list_for_each_entry(tmp, &conf->saved_fds, sfd_pos) {
- sprintf (key, "fd.%d.remote_fd", ++i);
+ sprintf (key, "fd.%d.remote_fd", i);
gf_proc_dump_write(key, "%d", tmp->remote_fd);
+ client_fd_lk_ctx_dump (this, tmp->lk_ctx, i);
+ i++;
}
gf_proc_dump_write("connecting", "%d", conf->connecting);
- gf_proc_dump_write("last_sent", "%s", ctime(&conf->last_sent.tv_sec));
- gf_proc_dump_write("last_received", "%s", ctime(&conf->last_received.tv_sec));
if (conf->rpc) {
gf_proc_dump_write("total_bytes_read", "%"PRIu64,
@@ -2528,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,
};
@@ -2581,10 +2839,29 @@ struct volume_options options[] = {
.type = GF_OPTION_TYPE_BOOL
},
{ .key = {"lk-heal"},
- .type = GF_OPTION_TYPE_STR
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "off",
+ .description = "Enables or disables the lock heal."
},
{ .key = {"grace-timeout"},
- .type = GF_OPTION_TYPE_INT
+ .type = GF_OPTION_TYPE_INT,
+ .min = 10,
+ .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,
+ .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 f7267b44a..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
@@ -35,28 +26,43 @@
#define CLIENT_CMD_CONNECT "trusted.glusterfs.client-connect"
#define CLIENT_CMD_DISCONNECT "trusted.glusterfs.client-disconnect"
#define CLIENT_DUMP_LOCKS "trusted.glusterfs.clientlk-dump"
+#define GF_MAX_SOCKET_WINDOW_SIZE (1 * GF_UNIT_MB)
+#define GF_MIN_SOCKET_WINDOW_SIZE (0)
+
+typedef enum {
+ GF_LK_HEAL_IN_PROGRESS,
+ GF_LK_HEAL_DONE,
+} lk_heal_state_t;
+
+typedef enum {
+ DEFAULT_REMOTE_FD = 0,
+ FALLBACK_TO_ANON_FD = 1
+} clnt_remote_fd_flags_t;
-#define CLIENT_GET_REMOTE_FD(conf, fd, remote_fd, op_errno, label) \
+#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; \
+ frame->local = NULL; \
+ STACK_UNWIND_STRICT (op, frame, params); \
+ client_local_wipe (__local); \
+ } while (0)
+
struct clnt_options {
char *remote_subvolume;
@@ -71,8 +77,6 @@ typedef struct clnt_conf {
pthread_mutex_t lock;
int connecting;
int connected;
- struct timeval last_sent;
- struct timeval last_received;
rpc_clnt_prog_t *fops;
rpc_clnt_prog_t *mgmt;
@@ -89,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 */
@@ -96,10 +104,22 @@ 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
+ a new grace-timer must be
+ registered or not. False
+ 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 {
@@ -107,16 +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 {
@@ -137,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;
@@ -145,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;
@@ -170,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;
@@ -178,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);
@@ -196,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);
@@ -209,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);
@@ -227,4 +244,14 @@ int32_t client_type_to_gf_type (short l_type);
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 */