summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnuradha Talur <atalur@redhat.com>2016-04-27 15:32:16 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2016-04-30 17:21:07 -0700
commit93eaeb9c93be3232f24e840044d560f9f0e66f71 (patch)
tree4499267cb96472d06067e9856cff1905e8003a49
parent0d23f5207337fa54be57939eb8d70fe835d4658b (diff)
protocol/client : Refactoring functions
These changes are made to accommodate compound fops. The new functions that are added pack the arguments required to perform the fops. These will be used both by normal fops and compound ones. Change-Id: I44d9cef8ff1d33aa2f5661689c8e9386d87b2007 BUG: 1303829 Signed-off-by: Anuradha Talur <atalur@redhat.com> Reviewed-on: http://review.gluster.org/13963 Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com> Smoke: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
-rw-r--r--xlators/protocol/client/src/Makefile.am4
-rw-r--r--xlators/protocol/client/src/client-common.c2158
-rw-r--r--xlators/protocol/client/src/client-common.h403
-rw-r--r--xlators/protocol/client/src/client-helpers.c1
-rw-r--r--xlators/protocol/client/src/client-rpc-fops.c1614
-rw-r--r--xlators/protocol/client/src/client.h6
6 files changed, 3040 insertions, 1146 deletions
diff --git a/xlators/protocol/client/src/Makefile.am b/xlators/protocol/client/src/Makefile.am
index 7dbcf2a833d..75acbc9e877 100644
--- a/xlators/protocol/client/src/Makefile.am
+++ b/xlators/protocol/client/src/Makefile.am
@@ -9,9 +9,9 @@ client_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la \
$(top_builddir)/rpc/xdr/src/libgfxdr.la
client_la_SOURCES = client.c client-helpers.c client-rpc-fops.c \
- client-handshake.c client-callback.c client-lk.c
+ client-handshake.c client-callback.c client-lk.c client-common.c
-noinst_HEADERS = client.h client-mem-types.h client-messages.h
+noinst_HEADERS = client.h client-mem-types.h client-messages.h client-common.h
AM_CPPFLAGS = $(GF_CPPFLAGS) \
-I$(top_srcdir)/libglusterfs/src \
diff --git a/xlators/protocol/client/src/client-common.c b/xlators/protocol/client/src/client-common.c
new file mode 100644
index 00000000000..3d83bc94f59
--- /dev/null
+++ b/xlators/protocol/client/src/client-common.c
@@ -0,0 +1,2158 @@
+/*
+ Copyright (c) 2016 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.
+*/
+
+#include "dict.h"
+#include "xlator.h"
+#include "rpc-common-xdr.h"
+#include "glusterfs3-xdr.h"
+#include "glusterfs3.h"
+#include "client.h"
+
+/* processing to be done before fops are woudn down */
+int
+client_pre_stat (xlator_t *this, gfs3_stat_req *req, loc_t *loc,
+ dict_t *xdata)
+{
+ int op_errno = ESTALE;
+
+ if (!(loc && loc->inode))
+ goto out;
+
+ if (!gf_uuid_is_null (loc->inode->gfid))
+ memcpy (req->gfid, loc->inode->gfid, 16);
+ else
+ memcpy (req->gfid, loc->gfid, 16);
+
+ GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
+ !gf_uuid_is_null (*((uuid_t *)req->gfid)),
+ out, op_errno, EINVAL);
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_readlink (xlator_t *this, gfs3_readlink_req *req, loc_t *loc,
+ size_t size, dict_t *xdata)
+{
+ int op_errno = ESTALE;
+
+ if (!(loc && loc->inode))
+ goto out;
+
+ if (!gf_uuid_is_null (loc->inode->gfid))
+ memcpy (req->gfid, loc->inode->gfid, 16);
+ else
+ memcpy (req->gfid, loc->gfid, 16);
+
+ GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
+ !gf_uuid_is_null (*((uuid_t *)req->gfid)),
+ out, op_errno, EINVAL);
+ req->size = size;
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_mknod (xlator_t *this, gfs3_mknod_req *req, loc_t *loc,
+ mode_t mode, dev_t rdev, mode_t umask, dict_t *xdata)
+{
+ int op_errno = ESTALE;
+
+ if (!(loc && loc->parent))
+ goto out;
+
+ if (!gf_uuid_is_null (loc->parent->gfid))
+ memcpy (req->pargfid, loc->parent->gfid, 16);
+ else
+ memcpy (req->pargfid, loc->pargfid, 16);
+
+ GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
+ !gf_uuid_is_null (*((uuid_t *)req->pargfid)),
+ out, op_errno, EINVAL);
+ req->bname = (char *)loc->name;
+ req->mode = mode;
+ req->dev = rdev;
+ req->umask = umask;
+
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_mkdir (xlator_t *this, gfs3_mkdir_req *req, loc_t *loc,
+ mode_t mode, mode_t umask, dict_t *xdata)
+{
+ int op_errno = ESTALE;
+
+ if (!(loc && loc->parent))
+ goto out;
+
+ if (!gf_uuid_is_null (loc->parent->gfid))
+ memcpy (req->pargfid, loc->parent->gfid, 16);
+ else
+ memcpy (req->pargfid, loc->pargfid, 16);
+
+ GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
+ !gf_uuid_is_null (*((uuid_t *)req->pargfid)),
+ out, op_errno, EINVAL);
+
+ req->bname = (char *)loc->name;
+ req->mode = mode;
+ req->umask = umask;
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_unlink (xlator_t *this, gfs3_unlink_req *req, loc_t *loc,
+ int32_t flags, dict_t *xdata)
+{
+ int op_errno = 0;
+
+ if (!(loc && loc->parent))
+ goto out;
+
+ if (!gf_uuid_is_null (loc->parent->gfid))
+ memcpy (req->pargfid, loc->parent->gfid, 16);
+ else
+ memcpy (req->pargfid, loc->pargfid, 16);
+
+ GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
+ !gf_uuid_is_null (*((uuid_t *)req->pargfid)),
+ out, op_errno, EINVAL);
+ req->bname = (char *)loc->name;
+ req->xflags = flags;
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_rmdir (xlator_t *this, gfs3_rmdir_req *req, loc_t *loc,
+ int32_t flags, dict_t *xdata)
+{
+ int op_errno = ESTALE;
+
+ if (!(loc && loc->parent))
+ goto out;
+
+ if (!gf_uuid_is_null (loc->parent->gfid))
+ memcpy (req->pargfid, loc->parent->gfid, 16);
+ else
+ memcpy (req->pargfid, loc->pargfid, 16);
+
+ GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
+ !gf_uuid_is_null (*((uuid_t *)req->pargfid)),
+ out, op_errno, EINVAL);
+ req->bname = (char *)loc->name;
+ req->xflags = flags;
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_symlink (xlator_t *this, gfs3_symlink_req *req, loc_t *loc,
+ const char *linkname, mode_t umask, dict_t *xdata)
+{
+ int op_errno = ESTALE;
+
+ if (!(loc && loc->parent))
+ goto out;
+
+ if (!gf_uuid_is_null (loc->parent->gfid))
+ memcpy (req->pargfid, loc->parent->gfid, 16);
+ else
+ memcpy (req->pargfid, loc->pargfid, 16);
+
+ GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
+ !gf_uuid_is_null (*((uuid_t *)req->pargfid)),
+ out, op_errno, EINVAL);
+ req->linkname = (char *)linkname;
+ req->bname = (char *)loc->name;
+ req->umask = umask;
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_rename (xlator_t *this, gfs3_rename_req *req, loc_t *oldloc,
+ loc_t *newloc, dict_t *xdata)
+{
+ int op_errno = ESTALE;
+
+ if (!(oldloc && newloc && oldloc->parent &&
+ newloc->parent))
+ goto out;
+
+ if (!gf_uuid_is_null (oldloc->parent->gfid))
+ memcpy (req->oldgfid, oldloc->parent->gfid, 16);
+ else
+ memcpy (req->oldgfid, oldloc->pargfid, 16);
+
+ if (!gf_uuid_is_null (newloc->parent->gfid))
+ memcpy (req->newgfid, newloc->parent->gfid, 16);
+ else
+ memcpy (req->newgfid, newloc->pargfid, 16);
+
+ GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
+ !gf_uuid_is_null (*((uuid_t *)req->oldgfid)),
+ out, op_errno, EINVAL);
+ GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
+ !gf_uuid_is_null (*((uuid_t *)req->newgfid)),
+ out, op_errno, EINVAL);
+ req->oldbname = (char *)oldloc->name;
+ req->newbname = (char *)newloc->name;
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_link (xlator_t *this,
+ gfs3_link_req *req, loc_t *oldloc, loc_t *newloc,
+ dict_t *xdata)
+{
+ int op_errno = ESTALE;
+
+ if (!(oldloc && oldloc->inode && newloc &&
+ newloc->parent))
+ goto out;
+
+ if (!gf_uuid_is_null (oldloc->inode->gfid))
+ memcpy (req->oldgfid, oldloc->inode->gfid, 16);
+ else
+ memcpy (req->oldgfid, oldloc->gfid, 16);
+
+ if (!gf_uuid_is_null (newloc->parent->gfid))
+ memcpy (req->newgfid, newloc->parent->gfid, 16);
+ else
+ memcpy (req->newgfid, newloc->pargfid, 16);
+
+ GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
+ !gf_uuid_is_null (*((uuid_t *)req->oldgfid)),
+ out, op_errno, EINVAL);
+ GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
+ !gf_uuid_is_null (*((uuid_t *)req->newgfid)),
+ out, op_errno, EINVAL);
+ req->newbname = (char *)newloc->name;
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_truncate (xlator_t *this, gfs3_truncate_req *req,
+ loc_t *loc, off_t offset, dict_t *xdata)
+{
+ int op_errno = ESTALE;
+
+ if (!(loc && loc->inode))
+ goto out;
+
+ if (!gf_uuid_is_null (loc->inode->gfid))
+ memcpy (req->gfid, loc->inode->gfid, 16);
+ else
+ memcpy (req->gfid, loc->gfid, 16);
+
+ GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
+ !gf_uuid_is_null (*((uuid_t *)req->gfid)),
+ out, op_errno, EINVAL);
+ req->offset = offset;
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_open (xlator_t *this, gfs3_open_req *req, loc_t *loc, fd_t *fd,
+ int32_t flags, dict_t *xdata)
+{
+ int op_errno = ESTALE;
+
+ if (!(loc && loc->inode))
+ goto out;
+
+ if (!gf_uuid_is_null (loc->inode->gfid))
+ memcpy (req->gfid, loc->inode->gfid, 16);
+ else
+ memcpy (req->gfid, loc->gfid, 16);
+
+ GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
+ !gf_uuid_is_null (*((uuid_t *)req->gfid)),
+ out, op_errno, EINVAL);
+ req->flags = gf_flags_from_flags (flags);
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_readv (xlator_t *this, gfs3_read_req *req, fd_t *fd, size_t size,
+ off_t offset, int32_t flags, dict_t *xdata)
+{
+ int64_t remote_fd = -1;
+ int op_errno = ESTALE;
+
+ CLIENT_GET_REMOTE_FD (this, fd, FALLBACK_TO_ANON_FD,
+ remote_fd, op_errno, out);
+
+ req->size = size;
+ req->offset = offset;
+ req->fd = remote_fd;
+ req->flag = flags;
+
+ memcpy (req->gfid, fd->inode->gfid, 16);
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_writev (xlator_t *this, gfs3_write_req *req,
+ fd_t *fd, size_t size, off_t offset, int32_t flags,
+ dict_t *xdata)
+{
+ int64_t remote_fd = -1;
+ int op_errno = ESTALE;
+
+ CLIENT_GET_REMOTE_FD (this, fd, FALLBACK_TO_ANON_FD,
+ remote_fd, op_errno, out);
+
+ req->size = size;
+ req->offset = offset;
+ req->fd = remote_fd;
+ req->flag = flags;
+
+ memcpy (req->gfid, fd->inode->gfid, 16);
+
+#ifdef GF_TESTING_IO_XDATA
+ if (!xdata)
+ xdata = dict_new ();
+
+ ret = dict_set_str (xdata, "testing-the-xdata-key",
+ "testing-the-xdata-value");
+#endif
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_statfs (xlator_t *this, gfs3_statfs_req *req, loc_t *loc,
+ dict_t *xdata)
+{
+ int op_errno = ESTALE;
+
+ if (!loc)
+ goto out;
+
+ if (loc->inode) {
+ if (!gf_uuid_is_null (loc->inode->gfid))
+ memcpy (req->gfid, loc->inode->gfid, 16);
+ else
+ memcpy (req->gfid, loc->gfid, 16);
+ } else {
+ req->gfid[15] = 1;
+ }
+
+ GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
+ !gf_uuid_is_null (*((uuid_t *)req->gfid)),
+ out, op_errno, EINVAL);
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_flush (xlator_t *this, gfs3_flush_req *req, fd_t *fd, dict_t *xdata)
+{
+ int64_t remote_fd = -1;
+ int op_errno = ESTALE;
+ clnt_local_t *local = NULL;
+
+ CLIENT_GET_REMOTE_FD (this, fd, DEFAULT_REMOTE_FD,
+ remote_fd, op_errno, out);
+
+ req->fd = remote_fd;
+ memcpy (req->gfid, fd->inode->gfid, 16);
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_fsync (xlator_t *this, gfs3_fsync_req *req, fd_t *fd,
+ int32_t flags, dict_t *xdata)
+{
+ int64_t remote_fd = -1;
+ int op_errno = 0;
+
+ CLIENT_GET_REMOTE_FD (this, fd, DEFAULT_REMOTE_FD,
+ remote_fd, op_errno, out);
+
+ req->fd = remote_fd;
+ req->data = flags;
+ memcpy (req->gfid, fd->inode->gfid, 16);
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_setxattr (xlator_t *this, gfs3_setxattr_req *req, loc_t *loc,
+ dict_t *xattr, int32_t flags, dict_t *xdata)
+{
+ int op_errno = ESTALE;
+
+ if (!(loc && loc->inode))
+ goto out;
+
+ if (!gf_uuid_is_null (loc->inode->gfid))
+ memcpy (req->gfid, loc->inode->gfid, 16);
+ else
+ memcpy (req->gfid, loc->gfid, 16);
+
+ GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
+ !gf_uuid_is_null (*((uuid_t *)req->gfid)),
+ out, op_errno, EINVAL);
+ if (xattr) {
+ GF_PROTOCOL_DICT_SERIALIZE (this, xattr,
+ (&req->dict.dict_val),
+ req->dict.dict_len,
+ op_errno, out);
+ }
+
+ req->flags = flags;
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_getxattr (xlator_t *this, gfs3_getxattr_req *req, loc_t *loc,
+ const char *name, dict_t *xdata)
+{
+ int op_errno = ESTALE;
+
+ if (!loc) {
+ op_errno = EINVAL;
+ goto out;
+ }
+
+ if (loc->inode && !gf_uuid_is_null (loc->inode->gfid))
+ memcpy (req->gfid, loc->inode->gfid, 16);
+ else
+ memcpy (req->gfid, loc->gfid, 16);
+
+ GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
+ !gf_uuid_is_null (*((uuid_t *)req->gfid)),
+ out, op_errno, EINVAL);
+ req->namelen = 1; /* Use it as a flag */
+
+ req->name = (char *)name;
+ if (!req->name) {
+ req->name = "";
+ req->namelen = 0;
+ }
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_removexattr (xlator_t *this, gfs3_removexattr_req *req,
+ loc_t *loc, const char *name, dict_t *xdata)
+{
+ int op_errno = ESTALE;
+
+ if (!(loc && loc->inode))
+ goto out;
+
+ if (!gf_uuid_is_null (loc->inode->gfid))
+ memcpy (req->gfid, loc->inode->gfid, 16);
+ else
+ memcpy (req->gfid, loc->gfid, 16);
+
+ GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
+ !gf_uuid_is_null (*((uuid_t *)req->gfid)),
+ out, op_errno, EINVAL);
+ req->name = (char *)name;
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_opendir (xlator_t *this,
+ gfs3_opendir_req *req, loc_t *loc,
+ fd_t *fd, dict_t *xdata)
+{
+ int op_errno = ESTALE;
+
+ if (!(loc && loc->inode))
+ goto out;
+
+ if (!gf_uuid_is_null (loc->inode->gfid))
+ memcpy (req->gfid, loc->inode->gfid, 16);
+ else
+ memcpy (req->gfid, loc->gfid, 16);
+
+ GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
+ !gf_uuid_is_null (*((uuid_t *)req->gfid)),
+ out, op_errno, EINVAL);
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_fsyncdir (xlator_t *this, gfs3_fsyncdir_req *req, fd_t *fd,
+ int32_t flags, dict_t *xdata)
+{
+ int32_t op_errno = ESTALE;
+ int64_t remote_fd = -1;
+
+ CLIENT_GET_REMOTE_FD (this, fd, DEFAULT_REMOTE_FD,
+ remote_fd, op_errno, out);
+
+ req->fd = remote_fd;
+ req->data = flags;
+ memcpy (req->gfid, fd->inode->gfid, 16);
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_access (xlator_t *this, gfs3_access_req *req, loc_t *loc,
+ int32_t mask, dict_t *xdata)
+{
+ int op_errno = ESTALE;
+
+ if (!(loc && loc->inode))
+ goto out;
+
+ if (!gf_uuid_is_null (loc->inode->gfid))
+ memcpy (req->gfid, loc->inode->gfid, 16);
+ else
+ memcpy (req->gfid, loc->gfid, 16);
+
+ GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
+ !gf_uuid_is_null (*((uuid_t *)req->gfid)),
+ out, op_errno, EINVAL);
+ req->mask = mask;
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_create (xlator_t *this, gfs3_create_req *req,
+ loc_t *loc, fd_t *fd, mode_t mode,
+ int32_t flags, mode_t umask, dict_t *xdata)
+{
+ int op_errno = ESTALE;
+
+ if (!(loc && loc->parent))
+ goto out;
+
+ if (!gf_uuid_is_null (loc->parent->gfid))
+ memcpy (req->pargfid, loc->parent->gfid, 16);
+ else
+ memcpy (req->pargfid, loc->pargfid, 16);
+
+ GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
+ !gf_uuid_is_null (*((uuid_t *)req->pargfid)),
+ out, op_errno, EINVAL);
+ req->bname = (char *)loc->name;
+ req->mode = mode;
+ req->flags = gf_flags_from_flags (flags);
+ req->umask = umask;
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_ftruncate (xlator_t *this, gfs3_ftruncate_req *req, fd_t *fd,
+ off_t offset, dict_t *xdata)
+{
+ int64_t remote_fd = -1;
+ int op_errno = EINVAL;
+
+ CLIENT_GET_REMOTE_FD (this, fd, DEFAULT_REMOTE_FD,
+ remote_fd, op_errno, out);
+
+ req->offset = offset;
+ req->fd = remote_fd;
+ memcpy (req->gfid, fd->inode->gfid, 16);
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_fstat (xlator_t *this, gfs3_fstat_req *req, fd_t *fd,
+ dict_t *xdata)
+{
+ int64_t remote_fd = -1;
+ int op_errno = ESTALE;
+
+ CLIENT_GET_REMOTE_FD (this, fd, DEFAULT_REMOTE_FD,
+ remote_fd, op_errno, out);
+
+ req->fd = remote_fd;
+ memcpy (req->gfid, fd->inode->gfid, 16);
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_lk (xlator_t *this, gfs3_lk_req *req,
+ int32_t cmd, struct gf_flock *flock, fd_t *fd, dict_t *xdata)
+{
+ int64_t remote_fd = -1;
+ int op_errno = ESTALE;
+ int32_t gf_cmd = 0;
+ int32_t gf_type = 0;
+ int ret = 0;
+
+ CLIENT_GET_REMOTE_FD (this, fd, DEFAULT_REMOTE_FD,
+ remote_fd, op_errno, out);
+
+ ret = client_cmd_to_gf_cmd (cmd, &gf_cmd);
+ if (ret) {
+ op_errno = EINVAL;
+ gf_msg (this->name, GF_LOG_WARNING, EINVAL,
+ PC_MSG_INVALID_ENTRY, "Unknown cmd (%d)!", gf_cmd);
+ goto out;
+ }
+
+ switch (flock->l_type) {
+ case F_RDLCK:
+ gf_type = GF_LK_F_RDLCK;
+ break;
+ case F_WRLCK:
+ gf_type = GF_LK_F_WRLCK;
+ break;
+ case F_UNLCK:
+ gf_type = GF_LK_F_UNLCK;
+ break;
+ }
+
+ req->fd = remote_fd;
+ req->cmd = gf_cmd;
+ req->type = gf_type;
+ gf_proto_flock_from_flock (&req->flock, flock);
+
+ memcpy (req->gfid, fd->inode->gfid, 16);
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_lookup (xlator_t *this, gfs3_lookup_req *req, loc_t *loc,
+ dict_t *xdata)
+{
+ int op_errno = ESTALE;
+
+ if (!(loc && loc->inode))
+ goto out;
+
+ if ((loc->parent) && (!gf_uuid_is_null (loc->parent->gfid)))
+ memcpy (req->pargfid, loc->parent->gfid, 16);
+ else
+ memcpy (req->pargfid, loc->pargfid, 16);
+
+ if ((loc->inode) && (!gf_uuid_is_null (loc->inode->gfid)))
+ memcpy (req->gfid, loc->inode->gfid, 16);
+ else
+ memcpy (req->gfid, loc->gfid, 16);
+
+
+ if (loc->name)
+ req->bname = (char *)loc->name;
+ else
+ req->bname = "";
+
+ if (xdata) {
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata,
+ (&req->xdata.xdata_val),
+ req->xdata.xdata_len,
+ op_errno, out);
+ }
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_readdir (xlator_t *this, gfs3_readdir_req *req, fd_t *fd,
+ size_t size, off_t offset, dict_t *xdata)
+{
+ int64_t remote_fd = -1;
+ int op_errno = ESTALE;
+
+ CLIENT_GET_REMOTE_FD (this, fd, DEFAULT_REMOTE_FD,
+ remote_fd, op_errno, out);
+
+ req->size = size;
+ req->offset = offset;
+ req->fd = remote_fd;
+
+ memcpy (req->gfid, fd->inode->gfid, 16);
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_inodelk (xlator_t *this, gfs3_inodelk_req *req, loc_t *loc,
+ int cmd, struct gf_flock *flock, const char *volume,
+ dict_t *xdata)
+{
+ int op_errno = ESTALE;
+ int32_t gf_cmd = 0;
+ int32_t gf_type = 0;
+
+ if (!(loc && loc->inode))
+ goto out;
+
+ if (!gf_uuid_is_null (loc->gfid))
+ memcpy (req->gfid, loc->gfid, 16);
+ else
+ memcpy (req->gfid, loc->inode->gfid, 16);
+
+ GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
+ !gf_uuid_is_null (*((uuid_t *)req->gfid)),
+ out, op_errno, EINVAL);
+ if (cmd == F_GETLK || cmd == F_GETLK64)
+ gf_cmd = GF_LK_GETLK;
+ else if (cmd == F_SETLK || cmd == F_SETLK64)
+ gf_cmd = GF_LK_SETLK;
+ else if (cmd == F_SETLKW || cmd == F_SETLKW64)
+ gf_cmd = GF_LK_SETLKW;
+ else {
+ gf_msg (this->name, GF_LOG_WARNING, EINVAL,
+ PC_MSG_INVALID_ENTRY, "Unknown cmd (%d)!", gf_cmd);
+ op_errno = EINVAL;
+ goto out;
+ }
+
+ switch (flock->l_type) {
+ case F_RDLCK:
+ gf_type = GF_LK_F_RDLCK;
+ break;
+ case F_WRLCK:
+ gf_type = GF_LK_F_WRLCK;
+ break;
+ case F_UNLCK:
+ gf_type = GF_LK_F_UNLCK;
+ break;
+ }
+
+ req->volume = (char *)volume;
+ req->cmd = gf_cmd;
+ req->type = gf_type;
+ gf_proto_flock_from_flock (&req->flock, flock);
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_finodelk (xlator_t *this, gfs3_finodelk_req *req, fd_t *fd,
+ int cmd, struct gf_flock *flock, const char *volume,
+ dict_t *xdata)
+{
+ int op_errno = ESTALE;
+ int64_t remote_fd = -1;
+ int32_t gf_type = 0;
+ int32_t gf_cmd = 0;
+
+ CLIENT_GET_REMOTE_FD (this, fd, FALLBACK_TO_ANON_FD,
+ remote_fd, op_errno, out);
+
+ if (cmd == F_GETLK || cmd == F_GETLK64)
+ gf_cmd = GF_LK_GETLK;
+ else if (cmd == F_SETLK || cmd == F_SETLK64)
+ gf_cmd = GF_LK_SETLK;
+ else if (cmd == F_SETLKW || cmd == F_SETLKW64)
+ gf_cmd = GF_LK_SETLKW;
+ else {
+ gf_msg (this->name, GF_LOG_WARNING, EINVAL,
+ PC_MSG_INVALID_ENTRY, "Unknown cmd (%d)!", gf_cmd);
+ goto out;
+ }
+
+ switch (flock->l_type) {
+ case F_RDLCK:
+ gf_type = GF_LK_F_RDLCK;
+ break;
+ case F_WRLCK:
+ gf_type = GF_LK_F_WRLCK;
+ break;
+ case F_UNLCK:
+ gf_type = GF_LK_F_UNLCK;
+ break;
+ }
+
+ req->volume = (char *)volume;
+ req->fd = remote_fd;
+ req->cmd = gf_cmd;
+ req->type = gf_type;
+ gf_proto_flock_from_flock (&req->flock, flock);
+ memcpy (req->gfid, fd->inode->gfid, 16);
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_entrylk (xlator_t *this, gfs3_entrylk_req *req, loc_t *loc,
+ entrylk_cmd cmd_entrylk, entrylk_type type,
+ const char *volume, const char *basename, dict_t *xdata)
+{
+ int op_errno = ESTALE;
+
+ if (!(loc && loc->inode))
+ goto out;
+
+ if (!gf_uuid_is_null (loc->gfid))
+ memcpy (req->gfid, loc->gfid, 16);
+ else
+ memcpy (req->gfid, loc->inode->gfid, 16);
+
+ GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
+ !gf_uuid_is_null (*((uuid_t *)req->gfid)),
+ out, op_errno, EINVAL);
+ req->cmd = cmd_entrylk;
+ req->type = type;
+ req->volume = (char *)volume;
+ req->name = "";
+ if (basename) {
+ req->name = (char *)basename;
+ req->namelen = 1;
+ }
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_fentrylk (xlator_t *this, gfs3_fentrylk_req *req, fd_t *fd,
+ entrylk_cmd cmd_entrylk, entrylk_type type,
+ const char *volume, const char *basename, dict_t *xdata)
+{
+ int64_t remote_fd = -1;
+ int op_errno = ESTALE;
+
+ CLIENT_GET_REMOTE_FD (this, fd, DEFAULT_REMOTE_FD,
+ remote_fd, op_errno, out);
+
+ req->fd = remote_fd;
+ req->cmd = cmd_entrylk;
+ req->type = type;
+ req->volume = (char *)volume;
+ req->name = "";
+ if (basename) {
+ req->name = (char *)basename;
+ req->namelen = 1;
+ }
+ memcpy (req->gfid, fd->inode->gfid, 16);
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_xattrop (xlator_t *this, gfs3_xattrop_req *req, loc_t *loc,
+ dict_t *xattr, int32_t flags, dict_t *xdata)
+{
+ int op_errno = ESTALE;
+
+ if (!(loc && loc->inode))
+ goto out;
+
+ if (!gf_uuid_is_null (loc->inode->gfid))
+ memcpy (req->gfid, loc->inode->gfid, 16);
+ else
+ memcpy (req->gfid, loc->gfid, 16);
+
+ GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
+ !gf_uuid_is_null (*((uuid_t *)req->gfid)),
+ out, op_errno, EINVAL);
+ if (xattr) {
+ GF_PROTOCOL_DICT_SERIALIZE (this, xattr,
+ (&req->dict.dict_val),
+ req->dict.dict_len,
+ op_errno, out);
+ }
+
+ req->flags = flags;
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_fxattrop (xlator_t *this, gfs3_fxattrop_req *req, fd_t *fd,
+ dict_t *xattr, int32_t flags, dict_t *xdata)
+{
+ int op_errno = ESTALE;
+ int64_t remote_fd = -1;
+
+ CLIENT_GET_REMOTE_FD (this, fd, FALLBACK_TO_ANON_FD,
+ remote_fd, op_errno, out);
+
+ req->fd = remote_fd;
+ req->flags = flags;
+ memcpy (req->gfid, fd->inode->gfid, 16);
+
+ if (xattr) {
+ GF_PROTOCOL_DICT_SERIALIZE (this, xattr,
+ (&req->dict.dict_val),
+ req->dict.dict_len,
+ op_errno, out);
+ }
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_fgetxattr (xlator_t *this, gfs3_fgetxattr_req *req, fd_t *fd,
+ const char *name, dict_t *xdata)
+{
+ int64_t remote_fd = -1;
+ int op_errno = ESTALE;
+
+ CLIENT_GET_REMOTE_FD (this, fd, DEFAULT_REMOTE_FD,
+ remote_fd, op_errno, out);
+
+ req->namelen = 1; /* Use it as a flag */
+ req->fd = remote_fd;
+ req->name = (char *)name;
+ if (!req->name) {
+ req->name = "";
+ req->namelen = 0;
+ }
+ memcpy (req->gfid, fd->inode->gfid, 16);
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_fsetxattr (xlator_t *this, gfs3_fsetxattr_req *req, fd_t *fd,
+ int32_t flags, dict_t *xattr, dict_t *xdata)
+{
+ int64_t remote_fd = -1;
+ int op_errno = ESTALE;
+
+ CLIENT_GET_REMOTE_FD (this, fd, DEFAULT_REMOTE_FD,
+ remote_fd, op_errno, out);
+
+ req->fd = remote_fd;
+ req->flags = flags;
+ memcpy (req->gfid, fd->inode->gfid, 16);
+
+ if (xattr) {
+ GF_PROTOCOL_DICT_SERIALIZE (this, xattr,
+ (&req->dict.dict_val),
+ req->dict.dict_len,
+ op_errno, out);
+ }
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_rchecksum (xlator_t *this, gfs3_rchecksum_req *req, fd_t *fd,
+ int32_t len, off_t offset, dict_t *xdata)
+{
+ int64_t remote_fd = -1;
+ int op_errno = ESTALE;
+
+ CLIENT_GET_REMOTE_FD (this, fd, DEFAULT_REMOTE_FD,
+ remote_fd, op_errno, out);
+
+ req->len = len;
+ req->offset = offset;
+ req->fd = remote_fd;
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_setattr (xlator_t *this, gfs3_setattr_req *req, loc_t *loc,
+ int32_t valid, struct iatt *stbuf, dict_t *xdata)
+{
+ int op_errno = ESTALE;
+
+ if (!(loc && loc->inode))
+ return -op_errno;
+
+ if (!gf_uuid_is_null (loc->inode->gfid))
+ memcpy (req->gfid, loc->inode->gfid, 16);
+ else
+ memcpy (req->gfid, loc->gfid, 16);
+
+ GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
+ !gf_uuid_is_null (*((uuid_t *)req->gfid)),
+ out, op_errno, EINVAL);
+
+ req->valid = valid;
+ gf_stat_from_iatt (&req->stbuf, stbuf);
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_fsetattr (xlator_t *this, gfs3_fsetattr_req *req, fd_t *fd,
+ int32_t valid, struct iatt *stbuf, dict_t *xdata)
+{
+ int op_errno = ESTALE;
+ int64_t remote_fd = -1;
+
+ CLIENT_GET_REMOTE_FD (this, fd, DEFAULT_REMOTE_FD,
+ remote_fd, op_errno, out);
+
+ req->fd = remote_fd;
+ req->valid = valid;
+ gf_stat_from_iatt (&req->stbuf, stbuf);
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_readdirp (xlator_t *this, gfs3_readdirp_req *req, fd_t *fd,
+ size_t size, off_t offset, dict_t *xdata)
+{
+ int op_errno = ESTALE;
+ int64_t remote_fd = -1;
+
+ CLIENT_GET_REMOTE_FD (this, fd, DEFAULT_REMOTE_FD,
+ remote_fd, op_errno, out);
+
+ req->size = size;
+ req->offset = offset;
+ req->fd = remote_fd;
+ memcpy (req->gfid, fd->inode->gfid, 16);
+
+ /* dict itself is 'xdata' here */
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->dict.dict_val),
+ req->dict.dict_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_fremovexattr (xlator_t *this, gfs3_fremovexattr_req *req, fd_t *fd,
+ const char *name, dict_t *xdata)
+{
+ int64_t remote_fd = -1;
+ int op_errno = ESTALE;
+
+ if (!(fd && fd->inode))
+ goto out;
+
+ CLIENT_GET_REMOTE_FD (this, fd, DEFAULT_REMOTE_FD,
+ remote_fd, op_errno, out);
+
+ memcpy (req->gfid, fd->inode->gfid, 16);
+ req->name = (char *)name;
+ req->fd = remote_fd;
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_fallocate (xlator_t *this, gfs3_fallocate_req *req, fd_t *fd,
+ int32_t flags, off_t offset, size_t size, dict_t *xdata)
+{
+ int op_errno = ESTALE;
+ int64_t remote_fd = -1;
+
+ CLIENT_GET_REMOTE_FD (this, fd, DEFAULT_REMOTE_FD,
+ remote_fd, op_errno, out);
+
+ req->fd = remote_fd;
+ req->flags = flags;
+ req->offset = offset;
+ req->size = size;
+ memcpy(req->gfid, fd->inode->gfid, 16);
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_discard (xlator_t *this, gfs3_discard_req *req, fd_t *fd,
+ off_t offset, size_t size, dict_t *xdata)
+{
+ int op_errno = ESTALE;
+ int64_t remote_fd = -1;
+
+ CLIENT_GET_REMOTE_FD (this, fd, DEFAULT_REMOTE_FD,
+ remote_fd, op_errno, out);
+
+ req->fd = remote_fd;
+ req->offset = offset;
+ req->size = size;
+ memcpy(req->gfid, fd->inode->gfid, 16);
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_zerofill (xlator_t *this, gfs3_zerofill_req *req, fd_t *fd,
+ off_t offset, size_t size, dict_t *xdata)
+{
+ int op_errno = ESTALE;
+ int64_t remote_fd = -1;
+
+ CLIENT_GET_REMOTE_FD (this, fd, DEFAULT_REMOTE_FD,
+ remote_fd, op_errno, out);
+
+ req->fd = remote_fd;
+ req->offset = offset;
+ req->size = size;
+ memcpy(req->gfid, fd->inode->gfid, 16);
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_ipc (xlator_t *this, gfs3_ipc_req *req, int32_t cmd,
+ dict_t *xdata)
+{
+ int op_errno = ESTALE;
+
+ req->op = cmd;
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_seek (xlator_t *this, gfs3_seek_req *req, fd_t *fd,
+ off_t offset, gf_seek_what_t what, dict_t *xdata)
+{
+ int64_t remote_fd = -1;
+ int op_errno = ESTALE;
+
+ CLIENT_GET_REMOTE_FD (this, fd, DEFAULT_REMOTE_FD,
+ remote_fd, op_errno, out);
+
+ memcpy (req->gfid, fd->inode->gfid, 16);
+ req->fd = remote_fd;
+ req->offset = offset;
+ req->what = what;
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+
+ return 0;
+out:
+ return -op_errno;
+}
+
+int
+client_pre_lease (xlator_t *this, gfs3_lease_req *req, loc_t *loc,
+ struct gf_lease *lease, dict_t *xdata)
+{
+ int ret = 0;
+ int op_errno = 0;
+
+ if (!(loc && loc->inode))
+ goto out;
+
+ if (!gf_uuid_is_null (loc->inode->gfid))
+ memcpy (req->gfid, loc->inode->gfid, 16);
+ else
+ memcpy (req->gfid, loc->gfid, 16);
+
+ GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
+ !gf_uuid_is_null (*((uuid_t *)req->gfid)),
+ out, op_errno, EINVAL);
+
+ gf_proto_lease_from_lease (&req->lease, lease);
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&req->xdata.xdata_val),
+ req->xdata.xdata_len, op_errno, out);
+out:
+ return -op_errno;
+}
+
+/* processing done after fop responses are obtained */
+int
+client_post_stat (xlator_t *this, gfs3_stat_rsp *rsp, struct iatt *iatt,
+ dict_t **xdata)
+{
+ int ret = 0;
+
+ if (-1 != rsp->op_ret) {
+ gf_stat_to_iatt (&rsp->stat, iatt);
+ }
+
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+
+out:
+ return ret;
+}
+
+int
+client_post_readlink (xlator_t *this, gfs3_readlink_rsp *rsp,
+ struct iatt *iatt, dict_t **xdata)
+{
+ int ret = 0;
+
+ if (-1 != rsp->op_ret) {
+ gf_stat_to_iatt (&rsp->buf, iatt);
+ }
+
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+
+out:
+ return ret;
+}
+
+int
+client_post_mknod (xlator_t *this, gfs3_mknod_rsp *rsp, struct iatt *stbuf,
+ struct iatt *preparent, struct iatt *postparent,
+ dict_t **xdata)
+{
+ int ret = 0;
+
+ if (-1 != rsp->op_ret) {
+ gf_stat_to_iatt (&rsp->stat, stbuf);
+ gf_stat_to_iatt (&rsp->preparent, preparent);
+ gf_stat_to_iatt (&rsp->postparent, postparent);
+ }
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+
+out:
+ return ret;
+}
+
+int
+client_post_mkdir (xlator_t *this, gfs3_mkdir_rsp *rsp, struct iatt *stbuf,
+ struct iatt *preparent, struct iatt *postparent,
+ dict_t **xdata)
+{
+ int ret = 0;
+
+ if (-1 != rsp->op_ret) {
+ gf_stat_to_iatt (&rsp->stat, stbuf);
+ gf_stat_to_iatt (&rsp->preparent, preparent);
+ gf_stat_to_iatt (&rsp->postparent, postparent);
+ }
+
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+
+out:
+ return ret;
+}
+
+int
+client_post_unlink (xlator_t *this, gfs3_unlink_rsp *rsp,
+ struct iatt *preparent, struct iatt *postparent,
+ dict_t **xdata)
+{
+ int ret = 0;
+
+ if (-1 != rsp->op_ret) {
+ gf_stat_to_iatt (&rsp->preparent, preparent);
+ gf_stat_to_iatt (&rsp->postparent, postparent);
+ }
+
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+out:
+ return ret;
+}
+
+int
+client_post_rmdir (xlator_t *this, gfs3_rmdir_rsp *rsp,
+ struct iatt *preparent, struct iatt *postparent,
+ dict_t **xdata)
+{
+ int ret = 0;
+
+ if (-1 != rsp->op_ret) {
+ gf_stat_to_iatt (&rsp->preparent, preparent);
+ gf_stat_to_iatt (&rsp->postparent, postparent);
+ }
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+
+out:
+ return ret;
+}
+
+int
+client_post_symlink (xlator_t *this, gfs3_symlink_rsp *rsp, struct iatt *stbuf,
+ struct iatt *preparent, struct iatt *postparent,
+ dict_t **xdata)
+{
+ int ret = 0;
+
+ if (-1 != rsp->op_ret) {
+ gf_stat_to_iatt (&rsp->stat, stbuf);
+ gf_stat_to_iatt (&rsp->preparent, preparent);
+ gf_stat_to_iatt (&rsp->postparent, postparent);
+ }
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+out:
+ return ret;
+}
+
+int
+client_post_rename (xlator_t *this, gfs3_rename_rsp *rsp, struct iatt *stbuf,
+ struct iatt *preoldparent, struct iatt *postoldparent,
+ struct iatt *prenewparent, struct iatt *postnewparent,
+ dict_t **xdata)
+{
+ int ret = 0;
+
+ if (-1 != rsp->op_ret) {
+ gf_stat_to_iatt (&rsp->stat, stbuf);
+
+ gf_stat_to_iatt (&rsp->preoldparent, preoldparent);
+ gf_stat_to_iatt (&rsp->postoldparent, postoldparent);
+
+ gf_stat_to_iatt (&rsp->prenewparent, prenewparent);
+ gf_stat_to_iatt (&rsp->postnewparent, postnewparent);
+ }
+
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+out:
+ return ret;
+}
+
+int
+client_post_link (xlator_t *this, gfs3_link_rsp *rsp, struct iatt *stbuf,
+ struct iatt *preparent, struct iatt *postparent,
+ dict_t **xdata)
+{
+ int ret = 0;
+
+ if (-1 != rsp->op_ret) {
+ gf_stat_to_iatt (&rsp->stat, stbuf);
+ gf_stat_to_iatt (&rsp->preparent, preparent);
+ gf_stat_to_iatt (&rsp->postparent, postparent);
+ }
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+out:
+ return ret;
+}
+
+int
+client_post_truncate (xlator_t *this, gfs3_truncate_rsp *rsp,
+ struct iatt *prestat, struct iatt *poststat,
+ dict_t **xdata)
+{
+ int ret = 0;
+
+ if (-1 != rsp->op_ret) {
+ gf_stat_to_iatt (&rsp->prestat, prestat);
+ gf_stat_to_iatt (&rsp->poststat, poststat);
+ }
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+out:
+ return ret;
+}
+
+int
+client_post_open (xlator_t *this, gfs3_open_rsp *rsp, dict_t **xdata)
+{
+ int ret = 0;
+
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+out:
+ return ret;
+}
+
+int
+client_post_readv (xlator_t *this, gfs3_read_rsp *rsp, struct iobref **iobref,
+ struct iobref *rsp_iobref, struct iatt *stat,
+ struct iovec *vector, struct iovec *rsp_vector,
+ int *rspcount, dict_t **xdata)
+{
+ int ret = 0;
+
+ if (rsp->op_ret != -1) {
+ *iobref = rsp_iobref;
+ gf_stat_to_iatt (&rsp->stat, stat);
+
+ vector[0].iov_len = rsp->op_ret;
+ if (rsp->op_ret > 0)
+ vector[0].iov_base = rsp_vector->iov_base;
+ *rspcount = 1;
+ }
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+
+#ifdef GF_TESTING_IO_XDATA
+ dict_dump_to_log (xdata);
+#endif
+out:
+ return ret;
+}
+
+int
+client_post_writev (xlator_t *this, gfs3_write_rsp *rsp, struct iatt *prestat,
+ struct iatt *poststat, dict_t **xdata)
+{
+ int ret = 0;
+
+ if (-1 != rsp->op_ret) {
+ gf_stat_to_iatt (&rsp->prestat, prestat);
+ gf_stat_to_iatt (&rsp->poststat, poststat);
+ }
+
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+
+out:
+ return ret;
+}
+
+int
+client_post_statfs (xlator_t *this, gfs3_statfs_rsp *rsp,
+ struct statvfs *statfs, dict_t **xdata)
+{
+ int ret = 0;
+
+ if (-1 != rsp->op_ret) {
+ gf_statfs_to_statfs (&rsp->statfs, statfs);
+ }
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+out:
+ return ret;
+}
+
+int
+client_post_flush (xlator_t *this, gf_common_rsp *rsp, dict_t **xdata)
+{
+ int ret = 0;
+
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+
+out:
+ return ret;
+}
+
+int
+client_post_fsync (xlator_t *this, gfs3_fsync_rsp *rsp,
+ struct iatt *prestat, struct iatt *poststat,
+ dict_t **xdata)
+{
+ int ret = 0;
+
+ if (-1 != rsp->op_ret) {
+ gf_stat_to_iatt (&rsp->prestat, prestat);
+ gf_stat_to_iatt (&rsp->poststat, poststat);
+ }
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+out:
+ return ret;
+}
+
+int
+client_post_setxattr (xlator_t *this, gf_common_rsp *rsp, dict_t **xdata)
+{
+ int ret = 0;
+
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+out:
+ return ret;
+}
+
+int
+client_post_getxattr (xlator_t *this, gfs3_getxattr_rsp *rsp, dict_t **dict,
+ dict_t **xdata)
+{
+ int op_errno = 0;
+ int ret = 0;
+
+ if (-1 != rsp->op_ret) {
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *dict,
+ (rsp->dict.dict_val),
+ (rsp->dict.dict_len), rsp->op_ret,
+ op_errno, out);
+ }
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ op_errno, out);
+
+out:
+ return -op_errno;
+}
+
+int
+client_post_removexattr (xlator_t *this, gf_common_rsp *rsp,
+ dict_t **xdata)
+{
+ int ret = 0;
+
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+out:
+ return ret;
+}
+
+int
+client_post_opendir (xlator_t *this, gfs3_opendir_rsp *rsp, dict_t **xdata)
+{
+ int ret = 0;
+
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+out:
+ return ret;
+}
+
+int
+client_post_fsyncdir (xlator_t *this, gf_common_rsp *rsp, dict_t **xdata)
+{
+ int ret = 0;
+
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+out:
+ return ret;
+}
+
+int
+client_post_access (xlator_t *this, gf_common_rsp *rsp, dict_t **xdata)
+{
+ int ret = 0;
+
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+out:
+ return ret;
+}
+
+int
+client_post_create (xlator_t *this, gfs3_create_rsp *rsp,
+ struct iatt *stbuf, struct iatt *preparent,
+ struct iatt *postparent,
+ clnt_local_t *local, dict_t **xdata)
+{
+ int ret = 0;
+
+ if (-1 != rsp->op_ret) {
+ gf_stat_to_iatt (&rsp->stat, stbuf);
+
+ gf_stat_to_iatt (&rsp->preparent, preparent);
+ gf_stat_to_iatt (&rsp->postparent, postparent);
+ gf_uuid_copy (local->loc.gfid, stbuf->ia_gfid);
+ }
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+out:
+ return ret;
+}
+
+int
+client_post_ftruncate (xlator_t *this, gfs3_ftruncate_rsp *rsp,
+ struct iatt *prestat, struct iatt *poststat,
+ dict_t **xdata)
+{
+ int ret = 0;
+
+ if (-1 != rsp->op_ret) {
+ gf_stat_to_iatt (&rsp->prestat, prestat);
+ gf_stat_to_iatt (&rsp->poststat, poststat);
+ }
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+out:
+ return ret;
+}
+
+int
+client_post_fstat (xlator_t *this, gfs3_fstat_rsp *rsp, struct iatt *stat,
+ dict_t **xdata)
+{
+ int ret = 0;
+
+ if (-1 != rsp->op_ret) {
+ gf_stat_to_iatt (&rsp->stat, stat);
+ }
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+out:
+ return -ret;
+}
+
+int
+client_post_lk (xlator_t *this, gfs3_lk_rsp *rsp, struct gf_flock *lock,
+ dict_t **xdata)
+{
+ int ret = 0;
+
+ if (rsp->op_ret >= 0) {
+ gf_proto_flock_to_flock (&rsp->flock, lock);
+ }
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+out:
+ return ret;
+}
+
+int
+client_post_lookup (xlator_t *this, gfs3_lookup_rsp *rsp, struct iatt *stbuf,
+ struct iatt *postparent, dict_t **xdata)
+{
+ gf_stat_to_iatt (&rsp->postparent, postparent);
+ gf_stat_to_iatt (&rsp->stat, stbuf);
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), rsp->op_ret,
+ rsp->op_errno, out);
+
+out:
+ return rsp->op_ret;
+}
+
+int
+client_post_readdir (xlator_t *this, gfs3_readdir_rsp *rsp,
+ gf_dirent_t *entries, dict_t **xdata)
+{
+ int ret = 0;
+
+ if (rsp->op_ret > 0) {
+ unserialize_rsp_dirent (this, rsp, entries);
+ }
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+
+out:
+ return ret;
+}
+
+int
+client_post_inodelk (xlator_t *this, gf_common_rsp *rsp, dict_t **xdata)
+{
+ int ret = 0;
+
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+
+out:
+ return ret;
+}
+
+int
+client_post_finodelk (xlator_t *this, gf_common_rsp *rsp, dict_t **xdata)
+{
+ int ret = 0;
+
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+
+out:
+ return ret;
+}
+
+int
+client_post_entrylk (xlator_t *this, gf_common_rsp *rsp, dict_t **xdata)
+{
+ int ret = 0;
+
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+
+out:
+ return ret;
+}
+
+int
+client_post_fentrylk (xlator_t *this, gf_common_rsp *rsp, dict_t **xdata)
+{
+ int ret = 0;
+
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+
+out:
+ return ret;
+}
+
+int
+client_post_xattrop (xlator_t *this, gfs3_xattrop_rsp *rsp, dict_t **dict,
+ dict_t **xdata)
+{
+ int op_errno = 0;
+ int ret = 0;
+
+ if (-1 != rsp->op_ret) {
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *dict,
+ (rsp->dict.dict_val),
+ (rsp->dict.dict_len), rsp->op_ret,
+ op_errno, out);
+ }
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ op_errno, out);
+
+out:
+ return -op_errno;
+}
+
+int
+client_post_fxattrop (xlator_t *this, gfs3_fxattrop_rsp *rsp, dict_t **dict,
+ dict_t **xdata)
+{
+ int op_errno = 0;
+ int ret = 0;
+
+ if (-1 != rsp->op_ret) {
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *dict,
+ (rsp->dict.dict_val),
+ (rsp->dict.dict_len), rsp->op_ret,
+ op_errno, out);
+ }
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ op_errno, out);
+
+out:
+ return -op_errno;
+}
+
+int
+client_post_fgetxattr (xlator_t *this, gfs3_fgetxattr_rsp *rsp, dict_t **dict,
+ dict_t **xdata)
+{
+ int op_errno = 0;
+ int ret = 0;
+
+ if (-1 != rsp->op_ret) {
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *dict,
+ (rsp->dict.dict_val),
+ (rsp->dict.dict_len), rsp->op_ret,
+ op_errno, out);
+ }
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ op_errno, out);
+
+out:
+ return -op_errno;
+}
+
+int
+client_post_fsetxattr (xlator_t *this, gf_common_rsp *rsp, dict_t **xdata)
+{
+ int ret = 0;
+
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+out:
+ return ret;
+}
+
+int
+client_post_rchecksum (xlator_t *this, gfs3_rchecksum_rsp *rsp, dict_t **xdata)
+{
+ int ret = 0;
+
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+out:
+ return ret;
+}
+
+int
+client_post_setattr (xlator_t *this, gfs3_setattr_rsp *rsp,
+ struct iatt *prestat, struct iatt *poststat,
+ dict_t **xdata)
+{
+ int ret = 0;
+
+ 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:
+ return ret;
+}
+
+int
+client_post_fsetattr (xlator_t *this, gfs3_fsetattr_rsp *rsp,
+ struct iatt *prestat, struct iatt *poststat,
+ dict_t **xdata)
+{
+ int ret = 0;
+
+ 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:
+ return ret;
+}
+
+int
+client_post_readdirp (xlator_t *this, gfs3_readdirp_rsp *rsp,
+ fd_t *fd, gf_dirent_t *entries,
+ dict_t **xdata)
+{
+ int ret = 0;
+
+ if (rsp->op_ret > 0) {
+ unserialize_rsp_direntp (this, fd, rsp, entries);
+ }
+
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+out:
+ return ret;
+}
+
+int
+client_post_fremovexattr (xlator_t *this, gf_common_rsp *rsp,
+ dict_t **xdata)
+{
+ int ret = 0;
+
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+out:
+ return ret;
+}
+
+int
+client_post_fallocate (xlator_t *this, gfs3_fallocate_rsp *rsp,
+ struct iatt *prestat, struct iatt *poststat,
+ dict_t **xdata)
+{
+ int ret = 0;
+
+ 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:
+ return ret;
+}
+
+int
+client_post_discard (xlator_t *this, gfs3_discard_rsp *rsp,
+ struct iatt *prestat,
+ struct iatt *poststat, dict_t **xdata)
+{
+ int ret = 0;
+
+ 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:
+ return ret;
+}
+
+int
+client_post_zerofill (xlator_t *this, gfs3_zerofill_rsp *rsp,
+ struct iatt *prestat, struct iatt *poststat,
+ dict_t **xdata)
+{
+ int ret = 0;
+
+ 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:
+ return ret;
+}
+
+int
+client_post_ipc (xlator_t *this, gfs3_ipc_rsp *rsp, dict_t **xdata)
+{
+ int ret = 0;
+
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+out:
+ return ret;
+}
+
+int
+client_post_seek (xlator_t *this, gfs3_seek_rsp *rsp, dict_t **xdata)
+{
+ int ret = 0;
+
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+out:
+ return ret;
+}
+
+int
+client_post_lease (xlator_t *this, gfs3_lease_rsp *rsp, struct gf_lease *lease,
+ dict_t **xdata)
+{
+ int ret = 0;
+
+ if (rsp->op_ret >= 0) {
+ gf_proto_lease_to_lease (&rsp->lease, lease);
+ }
+
+ GF_PROTOCOL_DICT_UNSERIALIZE (this, *xdata, (rsp->xdata.xdata_val),
+ (rsp->xdata.xdata_len), ret,
+ rsp->op_errno, out);
+out:
+ return ret;
+}
diff --git a/xlators/protocol/client/src/client-common.h b/xlators/protocol/client/src/client-common.h
new file mode 100644
index 00000000000..2298fa4e16d
--- /dev/null
+++ b/xlators/protocol/client/src/client-common.h
@@ -0,0 +1,403 @@
+/*
+ Copyright (c); 2016 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_COMMON_H__
+#define __CLIENT_COMMON_H__
+
+#include "dict.h"
+#include "xlator.h"
+#include "rpc-common-xdr.h"
+#include "glusterfs3-xdr.h"
+#include "glusterfs3.h"
+#include "client.h"
+
+int
+client_pre_stat (xlator_t *this, gfs3_stat_req *req, loc_t *loc,
+ dict_t *xdata);
+
+int
+client_pre_readlink (xlator_t *this, gfs3_readlink_req *req, loc_t *loc,
+ size_t size, dict_t *xdata);
+
+int
+client_pre_mknod (xlator_t *this, gfs3_mknod_req *req, loc_t *loc,
+ mode_t mode, dev_t rdev, mode_t umask, dict_t *xdata);
+
+int
+client_pre_mkdir (xlator_t *this, gfs3_mkdir_req *req, loc_t *loc,
+ mode_t mode, mode_t umask, dict_t *xdata);
+
+int
+client_pre_unlink (xlator_t *this, gfs3_unlink_req *req, loc_t *loc,
+ int32_t flags, dict_t *xdata);
+
+int
+client_pre_rmdir (xlator_t *this, gfs3_rmdir_req *req, loc_t *loc,
+ int32_t flags, dict_t *xdata);
+
+int
+client_pre_symlink (xlator_t *this, gfs3_symlink_req *req, loc_t *loc,
+ const char *linkname, mode_t umask, dict_t *xdata);
+
+int
+client_pre_rename (xlator_t *this, gfs3_rename_req *req, loc_t *oldloc,
+ loc_t *newloc, dict_t *xdata);
+
+int
+client_pre_link (xlator_t *this,
+ gfs3_link_req *req, loc_t *oldloc, loc_t *newloc,
+ dict_t *xdata);
+
+int
+client_pre_truncate (xlator_t *this, gfs3_truncate_req *req,
+ loc_t *loc, off_t offset, dict_t *xdata);
+
+int
+client_pre_open (xlator_t *this, gfs3_open_req *req, loc_t *loc, fd_t *fd,
+ int32_t flags, dict_t *xdata);
+
+int
+client_pre_readv (xlator_t *this, gfs3_read_req *req, fd_t *fd, size_t size,
+ off_t offset, int32_t flags, dict_t *xdata);
+
+int
+client_pre_writev (xlator_t *this, gfs3_write_req *req,
+ fd_t *fd, size_t size, off_t offset, int32_t flags,
+ dict_t *xdata);
+
+int
+client_pre_statfs (xlator_t *this, gfs3_statfs_req *req, loc_t *loc,
+ dict_t *xdata);
+
+int
+client_pre_flush (xlator_t *this, gfs3_flush_req *req, fd_t *fd, dict_t *xdata);
+
+int
+client_pre_fsync (xlator_t *this, gfs3_fsync_req *req, fd_t *fd,
+ int32_t flags, dict_t *xdata);
+
+int
+client_pre_setxattr (xlator_t *this, gfs3_setxattr_req *req, loc_t *loc,
+ dict_t *xattr, int32_t flags, dict_t *xdata);
+
+int
+client_pre_getxattr (xlator_t *this, gfs3_getxattr_req *req, loc_t *loc,
+ const char *name, dict_t *xdata);
+
+int
+client_pre_removexattr (xlator_t *this, gfs3_removexattr_req *req,
+ loc_t *loc, const char *name, dict_t *xdata);
+
+int
+client_pre_opendir (xlator_t *this,
+ gfs3_opendir_req *req, loc_t *loc,
+ fd_t *fd, dict_t *xdata);
+
+int
+client_pre_fsyncdir (xlator_t *this, gfs3_fsyncdir_req *req, fd_t *fd,
+ int32_t flags, dict_t *xdata);
+
+int
+client_pre_access (xlator_t *this, gfs3_access_req *req, loc_t *loc,
+ int32_t mask, dict_t *xdata);
+
+int
+client_pre_create (xlator_t *this, gfs3_create_req *req,
+ loc_t *loc, fd_t *fd, mode_t mode,
+ int32_t flags, mode_t umask, dict_t *xdata);
+
+int
+client_pre_ftruncate (xlator_t *this, gfs3_ftruncate_req *req, fd_t *fd,
+ off_t offset, dict_t *xdata);
+
+int
+client_pre_fstat (xlator_t *this, gfs3_fstat_req *req, fd_t *fd,
+ dict_t *xdata);
+
+int
+client_pre_lk (xlator_t *this, gfs3_lk_req *req,
+ int32_t cmd, struct gf_flock *flock, fd_t *fd, dict_t *xdata);
+
+int
+client_pre_lookup (xlator_t *this, gfs3_lookup_req *req, loc_t *loc,
+ dict_t *xdata);
+
+int
+client_pre_readdir (xlator_t *this, gfs3_readdir_req *req, fd_t *fd,
+ size_t size, off_t offset, dict_t *xdata);
+
+int
+client_pre_inodelk (xlator_t *this, gfs3_inodelk_req *req, loc_t *loc,
+ int cmd, struct gf_flock *flock, const char *volume,
+ dict_t *xdata);
+
+int
+client_pre_finodelk (xlator_t *this, gfs3_finodelk_req *req, fd_t *fd,
+ int cmd, struct gf_flock *flock, const char *volume,
+ dict_t *xdata);
+
+int
+client_pre_entrylk (xlator_t *this, gfs3_entrylk_req *req, loc_t *loc,
+ entrylk_cmd cmd_entrylk, entrylk_type type,
+ const char *volume, const char *basename, dict_t *xdata);
+
+int
+client_pre_fentrylk (xlator_t *this, gfs3_fentrylk_req *req, fd_t *fd,
+ entrylk_cmd cmd_entrylk, entrylk_type type,
+ const char *volume, const char *basename, dict_t *xdata);
+
+int
+client_pre_xattrop (xlator_t *this, gfs3_xattrop_req *req, loc_t *loc,
+ dict_t *xattr, int32_t flags, dict_t *xdata);
+
+int
+client_pre_fxattrop (xlator_t *this, gfs3_fxattrop_req *req, fd_t *fd,
+ dict_t *xattr, int32_t flags, dict_t *xdata);
+
+int
+client_pre_fgetxattr (xlator_t *this, gfs3_fgetxattr_req *req, fd_t *fd,
+ const char *name, dict_t *xdata);
+
+int
+client_pre_fsetxattr (xlator_t *this, gfs3_fsetxattr_req *req, fd_t *fd,
+ int32_t flags, dict_t *xattr, dict_t *xdata);
+int
+client_pre_seek (xlator_t *this, gfs3_seek_req *req, fd_t *fd,
+ off_t offset, gf_seek_what_t what, dict_t *xdata);
+
+int
+client_pre_rchecksum (xlator_t *this, gfs3_rchecksum_req *req, fd_t *fd,
+ int32_t len, off_t offset, dict_t *xdata);
+
+int
+client_pre_setattr (xlator_t *this, gfs3_setattr_req *req, loc_t *loc,
+ int32_t valid, struct iatt *stbuf, dict_t *xdata);
+int
+client_pre_fsetattr (xlator_t *this, gfs3_fsetattr_req *req, fd_t *fd,
+ int32_t valid, struct iatt *stbuf, dict_t *xdata);
+
+int
+client_pre_readdirp (xlator_t *this, gfs3_readdirp_req *req, fd_t *fd,
+ size_t size, off_t offset, dict_t *xdata);
+
+int
+client_pre_fremovexattr (xlator_t *this, gfs3_fremovexattr_req *req, fd_t *fd,
+ const char *name, dict_t *xdata);
+
+int
+client_pre_fallocate (xlator_t *this, gfs3_fallocate_req *req, fd_t *fd,
+ int32_t flags, off_t offset, size_t size, dict_t *xdata);
+int
+client_pre_discard (xlator_t *this, gfs3_discard_req *req, fd_t *fd,
+ off_t offset, size_t size, dict_t *xdata);
+int
+client_pre_zerofill (xlator_t *this, gfs3_zerofill_req *req, fd_t *fd,
+ off_t offset, size_t size, dict_t *xdata);
+int
+client_pre_ipc (xlator_t *this, gfs3_ipc_req *req, int32_t cmd,
+ dict_t *xdata);
+
+int
+client_pre_lease (xlator_t *this, gfs3_lease_req *req, loc_t *loc,
+ struct gf_lease *lease, dict_t *xdata);
+
+int
+client_post_stat (xlator_t *this, gfs3_stat_rsp *rsp, struct iatt *iatt,
+ dict_t **xdata);
+
+int
+client_post_readlink (xlator_t *this, gfs3_readlink_rsp *rsp,
+ struct iatt *iatt, dict_t **xdata);
+
+int
+client_post_mknod (xlator_t *this, gfs3_mknod_rsp *rsp, struct iatt *stbuf,
+ struct iatt *preparent, struct iatt *postparent,
+ dict_t **xdata);
+
+int
+client_post_mkdir (xlator_t *this, gfs3_mkdir_rsp *rsp, struct iatt *stbuf,
+ struct iatt *preparent, struct iatt *postparent,
+ dict_t **xdata);
+
+int
+client_post_unlink (xlator_t *this, gfs3_unlink_rsp *rsp,
+ struct iatt *preparent, struct iatt *postparent,
+ dict_t **xdata);
+
+int
+client_post_rmdir (xlator_t *this, gfs3_rmdir_rsp *rsp,
+ struct iatt *preparent, struct iatt *postparent,
+ dict_t **xdata);
+
+int
+client_post_symlink (xlator_t *this, gfs3_symlink_rsp *rsp, struct iatt *stbuf,
+ struct iatt *preparent, struct iatt *postparent,
+ dict_t **xdata);
+
+int
+client_post_rename (xlator_t *this, gfs3_rename_rsp *rsp, struct iatt *stbuf,
+ struct iatt *preoldparent, struct iatt *postoldparent,
+ struct iatt *prenewparent, struct iatt *postnewparent,
+ dict_t **xdata);
+int
+client_post_link (xlator_t *this, gfs3_link_rsp *rsp, struct iatt *stbuf,
+ struct iatt *preparent, struct iatt *postparent,
+ dict_t **xdata);
+
+int
+client_post_truncate (xlator_t *this, gfs3_truncate_rsp *rsp,
+ struct iatt *prestat, struct iatt *poststat,
+ dict_t **xdata);
+
+int
+client_post_open (xlator_t *this, gfs3_open_rsp *rsp, dict_t **xdata);
+
+int
+client_post_readv (xlator_t *this, gfs3_read_rsp *rsp, struct iobref **iobref,
+ struct iobref *rsp_iobref, struct iatt *stat,
+ struct iovec *vector, struct iovec *rsp_vector,
+ int *rspcount, dict_t **xdata);
+
+int
+client_post_writev (xlator_t *this, gfs3_write_rsp *rsp, struct iatt *prestat,
+ struct iatt *poststat, dict_t **xdata);
+
+int
+client_post_statfs (xlator_t *this, gfs3_statfs_rsp *rsp,
+ struct statvfs *statfs, dict_t **xdata);
+
+int
+client_post_flush (xlator_t *this, gf_common_rsp *rsp, dict_t **xdata);
+
+int
+client_post_fsync (xlator_t *this, gfs3_fsync_rsp *rsp,
+ struct iatt *prestat, struct iatt *poststat,
+ dict_t **xdata);
+int
+client_post_setxattr (xlator_t *this, gf_common_rsp *rsp, dict_t **xdata);
+
+int
+client_post_getxattr (xlator_t *this, gfs3_getxattr_rsp *rsp, dict_t **dict,
+ dict_t **xdata);
+
+int
+client_post_removexattr (xlator_t *this, gf_common_rsp *rsp,
+ dict_t **xdata);
+
+int
+client_post_opendir (xlator_t *this, gfs3_opendir_rsp *rsp, dict_t **xdata);
+
+int
+client_post_fsyncdir (xlator_t *this, gf_common_rsp *rsp, dict_t **xdata);
+
+int
+client_post_access (xlator_t *this, gf_common_rsp *rsp, dict_t **xdata);
+
+int
+client_post_create (xlator_t *this, gfs3_create_rsp *rsp,
+ struct iatt *stbuf, struct iatt *preparent,
+ struct iatt *postparent,
+ clnt_local_t *local, dict_t **xdata);
+
+int
+client_post_ftruncate (xlator_t *this, gfs3_ftruncate_rsp *rsp,
+ struct iatt *prestat, struct iatt *poststat,
+ dict_t **xdata);
+
+int
+client_post_fstat (xlator_t *this, gfs3_fstat_rsp *rsp, struct iatt *stat,
+ dict_t **xdata);
+
+int
+client_post_lk (xlator_t *this, gfs3_lk_rsp *rsp, struct gf_flock *lock,
+ dict_t **xdata);
+
+int
+client_post_lookup (xlator_t *this, gfs3_lookup_rsp *rsp, struct iatt *stbuf,
+ struct iatt *postparent, dict_t **xdata);
+
+int
+client_post_readdir (xlator_t *this, gfs3_readdir_rsp *rsp,
+ gf_dirent_t *entries, dict_t **xdata);
+
+int
+client_post_inodelk (xlator_t *this, gf_common_rsp *rsp, dict_t **xdata);
+
+int
+client_post_finodelk (xlator_t *this, gf_common_rsp *rsp, dict_t **xdata);
+
+int
+client_post_entrylk (xlator_t *this, gf_common_rsp *rsp, dict_t **xdata);
+
+int
+client_post_fentrylk (xlator_t *this, gf_common_rsp *rsp, dict_t **xdata);
+
+int
+client_post_xattrop (xlator_t *this, gfs3_xattrop_rsp *rsp, dict_t **dict,
+ dict_t **xdata);
+
+int
+client_post_fxattrop (xlator_t *this, gfs3_fxattrop_rsp *rsp, dict_t **dict,
+ dict_t **xdata);
+
+int
+client_post_fgetxattr (xlator_t *this, gfs3_fgetxattr_rsp *rsp, dict_t **dict,
+ dict_t **xdata);
+
+int
+client_post_fsetxattr (xlator_t *this, gf_common_rsp *rsp, dict_t **xdata);
+
+int
+client_post_rchecksum (xlator_t *this, gfs3_rchecksum_rsp *rsp, dict_t **xdata);
+
+int
+client_post_setattr (xlator_t *this, gfs3_setattr_rsp *rsp,
+ struct iatt *prestat, struct iatt *poststat,
+ dict_t **xdata);
+
+int
+client_post_fsetattr (xlator_t *this, gfs3_fsetattr_rsp *rsp,
+ struct iatt *prestat, struct iatt *poststat,
+ dict_t **xdata);
+
+int
+client_post_readdirp (xlator_t *this, gfs3_readdirp_rsp *rsp,
+ fd_t *fd, gf_dirent_t *entries,
+ dict_t **xdata);
+
+int
+client_post_fremovexattr (xlator_t *this, gf_common_rsp *rsp,
+ dict_t **xdata);
+
+int
+client_post_fallocate (xlator_t *this, gfs3_fallocate_rsp *rsp,
+ struct iatt *prestat, struct iatt *poststat,
+ dict_t **xdata);
+
+int
+client_post_discard (xlator_t *this, gfs3_discard_rsp *rsp,
+ struct iatt *prestat,
+ struct iatt *poststat, dict_t **xdata);
+
+int
+client_post_zerofill (xlator_t *this, gfs3_zerofill_rsp *rsp,
+ struct iatt *prestat, struct iatt *poststat,
+ dict_t **xdata);
+
+int
+client_post_ipc (xlator_t *this, gfs3_ipc_rsp *rsp, dict_t **xdata);
+
+int
+client_post_seek (xlator_t *this, gfs3_seek_rsp *rsp, dict_t **xdata);
+
+int
+client_post_lease (xlator_t *this, gfs3_lease_rsp *rsp, struct gf_lease *lease,
+ dict_t **xdata);
+#endif /* __CLIENT_COMMON_H__ */
diff --git a/xlators/protocol/client/src/client-helpers.c b/xlators/protocol/client/src/client-helpers.c
index 104a13d3786..804b4028803 100644
--- a/xlators/protocol/client/src/client-helpers.c
+++ b/xlators/protocol/client/src/client-helpers.c
@@ -354,6 +354,7 @@ client_fd_fop_prepare_local (call_frame_t *frame, fd_t *fd, int64_t remote_fd)
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-rpc-fops.c b/xlators/protocol/client/src/client-rpc-fops.c
index 9e39ebd7242..b09c169b806 100644
--- a/xlators/protocol/client/src/client-rpc-fops.c
+++ b/xlators/protocol/client/src/client-rpc-fops.c
@@ -14,6 +14,8 @@
#include "glusterfs3.h"
#include "compat-errno.h"
#include "client-messages.h"
+#include "defaults.h"
+#include "client-common.h"
int32_t client3_getspec (call_frame_t *frame, xlator_t *this, void *data);
rpc_clnt_prog_t clnt3_3_fop_prog;
@@ -149,16 +151,10 @@ client3_3_symlink_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- if (-1 != rsp.op_ret) {
- gf_stat_to_iatt (&rsp.stat, &stbuf);
-
- gf_stat_to_iatt (&rsp.preparent, &preparent);
- gf_stat_to_iatt (&rsp.postparent, &postparent);
- }
-
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
+ ret = client_post_symlink (this, &rsp, &stbuf, &preparent,
+ &postparent, &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
@@ -224,16 +220,10 @@ client3_3_mknod_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- if (-1 != rsp.op_ret) {
- gf_stat_to_iatt (&rsp.stat, &stbuf);
-
- gf_stat_to_iatt (&rsp.preparent, &preparent);
- gf_stat_to_iatt (&rsp.postparent, &postparent);
- }
-
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
+ ret = client_post_mknod (this, &rsp, &stbuf, &preparent, &postparent,
+ &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1 &&
@@ -294,16 +284,10 @@ client3_3_mkdir_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- if (-1 != rsp.op_ret) {
- gf_stat_to_iatt (&rsp.stat, &stbuf);
-
- gf_stat_to_iatt (&rsp.preparent, &preparent);
- gf_stat_to_iatt (&rsp.postparent, &postparent);
- }
-
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
+ ret = client_post_mkdir (this, &rsp, &stbuf, &preparent, &postparent,
+ &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1 &&
@@ -447,10 +431,9 @@ client3_3_open_cbk (struct rpc_req *req, struct iovec *iov, int count,
}
}
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
-
+ ret = client_post_open (this, &rsp, &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
gf_msg (this->name, fop_log_level (GF_FOP_OPEN,
@@ -502,14 +485,9 @@ client3_3_stat_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- if (-1 != rsp.op_ret) {
- gf_stat_to_iatt (&rsp.stat, &iatt);
- }
-
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
-
+ ret = client_post_stat (this, &rsp, &iatt, &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
/* stale filehandles are possible during normal operations, no
@@ -568,13 +546,9 @@ client3_3_readlink_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- if (-1 != rsp.op_ret) {
- gf_stat_to_iatt (&rsp.buf, &iatt);
- }
-
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
+ ret = client_post_readlink (this, &rsp, &iatt, &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
@@ -637,14 +611,10 @@ client3_3_unlink_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- if (-1 != rsp.op_ret) {
- gf_stat_to_iatt (&rsp.preparent, &preparent);
- gf_stat_to_iatt (&rsp.postparent, &postparent);
- }
-
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
+ ret = client_post_unlink (this, &rsp, &preparent, &postparent,
+ &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
@@ -703,14 +673,10 @@ client3_3_rmdir_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- if (-1 != rsp.op_ret) {
- gf_stat_to_iatt (&rsp.preparent, &preparent);
- gf_stat_to_iatt (&rsp.postparent, &postparent);
- }
-
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
+ ret = client_post_rmdir (this, &rsp, &preparent, &postparent,
+ &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
@@ -765,14 +731,10 @@ client3_3_truncate_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- if (-1 != rsp.op_ret) {
- gf_stat_to_iatt (&rsp.prestat, &prestat);
- gf_stat_to_iatt (&rsp.poststat, &poststat);
- }
-
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
+ ret = client_post_truncate (this, &rsp, &prestat, &poststat,
+ &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
@@ -824,13 +786,9 @@ client3_3_statfs_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- if (-1 != rsp.op_ret) {
- gf_statfs_to_statfs (&rsp.statfs, &statfs);
- }
-
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
+ ret = client_post_statfs (this, &rsp, &statfs, &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
@@ -885,15 +843,9 @@ client3_3_writev_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- if (-1 != rsp.op_ret) {
- gf_stat_to_iatt (&rsp.prestat, &prestat);
- gf_stat_to_iatt (&rsp.poststat, &poststat);
- }
-
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
-
+ ret = client_post_writev (this, &rsp, &prestat, &poststat, &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
gf_msg (this->name, GF_LOG_WARNING,
@@ -954,10 +906,9 @@ client3_3_flush_cbk (struct rpc_req *req, struct iovec *iov, int count,
lkowner_utoa (&local->owner), ret);
}
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
-
+ ret = client_post_flush (this, &rsp, &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
gf_msg (this->name, fop_log_level (GF_FOP_FLUSH,
@@ -1009,14 +960,10 @@ client3_3_fsync_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- if (-1 != rsp.op_ret) {
- gf_stat_to_iatt (&rsp.prestat, &prestat);
- gf_stat_to_iatt (&rsp.poststat, &poststat);
- }
-
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
+ ret = client_post_fsync (this, &rsp, &prestat, &poststat,
+ &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
@@ -1067,9 +1014,9 @@ client3_3_setxattr_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
+ ret = client_post_setxattr (this, &rsp, &xdata);
+ if (ret < 0)
+ goto out;
out:
op_errno = gf_error_to_errno (rsp.op_errno);
@@ -1129,17 +1076,12 @@ client3_3_getxattr_cbk (struct rpc_req *req, struct iovec *iov, int count,
}
op_errno = gf_error_to_errno (rsp.op_errno);
- if (-1 != rsp.op_ret) {
- GF_PROTOCOL_DICT_UNSERIALIZE (frame->this, dict,
- (rsp.dict.dict_val),
- (rsp.dict.dict_len), rsp.op_ret,
- op_errno, out);
+ ret = client_post_getxattr (this, &rsp, &dict, &xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto out;
}
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- op_errno, out);
-
out:
if (rsp.op_ret == -1) {
if ((op_errno == ENOTSUP) || (op_errno == ENODATA) ||
@@ -1210,16 +1152,11 @@ client3_3_fgetxattr_cbk (struct rpc_req *req, struct iovec *iov, int count,
}
op_errno = gf_error_to_errno (rsp.op_errno);
- if (-1 != rsp.op_ret) {
- GF_PROTOCOL_DICT_UNSERIALIZE (frame->this, dict,
- (rsp.dict.dict_val),
- (rsp.dict.dict_len), rsp.op_ret,
- op_errno, out);
+ ret = client_post_fgetxattr (this, &rsp, &dict, &xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto out;
}
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- op_errno, out);
-
out:
if (rsp.op_ret == -1) {
if ((op_errno == ENOTSUP) || (op_errno == ERANGE) ||
@@ -1279,10 +1216,9 @@ client3_3_removexattr_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
-
+ ret = client_post_removexattr (this, &rsp, &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
if ((ENODATA == rsp.op_errno) || (ENOATTR == rsp.op_errno))
@@ -1337,10 +1273,9 @@ client3_3_fremovexattr_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
-
+ ret = client_post_fremovexattr (this, &rsp, &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
gf_msg (this->name, GF_LOG_WARNING,
@@ -1388,9 +1323,9 @@ client3_3_fsyncdir_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
+ ret = client_post_fsyncdir (this, &rsp, &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
@@ -1439,9 +1374,9 @@ client3_3_access_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
+ ret = client_post_access (this, &rsp, &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
@@ -1493,14 +1428,10 @@ client3_3_ftruncate_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- if (-1 != rsp.op_ret) {
- gf_stat_to_iatt (&rsp.prestat, &prestat);
- gf_stat_to_iatt (&rsp.poststat, &poststat);
- }
-
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
+ ret = client_post_ftruncate (this, &rsp, &prestat, &poststat,
+ &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
@@ -1551,13 +1482,9 @@ client3_3_fstat_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- if (-1 != rsp.op_ret) {
- gf_stat_to_iatt (&rsp.stat, &stat);
- }
-
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
+ ret = client_post_fstat (this, &rsp, &stat, &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
@@ -1611,6 +1538,9 @@ client3_3_inodelk_cbk (struct rpc_req *req, struct iovec *iov, int count,
(rsp.xdata.xdata_len), ret,
rsp.op_errno, out);
+ ret = client_post_inodelk (this, &rsp, &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
gf_msg (this->name, fop_log_level (GF_FOP_INODELK,
@@ -1659,10 +1589,9 @@ client3_3_finodelk_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
-
+ ret = client_post_finodelk (this, &rsp, &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
gf_msg (this->name, fop_log_level (GF_FOP_FINODELK,
@@ -1713,10 +1642,9 @@ client3_3_entrylk_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
-
+ ret = client_post_entrylk (this, &rsp, &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
gf_msg (this->name, fop_log_level (GF_FOP_ENTRYLK,
@@ -1765,9 +1693,9 @@ client3_3_fentrylk_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
+ ret = client_post_fentrylk (this, &rsp, &xdata);
+ if (ret < 0)
+ goto out;
out:
if ((rsp.op_ret == -1) &&
@@ -1823,17 +1751,11 @@ client3_3_xattrop_cbk (struct rpc_req *req, struct iovec *iov, int count,
}
op_errno = rsp.op_errno;
- if (-1 != rsp.op_ret) {
- GF_PROTOCOL_DICT_UNSERIALIZE (frame->this, dict,
- (rsp.dict.dict_val),
- (rsp.dict.dict_len), rsp.op_ret,
- op_errno, out);
+ ret = client_post_xattrop (this, &rsp, &dict, &xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto out;
}
-
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- op_errno, out);
-
out:
if (rsp.op_ret == -1) {
gf_msg (this->name, GF_LOG_WARNING,
@@ -1892,17 +1814,12 @@ client3_3_fxattrop_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
op_errno = rsp.op_errno;
- if (-1 != rsp.op_ret) {
- GF_PROTOCOL_DICT_UNSERIALIZE (frame->this, dict,
- (rsp.dict.dict_val),
- (rsp.dict.dict_len), rsp.op_ret,
- op_errno, out);
+ ret = client_post_fxattrop (this, &rsp, &dict, &xdata);
+ if (ret) {
+ rsp.op_ret = -1;
+ op_errno = -ret;
+ goto out;
}
-
- GF_PROTOCOL_DICT_UNSERIALIZE (frame->this, xdata,
- (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), rsp.op_ret,
- op_errno, out);
out:
if (rsp.op_ret == -1) {
@@ -1959,9 +1876,9 @@ client3_3_fsetxattr_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
+ ret = client_post_setxattr (this, &rsp, &xdata);
+ if (ret < 0)
+ goto out;
out:
op_errno = gf_error_to_errno (rsp.op_errno);
@@ -2017,15 +1934,9 @@ client3_3_fsetattr_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- if (-1 != rsp.op_ret) {
- gf_stat_to_iatt (&rsp.statpre, &prestat);
- gf_stat_to_iatt (&rsp.statpost, &poststat);
- }
-
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
-
+ ret = client_post_fsetattr (this, &rsp, &prestat, &poststat, &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
gf_msg (this->name, GF_LOG_WARNING,
@@ -2076,10 +1987,9 @@ client3_3_fallocate_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- if (-1 != rsp.op_ret) {
- gf_stat_to_iatt (&rsp.statpre, &prestat);
- gf_stat_to_iatt (&rsp.statpost, &poststat);
- }
+ ret = client_post_fallocate (this, &rsp, &prestat, &poststat, &xdata);
+ if (ret < 0)
+ goto out;
GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
(rsp.xdata.xdata_len), ret,
@@ -2134,14 +2044,9 @@ client3_3_discard_cbk(struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- if (-1 != rsp.op_ret) {
- gf_stat_to_iatt (&rsp.statpre, &prestat);
- gf_stat_to_iatt (&rsp.statpost, &poststat);
- }
-
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
+ ret = client_post_discard (this, &rsp, &prestat, &poststat, &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
@@ -2192,15 +2097,9 @@ client3_3_zerofill_cbk(struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- if (-1 != rsp.op_ret) {
- gf_stat_to_iatt (&rsp.statpre, &prestat);
- gf_stat_to_iatt (&rsp.statpost, &poststat);
- }
-
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
-
+ ret = client_post_zerofill (this, &rsp, &prestat, &poststat, &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
gf_msg (this->name, GF_LOG_WARNING,
@@ -2248,10 +2147,9 @@ client3_3_ipc_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
-
+ ret = client_post_ipc (this, &rsp, &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
gf_msg (this->name, GF_LOG_WARNING,
@@ -2300,9 +2198,9 @@ client3_3_seek_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
+ ret = client_post_seek (this, &rsp, &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
@@ -2355,14 +2253,9 @@ client3_3_setattr_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- if (-1 != rsp.op_ret) {
- gf_stat_to_iatt (&rsp.statpre, &prestat);
- gf_stat_to_iatt (&rsp.statpost, &poststat);
- }
-
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
+ ret = client_post_setattr (this, &rsp, &prestat, &poststat, &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
@@ -2422,11 +2315,11 @@ client3_3_create_cbk (struct rpc_req *req, struct iovec *iov, int count,
}
if (-1 != rsp.op_ret) {
- gf_stat_to_iatt (&rsp.stat, &stbuf);
-
- gf_stat_to_iatt (&rsp.preparent, &preparent);
- gf_stat_to_iatt (&rsp.postparent, &postparent);
- gf_uuid_copy (local->loc.gfid, stbuf.ia_gfid);
+ ret = client_post_create (this, &rsp, &stbuf,
+ &preparent, &postparent,
+ local, &xdata);
+ if (ret < 0)
+ goto out;
ret = client_add_fd_to_saved_fds (frame->this, fd, &local->loc,
local->flags, rsp.fd, 0);
if (ret) {
@@ -2436,9 +2329,6 @@ client3_3_create_cbk (struct rpc_req *req, struct iovec *iov, int count,
}
}
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
out:
if (rsp.op_ret == -1) {
@@ -2461,7 +2351,6 @@ out:
return 0;
}
-
int
client3_3_rchecksum_cbk (struct rpc_req *req, struct iovec *iov, int count,
void *myframe)
@@ -2492,9 +2381,9 @@ client3_3_rchecksum_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
+ ret = client_post_rchecksum (this, &rsp, &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
@@ -2555,13 +2444,9 @@ client3_3_lease_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- if (rsp.op_ret >= 0) {
- gf_proto_lease_to_lease (&rsp.lease, &lease);
- }
-
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
+ ret = client_post_lease (this, &rsp, &lease, &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
@@ -2615,7 +2500,9 @@ client3_3_lk_cbk (struct rpc_req *req, struct iovec *iov, int count,
}
if (rsp.op_ret >= 0) {
- gf_proto_flock_to_flock (&rsp.flock, &lock);
+ ret = client_post_lk (this, &rsp, &lock, &xdata);
+ if (ret < 0)
+ goto out;
}
/* Save the lock to the client lock cache to be able
@@ -2632,10 +2519,6 @@ client3_3_lk_cbk (struct rpc_req *req, struct iovec *iov, int count,
}
*/
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
-
out:
if ((rsp.op_ret == -1) &&
(EAGAIN != gf_error_to_errno (rsp.op_errno))) {
@@ -2691,14 +2574,9 @@ client3_3_readdir_cbk (struct rpc_req *req, struct iovec *iov, int count,
}
INIT_LIST_HEAD (&entries.list);
- if (rsp.op_ret > 0) {
- unserialize_rsp_dirent (this, &rsp, &entries);
- }
-
- GF_PROTOCOL_DICT_UNSERIALIZE (frame->this, xdata,
- (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
+ ret = client_post_readdir (this, &rsp, &entries, &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
@@ -2725,7 +2603,6 @@ out:
return 0;
}
-
int
client3_3_readdirp_cbk (struct rpc_req *req, struct iovec *iov, int count,
void *myframe)
@@ -2759,14 +2636,9 @@ client3_3_readdirp_cbk (struct rpc_req *req, struct iovec *iov, int count,
}
INIT_LIST_HEAD (&entries.list);
- if (rsp.op_ret > 0) {
- unserialize_rsp_direntp (this, local->fd, &rsp, &entries);
- }
-
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
-
+ ret = client_post_readdirp (this, &rsp, local->fd, &entries, &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
gf_msg (this->name, GF_LOG_WARNING,
@@ -2790,7 +2662,6 @@ out:
return 0;
}
-
int
client3_3_rename_cbk (struct rpc_req *req, struct iovec *iov, int count,
void *myframe)
@@ -2825,19 +2696,11 @@ client3_3_rename_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- if (-1 != rsp.op_ret) {
- gf_stat_to_iatt (&rsp.stat, &stbuf);
-
- gf_stat_to_iatt (&rsp.preoldparent, &preoldparent);
- gf_stat_to_iatt (&rsp.postoldparent, &postoldparent);
-
- gf_stat_to_iatt (&rsp.prenewparent, &prenewparent);
- gf_stat_to_iatt (&rsp.postnewparent, &postnewparent);
- }
-
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
+ ret = client_post_rename (this, &rsp, &stbuf, &preoldparent,
+ &postoldparent, &prenewparent,
+ &postnewparent, &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
@@ -2897,17 +2760,10 @@ client3_3_link_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- if (-1 != rsp.op_ret) {
- gf_stat_to_iatt (&rsp.stat, &stbuf);
-
- gf_stat_to_iatt (&rsp.preparent, &preparent);
- gf_stat_to_iatt (&rsp.postparent, &postparent);
- }
-
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
-
+ ret = client_post_link (this, &rsp, &stbuf, &preparent,
+ &postparent, &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
if (GF_IGNORE_IF_GSYNCD_SAFE_ERROR(frame, rsp.op_errno)) {
@@ -2931,7 +2787,6 @@ out:
return 0;
}
-
int
client3_3_opendir_cbk (struct rpc_req *req, struct iovec *iov, int count,
void *myframe)
@@ -2978,10 +2833,9 @@ client3_3_opendir_cbk (struct rpc_req *req, struct iovec *iov, int count,
}
}
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
-
+ ret = client_post_opendir (this, &rsp, &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
gf_msg (this->name, fop_log_level (GF_FOP_OPENDIR,
@@ -3040,17 +2894,13 @@ client3_3_lookup_cbk (struct rpc_req *req, struct iovec *iov, int count,
}
op_errno = gf_error_to_errno (rsp.op_errno);
- gf_stat_to_iatt (&rsp.postparent, &postparent);
if (rsp.op_ret == -1)
goto out;
- rsp.op_ret = -1;
- gf_stat_to_iatt (&rsp.stat, &stbuf);
-
- GF_PROTOCOL_DICT_UNSERIALIZE (frame->this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), rsp.op_ret,
- op_errno, out);
+ ret = client_post_lookup (this, &rsp, &stbuf, &postparent, &xdata);
+ if (ret < 0)
+ goto out;
if ((!gf_uuid_is_null (inode->gfid))
&& (gf_uuid_compare (stbuf.ia_gfid, inode->gfid) != 0)) {
@@ -3131,23 +2981,11 @@ client3_3_readv_cbk (struct rpc_req *req, struct iovec *iov, int count,
goto out;
}
- if (rsp.op_ret != -1) {
- iobref = req->rsp_iobref;
- gf_stat_to_iatt (&rsp.stat, &stat);
-
- vector[0].iov_len = rsp.op_ret;
- if (rsp.op_ret > 0)
- vector[0].iov_base = req->rsp[1].iov_base;
- rspcount = 1;
- }
- GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val),
- (rsp.xdata.xdata_len), ret,
- rsp.op_errno, out);
-
-#ifdef GF_TESTING_IO_XDATA
- dict_dump_to_log (xdata);
-#endif
-
+ ret = client_post_readv (this, &rsp, &iobref, req->rsp_iobref,
+ &stat, vector, &req->rsp[1],
+ &rspcount, &xdata);
+ if (ret < 0)
+ goto out;
out:
if (rsp.op_ret == -1) {
gf_msg (this->name, GF_LOG_WARNING,
@@ -3385,16 +3223,6 @@ client3_3_lookup (call_frame_t *frame, xlator_t *this,
loc_copy (&local->loc, args->loc);
loc_path (&local->loc, NULL);
- if ((args->loc->parent) && (!gf_uuid_is_null (args->loc->parent->gfid)))
- memcpy (req.pargfid, args->loc->parent->gfid, 16);
- else
- memcpy (req.pargfid, args->loc->pargfid, 16);
-
- if ((args->loc->inode) && (!gf_uuid_is_null (args->loc->inode->gfid)))
- memcpy (req.gfid, args->loc->inode->gfid, 16);
- else
- memcpy (req.gfid, args->loc->gfid, 16);
-
if (args->xdata) {
content = dict_get (args->xdata, GF_CONTENT_KEY);
if (content != NULL) {
@@ -3422,17 +3250,13 @@ client3_3_lookup (call_frame_t *frame, xlator_t *this,
rsp_iobref = NULL;
}
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata,
- (&req.xdata.xdata_val),
- req.xdata.xdata_len,
- op_errno, unwind);
}
- if (args->loc->name)
- req.bname = (char *)args->loc->name;
- else
- req.bname = "";
-
+ ret = client_pre_lookup (this, &req, args->loc, args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_LOOKUP, client3_3_lookup_cbk,
NULL, rsphdr, count,
@@ -3477,22 +3301,13 @@ client3_3_stat (call_frame_t *frame, xlator_t *this,
goto unwind;
args = data;
- if (!(args->loc && args->loc->inode))
- goto unwind;
-
- if (!gf_uuid_is_null (args->loc->inode->gfid))
- memcpy (req.gfid, args->loc->inode->gfid, 16);
- else
- memcpy (req.gfid, args->loc->gfid, 16);
-
- GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
- !gf_uuid_is_null (*((uuid_t*)req.gfid)),
- unwind, op_errno, EINVAL);
conf = this->private;
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
-
+ ret = client_pre_stat (this, &req, args->loc, args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_STAT, client3_3_stat_cbk, NULL,
NULL, 0, NULL, 0, NULL,
@@ -3528,25 +3343,14 @@ client3_3_truncate (call_frame_t *frame, xlator_t *this,
goto unwind;
args = data;
-
- if (!(args->loc && args->loc->inode))
- goto unwind;
-
- if (!gf_uuid_is_null (args->loc->inode->gfid))
- memcpy (req.gfid, args->loc->inode->gfid, 16);
- else
- memcpy (req.gfid, args->loc->gfid, 16);
-
- GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
- !gf_uuid_is_null (*((uuid_t*)req.gfid)),
- unwind, op_errno, EINVAL);
- req.offset = args->offset;
-
conf = this->private;
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
-
+ ret = client_pre_truncate (this, &req, args->loc, args->offset,
+ args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_TRUNCATE,
client3_3_truncate_cbk, NULL,
@@ -3586,16 +3390,12 @@ client3_3_ftruncate (call_frame_t *frame, xlator_t *this,
conf = this->private;
- CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD,
- remote_fd, op_errno, unwind);
-
- req.offset = args->offset;
- req.fd = remote_fd;
- memcpy (req.gfid, args->fd->inode->gfid, 16);
-
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
-
+ ret = client_pre_ftruncate (this, &req, args->fd, args->offset,
+ args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_FTRUNCATE,
client3_3_ftruncate_cbk, NULL,
@@ -3617,7 +3417,6 @@ unwind:
}
-
int32_t
client3_3_access (call_frame_t *frame, xlator_t *this,
void *data)
@@ -3633,24 +3432,15 @@ client3_3_access (call_frame_t *frame, xlator_t *this,
args = data;
- if (!(args->loc && args->loc->inode))
- goto unwind;
-
- if (!gf_uuid_is_null (args->loc->inode->gfid))
- memcpy (req.gfid, args->loc->inode->gfid, 16);
- else
- memcpy (req.gfid, args->loc->gfid, 16);
-
- GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
- !gf_uuid_is_null (*((uuid_t*)req.gfid)),
- unwind, op_errno, EINVAL);
- req.mask = args->mask;
-
conf = this->private;
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
+ ret = client_pre_access (this, &req, args->loc, args->mask,
+ args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_ACCESS,
client3_3_access_cbk, NULL,
@@ -3692,18 +3482,6 @@ client3_3_readlink (call_frame_t *frame, xlator_t *this,
args = data;
- if (!(args->loc && args->loc->inode))
- goto unwind;
-
- if (!gf_uuid_is_null (args->loc->inode->gfid))
- memcpy (req.gfid, args->loc->inode->gfid, 16);
- else
- memcpy (req.gfid, args->loc->gfid, 16);
-
- GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
- !gf_uuid_is_null (*((uuid_t*)req.gfid)),
- unwind, op_errno, EINVAL);
- req.size = args->size;
conf = this->private;
local = mem_get0 (this->local_pool);
@@ -3714,8 +3492,12 @@ client3_3_readlink (call_frame_t *frame, xlator_t *this,
frame->local = local;
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
+ ret = client_pre_readlink (this, &req, args->loc, args->size,
+ args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
rsp_iobref = iobref_new ();
if (rsp_iobref == NULL) {
@@ -3762,9 +3544,6 @@ unwind:
return 0;
}
-
-
-
int32_t
client3_3_unlink (call_frame_t *frame, xlator_t *this,
void *data)
@@ -3779,25 +3558,14 @@ client3_3_unlink (call_frame_t *frame, xlator_t *this,
goto unwind;
args = data;
-
- if (!(args->loc && args->loc->parent))
- goto unwind;
-
- if (!gf_uuid_is_null (args->loc->parent->gfid))
- memcpy (req.pargfid, args->loc->parent->gfid, 16);
- else
- memcpy (req.pargfid, args->loc->pargfid, 16);
-
- GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
- !gf_uuid_is_null (*((uuid_t*)req.pargfid)),
- unwind, op_errno, EINVAL);
- req.bname = (char *)args->loc->name;
- req.xflags = args->flags;
conf = this->private;
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
-
+ ret = client_pre_unlink (this, &req, args->loc, args->flags,
+ args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_UNLINK,
client3_3_unlink_cbk, NULL,
@@ -3834,25 +3602,15 @@ client3_3_rmdir (call_frame_t *frame, xlator_t *this,
goto unwind;
args = data;
-
- if (!(args->loc && args->loc->parent))
- goto unwind;
-
- if (!gf_uuid_is_null (args->loc->parent->gfid))
- memcpy (req.pargfid, args->loc->parent->gfid, 16);
- else
- memcpy (req.pargfid, args->loc->pargfid, 16);
-
- GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
- !gf_uuid_is_null (*((uuid_t*)req.pargfid)),
- unwind, op_errno, EINVAL);
- req.bname = (char *)args->loc->name;
- req.xflags = args->flags;
conf = this->private;
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
+ ret = client_pre_rmdir (this, &req, args->loc, args->flags,
+ args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_RMDIR, client3_3_rmdir_cbk, NULL,
NULL, 0, NULL, 0,
@@ -3888,6 +3646,8 @@ client3_3_symlink (call_frame_t *frame, xlator_t *this,
goto unwind;
args = data;
+ conf = this->private;
+
local = mem_get0 (this->local_pool);
if (!local) {
op_errno = ENOMEM;
@@ -3902,24 +3662,14 @@ client3_3_symlink (call_frame_t *frame, xlator_t *this,
loc_copy (&local->loc, args->loc);
loc_path (&local->loc, NULL);
- if (!gf_uuid_is_null (args->loc->parent->gfid))
- memcpy (req.pargfid, args->loc->parent->gfid, 16);
- else
- memcpy (req.pargfid, args->loc->pargfid, 16);
-
- GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
- !gf_uuid_is_null (*((uuid_t*)req.pargfid)),
- unwind, op_errno, EINVAL);
- 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;
-
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
+ local->loc2.path = gf_strdup (args->linkname);
+ ret = client_pre_symlink (this, &req, args->loc,
+ args->linkname, args->umask, args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_SYMLINK, client3_3_symlink_cbk,
NULL, NULL, 0, NULL,
@@ -3943,7 +3693,6 @@ unwind:
}
-
int32_t
client3_3_rename (call_frame_t *frame, xlator_t *this,
void *data)
@@ -3958,34 +3707,14 @@ client3_3_rename (call_frame_t *frame, xlator_t *this,
goto unwind;
args = data;
-
- if (!(args->oldloc && args->newloc && args->oldloc->parent &&
- args->newloc->parent))
- goto unwind;
-
- if (!gf_uuid_is_null (args->oldloc->parent->gfid))
- memcpy (req.oldgfid, args->oldloc->parent->gfid, 16);
- else
- memcpy (req.oldgfid, args->oldloc->pargfid, 16);
-
- if (!gf_uuid_is_null (args->newloc->parent->gfid))
- memcpy (req.newgfid, args->newloc->parent->gfid, 16);
- else
- memcpy (req.newgfid, args->newloc->pargfid, 16);
-
- GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
- !gf_uuid_is_null (*((uuid_t*)req.oldgfid)),
- unwind, op_errno, EINVAL);
- GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
- !gf_uuid_is_null (*((uuid_t*)req.newgfid)),
- unwind, op_errno, EINVAL);
- req.oldbname = (char *)args->oldloc->name;
- req.newbname = (char *)args->newloc->name;
conf = this->private;
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
-
+ ret = client_pre_rename (this, &req, args->oldloc, args->newloc,
+ args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_RENAME, client3_3_rename_cbk, NULL,
NULL, 0, NULL, 0,
@@ -4008,7 +3737,6 @@ unwind:
}
-
int32_t
client3_3_link (call_frame_t *frame, xlator_t *this,
void *data)
@@ -4024,44 +3752,27 @@ client3_3_link (call_frame_t *frame, xlator_t *this,
goto unwind;
args = data;
+ conf = this->private;
- if (!(args->oldloc && args->oldloc->inode && args->newloc &&
- args->newloc->parent))
- goto unwind;
-
- if (!gf_uuid_is_null (args->oldloc->inode->gfid))
- memcpy (req.oldgfid, args->oldloc->inode->gfid, 16);
- else
- memcpy (req.oldgfid, args->oldloc->gfid, 16);
-
- if (!gf_uuid_is_null (args->newloc->parent->gfid))
- memcpy (req.newgfid, args->newloc->parent->gfid, 16);
- else
- memcpy (req.newgfid, args->newloc->pargfid, 16);
-
- GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
- !gf_uuid_is_null (*((uuid_t*)req.oldgfid)),
- unwind, op_errno, EINVAL);
- GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
- !gf_uuid_is_null (*((uuid_t*)req.newgfid)),
- unwind, op_errno, EINVAL);
local = mem_get0 (this->local_pool);
if (!local) {
op_errno = ENOMEM;
goto unwind;
}
+ frame->local = local;
+
+ ret = client_pre_link (this, &req, args->oldloc, args->newloc,
+ args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
+
loc_copy (&local->loc, args->oldloc);
loc_path (&local->loc, NULL);
loc_copy (&local->loc2, args->newloc);
loc_path (&local->loc2, NULL);
- frame->local = local;
-
- req.newbname = (char *)args->newloc->name;
- conf = this->private;
-
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_LINK, client3_3_link_cbk, NULL,
@@ -4099,6 +3810,7 @@ client3_3_mknod (call_frame_t *frame, xlator_t *this,
goto unwind;
args = data;
+ conf = this->private;
local = mem_get0 (this->local_pool);
if (!local) {
@@ -4107,30 +3819,16 @@ client3_3_mknod (call_frame_t *frame, xlator_t *this,
}
frame->local = local;
- if (!(args->loc && args->loc->parent))
- goto unwind;
-
loc_copy (&local->loc, args->loc);
loc_path (&local->loc, NULL);
- if (!gf_uuid_is_null (args->loc->parent->gfid))
- memcpy (req.pargfid, args->loc->parent->gfid, 16);
- else
- memcpy (req.pargfid, args->loc->pargfid, 16);
-
- GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
- !gf_uuid_is_null (*((uuid_t*)req.pargfid)),
- unwind, op_errno, EINVAL);
- req.bname = (char *)args->loc->name;
- req.mode = args->mode;
- req.dev = args->rdev;
- req.umask = args->umask;
-
- conf = this->private;
-
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
-
+ ret = client_pre_mknod (this, &req, args->loc,
+ args->mode, args->rdev, args->umask,
+ args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_MKNOD, client3_3_mknod_cbk, NULL,
NULL, 0, NULL, 0,
@@ -4168,6 +3866,7 @@ client3_3_mkdir (call_frame_t *frame, xlator_t *this,
goto unwind;
args = data;
+ conf = this->private;
if (!args->xdata || !dict_get (args->xdata, "gfid-req")) {
op_errno = EPERM;
@@ -4191,24 +3890,12 @@ client3_3_mkdir (call_frame_t *frame, xlator_t *this,
loc_copy (&local->loc, args->loc);
loc_path (&local->loc, NULL);
- if (!gf_uuid_is_null (args->loc->parent->gfid))
- memcpy (req.pargfid, args->loc->parent->gfid, 16);
- else
- memcpy (req.pargfid, args->loc->pargfid, 16);
-
- GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
- !gf_uuid_is_null (*((uuid_t*)req.pargfid)),
- unwind, op_errno, EINVAL);
-
- req.bname = (char *)args->loc->name;
- req.mode = args->mode;
- req.umask = args->umask;
-
- conf = this->private;
-
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
-
+ ret = client_pre_mkdir (this, &req, args->loc, args->mode,
+ args->umask, args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_MKDIR, client3_3_mkdir_cbk, NULL,
NULL, 0, NULL, 0,
@@ -4245,6 +3932,7 @@ client3_3_create (call_frame_t *frame, xlator_t *this,
goto unwind;
args = data;
+ conf = this->private;
local = mem_get0 (this->local_pool);
if (!local) {
@@ -4253,33 +3941,19 @@ client3_3_create (call_frame_t *frame, xlator_t *this,
}
frame->local = local;
- if (!(args->loc && args->loc->parent))
- goto unwind;
-
local->fd = fd_ref (args->fd);
local->flags = args->flags;
loc_copy (&local->loc, args->loc);
loc_path (&local->loc, NULL);
- if (!gf_uuid_is_null (args->loc->parent->gfid))
- memcpy (req.pargfid, args->loc->parent->gfid, 16);
- else
- memcpy (req.pargfid, args->loc->pargfid, 16);
-
- GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
- !gf_uuid_is_null (*((uuid_t*)req.pargfid)),
- unwind, op_errno, EINVAL);
- req.bname = (char *)args->loc->name;
- req.mode = args->mode;
- req.flags = gf_flags_from_flags (args->flags);
- req.umask = args->umask;
-
- conf = this->private;
-
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
-
+ ret = client_pre_create (this, &req, args->loc,
+ args->fd, args->mode,
+ args->flags, args->umask, args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_CREATE, client3_3_create_cbk, NULL,
NULL, 0, NULL, 0,
@@ -4319,6 +3993,8 @@ client3_3_open (call_frame_t *frame, xlator_t *this,
args = data;
+ conf = this->private;
+
local = mem_get0 (this->local_pool);
if (!local) {
op_errno = ENOMEM;
@@ -4326,29 +4002,19 @@ client3_3_open (call_frame_t *frame, xlator_t *this,
}
frame->local = local;
- if (!(args->loc && args->loc->inode))
- goto unwind;
+ local->flags = args->flags;
local->fd = fd_ref (args->fd);
- local->flags = args->flags;
loc_copy (&local->loc, args->loc);
loc_path (&local->loc, NULL);
- if (!gf_uuid_is_null (args->loc->inode->gfid))
- memcpy (req.gfid, args->loc->inode->gfid, 16);
- else
- memcpy (req.gfid, args->loc->gfid, 16);
-
- GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
- !gf_uuid_is_null (*((uuid_t*)req.gfid)),
- unwind, op_errno, EINVAL);
- req.flags = gf_flags_from_flags (args->flags);
-
- conf = this->private;
-
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
+ ret = client_pre_open (this, &req, args->loc, args->fd, args->flags,
+ args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_OPEN, client3_3_open_cbk, NULL,
NULL, 0, NULL, 0, NULL,
@@ -4370,13 +4036,11 @@ unwind:
}
-
int32_t
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;
@@ -4392,21 +4056,19 @@ client3_3_readv (call_frame_t *frame, xlator_t *this,
args = data;
conf = this->private;
- 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);
+ ret = client_pre_readv (this, &req, args->fd, args->size,
+ args->offset, args->flags, args->xdata);
if (ret) {
op_errno = -ret;
goto unwind;
}
- local = frame->local;
-
- req.size = args->size;
- req.offset = args->offset;
- req.fd = remote_fd;
- req.flag = args->flags;
- memcpy (req.gfid, args->fd->inode->gfid, 16);
+ ret = client_fd_fop_prepare_local (frame, args->fd, req.fd);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
+ local = frame->local;
rsp_iobuf = iobuf_get2 (this->ctx->iobuf_pool, args->size);
if (rsp_iobuf == NULL) {
@@ -4440,9 +4102,6 @@ client3_3_readv (call_frame_t *frame, xlator_t *this,
local->iobref = rsp_iobref;
rsp_iobref = NULL;
- 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_3_readv_cbk, NULL,
NULL, 0, &rsp_vec, 1,
@@ -4475,7 +4134,6 @@ int32_t
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;
@@ -4487,32 +4145,19 @@ client3_3_writev (call_frame_t *frame, xlator_t *this, void *data)
args = data;
conf = this->private;
- 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);
+ ret = client_pre_writev (this, &req, args->fd, args->size,
+ args->offset, args->flags, args->xdata);
+
if (ret) {
op_errno = -ret;
goto unwind;
}
- req.size = args->size;
- req.offset = args->offset;
- req.fd = remote_fd;
- req.flag = args->flags;
-
- 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_fd_fop_prepare_local (frame, args->fd, req.fd);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_vec_request (this, &req, frame, conf->fops,
GFS3_OP_WRITE, client3_3_writev_cbk,
args->vector, args->count,
@@ -4546,7 +4191,6 @@ client3_3_flush (call_frame_t *frame, xlator_t *this,
{
clnt_args_t *args = NULL;
gfs3_flush_req req = {{0,},};
- int64_t remote_fd = -1;
clnt_conf_t *conf = NULL;
clnt_local_t *local = NULL;
int op_errno = ESTALE;
@@ -4558,27 +4202,21 @@ client3_3_flush (call_frame_t *frame, xlator_t *this,
args = data;
conf = this->private;
- CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD,
- remote_fd, op_errno, unwind);
-
- conf = this->private;
-
local = mem_get0 (this->local_pool);
if (!local) {
op_errno = ENOMEM;
goto unwind;
}
- local->fd = fd_ref (args->fd);
- local->owner = frame->root->lk_owner;
frame->local = local;
- req.fd = remote_fd;
- memcpy (req.gfid, args->fd->inode->gfid, 16);
-
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
-
+ local->fd = fd_ref (args->fd);
+ local->owner = frame->root->lk_owner;
+ ret = client_pre_flush (this, &req, args->fd, args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_FLUSH, client3_3_flush_cbk, NULL,
NULL, 0, NULL, 0,
@@ -4608,7 +4246,6 @@ client3_3_fsync (call_frame_t *frame, xlator_t *this,
{
clnt_args_t *args = NULL;
gfs3_fsync_req req = {{0,},};
- int64_t remote_fd = -1;
clnt_conf_t *conf = NULL;
int op_errno = 0;
int ret = 0;
@@ -4619,16 +4256,12 @@ client3_3_fsync (call_frame_t *frame, xlator_t *this,
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.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_pre_fsync (this, &req, args->fd, args->flags,
+ args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_FSYNC, client3_3_fsync_cbk, NULL,
NULL, 0, NULL, 0,
@@ -4658,7 +4291,6 @@ client3_3_fstat (call_frame_t *frame, xlator_t *this,
{
clnt_args_t *args = NULL;
gfs3_fstat_req req = {{0,},};
- int64_t remote_fd = -1;
clnt_conf_t *conf = NULL;
int op_errno = ESTALE;
int ret = 0;
@@ -4669,14 +4301,12 @@ client3_3_fstat (call_frame_t *frame, xlator_t *this,
args = data;
conf = this->private;
- 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);
+ ret = client_pre_fstat (this, &req, args->fd, args->xdata);
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_FSTAT, client3_3_fstat_cbk, NULL,
@@ -4715,6 +4345,7 @@ client3_3_opendir (call_frame_t *frame, xlator_t *this,
goto unwind;
args = data;
+ conf = this->private;
local = mem_get0 (this->local_pool);
if (!local) {
@@ -4723,27 +4354,16 @@ client3_3_opendir (call_frame_t *frame, xlator_t *this,
}
frame->local = local;
- if (!(args->loc && args->loc->inode))
- goto unwind;
-
local->fd = fd_ref (args->fd);
loc_copy (&local->loc, args->loc);
loc_path (&local->loc, NULL);
- if (!gf_uuid_is_null (args->loc->inode->gfid))
- memcpy (req.gfid, args->loc->inode->gfid, 16);
- else
- memcpy (req.gfid, args->loc->gfid, 16);
-
- GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
- !gf_uuid_is_null (*((uuid_t*)req.gfid)),
- unwind, op_errno, EINVAL);
-
- conf = this->private;
-
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
-
+ ret = client_pre_opendir (this, &req, args->loc, args->fd,
+ args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_OPENDIR, client3_3_opendir_cbk,
NULL, NULL, 0, NULL, 0, NULL,
@@ -4771,7 +4391,6 @@ int32_t
client3_3_fsyncdir (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_fsyncdir_req req = {{0,},};
int ret = 0;
@@ -4783,18 +4402,12 @@ client3_3_fsyncdir (call_frame_t *frame, xlator_t *this, void *data)
args = data;
conf = this->private;
- CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD,
- remote_fd, op_errno, unwind);
-
- req.fd = remote_fd;
- req.data = args->flags;
- memcpy (req.gfid, args->fd->inode->gfid, 16);
-
- conf = this->private;
-
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
-
+ ret = client_pre_fsyncdir (this, &req, args->fd, args->flags,
+ args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_FSYNCDIR, client3_3_fsyncdir_cbk,
NULL, NULL, 0,
@@ -4833,26 +4446,13 @@ client3_3_statfs (call_frame_t *frame, xlator_t *this,
args = data;
- if (!args->loc)
- goto unwind;
-
- if (args->loc->inode) {
- if (!gf_uuid_is_null (args->loc->inode->gfid))
- memcpy (req.gfid, args->loc->inode->gfid, 16);
- else
- memcpy (req.gfid, args->loc->gfid, 16);
- } else
- req.gfid[15] = 1;
-
- GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
- !gf_uuid_is_null (*((uuid_t*)req.gfid)),
- unwind, op_errno, EINVAL);
-
conf = this->private;
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
-
+ ret = client_pre_statfs (this, &req, args->loc, args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_STATFS, client3_3_statfs_cbk, NULL,
NULL, 0, NULL, 0,
@@ -4889,32 +4489,14 @@ client3_3_setxattr (call_frame_t *frame, xlator_t *this,
goto unwind;
args = data;
+ conf = this->private;
- if (!(args->loc && args->loc->inode))
+ ret = client_pre_setxattr (this, &req, args->loc, args->xattr,
+ args->flags, args->xdata);
+ if (ret) {
+ op_errno = -ret;
goto unwind;
-
- if (!gf_uuid_is_null (args->loc->inode->gfid))
- memcpy (req.gfid, args->loc->inode->gfid, 16);
- else
- memcpy (req.gfid, args->loc->gfid, 16);
-
- GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
- !gf_uuid_is_null (*((uuid_t*)req.gfid)),
- unwind, op_errno, EINVAL);
- if (args->xattr) {
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xattr,
- (&req.dict.dict_val),
- req.dict.dict_len,
- op_errno, unwind);
}
-
- req.flags = args->flags;
-
- conf = this->private;
-
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
-
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_SETXATTR, client3_3_setxattr_cbk,
NULL, NULL, 0, NULL, 0, NULL,
@@ -4944,7 +4526,6 @@ client3_3_fsetxattr (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_fsetxattr_req req = {{0,},};
int op_errno = ESTALE;
@@ -4956,23 +4537,12 @@ client3_3_fsetxattr (call_frame_t *frame, xlator_t *this,
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;
- memcpy (req.gfid, args->fd->inode->gfid, 16);
-
- if (args->xattr) {
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xattr,
- (&req.dict.dict_val),
- req.dict.dict_len,
- op_errno, unwind);
+ ret = client_pre_fsetxattr (this, &req, args->fd, args->flags,
+ args->xattr, args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
}
-
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
-
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_FSETXATTR, client3_3_fsetxattr_cbk,
NULL, NULL, 0, NULL, 0, NULL,
@@ -4996,9 +4566,6 @@ unwind:
return 0;
}
-
-
-
int32_t
client3_3_fgetxattr (call_frame_t *frame, xlator_t *this,
void *data)
@@ -5022,9 +4589,6 @@ client3_3_fgetxattr (call_frame_t *frame, xlator_t *this,
args = data;
conf = this->private;
- CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD,
- remote_fd, op_errno, unwind);
-
local = mem_get0 (this->local_pool);
if (!local) {
op_errno = ENOMEM;
@@ -5056,18 +4620,12 @@ client3_3_fgetxattr (call_frame_t *frame, xlator_t *this,
rsp_iobuf = NULL;
rsp_iobref = NULL;
- req.namelen = 1; /* Use it as a flag */
- req.fd = remote_fd;
- req.name = (char *)args->name;
- if (!req.name) {
- req.name = "";
- req.namelen = 0;
+ ret = client_pre_fgetxattr (this, &req, args->fd, args->name,
+ args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
}
- memcpy (req.gfid, args->fd->inode->gfid, 16);
-
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
-
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_FGETXATTR,
client3_3_fgetxattr_cbk, NULL,
@@ -5122,24 +4680,20 @@ client3_3_getxattr (call_frame_t *frame, xlator_t *this,
}
args = data;
- if (!args->loc) {
- op_errno = EINVAL;
- goto unwind;
- }
-
local = mem_get0 (this->local_pool);
if (!local) {
op_errno = ENOMEM;
goto unwind;
}
+ frame->local = local;
+
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 ();
if (rsp_iobref == NULL) {
op_errno = ENOMEM;
@@ -5164,22 +4718,6 @@ client3_3_getxattr (call_frame_t *frame, xlator_t *this,
rsp_iobuf = NULL;
rsp_iobref = NULL;
- if (args->loc->inode && !gf_uuid_is_null (args->loc->inode->gfid))
- memcpy (req.gfid, args->loc->inode->gfid, 16);
- else
- memcpy (req.gfid, args->loc->gfid, 16);
-
- GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
- !gf_uuid_is_null (*((uuid_t*)req.gfid)),
- unwind, op_errno, EINVAL);
- req.namelen = 1; /* Use it as a flag */
-
- req.name = (char *)args->name;
- if (!req.name) {
- req.name = "";
- req.namelen = 0;
- }
-
conf = this->private;
if (args && args->name) {
@@ -5202,9 +4740,12 @@ client3_3_getxattr (call_frame_t *frame, xlator_t *this,
}
}
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
-
+ ret = client_pre_getxattr (this, &req, args->loc, args->name,
+ args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_GETXATTR,
client3_3_getxattr_cbk, NULL,
@@ -5290,30 +4831,16 @@ client3_3_xattrop (call_frame_t *frame, xlator_t *this,
rsp_iobuf = NULL;
rsp_iobref = NULL;
- if (!gf_uuid_is_null (args->loc->inode->gfid))
- memcpy (req.gfid, args->loc->inode->gfid, 16);
- 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,
- !gf_uuid_is_null (*((uuid_t*)req.gfid)),
- unwind, op_errno, EINVAL);
- if (args->xattr) {
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xattr,
- (&req.dict.dict_val),
- req.dict.dict_len,
- op_errno, unwind);
- }
-
- req.flags = args->flags;
-
conf = this->private;
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
-
+ ret = client_pre_xattrop (this, &req, args->loc, args->xattr,
+ args->flags, args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_XATTROP,
client3_3_xattrop_cbk, NULL,
@@ -5353,7 +4880,6 @@ 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,},};
@@ -5371,9 +4897,13 @@ client3_3_fxattrop (call_frame_t *frame, xlator_t *this,
args = data;
conf = this->private;
- 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);
+ ret = client_pre_fxattrop (this, &req, args->fd, args->xattr,
+ args->flags, args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
+ ret = client_fd_fop_prepare_local (frame, args->fd, req.fd);
if (ret) {
op_errno = -ret;
goto unwind;
@@ -5381,10 +4911,6 @@ client3_3_fxattrop (call_frame_t *frame, xlator_t *this,
local = frame->local;
- req.fd = remote_fd;
- req.flags = args->flags;
- memcpy (req.gfid, args->fd->inode->gfid, 16);
-
rsp_iobref = iobref_new ();
if (rsp_iobref == NULL) {
op_errno = ENOMEM;
@@ -5408,16 +4934,6 @@ client3_3_fxattrop (call_frame_t *frame, xlator_t *this,
rsp_iobuf = NULL;
rsp_iobref = NULL;
- if (args->xattr) {
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xattr,
- (&req.dict.dict_val),
- req.dict.dict_len,
- op_errno, unwind);
- }
-
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
-
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_FXATTROP,
client3_3_fxattrop_cbk, NULL,
@@ -5465,25 +4981,14 @@ client3_3_removexattr (call_frame_t *frame, xlator_t *this,
goto unwind;
args = data;
-
- if (!(args->loc && args->loc->inode))
- goto unwind;
-
- if (!gf_uuid_is_null (args->loc->inode->gfid))
- memcpy (req.gfid, args->loc->inode->gfid, 16);
- else
- memcpy (req.gfid, args->loc->gfid, 16);
-
- GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
- !gf_uuid_is_null (*((uuid_t*)req.gfid)),
- unwind, op_errno, EINVAL);
- req.name = (char *)args->name;
-
conf = this->private;
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
-
+ ret = client_pre_removexattr (this, &req, args->loc, args->name,
+ args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_REMOVEXATTR,
client3_3_removexattr_cbk, NULL,
@@ -5512,7 +5017,6 @@ client3_3_fremovexattr (call_frame_t *frame, xlator_t *this,
clnt_args_t *args = NULL;
gfs3_fremovexattr_req req = {{0,},};
int ret = 0;
- int64_t remote_fd = -1;
int op_errno = ESTALE;
if (!frame || !this || !data)
@@ -5520,21 +5024,14 @@ client3_3_fremovexattr (call_frame_t *frame, xlator_t *this,
args = data;
- if (!(args->fd && args->fd->inode))
- goto unwind;
-
conf = this->private;
- CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD,
- remote_fd, op_errno, unwind);
-
- memcpy (req.gfid, args->fd->inode->gfid, 16);
- req.name = (char *)args->name;
- req.fd = remote_fd;
-
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
-
+ ret = client_pre_fremovexattr (this, &req, args->fd, args->name,
+ args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_FREMOVEXATTR,
client3_3_fremovexattr_cbk, NULL,
@@ -5575,23 +5072,12 @@ client3_3_lease (call_frame_t *frame, xlator_t *this,
args = data;
conf = this->private;
- if (!(args->loc && args->loc->inode))
+ ret = client_pre_lease (this, &req, args->loc, args->lease,
+ args->xdata);
+ if (ret < 0) {
+ op_errno = -ret;
goto unwind;
-
- if (!gf_uuid_is_null (args->loc->inode->gfid))
- memcpy (req.gfid, args->loc->inode->gfid, 16);
- else
- memcpy (req.gfid, args->loc->gfid, 16);
-
- GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
- !gf_uuid_is_null (*((uuid_t *)req.gfid)),
- unwind, op_errno, EINVAL);
-
- gf_proto_lease_from_lease (&req.lease, args->lease);
-
- 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_LEASE,
client3_3_lease_cbk, NULL,
NULL, 0, NULL, 0, NULL,
@@ -5619,7 +5105,6 @@ client3_3_lk (call_frame_t *frame, xlator_t *this,
gfs3_lk_req req = {{0,},};
int32_t gf_cmd = 0;
int32_t gf_type = 0;
- int64_t remote_fd = -1;
clnt_local_t *local = NULL;
clnt_conf_t *conf = NULL;
int op_errno = ESTALE;
@@ -5637,9 +5122,6 @@ client3_3_lk (call_frame_t *frame, xlator_t *this,
}
frame->local = local;
- 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) {
op_errno = EINVAL;
@@ -5648,32 +5130,16 @@ client3_3_lk (call_frame_t *frame, xlator_t *this,
goto unwind;
}
- switch (args->flock->l_type) {
- case F_RDLCK:
- gf_type = GF_LK_F_RDLCK;
- break;
- case F_WRLCK:
- gf_type = GF_LK_F_WRLCK;
- break;
- case F_UNLCK:
- gf_type = GF_LK_F_UNLCK;
- break;
- }
-
local->owner = frame->root->lk_owner;
local->cmd = args->cmd;
local->fd = fd_ref (args->fd);
- req.fd = remote_fd;
- req.cmd = gf_cmd;
- req.type = gf_type;
- gf_proto_flock_from_flock (&req.flock, args->flock);
-
- memcpy (req.gfid, args->fd->inode->gfid, 16);
-
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
-
+ ret = client_pre_lk (this, &req, args->cmd, args->flock,
+ args->fd, args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request (this, &req, frame, conf->fops, GFS3_OP_LK,
client3_3_lk_cbk, NULL,
NULL, 0, NULL, 0, NULL,
@@ -5702,60 +5168,20 @@ client3_3_inodelk (call_frame_t *frame, xlator_t *this,
clnt_args_t *args = NULL;
gfs3_inodelk_req req = {{0,},};
int ret = 0;
- int32_t gf_cmd = 0;
- int32_t gf_type = 0;
int op_errno = ESTALE;
if (!frame || !this || !data)
goto unwind;
args = data;
- if (!(args->loc && args->loc->inode))
- goto unwind;
+ conf = this->private;
- if (!gf_uuid_is_null (args->loc->gfid))
- memcpy (req.gfid, args->loc->gfid, 16);
- else
- memcpy (req.gfid, args->loc->inode->gfid, 16);
-
- GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
- !gf_uuid_is_null (*((uuid_t*)req.gfid)),
- unwind, op_errno, EINVAL);
- if (args->cmd == F_GETLK || args->cmd == F_GETLK64)
- gf_cmd = GF_LK_GETLK;
- else if (args->cmd == F_SETLK || args->cmd == F_SETLK64)
- gf_cmd = GF_LK_SETLK;
- else if (args->cmd == F_SETLKW || args->cmd == F_SETLKW64)
- gf_cmd = GF_LK_SETLKW;
- else {
- gf_msg (this->name, GF_LOG_WARNING, EINVAL,
- PC_MSG_INVALID_ENTRY, "Unknown cmd (%d)!", gf_cmd);
- op_errno = EINVAL;
+ ret = client_pre_inodelk (this, &req, args->loc, args->cmd,
+ args->flock, args->volume, args->xdata);
+ if (ret) {
+ op_errno = -ret;
goto unwind;
}
-
- switch (args->flock->l_type) {
- case F_RDLCK:
- gf_type = GF_LK_F_RDLCK;
- break;
- case F_WRLCK:
- gf_type = GF_LK_F_WRLCK;
- break;
- case F_UNLCK:
- gf_type = GF_LK_F_UNLCK;
- break;
- }
-
- req.volume = (char *)args->volume;
- req.cmd = gf_cmd;
- req.type = gf_type;
- gf_proto_flock_from_flock (&req.flock, args->flock);
-
- conf = this->private;
-
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
-
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_INODELK,
client3_3_inodelk_cbk, NULL,
@@ -5784,9 +5210,6 @@ client3_3_finodelk (call_frame_t *frame, xlator_t *this,
{
clnt_args_t *args = NULL;
gfs3_finodelk_req req = {{0,},};
- int32_t gf_cmd = 0;
- int32_t gf_type = 0;
- int64_t remote_fd = -1;
clnt_conf_t *conf = NULL;
int op_errno = ESTALE;
int ret = 0;
@@ -5796,48 +5219,21 @@ client3_3_finodelk (call_frame_t *frame, xlator_t *this,
args = data;
conf = this->private;
- 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);
+
+ ret = client_pre_finodelk (this, &req, args->fd,
+ args->cmd, args->flock, args->volume,
+ args->xdata);
if (ret) {
op_errno = -ret;
goto unwind;
}
- if (args->cmd == F_GETLK || args->cmd == F_GETLK64)
- gf_cmd = GF_LK_GETLK;
- else if (args->cmd == F_SETLK || args->cmd == F_SETLK64)
- gf_cmd = GF_LK_SETLK;
- else if (args->cmd == F_SETLKW || args->cmd == F_SETLKW64)
- gf_cmd = GF_LK_SETLKW;
- else {
- gf_msg (this->name, GF_LOG_WARNING, EINVAL,
- PC_MSG_INVALID_ENTRY, "Unknown cmd (%d)!", gf_cmd);
+ ret = client_fd_fop_prepare_local (frame, args->fd, req.fd);
+ if (ret) {
+ op_errno = -ret;
goto unwind;
}
- switch (args->flock->l_type) {
- case F_RDLCK:
- gf_type = GF_LK_F_RDLCK;
- break;
- case F_WRLCK:
- gf_type = GF_LK_F_WRLCK;
- break;
- case F_UNLCK:
- gf_type = GF_LK_F_UNLCK;
- break;
- }
-
- req.volume = (char *)args->volume;
- req.fd = remote_fd;
- req.cmd = gf_cmd;
- req.type = gf_type;
- gf_proto_flock_from_flock (&req.flock, args->flock);
- memcpy (req.gfid, args->fd->inode->gfid, 16);
-
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
-
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_FINODELK,
client3_3_finodelk_cbk, NULL,
@@ -5873,30 +5269,15 @@ client3_3_entrylk (call_frame_t *frame, xlator_t *this,
args = data;
- if (!(args->loc && args->loc->inode))
- goto unwind;
-
- if (!gf_uuid_is_null (args->loc->gfid))
- memcpy (req.gfid, args->loc->gfid, 16);
- else
- memcpy (req.gfid, args->loc->inode->gfid, 16);
-
- GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
- !gf_uuid_is_null (*((uuid_t*)req.gfid)),
- unwind, op_errno, EINVAL);
- req.cmd = args->cmd_entrylk;
- req.type = args->type;
- req.volume = (char *)args->volume;
- req.name = "";
- if (args->basename) {
- req.name = (char *)args->basename;
- req.namelen = 1;
- }
-
conf = this->private;
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
+ ret = client_pre_entrylk (this, &req, args->loc, args->cmd_entrylk,
+ args->type, args->volume, args->basename,
+ args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_ENTRYLK,
@@ -5926,7 +5307,6 @@ client3_3_fentrylk (call_frame_t *frame, xlator_t *this,
{
clnt_args_t *args = NULL;
gfs3_fentrylk_req req = {{0,},};
- int64_t remote_fd = -1;
clnt_conf_t *conf = NULL;
int op_errno = ESTALE;
int ret = 0;
@@ -5937,23 +5317,13 @@ client3_3_fentrylk (call_frame_t *frame, xlator_t *this,
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.cmd = args->cmd_entrylk;
- req.type = args->type;
- req.volume = (char *)args->volume;
- req.name = "";
- if (args->basename) {
- req.name = (char *)args->basename;
- req.namelen = 1;
+ ret = client_pre_fentrylk (this, &req, args->fd, args->cmd_entrylk,
+ args->type, args->volume, args->basename,
+ args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
}
- memcpy (req.gfid, args->fd->inode->gfid, 16);
-
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
-
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_FENTRYLK,
client3_3_fentrylk_cbk, NULL,
@@ -5980,7 +5350,6 @@ client3_3_rchecksum (call_frame_t *frame, xlator_t *this,
void *data)
{
clnt_args_t *args = NULL;
- int64_t remote_fd = -1;
clnt_conf_t *conf = NULL;
gfs3_rchecksum_req req = {0,};
int op_errno = ESTALE;
@@ -5992,16 +5361,12 @@ client3_3_rchecksum (call_frame_t *frame, xlator_t *this,
args = data;
conf = this->private;
- CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD,
- remote_fd, op_errno, unwind);
-
- req.len = args->len;
- req.offset = args->offset;
- req.fd = remote_fd;
-
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
-
+ ret = client_pre_rchecksum (this, &req, args->fd, args->len,
+ args->offset, args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_RCHECKSUM,
client3_3_rchecksum_cbk, NULL,
@@ -6023,8 +5388,6 @@ unwind:
return 0;
}
-
-
int32_t
client3_3_readdir (call_frame_t *frame, xlator_t *this,
void *data)
@@ -6050,9 +5413,6 @@ client3_3_readdir (call_frame_t *frame, xlator_t *this,
args = data;
conf = this->private;
- 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;
@@ -6063,6 +5423,8 @@ client3_3_readdir (call_frame_t *frame, xlator_t *this,
}
frame->local = local;
+ local->cmd = remote_fd;
+
if ((readdir_rsp_size + GLUSTERFS_RPC_REPLY_SIZE + GLUSTERFS_RDMA_MAX_HEADER_SIZE)
> (GLUSTERFS_RDMA_INLINE_THRESHOLD)) {
rsp_iobref = iobref_new ();
@@ -6090,15 +5452,12 @@ client3_3_readdir (call_frame_t *frame, xlator_t *this,
rsp_iobref = NULL;
}
- req.size = args->size;
- req.offset = args->offset;
- req.fd = remote_fd;
-
- local->cmd = remote_fd;
-
- memcpy (req.gfid, args->fd->inode->gfid, 16);
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
+ ret = client_pre_readdir (this, &req, args->fd, args->size,
+ args->offset, args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_READDIR,
@@ -6155,12 +5514,6 @@ client3_3_readdirp (call_frame_t *frame, xlator_t *this,
args = data;
conf = this->private;
- 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;
-
local = mem_get0 (this->local_pool);
if (!local) {
op_errno = ENOMEM;
@@ -6168,6 +5521,17 @@ client3_3_readdirp (call_frame_t *frame, xlator_t *this,
}
frame->local = local;
+ ret = client_pre_readdirp (this, &req, args->fd, args->size,
+ args->offset, args->xdata);
+
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
+
+ readdirp_rsp_size = xdr_sizeof ((xdrproc_t) xdr_gfs3_readdirp_rsp, &rsp)
+ + args->size;
+
if ((readdirp_rsp_size + GLUSTERFS_RPC_REPLY_SIZE
+ GLUSTERFS_RDMA_MAX_HEADER_SIZE)
> (GLUSTERFS_RDMA_INLINE_THRESHOLD)) {
@@ -6198,15 +5562,6 @@ client3_3_readdirp (call_frame_t *frame, xlator_t *this,
local->fd = fd_ref (args->fd);
- req.size = args->size;
- req.offset = args->offset;
- req.fd = remote_fd;
- memcpy (req.gfid, args->fd->inode->gfid, 16);
-
- /* dict itself is 'xdata' here */
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.dict.dict_val),
- req.dict.dict_len, op_errno, unwind);
-
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_READDIRP,
client3_3_readdirp_cbk, NULL,
@@ -6249,25 +5604,15 @@ client3_3_setattr (call_frame_t *frame, xlator_t *this,
goto unwind;
args = data;
-
- if (!(args->loc && args->loc->inode))
- goto unwind;
-
- if (!gf_uuid_is_null (args->loc->inode->gfid))
- memcpy (req.gfid, args->loc->inode->gfid, 16);
- else
- memcpy (req.gfid, args->loc->gfid, 16);
-
- GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,
- !gf_uuid_is_null (*((uuid_t*)req.gfid)),
- unwind, op_errno, EINVAL);
- req.valid = args->valid;
- gf_stat_from_iatt (&req.stbuf, args->stbuf);
-
conf = this->private;
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
+ ret = client_pre_setattr (this, &req, args->loc, args->valid,
+ args->stbuf, args->xdata);
+
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_SETATTR,
@@ -6305,16 +5650,13 @@ client3_3_fsetattr (call_frame_t *frame, xlator_t *this, void *data)
args = data;
conf = this->private;
- CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD,
- remote_fd, op_errno, unwind);
-
- req.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_pre_fsetattr (this, &req, args->fd, args->valid,
+ args->stbuf, args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_FSETATTR,
client3_3_fsetattr_cbk, NULL,
@@ -6351,17 +5693,12 @@ client3_3_fallocate(call_frame_t *frame, xlator_t *this, void *data)
args = data;
conf = this->private;
- CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD,
- remote_fd, op_errno, unwind);
-
- req.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_pre_fallocate (this, &req, args->fd, args->flags,
+ args->offset, args->size, args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_FALLOCATE,
@@ -6399,16 +5736,13 @@ client3_3_discard(call_frame_t *frame, xlator_t *this, void *data)
args = data;
conf = this->private;
- CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD,
- remote_fd, op_errno, unwind);
-
- req.fd = remote_fd;
- req.offset = args->offset;
- req.size = args->size;
- memcpy(req.gfid, args->fd->inode->gfid, 16);
+ ret = client_pre_discard (this, &req, args->fd, args->offset,
+ args->size, args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
ret = client_submit_request(this, &req, frame, conf->fops,
GFS3_OP_DISCARD, client3_3_discard_cbk,
@@ -6446,16 +5780,12 @@ client3_3_zerofill(call_frame_t *frame, xlator_t *this, void *data)
args = data;
conf = this->private;
- CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD,
- remote_fd, op_errno, unwind);
-
- req.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_pre_zerofill (this, &req, args->fd, args->offset,
+ args->size, args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request(this, &req, frame, conf->fops,
GFS3_OP_ZEROFILL, client3_3_zerofill_cbk,
@@ -6492,10 +5822,12 @@ client3_3_ipc (call_frame_t *frame, xlator_t *this, void *data)
args = data;
conf = this->private;
- req.op = args->cmd;
+ ret = client_pre_ipc (this, &req, args->cmd, args->xdata);
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request(this, &req, frame, conf->fops,
GFS3_OP_IPC, client3_3_ipc_cbk,
@@ -6523,7 +5855,6 @@ client3_3_seek (call_frame_t *frame, xlator_t *this, void *data)
struct gfs3_seek_req req = {{0,},};
int op_errno = ESTALE;
int ret = 0;
- int64_t remote_fd = -1;
GF_ASSERT (frame);
@@ -6533,16 +5864,12 @@ client3_3_seek (call_frame_t *frame, xlator_t *this, void *data)
args = data;
conf = this->private;
- CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD,
- remote_fd, op_errno, unwind);
-
- memcpy (req.gfid, args->fd->inode->gfid, 16);
- req.fd = remote_fd;
- req.offset = args->offset;
- req.what = args->what;
-
- GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
- req.xdata.xdata_len, op_errno, unwind);
+ ret = client_pre_seek (this, &req, args->fd,
+ args->offset, args->what, args->xdata);
+ if (ret) {
+ op_errno = -ret;
+ goto unwind;
+ }
ret = client_submit_request(this, &req, frame, conf->fops,
GFS3_OP_SEEK, client3_3_seek_cbk,
@@ -6671,7 +5998,6 @@ char *clnt3_3_fop_names[GFS3_OP_MAXVALUE] = {
[GFS3_OP_IPC] = "IPC",
[GFS3_OP_SEEK] = "SEEK",
[GFS3_OP_LEASE] = "LEASE",
-
};
rpc_clnt_prog_t clnt3_3_fop_prog = {
diff --git a/xlators/protocol/client/src/client.h b/xlators/protocol/client/src/client.h
index 20a57a1f855..e27b1dbca21 100644
--- a/xlators/protocol/client/src/client.h
+++ b/xlators/protocol/client/src/client.h
@@ -21,6 +21,9 @@
#include "protocol-common.h"
#include "glusterfs3.h"
#include "fd-lk.h"
+#include "defaults.h"
+#include "default-args.h"
+#include "client-messages.h"
/* FIXME: Needs to be defined in a common file */
#define CLIENT_CMD_CONNECT "trusted.glusterfs.client-connect"
@@ -277,4 +280,7 @@ int
client_notify_dispatch (xlator_t *this, int32_t event, void *data, ...);
int
client_notify_dispatch_uniq (xlator_t *this, int32_t event, void *data, ...);
+
+gf_boolean_t
+client_is_reopen_needed (fd_t *fd, xlator_t *this, int64_t remote_fd);
#endif /* !_CLIENT_H */