summaryrefslogtreecommitdiffstats
path: root/xlators/protocol/client/src
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/protocol/client/src')
-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.c399
-rw-r--r--xlators/protocol/client/src/client-helpers.c95
-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)1583
-rw-r--r--xlators/protocol/client/src/client.c202
-rw-r--r--xlators/protocol/client/src/client.h84
9 files changed, 1467 insertions, 1334 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 c249516a9..5668fea53 100644
--- a/xlators/protocol/client/src/client-handshake.c
+++ b/xlators/protocol/client/src/client-handshake.c
@@ -1,20 +1,11 @@
/*
- Copyright (c) 2010-2011 Gluster, Inc. <http://www.gluster.com>
+ Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com>
This file is part of GlusterFS.
- GlusterFS is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3 of the License,
- or (at your option) any later version.
-
- GlusterFS is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see
- <http://www.gnu.org/licenses/>.
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
*/
#ifndef _CONFIG_H
@@ -34,7 +25,8 @@
#include "portmap-xdr.h"
#include "rpc-common-xdr.h"
-extern rpc_clnt_prog_t clnt3_1_fop_prog;
+#define CLIENT_REOPEN_MAX_ATTEMPTS 1024
+extern rpc_clnt_prog_t clnt3_3_fop_prog;
extern rpc_clnt_prog_t clnt_pmap_prog;
int client_ping_cbk (struct rpc_req *req, struct iovec *iov, int count,
@@ -61,7 +53,7 @@ rpc_client_ping_timer_expired (void *data)
rpc_clnt_connection_t *conn = NULL;
int disconnect = 0;
int transport_activity = 0;
- struct timeval timeout = {0, };
+ struct timespec timeout = {0, };
struct timeval current = {0, };
struct rpc_clnt *clnt = NULL;
xlator_t *this = NULL;
@@ -109,7 +101,7 @@ rpc_client_ping_timer_expired (void *data)
"ping timer expired but transport activity "
"detected - not bailing transport");
timeout.tv_sec = conf->opt.ping_timeout;
- timeout.tv_usec = 0;
+ timeout.tv_nsec = 0;
conn->ping_timer =
gf_timer_call_after (this->ctx, timeout,
@@ -148,7 +140,7 @@ client_start_ping (void *data)
clnt_conf_t *conf = NULL;
rpc_clnt_connection_t *conn = NULL;
int32_t ret = -1;
- struct timeval timeout = {0, };
+ struct timespec timeout = {0, };
call_frame_t *frame = NULL;
int frame_count = 0;
@@ -204,7 +196,7 @@ client_start_ping (void *data)
}
timeout.tv_sec = conf->opt.ping_timeout;
- timeout.tv_usec = 0;
+ timeout.tv_nsec = 0;
conn->ping_timer =
gf_timer_call_after (this->ctx, timeout,
@@ -249,7 +241,7 @@ 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;
@@ -289,7 +281,7 @@ client_ping_cbk (struct rpc_req *req, struct iovec *iov, int count,
timeout.tv_sec = conf->opt.ping_timeout;
- timeout.tv_usec = 0;
+ timeout.tv_nsec = 0;
gf_timer_call_cancel (this->ctx,
conn->ping_timer);
@@ -356,8 +348,7 @@ out:
rsp.spec);
/* Don't use 'GF_FREE', this is allocated by libc */
- if (rsp.spec)
- free (rsp.spec);
+ free (rsp.spec);
return 0;
}
@@ -425,9 +416,6 @@ clnt_fd_lk_reacquire_failed (xlator_t *this, clnt_fd_ctx_t *fdctx,
{
fdctx->remote_fd = -1;
fdctx->lk_heal_state = GF_LK_HEAL_DONE;
-
- list_add_tail (&fdctx->sfd_pos,
- &conf->saved_fds);
}
pthread_mutex_unlock (&conf->lock);
@@ -463,13 +451,13 @@ client_set_lk_version_cbk (struct rpc_req *req, struct iovec *iov,
ret = 0;
out:
- //TODO: Check for all released fdctx and destroy them
if (fr)
STACK_DESTROY (fr->root);
return ret;
}
+//TODO: Check for all released fdctx and destroy them
int
client_set_lk_version (xlator_t *this)
{
@@ -478,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,
@@ -496,11 +492,11 @@ client_set_lk_version (xlator_t *this)
NULL, NULL, 0, NULL, 0, NULL,
(xdrproc_t)xdr_gf_set_lk_ver_req);
out:
- if (ret < 0) {
- //TODO: Check for all released fdctx and destroy them
- gf_log (this->name, GF_LOG_WARNING,
- "Failed to send SET_LK_VERSION to server");
- }
+ GF_FREE (req.uid);
+ return ret;
+err:
+ gf_log (this->name, GF_LOG_WARNING,
+ "Failed to send SET_LK_VERSION to server");
return ret;
}
@@ -605,7 +601,7 @@ clnt_release_reopen_fd_cbk (struct rpc_req *req, struct iovec *iov,
clnt_fd_lk_reacquire_failed (this, fdctx, conf);
- decrement_reopen_fd_count (this, conf);
+ fdctx->reopen_done (fdctx, this);
frame->local = NULL;
STACK_DESTROY (frame->root);
@@ -623,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;
@@ -635,10 +631,11 @@ clnt_release_reopen_fd (xlator_t *this, clnt_fd_ctx_t *fdctx)
clnt_release_reopen_fd_cbk, NULL,
NULL, 0, NULL, 0, NULL,
(xdrproc_t)xdr_gfs3_releasedir_req);
+ return 0;
out:
if (ret) {
- decrement_reopen_fd_count (this, conf);
clnt_fd_lk_reacquire_failed (this, fdctx, conf);
+ fdctx->reopen_done (fdctx, this);
if (frame) {
frame->local = NULL;
STACK_DESTROY (frame->root);
@@ -748,21 +745,18 @@ client_reacquire_lock_cbk (struct rpc_req *req, struct iovec *iov,
gf_log (this->name, GF_LOG_DEBUG, "%s type lock reacquired on file "
"with gfid %s from %"PRIu64 " to %"PRIu64,
- get_lk_type (lock.l_type), uuid_utoa (fdctx->inode->gfid),
+ get_lk_type (lock.l_type), uuid_utoa (fdctx->gfid),
lock.l_start, lock.l_start + lock.l_len);
- if (clnt_fd_lk_local_unref (this, local) == 0 &&
- !clnt_fd_lk_local_error_status (this, local)) {
+ if (!clnt_fd_lk_local_error_status (this, local) &&
+ clnt_fd_lk_local_unref (this, local) == 0) {
pthread_mutex_lock (&conf->lock);
{
fdctx->lk_heal_state = GF_LK_HEAL_DONE;
-
- list_add_tail (&fdctx->sfd_pos,
- &conf->saved_fds);
}
pthread_mutex_unlock (&conf->lock);
- decrement_reopen_fd_count (this, conf);
+ fdctx->reopen_done (fdctx, this);
}
ret = 0;
@@ -800,7 +794,7 @@ _client_reacquire_lock (xlator_t *this, clnt_fd_ctx_t *fdctx)
if (!local) {
gf_log (this->name, GF_LOG_WARNING, "clnt_fd_lk_local_create "
"failed, aborting reacquring of locks on %s.",
- uuid_utoa (fdctx->inode->gfid));
+ uuid_utoa (fdctx->gfid));
clnt_reacquire_lock_error (this, fdctx, conf);
goto out;
}
@@ -826,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;
@@ -845,7 +839,7 @@ _client_reacquire_lock (xlator_t *this, clnt_fd_ctx_t *fdctx)
if (ret) {
gf_log (this->name, GF_LOG_WARNING,
"reacquiring locks failed on file with gfid %s",
- uuid_utoa (fdctx->inode->gfid));
+ uuid_utoa (fdctx->gfid));
break;
}
@@ -871,8 +865,7 @@ client_reacquire_lock (xlator_t *this, clnt_fd_ctx_t *fdctx)
if (client_fd_lk_list_empty (fdctx->lk_ctx, _gf_false)) {
gf_log (this->name, GF_LOG_DEBUG,
"fd lock list is empty");
- decrement_reopen_fd_count (this,
- (clnt_conf_t *)this->private);
+ fdctx->reopen_done (fdctx, this);
} else {
lk_ctx = fdctx->lk_ctx;
@@ -887,14 +880,66 @@ out:
return ret;
}
+void
+client_default_reopen_done (clnt_fd_ctx_t *fdctx, xlator_t *this)
+{
+ gf_log_callingfn (this->name, GF_LOG_WARNING,
+ "This function should never be called");
+}
+
+void
+client_reopen_done (clnt_fd_ctx_t *fdctx, xlator_t *this)
+{
+ clnt_conf_t *conf = NULL;
+ gf_boolean_t destroy = _gf_false;
+
+ conf = this->private;
+
+ pthread_mutex_lock (&conf->lock);
+ {
+ fdctx->reopen_attempts = 0;
+ if (!fdctx->released)
+ list_add_tail (&fdctx->sfd_pos, &conf->saved_fds);
+ else
+ destroy = _gf_true;
+ fdctx->reopen_done = client_default_reopen_done;
+ }
+ pthread_mutex_unlock (&conf->lock);
+
+ if (destroy)
+ client_fdctx_destroy (this, fdctx);
+}
+
+void
+client_child_up_reopen_done (clnt_fd_ctx_t *fdctx, xlator_t *this)
+{
+ clnt_conf_t *conf = NULL;
+ uint64_t fd_count = 0;
+
+ conf = this->private;
+
+ LOCK (&conf->rec_lock);
+ {
+ fd_count = --(conf->reopen_fd_count);
+ }
+ UNLOCK (&conf->rec_lock);
+
+ client_reopen_done (fdctx, this);
+ if (fd_count == 0) {
+ gf_log (this->name, GF_LOG_INFO,
+ "last fd open'd/lock-self-heal'd - notifying CHILD-UP");
+ client_set_lk_version (this);
+ client_notify_parents_child_up (this);
+ }
+}
+
int
-client3_1_reopen_cbk (struct rpc_req *req, struct iovec *iov, int count,
+client3_3_reopen_cbk (struct rpc_req *req, struct iovec *iov, int count,
void *myframe)
{
int32_t ret = -1;
gfs3_open_rsp rsp = {0,};
- int attempt_lock_recovery = _gf_false;
- uint64_t fd_count = 0;
+ gf_boolean_t attempt_lock_recovery = _gf_false;
clnt_local_t *local = NULL;
clnt_conf_t *conf = NULL;
clnt_fd_ctx_t *fdctx = NULL;
@@ -902,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,
@@ -940,32 +983,23 @@ client3_1_reopen_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- fdctx = local->fdctx;
- if (!fdctx) {
- gf_log (frame->this->name, GF_LOG_WARNING, "fdctx not found");
- ret = -1;
- goto out;
- }
-
pthread_mutex_lock (&conf->lock);
{
fdctx->remote_fd = rsp.fd;
if (!fdctx->released) {
- if (!client_fd_lk_list_empty (fdctx->lk_ctx, _gf_false)) {
+ if (conf->lk_heal &&
+ !client_fd_lk_list_empty (fdctx->lk_ctx,
+ _gf_false)) {
attempt_lock_recovery = _gf_true;
fdctx->lk_heal_state = GF_LK_HEAL_IN_PROGRESS;
- } else {
- list_add_tail (&fdctx->sfd_pos,
- &conf->saved_fds);
}
- fdctx = NULL;
}
}
pthread_mutex_unlock (&conf->lock);
ret = 0;
- if (conf->lk_heal && attempt_lock_recovery) {
+ if (attempt_lock_recovery) {
/* Delay decrementing the reopen fd count untill all the
locks corresponding to this fd are acquired.*/
gf_log (this->name, GF_LOG_DEBUG, "acquiring locks "
@@ -975,23 +1009,15 @@ client3_1_reopen_cbk (struct rpc_req *req, struct iovec *iov, int count,
clnt_reacquire_lock_error (this, local->fdctx, conf);
gf_log (this->name, GF_LOG_WARNING, "acquiring locks "
"failed on %s", local->loc.path);
- ret = 0;
}
- } else {
- fd_count = decrement_reopen_fd_count (frame->this, conf);
}
out:
- if (fdctx) {
- clnt_release_reopen_fd (this, fdctx);
- } else if ((ret < 0) && frame && frame->this && conf) {
- decrement_reopen_fd_count (frame->this, conf);
- }
+ if (!attempt_lock_recovery)
+ fdctx->reopen_done (fdctx, this);
- if (frame) {
- frame->local = NULL;
- STACK_DESTROY (frame->root);
- }
+ frame->local = NULL;
+ STACK_DESTROY (frame->root);
client_local_wipe (local);
@@ -999,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;
@@ -1010,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,
@@ -1047,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) {
@@ -1126,24 +1117,24 @@ protocol_client_reopendir (xlator_t *this, clnt_fd_ctx_t *fdctx)
goto out;
}
- memcpy (req.gfid, inode->gfid, 16);
+ memcpy (req.gfid, fdctx->gfid, 16);
gf_log (frame->this->name, GF_LOG_DEBUG,
"attempting reopen on %s", local->loc.path);
- frame->local = local; local = NULL;
+ frame->local = local;
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_OPENDIR,
- client3_1_reopendir_cbk, NULL,
+ client3_3_reopendir_cbk, NULL,
NULL, 0, NULL, 0, NULL,
(xdrproc_t)xdr_gfs3_opendir_req);
if (ret) {
- gf_log (THIS->name, GF_LOG_ERROR,
+ gf_log (this->name, GF_LOG_ERROR,
"failed to send the re-opendir request");
}
- return ret;
+ return 0;
out:
if (frame) {
@@ -1154,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;
@@ -1202,27 +1175,30 @@ protocol_client_reopen (xlator_t *this, clnt_fd_ctx_t *fdctx)
}
local->fdctx = fdctx;
- local->loc.path = path;
- path = NULL;
+ uuid_copy (local->loc.gfid, fdctx->gfid);
+ ret = loc_path (&local->loc, NULL);
+ if (ret < 0)
+ goto out;
+
frame->local = local;
- memcpy (req.gfid, inode->gfid, 16);
+ memcpy (req.gfid, fdctx->gfid, 16);
req.flags = gf_flags_from_flags (fdctx->flags);
+ req.flags = req.flags & (~(O_TRUNC|O_CREAT|O_EXCL));
gf_log (frame->this->name, GF_LOG_DEBUG,
"attempting reopen on %s", local->loc.path);
- local = NULL;
ret = client_submit_request (this, &req, frame, conf->fops,
- GFS3_OP_OPEN, client3_1_reopen_cbk, NULL,
+ GFS3_OP_OPEN, client3_3_reopen_cbk, NULL,
NULL, 0, NULL, 0, NULL,
(xdrproc_t)xdr_gfs3_open_req);
if (ret) {
- gf_log (THIS->name, GF_LOG_ERROR,
+ gf_log (this->name, GF_LOG_ERROR,
"failed to send the re-open request");
}
- return ret;
+ return 0;
out:
if (frame) {
@@ -1233,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)
@@ -1268,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++;
@@ -1286,10 +1311,7 @@ client_post_handshake (call_frame_t *frame, xlator_t *this)
list_for_each_entry_safe (fdctx, tmp, &reopen_head, sfd_pos) {
list_del_init (&fdctx->sfd_pos);
- if (fdctx->is_dir)
- protocol_client_reopendir (this, fdctx);
- else
- protocol_client_reopen (this, fdctx);
+ protocol_client_reopen (fdctx, this);
}
} else {
gf_log (this->name, GF_LOG_DEBUG,
@@ -1482,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);
@@ -1578,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);
@@ -1604,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;
}
@@ -1628,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")",
@@ -1715,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)
@@ -1734,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 3ee3bba53..5d9f00fdc 100644
--- a/xlators/protocol/client/src/client-helpers.c
+++ b/xlators/protocol/client/src/client-helpers.c
@@ -1,20 +1,11 @@
/*
- Copyright (c) 2010-2011 Gluster, Inc. <http://www.gluster.com>
+ Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com>
This file is part of GlusterFS.
- GlusterFS is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3 of the License,
- or (at your option) any later version.
-
- GlusterFS is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see
- <http://www.gnu.org/licenses/>.
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
*/
#ifndef _CONFIG_H
@@ -25,7 +16,6 @@
#include "client.h"
#include "fd.h"
-
int
client_fd_lk_list_empty (fd_lk_ctx_t *lk_ctx, gf_boolean_t try_lock)
{
@@ -132,6 +122,7 @@ client_local_wipe (clnt_local_t *local)
{
if (local) {
loc_wipe (&local->loc);
+ loc_wipe (&local->loc2);
if (local->fd) {
fd_unref (local->fd);
@@ -141,6 +132,8 @@ client_local_wipe (clnt_local_t *local)
iobref_unref (local->iobref);
}
+ GF_FREE (local->name);
+
mem_put (local);
}
@@ -282,3 +275,75 @@ clnt_readdir_rsp_cleanup (gfs3_readdir_rsp *rsp)
return 0;
}
+
+int
+client_get_remote_fd (xlator_t *this, fd_t *fd, int flags, int64_t *remote_fd)
+{
+ clnt_fd_ctx_t *fdctx = NULL;
+ clnt_conf_t *conf = NULL;
+
+ GF_VALIDATE_OR_GOTO (this->name, fd, out);
+ GF_VALIDATE_OR_GOTO (this->name, remote_fd, out);
+
+ conf = this->private;
+ pthread_mutex_lock (&conf->lock);
+ {
+ fdctx = this_fd_get_ctx (fd, this);
+ if (!fdctx)
+ *remote_fd = GF_ANON_FD_NO;
+ else if (__is_fd_reopen_in_progress (fdctx))
+ *remote_fd = -1;
+ else
+ *remote_fd = fdctx->remote_fd;
+ }
+ pthread_mutex_unlock (&conf->lock);
+
+ if ((flags & FALLBACK_TO_ANON_FD) && (*remote_fd == -1))
+ *remote_fd = GF_ANON_FD_NO;
+
+ return 0;
+out:
+ return -1;
+}
+
+gf_boolean_t
+client_is_reopen_needed (fd_t *fd, xlator_t *this, int64_t remote_fd)
+{
+ clnt_fd_ctx_t *fdctx = NULL;
+
+ fdctx = this_fd_get_ctx (fd, this);
+ if (fdctx && (fdctx->remote_fd == -1) &&
+ (remote_fd == GF_ANON_FD_NO))
+ return _gf_true;
+ return _gf_false;
+}
+
+int
+client_fd_fop_prepare_local (call_frame_t *frame, fd_t *fd, int64_t remote_fd)
+{
+ xlator_t *this = NULL;
+ clnt_conf_t *conf = NULL;
+ clnt_local_t *local = NULL;
+ int ret = 0;
+
+ this = frame->this;
+ conf = this->private;
+
+ if (!frame || !fd) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ frame->local = mem_get0 (this->local_pool);
+ if (frame->local == NULL) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ local = frame->local;
+ local->fd = fd_ref (fd);
+ local->attempt_reopen = client_is_reopen_needed (fd, this, remote_fd);
+ return 0;
+out:
+ return ret;
+}
diff --git a/xlators/protocol/client/src/client-lk.c b/xlators/protocol/client/src/client-lk.c
index 76f78b846..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, dict_t *xdata)
-{
- 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, NULL);
-}
-
-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, dict_t *xdata)
-{
-
- 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, dict_t *xdata)
-{
- 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, NULL);
- 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), NULL);
-
- 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, NULL);
-
-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 13b577a57..6355450c3 100644
--- a/xlators/protocol/client/src/client3_1-fops.c
+++ b/xlators/protocol/client/src/client-rpc-fops.c
@@ -1,20 +1,11 @@
/*
- Copyright (c) 2010-2011 Gluster, Inc. <http://www.gluster.com>
+ Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com>
This file is part of GlusterFS.
- GlusterFS is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3 of the License,
- or (at your option) any later version.
-
- GlusterFS is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see
- <http://www.gnu.org/licenses/>.
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
*/
#ifndef _CONFIG_H
@@ -29,7 +20,7 @@
int32_t client3_getspec (call_frame_t *frame, xlator_t *this, void *data);
void client_start_ping (void *data);
-rpc_clnt_prog_t clnt3_1_fop_prog;
+rpc_clnt_prog_t clnt3_3_fop_prog;
int
@@ -141,7 +132,7 @@ unwind:
/* CBK */
int
-client3_1_symlink_cbk (struct rpc_req *req, struct iovec *iov, int count,
+client3_3_symlink_cbk (struct rpc_req *req, struct iovec *iov, int count,
void *myframe)
{
call_frame_t *frame = NULL;
@@ -188,20 +179,20 @@ client3_1_symlink_cbk (struct rpc_req *req, struct iovec *iov, int count,
out:
if (rsp.op_ret == -1) {
+ /* no need to print the gfid, because it will be null, since
+ * symlink operation failed.
+ */
gf_log (this->name, GF_LOG_WARNING,
- "remote operation failed: %s. Path: %s (%s)",
+ "remote operation failed: %s. Path: (%s to %s)",
strerror (gf_error_to_errno (rsp.op_errno)),
- (local) ? local->loc.path : "--",
- (local && local->loc.inode) ?
- uuid_utoa (local->loc.inode->gfid) : "--");
+ local->loc.path, local->loc2.path);
}
CLIENT_STACK_UNWIND (symlink, frame, rsp.op_ret,
gf_error_to_errno (rsp.op_errno), inode, &stbuf,
&preparent, &postparent, xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -211,7 +202,7 @@ out:
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;
@@ -260,19 +251,16 @@ client3_1_mknod_cbk (struct rpc_req *req, struct iovec *iov, int count,
out:
if (rsp.op_ret == -1) {
gf_log (this->name, GF_LOG_WARNING,
- "remote operation failed: %s. Path: %s (%s)",
+ "remote operation failed: %s. Path: %s",
strerror (gf_error_to_errno (rsp.op_errno)),
- (local) ? local->loc.path : "--",
- (local && local->loc.inode) ?
- uuid_utoa (local->loc.inode->gfid) : "--");
+ local->loc.path);
}
CLIENT_STACK_UNWIND (mknod, frame, rsp.op_ret,
gf_error_to_errno (rsp.op_errno), inode,
&stbuf, &preparent, &postparent, xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -281,7 +269,7 @@ out:
}
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;
@@ -329,19 +317,16 @@ client3_1_mkdir_cbk (struct rpc_req *req, struct iovec *iov, int count,
out:
if (rsp.op_ret == -1) {
gf_log (this->name, GF_LOG_WARNING,
- "remote operation failed: %s. Path: %s (%s)",
+ "remote operation failed: %s. Path: %s",
strerror (gf_error_to_errno (rsp.op_errno)),
- (local) ? local->loc.path : "--",
- (local && local->loc.inode) ?
- uuid_utoa (local->loc.inode->gfid) : "--");
+ local->loc.path);
}
CLIENT_STACK_UNWIND (mkdir, frame, rsp.op_ret,
gf_error_to_errno (rsp.op_errno), inode,
&stbuf, &preparent, &postparent, xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -350,12 +335,84 @@ out:
}
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;
@@ -386,31 +443,13 @@ client3_1_open_cbk (struct rpc_req *req, struct iovec *iov, int count,
}
if (-1 != rsp.op_ret) {
- fdctx = GF_CALLOC (1, sizeof (*fdctx),
- gf_client_mt_clnt_fdctx_t);
- if (!fdctx) {
+ ret = client_add_fd_to_saved_fds (frame->this, fd, &local->loc,
+ local->flags, rsp.fd, 0);
+ if (ret) {
rsp.op_ret = -1;
- rsp.op_errno = ENOMEM;
+ rsp.op_errno = -ret;
goto out;
}
-
- fdctx->remote_fd = rsp.fd;
- fdctx->inode = inode_ref (fd->inode);
- fdctx->flags = local->flags;
- fdctx->wbflags = local->wbflags;
- fdctx->lk_ctx = fd_lk_ctx_ref (fd->lk_ctx);
- fdctx->lk_heal_state = GF_LK_HEAL_DONE;
-
- INIT_LIST_HEAD (&fdctx->sfd_pos);
- INIT_LIST_HEAD (&fdctx->lock_list);
-
- this_fd_set_ctx (fd, frame->this, &local->loc, fdctx);
-
- pthread_mutex_lock (&conf->lock);
- {
- list_add_tail (&fdctx->sfd_pos, &conf->saved_fds);
- }
- pthread_mutex_unlock (&conf->lock);
}
GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
@@ -422,16 +461,13 @@ out:
gf_log (this->name, GF_LOG_WARNING,
"remote operation failed: %s. Path: %s (%s)",
strerror (gf_error_to_errno (rsp.op_errno)),
- (local) ? local->loc.path : "--",
- (local && local->loc.inode) ?
- uuid_utoa (local->loc.inode->gfid) : "--");
+ local->loc.path, loc_gfid_utoa (&local->loc));
}
CLIENT_STACK_UNWIND (open, frame, rsp.op_ret,
gf_error_to_errno (rsp.op_errno), fd, xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -441,7 +477,7 @@ out:
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,};
@@ -486,8 +522,7 @@ out:
CLIENT_STACK_UNWIND (stat, frame, rsp.op_ret,
gf_error_to_errno (rsp.op_errno), &iatt, xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -496,7 +531,7 @@ out:
}
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,};
@@ -534,8 +569,9 @@ client3_1_readlink_cbk (struct rpc_req *req, struct iovec *iov, int count,
out:
if (rsp.op_ret == -1) {
- gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s",
- strerror (gf_error_to_errno (rsp.op_errno)));
+ gf_log (this->name, (gf_error_to_errno(rsp.op_errno) == ENOENT)?
+ GF_LOG_DEBUG:GF_LOG_WARNING, "remote operation failed:"
+ " %s", strerror (gf_error_to_errno (rsp.op_errno)));
}
CLIENT_STACK_UNWIND (readlink, frame, rsp.op_ret,
@@ -544,11 +580,9 @@ out:
/* 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);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -557,7 +591,7 @@ out:
}
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;
@@ -597,15 +631,18 @@ client3_1_unlink_cbk (struct rpc_req *req, struct iovec *iov, int count,
out:
if (rsp.op_ret == -1) {
- gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s",
+ gf_log (this->name,
+ ((gf_error_to_errno (rsp.op_errno) == ENOENT)
+ ? GF_LOG_DEBUG : GF_LOG_WARNING),
+ "remote operation failed: %s",
strerror (gf_error_to_errno (rsp.op_errno)));
}
+
CLIENT_STACK_UNWIND (unlink, frame, rsp.op_ret,
gf_error_to_errno (rsp.op_errno), &preparent,
&postparent, xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -614,7 +651,7 @@ out:
}
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,};
@@ -661,8 +698,7 @@ out:
gf_error_to_errno (rsp.op_errno), &preparent,
&postparent, xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -672,7 +708,7 @@ out:
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,};
@@ -719,8 +755,7 @@ out:
gf_error_to_errno (rsp.op_errno), &prestat,
&poststat, xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -730,7 +765,7 @@ out:
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,};
@@ -774,8 +809,7 @@ out:
CLIENT_STACK_UNWIND (statfs, frame, rsp.op_ret,
gf_error_to_errno (rsp.op_errno), &statfs, xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -785,7 +819,7 @@ out:
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,};
@@ -795,11 +829,13 @@ client3_1_writev_cbk (struct rpc_req *req, struct iovec *iov, int count,
int ret = 0;
xlator_t *this = NULL;
dict_t *xdata = NULL;
+ clnt_local_t *local = NULL;
this = THIS;
frame = myframe;
+ local = frame->local;
if (-1 == req->rpc_status) {
rsp.op_ret = -1;
@@ -828,13 +864,15 @@ out:
if (rsp.op_ret == -1) {
gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s",
strerror (gf_error_to_errno (rsp.op_errno)));
+ } else if (rsp.op_ret >= 0) {
+ if (local->attempt_reopen)
+ client_attempt_reopen (local->fd, this);
}
CLIENT_STACK_UNWIND (writev, frame, rsp.op_ret,
gf_error_to_errno (rsp.op_errno), &prestat,
&poststat, xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -843,7 +881,7 @@ out:
}
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;
@@ -892,8 +930,7 @@ out:
CLIENT_STACK_UNWIND (flush, frame, rsp.op_ret,
gf_error_to_errno (rsp.op_errno), xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -902,7 +939,7 @@ out:
}
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,};
@@ -950,8 +987,7 @@ out:
gf_error_to_errno (rsp.op_errno), &prestat,
&poststat, xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -960,7 +996,7 @@ out:
}
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;
@@ -1002,8 +1038,7 @@ out:
}
CLIENT_STACK_UNWIND (setxattr, frame, rsp.op_ret, op_errno, xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -1012,7 +1047,7 @@ out:
}
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;
@@ -1058,23 +1093,22 @@ client3_1_getxattr_cbk (struct rpc_req *req, struct iovec *iov, int count,
out:
if (rsp.op_ret == -1) {
- gf_log (this->name, ((op_errno == ENOTSUP) ?
+ 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)",
+ "remote operation failed: %s. Path: %s (%s). Key: %s",
strerror (op_errno),
- (local) ? local->loc.path : "--",
- (local && local->loc.inode) ?
- uuid_utoa (local->loc.inode->gfid) : "--");
+ local->loc.path, loc_gfid_utoa (&local->loc),
+ (local->name) ? local->name : "(null)");
}
CLIENT_STACK_UNWIND (getxattr, frame, rsp.op_ret, op_errno, dict, xdata);
/* don't use GF_FREE, this memory was allocated by libc */
- if (rsp.dict.dict_val)
- free (rsp.dict.dict_val);
+ free (rsp.dict.dict_val);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -1086,7 +1120,7 @@ out:
}
int
-client3_1_fgetxattr_cbk (struct rpc_req *req, struct iovec *iov, int count,
+client3_3_fgetxattr_cbk (struct rpc_req *req, struct iovec *iov, int count,
void *myframe)
{
call_frame_t *frame = NULL;
@@ -1138,11 +1172,9 @@ out:
CLIENT_STACK_UNWIND (fgetxattr, frame, rsp.op_ret, op_errno, dict, xdata);
- if (rsp.dict.dict_val)
- free (rsp.dict.dict_val);
+ free (rsp.dict.dict_val);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -1154,7 +1186,7 @@ out:
}
int
-client3_1_removexattr_cbk (struct rpc_req *req, struct iovec *iov, int count,
+client3_3_removexattr_cbk (struct rpc_req *req, struct iovec *iov, int count,
void *myframe)
{
call_frame_t *frame = NULL;
@@ -1194,8 +1226,7 @@ out:
CLIENT_STACK_UNWIND (removexattr, frame, rsp.op_ret,
gf_error_to_errno (rsp.op_errno), xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -1204,7 +1235,7 @@ out:
}
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;
@@ -1244,8 +1275,7 @@ out:
CLIENT_STACK_UNWIND (fremovexattr, frame, rsp.op_ret,
gf_error_to_errno (rsp.op_errno), xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -1254,7 +1284,7 @@ out:
}
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;
@@ -1293,8 +1323,7 @@ out:
CLIENT_STACK_UNWIND (fsyncdir, frame, rsp.op_ret,
gf_error_to_errno (rsp.op_errno), xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -1303,7 +1332,7 @@ out:
}
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;
@@ -1342,8 +1371,7 @@ out:
CLIENT_STACK_UNWIND (access, frame, rsp.op_ret,
gf_error_to_errno (rsp.op_errno), xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -1353,7 +1381,7 @@ out:
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,};
@@ -1400,8 +1428,7 @@ out:
gf_error_to_errno (rsp.op_errno), &prestat,
&poststat, xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -1410,7 +1437,7 @@ out:
}
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,};
@@ -1454,8 +1481,7 @@ out:
CLIENT_STACK_UNWIND (fstat, frame, rsp.op_ret,
gf_error_to_errno (rsp.op_errno), &stat, xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -1465,7 +1491,7 @@ out:
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;
@@ -1505,8 +1531,7 @@ out:
CLIENT_STACK_UNWIND (inodelk, frame, rsp.op_ret,
gf_error_to_errno (rsp.op_errno), xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -1515,19 +1540,20 @@ out:
}
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;
- dict_t *xdata = 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;
@@ -1551,12 +1577,14 @@ out:
(EAGAIN != gf_error_to_errno (rsp.op_errno))) {
gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s",
strerror (gf_error_to_errno (rsp.op_errno)));
+ } else if (rsp.op_ret == 0) {
+ if (local->attempt_reopen)
+ client_attempt_reopen (local->fd, this);
}
CLIENT_STACK_UNWIND (finodelk, frame, rsp.op_ret,
gf_error_to_errno (rsp.op_errno), xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -1565,7 +1593,7 @@ out:
}
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;
@@ -1606,8 +1634,7 @@ out:
CLIENT_STACK_UNWIND (entrylk, frame, rsp.op_ret,
gf_error_to_errno (rsp.op_errno), xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -1616,7 +1643,7 @@ out:
}
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;
@@ -1657,8 +1684,7 @@ out:
CLIENT_STACK_UNWIND (fentrylk, frame, rsp.op_ret,
gf_error_to_errno (rsp.op_errno), xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -1667,7 +1693,7 @@ out:
}
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;
@@ -1715,19 +1741,15 @@ out:
gf_log (this->name, GF_LOG_WARNING,
"remote operation failed: %s. Path: %s (%s)",
strerror (gf_error_to_errno (rsp.op_errno)),
- (local) ? local->loc.path : "--",
- (local && local->loc.inode) ?
- uuid_utoa (local->loc.inode->gfid) : "--");
+ local->loc.path, loc_gfid_utoa (&local->loc));
}
CLIENT_STACK_UNWIND (xattrop, frame, rsp.op_ret,
gf_error_to_errno (op_errno), dict, xdata);
- if (rsp.dict.dict_val)
- free (rsp.dict.dict_val);
+ free (rsp.dict.dict_val);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -1739,7 +1761,7 @@ out:
}
int
-client3_1_fxattrop_cbk (struct rpc_req *req, struct iovec *iov, int count,
+client3_3_fxattrop_cbk (struct rpc_req *req, struct iovec *iov, int count,
void *myframe)
{
call_frame_t *frame = NULL;
@@ -1787,15 +1809,16 @@ out:
gf_log (this->name, GF_LOG_WARNING,
"remote operation failed: %s",
strerror (gf_error_to_errno (op_errno)));
+ } else if (rsp.op_ret == 0) {
+ if (local->attempt_reopen)
+ client_attempt_reopen (local->fd, this);
}
CLIENT_STACK_UNWIND (fxattrop, frame, rsp.op_ret,
gf_error_to_errno (op_errno), dict, xdata);
- if (rsp.dict.dict_val)
- free (rsp.dict.dict_val);
+ free (rsp.dict.dict_val);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -1807,7 +1830,7 @@ out:
}
int
-client3_1_fsetxattr_cbk (struct rpc_req *req, struct iovec *iov, int count,
+client3_3_fsetxattr_cbk (struct rpc_req *req, struct iovec *iov, int count,
void *myframe)
{
call_frame_t *frame = NULL;
@@ -1849,8 +1872,7 @@ out:
CLIENT_STACK_UNWIND (fsetxattr, frame, rsp.op_ret, op_errno, xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -1859,7 +1881,7 @@ out:
}
int
-client3_1_fsetattr_cbk (struct rpc_req *req, struct iovec *iov, int count,
+client3_3_fsetattr_cbk (struct rpc_req *req, struct iovec *iov, int count,
void *myframe)
{
call_frame_t *frame = NULL;
@@ -1906,8 +1928,118 @@ out:
gf_error_to_errno (rsp.op_errno), &prestat,
&poststat, xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
+
+ if (xdata)
+ dict_unref (xdata);
+
+ return 0;
+}
+
+int
+client3_3_fallocate_cbk (struct rpc_req *req, struct iovec *iov, int count,
+ void *myframe)
+{
+ call_frame_t *frame = NULL;
+ gfs3_fallocate_rsp rsp = {0,};
+ struct iatt prestat = {0,};
+ struct iatt poststat = {0,};
+ int ret = 0;
+ xlator_t *this = NULL;
+ dict_t *xdata = NULL;
+
+
+ this = THIS;
+
+ frame = myframe;
+
+ if (-1 == req->rpc_status) {
+ rsp.op_ret = -1;
+ rsp.op_errno = ENOTCONN;
+ goto out;
+ }
+ ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_fallocate_rsp);
+ if (ret < 0) {
+ gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed");
+ rsp.op_ret = -1;
+ rsp.op_errno = EINVAL;
+ goto out;
+ }
+
+ if (-1 != rsp.op_ret) {
+ gf_stat_to_iatt (&rsp.statpre, &prestat);
+ gf_stat_to_iatt (&rsp.statpost, &poststat);
+ }
+
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
+ (rsp.xdata.xdata_len), ret,
+ rsp.op_errno, out);
+
+out:
+ if (rsp.op_ret == -1) {
+ gf_log (this->name, GF_LOG_WARNING, "remote operation failed: %s",
+ strerror (gf_error_to_errno (rsp.op_errno)));
+ }
+ CLIENT_STACK_UNWIND (fallocate, frame, rsp.op_ret,
+ gf_error_to_errno (rsp.op_errno), &prestat,
+ &poststat, xdata);
+
+ free (rsp.xdata.xdata_val);
+
+ if (xdata)
+ dict_unref (xdata);
+
+ return 0;
+}
+
+int
+client3_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);
@@ -1915,9 +2047,64 @@ out:
return 0;
}
+int
+client3_3_zerofill_cbk(struct rpc_req *req, struct iovec *iov, int count,
+ void *myframe)
+{
+ call_frame_t *frame = NULL;
+ gfs3_zerofill_rsp rsp = {0,};
+ struct iatt prestat = {0,};
+ struct iatt poststat = {0,};
+ int ret = 0;
+ xlator_t *this = NULL;
+ dict_t *xdata = NULL;
+
+ this = THIS;
+
+ frame = myframe;
+
+ if (-1 == req->rpc_status) {
+ rsp.op_ret = -1;
+ rsp.op_errno = ENOTCONN;
+ goto out;
+ }
+ ret = xdr_to_generic(*iov, &rsp, (xdrproc_t) xdr_gfs3_zerofill_rsp);
+ if (ret < 0) {
+ gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed");
+ rsp.op_ret = -1;
+ rsp.op_errno = EINVAL;
+ goto out;
+ }
+
+ if (-1 != rsp.op_ret) {
+ gf_stat_to_iatt (&rsp.statpre, &prestat);
+ gf_stat_to_iatt (&rsp.statpost, &poststat);
+ }
+
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
+ (rsp.xdata.xdata_len), ret,
+ rsp.op_errno, out);
+
+out:
+ if (rsp.op_ret == -1) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "remote operation failed: %s",
+ strerror (gf_error_to_errno (rsp.op_errno)));
+ }
+ CLIENT_STACK_UNWIND (zerofill, frame, rsp.op_ret,
+ gf_error_to_errno (rsp.op_errno), &prestat,
+ &poststat, xdata);
+
+ free (rsp.xdata.xdata_val);
+
+ if (xdata)
+ dict_unref (xdata);
+
+ return 0;
+}
int
-client3_1_setattr_cbk (struct rpc_req *req, struct iovec *iov, int count,
+client3_3_setattr_cbk (struct rpc_req *req, struct iovec *iov, int count,
void *myframe)
{
call_frame_t *frame = NULL;
@@ -1965,8 +2152,7 @@ out:
gf_error_to_errno (rsp.op_errno), &prestat,
&poststat, xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -1975,7 +2161,7 @@ out:
}
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;
@@ -1986,8 +2172,6 @@ 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;
dict_t *xdata = NULL;
@@ -1996,7 +2180,6 @@ client3_1_create_cbk (struct rpc_req *req, struct iovec *iov, int count,
frame = myframe;
local = frame->local;
- conf = frame->this->private;
fd = local->fd;
inode = local->loc.inode;
@@ -2019,31 +2202,14 @@ client3_1_create_cbk (struct rpc_req *req, struct iovec *iov, int count,
gf_stat_to_iatt (&rsp.preparent, &preparent);
gf_stat_to_iatt (&rsp.postparent, &postparent);
-
- fdctx = GF_CALLOC (1, sizeof (*fdctx),
- gf_client_mt_clnt_fdctx_t);
- if (!fdctx) {
+ uuid_copy (local->loc.gfid, stbuf.ia_gfid);
+ ret = client_add_fd_to_saved_fds (frame->this, fd, &local->loc,
+ local->flags, rsp.fd, 0);
+ if (ret) {
rsp.op_ret = -1;
- rsp.op_errno = ENOMEM;
+ rsp.op_errno = -ret;
goto out;
}
-
- fdctx->remote_fd = rsp.fd;
- fdctx->inode = inode_ref (inode);
- fdctx->flags = local->flags;
- fdctx->lk_ctx = fd_lk_ctx_ref (fd->lk_ctx);
- fdctx->lk_heal_state = GF_LK_HEAL_DONE;
-
- INIT_LIST_HEAD (&fdctx->sfd_pos);
- INIT_LIST_HEAD (&fdctx->lock_list);
-
- this_fd_set_ctx (fd, frame->this, &local->loc, fdctx);
-
- pthread_mutex_lock (&conf->lock);
- {
- list_add_tail (&fdctx->sfd_pos, &conf->saved_fds);
- }
- pthread_mutex_unlock (&conf->lock);
}
GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
@@ -2053,19 +2219,16 @@ client3_1_create_cbk (struct rpc_req *req, struct iovec *iov, int count,
out:
if (rsp.op_ret == -1) {
gf_log (this->name, GF_LOG_WARNING,
- "remote operation failed: %s. Path: %s (%s)",
+ "remote operation failed: %s. Path: %s",
strerror (gf_error_to_errno (rsp.op_errno)),
- (local) ? local->loc.path : "--",
- (local && local->loc.inode) ?
- uuid_utoa (local->loc.inode->gfid) : "--");
+ local->loc.path);
}
CLIENT_STACK_UNWIND (create, frame, rsp.op_ret,
gf_error_to_errno (rsp.op_errno), fd, inode,
&stbuf, &preparent, &postparent, xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -2075,7 +2238,7 @@ out:
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;
@@ -2124,8 +2287,7 @@ out:
free (rsp.strong_checksum.strong_checksum_val);
}
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -2134,7 +2296,7 @@ out:
}
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;
@@ -2197,11 +2359,9 @@ out:
CLIENT_STACK_UNWIND (lk, frame, rsp.op_ret,
gf_error_to_errno (rsp.op_errno), &lock, xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
- if (rsp.flock.lk_owner.lk_owner_val)
- free (rsp.flock.lk_owner.lk_owner_val);
+ free (rsp.flock.lk_owner.lk_owner_val);
if (xdata)
dict_unref (xdata);
@@ -2210,7 +2370,7 @@ out:
}
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;
@@ -2264,8 +2424,7 @@ out:
gf_dirent_free (&entries);
}
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -2277,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;
@@ -2328,8 +2487,7 @@ out:
if (rsp.op_ret != -1) {
gf_dirent_free (&entries);
}
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -2341,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;
@@ -2397,8 +2555,7 @@ out:
&stbuf, &preoldparent, &postoldparent,
&prenewparent, &postnewparent, xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -2407,7 +2564,7 @@ out:
}
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;
@@ -2459,18 +2616,14 @@ out:
gf_log (this->name, GF_LOG_WARNING,
"remote operation failed: %s (%s -> %s)",
strerror (gf_error_to_errno (rsp.op_errno)),
- (local) ? ((local->loc.path)? local->loc.path :
- uuid_utoa (local->loc.inode->gfid)) : "--",
- (local) ? ((local->loc2.path)? local->loc2.path :
- local->loc2.name) : "--");
+ local->loc.path, local->loc2.path);
}
CLIENT_STACK_UNWIND (link, frame, rsp.op_ret,
gf_error_to_errno (rsp.op_errno), inode,
&stbuf, &preparent, &postparent, xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -2480,14 +2633,13 @@ out:
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;
@@ -2516,28 +2668,13 @@ 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),
@@ -2549,15 +2686,12 @@ out:
gf_log (this->name, GF_LOG_WARNING,
"remote operation failed: %s. Path: %s (%s)",
strerror (gf_error_to_errno (rsp.op_errno)),
- (local) ? local->loc.path : "--",
- (local && local->loc.inode) ?
- uuid_utoa (local->loc.inode->gfid) : "--");
+ local->loc.path, loc_gfid_utoa (&local->loc));
}
CLIENT_STACK_UNWIND (opendir, frame, rsp.op_ret,
gf_error_to_errno (rsp.op_errno), fd, xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -2567,7 +2701,7 @@ out:
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;
@@ -2632,10 +2766,8 @@ out:
if (rsp.op_errno != ENOENT)
gf_log (this->name, GF_LOG_WARNING,
"remote operation failed: %s. Path: %s (%s)",
- strerror (rsp.op_errno),
- (local) ? local->loc.path : "--",
- (local && local->loc.inode) ?
- uuid_utoa (local->loc.inode->gfid) : "--");
+ 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");
@@ -2647,14 +2779,13 @@ out:
if (xdata)
dict_unref (xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_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;
@@ -2701,18 +2832,24 @@ client3_1_readv_cbk (struct rpc_req *req, struct iovec *iov, int count,
(rsp.xdata.xdata_len), ret,
rsp.op_errno, out);
+#ifdef GF_TESTING_IO_XDATA
+ dict_dump (xdata);
+#endif
+
out:
if (rsp.op_ret == -1) {
gf_log (this->name, GF_LOG_WARNING,
"remote operation failed: %s",
strerror (gf_error_to_errno (rsp.op_errno)));
+ } else if (rsp.op_ret >= 0) {
+ if (local->attempt_reopen)
+ client_attempt_reopen (local->fd, this);
}
CLIENT_STACK_UNWIND (readv, frame, rsp.op_ret,
gf_error_to_errno (rsp.op_errno), vector, rspcount,
&stat, iobref, xdata);
- if (rsp.xdata.xdata_val)
- free (rsp.xdata.xdata_val);
+ free (rsp.xdata.xdata_val);
if (xdata)
dict_unref (xdata);
@@ -2721,7 +2858,7 @@ out:
}
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;
@@ -2731,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;
@@ -2786,19 +2923,19 @@ client_fdctx_destroy (xlator_t *this, clnt_fd_ctx_t *fdctx)
if (fdctx->is_dir) {
gfs3_releasedir_req req = {{0,},};
req.fd = fdctx->remote_fd;
- gf_log (this->name, GF_LOG_DEBUG, "sending releasedir on fd");
- client_submit_request (this, &req, fr, &clnt3_1_fop_prog,
+ gf_log (this->name, GF_LOG_TRACE, "sending releasedir on fd");
+ client_submit_request (this, &req, fr, &clnt3_3_fop_prog,
GFS3_OP_RELEASEDIR,
- client3_1_releasedir_cbk,
+ client3_3_releasedir_cbk,
NULL, NULL, 0, NULL, 0, NULL,
(xdrproc_t)xdr_gfs3_releasedir_req);
} else {
gfs3_release_req req = {{0,},};
req.fd = fdctx->remote_fd;
- gf_log (this->name, GF_LOG_DEBUG, "sending release on fd");
- client_submit_request (this, &req, fr, &clnt3_1_fop_prog,
+ gf_log (this->name, GF_LOG_TRACE, "sending release on fd");
+ client_submit_request (this, &req, fr, &clnt3_3_fop_prog,
GFS3_OP_RELEASE,
- client3_1_release_cbk, NULL,
+ client3_3_release_cbk, NULL,
NULL, 0, NULL, 0, NULL,
(xdrproc_t)xdr_gfs3_release_req);
}
@@ -2807,7 +2944,6 @@ client_fdctx_destroy (xlator_t *this, clnt_fd_ctx_t *fdctx)
out:
if (fdctx) {
fdctx->remote_fd = -1;
- inode_unref (fdctx->inode);
GF_FREE (fdctx);
}
@@ -2818,7 +2954,7 @@ out:
}
int32_t
-client3_1_releasedir (call_frame_t *frame, xlator_t *this,
+client3_3_releasedir (call_frame_t *frame, xlator_t *this,
void *data)
{
clnt_conf_t *conf = NULL;
@@ -2859,7 +2995,7 @@ out:
}
int32_t
-client3_1_release (call_frame_t *frame, xlator_t *this,
+client3_3_release (call_frame_t *frame, xlator_t *this,
void *data)
{
int64_t remote_fd = -1;
@@ -2903,7 +3039,7 @@ out:
int32_t
-client3_1_lookup (call_frame_t *frame, xlator_t *this,
+client3_3_lookup (call_frame_t *frame, xlator_t *this,
void *data)
{
clnt_conf_t *conf = NULL;
@@ -2936,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) {
@@ -2989,7 +3126,7 @@ client3_1_lookup (call_frame_t *frame, xlator_t *this,
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);
@@ -2998,8 +3135,7 @@ client3_1_lookup (call_frame_t *frame, xlator_t *this,
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
if (rsp_iobref)
iobref_unref (rsp_iobref);
@@ -3013,8 +3149,7 @@ unwind:
CLIENT_STACK_UNWIND (lookup, frame, -1, op_errno, NULL, NULL, NULL,
NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
if (rsp_iobref)
iobref_unref (rsp_iobref);
@@ -3026,7 +3161,7 @@ unwind:
}
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;
@@ -3056,29 +3191,27 @@ client3_1_stat (call_frame_t *frame, xlator_t *this,
req.xdata.xdata_len, op_errno, unwind);
ret = client_submit_request (this, &req, frame, conf->fops,
- GFS3_OP_STAT, client3_1_stat_cbk, NULL,
+ GFS3_OP_STAT, client3_3_stat_cbk, NULL,
NULL, 0, NULL, 0, NULL,
(xdrproc_t)xdr_gfs3_stat_req);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (stat, frame, -1, op_errno, NULL, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ 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;
@@ -3112,28 +3245,26 @@ client3_1_truncate (call_frame_t *frame, xlator_t *this,
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_TRUNCATE,
- client3_1_truncate_cbk, NULL,
+ client3_3_truncate_cbk, NULL,
NULL, 0, NULL, 0,
NULL, (xdrproc_t)xdr_gfs3_truncate_req);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (truncate, frame, -1, op_errno, NULL, NULL, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ 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;
@@ -3150,7 +3281,8 @@ 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;
@@ -3161,21 +3293,19 @@ client3_1_ftruncate (call_frame_t *frame, xlator_t *this,
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_FTRUNCATE,
- client3_1_ftruncate_cbk, NULL,
+ client3_3_ftruncate_cbk, NULL,
NULL, 0, NULL, 0,
NULL, (xdrproc_t)xdr_gfs3_ftruncate_req);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (ftruncate, frame, -1, op_errno, NULL, NULL, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
}
@@ -3183,7 +3313,7 @@ unwind:
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;
@@ -3217,34 +3347,38 @@ client3_1_access (call_frame_t *frame, xlator_t *this,
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_ACCESS,
- client3_1_access_cbk, NULL,
+ client3_3_access_cbk, NULL,
NULL, 0, NULL, 0,
NULL, (xdrproc_t)xdr_gfs3_access_req);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (access, frame, -1, op_errno, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ 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;
@@ -3265,26 +3399,57 @@ client3_1_readlink (call_frame_t *frame, xlator_t *this,
req.size = args->size;
conf = this->private;
+ local = mem_get0 (this->local_pool);
+ if (!local) {
+ op_errno = ENOMEM;
+ goto unwind;
+ }
+
+ frame->local = local;
+
GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
req.xdata.xdata_len, op_errno, unwind);
+ rsp_iobref = iobref_new ();
+ if (rsp_iobref == NULL) {
+ goto unwind;
+ }
+
+ rsp_iobuf = iobuf_get (this->ctx->iobuf_pool);
+ if (rsp_iobuf == NULL) {
+ goto unwind;
+ }
+
+ iobref_add (rsp_iobref, rsp_iobuf);
+ iobuf_unref (rsp_iobuf);
+ rsphdr = &vector[0];
+ rsphdr->iov_base = iobuf_ptr (rsp_iobuf);
+ rsphdr->iov_len = iobuf_pagesize (rsp_iobuf);
+ count = 1;
+ local->iobref = rsp_iobref;
+ rsp_iobuf = NULL;
+ rsp_iobref = NULL;
+
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_READLINK,
- client3_1_readlink_cbk, NULL,
- NULL, 0, NULL, 0,
- NULL, (xdrproc_t)xdr_gfs3_readlink_req);
+ client3_3_readlink_cbk, NULL,
+ rsphdr, count, NULL, 0,
+ local->iobref,
+ (xdrproc_t)xdr_gfs3_readlink_req);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
+ if (rsp_iobref != NULL) {
+ iobref_unref (rsp_iobref);
+ }
+
CLIENT_STACK_UNWIND (readlink, frame, -1, op_errno, NULL, NULL, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
}
@@ -3293,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;
@@ -3326,21 +3491,19 @@ client3_1_unlink (call_frame_t *frame, xlator_t *this,
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_UNLINK,
- client3_1_unlink_cbk, NULL,
+ client3_3_unlink_cbk, NULL,
NULL, 0, NULL, 0,
NULL, (xdrproc_t)xdr_gfs3_unlink_req);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (unlink, frame, -1, op_errno, NULL, NULL, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
}
@@ -3348,7 +3511,7 @@ unwind:
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;
@@ -3381,20 +3544,18 @@ client3_1_rmdir (call_frame_t *frame, xlator_t *this,
req.xdata.xdata_len, op_errno, unwind);
ret = client_submit_request (this, &req, frame, conf->fops,
- GFS3_OP_RMDIR, client3_1_rmdir_cbk, NULL,
+ GFS3_OP_RMDIR, client3_3_rmdir_cbk, NULL,
NULL, 0, NULL, 0,
NULL, (xdrproc_t)xdr_gfs3_rmdir_req);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (rmdir, frame, -1, op_errno, NULL, NULL, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
}
@@ -3402,7 +3563,7 @@ unwind:
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;
@@ -3428,6 +3589,7 @@ client3_1_symlink (call_frame_t *frame, xlator_t *this,
goto unwind;
loc_copy (&local->loc, args->loc);
+ loc_path (&local->loc, NULL);
if (!uuid_is_null (args->loc->parent->gfid))
memcpy (req.pargfid, args->loc->parent->gfid, 16);
@@ -3440,6 +3602,7 @@ client3_1_symlink (call_frame_t *frame, xlator_t *this,
req.linkname = (char *)args->linkname;
req.bname = (char *)args->loc->name;
req.umask = args->umask;
+ local->loc2.path = gf_strdup (req.linkname);
conf = this->private;
@@ -3447,15 +3610,14 @@ client3_1_symlink (call_frame_t *frame, xlator_t *this,
req.xdata.xdata_len, op_errno, unwind);
ret = client_submit_request (this, &req, frame, conf->fops,
- GFS3_OP_SYMLINK, client3_1_symlink_cbk,
+ GFS3_OP_SYMLINK, client3_3_symlink_cbk,
NULL, NULL, 0, NULL,
0, NULL, (xdrproc_t)xdr_gfs3_symlink_req);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
@@ -3463,8 +3625,7 @@ unwind:
CLIENT_STACK_UNWIND (symlink, frame, -1, op_errno, NULL, NULL, NULL,
NULL, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
}
@@ -3472,7 +3633,7 @@ unwind:
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;
@@ -3514,23 +3675,21 @@ client3_1_rename (call_frame_t *frame, xlator_t *this,
req.xdata.xdata_len, op_errno, unwind);
ret = client_submit_request (this, &req, frame, conf->fops,
- GFS3_OP_RENAME, client3_1_rename_cbk, NULL,
+ GFS3_OP_RENAME, client3_3_rename_cbk, NULL,
NULL, 0, NULL, 0,
NULL, (xdrproc_t)xdr_gfs3_rename_req);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (rename, frame, -1, op_errno, NULL, NULL, NULL,
NULL, NULL, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
}
@@ -3538,7 +3697,7 @@ unwind:
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;
@@ -3580,7 +3739,9 @@ 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;
@@ -3590,21 +3751,19 @@ client3_1_link (call_frame_t *frame, xlator_t *this,
req.xdata.xdata_len, op_errno, unwind);
ret = client_submit_request (this, &req, frame, conf->fops,
- GFS3_OP_LINK, client3_1_link_cbk, NULL,
+ GFS3_OP_LINK, client3_3_link_cbk, NULL,
NULL, 0, NULL, 0, NULL,
(xdrproc_t)xdr_gfs3_link_req);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (link, frame, -1, op_errno, NULL, NULL, NULL, NULL, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
}
@@ -3612,7 +3771,7 @@ unwind:
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;
@@ -3637,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))
@@ -3658,22 +3818,20 @@ client3_1_mknod (call_frame_t *frame, xlator_t *this,
req.xdata.xdata_len, op_errno, unwind);
ret = client_submit_request (this, &req, frame, conf->fops,
- GFS3_OP_MKNOD, client3_1_mknod_cbk, NULL,
+ GFS3_OP_MKNOD, client3_3_mknod_cbk, NULL,
NULL, 0, NULL, 0,
NULL, (xdrproc_t)xdr_gfs3_mknod_req);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (mknod, frame, -1, op_errno, NULL, NULL, NULL,
NULL, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
}
@@ -3681,7 +3839,7 @@ unwind:
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;
@@ -3706,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))
@@ -3727,29 +3886,27 @@ client3_1_mkdir (call_frame_t *frame, xlator_t *this,
req.xdata.xdata_len, op_errno, unwind);
ret = client_submit_request (this, &req, frame, conf->fops,
- GFS3_OP_MKDIR, client3_1_mkdir_cbk, NULL,
+ GFS3_OP_MKDIR, client3_3_mkdir_cbk, NULL,
NULL, 0, NULL, 0,
NULL, (xdrproc_t)xdr_gfs3_mkdir_req);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (mkdir, frame, -1, op_errno, NULL, NULL, NULL,
NULL, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_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;
@@ -3776,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))
@@ -3797,23 +3955,21 @@ client3_1_create (call_frame_t *frame, xlator_t *this,
req.xdata.xdata_len, op_errno, unwind);
ret = client_submit_request (this, &req, frame, conf->fops,
- GFS3_OP_CREATE, client3_1_create_cbk, NULL,
+ GFS3_OP_CREATE, client3_3_create_cbk, NULL,
NULL, 0, NULL, 0,
NULL, (xdrproc_t)xdr_gfs3_create_req);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (create, frame, -1, op_errno, NULL, NULL, NULL,
NULL, NULL, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
}
@@ -3821,7 +3977,7 @@ unwind:
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;
@@ -3847,6 +4003,7 @@ client3_1_open (call_frame_t *frame, xlator_t *this,
local->fd = fd_ref (args->fd);
local->flags = args->flags;
loc_copy (&local->loc, args->loc);
+ loc_path (&local->loc, NULL);
frame->local = local;
if (!uuid_is_null (args->loc->inode->gfid))
@@ -3865,22 +4022,20 @@ client3_1_open (call_frame_t *frame, xlator_t *this,
req.xdata.xdata_len, op_errno, unwind);
ret = client_submit_request (this, &req, frame, conf->fops,
- GFS3_OP_OPEN, client3_1_open_cbk, NULL,
+ GFS3_OP_OPEN, client3_3_open_cbk, NULL,
NULL, 0, NULL, 0, NULL,
(xdrproc_t)xdr_gfs3_open_req);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (open, frame, -1, op_errno, NULL, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
}
@@ -3888,19 +4043,19 @@ unwind:
int32_t
-client3_1_readv (call_frame_t *frame, xlator_t *this,
+client3_3_readv (call_frame_t *frame, xlator_t *this,
void *data)
{
clnt_args_t *args = NULL;
int64_t remote_fd = -1;
clnt_conf_t *conf = NULL;
+ clnt_local_t *local = NULL;
int op_errno = ESTALE;
gfs3_read_req req = {{0,},};
int ret = 0;
struct iovec rsp_vec = {0, };
struct iobuf *rsp_iobuf = NULL;
struct iobref *rsp_iobref = NULL;
- clnt_local_t *local = NULL;
if (!frame || !this || !data)
goto unwind;
@@ -3908,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;
@@ -3946,36 +4108,23 @@ client3_1_readv (call_frame_t *frame, xlator_t *this,
goto unwind;
}
- local = mem_get0 (this->local_pool);
- if (local == NULL) {
- op_errno = ENOMEM;
- goto unwind;
- }
-
local->iobref = rsp_iobref;
rsp_iobref = NULL;
- frame->local = local;
GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
req.xdata.xdata_len, op_errno, unwind);
ret = client_submit_request (this, &req, frame, conf->fops,
- GFS3_OP_READ, client3_1_readv_cbk, NULL,
+ GFS3_OP_READ, client3_3_readv_cbk, NULL,
NULL, 0, &rsp_vec, 1,
local->iobref,
(xdrproc_t)xdr_gfs3_read_req);
if (ret) {
+ //unwind is done in the cbk
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
-
- if (rsp_iobuf)
- iobuf_unref (rsp_iobuf);
-
- if (rsp_iobref)
- iobref_unref (rsp_iobref);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
@@ -3986,22 +4135,21 @@ unwind:
iobref_unref (rsp_iobref);
CLIENT_STACK_UNWIND (readv, frame, -1, op_errno, NULL, 0, NULL, NULL, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ 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;
@@ -4009,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;
@@ -4018,8 +4172,19 @@ client3_1_writev (call_frame_t *frame, xlator_t *this, void *data)
memcpy (req.gfid, args->fd->inode->gfid, 16);
+#ifdef GF_TESTING_IO_XDATA
+ if (!args->xdata)
+ args->xdata = dict_new ();
+
+ ret = dict_set_str (args->xdata, "testing-the-xdata-key",
+ "testing-the-xdata-value");
+#endif
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
+ req.xdata.xdata_len, op_errno, unwind);
+
ret = client_submit_vec_request (this, &req, frame, conf->fops,
- GFS3_OP_WRITE, client3_1_writev_cbk,
+ GFS3_OP_WRITE, client3_3_writev_cbk,
args->vector, args->count,
args->iobref,
(xdrproc_t)xdr_gfs3_write_req);
@@ -4032,22 +4197,20 @@ client3_1_writev (call_frame_t *frame, xlator_t *this, void *data)
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (writev, frame, -1, op_errno, NULL, NULL, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ 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;
@@ -4064,7 +4227,8 @@ client3_1_flush (call_frame_t *frame, xlator_t *this,
args = data;
conf = this->private;
- CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind);
+ CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD,
+ remote_fd, op_errno, unwind);
conf = this->private;
@@ -4085,23 +4249,21 @@ client3_1_flush (call_frame_t *frame, xlator_t *this,
req.xdata.xdata_len, op_errno, unwind);
ret = client_submit_request (this, &req, frame, conf->fops,
- GFS3_OP_FLUSH, client3_1_flush_cbk, NULL,
+ GFS3_OP_FLUSH, client3_3_flush_cbk, NULL,
NULL, 0, NULL, 0,
NULL, (xdrproc_t)xdr_gfs3_flush_req);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (flush, frame, -1, op_errno, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
}
@@ -4109,7 +4271,7 @@ unwind:
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;
@@ -4125,15 +4287,18 @@ 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) {
@@ -4141,15 +4306,13 @@ client3_1_fsync (call_frame_t *frame, xlator_t *this,
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (fsync, frame, -1, op_errno, NULL, NULL, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
}
@@ -4157,7 +4320,7 @@ unwind:
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;
@@ -4173,7 +4336,8 @@ 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);
@@ -4182,22 +4346,20 @@ client3_1_fstat (call_frame_t *frame, xlator_t *this,
req.xdata.xdata_len, op_errno, unwind);
ret = client_submit_request (this, &req, frame, conf->fops,
- GFS3_OP_FSTAT, client3_1_fstat_cbk, NULL,
+ GFS3_OP_FSTAT, client3_3_fstat_cbk, NULL,
NULL, 0, NULL, 0,
NULL, (xdrproc_t)xdr_gfs3_fstat_req);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (fstat, frame, -1, op_errno, NULL, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
}
@@ -4205,7 +4367,7 @@ unwind:
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;
@@ -4230,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))
@@ -4243,24 +4406,25 @@ client3_1_opendir (call_frame_t *frame, xlator_t *this,
conf = this->private;
+ GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
+ req.xdata.xdata_len, op_errno, unwind);
+
ret = client_submit_request (this, &req, frame, conf->fops,
- GFS3_OP_OPENDIR, client3_1_opendir_cbk,
+ GFS3_OP_OPENDIR, client3_3_opendir_cbk,
NULL, NULL, 0, NULL, 0, NULL,
(xdrproc_t)xdr_gfs3_opendir_req);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (opendir, frame, -1, op_errno, NULL, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
}
@@ -4268,7 +4432,7 @@ unwind:
int32_t
-client3_1_fsyncdir (call_frame_t *frame, xlator_t *this, void *data)
+client3_3_fsyncdir (call_frame_t *frame, xlator_t *this, void *data)
{
clnt_args_t *args = NULL;
int64_t remote_fd = -1;
@@ -4283,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;
@@ -4295,7 +4460,7 @@ client3_1_fsyncdir (call_frame_t *frame, xlator_t *this, void *data)
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);
@@ -4303,15 +4468,13 @@ client3_1_fsyncdir (call_frame_t *frame, xlator_t *this, void *data)
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (fsyncdir, frame, -1, op_errno, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
}
@@ -4319,7 +4482,7 @@ unwind:
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;
@@ -4354,22 +4517,20 @@ client3_1_statfs (call_frame_t *frame, xlator_t *this,
req.xdata.xdata_len, op_errno, unwind);
ret = client_submit_request (this, &req, frame, conf->fops,
- GFS3_OP_STATFS, client3_1_statfs_cbk, NULL,
+ GFS3_OP_STATFS, client3_3_statfs_cbk, NULL,
NULL, 0, NULL, 0,
NULL, (xdrproc_t)xdr_gfs3_statfs_req);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (statfs, frame, -1, op_errno, NULL, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
}
@@ -4377,7 +4538,7 @@ unwind:
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;
@@ -4417,26 +4578,22 @@ client3_1_setxattr (call_frame_t *frame, xlator_t *this,
req.xdata.xdata_len, op_errno, unwind);
ret = client_submit_request (this, &req, frame, conf->fops,
- GFS3_OP_SETXATTR, client3_1_setxattr_cbk,
+ GFS3_OP_SETXATTR, client3_3_setxattr_cbk,
NULL, NULL, 0, NULL, 0, NULL,
(xdrproc_t)xdr_gfs3_setxattr_req);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.dict.dict_val)
- GF_FREE (req.dict.dict_val);
+ GF_FREE (req.dict.dict_val);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (setxattr, frame, -1, op_errno, NULL);
- if (req.dict.dict_val)
- GF_FREE (req.dict.dict_val);
+ GF_FREE (req.dict.dict_val);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
}
@@ -4444,7 +4601,7 @@ unwind:
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;
@@ -4460,7 +4617,8 @@ 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;
@@ -4477,27 +4635,23 @@ client3_1_fsetxattr (call_frame_t *frame, xlator_t *this,
req.xdata.xdata_len, op_errno, unwind);
ret = client_submit_request (this, &req, frame, conf->fops,
- GFS3_OP_FSETXATTR, client3_1_fsetxattr_cbk,
+ GFS3_OP_FSETXATTR, client3_3_fsetxattr_cbk,
NULL, NULL, 0, NULL, 0, NULL,
(xdrproc_t)xdr_gfs3_fsetxattr_req);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.dict.dict_val)
- GF_FREE (req.dict.dict_val);
+ GF_FREE (req.dict.dict_val);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (fsetxattr, frame, -1, op_errno, NULL);
- if (req.dict.dict_val)
- GF_FREE (req.dict.dict_val);
+ GF_FREE (req.dict.dict_val);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
}
@@ -4506,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;
@@ -4528,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) {
@@ -4575,7 +4730,7 @@ client3_1_fgetxattr (call_frame_t *frame, xlator_t *this,
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);
@@ -4583,8 +4738,7 @@ client3_1_fgetxattr (call_frame_t *frame, xlator_t *this,
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
if (rsp_iobuf)
iobuf_unref (rsp_iobuf);
@@ -4602,8 +4756,7 @@ unwind:
if (rsp_iobref)
iobref_unref (rsp_iobref);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
}
@@ -4611,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;
@@ -4634,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;
}
@@ -4644,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 ();
@@ -4670,7 +4829,7 @@ client3_1_getxattr (call_frame_t *frame, xlator_t *this,
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);
@@ -4712,7 +4871,7 @@ client3_1_getxattr (call_frame_t *frame, xlator_t *this,
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);
@@ -4720,8 +4879,7 @@ client3_1_getxattr (call_frame_t *frame, xlator_t *this,
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
if (rsp_iobuf)
iobuf_unref (rsp_iobuf);
@@ -4739,8 +4897,7 @@ unwind:
CLIENT_STACK_UNWIND (getxattr, frame, op_ret, op_errno, dict, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
}
@@ -4748,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;
@@ -4807,6 +4964,8 @@ 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);
@@ -4826,7 +4985,7 @@ client3_1_xattrop (call_frame_t *frame, xlator_t *this,
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);
@@ -4834,11 +4993,9 @@ client3_1_xattrop (call_frame_t *frame, xlator_t *this,
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.dict.dict_val)
- GF_FREE (req.dict.dict_val);
+ GF_FREE (req.dict.dict_val);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
if (rsp_iobuf)
iobuf_unref (rsp_iobuf);
@@ -4850,9 +5007,7 @@ client3_1_xattrop (call_frame_t *frame, xlator_t *this,
unwind:
CLIENT_STACK_UNWIND (xattrop, frame, -1, op_errno, NULL, NULL);
- if (req.dict.dict_val) {
- GF_FREE (req.dict.dict_val);
- }
+ GF_FREE (req.dict.dict_val);
if (rsp_iobuf)
iobuf_unref (rsp_iobuf);
@@ -4860,8 +5015,7 @@ unwind:
if (rsp_iobref)
iobref_unref (rsp_iobref);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
}
@@ -4869,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;
@@ -4891,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;
@@ -4939,7 +5094,7 @@ client3_1_fxattrop (call_frame_t *frame, xlator_t *this,
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);
@@ -4947,24 +5102,15 @@ client3_1_fxattrop (call_frame_t *frame, xlator_t *this,
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.dict.dict_val)
- GF_FREE (req.dict.dict_val);
-
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
-
- if (rsp_iobuf)
- iobuf_unref (rsp_iobuf);
+ GF_FREE (req.dict.dict_val);
- if (rsp_iobref)
- iobref_unref (rsp_iobref);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (fxattrop, frame, -1, op_errno, NULL, NULL);
- if (req.dict.dict_val)
- GF_FREE (req.dict.dict_val);
+ GF_FREE (req.dict.dict_val);
if (rsp_iobref)
iobref_unref (rsp_iobref);
@@ -4972,15 +5118,14 @@ unwind:
if (rsp_iobuf)
iobuf_unref (rsp_iobuf);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ 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;
@@ -5014,27 +5159,25 @@ client3_1_removexattr (call_frame_t *frame, xlator_t *this,
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_REMOVEXATTR,
- client3_1_removexattr_cbk, NULL,
+ client3_3_removexattr_cbk, NULL,
NULL, 0, NULL, 0, NULL,
(xdrproc_t)xdr_gfs3_removexattr_req);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (removexattr, frame, -1, op_errno, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ 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;
@@ -5054,7 +5197,8 @@ 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;
@@ -5065,27 +5209,25 @@ client3_1_fremovexattr (call_frame_t *frame, xlator_t *this,
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_FREMOVEXATTR,
- client3_1_fremovexattr_cbk, NULL,
+ client3_3_fremovexattr_cbk, NULL,
NULL, 0, NULL, 0, NULL,
(xdrproc_t)xdr_gfs3_fremovexattr_req);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (fremovexattr, frame, -1, op_errno, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ 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;
@@ -5109,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) {
@@ -5143,29 +5286,30 @@ client3_1_lk (call_frame_t *frame, xlator_t *this,
memcpy (req.gfid, args->fd->inode->gfid, 16);
+ GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
+ req.xdata.xdata_len, op_errno, unwind);
+
ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_LK,
- client3_1_lk_cbk, NULL,
+ client3_3_lk_cbk, NULL,
NULL, 0, NULL, 0, NULL,
(xdrproc_t)xdr_gfs3_lk_req);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (lk, frame, -1, op_errno, NULL, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ 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;
@@ -5228,21 +5372,19 @@ client3_1_inodelk (call_frame_t *frame, xlator_t *this,
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_INODELK,
- client3_1_inodelk_cbk, NULL,
+ client3_3_inodelk_cbk, NULL,
NULL, 0, NULL, 0,
NULL, (xdrproc_t)xdr_gfs3_inodelk_req);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (inodelk, frame, -1, op_errno, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
}
@@ -5250,7 +5392,7 @@ unwind:
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;
@@ -5260,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;
@@ -5306,27 +5453,25 @@ client3_1_finodelk (call_frame_t *frame, xlator_t *this,
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_FINODELK,
- client3_1_finodelk_cbk, NULL,
+ client3_3_finodelk_cbk, NULL,
NULL, 0, NULL, 0,
NULL, (xdrproc_t)xdr_gfs3_finodelk_req);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (finodelk, frame, -1, op_errno, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ 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;
@@ -5367,21 +5512,19 @@ client3_1_entrylk (call_frame_t *frame, xlator_t *this,
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_ENTRYLK,
- client3_1_entrylk_cbk, NULL,
+ client3_3_entrylk_cbk, NULL,
NULL, 0, NULL, 0,
NULL, (xdrproc_t)xdr_gfs3_entrylk_req);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (entrylk, frame, -1, op_errno, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
}
@@ -5389,7 +5532,7 @@ unwind:
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;
@@ -5405,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;
@@ -5423,28 +5567,26 @@ client3_1_fentrylk (call_frame_t *frame, xlator_t *this,
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_FENTRYLK,
- client3_1_fentrylk_cbk, NULL,
+ client3_3_fentrylk_cbk, NULL,
NULL, 0, NULL, 0,
NULL, (xdrproc_t)xdr_gfs3_fentrylk_req);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (fentrylk, frame, -1, op_errno, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ 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;
@@ -5460,7 +5602,8 @@ 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;
@@ -5471,7 +5614,7 @@ client3_1_rchecksum (call_frame_t *frame, xlator_t *this,
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);
@@ -5479,14 +5622,12 @@ client3_1_rchecksum (call_frame_t *frame, xlator_t *this,
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (rchecksum, frame, -1, op_errno, 0, NULL, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
}
@@ -5494,7 +5635,7 @@ unwind:
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;
@@ -5518,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;
@@ -5569,7 +5711,7 @@ client3_1_readdir (call_frame_t *frame, xlator_t *this,
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);
@@ -5578,8 +5720,7 @@ client3_1_readdir (call_frame_t *frame, xlator_t *this,
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
if (rsp_iobuf)
iobuf_unref (rsp_iobuf);
@@ -5597,15 +5738,14 @@ unwind:
iobuf_unref (rsp_iobuf);
CLIENT_STACK_UNWIND (readdir, frame, -1, op_errno, NULL, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ 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;
@@ -5629,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;
@@ -5682,7 +5823,7 @@ client3_1_readdirp (call_frame_t *frame, xlator_t *this,
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);
@@ -5690,8 +5831,7 @@ client3_1_readdirp (call_frame_t *frame, xlator_t *this,
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.dict.dict_val)
- GF_FREE (req.dict.dict_val);
+ GF_FREE (req.dict.dict_val);
if (rsp_iobuf)
iobuf_unref (rsp_iobuf);
@@ -5707,8 +5847,7 @@ unwind:
if (rsp_iobuf)
iobuf_unref (rsp_iobuf);
- if (req.dict.dict_val)
- GF_FREE (req.dict.dict_val);
+ GF_FREE (req.dict.dict_val);
CLIENT_STACK_UNWIND (readdirp, frame, -1, op_errno, NULL, NULL);
return 0;
@@ -5716,7 +5855,7 @@ unwind:
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;
@@ -5751,27 +5890,25 @@ client3_1_setattr (call_frame_t *frame, xlator_t *this,
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_SETATTR,
- client3_1_setattr_cbk, NULL,
+ client3_3_setattr_cbk, NULL,
NULL, 0, NULL, 0,
NULL, (xdrproc_t)xdr_gfs3_setattr_req);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (setattr, frame, -1, op_errno, NULL, NULL, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ 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;
@@ -5786,88 +5923,226 @@ client3_1_fsetattr (call_frame_t *frame, xlator_t *this, void *data)
args = data;
conf = this->private;
- CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind);
+ CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD,
+ remote_fd, op_errno, unwind);
req.fd = remote_fd;
req.valid = args->valid;
gf_stat_from_iatt (&req.stbuf, args->stbuf);
+ GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
+ req.xdata.xdata_len, op_errno, unwind);
+
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_FSETATTR,
- client3_1_fsetattr_cbk, NULL,
+ client3_3_fsetattr_cbk, NULL,
NULL, 0, NULL, 0,
NULL, (xdrproc_t)xdr_gfs3_fsetattr_req);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (fsetattr, frame, -1, op_errno, NULL, NULL, NULL);
- if (req.xdata.xdata_val)
- GF_FREE (req.xdata.xdata_val);
+ GF_FREE (req.xdata.xdata_val);
+
+ return 0;
+}
+
+int32_t
+client3_3_fallocate(call_frame_t *frame, xlator_t *this, void *data)
+{
+ clnt_args_t *args = NULL;
+ int64_t remote_fd = -1;
+ clnt_conf_t *conf = NULL;
+ gfs3_fallocate_req req = {{0},};
+ int op_errno = ESTALE;
+ int ret = 0;
+
+ if (!frame || !this || !data)
+ goto unwind;
+
+ args = data;
+ conf = this->private;
+
+ CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD,
+ remote_fd, op_errno, unwind);
+
+ req.fd = remote_fd;
+ req.flags = args->flags;
+ req.offset = args->offset;
+ req.size = args->size;
+ memcpy(req.gfid, args->fd->inode->gfid, 16);
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
+ req.xdata.xdata_len, op_errno, unwind);
+
+ ret = client_submit_request (this, &req, frame, conf->fops,
+ GFS3_OP_FALLOCATE,
+ client3_3_fallocate_cbk, NULL,
+ NULL, 0, NULL, 0,
+ NULL, (xdrproc_t)xdr_gfs3_fallocate_req);
+ if (ret) {
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
+ }
+
+ GF_FREE (req.xdata.xdata_val);
+
+ return 0;
+unwind:
+ CLIENT_STACK_UNWIND (fallocate, frame, -1, op_errno, NULL, NULL, NULL);
+ GF_FREE (req.xdata.xdata_val);
return 0;
}
+int32_t
+client3_3_discard(call_frame_t *frame, xlator_t *this, void *data)
+{
+ clnt_args_t *args = NULL;
+ int64_t remote_fd = -1;
+ clnt_conf_t *conf = NULL;
+ gfs3_discard_req req = {{0},};
+ int op_errno = ESTALE;
+ int ret = 0;
+
+ if (!frame || !this || !data)
+ goto unwind;
+
+ args = data;
+ conf = this->private;
+
+ CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD,
+ remote_fd, op_errno, unwind);
+
+ req.fd = remote_fd;
+ req.offset = args->offset;
+ req.size = args->size;
+ memcpy(req.gfid, args->fd->inode->gfid, 16);
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
+ req.xdata.xdata_len, op_errno, unwind);
+
+ ret = client_submit_request(this, &req, frame, conf->fops,
+ GFS3_OP_DISCARD, client3_3_discard_cbk,
+ NULL, NULL, 0, NULL, 0, NULL,
+ (xdrproc_t) xdr_gfs3_discard_req);
+ if (ret)
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
+
+ GF_FREE (req.xdata.xdata_val);
+
+ return 0;
+unwind:
+ CLIENT_STACK_UNWIND(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",
@@ -5912,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 b698f3c18..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.
*/
@@ -139,7 +130,7 @@ client_register_grace_timer (xlator_t *this, clnt_conf_t *conf)
conf->grace_timer =
gf_timer_call_after (this->ctx,
- conf->grace_tv,
+ conf->grace_ts,
client_grace_timeout,
conf->rpc);
}
@@ -824,12 +815,16 @@ client_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
goto out;
args.loc = loc;
- args.flags = flags;
args.mode = mode;
args.fd = fd;
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) {
gf_log (this->name, GF_LOG_ERROR,
@@ -863,10 +858,14 @@ client_open (call_frame_t *frame, xlator_t *this, loc_t *loc,
goto out;
args.loc = loc;
- args.flags = flags;
args.fd = fd;
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) {
gf_log (this->name, GF_LOG_ERROR,
@@ -1278,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;
}
@@ -1963,6 +1961,110 @@ out:
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,
@@ -2052,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);
@@ -2094,9 +2196,19 @@ client_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,
client_register_grace_timer (this, conf);
if (!conf->skip_notify) {
- if (conf->connected)
- gf_log (this->name, GF_LOG_INFO,
- "disconnected");
+ if (conf->connected) {
+ gf_log (this->name,
+ ((!conf->disconnect_err_logged)
+ ? GF_LOG_INFO : GF_LOG_DEBUG),
+ "disconnected from %s. Client process "
+ "will keep trying to connect to "
+ "glusterd until brick's port is "
+ "available",
+ conf->rpc->conn.trans->peerinfo.identifier);
+
+ if (conf->portmap_err_logged)
+ conf->disconnect_err_logged = 1;
+ }
/* If the CHILD_DOWN event goes to parent xlator
multiple times, the logic of parent xlator notify
@@ -2120,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:
@@ -2203,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;
@@ -2287,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");
@@ -2325,14 +2450,14 @@ client_init_grace_timer (xlator_t *this, dict_t *options,
ret = dict_get_int32 (options, "grace-timeout", &grace_timeout);
if (!ret)
- conf->grace_tv.tv_sec = grace_timeout;
+ conf->grace_ts.tv_sec = grace_timeout;
else
- conf->grace_tv.tv_sec = 10;
+ conf->grace_ts.tv_sec = 10;
- conf->grace_tv.tv_usec = 0;
+ conf->grace_ts.tv_nsec = 0;
gf_log (this->name, GF_LOG_DEBUG, "Client grace timeout "
- "value = %"PRIu64, conf->grace_tv.tv_sec);
+ "value = %"PRIu64, conf->grace_ts.tv_sec);
ret = 0;
out:
@@ -2386,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;
@@ -2655,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,
};
@@ -2710,16 +2841,27 @@ struct volume_options options[] = {
{ .key = {"lk-heal"},
.type = GF_OPTION_TYPE_BOOL,
.default_value = "off",
+ .description = "Enables or disables the lock heal."
},
{ .key = {"grace-timeout"},
.type = GF_OPTION_TYPE_INT,
.min = 10,
- .max = 1800
+ .max = 1800,
+ .description = "Sets the grace-timeout value. Valid range 10-1800."
},
{.key = {"tcp-window-size"},
.type = GF_OPTION_TYPE_SIZET,
.min = GF_MIN_SOCKET_WINDOW_SIZE,
- .max = GF_MAX_SOCKET_WINDOW_SIZE
+ .max = GF_MAX_SOCKET_WINDOW_SIZE,
+ .description = "Specifies the window size for tcp socket."
+ },
+ { .key = {"filter-O_DIRECT"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "disable",
+ .description = "If enabled, in open() and creat() calls, O_DIRECT "
+ "flag will be filtered at the client protocol level so server will "
+ "still continue to cache the file. This works similar to NFS's "
+ "behavior of O_DIRECT",
},
{ .key = {NULL} },
};
diff --git a/xlators/protocol/client/src/client.h b/xlators/protocol/client/src/client.h
index 1ca7b2e57..afab2d74f 100644
--- a/xlators/protocol/client/src/client.h
+++ b/xlators/protocol/client/src/client.h
@@ -1,20 +1,11 @@
/*
- Copyright (c) 2010-2011 Gluster, Inc. <http://www.gluster.com>
- This file is part of GlusterFS.
-
- GlusterFS is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3 of the License,
- or (at your option) any later version.
-
- GlusterFS is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see
- <http://www.gnu.org/licenses/>.
+ Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
*/
#ifndef _CLIENT_H
@@ -43,27 +34,27 @@ typedef enum {
GF_LK_HEAL_DONE,
} lk_heal_state_t;
-#define CLIENT_GET_REMOTE_FD(conf, fd, remote_fd, op_errno, label) \
+typedef enum {
+ DEFAULT_REMOTE_FD = 0,
+ FALLBACK_TO_ANON_FD = 1
+} clnt_remote_fd_flags_t;
+
+#define CLIENT_GET_REMOTE_FD(xl, fd, flags, remote_fd, op_errno, label) \
do { \
- clnt_fd_ctx_t *fdctx = NULL; \
- pthread_mutex_lock (&conf->lock); \
- { \
- fdctx = this_fd_get_ctx (fd, THIS); \
- } \
- pthread_mutex_unlock (&conf->lock); \
- if (!fdctx) { \
- remote_fd = -2; \
- } else { \
- remote_fd = fdctx->remote_fd; \
+ int _ret = 0; \
+ _ret = client_get_remote_fd (xl, fd, flags, &remote_fd);\
+ if (_ret < 0) { \
+ op_errno = errno; \
+ goto label; \
} \
if (remote_fd == -1) { \
- gf_log (THIS->name, GF_LOG_WARNING, " (%s) " \
+ gf_log (xl->name, GF_LOG_WARNING, " (%s) " \
"remote_fd is -1. EBADFD", \
uuid_utoa (fd->inode->gfid)); \
op_errno = EBADFD; \
goto label; \
} \
- } while (0);
+ } while (0)
#define CLIENT_STACK_UNWIND(op, frame, params ...) do { \
clnt_local_t *__local = frame->local; \
@@ -102,6 +93,10 @@ typedef struct clnt_conf {
which was sent earlier */
char portmap_err_logged; /* flag used to prevent
excessive logging */
+ char disconnect_err_logged; /* flag used to prevent
+ excessive disconnect
+ logging */
+
char need_different_port; /* flag used to change the
portmap path in case of
'tcp,rdma' on server */
@@ -109,7 +104,7 @@ typedef struct clnt_conf {
uint16_t lk_version; /* this variable is used to distinguish
client-server transaction while
performing lock healing */
- struct timeval grace_tv;
+ struct timespec grace_ts;
gf_timer_t *grace_timer;
gf_boolean_t grace_timer_needed; /* The state of this flag will
be used to decide whether
@@ -118,6 +113,13 @@ typedef struct clnt_conf {
means dont register, true
means register */
char parent_down;
+ gf_boolean_t quick_reconnect; /* When reconnecting after
+ portmap query, do not let
+ the reconnection happen after
+ the usual 3-second wait
+ */
+ gf_boolean_t filter_o_direct; /* if set, filter O_DIRECT from
+ the flags list of open() */
} clnt_conf_t;
typedef struct _client_fd_ctx {
@@ -125,17 +127,16 @@ typedef struct _client_fd_ctx {
fd's position in the saved_fds list.
*/
int64_t remote_fd;
- inode_t *inode;
- uint64_t ino;
- uint64_t gen;
char is_dir;
char released;
int32_t flags;
- int32_t wbflags;
fd_lk_ctx_t *lk_ctx;
pthread_mutex_t mutex;
lk_heal_state_t lk_heal_state;
+ uuid_t gfid;
+ void (*reopen_done) (struct _client_fd_ctx*, xlator_t *);
struct list_head lock_list; /* List of all granted locks on this fd */
+ int32_t reopen_attempts;
} clnt_fd_ctx_t;
typedef struct _client_posix_lock {
@@ -156,7 +157,6 @@ typedef struct client_local {
fd_t *fd;
clnt_fd_ctx_t *fdctx;
uint32_t flags;
- uint32_t wbflags;
struct iobref *iobref;
client_posix_lock_t *client_lock;
@@ -164,6 +164,8 @@ 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 {
@@ -215,9 +217,6 @@ int client_submit_request (xlator_t *this, void *req,
struct iovec *rsp_payload, int rsp_count,
struct iobref *rsp_iobref, xdrproc_t xdrproc);
-int protocol_client_reopendir (xlator_t *this, clnt_fd_ctx_t *fdctx);
-int protocol_client_reopen (xlator_t *this, clnt_fd_ctx_t *fdctx);
-
int unserialize_rsp_dirent (struct gfs3_readdir_rsp *rsp, gf_dirent_t *entries);
int unserialize_rsp_direntp (xlator_t *this, fd_t *fd,
struct gfs3_readdirp_rsp *rsp, gf_dirent_t *entries);
@@ -228,7 +227,6 @@ int client_attempt_lock_recovery (xlator_t *this, clnt_fd_ctx_t *fdctx);
int32_t delete_granted_locks_owner (fd_t *fd, gf_lkowner_t *owner);
int client_add_lock_for_recovery (fd_t *fd, struct gf_flock *flock,
gf_lkowner_t *owner, int32_t cmd);
-uint64_t decrement_reopen_fd_count (xlator_t *this, clnt_conf_t *conf);
int32_t delete_granted_locks_fd (clnt_fd_ctx_t *fdctx);
int32_t client_cmd_to_gf_cmd (int32_t cmd, int32_t *gf_cmd);
void client_save_number_fds (clnt_conf_t *conf, int count);
@@ -248,4 +246,12 @@ int client_mark_fd_bad (xlator_t *this);
int client_set_lk_version (xlator_t *this);
int client_fd_lk_list_empty (fd_lk_ctx_t *lk_ctx, gf_boolean_t use_try_lock);
+void client_default_reopen_done (clnt_fd_ctx_t *fdctx, xlator_t *this);
+void client_attempt_reopen (fd_t *fd, xlator_t *this);
+int client_get_remote_fd (xlator_t *this, fd_t *fd, int flags,
+ int64_t *remote_fd);
+int client_fd_fop_prepare_local (call_frame_t *frame, fd_t *fd,
+ int64_t remote_fd);
+gf_boolean_t
+__is_fd_reopen_in_progress (clnt_fd_ctx_t *fdctx);
#endif /* !_CLIENT_H */