summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libglusterfs/src/dict.h45
-rw-r--r--xlators/protocol/client/src/client3_1-fops.c350
-rw-r--r--xlators/protocol/server/src/server3_1-fops.c557
3 files changed, 245 insertions, 707 deletions
diff --git a/libglusterfs/src/dict.h b/libglusterfs/src/dict.h
index c68c3af873b..8e81e539b74 100644
--- a/libglusterfs/src/dict.h
+++ b/libglusterfs/src/dict.h
@@ -35,6 +35,51 @@ typedef struct _data data_t;
typedef struct _dict dict_t;
typedef struct _data_pair data_pair_t;
+
+#define GF_PROTOCOL_DICT_SERIALIZE(this,from_dict,to,len,ope,labl) do { \
+ int ret = 0; \
+ size_t dictlen = 0; \
+ \
+ if (!from_dict) \
+ break; \
+ \
+ ret = dict_allocate_and_serialize (from_dict, to, \
+ &dictlen); \
+ if (ret < 0) { \
+ gf_log (this->name, GF_LOG_WARNING, \
+ "failed to get serialized dict (%s)", \
+ (#from_dict)); \
+ ope = EINVAL; \
+ goto labl; \
+ } \
+ len = dictlen; \
+ } while (0)
+
+
+#define GF_PROTOCOL_DICT_UNSERIALIZE(xl,to,buff,len,ret,ope,labl) do { \
+ char *buf = NULL; \
+ if (!len) \
+ break; \
+ to = dict_new(); \
+ GF_VALIDATE_OR_GOTO (xl->name, to, labl); \
+ \
+ buf = memdup (buff, len); \
+ GF_VALIDATE_OR_GOTO (xl->name, buf, labl); \
+ \
+ ret = dict_unserialize (buf, len, &to); \
+ if (ret < 0) { \
+ gf_log (xl->name, GF_LOG_WARNING, \
+ "failed to unserialize dictionary (%s)", \
+ (#to)); \
+ \
+ ope = EINVAL; \
+ GF_FREE (buf); \
+ goto labl; \
+ } \
+ \
+ to->extra_free = buf; \
+ } while (0)
+
struct _data {
unsigned char is_static:1;
unsigned char is_const:1;
diff --git a/xlators/protocol/client/src/client3_1-fops.c b/xlators/protocol/client/src/client3_1-fops.c
index e28079ff73c..fe928aecd19 100644
--- a/xlators/protocol/client/src/client3_1-fops.c
+++ b/xlators/protocol/client/src/client3_1-fops.c
@@ -836,9 +836,6 @@ client3_1_getxattr_cbk (struct rpc_req *req, struct iovec *iov, int count,
{
call_frame_t *frame = NULL;
dict_t *dict = NULL;
- char *buf = NULL;
- int dict_len = 0;
- int op_ret = 0;
int op_errno = EINVAL;
gfs3_getxattr_rsp rsp = {0,};
int ret = 0;
@@ -852,7 +849,7 @@ client3_1_getxattr_cbk (struct rpc_req *req, struct iovec *iov, int count,
frame->local = NULL;
if (-1 == req->rpc_status) {
- op_ret = -1;
+ rsp.op_ret = -1;
op_errno = ENOTCONN;
goto out;
}
@@ -860,35 +857,17 @@ client3_1_getxattr_cbk (struct rpc_req *req, struct iovec *iov, int count,
ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_getxattr_rsp);
if (ret < 0) {
gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed");
- op_ret = -1;
+ rsp.op_ret = -1;
op_errno = EINVAL;
goto out;
}
op_errno = gf_error_to_errno (rsp.op_errno);
- op_ret = rsp.op_ret;
- if (-1 != op_ret) {
- op_ret = -1;
- dict_len = rsp.dict.dict_len;
-
- if (dict_len > 0) {
- dict = dict_new();
- buf = memdup (rsp.dict.dict_val, rsp.dict.dict_len);
-
- GF_VALIDATE_OR_GOTO (frame->this->name, dict, out);
- GF_VALIDATE_OR_GOTO (frame->this->name, buf, out);
-
- ret = dict_unserialize (buf, dict_len, &dict);
- if (ret < 0) {
- gf_log (frame->this->name, GF_LOG_WARNING,
- "failed to unserialize xattr dict");
- op_errno = EINVAL;
- goto out;
- }
- dict->extra_free = buf;
- buf = NULL;
- }
- op_ret = 0;
+ 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);
}
out:
@@ -898,7 +877,7 @@ out:
strerror (op_errno),
(local) ? local->loc.path : "--");
}
- STACK_UNWIND_STRICT (getxattr, frame, op_ret, op_errno, dict);
+ STACK_UNWIND_STRICT (getxattr, frame, rsp.op_ret, op_errno, dict);
if (rsp.dict.dict_val) {
/* don't use GF_FREE, this memory was allocated by libc
@@ -907,9 +886,6 @@ out:
rsp.dict.dict_val = NULL;
}
- if (buf)
- GF_FREE (buf);
-
if (dict)
dict_unref (dict);
@@ -923,12 +899,9 @@ client3_1_fgetxattr_cbk (struct rpc_req *req, struct iovec *iov, int count,
void *myframe)
{
call_frame_t *frame = NULL;
- char *buf = NULL;
dict_t *dict = NULL;
gfs3_fgetxattr_rsp rsp = {0,};
int ret = 0;
- int dict_len = 0;
- int op_ret = 0;
int op_errno = EINVAL;
clnt_local_t *local = NULL;
xlator_t *this = NULL;
@@ -940,41 +913,24 @@ client3_1_fgetxattr_cbk (struct rpc_req *req, struct iovec *iov, int count,
frame->local = NULL;
if (-1 == req->rpc_status) {
- op_ret = -1;
+ rsp.op_ret = -1;
op_errno = ENOTCONN;
goto out;
}
ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_fgetxattr_rsp);
if (ret < 0) {
gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed");
- op_ret = -1;
+ rsp.op_ret = -1;
op_errno = EINVAL;
goto out;
}
op_errno = gf_error_to_errno (rsp.op_errno);
- op_ret = rsp.op_ret;
- if (-1 != op_ret) {
- op_ret = -1;
- dict_len = rsp.dict.dict_len;
-
- if (dict_len > 0) {
- dict = dict_new();
- GF_VALIDATE_OR_GOTO (frame->this->name, dict, out);
- buf = memdup (rsp.dict.dict_val, rsp.dict.dict_len);
- GF_VALIDATE_OR_GOTO (frame->this->name, buf, out);
-
- ret = dict_unserialize (buf, dict_len, &dict);
- if (ret < 0) {
- gf_log (frame->this->name, GF_LOG_WARNING,
- "failed to unserialize xattr dict");
- op_errno = EINVAL;
- goto out;
- }
- dict->extra_free = buf;
- buf = NULL;
- }
- op_ret = 0;
+ 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);
}
out:
if (rsp.op_ret == -1) {
@@ -982,7 +938,7 @@ out:
"remote operation failed: %s",
strerror (op_errno));
}
- STACK_UNWIND_STRICT (fgetxattr, frame, op_ret, op_errno, dict);
+ STACK_UNWIND_STRICT (fgetxattr, frame, rsp.op_ret, op_errno, dict);
if (rsp.dict.dict_val) {
/* don't use GF_FREE, this memory was allocated by libc
*/
@@ -990,9 +946,6 @@ out:
rsp.dict.dict_val = NULL;
}
- if (buf)
- GF_FREE (buf);
-
if (dict)
dict_unref (dict);
@@ -1399,11 +1352,8 @@ client3_1_xattrop_cbk (struct rpc_req *req, struct iovec *iov, int count,
{
call_frame_t *frame = NULL;
dict_t *dict = NULL;
- char *buf = NULL;
gfs3_xattrop_rsp rsp = {0,};
int ret = 0;
- int op_ret = 0;
- int dict_len = 0;
int op_errno = EINVAL;
clnt_local_t *local = NULL;
xlator_t *this = NULL;
@@ -1415,41 +1365,24 @@ client3_1_xattrop_cbk (struct rpc_req *req, struct iovec *iov, int count,
frame->local = NULL;
if (-1 == req->rpc_status) {
- op_ret = -1;
+ rsp.op_ret = -1;
op_errno = ENOTCONN;
goto out;
}
ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_xattrop_rsp);
if (ret < 0) {
gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed");
- op_ret = -1;
+ rsp.op_ret = -1;
op_errno = EINVAL;
goto out;
}
op_errno = rsp.op_errno;
- op_ret = rsp.op_ret;
- if (-1 != op_ret) {
- op_ret = -1;
- dict_len = rsp.dict.dict_len;
-
- if (dict_len > 0) {
- dict = dict_new();
- GF_VALIDATE_OR_GOTO (frame->this->name, dict, out);
-
- buf = memdup (rsp.dict.dict_val, rsp.dict.dict_len);
- GF_VALIDATE_OR_GOTO (frame->this->name, buf, out);
- op_ret = dict_unserialize (buf, dict_len, &dict);
- if (op_ret < 0) {
- gf_log (frame->this->name, GF_LOG_WARNING,
- "failed to unserialize xattr dict");
- op_errno = EINVAL;
- goto out;
- }
- dict->extra_free = buf;
- buf = NULL;
- }
- op_ret = 0;
+ 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);
}
out:
@@ -1460,7 +1393,7 @@ out:
strerror (gf_error_to_errno (rsp.op_errno)),
(local) ? local->loc.path : "--");
}
- STACK_UNWIND_STRICT (xattrop, frame, op_ret,
+ STACK_UNWIND_STRICT (xattrop, frame, rsp.op_ret,
gf_error_to_errno (op_errno), dict);
if (rsp.dict.dict_val) {
@@ -1470,9 +1403,6 @@ out:
rsp.dict.dict_val = NULL;
}
- if (buf)
- GF_FREE (buf);
-
if (dict)
dict_unref (dict);
@@ -1487,11 +1417,8 @@ client3_1_fxattrop_cbk (struct rpc_req *req, struct iovec *iov, int count,
{
call_frame_t *frame = NULL;
dict_t *dict = NULL;
- char *buf = NULL;
gfs3_fxattrop_rsp rsp = {0,};
int ret = 0;
- int op_ret = 0;
- int dict_len = 0;
int op_errno = 0;
clnt_local_t *local = NULL;
xlator_t *this = NULL;
@@ -1503,41 +1430,24 @@ client3_1_fxattrop_cbk (struct rpc_req *req, struct iovec *iov, int count,
frame->local = NULL;
if (-1 == req->rpc_status) {
- op_ret = -1;
+ rsp.op_ret = -1;
op_errno = ENOTCONN;
goto out;
}
ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gfs3_fxattrop_rsp);
if (ret < 0) {
- op_ret = -1;
+ rsp.op_ret = -1;
op_errno = EINVAL;
gf_log (this->name, GF_LOG_ERROR, "XDR decoding failed");
goto out;
}
op_errno = rsp.op_errno;
- op_ret = rsp.op_ret;
- if (-1 != op_ret) {
- op_ret = -1;
- dict_len = rsp.dict.dict_len;
-
- if (dict_len > 0) {
- dict = dict_new();
- GF_VALIDATE_OR_GOTO (frame->this->name, dict, out);
-
- buf = memdup (rsp.dict.dict_val, rsp.dict.dict_len);
- GF_VALIDATE_OR_GOTO (frame->this->name, buf, out);
- op_ret = dict_unserialize (buf, dict_len, &dict);
- if (op_ret < 0) {
- gf_log (frame->this->name, GF_LOG_WARNING,
- "failed to unserialize xattr dict");
- op_errno = EINVAL;
- goto out;
- }
- dict->extra_free = buf;
- buf = NULL;
- }
- op_ret = 0;
+ 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);
}
out:
@@ -1547,7 +1457,7 @@ out:
"remote operation failed: %s",
strerror (gf_error_to_errno (rsp.op_errno)));
}
- STACK_UNWIND_STRICT (fxattrop, frame, op_ret,
+ STACK_UNWIND_STRICT (fxattrop, frame, rsp.op_ret,
gf_error_to_errno (op_errno), dict);
if (rsp.dict.dict_val) {
@@ -1557,9 +1467,6 @@ out:
rsp.dict.dict_val = NULL;
}
- if (buf)
- GF_FREE (buf);
-
if (dict)
dict_unref (dict);
@@ -2211,8 +2118,7 @@ client3_1_lookup_cbk (struct rpc_req *req, struct iovec *iov, int count,
int op_errno = EINVAL;
dict_t *xattr = NULL;
inode_t *inode = NULL;
- char *buf = NULL;
- xlator_t *this = NULL;
+ xlator_t *this = NULL;
this = THIS;
@@ -2244,25 +2150,9 @@ client3_1_lookup_cbk (struct rpc_req *req, struct iovec *iov, int count,
rsp.op_ret = -1;
gf_stat_to_iatt (&rsp.stat, &stbuf);
- if (rsp.dict.dict_len > 0) {
- xattr = dict_new();
- GF_VALIDATE_OR_GOTO (frame->this->name, xattr, out);
-
- buf = memdup (rsp.dict.dict_val, rsp.dict.dict_len);
- GF_VALIDATE_OR_GOTO (frame->this->name, buf, out);
-
- ret = dict_unserialize (buf, rsp.dict.dict_len, &xattr);
- if (ret < 0) {
- gf_log (frame->this->name, GF_LOG_WARNING,
- "%s (%s): failed to unserialize dictionary",
- local->loc.path, uuid_utoa (inode->gfid));
- op_errno = EINVAL;
- goto out;
- }
-
- xattr->extra_free = buf;
- buf = NULL;
- }
+ GF_PROTOCOL_DICT_UNSERIALIZE (frame->this, xattr, (rsp.dict.dict_val),
+ (rsp.dict.dict_len), rsp.op_ret,
+ op_errno, out);
if ((!uuid_is_null (inode->gfid))
&& (uuid_compare (stbuf.ia_gfid, inode->gfid) != 0)) {
@@ -2301,11 +2191,6 @@ out:
/* don't use GF_FREE, this memory was allocated by libc
*/
free (rsp.dict.dict_val);
- rsp.dict.dict_val = NULL;
- }
-
- if (buf) {
- GF_FREE (buf);
}
return 0;
@@ -2560,7 +2445,6 @@ client3_1_lookup (call_frame_t *frame, xlator_t *this,
clnt_args_t *args = NULL;
gfs3_lookup_req req = {{0,},};
int ret = 0;
- size_t dict_len = 0;
int op_errno = ESTALE;
data_t *content = NULL;
struct iovec vector[MAX_IOVEC] = {{0}, };
@@ -2626,15 +2510,10 @@ client3_1_lookup (call_frame_t *frame, xlator_t *this,
rsp_iobref = NULL;
}
- ret = dict_allocate_and_serialize (args->dict,
- &req.dict.dict_val,
- &dict_len);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "failed to get serialized length of dict");
- op_errno = EINVAL;
- goto unwind;
- }
+ GF_PROTOCOL_DICT_SERIALIZE (this, args->dict,
+ (&req.dict.dict_val),
+ req.dict.dict_len,
+ op_errno, unwind);
}
req.path = (char *)args->loc->path;
@@ -2642,7 +2521,6 @@ client3_1_lookup (call_frame_t *frame, xlator_t *this,
req.bname = (char *)args->loc->name;
else
req.bname = "";
- req.dict.dict_len = dict_len;
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_LOOKUP, client3_1_lookup_cbk,
@@ -3030,7 +2908,6 @@ client3_1_symlink (call_frame_t *frame, xlator_t *this,
clnt_conf_t *conf = NULL;
clnt_args_t *args = NULL;
gfs3_symlink_req req = {{0,},};
- size_t dict_len = 0;
int ret = 0;
int op_errno = ESTALE;
@@ -3061,18 +2938,9 @@ client3_1_symlink (call_frame_t *frame, xlator_t *this,
req.path = (char *)args->loc->path;
req.linkname = (char *)args->linkname;
req.bname = (char *)args->loc->name;
- if (args->dict) {
- ret = dict_allocate_and_serialize (args->dict,
- &req.dict.dict_val,
- &dict_len);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "failed to get serialized length of dict");
- op_errno = EINVAL;
- goto unwind;
- }
- }
- req.dict.dict_len = dict_len;
+
+ GF_PROTOCOL_DICT_SERIALIZE (this, args->dict, (&req.dict.dict_val),
+ req.dict.dict_len, op_errno, unwind);
conf = this->private;
@@ -3237,7 +3105,6 @@ client3_1_mknod (call_frame_t *frame, xlator_t *this,
clnt_conf_t *conf = NULL;
clnt_args_t *args = NULL;
gfs3_mknod_req req = {{0,},};
- size_t dict_len = 0;
int ret = 0;
int op_errno = ESTALE;
@@ -3271,17 +3138,11 @@ client3_1_mknod (call_frame_t *frame, xlator_t *this,
req.mode = args->mode;
req.dev = args->rdev;
if (args->dict) {
- ret = dict_allocate_and_serialize (args->dict,
- &req.dict.dict_val,
- &dict_len);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "failed to get serialized length of dict");
- op_errno = EINVAL;
- goto unwind;
- }
+ GF_PROTOCOL_DICT_SERIALIZE (this, args->dict,
+ (&req.dict.dict_val),
+ req.dict.dict_len,
+ op_errno, unwind);
}
- req.dict.dict_len = dict_len;
conf = this->private;
@@ -3321,7 +3182,6 @@ client3_1_mkdir (call_frame_t *frame, xlator_t *this,
clnt_conf_t *conf = NULL;
clnt_args_t *args = NULL;
gfs3_mkdir_req req = {{0,},};
- size_t dict_len = 0;
int ret = 0;
int op_errno = ESTALE;
@@ -3354,17 +3214,11 @@ client3_1_mkdir (call_frame_t *frame, xlator_t *this,
req.bname = (char *)args->loc->name;
req.mode = args->mode;
if (args->dict) {
- ret = dict_allocate_and_serialize (args->dict,
- &req.dict.dict_val,
- &dict_len);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "failed to get serialized length of dict");
- op_errno = EINVAL;
- goto unwind;
- }
+ GF_PROTOCOL_DICT_SERIALIZE (this, args->dict,
+ (&req.dict.dict_val),
+ req.dict.dict_len,
+ op_errno, unwind);
}
- req.dict.dict_len = dict_len;
conf = this->private;
@@ -3403,7 +3257,6 @@ client3_1_create (call_frame_t *frame, xlator_t *this,
clnt_conf_t *conf = NULL;
clnt_args_t *args = NULL;
gfs3_create_req req = {{0,},};
- size_t dict_len = 0;
int ret = 0;
int op_errno = ESTALE;
@@ -3439,17 +3292,11 @@ client3_1_create (call_frame_t *frame, xlator_t *this,
req.mode = args->mode;
req.flags = gf_flags_from_flags (args->flags);
if (args->dict) {
- ret = dict_allocate_and_serialize (args->dict,
- &req.dict.dict_val,
- &dict_len);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "failed to get serialized length of dict");
- op_errno = EINVAL;
- goto unwind;
- }
+ GF_PROTOCOL_DICT_SERIALIZE (this, args->dict,
+ (&req.dict.dict_val),
+ req.dict.dict_len,
+ op_errno, unwind);
}
- req.dict.dict_len = dict_len;
conf = this->private;
@@ -3977,7 +3824,6 @@ client3_1_setxattr (call_frame_t *frame, xlator_t *this,
clnt_args_t *args = NULL;
gfs3_setxattr_req req = {{0,},};
int ret = 0;
- size_t dict_len = 0;
int op_errno = ESTALE;
if (!frame || !this || !data)
@@ -3997,17 +3843,12 @@ client3_1_setxattr (call_frame_t *frame, xlator_t *this,
!uuid_is_null (*((uuid_t*)req.gfid)),
unwind, op_errno, EINVAL);
if (args->dict) {
- ret = dict_allocate_and_serialize (args->dict,
- &req.dict.dict_val,
- &dict_len);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "failed to get serialized dict");
- op_errno = EINVAL;
- goto unwind;
- }
- req.dict.dict_len = dict_len;
+ GF_PROTOCOL_DICT_SERIALIZE (this, args->dict,
+ (&req.dict.dict_val),
+ req.dict.dict_len,
+ op_errno, unwind);
}
+
req.flags = args->flags;
req.path = (char *)args->loc->path;
@@ -4047,7 +3888,6 @@ client3_1_fsetxattr (call_frame_t *frame, xlator_t *this,
gfs3_fsetxattr_req req = {{0,},};
int op_errno = ESTALE;
int ret = 0;
- size_t dict_len = 0;
if (!frame || !this || !data)
goto unwind;
@@ -4062,15 +3902,10 @@ client3_1_fsetxattr (call_frame_t *frame, xlator_t *this,
memcpy (req.gfid, args->fd->inode->gfid, 16);
if (args->dict) {
- ret = dict_allocate_and_serialize (args->dict,
- &req.dict.dict_val,
- &dict_len);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "failed to get serialized dict");
- goto unwind;
- }
- req.dict.dict_len = dict_len;
+ GF_PROTOCOL_DICT_SERIALIZE (this, args->dict,
+ (&req.dict.dict_val),
+ req.dict.dict_len,
+ op_errno, unwind);
}
ret = client_submit_request (this, &req, frame, conf->fops,
@@ -4207,7 +4042,7 @@ client3_1_getxattr (call_frame_t *frame, xlator_t *this,
gfs3_getxattr_req req = {{0,},};
dict_t *dict = NULL;
int ret = 0;
- int32_t op_ret = 0;
+ int32_t op_ret = -1;
int op_errno = ESTALE;
int count = 0;
clnt_local_t *local = NULL;
@@ -4217,14 +4052,12 @@ client3_1_getxattr (call_frame_t *frame, xlator_t *this,
struct iovec vector[MAX_IOVEC] = {{0}, };
if (!frame || !this || !data) {
- op_ret = -1;
op_errno = 0;
goto unwind;
}
args = data;
if (!(args->loc && args->loc->inode)) {
- op_ret = -1;
op_errno = EINVAL;
goto unwind;
}
@@ -4232,7 +4065,6 @@ client3_1_getxattr (call_frame_t *frame, xlator_t *this,
local = GF_CALLOC (1, sizeof (*local),
gf_client_mt_clnt_local_t);
if (!local) {
- op_ret = -1;
op_errno = ENOMEM;
goto unwind;
}
@@ -4240,7 +4072,6 @@ client3_1_getxattr (call_frame_t *frame, xlator_t *this,
rsp_iobref = iobref_new ();
if (rsp_iobref == NULL) {
- op_ret = -1;
op_errno = ENOMEM;
goto unwind;
}
@@ -4248,7 +4079,6 @@ client3_1_getxattr (call_frame_t *frame, xlator_t *this,
/* TODO: what is the size we should send ? */
rsp_iobuf = iobuf_get (this->ctx->iobuf_pool);
if (rsp_iobuf == NULL) {
- op_ret = -1;
op_errno = ENOMEM;
goto unwind;
}
@@ -4290,7 +4120,6 @@ client3_1_getxattr (call_frame_t *frame, xlator_t *this,
if (ret) {
gf_log (this->name, GF_LOG_WARNING,
"Client dump locks failed");
- op_ret = -1;
op_errno = EINVAL;
}
@@ -4308,14 +4137,14 @@ client3_1_getxattr (call_frame_t *frame, xlator_t *this,
NULL, 0, local->iobref,
(xdrproc_t)xdr_gfs3_getxattr_req);
if (ret) {
- op_ret = -1;
op_errno = ENOTCONN;
goto unwind;
}
return 0;
unwind:
- gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s", strerror (op_errno));
+ gf_log (this->name, GF_LOG_WARNING, "failed to send the fop: %s",
+ strerror (op_errno));
local = frame->local;
frame->local = NULL;
client_local_wipe (local);
@@ -4343,7 +4172,6 @@ client3_1_xattrop (call_frame_t *frame, xlator_t *this,
clnt_args_t *args = NULL;
gfs3_xattrop_req req = {{0,},};
int ret = 0;
- size_t dict_len = 0;
int op_errno = ESTALE;
int count = 0;
clnt_local_t *local = NULL;
@@ -4400,17 +4228,12 @@ client3_1_xattrop (call_frame_t *frame, xlator_t *this,
!uuid_is_null (*((uuid_t*)req.gfid)),
unwind, op_errno, EINVAL);
if (args->dict) {
- ret = dict_allocate_and_serialize (args->dict,
- &req.dict.dict_val,
- &dict_len);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "failed to get serialized dict");
- op_errno = EINVAL;
- goto unwind;
- }
- req.dict.dict_len = dict_len;
+ GF_PROTOCOL_DICT_SERIALIZE (this, args->dict,
+ (&req.dict.dict_val),
+ req.dict.dict_len,
+ op_errno, unwind);
}
+
req.flags = args->flags;
req.path = (char *)args->loc->path;
@@ -4467,7 +4290,6 @@ client3_1_fxattrop (call_frame_t *frame, xlator_t *this,
gfs3_fxattrop_req req = {{0,},};
int op_errno = ESTALE;
int ret = 0;
- size_t dict_len = 0;
int count = 0;
clnt_local_t *local = NULL;
struct iobref *rsp_iobref = NULL;
@@ -4519,15 +4341,10 @@ client3_1_fxattrop (call_frame_t *frame, xlator_t *this,
rsp_iobref = NULL;
if (args->dict) {
- ret = dict_allocate_and_serialize (args->dict,
- &req.dict.dict_val,
- &dict_len);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "failed to get serialized dict");
- goto unwind;
- }
- req.dict.dict_len = dict_len;
+ GF_PROTOCOL_DICT_SERIALIZE (this, args->dict,
+ (&req.dict.dict_val),
+ req.dict.dict_len,
+ op_errno, unwind);
}
ret = client_submit_request (this, &req, frame, conf->fops,
@@ -5155,7 +4972,6 @@ client3_1_readdirp (call_frame_t *frame, xlator_t *this,
struct iovec *rsphdr = NULL;
struct iovec vector[MAX_IOVEC] = {{0}, };
clnt_local_t *local = NULL;
- size_t dict_len = 0;
if (!frame || !this || !data)
goto unwind;
@@ -5209,16 +5025,10 @@ client3_1_readdirp (call_frame_t *frame, xlator_t *this,
memcpy (req.gfid, args->fd->inode->gfid, 16);
if (args->dict) {
- ret = dict_allocate_and_serialize (args->dict,
- &req.dict.dict_val,
- &dict_len);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "failed to get serialized dict");
- op_errno = EINVAL;
- goto unwind;
- }
- req.dict.dict_len = dict_len;
+ GF_PROTOCOL_DICT_SERIALIZE (this, args->dict,
+ (&req.dict.dict_val),
+ req.dict.dict_len,
+ op_errno, unwind);
}
ret = client_submit_request (this, &req, frame, conf->fops,
diff --git a/xlators/protocol/server/src/server3_1-fops.c b/xlators/protocol/server/src/server3_1-fops.c
index 79aede07461..62aca398dae 100644
--- a/xlators/protocol/server/src/server3_1-fops.c
+++ b/xlators/protocol/server/src/server3_1-fops.c
@@ -72,7 +72,6 @@ server_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
inode_t *link_inode = NULL;
loc_t fresh_loc = {0,};
gfs3_lookup_rsp rsp = {0,};
- int32_t ret = -1;
uuid_t rootgfid = {0,};
state = CALL_STATE(frame);
@@ -94,36 +93,10 @@ server_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
if ((op_ret >= 0) && dict) {
- rsp.dict.dict_len = dict_serialized_length (dict);
- if (rsp.dict.dict_len < 0) {
- gf_log (this->name, GF_LOG_ERROR,
- "%s (%s): failed to get serialized "
- "length of reply dict",
- state->loc.path, uuid_utoa (state->loc.inode->gfid));
- op_ret = -1;
- op_errno = EINVAL;
- rsp.dict.dict_len = 0;
- goto out;
- }
-
- rsp.dict.dict_val = GF_CALLOC (1, rsp.dict.dict_len,
- gf_server_mt_rsp_buf_t);
- if (!rsp.dict.dict_val) {
- op_ret = -1;
- op_errno = ENOMEM;
- rsp.dict.dict_len = 0;
- goto out;
- }
- ret = dict_serialize (dict, rsp.dict.dict_val);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_ERROR,
- "%s (%s): failed to serialize reply dict",
- state->loc.path, uuid_utoa (state->loc.inode->gfid));
- op_ret = -1;
- op_errno = -ret;
- rsp.dict.dict_len = 0;
- goto out;
- }
+ GF_PROTOCOL_DICT_SERIALIZE (this, dict,
+ (&rsp.dict.dict_val),
+ rsp.dict.dict_len,
+ op_errno, out);
}
gf_stat_from_iatt (&rsp.postparent, postparent);
@@ -723,50 +696,23 @@ server_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, dict_t *dict)
{
gfs3_getxattr_rsp rsp = {0,};
- int32_t len = 0;
- int32_t ret = -1;
rpcsvc_request_t *req = NULL;
server_state_t *state = NULL;
state = CALL_STATE (frame);
if (op_ret >= 0) {
- len = dict_serialized_length (dict);
- if (len < 0) {
- gf_log (this->name, GF_LOG_ERROR,
- "%s (%s): failed to get serialized length of "
- "reply dict", state->loc.path,
- uuid_utoa (state->resolve.gfid));
- op_ret = -1;
- op_errno = EINVAL;
- len = 0;
- goto out;
- }
-
- rsp.dict.dict_val = GF_CALLOC (len, sizeof (char),
- gf_server_mt_rsp_buf_t);
- if (!rsp.dict.dict_val) {
- op_ret = -1;
- op_errno = ENOMEM;
- len = 0;
- goto out;
- }
- ret = dict_serialize (dict, rsp.dict.dict_val);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_ERROR,
- "%s (%s): failed to serialize reply dict",
- state->loc.path, uuid_utoa (state->resolve.gfid));
- op_ret = -1;
- op_errno = EINVAL;
- len = 0;
- }
+ GF_PROTOCOL_DICT_SERIALIZE (this, dict,
+ (&rsp.dict.dict_val),
+ rsp.dict.dict_len,
+ op_errno, out);
}
out:
req = frame->local;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
- rsp.dict.dict_len = len;
+
if (op_ret == -1)
gf_log (this->name, GF_LOG_INFO,
"%"PRId64": GETXATTR %s (%s) ==> %"PRId32" (%s)",
@@ -788,41 +734,16 @@ server_fgetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, dict_t *dict)
{
gfs3_fgetxattr_rsp rsp = {0,};
- int32_t len = 0;
- int32_t ret = -1;
server_state_t *state = NULL;
rpcsvc_request_t *req = NULL;
state = CALL_STATE (frame);
if (op_ret >= 0) {
- len = dict_serialized_length (dict);
- if (len < 0) {
- gf_log (this->name, GF_LOG_ERROR,
- "%s (%s): failed to get serialized "
- "length of reply dict",
- state->loc.path, uuid_utoa (state->resolve.gfid));
- op_ret = -1;
- op_errno = EINVAL;
- len = 0;
- goto out;
- }
- rsp.dict.dict_val = GF_CALLOC (1, len, gf_server_mt_rsp_buf_t);
- if (!rsp.dict.dict_val) {
- op_ret = -1;
- op_errno = ENOMEM;
- len = 0;
- goto out;
- }
- ret = dict_serialize (dict, rsp.dict.dict_val);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_ERROR,
- "%s (%s): failed to serialize reply dict",
- state->loc.path, uuid_utoa (state->resolve.gfid));
- op_ret = -1;
- op_errno = -ret;
- len = 0;
- }
+ GF_PROTOCOL_DICT_SERIALIZE (this, dict,
+ (&rsp.dict.dict_val),
+ rsp.dict.dict_len,
+ op_errno, out);
}
out:
@@ -830,7 +751,7 @@ out:
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
- rsp.dict.dict_len = len;
+
if (op_ret == -1)
gf_log (this->name, GF_LOG_INFO,
"%"PRId64": FGETXATTR %"PRId64" (%s) ==> %"PRId32" (%s)",
@@ -1600,8 +1521,6 @@ server_xattrop_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, dict_t *dict)
{
gfs3_xattrop_rsp rsp = {0,};
- int32_t len = 0;
- int32_t ret = -1;
server_state_t *state = NULL;
rpcsvc_request_t *req = NULL;
@@ -1617,42 +1536,17 @@ server_xattrop_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
if ((op_ret >= 0) && dict) {
- len = dict_serialized_length (dict);
- if (len < 0) {
- gf_log (this->name, GF_LOG_ERROR,
- "%s (%s): failed to get serialized length"
- " for reply dict",
- state->loc.path,
- uuid_utoa (state->loc.inode->gfid));
- op_ret = -1;
- op_errno = EINVAL;
- len = 0;
- goto out;
- }
- rsp.dict.dict_val = GF_CALLOC (1, len, gf_server_mt_rsp_buf_t);
- if (!rsp.dict.dict_val) {
- op_ret = -1;
- op_errno = ENOMEM;
- len = 0;
- goto out;
- }
- ret = dict_serialize (dict, rsp.dict.dict_val);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_ERROR,
- "%s (%s): failed to serialize reply dict",
- state->loc.path,
- uuid_utoa (state->loc.inode->gfid));
- op_ret = -1;
- op_errno = -ret;
- len = 0;
- }
+ GF_PROTOCOL_DICT_SERIALIZE (this, dict,
+ (&rsp.dict.dict_val),
+ rsp.dict.dict_len,
+ op_errno, out);
}
out:
req = frame->local;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
- rsp.dict.dict_len = len;
+
if (op_ret == -1)
gf_log (this->name, GF_LOG_INFO,
"%"PRId64": XATTROP %s (%s) ==> %"PRId32" (%s)",
@@ -1675,8 +1569,6 @@ server_fxattrop_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, dict_t *dict)
{
gfs3_xattrop_rsp rsp = {0,};
- int32_t len = 0;
- int32_t ret = -1;
server_state_t *state = NULL;
rpcsvc_request_t *req = NULL;
@@ -1692,42 +1584,17 @@ server_fxattrop_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
if ((op_ret >= 0) && dict) {
- len = dict_serialized_length (dict);
- if (len < 0) {
- gf_log (this->name, GF_LOG_ERROR,
- "fd - %"PRId64" (%s): failed to get "
- "serialized length for reply dict",
- state->resolve.fd_no,
- uuid_utoa (state->fd->inode->gfid));
- op_ret = -1;
- op_errno = EINVAL;
- len = 0;
- goto out;
- }
- rsp.dict.dict_val = GF_CALLOC (1, len, gf_server_mt_rsp_buf_t);
- if (!rsp.dict.dict_val) {
- op_ret = -1;
- op_errno = ENOMEM;
- len = 0;
- goto out;
- }
- ret = dict_serialize (dict, rsp.dict.dict_val);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_ERROR,
- "fd - %"PRId64" (%s): failed to serialize "
- "reply dict", state->resolve.fd_no,
- uuid_utoa (state->fd->inode->gfid));
- op_ret = -1;
- op_errno = -ret;
- len = 0;
- }
+ GF_PROTOCOL_DICT_SERIALIZE (this, dict,
+ (&rsp.dict.dict_val),
+ rsp.dict.dict_len,
+ op_errno, out);
}
out:
req = frame->local;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
- rsp.dict.dict_len = len;
+
if (op_ret == -1)
gf_log (this->name, GF_LOG_INFO,
"%"PRId64": FXATTROP %"PRId64" (%s) ==> %"PRId32" (%s)",
@@ -2913,12 +2780,12 @@ out:
int
server_create (rpcsvc_request_t *req)
{
- server_state_t *state = NULL;
- call_frame_t *frame = NULL;
- dict_t *params = NULL;
- char *buf = NULL;
- gfs3_create_req args = {{0,},};
- int ret = -1;
+ server_state_t *state = NULL;
+ call_frame_t *frame = NULL;
+ dict_t *params = NULL;
+ gfs3_create_req args = {{0,},};
+ int ret = -1;
+ int op_errno = 0;
if (!req)
return ret;
@@ -2945,32 +2812,14 @@ server_create (rpcsvc_request_t *req)
req->rpc_err = GARBAGE_ARGS;
goto out;
}
- if (args.dict.dict_len) {
- /* Unserialize the dictionary */
- params = dict_new ();
-
- buf = memdup (args.dict.dict_val, args.dict.dict_len);
- if (buf == NULL) {
- goto out;
- }
- ret = dict_unserialize (buf, args.dict.dict_len,
- &params);
- if (ret < 0) {
- gf_log (state->conn->bound_xl->name, GF_LOG_ERROR,
- "%"PRId64": %s (%s): failed to "
- "unserialize req-buffer to dictionary",
- frame->root->unique, state->resolve.path,
- uuid_utoa (state->resolve.gfid));
- goto out;
- }
+ /* Unserialize the dictionary */
+ GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->bound_xl, params,
+ (args.dict.dict_val),
+ (args.dict.dict_len), ret,
+ op_errno, out);
- state->params = params;
-
- params->extra_free = buf;
-
- buf = NULL;
- }
+ state->params = params;
state->resolve.bname = gf_strdup (args.bname);
state->mode = args.mode;
@@ -2993,13 +2842,12 @@ server_create (rpcsvc_request_t *req)
return ret;
out:
+ if (op_errno)
+ req->rpc_err = GARBAGE_ARGS;
+
if (params)
dict_unref (params);
- if (buf) {
- GF_FREE (buf);
- }
-
/* memory allocated by libc, don't use GF_FREE */
if (args.dict.dict_val != NULL) {
free (args.dict.dict_val);
@@ -3516,9 +3364,9 @@ server_setxattr (rpcsvc_request_t *req)
dict_t *dict = NULL;
call_frame_t *frame = NULL;
server_connection_t *conn = NULL;
- char *buf = NULL;
gfs3_setxattr_req args = {{0,},};
int32_t ret = -1;
+ int op_errno = 0;
if (!req)
return ret;
@@ -3552,26 +3400,12 @@ server_setxattr (rpcsvc_request_t *req)
state->flags = args.flags;
memcpy (state->resolve.gfid, args.gfid, 16);
- if (args.dict.dict_len) {
- dict = dict_new ();
- buf = memdup (args.dict.dict_val, args.dict.dict_len);
- GF_VALIDATE_OR_GOTO (conn->bound_xl->name, buf, out);
-
- ret = dict_unserialize (buf, args.dict.dict_len, &dict);
- if (ret < 0) {
- gf_log (conn->bound_xl->name, GF_LOG_ERROR,
- "%"PRId64": %s (%s): failed to "
- "unserialize request buffer to dictionary",
- frame->root->unique, state->loc.path,
- uuid_utoa (state->resolve.gfid));
- goto err;
- }
+ GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->bound_xl, dict,
+ (args.dict.dict_val),
+ (args.dict.dict_len), ret,
+ op_errno, out);
- dict->extra_free = buf;
- buf = NULL;
-
- state->dict = dict;
- }
+ state->dict = dict;
/* There can be some commands hidden in key, check and proceed */
gf_server_check_setxattr_cmd (frame, dict);
@@ -3580,17 +3414,14 @@ server_setxattr (rpcsvc_request_t *req)
resolve_and_resume (frame, server_setxattr_resume);
return ret;
-err:
+out:
if (dict)
dict_unref (dict);
- server_setxattr_cbk (frame, NULL, frame->this, -1, EINVAL);
- ret = 0;
-out:
- if (buf)
- GF_FREE (buf);
- return ret;
+ if (op_errno)
+ req->rpc_err = GARBAGE_ARGS;
+ return ret;
}
@@ -3602,9 +3433,9 @@ server_fsetxattr (rpcsvc_request_t *req)
dict_t *dict = NULL;
server_connection_t *conn = NULL;
call_frame_t *frame = NULL;
- char *buf = NULL;
gfs3_fsetxattr_req args = {{0,},};
int32_t ret = -1;
+ int op_errno = 0;
if (!req)
return ret;
@@ -3638,38 +3469,22 @@ server_fsetxattr (rpcsvc_request_t *req)
state->flags = args.flags;
memcpy (state->resolve.gfid, args.gfid, 16);
- if (args.dict.dict_len) {
- dict = dict_new ();
- buf = memdup (args.dict.dict_val, args.dict.dict_len);
- GF_VALIDATE_OR_GOTO (conn->bound_xl->name, buf, out);
-
- ret = dict_unserialize (buf, args.dict.dict_len, &dict);
- if (ret < 0) {
- gf_log (conn->bound_xl->name, GF_LOG_ERROR,
- "%"PRId64": %s (%s): failed to "
- "unserialize request buffer to dictionary",
- frame->root->unique, state->loc.path,
- uuid_utoa (state->resolve.gfid));
- goto err;
- }
- dict->extra_free = buf;
- buf = NULL;
- state->dict = dict;
- }
+ GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->bound_xl, dict,
+ (args.dict.dict_val),
+ (args.dict.dict_len), ret,
+ op_errno, out);
+
+ state->dict = dict;
ret = 0;
resolve_and_resume (frame, server_fsetxattr_resume);
return ret;
-err:
+out:
if (dict)
dict_unref (dict);
-
- server_setxattr_cbk (frame, NULL, frame->this, -1, EINVAL);
- ret = 0;
-out:
- if (buf)
- GF_FREE (buf);
+ if (op_errno)
+ req->rpc_err = GARBAGE_ARGS;
return ret;
}
@@ -3682,9 +3497,9 @@ server_fxattrop (rpcsvc_request_t *req)
server_state_t *state = NULL;
server_connection_t *conn = NULL;
call_frame_t *frame = NULL;
- char *buf = NULL;
gfs3_fxattrop_req args = {{0,},};
int32_t ret = -1;
+ int op_errno = 0;
if (!req)
return ret;
@@ -3718,40 +3533,24 @@ server_fxattrop (rpcsvc_request_t *req)
state->flags = args.flags;
memcpy (state->resolve.gfid, args.gfid, 16);
- if (args.dict.dict_len) {
- /* Unserialize the dictionary */
- dict = dict_new ();
-
- buf = memdup (args.dict.dict_val, args.dict.dict_len);
- GF_VALIDATE_OR_GOTO (conn->bound_xl->name, buf, out);
-
- ret = dict_unserialize (buf, args.dict.dict_len, &dict);
- if (ret < 0) {
- gf_log (conn->bound_xl->name, GF_LOG_ERROR,
- "fd - %"PRId64" (%s): failed to unserialize "
- "request buffer to dictionary",
- state->resolve.fd_no,
- uuid_utoa (state->fd->inode->gfid));
- goto fail;
- }
- dict->extra_free = buf;
- buf = NULL;
+ GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->bound_xl, dict,
+ (args.dict.dict_val),
+ (args.dict.dict_len), ret,
+ op_errno, out);
- state->dict = dict;
- }
+ state->dict = dict;
ret = 0;
resolve_and_resume (frame, server_fxattrop_resume);
return ret;
-fail:
+out:
if (dict)
dict_unref (dict);
+ if (op_errno)
+ req->rpc_err = GARBAGE_ARGS;
- server_fxattrop_cbk (frame, NULL, frame->this, -1, EINVAL, NULL);
- ret = 0;
-out:
return ret;
}
@@ -3764,9 +3563,9 @@ server_xattrop (rpcsvc_request_t *req)
server_state_t *state = NULL;
server_connection_t *conn = NULL;
call_frame_t *frame = NULL;
- char *buf = NULL;
gfs3_xattrop_req args = {{0,},};
int32_t ret = -1;
+ int op_errno = 0;
if (!req)
return ret;
@@ -3800,39 +3599,24 @@ server_xattrop (rpcsvc_request_t *req)
state->flags = args.flags;
memcpy (state->resolve.gfid, args.gfid, 16);
- if (args.dict.dict_len) {
- /* Unserialize the dictionary */
- dict = dict_new ();
-
- buf = memdup (args.dict.dict_val, args.dict.dict_len);
- GF_VALIDATE_OR_GOTO (conn->bound_xl->name, buf, out);
-
- ret = dict_unserialize (buf, args.dict.dict_len, &dict);
- if (ret < 0) {
- gf_log (conn->bound_xl->name, GF_LOG_ERROR,
- "fd - %"PRId64" (%s): failed to unserialize "
- "request buffer to dictionary",
- state->resolve.fd_no,
- uuid_utoa (state->fd->inode->gfid));
- goto fail;
- }
- dict->extra_free = buf;
- buf = NULL;
+ GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->bound_xl, dict,
+ (args.dict.dict_val),
+ (args.dict.dict_len), ret,
+ op_errno, out);
- state->dict = dict;
- }
+ state->dict = dict;
ret = 0;
resolve_and_resume (frame, server_xattrop_resume);
return ret;
-fail:
+out:
if (dict)
dict_unref (dict);
- server_xattrop_cbk (frame, NULL, frame->this, -1, EINVAL, NULL);
- ret = 0;
-out:
+ if (op_errno)
+ req->rpc_err = GARBAGE_ARGS;
+
return ret;
}
@@ -4075,10 +3859,11 @@ server_readdirp (rpcsvc_request_t *req)
{
server_state_t *state = NULL;
call_frame_t *frame = NULL;
- char *buf = NULL;
gfs3_readdirp_req args = {{0,},};
size_t headers_size = 0;
int ret = -1;
+ int op_errno = 0;
+
if (!req)
return ret;
@@ -4119,32 +3904,18 @@ server_readdirp (rpcsvc_request_t *req)
state->offset = args.offset;
memcpy (state->resolve.gfid, args.gfid, 16);
- if (args.dict.dict_len) {
- /* Unserialize the dictionary */
- state->dict = dict_new ();
-
- buf = memdup (args.dict.dict_val, args.dict.dict_len);
- if (buf == NULL) {
- goto out;
- }
+ GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->bound_xl, state->dict,
+ (args.dict.dict_val),
+ (args.dict.dict_len), ret,
+ op_errno, out);
- ret = dict_unserialize (buf, args.dict.dict_len,
- &state->dict);
- if (ret < 0) {
- gf_log (state->conn->bound_xl->name, GF_LOG_ERROR,
- "%"PRId64": failed to unserialize req-buffer "
- " to dictionary", frame->root->unique);
- goto out;
- }
-
- state->dict->extra_free = buf;
-
- buf = NULL;
- }
ret = 0;
resolve_and_resume (frame, server_readdirp_resume);
out:
+ if (op_errno)
+ req->rpc_err = GARBAGE_ARGS;
+
return ret;
}
@@ -4254,9 +4025,9 @@ server_mknod (rpcsvc_request_t *req)
server_state_t *state = NULL;
call_frame_t *frame = NULL;
dict_t *params = NULL;
- char *buf = NULL;
gfs3_mknod_req args = {{0,},};
int ret = -1;
+ int op_errno = 0;
if (!req)
return ret;
@@ -4284,32 +4055,12 @@ server_mknod (rpcsvc_request_t *req)
goto out;
}
- if (args.dict.dict_len) {
- /* Unserialize the dictionary */
- params = dict_new ();
-
- buf = memdup (args.dict.dict_val, args.dict.dict_len);
- if (buf == NULL) {
- goto out;
- }
-
- ret = dict_unserialize (buf, args.dict.dict_len,
- &params);
- if (ret < 0) {
- gf_log (state->conn->bound_xl->name, GF_LOG_ERROR,
- "%"PRId64": %s (%s): failed to "
- "unserialize req-buffer to dictionary",
- frame->root->unique, state->resolve.path,
- uuid_utoa (state->resolve.gfid));
- goto out;
- }
-
- state->params = params;
-
- params->extra_free = buf;
+ GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->bound_xl, params,
+ (args.dict.dict_val),
+ (args.dict.dict_len), ret,
+ op_errno, out);
- buf = NULL;
- }
+ state->params = params;
state->resolve.type = RESOLVE_NOT;
memcpy (state->resolve.pargfid, args.pargfid, 16);
@@ -4328,13 +4079,12 @@ server_mknod (rpcsvc_request_t *req)
return ret;
out:
+ if (op_errno)
+ req->rpc_err = GARBAGE_ARGS;
+
if (params)
dict_unref (params);
- if (buf) {
- GF_FREE (buf);
- }
-
/* memory allocated by libc, don't use GF_FREE */
if (args.dict.dict_val != NULL) {
free (args.dict.dict_val);
@@ -4351,9 +4101,9 @@ server_mkdir (rpcsvc_request_t *req)
server_state_t *state = NULL;
call_frame_t *frame = NULL;
dict_t *params = NULL;
- char *buf = NULL;
gfs3_mkdir_req args = {{0,},};
int ret = -1;
+ int op_errno = 0;
if (!req)
return ret;
@@ -4380,32 +4130,12 @@ server_mkdir (rpcsvc_request_t *req)
req->rpc_err = GARBAGE_ARGS;
goto out;
}
- if (args.dict.dict_len) {
- /* Unserialize the dictionary */
- params = dict_new ();
-
- buf = memdup (args.dict.dict_val, args.dict.dict_len);
- if (buf == NULL) {
- goto out;
- }
-
- ret = dict_unserialize (buf, args.dict.dict_len,
- &params);
- if (ret < 0) {
- gf_log (state->conn->bound_xl->name, GF_LOG_ERROR,
- "%"PRId64": %s (%s): failed to "
- "unserialize req-buffer to dictionary",
- frame->root->unique, state->resolve.path,
- uuid_utoa (state->resolve.gfid));
- goto out;
- }
+ GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->bound_xl, params,
+ (args.dict.dict_val),
+ (args.dict.dict_len), ret,
+ op_errno, out);
- state->params = params;
-
- params->extra_free = buf;
-
- buf = NULL;
- }
+ state->params = params;
state->resolve.type = RESOLVE_NOT;
memcpy (state->resolve.pargfid, args.pargfid, 16);
@@ -4423,13 +4153,12 @@ server_mkdir (rpcsvc_request_t *req)
return ret;
out:
+ if (op_errno)
+ req->rpc_err = GARBAGE_ARGS;
+
if (params)
dict_unref (params);
- if (buf) {
- GF_FREE (buf);
- }
-
if (args.dict.dict_val != NULL) {
/* memory allocated by libc, don't use GF_FREE */
free (args.dict.dict_val);
@@ -4787,9 +4516,9 @@ server_symlink (rpcsvc_request_t *req)
server_state_t *state = NULL;
call_frame_t *frame = NULL;
dict_t *params = NULL;
- char *buf = NULL;
gfs3_symlink_req args = {{0,},};
int ret = -1;
+ int op_errno = 0;
if (!req)
return ret;
@@ -4818,32 +4547,12 @@ server_symlink (rpcsvc_request_t *req)
goto out;
}
- if (args.dict.dict_len) {
- /* Unserialize the dictionary */
- params = dict_new ();
+ GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->bound_xl, params,
+ (args.dict.dict_val),
+ (args.dict.dict_len), ret,
+ op_errno, out);
- buf = memdup (args.dict.dict_val, args.dict.dict_len);
- if (buf == NULL) {
- goto out;
- }
-
- ret = dict_unserialize (buf, args.dict.dict_len,
- &params);
- if (ret < 0) {
- gf_log (state->conn->bound_xl->name, GF_LOG_ERROR,
- "%"PRId64": %s (%s): failed to "
- "unserialize req-buffer to dictionary",
- frame->root->unique, state->resolve.path,
- uuid_utoa (state->resolve.gfid));
- goto out;
- }
-
- state->params = params;
-
- params->extra_free = buf;
-
- buf = NULL;
- }
+ state->params = params;
state->resolve.type = RESOLVE_NOT;
memcpy (state->resolve.pargfid, args.pargfid, 16);
@@ -4859,13 +4568,12 @@ server_symlink (rpcsvc_request_t *req)
}
return ret;
out:
+ if (op_errno)
+ req->rpc_err = GARBAGE_ARGS;
+
if (params)
dict_unref (params);
- if (buf) {
- GF_FREE (buf);
- }
-
/* memory allocated by libc, don't use GF_FREE */
if (args.dict.dict_val != NULL) {
free (args.dict.dict_val);
@@ -5139,9 +4847,9 @@ server_lookup (rpcsvc_request_t *req)
server_connection_t *conn = NULL;
server_state_t *state = NULL;
dict_t *xattr_req = NULL;
- char *buf = NULL;
gfs3_lookup_req args = {{0,},};
int ret = -1;
+ int op_errno = 0;
GF_VALIDATE_OR_GOTO ("server", req, err);
@@ -5184,32 +4892,11 @@ server_lookup (rpcsvc_request_t *req)
memcpy (state->resolve.gfid, args.gfid, 16);
}
- if (args.dict.dict_len) {
- /* Unserialize the dictionary */
- xattr_req = dict_new ();
-
- buf = memdup (args.dict.dict_val, args.dict.dict_len);
- if (buf == NULL) {
- goto out;
- }
-
- ret = dict_unserialize (buf, args.dict.dict_len,
- &xattr_req);
- if (ret < 0) {
- gf_log (conn->bound_xl->name, GF_LOG_ERROR,
- "%"PRId64": %s (%s): failed to "
- "unserialize req-buffer to dictionary",
- frame->root->unique, state->resolve.path,
- uuid_utoa (state->resolve.gfid));
- goto out;
- }
-
- state->dict = xattr_req;
-
- xattr_req->extra_free = buf;
-
- buf = NULL;
- }
+ GF_PROTOCOL_DICT_UNSERIALIZE (state->conn->bound_xl, xattr_req,
+ (args.dict.dict_val),
+ (args.dict.dict_len), ret,
+ op_errno, out);
+ state->dict = xattr_req;
ret = 0;
resolve_and_resume (frame, server_lookup_resume);
@@ -5219,10 +4906,6 @@ out:
if (xattr_req)
dict_unref (xattr_req);
- if (buf) {
- GF_FREE (buf);
- }
-
server_lookup_cbk (frame, NULL, frame->this, -1, EINVAL, NULL, NULL,
NULL, NULL);
ret = 0;