summaryrefslogtreecommitdiffstats
path: root/xlators/protocol/server/src
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2010-06-23 02:55:21 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-06-24 10:32:11 -0700
commite82ca8fc5164f4ba2ff396da86b4a490d9a47370 (patch)
tree1c92b4d4c0a4ad42b2213f17c92ededc45ae89a2 /xlators/protocol/server/src
parent487e9f1d59bbf7b37a30ceef5dbfd8ca77b94988 (diff)
minor improvements in protocol
* rpc_clnt_submit() now takes 'cbkfn' as an argument. * readdir xdr now uses dirent structure directly instead of using 'opaque' buffer through which it was serializing / unserializing the dirent structure. * 'gfs_id' field (currently used for debugging) is properly updated Signed-off-by: Amar Tumballi <amar@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 875 (Implement a new protocol to provide proper backward/forward compatibility) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=875
Diffstat (limited to 'xlators/protocol/server/src')
-rw-r--r--xlators/protocol/server/src/server-helpers.c100
-rw-r--r--xlators/protocol/server/src/server-helpers.h5
-rw-r--r--xlators/protocol/server/src/server.c6
-rw-r--r--xlators/protocol/server/src/server.h2
-rw-r--r--xlators/protocol/server/src/server3_1-fops.c82
5 files changed, 169 insertions, 26 deletions
diff --git a/xlators/protocol/server/src/server-helpers.c b/xlators/protocol/server/src/server-helpers.c
index 5cae205..44496a1 100644
--- a/xlators/protocol/server/src/server-helpers.c
+++ b/xlators/protocol/server/src/server-helpers.c
@@ -1390,3 +1390,103 @@ server_print_request (call_frame_t *frame)
op, caller,
resolve_vars, loc_vars, resolve2_vars, loc2_vars, other_vars);
}
+
+int
+serialize_rsp_direntp (gf_dirent_t *entries, gfs3_readdirp_rsp *rsp)
+{
+ gf_dirent_t *entry = NULL;
+ gfs3_dirplist *trav = NULL;
+ gfs3_dirplist *prev = NULL;
+ int ret = -1;
+
+ list_for_each_entry (entry, &entries->list, list) {
+ trav = GF_CALLOC (1, sizeof (*trav), 0);
+ if (!trav)
+ goto out;
+
+ trav->d_ino = entry->d_ino;
+ trav->d_off = entry->d_off;
+ trav->d_len = entry->d_len;
+ trav->d_type = entry->d_type;
+ //trav->name = memdup (entry->d_name, entry->d_len + 1);
+ trav->name = entry->d_name;
+
+ gf_stat_from_iatt (&trav->stat, &entry->d_stat);
+
+ if (prev)
+ prev->nextentry = trav;
+ else
+ rsp->reply = trav;
+
+ prev = trav;
+ }
+
+ ret = 0;
+out:
+ return ret;
+}
+
+
+int
+serialize_rsp_dirent (gf_dirent_t *entries, gfs3_readdir_rsp *rsp)
+{
+ gf_dirent_t *entry = NULL;
+ gfs3_dirlist *trav = NULL;
+ gfs3_dirlist *prev = NULL;
+ int ret = -1;
+
+ list_for_each_entry (entry, &entries->list, list) {
+ trav = GF_CALLOC (1, sizeof (*trav), 0);
+ if (!trav)
+ goto out;
+ trav->d_ino = entry->d_ino;
+ trav->d_off = entry->d_off;
+ trav->d_len = entry->d_len;
+ trav->d_type = entry->d_type;
+ trav->name = entry->d_name;
+ if (prev)
+ prev->nextentry = trav;
+ else
+ rsp->reply = trav;
+
+ prev = trav;
+ }
+
+ ret = 0;
+out:
+ return ret;
+}
+
+int
+readdir_rsp_cleanup (gfs3_readdir_rsp *rsp)
+{
+ gfs3_dirlist *prev = NULL;
+ gfs3_dirlist *trav = NULL;
+
+ trav = rsp->reply;
+ prev = trav;
+ while (trav) {
+ trav = trav->nextentry;
+ GF_FREE (prev);
+ prev = trav;
+ }
+
+ return 0;
+}
+
+int
+readdirp_rsp_cleanup (gfs3_readdirp_rsp *rsp)
+{
+ gfs3_dirplist *prev = NULL;
+ gfs3_dirplist *trav = NULL;
+
+ trav = rsp->reply;
+ prev = trav;
+ while (trav) {
+ trav = trav->nextentry;
+ GF_FREE (prev);
+ prev = trav;
+ }
+
+ return 0;
+}
diff --git a/xlators/protocol/server/src/server-helpers.h b/xlators/protocol/server/src/server-helpers.h
index 4897336..ef27b61 100644
--- a/xlators/protocol/server/src/server-helpers.h
+++ b/xlators/protocol/server/src/server-helpers.h
@@ -86,4 +86,9 @@ destroy_server_conn_state (server_connection_t *conn);
int
server_build_config (xlator_t *this, server_conf_t *conf);
+int serialize_rsp_dirent (gf_dirent_t *entries, gfs3_readdir_rsp *rsp);
+int serialize_rsp_direntp (gf_dirent_t *entries, gfs3_readdirp_rsp *rsp);
+int readdirp_rsp_cleanup (gfs3_readdirp_rsp *rsp);
+int readdir_rsp_cleanup (gfs3_readdir_rsp *rsp);
+
#endif /* !_SERVER_HELPERS_H */
diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c
index 18be607..190da28 100644
--- a/xlators/protocol/server/src/server.c
+++ b/xlators/protocol/server/src/server.c
@@ -60,8 +60,12 @@ gfs_serialize_reply (rpcsvc_request_t *req, void *arg, gfs_serialize_t sfunc,
*/
retlen = sfunc (*outmsg, arg);
if (retlen == -1) {
+ /* Failed to Encode 'GlusterFS' msg in RPC is not exactly
+ failure of RPC return values.. client should get
+ notified about this, so there are no missing frames */
gf_log ("", GF_LOG_ERROR, "Failed to encode message");
- goto ret;
+ req->rpc_err = GARBAGE_ARGS;
+ retlen = 0;
}
outmsg->iov_len = retlen;
diff --git a/xlators/protocol/server/src/server.h b/xlators/protocol/server/src/server.h
index aaa036e..6626a7c 100644
--- a/xlators/protocol/server/src/server.h
+++ b/xlators/protocol/server/src/server.h
@@ -26,8 +26,8 @@
#include "fd.h"
#include "protocol-common.h"
-
#include "server-mem-types.h"
+#include "glusterfs-xdr.h"
#define DEFAULT_BLOCK_SIZE 4194304 /* 4MB */
#define DEFAULT_VOLUME_FILE_PATH CONFDIR "/glusterfs.vol"
diff --git a/xlators/protocol/server/src/server3_1-fops.c b/xlators/protocol/server/src/server3_1-fops.c
index 4156e7b..54dda89 100644
--- a/xlators/protocol/server/src/server3_1-fops.c
+++ b/xlators/protocol/server/src/server3_1-fops.c
@@ -44,6 +44,7 @@ server_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -158,6 +159,7 @@ server_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
op_ret, strerror (op_errno));
}
out:
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -182,6 +184,7 @@ server_lk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -216,6 +219,7 @@ server_inodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -256,6 +260,7 @@ server_finodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -297,6 +302,7 @@ server_entrylk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -336,6 +342,7 @@ server_fentrylk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -374,6 +381,7 @@ server_access_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -396,6 +404,7 @@ server_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -440,6 +449,7 @@ server_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -480,6 +490,7 @@ server_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -518,6 +529,7 @@ server_fsyncdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -544,22 +556,18 @@ server_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
gfs3_readdir_rsp rsp = {0,};
server_state_t *state = NULL;
rpcsvc_request_t *req = NULL;
+ int ret = 0;
req = frame->local;
frame->local = NULL;
state = CALL_STATE(frame);
if (op_ret > 0) {
- rsp.buf.buf_len = gf_dirent_serialize (entries, NULL, 0);
- if (rsp.buf.buf_len > 0) {
- rsp.buf.buf_val = GF_CALLOC (1, rsp.buf.buf_len, 0);
- if (!rsp.buf.buf_val) {
- op_ret = -1;
- op_errno = ENOMEM;
- goto unwind;
- }
- gf_dirent_serialize (entries, rsp.buf.buf_val,
- rsp.buf.buf_len);
+ ret = serialize_rsp_dirent (entries, &rsp);
+ if (ret == -1) {
+ op_ret = -1;
+ op_errno = ENOMEM;
+ goto unwind;
}
} else {
gf_log (this->name, GF_LOG_TRACE,
@@ -569,15 +577,14 @@ server_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
strerror (op_errno));
}
unwind:
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
-
server_submit_reply (frame, req, &rsp, NULL, 0, NULL,
xdr_serialize_readdir_rsp);
- if (rsp.buf.buf_val)
- GF_FREE (rsp.buf.buf_val);
+ readdir_rsp_cleanup (&rsp);
return 0;
}
@@ -593,6 +600,7 @@ server_releasedir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -632,6 +640,7 @@ server_opendir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
frame->local = NULL;
rsp.fd = fd_no;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -651,6 +660,7 @@ server_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -703,13 +713,14 @@ server_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
}
out:
+ req = frame->local;
+ frame->local = NULL;
+
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
rsp.dict.dict_len = len;
- req = frame->local;
- frame->local = NULL;
-
server_submit_reply (frame, req, &rsp, NULL, 0, NULL,
xdr_serialize_getxattr_rsp);
@@ -766,6 +777,7 @@ out:
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
rsp.dict.dict_len = len;
@@ -788,6 +800,7 @@ server_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -808,6 +821,7 @@ server_fsetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -830,6 +844,7 @@ server_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -878,6 +893,7 @@ server_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -929,6 +945,7 @@ server_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -971,6 +988,7 @@ server_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -1022,6 +1040,7 @@ server_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -1055,6 +1074,7 @@ server_fstat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -1088,6 +1108,7 @@ server_ftruncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -1121,6 +1142,7 @@ server_flush_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -1152,6 +1174,7 @@ server_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -1184,6 +1207,7 @@ server_release_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -1205,6 +1229,7 @@ server_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -1240,6 +1265,7 @@ server_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -1272,6 +1298,7 @@ server_checksum_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -1300,6 +1327,7 @@ server_rchecksum_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -1346,6 +1374,7 @@ server_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
frame->local = NULL;
rsp.fd = fd_no;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -1426,6 +1455,7 @@ server_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
frame->local = NULL;
rsp.fd = fd_no;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -1447,6 +1477,7 @@ server_readlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -1481,6 +1512,7 @@ server_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -1515,6 +1547,7 @@ server_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -1563,6 +1596,7 @@ server_fsetattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
@@ -1627,6 +1661,7 @@ out:
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
rsp.dict.dict_len = len;
@@ -1696,6 +1731,7 @@ out:
req = frame->local;
frame->local = NULL;
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
rsp.dict.dict_len = len;
@@ -1717,21 +1753,19 @@ server_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
gfs3_readdirp_rsp rsp = {0,};
server_state_t *state = NULL;
rpcsvc_request_t *req = NULL;
+ int ret = 0;
req = frame->local;
frame->local = NULL;
state = CALL_STATE(frame);
if (op_ret > 0) {
- rsp.buf.buf_len = gf_dirent_serialize (entries, NULL, 0);
- rsp.buf.buf_val = GF_CALLOC (1, rsp.buf.buf_len, 0);
- if (!rsp.buf.buf_val) {
- op_ret = -1;
+ ret = serialize_rsp_direntp (entries, &rsp);
+ if (ret == -1) {
+ op_ret = -1;
op_errno = ENOMEM;
- rsp.buf.buf_len = 0;
goto out;
}
- gf_dirent_serialize (entries, rsp.buf.buf_val, rsp.buf.buf_len);
} else {
gf_log (this->name, GF_LOG_TRACE,
"%"PRId64": READDIRP %"PRId64" (%"PRId64") ==>"
@@ -1742,14 +1776,14 @@ server_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
out:
+ rsp.gfs_id = req->gfs_id;
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
server_submit_reply (frame, req, &rsp, NULL, 0, NULL,
xdr_serialize_readdirp_rsp);
- if (rsp.buf.buf_val)
- GF_FREE (rsp.buf.buf_val);
+ readdirp_rsp_cleanup (&rsp);
return 0;
}