diff options
author | Amar Tumballi <amar@gluster.com> | 2011-08-29 17:53:24 +0530 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2011-09-07 10:48:52 -0700 |
commit | f0f3b040dfa062021d3a193e5a19c380eb5e908d (patch) | |
tree | 5e78d2dc05a2aa143b68b0980e21f09511c9120b /xlators/mgmt/glusterd | |
parent | f78c8253d7fb75762effcf64683cbce10783a55b (diff) |
modify to the way we used XDR definitions files (.x files)
Earlier:
step 1: copy the existing <xdr>.x files to /tmp
step 2: generate '.[ch]' files using 'rpcgen <xdr>.x'
step 3: check diff with the to the existing files, add only your part
of changes back to the original file. (ignore other changes).
step 4: there is another file to write wrapper functions to convert
structures to/from XDR buffers, update it with your new structure.
step 5: use these wrapper functions in the newly written procedures.
step 6: commit :-|
Now:
step 1: update (mostly adding only) the <xdr>.x file
step 2: run '<path-to-src>/extras/generate-xdr-files.sh <xdr>.x' command
step 3: implement rpc procedure to handle the request/response.
step 4: commit :-)
Change-Id: I219f9159fc980438c86e847c6b030be96e595ea2
BUG: 3488
Reviewed-on: http://review.gluster.com/341
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@gluster.com>
Diffstat (limited to 'xlators/mgmt/glusterd')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-brick-ops.c | 11 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-geo-rep.c | 6 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handler.c | 60 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handshake.c | 24 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-log-ops.c | 16 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-op-sm.c | 2 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-pmap.c | 44 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-quota.c | 6 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-rebalance.c | 12 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-replace-brick.c | 6 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-rpc-ops.c | 61 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-store.c | 2 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 51 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.h | 6 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volgen.c | 2 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volume-ops.c | 16 |
16 files changed, 128 insertions, 197 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c index d05dd49a1..5fbdfc116 100644 --- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c @@ -23,7 +23,8 @@ #endif #include "common-utils.h" -#include "cli1.h" +#include "cli1-xdr.h" +#include "xdr-generic.h" #include "glusterd.h" #include "glusterd-op-sm.h" #include "glusterd-store.h" @@ -65,7 +66,8 @@ glusterd_handle_add_brick (rpcsvc_request_t *req) INIT_LIST_HEAD (&tmpvolinfo.bricks); - if (!gf_xdr_to_cli_add_brick_req (req->msg[0], &cli_req)) { + if (!xdr_to_generic (req->msg[0], &cli_req, + (xdrproc_t)xdr_gf1_cli_add_brick_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; snprintf (err_str, sizeof (err_str), "Garbage args received"); @@ -221,7 +223,6 @@ out: rsp.op_errstr = err_str; cli_rsp = &rsp; glusterd_submit_reply(req, cli_rsp, NULL, 0, NULL, - gf_xdr_serialize_cli_add_brick_rsp, (xdrproc_t)xdr_gf1_cli_add_brick_rsp); ret = 0; //sent error to cli, prevent second reply } @@ -265,7 +266,8 @@ glusterd_handle_remove_brick (rpcsvc_request_t *req) GF_ASSERT (req); - if (!gf_xdr_to_cli_remove_brick_req (req->msg[0], &cli_req)) { + if (!xdr_to_generic (req->msg[0], &cli_req, + (xdrproc_t)xdr_gf1_cli_remove_brick_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; goto out; @@ -417,7 +419,6 @@ out: rsp.op_errstr = err_str; cli_rsp = &rsp; glusterd_submit_reply(req, cli_rsp, NULL, 0, NULL, - gf_xdr_serialize_cli_remove_brick_rsp, (xdrproc_t)xdr_gf1_cli_remove_brick_rsp); ret = 0; //sent error to cli, prevent second reply diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c index 49654220b..9630546b4 100644 --- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c +++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c @@ -23,7 +23,8 @@ #endif #include "common-utils.h" -#include "cli1.h" +#include "cli1-xdr.h" +#include "xdr-generic.h" #include "glusterd.h" #include "glusterd-op-sm.h" #include "glusterd-store.h" @@ -61,7 +62,8 @@ glusterd_handle_gsync_set (rpcsvc_request_t *req) priv = THIS->private; - if (!gf_xdr_to_cli_gsync_set_req (req->msg[0], &cli_req)) { + if (!xdr_to_generic (req->msg[0], &cli_req, + (xdrproc_t)xdr_gf1_cli_gsync_set_req)) { req->rpc_err = GARBAGE_ARGS; goto out; } diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index 08ba9bc46..881e84214 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -43,10 +43,10 @@ #include "glusterd-utils.h" #include "glusterd-store.h" -#include "glusterd1.h" -#include "cli1.h" -#include "rpc-clnt.h" #include "glusterd1-xdr.h" +#include "cli1-xdr.h" +#include "xdr-generic.h" +#include "rpc-clnt.h" #include "glusterd-volgen.h" #include <sys/resource.h> @@ -459,7 +459,7 @@ glusterd_handle_cluster_lock (rpcsvc_request_t *req) GF_ASSERT (req); - if (!gd_xdr_to_mgmt_cluster_lock_req (req->msg[0], &lock_req)) { + if (!xdr_to_generic (req->msg[0], &lock_req, (xdrproc_t)xdr_gd1_mgmt_cluster_lock_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; goto out; @@ -565,7 +565,7 @@ glusterd_handle_stage_op (rpcsvc_request_t *req) gd1_mgmt_stage_op_req op_req = {{0},}; GF_ASSERT (req); - if (!gd_xdr_to_mgmt_stage_op_req (req->msg[0], &op_req)) { + if (!xdr_to_generic (req->msg[0], &op_req, (xdrproc_t)xdr_gd1_mgmt_stage_op_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; goto out; @@ -596,7 +596,7 @@ glusterd_handle_commit_op (rpcsvc_request_t *req) GF_ASSERT (req); - if (!gd_xdr_to_mgmt_commit_op_req (req->msg[0], &op_req)) { + if (!xdr_to_generic (req->msg[0], &op_req, (xdrproc_t)xdr_gd1_mgmt_commit_op_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; goto out; @@ -631,7 +631,7 @@ glusterd_handle_cli_probe (rpcsvc_request_t *req) gf_boolean_t run_fsm = _gf_true; GF_ASSERT (req); - if (!gf_xdr_to_cli_probe_req (req->msg[0], &cli_req)) { + if (!xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf1_cli_probe_req)) { //failed to decode msg; gf_log ("", GF_LOG_ERROR, "xdr decoding error"); req->rpc_err = GARBAGE_ARGS; @@ -698,7 +698,7 @@ glusterd_handle_cli_deprobe (rpcsvc_request_t *req) GF_ASSERT (priv); GF_ASSERT (req); - if (!gf_xdr_to_cli_probe_req (req->msg[0], &cli_req)) { + if (!xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf1_cli_probe_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; goto out; @@ -762,7 +762,7 @@ glusterd_handle_cli_list_friends (rpcsvc_request_t *req) GF_ASSERT (req); - if (!gf_xdr_to_cli_peer_list_req (req->msg[0], &cli_req)) { + if (!xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf1_cli_peer_list_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; goto out; @@ -808,7 +808,7 @@ glusterd_handle_cli_get_volume (rpcsvc_request_t *req) GF_ASSERT (req); - if (!gf_xdr_to_cli_get_vol_req (req->msg[0], &cli_req)) { + if (!xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf1_cli_get_vol_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; goto out; @@ -867,7 +867,7 @@ glusterd_handle_reset_volume (rpcsvc_request_t *req) GF_ASSERT (req); - if (!gf_xdr_to_cli_set_vol_req (req->msg[0], &cli_req)) { + if (!xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf1_cli_set_vol_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; goto out; @@ -924,7 +924,7 @@ glusterd_handle_set_volume (rpcsvc_request_t *req) GF_ASSERT (req); - if (!gf_xdr_to_cli_set_vol_req (req->msg[0], &cli_req)) { + if (!xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf1_cli_set_vol_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; goto out; @@ -1008,7 +1008,7 @@ glusterd_handle_sync_volume (rpcsvc_request_t *req) GF_ASSERT (req); - if (!gf_xdr_to_cli_sync_volume_req (req->msg[0], &cli_req)) { + if (!xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf1_cli_sync_volume_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; goto out; @@ -1082,7 +1082,6 @@ out: if (msg[0] == '\0') snprintf (msg, sizeof (msg), "Operation failed"); glusterd_submit_reply(req, &cli_rsp, NULL, 0, NULL, - gf_xdr_from_cli_sync_volume_rsp, (xdrproc_t)xdr_gf1_cli_sync_volume_rsp); if (free_hostname && cli_req.hostname) free (cli_req.hostname); @@ -1119,7 +1118,6 @@ glusterd_fsm_log_send_resp (rpcsvc_request_t *req, int op_ret, (size_t *)&rsp.fsm_log.fsm_log_len); ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, - gf_xdr_from_cli_fsm_log_rsp, (xdrproc_t)xdr_gf1_cli_fsm_log_rsp); if (rsp.fsm_log.fsm_log_val) GF_FREE (rsp.fsm_log.fsm_log_val); @@ -1143,7 +1141,7 @@ glusterd_handle_fsm_log (rpcsvc_request_t *req) GF_ASSERT (req); - if (!gf_xdr_to_cli_fsm_log_req (req->msg[0], &cli_req)) { + if (!xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf1_cli_fsm_log_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; snprintf (msg, sizeof (msg), "Garbage request"); @@ -1197,7 +1195,6 @@ glusterd_op_lock_send_resp (rpcsvc_request_t *req, int32_t status) rsp.op_ret = status; ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, - gd_xdr_serialize_mgmt_cluster_lock_rsp, (xdrproc_t)xdr_gd1_mgmt_cluster_lock_rsp); gf_log ("glusterd", GF_LOG_INFO, @@ -1218,7 +1215,6 @@ glusterd_op_unlock_send_resp (rpcsvc_request_t *req, int32_t status) glusterd_get_uuid (&rsp.uuid); ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, - gd_xdr_serialize_mgmt_cluster_unlock_rsp, (xdrproc_t)xdr_gd1_mgmt_cluster_unlock_rsp); gf_log ("glusterd", GF_LOG_INFO, @@ -1236,7 +1232,8 @@ glusterd_handle_cluster_unlock (rpcsvc_request_t *req) GF_ASSERT (req); - if (!gd_xdr_to_mgmt_cluster_unlock_req (req->msg[0], &unlock_req)) { + if (!xdr_to_generic (req->msg[0], &unlock_req, + (xdrproc_t)xdr_gd1_mgmt_cluster_unlock_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; goto out; @@ -1291,7 +1288,6 @@ glusterd_op_stage_send_resp (rpcsvc_request_t *req, } ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, - gd_xdr_serialize_mgmt_stage_op_rsp, (xdrproc_t)xdr_gd1_mgmt_stage_op_rsp); gf_log ("glusterd", GF_LOG_INFO, @@ -1333,7 +1329,6 @@ glusterd_op_commit_send_resp (rpcsvc_request_t *req, ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, - gd_xdr_serialize_mgmt_commit_op_rsp, (xdrproc_t)xdr_gd1_mgmt_commit_op_rsp); gf_log ("glusterd", GF_LOG_INFO, @@ -1353,7 +1348,7 @@ glusterd_handle_incoming_friend_req (rpcsvc_request_t *req) gf_boolean_t run_fsm = _gf_true; GF_ASSERT (req); - if (!gd_xdr_to_mgmt_friend_req (req->msg[0], &friend_req)) { + if (!xdr_to_generic (req->msg[0], &friend_req, (xdrproc_t)xdr_gd1_mgmt_friend_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; goto out; @@ -1391,7 +1386,7 @@ glusterd_handle_incoming_unfriend_req (rpcsvc_request_t *req) char remote_hostname[UNIX_PATH_MAX + 1] = {0,}; GF_ASSERT (req); - if (!gd_xdr_to_mgmt_friend_req (req->msg[0], &friend_req)) { + if (!xdr_to_generic (req->msg[0], &friend_req, (xdrproc_t)xdr_gd1_mgmt_friend_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; goto out; @@ -1494,7 +1489,7 @@ glusterd_handle_friend_update (rpcsvc_request_t *req) priv = this->private; GF_ASSERT (priv); - if (!gd_xdr_to_mgmt_friend_update (req->msg[0], &friend_req)) { + if (!xdr_to_generic (req->msg[0], &friend_req, (xdrproc_t)xdr_gd1_mgmt_friend_update)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; goto out; @@ -1581,7 +1576,6 @@ glusterd_handle_friend_update (rpcsvc_request_t *req) out: uuid_copy (rsp.uuid, priv->uuid); ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, - gd_xdr_serialize_mgmt_friend_update_rsp, (xdrproc_t)xdr_gd1_mgmt_friend_update_rsp); if (dict) { if (!dict->extra_stdfree && friend_req.friends.friends_val) @@ -1613,13 +1607,12 @@ glusterd_handle_probe_query (rpcsvc_request_t *req) GF_ASSERT (req); - if (!gd_xdr_to_mgmt_probe_req (req->msg[0], &probe_req)) { + if (!xdr_to_generic (req->msg[0], &probe_req, (xdrproc_t)xdr_gd1_mgmt_probe_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; goto out; } - this = THIS; conf = this->private; @@ -1660,7 +1653,6 @@ glusterd_handle_probe_query (rpcsvc_request_t *req) rsp.hostname = probe_req.hostname; ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, - gd_xdr_serialize_mgmt_probe_rsp, (xdrproc_t)xdr_gd1_mgmt_probe_rsp); gf_log ("glusterd", GF_LOG_INFO, "Responded to %s, op_ret: %d, " @@ -1690,7 +1682,7 @@ glusterd_handle_cli_profile_volume (rpcsvc_request_t *req) GF_ASSERT (req); - if (!gf_xdr_to_cli_stats_volume_req (req->msg[0], &cli_req)) { + if (!xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf1_cli_stats_volume_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; goto out; @@ -1772,7 +1764,6 @@ glusterd_handle_getwd (rpcsvc_request_t *req) rsp.wd = priv->workdir; ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, - gf_xdr_from_cli_getwd_rsp, (xdrproc_t)xdr_gf1_cli_getwd_rsp); glusterd_friend_sm (); @@ -2085,7 +2076,6 @@ glusterd_xfer_friend_remove_resp (rpcsvc_request_t *req, char *hostname, int por rsp.hostname = hostname; rsp.port = port; ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, - gd_xdr_serialize_mgmt_friend_rsp, (xdrproc_t)xdr_gd1_mgmt_friend_rsp); gf_log ("glusterd", GF_LOG_INFO, @@ -2117,7 +2107,6 @@ glusterd_xfer_friend_add_resp (rpcsvc_request_t *req, char *hostname, int port, rsp.port = port; ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, - gd_xdr_serialize_mgmt_friend_rsp, (xdrproc_t)xdr_gd1_mgmt_friend_rsp); gf_log ("glusterd", GF_LOG_INFO, @@ -2142,7 +2131,6 @@ glusterd_xfer_cli_probe_resp (rpcsvc_request_t *req, int32_t op_ret, rsp.port = port; ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, - gf_xdr_serialize_cli_probe_rsp, (xdrproc_t)xdr_gf1_cli_probe_rsp); gf_log ("glusterd", GF_LOG_INFO, "Responded to CLI, ret: %d",ret); @@ -2164,7 +2152,6 @@ glusterd_xfer_cli_deprobe_resp (rpcsvc_request_t *req, int32_t op_ret, rsp.hostname = hostname; ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, - gf_xdr_serialize_cli_deprobe_rsp, (xdrproc_t)xdr_gf1_cli_deprobe_rsp); gf_log ("glusterd", GF_LOG_INFO, "Responded to CLI, ret: %d",ret); @@ -2227,7 +2214,6 @@ out: rsp.op_ret = ret; ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, - gf_xdr_serialize_cli_peer_list_rsp, (xdrproc_t)xdr_gf1_cli_peer_list_rsp); if (rsp.friends.friends_val) GF_FREE (rsp.friends.friends_val); @@ -2331,7 +2317,6 @@ out: rsp.op_ret = ret; ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, - gf_xdr_serialize_cli_peer_list_rsp, (xdrproc_t)xdr_gf1_cli_peer_list_rsp); if (volumes) @@ -2352,7 +2337,8 @@ glusterd_handle_status_volume (rpcsvc_request_t *req) GF_ASSERT (req); - if (!gf_xdr_to_cli_status_volume_req (req->msg[0], &cli_req)) { + if (!xdr_to_generic (req->msg[0], &cli_req, + (xdrproc_t)xdr_gf1_cli_status_volume_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; goto out; diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c index e78ccbfdc..25b1e6695 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handshake.c +++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c @@ -101,23 +101,6 @@ out: return ret; } -static int -xdr_to_glusterfs_req (rpcsvc_request_t *req, void *arg, gfs_serialize_t sfunc) -{ - int ret = -1; - - if (!req) - return -1; - - ret = sfunc (req->msg[0], arg); - - if (ret > 0) - ret = 0; - - return ret; -} - - int server_getspec (rpcsvc_request_t *req) { @@ -134,7 +117,7 @@ server_getspec (rpcsvc_request_t *req) gf_getspec_rsp rsp = {0,}; - if (xdr_to_glusterfs_req (req, &args, xdr_to_getspec_req)) { + if (!xdr_to_generic (req->msg[0], &args, (xdrproc_t)xdr_gf_getspec_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; goto fail; @@ -191,7 +174,6 @@ fail: rsp.spec = ""; glusterd_submit_reply (req, &rsp, NULL, 0, NULL, - (gd_serialize_t)xdr_serialize_getspec_rsp, (xdrproc_t)xdr_gf_getspec_rsp); if (args.key) free (args.key);//malloced by xdr @@ -346,7 +328,7 @@ glusterd_peer_dump_version_cbk (struct rpc_req *req, struct iovec *iov, goto out; } - ret = xdr_to_dump_rsp (*iov, &rsp); + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_dump_rsp); if (ret < 0) { gf_log ("", GF_LOG_ERROR, "failed to decode XDR"); goto out; @@ -421,7 +403,7 @@ glusterd_peer_handshake (xlator_t *this, struct rpc_clnt *rpc, ret = glusterd_submit_request (peerctx->peerinfo->rpc, &req, frame, &glusterd_dump_prog, GF_DUMP_DUMP, - NULL, xdr_from_dump_req, this, + NULL, this, glusterd_peer_dump_version_cbk, (xdrproc_t)xdr_gf_dump_req); out: diff --git a/xlators/mgmt/glusterd/src/glusterd-log-ops.c b/xlators/mgmt/glusterd/src/glusterd-log-ops.c index 017698291..7274d1024 100644 --- a/xlators/mgmt/glusterd/src/glusterd-log-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-log-ops.c @@ -23,7 +23,8 @@ #endif #include "common-utils.h" -#include "cli1.h" +#include "cli1-xdr.h" +#include "xdr-generic.h" #include "glusterd.h" #include "glusterd-op-sm.h" #include "glusterd-store.h" @@ -42,7 +43,8 @@ glusterd_handle_log_filename (rpcsvc_request_t *req) GF_ASSERT (req); - if (!gf_xdr_to_cli_log_filename_req (req->msg[0], &cli_req)) { + if (!xdr_to_generic (req->msg[0], &cli_req, + (xdrproc_t)xdr_gf1_cli_log_filename_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; goto out; @@ -99,7 +101,8 @@ glusterd_handle_log_locate (rpcsvc_request_t *req) priv = THIS->private; - if (!gf_xdr_to_cli_log_locate_req (req->msg[0], &cli_req)) { + if (!xdr_to_generic (req->msg[0], &cli_req, + (xdrproc_t)xdr_gf1_cli_log_locate_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; goto out; @@ -172,7 +175,6 @@ out: rsp.path = "Operation failed"; ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, - gf_xdr_serialize_cli_log_locate_rsp, (xdrproc_t)xdr_gf1_cli_log_locate_rsp); if (cli_req.brick) @@ -197,7 +199,8 @@ glusterd_handle_log_level (rpcsvc_request_t *req) GF_ASSERT(req); - if (!gf_xdr_to_cli_log_level_req(req->msg[0], &cli_req)) { + if (!xdr_to_generic (req->msg[0], &cli_req, + (xdrproc_t)xdr_gf1_cli_log_level_req)) { gf_log ("glusterd", GF_LOG_ERROR, "Failed to decode rpc message"); req->rpc_err = GARBAGE_ARGS; goto out; @@ -248,7 +251,8 @@ glusterd_handle_log_rotate (rpcsvc_request_t *req) GF_ASSERT (req); - if (!gf_xdr_to_cli_log_rotate_req (req->msg[0], &cli_req)) { + if (!xdr_to_generic (req->msg[0], &cli_req, + (xdrproc_t)xdr_gf1_cli_log_rotate_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; goto out; diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index a460582a0..7fe68ded0 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -47,7 +47,7 @@ #include "glusterd-store.h" #include "glusterd-volgen.h" #include "syscall.h" -#include "cli1.h" +#include "cli1-xdr.h" #include "common-utils.h" #include "run.h" diff --git a/xlators/mgmt/glusterd/src/glusterd-pmap.c b/xlators/mgmt/glusterd/src/glusterd-pmap.c index 2658cf40a..871539a50 100644 --- a/xlators/mgmt/glusterd/src/glusterd-pmap.c +++ b/xlators/mgmt/glusterd/src/glusterd-pmap.c @@ -30,7 +30,8 @@ #include "glusterd.h" #include "glusterd-utils.h" -#include "portmap.h" +#include "portmap-xdr.h" +#include "xdr-generic.h" #include "protocol-common.h" #include "rpcsvc.h" @@ -290,27 +291,6 @@ out: return 0; } - -typedef ssize_t (*gfs_serialize_t) (struct iovec outmsg, void *data); - - -static int -xdr_to_glusterfs_req (rpcsvc_request_t *req, void *arg, gfs_serialize_t sfunc) -{ - int ret = -1; - - if (!req) - return -1; - - ret = sfunc (req->msg[0], arg); - - if (ret > 0) - ret = 0; - - return ret; -} - - int gluster_pmap_portbybrick (rpcsvc_request_t *req) { @@ -319,7 +299,8 @@ gluster_pmap_portbybrick (rpcsvc_request_t *req) char *brick = NULL; int port = 0; - if (xdr_to_glusterfs_req (req, &args, xdr_to_pmap_port_by_brick_req)) { + if (!xdr_to_generic (req->msg[0], &args, + (xdrproc_t)xdr_pmap_port_by_brick_req)) { req->rpc_err = GARBAGE_ARGS; goto fail; } @@ -335,7 +316,6 @@ gluster_pmap_portbybrick (rpcsvc_request_t *req) fail: glusterd_submit_reply (req, &rsp, NULL, 0, NULL, - (gd_serialize_t)xdr_from_pmap_port_by_brick_rsp, (xdrproc_t)xdr_pmap_port_by_brick_rsp); if (args.brick) free (args.brick);//malloced by xdr @@ -350,7 +330,8 @@ gluster_pmap_brickbyport (rpcsvc_request_t *req) pmap_brick_by_port_req args = {0,}; pmap_brick_by_port_rsp rsp = {0,}; - if (xdr_to_glusterfs_req (req, &args, xdr_to_pmap_brick_by_port_req)) { + if (!xdr_to_generic (req->msg[0], &args, + (xdrproc_t)xdr_pmap_brick_by_port_req)) { req->rpc_err = GARBAGE_ARGS; goto fail; } @@ -363,7 +344,6 @@ gluster_pmap_brickbyport (rpcsvc_request_t *req) fail: glusterd_submit_reply (req, &rsp, NULL, 0, NULL, - (gd_serialize_t)xdr_from_pmap_brick_by_port_rsp, (xdrproc_t)xdr_pmap_brick_by_port_rsp); return 0; @@ -385,7 +365,8 @@ gluster_pmap_signup (rpcsvc_request_t *req) pmap_signup_rsp rsp = {0,}; - if (xdr_to_glusterfs_req (req, &args, xdr_to_pmap_signup_req)) { + if (!xdr_to_generic (req->msg[0], &args, + (xdrproc_t)xdr_pmap_signup_req)) { req->rpc_err = GARBAGE_ARGS; goto fail; } @@ -395,7 +376,6 @@ gluster_pmap_signup (rpcsvc_request_t *req) fail: glusterd_submit_reply (req, &rsp, NULL, 0, NULL, - (gd_serialize_t)xdr_from_pmap_signup_rsp, (xdrproc_t)xdr_pmap_signup_rsp); if (args.brick) free (args.brick);//malloced by xdr @@ -411,7 +391,8 @@ gluster_pmap_signin (rpcsvc_request_t *req) glusterd_brickinfo_t *brickinfo = NULL; int ret = -1; - if (xdr_to_glusterfs_req (req, &args, xdr_to_pmap_signin_req)) { + if (!xdr_to_generic (req->msg[0], &args, + (xdrproc_t)xdr_pmap_signin_req)) { req->rpc_err = GARBAGE_ARGS; goto fail; } @@ -423,7 +404,6 @@ gluster_pmap_signin (rpcsvc_request_t *req) &brickinfo); fail: glusterd_submit_reply (req, &rsp, NULL, 0, NULL, - (gd_serialize_t)xdr_from_pmap_signin_rsp, (xdrproc_t)xdr_pmap_signin_rsp); if (args.brick) free (args.brick);//malloced by xdr @@ -444,7 +424,8 @@ gluster_pmap_signout (rpcsvc_request_t *req) int ret = -1; glusterd_brickinfo_t *brickinfo = NULL; - if (xdr_to_glusterfs_req (req, &args, xdr_to_pmap_signout_req)) { + if (!xdr_to_generic (req->msg[0], &args, + (xdrproc_t)xdr_pmap_signout_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; goto fail; @@ -457,7 +438,6 @@ gluster_pmap_signout (rpcsvc_request_t *req) &brickinfo); fail: glusterd_submit_reply (req, &rsp, NULL, 0, NULL, - (gd_serialize_t)xdr_from_pmap_signout_rsp, (xdrproc_t)xdr_pmap_signout_rsp); if (args.brick) free (args.brick);//malloced by xdr diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c index 809b56efe..c81a94501 100644 --- a/xlators/mgmt/glusterd/src/glusterd-quota.c +++ b/xlators/mgmt/glusterd/src/glusterd-quota.c @@ -23,7 +23,8 @@ #endif #include "common-utils.h" -#include "cli1.h" +#include "cli1-xdr.h" +#include "xdr-generic.h" #include "glusterd.h" #include "glusterd-op-sm.h" #include "glusterd-store.h" @@ -46,7 +47,8 @@ glusterd_handle_quota (rpcsvc_request_t *req) GF_ASSERT (req); - if (!gf_xdr_to_cli_quota_req (req->msg[0], &cli_req)) { + if (!xdr_to_generic (req->msg[0], &cli_req, + (xdrproc_t)xdr_gf1_cli_quota_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; goto out; diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c index d09a83642..68cbab54b 100644 --- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c +++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c @@ -43,8 +43,8 @@ #include "run.h" #include "syscall.h" -#include "cli1.h" - +#include "cli1-xdr.h" +#include "xdr-generic.h" int gf_glusterd_rebalance_move_data (glusterd_volinfo_t *volinfo, const char *dir) @@ -574,7 +574,8 @@ glusterd_handle_defrag_volume_v2 (rpcsvc_request_t *req) GF_ASSERT (req); priv = THIS->private; - if (!gf_xdr_to_cli_defrag_vol_req (req->msg[0], &cli_req)) { + if (!xdr_to_generic (req->msg[0], &cli_req, + (xdrproc_t)xdr_gf1_cli_defrag_vol_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; goto out; @@ -615,7 +616,6 @@ glusterd_handle_defrag_volume_v2 (rpcsvc_request_t *req) out: ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, - gf_xdr_serialize_cli_defrag_vol_rsp_v2, (xdrproc_t)xdr_gf2_cli_defrag_vol_rsp); if (cli_req.volname) free (cli_req.volname);//malloced by xdr @@ -638,7 +638,8 @@ glusterd_handle_defrag_volume (rpcsvc_request_t *req) priv = THIS->private; - if (!gf_xdr_to_cli_defrag_vol_req (req->msg[0], &cli_req)) { + if (!xdr_to_generic (req->msg[0], &cli_req, + (xdrproc_t)xdr_gf1_cli_defrag_vol_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; goto out; @@ -686,7 +687,6 @@ glusterd_handle_defrag_volume (rpcsvc_request_t *req) out: ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, - gf_xdr_serialize_cli_defrag_vol_rsp, (xdrproc_t)xdr_gf1_cli_defrag_vol_rsp); if (cli_req.volname) free (cli_req.volname);//malloced by xdr diff --git a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c index 16fd0bb82..f8f0e8a84 100644 --- a/xlators/mgmt/glusterd/src/glusterd-replace-brick.c +++ b/xlators/mgmt/glusterd/src/glusterd-replace-brick.c @@ -23,7 +23,8 @@ #endif #include "common-utils.h" -#include "cli1.h" +#include "cli1-xdr.h" +#include "xdr-generic.h" #include "glusterd.h" #include "glusterd-op-sm.h" #include "glusterd-store.h" @@ -48,7 +49,8 @@ glusterd_handle_replace_brick (rpcsvc_request_t *req) GF_ASSERT (req); - if (!gf_xdr_to_cli_replace_brick_req (req->msg[0], &cli_req)) { + if (!xdr_to_generic (req->msg[0], &cli_req, + (xdrproc_t)xdr_gf1_cli_replace_brick_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; goto out; diff --git a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c index 0ba0aad63..06dff923b 100644 --- a/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-rpc-ops.c @@ -25,8 +25,9 @@ #include "rpc-clnt.h" #include "glusterd1-xdr.h" -#include "glusterd1.h" -#include "cli1.h" +#include "cli1-xdr.h" + +#include "xdr-generic.h" #include "compat-errno.h" #include "glusterd-op-sm.h" @@ -52,7 +53,6 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, void *op_ctx, char *op_errstr) { int32_t ret = -1; - gd_serialize_t sfunc = NULL; void *cli_rsp = NULL; dict_t *ctx = NULL; char *free_ptr = NULL; @@ -77,7 +77,6 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, else rsp.op_errstr = ""; cli_rsp = &rsp; - sfunc = gf_xdr_serialize_cli_create_vol_rsp; xdrproc = (xdrproc_t)xdr_gf1_cli_create_vol_rsp; break; } @@ -93,7 +92,6 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, else rsp.op_errstr = ""; cli_rsp = &rsp; - sfunc = gf_xdr_serialize_cli_start_vol_rsp; xdrproc = (xdrproc_t) xdr_gf1_cli_start_vol_rsp; break; } @@ -109,7 +107,6 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, else rsp.op_errstr = ""; cli_rsp = &rsp; - sfunc = gf_xdr_serialize_cli_stop_vol_rsp; xdrproc = (xdrproc_t) xdr_gf1_cli_stop_vol_rsp; break; } @@ -125,7 +122,6 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, else rsp.op_errstr = ""; cli_rsp = &rsp; - sfunc = gf_xdr_serialize_cli_delete_vol_rsp; xdrproc = (xdrproc_t) xdr_gf1_cli_delete_vol_rsp; break; } @@ -137,7 +133,6 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, rsp.op_errno = op_errno; //rsp.volname = ""; cli_rsp = &rsp; - sfunc = gf_xdr_serialize_cli_defrag_vol_rsp; xdrproc = (xdrproc_t) xdr_gf1_cli_defrag_vol_rsp; break; } @@ -153,7 +148,6 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, else rsp.op_errstr = ""; cli_rsp = &rsp; - sfunc = gf_xdr_serialize_cli_add_brick_rsp; xdrproc = (xdrproc_t) xdr_gf1_cli_add_brick_rsp; break; } @@ -169,7 +163,6 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, rsp.op_errno = op_errno; rsp.volname = ""; cli_rsp = &rsp; - sfunc = gf_xdr_serialize_cli_remove_brick_rsp; xdrproc = (xdrproc_t) xdr_gf1_cli_remove_brick_rsp; break; } @@ -189,7 +182,6 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, rsp.op_errstr = ""; rsp.volname = ""; cli_rsp = &rsp; - sfunc = gf_xdr_serialize_cli_replace_brick_rsp; xdrproc = (xdrproc_t) xdr_gf1_cli_replace_brick_rsp; break; } @@ -215,7 +207,6 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, } cli_rsp = &rsp; - sfunc = gf_xdr_serialize_cli_set_vol_rsp; xdrproc = (xdrproc_t) xdr_gf1_cli_set_vol_rsp; break; } @@ -232,7 +223,6 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, else rsp.op_errstr = "Error while resetting options"; cli_rsp = &rsp; - sfunc = gf_xdr_serialize_cli_reset_vol_rsp; xdrproc = (xdrproc_t) xdr_gf1_cli_reset_vol_rsp; break; } @@ -247,7 +237,6 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, else rsp.errstr = ""; cli_rsp = &rsp; - sfunc = gf_xdr_serialize_cli_log_filename_rsp; xdrproc = (xdrproc_t) xdr_gf1_cli_log_filename_rsp; break; } @@ -261,7 +250,6 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, else rsp.errstr = ""; cli_rsp = &rsp; - sfunc = gf_xdr_serialize_cli_log_rotate_rsp; xdrproc = (xdrproc_t) xdr_gf1_cli_log_rotate_rsp; break; } @@ -275,7 +263,6 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, else rsp.op_errstr = ""; cli_rsp = &rsp; - sfunc = gf_xdr_from_cli_sync_volume_rsp; xdrproc = (xdrproc_t) xdr_gf1_cli_sync_volume_rsp; break; } @@ -310,7 +297,6 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, if (op_errstr) rsp.op_errstr = op_errstr; cli_rsp = &rsp; - sfunc = gf_xdr_serialize_cli_gsync_set_rsp; xdrproc = (xdrproc_t) xdr_gf1_cli_gsync_set_rsp; break; } @@ -337,7 +323,6 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, (size_t*)&rsp.stats_info.stats_info_len); free_ptr = rsp.stats_info.stats_info_val; cli_rsp = &rsp; - sfunc = gf_xdr_from_cli_stats_volume_rsp; xdrproc = (xdrproc_t) xdr_gf1_cli_stats_volume_rsp; break; } @@ -386,7 +371,6 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, } } cli_rsp = &rsp; - sfunc = gf_xdr_serialize_cli_quota_rsp; xdrproc = (xdrproc_t) xdr_gf1_cli_quota_rsp; break; } @@ -402,7 +386,6 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, rsp.op_errstr = ""; cli_rsp = &rsp; - sfunc = gf_xdr_serialize_cli_log_level_rsp; xdrproc = (xdrproc_t) xdr_gf1_cli_log_level_rsp; break; } @@ -423,7 +406,6 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, (size_t*)&rsp.dict.dict_len); free_ptr = rsp.dict.dict_val; cli_rsp = &rsp; - sfunc = gf_xdr_serialize_cli_status_volume_rsp; xdrproc = (xdrproc_t) xdr_gf1_cli_status_volume_rsp; break; } @@ -436,7 +418,7 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret, } ret = glusterd_submit_reply (req, cli_rsp, NULL, 0, NULL, - sfunc, xdrproc); + xdrproc); if (free_ptr) GF_FREE (free_ptr); @@ -461,7 +443,7 @@ glusterd3_1_probe_cbk (struct rpc_req *req, struct iovec *iov, goto out; } - ret = gd_xdr_to_mgmt_probe_rsp (*iov, &rsp); + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gd1_mgmt_probe_rsp); if (ret < 0) { gf_log ("", GF_LOG_ERROR, "error"); //rsp.op_ret = -1; @@ -548,7 +530,7 @@ glusterd3_1_friend_add_cbk (struct rpc_req * req, struct iovec *iov, goto out; } - ret = gd_xdr_to_mgmt_friend_rsp (*iov, &rsp); + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gd1_mgmt_friend_rsp); if (ret < 0) { gf_log ("", GF_LOG_ERROR, "error"); rsp.op_ret = -1; @@ -648,7 +630,7 @@ glusterd3_1_friend_remove_cbk (struct rpc_req * req, struct iovec *iov, goto inject; } - ret = gd_xdr_to_mgmt_friend_rsp (*iov, &rsp); + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gd1_mgmt_friend_rsp); if (ret < 0) { gf_log ("", GF_LOG_ERROR, "error"); rsp.op_ret = -1; @@ -730,7 +712,7 @@ glusterd3_1_friend_update_cbk (struct rpc_req *req, struct iovec *iov, goto out; } -/* ret = gd_xdr_to_mgmt_friend_update_rsp (*iov, &rsp); +/* ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gd1_mgmt_friend_update_rsp); if (ret < 0) { gf_log ("", GF_LOG_ERROR, "error"); rsp.op_ret = -1; @@ -768,7 +750,7 @@ glusterd3_1_cluster_lock_cbk (struct rpc_req *req, struct iovec *iov, goto out; } - ret = gd_xdr_to_mgmt_cluster_lock_rsp (*iov, &rsp); + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gd1_mgmt_cluster_lock_rsp); if (ret < 0) { gf_log ("", GF_LOG_ERROR, "error"); rsp.op_ret = -1; @@ -827,7 +809,7 @@ glusterd3_1_cluster_unlock_cbk (struct rpc_req *req, struct iovec *iov, goto out; } - ret = gd_xdr_to_mgmt_cluster_unlock_rsp (*iov, &rsp); + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gd1_mgmt_cluster_unlock_rsp); if (ret < 0) { gf_log ("", GF_LOG_ERROR, "error"); rsp.op_ret = -1; @@ -1078,7 +1060,7 @@ glusterd3_1_stage_op_cbk (struct rpc_req *req, struct iovec *iov, goto out; } - ret = gd_xdr_to_mgmt_stage_op_rsp (*iov, &rsp); + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gd1_mgmt_stage_op_rsp); if (ret < 0) { gf_log ("", GF_LOG_ERROR, "error"); rsp.op_ret = -1; @@ -1319,7 +1301,7 @@ glusterd3_1_commit_op_cbk (struct rpc_req *req, struct iovec *iov, goto out; } - ret = gd_xdr_to_mgmt_commit_op_rsp (*iov, &rsp); + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gd1_mgmt_commit_op_rsp); if (ret < 0) { gf_log ("", GF_LOG_ERROR, "error"); rsp.op_ret = -1; @@ -1473,8 +1455,7 @@ glusterd3_1_probe (call_frame_t *frame, xlator_t *this, ret = glusterd_submit_request (peerinfo->rpc, &req, frame, peerinfo->mgmt, GD_MGMT_PROBE_QUERY, - NULL, gd_xdr_from_mgmt_probe_req, - this, glusterd3_1_probe_cbk, + NULL, this, glusterd3_1_probe_cbk, (xdrproc_t)xdr_gd1_mgmt_probe_req); out: @@ -1527,8 +1508,7 @@ glusterd3_1_friend_add (call_frame_t *frame, xlator_t *this, ret = glusterd_submit_request (peerinfo->rpc, &req, frame, peerinfo->mgmt, GD_MGMT_FRIEND_ADD, - NULL, gd_xdr_from_mgmt_friend_req, - this, glusterd3_1_friend_add_cbk, + NULL, this, glusterd3_1_friend_add_cbk, (xdrproc_t)xdr_gd1_mgmt_friend_req); @@ -1569,8 +1549,7 @@ glusterd3_1_friend_remove (call_frame_t *frame, xlator_t *this, req.hostname = peerinfo->hostname; req.port = peerinfo->port; ret = glusterd_submit_request (peerinfo->rpc, &req, frame, peerinfo->mgmt, - GD_MGMT_FRIEND_REMOVE, - NULL, gd_xdr_from_mgmt_friend_req, + GD_MGMT_FRIEND_REMOVE, NULL, this, glusterd3_1_friend_remove_cbk, (xdrproc_t)xdr_gd1_mgmt_friend_req); @@ -1616,8 +1595,7 @@ glusterd3_1_friend_update (call_frame_t *frame, xlator_t *this, dummy_frame = create_frame (this, this->ctx->pool); ret = glusterd_submit_request (peerinfo->rpc, &req, dummy_frame, peerinfo->mgmt, - GD_MGMT_FRIEND_UPDATE, - NULL, gd_xdr_from_mgmt_friend_update, + GD_MGMT_FRIEND_UPDATE, NULL, this, glusterd3_1_friend_update_cbk, (xdrproc_t)xdr_gd1_mgmt_friend_update); @@ -1656,7 +1634,6 @@ glusterd3_1_cluster_lock (call_frame_t *frame, xlator_t *this, ret = glusterd_submit_request (peerinfo->rpc, &req, dummy_frame, peerinfo->mgmt, GD_MGMT_CLUSTER_LOCK, NULL, - gd_xdr_from_mgmt_cluster_lock_req, this, glusterd3_1_cluster_lock_cbk, (xdrproc_t)xdr_gd1_mgmt_cluster_lock_req); out: @@ -1691,7 +1668,6 @@ glusterd3_1_cluster_unlock (call_frame_t *frame, xlator_t *this, ret = glusterd_submit_request (peerinfo->rpc, &req, dummy_frame, peerinfo->mgmt, GD_MGMT_CLUSTER_UNLOCK, NULL, - gd_xdr_from_mgmt_cluster_unlock_req, this, glusterd3_1_cluster_unlock_cbk, (xdrproc_t)xdr_gd1_mgmt_cluster_unlock_req); out: @@ -1751,7 +1727,6 @@ glusterd3_1_stage_op (call_frame_t *frame, xlator_t *this, ret = glusterd_submit_request (peerinfo->rpc, &req, dummy_frame, peerinfo->mgmt, GD_MGMT_STAGE_OP, NULL, - gd_xdr_from_mgmt_stage_op_req, this, glusterd3_1_stage_op_cbk, (xdrproc_t)xdr_gd1_mgmt_stage_op_req); @@ -1814,7 +1789,6 @@ glusterd3_1_commit_op (call_frame_t *frame, xlator_t *this, ret = glusterd_submit_request (peerinfo->rpc, &req, dummy_frame, peerinfo->mgmt, GD_MGMT_COMMIT_OP, NULL, - gd_xdr_from_mgmt_commit_op_req, this, glusterd3_1_commit_op_cbk, (xdrproc_t)xdr_gd1_mgmt_commit_op_req); @@ -1874,7 +1848,7 @@ glusterd3_1_brick_op_cbk (struct rpc_req *req, struct iovec *iov, goto out; } - ret = gd_xdr_to_mgmt_brick_op_rsp (*iov, &rsp); + ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gd1_mgmt_brick_op_rsp); if (ret < 0) { gf_log ("", GF_LOG_ERROR, "error"); rsp.op_ret = -1; @@ -2044,7 +2018,6 @@ glusterd3_1_brick_op (call_frame_t *frame, xlator_t *this, ret = glusterd_submit_request (brickinfo->rpc, req, dummy_frame, &glusterd_glusterfs_3_1_mgmt_prog, req->op, NULL, - gd_xdr_from_mgmt_brick_op_req, this, glusterd3_1_brick_op_cbk, (xdrproc_t)xdr_gd1_mgmt_brick_op_req); if (req) { diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index f0164849e..53fdcf484 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -44,8 +44,6 @@ #include "glusterd-utils.h" #include "glusterd-store.h" -#include "glusterd1.h" -#include "cli1.h" #include "rpc-clnt.h" #include "common-utils.h" diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 589bbbe20..eaae6b7fb 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -46,6 +46,8 @@ #include "glusterd-volgen.h" #include "glusterd-pmap.h" +#include "xdr-generic.h" + #include <sys/resource.h> #include <inttypes.h> #include <signal.h> @@ -306,8 +308,7 @@ int glusterd_submit_request (struct rpc_clnt *rpc, void *req, call_frame_t *frame, rpc_clnt_prog_t *prog, int procnum, struct iobref *iobref, - gd_serialize_t sfunc, xlator_t *this, - fop_cbk_fn_t cbkfn, xdrproc_t xdrproc) + xlator_t *this, fop_cbk_fn_t cbkfn, xdrproc_t xdrproc) { int ret = -1; struct iobuf *iobuf = NULL; @@ -319,35 +320,36 @@ glusterd_submit_request (struct rpc_clnt *rpc, void *req, GF_ASSERT (rpc); GF_ASSERT (this); - req_size = xdr_sizeof (xdrproc, req); - iobuf = iobuf_get2 (this->ctx->iobuf_pool, req_size); - if (!iobuf) { - goto out; - }; + if (req) { + req_size = xdr_sizeof (xdrproc, req); + iobuf = iobuf_get2 (this->ctx->iobuf_pool, req_size); + if (!iobuf) { + goto out; + }; - if (!iobref) { - iobref = iobref_new (); if (!iobref) { - goto out; - } + iobref = iobref_new (); + if (!iobref) { + goto out; + } - new_iobref = 1; - } + new_iobref = 1; + } - iobref_add (iobref, iobuf); + iobref_add (iobref, iobuf); - iov.iov_base = iobuf->ptr; - iov.iov_len = iobuf_pagesize (iobuf); + iov.iov_base = iobuf->ptr; + iov.iov_len = iobuf_pagesize (iobuf); - /* Create the xdr payload */ - if (req && sfunc) { - ret = sfunc (iov, req); + /* Create the xdr payload */ + ret = xdr_serialize_generic (iov, req, xdrproc); if (ret == -1) { goto out; } iov.iov_len = ret; count = 1; } + /* Send the msg */ ret = rpc_clnt_submit (rpc, prog, procnum, cbkfn, &iov, count, @@ -379,8 +381,7 @@ out: struct iobuf * glusterd_serialize_reply (rpcsvc_request_t *req, void *arg, - gd_serialize_t sfunc, struct iovec *outmsg, - xdrproc_t xdrproc) + struct iovec *outmsg, xdrproc_t xdrproc) { struct iobuf *iob = NULL; ssize_t retlen = -1; @@ -403,7 +404,7 @@ glusterd_serialize_reply (rpcsvc_request_t *req, void *arg, /* retlen is used to received the error since size_t is unsigned and we * need -1 for error notification during encoding. */ - retlen = sfunc (*outmsg, arg); + retlen = xdr_serialize_generic (*outmsg, arg, xdrproc); if (retlen == -1) { gf_log ("", GF_LOG_ERROR, "Failed to encode message"); goto ret; @@ -422,8 +423,7 @@ ret: int glusterd_submit_reply (rpcsvc_request_t *req, void *arg, struct iovec *payload, int payloadcount, - struct iobref *iobref, gd_serialize_t sfunc, - xdrproc_t xdrproc) + struct iobref *iobref, xdrproc_t xdrproc) { struct iobuf *iob = NULL; int ret = -1; @@ -435,7 +435,6 @@ glusterd_submit_reply (rpcsvc_request_t *req, void *arg, goto out; } - if (!iobref) { iobref = iobref_new (); if (!iobref) { @@ -446,7 +445,7 @@ glusterd_submit_reply (rpcsvc_request_t *req, void *arg, new_iobref = 1; } - iob = glusterd_serialize_reply (req, arg, sfunc, &rsp, xdrproc); + iob = glusterd_serialize_reply (req, arg, &rsp, xdrproc); if (!iob) { gf_log ("", GF_LOG_ERROR, "Failed to serialize reply"); } else { diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h index 1a4dadf1f..57e5c82f4 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.h +++ b/xlators/mgmt/glusterd/src/glusterd-utils.h @@ -71,15 +71,13 @@ glusterd_get_uuid (uuid_t *uuid); int glusterd_submit_reply (rpcsvc_request_t *req, void *arg, struct iovec *payload, int payloadcount, - struct iobref *iobref, gd_serialize_t sfunc, - xdrproc_t xdrproc); + struct iobref *iobref, xdrproc_t xdrproc); int glusterd_submit_request (struct rpc_clnt *rpc, void *req, call_frame_t *frame, rpc_clnt_prog_t *prog, int procnum, struct iobref *iobref, - gd_serialize_t sfunc, xlator_t *this, - fop_cbk_fn_t cbkfn, xdrproc_t xdrproc); + xlator_t *this, fop_cbk_fn_t cbkfn, xdrproc_t xdrproc); int32_t glusterd_volinfo_new (glusterd_volinfo_t **volinfo); diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index 050a02e4b..9f1ebe013 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -38,7 +38,7 @@ #include "graph-utils.h" #include "trie.h" #include "glusterd-mem-types.h" -#include "cli1.h" +#include "cli1-xdr.h" #include "glusterd-volgen.h" #include "glusterd-op-sm.h" #include "glusterd-utils.h" diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c index 1e4670304..d7b28ba1e 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c @@ -23,7 +23,8 @@ #endif #include "common-utils.h" -#include "cli1.h" +#include "cli1-xdr.h" +#include "xdr-generic.h" #include "glusterd.h" #include "glusterd-op-sm.h" #include "glusterd-store.h" @@ -69,7 +70,8 @@ glusterd_handle_create_volume (rpcsvc_request_t *req) priv = this->private; ret = -1; - if (!gf_xdr_to_cli_create_vol_req (req->msg[0], &cli_req)) { + if (!xdr_to_generic (req->msg[0], &cli_req, + (xdrproc_t)xdr_gf1_cli_create_vol_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; snprintf (err_str, sizeof (err_str), "Garbage args received"); @@ -204,7 +206,6 @@ out: rsp.op_errstr = err_str; cli_rsp = &rsp; glusterd_submit_reply(req, cli_rsp, NULL, 0, NULL, - gf_xdr_serialize_cli_create_vol_rsp, (xdrproc_t)xdr_gf1_cli_create_vol_rsp); ret = 0; //Client response sent, prevent second response @@ -236,7 +237,8 @@ glusterd_handle_cli_start_volume (rpcsvc_request_t *req) GF_ASSERT (req); - if (!gf_xdr_to_cli_start_vol_req (req->msg[0], &cli_req)) { + if (!xdr_to_generic (req->msg[0], &cli_req, + (xdrproc_t)xdr_gf1_cli_start_vol_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; goto out; @@ -294,7 +296,8 @@ glusterd_handle_cli_stop_volume (rpcsvc_request_t *req) GF_ASSERT (req); - if (!gf_xdr_to_cli_stop_vol_req (req->msg[0], &cli_req)) { + if (!xdr_to_generic (req->msg[0], &cli_req, + (xdrproc_t)xdr_gf1_cli_stop_vol_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; goto out; @@ -351,7 +354,8 @@ glusterd_handle_cli_delete_volume (rpcsvc_request_t *req) GF_ASSERT (req); - if (!gf_xdr_to_cli_delete_vol_req (req->msg[0], &cli_req)) { + if (!xdr_to_generic (req->msg[0], &cli_req, + (xdrproc_t)xdr_gf1_cli_delete_vol_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; goto out; |