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 /cli | |
| 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 'cli')
| -rw-r--r-- | cli/src/cli-cmd.c | 6 | ||||
| -rw-r--r-- | cli/src/cli-cmd.h | 3 | ||||
| -rw-r--r-- | cli/src/cli-rpc-ops.c | 101 | ||||
| -rw-r--r-- | cli/src/cli.c | 39 | ||||
| -rw-r--r-- | cli/src/cli.h | 3 | 
5 files changed, 61 insertions, 91 deletions
diff --git a/cli/src/cli-cmd.c b/cli/src/cli-cmd.c index 8751a570353..385e2ac2e1c 100644 --- a/cli/src/cli-cmd.c +++ b/cli/src/cli-cmd.c @@ -364,16 +364,14 @@ int  cli_cmd_submit (void *req, call_frame_t *frame,                  rpc_clnt_prog_t *prog,                  int procnum, struct iobref *iobref, -                cli_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;          cli_cmd_lock ();          cmd_sent = 0;          ret = cli_submit_request (req, frame, prog, -                                  procnum, NULL, sfunc, -                                  this, cbkfn, xdrproc); +                                  procnum, NULL, this, cbkfn, xdrproc);          if (!ret) {                  cmd_sent = 1; diff --git a/cli/src/cli-cmd.h b/cli/src/cli-cmd.h index b5680d5da35..f6abfa4645f 100644 --- a/cli/src/cli-cmd.h +++ b/cli/src/cli-cmd.h @@ -83,8 +83,7 @@ int  cli_cmd_submit (void *req, call_frame_t *frame,                  rpc_clnt_prog_t *prog,                  int procnum, struct iobref *iobref, -                cli_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);  gf_answer_t  cli_cmd_get_confirmation (struct cli_state *state, const char *question); diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 52e3d11d7fc..31ede5007fd 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -35,14 +35,14 @@  #include <stdlib.h>  #include <sys/mount.h>  #include "cli1-xdr.h" -#include "cli1.h" +#include "xdr-generic.h"  #include "protocol-common.h"  #include "cli-mem-types.h"  #include "compat.h"  #include "syscall.h"  #include "glusterfs3.h" -#include "portmap.h" +#include "portmap-xdr.h"  #include "run.h" @@ -94,7 +94,7 @@ gf_cli3_1_probe_cbk (struct rpc_req *req, struct iovec *iov,                  goto out;          } -        ret = gf_xdr_to_cli_probe_rsp (*iov, &rsp); +        ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_probe_rsp);          if (ret < 0) {                  gf_log ("", GF_LOG_ERROR, "error");                  //rsp.op_ret   = -1; @@ -170,7 +170,7 @@ gf_cli3_1_deprobe_cbk (struct rpc_req *req, struct iovec *iov,                  goto out;          } -        ret = gf_xdr_to_cli_deprobe_rsp (*iov, &rsp); +        ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_deprobe_rsp);          if (ret < 0) {                  gf_log ("", GF_LOG_ERROR, "error");                  //rsp.op_ret   = -1; @@ -233,7 +233,7 @@ gf_cli3_1_list_friends_cbk (struct rpc_req *req, struct iovec *iov,                  goto out;          } -        ret = gf_xdr_to_cli_peer_list_rsp (*iov, &rsp); +        ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_peer_list_rsp);          if (ret < 0) {                  gf_log ("", GF_LOG_ERROR, "error");                  //rsp.op_ret   = -1; @@ -400,7 +400,7 @@ gf_cli3_1_get_volume_cbk (struct rpc_req *req, struct iovec *iov,                  goto out;          } -        ret = gf_xdr_to_cli_get_vol_rsp (*iov, &rsp); +        ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_get_vol_rsp);          if (ret < 0) {                  gf_log ("", GF_LOG_ERROR, "error");                  //rsp.op_ret   = -1; @@ -624,7 +624,7 @@ gf_cli3_1_create_volume_cbk (struct rpc_req *req, struct iovec *iov,          local = ((call_frame_t *) (myframe))->local;          ((call_frame_t *) (myframe))->local = NULL; -        ret = gf_xdr_to_cli_create_vol_rsp (*iov, &rsp); +        ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_create_vol_rsp);          if (ret < 0) {                  gf_log ("", GF_LOG_ERROR, "error");                  goto out; @@ -671,7 +671,7 @@ gf_cli3_1_delete_volume_cbk (struct rpc_req *req, struct iovec *iov,                  goto out;          } -        ret = gf_xdr_to_cli_delete_vol_rsp (*iov, &rsp); +        ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_delete_vol_rsp);          if (ret < 0) {                  gf_log ("", GF_LOG_ERROR, "error");                  goto out; @@ -717,7 +717,7 @@ gf_cli3_1_start_volume_cbk (struct rpc_req *req, struct iovec *iov,                  goto out;          } -        ret = gf_xdr_to_cli_start_vol_rsp (*iov, &rsp); +        ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_start_vol_rsp);          if (ret < 0) {                  gf_log ("", GF_LOG_ERROR, "error");                  goto out; @@ -768,7 +768,7 @@ gf_cli3_1_stop_volume_cbk (struct rpc_req *req, struct iovec *iov,                  goto out;          } -        ret = gf_xdr_to_cli_stop_vol_rsp (*iov, &rsp); +        ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_stop_vol_rsp);          if (ret < 0) {                  gf_log ("", GF_LOG_ERROR, "error");                  goto out; @@ -816,7 +816,8 @@ gf_cli3_1_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov,                  goto out;          } -        ret = gf_xdr_to_cli_defrag_vol_rsp_v2 (*iov, &rsp); +        ret = xdr_to_generic (*iov, &rsp, +                              (xdrproc_t)xdr_gf2_cli_defrag_vol_rsp);          if (ret < 0) {                  gf_log ("", GF_LOG_ERROR, "error");                  goto out; @@ -928,7 +929,7 @@ gf_cli3_1_rename_volume_cbk (struct rpc_req *req, struct iovec *iov,                  goto out;          } -        ret = gf_xdr_to_cli_rename_vol_rsp (*iov, &rsp); +        ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_rename_vol_rsp);          if (ret < 0) {                  gf_log ("", GF_LOG_ERROR, "error");                  goto out; @@ -957,7 +958,7 @@ gf_cli3_1_reset_volume_cbk (struct rpc_req *req, struct iovec *iov,                  goto out;          } -        ret = gf_xdr_to_cli_reset_vol_rsp (*iov, &rsp); +        ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_reset_vol_rsp);          if (ret < 0) {                  gf_log ("", GF_LOG_ERROR, "error");                  goto out; @@ -991,7 +992,7 @@ gf_cli3_1_set_volume_cbk (struct rpc_req *req, struct iovec *iov,                  goto out;          } -        ret = gf_xdr_to_cli_set_vol_rsp (*iov, &rsp); +        ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_set_vol_rsp);          if (ret < 0) {                  gf_log ("", GF_LOG_ERROR, "error");                  goto out; @@ -1038,7 +1039,7 @@ gf_cli3_1_add_brick_cbk (struct rpc_req *req, struct iovec *iov,                  goto out;          } -        ret = gf_xdr_to_cli_add_brick_rsp (*iov, &rsp); +        ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_add_brick_rsp);          if (ret < 0) {                  gf_log ("", GF_LOG_ERROR, "error");                  goto out; @@ -1075,7 +1076,7 @@ gf_cli3_1_remove_brick_cbk (struct rpc_req *req, struct iovec *iov,                  goto out;          } -        ret = gf_xdr_to_cli_remove_brick_rsp (*iov, &rsp); +        ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_remove_brick_rsp);          if (ret < 0) {                  gf_log ("", GF_LOG_ERROR, "error");                  goto out; @@ -1123,7 +1124,7 @@ gf_cli3_1_replace_brick_cbk (struct rpc_req *req, struct iovec *iov,          frame = (call_frame_t *) myframe; -        ret = gf_xdr_to_cli_replace_brick_rsp (*iov, &rsp); +        ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_replace_brick_rsp);          if (ret < 0) {                  gf_log ("", GF_LOG_ERROR, "error");                  goto out; @@ -1234,7 +1235,7 @@ gf_cli3_1_log_filename_cbk (struct rpc_req *req, struct iovec *iov,                  goto out;          } -        ret = gf_xdr_to_cli_log_filename_rsp (*iov, &rsp); +        ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_log_filename_rsp);          if (ret < 0) {                  gf_log ("", GF_LOG_ERROR, "error");                  goto out; @@ -1266,7 +1267,7 @@ gf_cli3_1_log_locate_cbk (struct rpc_req *req, struct iovec *iov,                  goto out;          } -        ret = gf_xdr_to_cli_log_locate_rsp (*iov, &rsp); +        ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_log_locate_rsp);          if (ret < 0) {                  gf_log ("", GF_LOG_ERROR, "error");                  goto out; @@ -1293,7 +1294,7 @@ gf_cli3_1_log_rotate_cbk (struct rpc_req *req, struct iovec *iov,                  goto out;          } -        ret = gf_xdr_to_cli_log_rotate_rsp (*iov, &rsp); +        ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_log_rotate_rsp);          if (ret < 0) {                  gf_log ("", GF_LOG_ERROR, "error");                  goto out; @@ -1325,7 +1326,7 @@ gf_cli3_1_sync_volume_cbk (struct rpc_req *req, struct iovec *iov,                  goto out;          } -        ret = gf_xdr_to_cli_sync_volume_rsp (*iov, &rsp); +        ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_sync_volume_rsp);          if (ret < 0) {                  gf_log ("", GF_LOG_ERROR, "error");                  goto out; @@ -1471,7 +1472,7 @@ gf_cli3_1_quota_cbk (struct rpc_req *req, struct iovec *iov,                  goto out;          } -        ret = gf_xdr_to_cli_quota_rsp (*iov, &rsp); +        ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_quota_rsp);          if (ret < 0) {                  gf_log ("", GF_LOG_ERROR, "error");                  goto out; @@ -1516,7 +1517,7 @@ gf_cli3_1_getspec_cbk (struct rpc_req *req, struct iovec *iov,                  goto out;          } -        ret = xdr_to_getspec_rsp (*iov, &rsp); +        ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_getspec_rsp);          if (ret < 0 || rsp.op_ret == -1) {                  gf_log ("", GF_LOG_ERROR, "error");                  goto out; @@ -1553,7 +1554,7 @@ gf_cli3_1_pmap_b2p_cbk (struct rpc_req *req, struct iovec *iov,                  goto out;          } -        ret = xdr_to_pmap_port_by_brick_rsp (*iov, &rsp); +        ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_pmap_port_by_brick_rsp);          if (ret < 0 || rsp.op_ret == -1) {                  gf_log ("", GF_LOG_ERROR, "error");                  goto out; @@ -1600,7 +1601,7 @@ gf_cli3_1_probe (call_frame_t *frame, xlator_t *this,          req.port     = port;          ret = cli_cmd_submit (&req, frame, cli_rpc_prog, -                              GLUSTER_CLI_PROBE, NULL, gf_xdr_from_cli_probe_req, +                              GLUSTER_CLI_PROBE, NULL,                                this, gf_cli3_1_probe_cbk,                                (xdrproc_t)xdr_gf1_cli_probe_req); @@ -1638,7 +1639,6 @@ gf_cli3_1_deprobe (call_frame_t *frame, xlator_t *this,          ret = cli_cmd_submit (&req, frame, cli_rpc_prog,                                GLUSTER_CLI_DEPROBE, NULL, -                              gf_xdr_from_cli_deprobe_req,                                this, gf_cli3_1_deprobe_cbk,                                (xdrproc_t)xdr_gf1_cli_deprobe_req); @@ -1663,7 +1663,6 @@ gf_cli3_1_list_friends (call_frame_t *frame, xlator_t *this,          ret = cli_cmd_submit (&req, frame, cli_rpc_prog,                                GLUSTER_CLI_LIST_FRIENDS, NULL, -                              gf_xdr_from_cli_peer_list_req,                                this, gf_cli3_1_list_friends_cbk,                                (xdrproc_t) xdr_gf1_cli_peer_list_req); @@ -1743,7 +1742,6 @@ gf_cli3_1_get_volume (call_frame_t *frame, xlator_t *this,          ret = cli_cmd_submit (&req, frame, cli_rpc_prog,                                GLUSTER_CLI_GET_VOLUME, NULL, -                              gf_xdr_from_cli_get_vol_req,                                this, gf_cli3_1_get_volume_cbk,                                (xdrproc_t) xdr_gf1_cli_get_vol_req); @@ -1801,7 +1799,6 @@ gf_cli3_1_create_volume (call_frame_t *frame, xlator_t *this,          ret = cli_cmd_submit (&req, frame, cli_rpc_prog,                                GLUSTER_CLI_CREATE_VOLUME, NULL, -                              gf_xdr_from_cli_create_vol_req,                                this, gf_cli3_1_create_volume_cbk,                                (xdrproc_t) xdr_gf1_cli_create_vol_req); @@ -1844,7 +1841,6 @@ gf_cli3_1_delete_volume (call_frame_t *frame, xlator_t *this,          ret = cli_cmd_submit (&req, frame, cli_rpc_prog,                                GLUSTER_CLI_DELETE_VOLUME, NULL, -                              gf_xdr_from_cli_delete_vol_req,                                this, gf_cli3_1_delete_volume_cbk,                                (xdrproc_t)xdr_gf1_cli_delete_vol_req); @@ -1878,7 +1874,6 @@ gf_cli3_1_start_volume (call_frame_t *frame, xlator_t *this,          ret = cli_cmd_submit (req, frame, cli_rpc_prog,                                GLUSTER_CLI_START_VOLUME, NULL, -                              gf_xdr_from_cli_start_vol_req,                                this, gf_cli3_1_start_volume_cbk,                                (xdrproc_t) xdr_gf1_cli_start_vol_req); @@ -1912,7 +1907,6 @@ gf_cli3_1_stop_volume (call_frame_t *frame, xlator_t *this,          ret = cli_cmd_submit (&req, frame, cli_rpc_prog,                                GLUSTER_CLI_STOP_VOLUME, NULL, -                              gf_xdr_from_cli_stop_vol_req,                                this, gf_cli3_1_stop_volume_cbk,                                (xdrproc_t) xdr_gf1_cli_stop_vol_req); @@ -1987,7 +1981,6 @@ done:          ret = cli_cmd_submit (&req, frame, cli_rpc_prog,                                GLUSTER_CLI_DEFRAG_VOLUME, NULL, -                              gf_xdr_from_cli_defrag_vol_req,                                this, gf_cli3_1_defrag_volume_cbk,                                (xdrproc_t) xdr_gf1_cli_defrag_vol_req); @@ -2024,7 +2017,6 @@ gf_cli3_1_rename_volume (call_frame_t *frame, xlator_t *this,          ret = cli_cmd_submit (&req, frame, cli_rpc_prog,                                GLUSTER_CLI_RENAME_VOLUME, NULL, -                              gf_xdr_from_cli_rename_vol_req,                                this, gf_cli3_1_rename_volume_cbk,                                (xdrproc_t) xdr_gf1_cli_rename_vol_req); @@ -2065,7 +2057,6 @@ gf_cli3_1_reset_volume (call_frame_t *frame, xlator_t *this,          ret = cli_cmd_submit (&req, frame, cli_rpc_prog,                                 GLUSTER_CLI_RESET_VOLUME, NULL, -                               gf_xdr_from_cli_reset_vol_req,                                 this, gf_cli3_1_reset_volume_cbk,                                 (xdrproc_t) xdr_gf1_cli_reset_vol_req); @@ -2106,7 +2097,6 @@ gf_cli3_1_set_volume (call_frame_t *frame, xlator_t *this,          ret = cli_cmd_submit (&req, frame, cli_rpc_prog,                                GLUSTER_CLI_SET_VOLUME, NULL, -                              gf_xdr_from_cli_set_vol_req,                                this, gf_cli3_1_set_volume_cbk,                                (xdrproc_t) xdr_gf1_cli_set_vol_req); @@ -2152,7 +2142,6 @@ gf_cli3_1_add_brick (call_frame_t *frame, xlator_t *this,          ret = cli_cmd_submit (&req, frame, cli_rpc_prog,                                GLUSTER_CLI_ADD_BRICK, NULL, -                              gf_xdr_from_cli_add_brick_req,                                this, gf_cli3_1_add_brick_cbk,                                (xdrproc_t) xdr_gf1_cli_add_brick_req); @@ -2202,7 +2191,6 @@ gf_cli3_1_remove_brick (call_frame_t *frame, xlator_t *this,          ret = cli_cmd_submit (&req, frame, cli_rpc_prog,                                GLUSTER_CLI_REMOVE_BRICK, NULL, -                              gf_xdr_from_cli_remove_brick_req,                                this, gf_cli3_1_remove_brick_cbk,                                (xdrproc_t) xdr_gf1_cli_remove_brick_req); @@ -2298,7 +2286,6 @@ gf_cli3_1_replace_brick (call_frame_t *frame, xlator_t *this,          ret = cli_cmd_submit (&req, frame, cli_rpc_prog,                                GLUSTER_CLI_REPLACE_BRICK, NULL, -                              gf_xdr_from_cli_replace_brick_req,                                this, gf_cli3_1_replace_brick_cbk,                                (xdrproc_t) xdr_gf1_cli_replace_brick_req); @@ -2341,7 +2328,6 @@ gf_cli3_1_log_filename (call_frame_t *frame, xlator_t *this,          ret = cli_cmd_submit (&req, frame, cli_rpc_prog,                                GLUSTER_CLI_LOG_FILENAME, NULL, -                              gf_xdr_from_cli_log_filename_req,                                this, gf_cli3_1_log_filename_cbk,                                (xdrproc_t) xdr_gf1_cli_log_filename_req); @@ -2361,7 +2347,7 @@ gf_cli3_1_log_level_cbk (struct rpc_req *req, struct iovec *iov,          if (req->rpc_status == -1)                  goto out; -        ret = gf_xdr_to_cli_log_level_rsp (*iov, &rsp); +        ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_log_level_rsp);          if (ret < 0) {                  gf_log ("cli", GF_LOG_ERROR, "log level response error");                  goto out; @@ -2411,7 +2397,6 @@ gf_cli3_1_log_level (call_frame_t *frame, xlator_t *this,          ret = cli_cmd_submit (&req, frame, cli_rpc_prog,                                GLUSTER_CLI_LOG_LEVEL, NULL, -                              gf_xdr_from_cli_log_level_req,                                this, gf_cli3_1_log_level_cbk,                                (xdrproc_t) xdr_gf1_cli_log_level_req); @@ -2446,7 +2431,6 @@ gf_cli3_1_log_locate (call_frame_t *frame, xlator_t *this,          ret = cli_cmd_submit (&req, frame, cli_rpc_prog,                                GLUSTER_CLI_LOG_LOCATE, NULL, -                              gf_xdr_from_cli_log_locate_req,                                this, gf_cli3_1_log_locate_cbk,                                (xdrproc_t) xdr_gf1_cli_log_locate_req); @@ -2481,7 +2465,6 @@ gf_cli3_1_log_rotate (call_frame_t *frame, xlator_t *this,          ret = cli_cmd_submit (&req, frame, cli_rpc_prog,                                GLUSTER_CLI_LOG_ROTATE, NULL, -                              gf_xdr_from_cli_log_rotate_req,                                this, gf_cli3_1_log_rotate_cbk,                                (xdrproc_t) xdr_gf1_cli_log_rotate_req); @@ -2505,8 +2488,7 @@ gf_cli3_1_sync_volume (call_frame_t *frame, xlator_t *this,          ret = cli_cmd_submit ((gf1_cli_sync_volume_req*)data, frame,                                cli_rpc_prog, GLUSTER_CLI_SYNC_VOLUME, -                              NULL, gf_xdr_from_cli_sync_volume_req, -                              this, gf_cli3_1_sync_volume_cbk, +                              NULL, this, gf_cli3_1_sync_volume_cbk,                                (xdrproc_t) xdr_gf1_cli_sync_volume_req);  out: @@ -2536,7 +2518,6 @@ gf_cli3_1_getspec (call_frame_t *frame, xlator_t *this,          ret = cli_cmd_submit (&req, frame, &cli_handshake_prog,                                GF_HNDSK_GETSPEC, NULL, -                              xdr_from_getspec_req,                                this, gf_cli3_1_getspec_cbk,                                (xdrproc_t) xdr_gf_getspec_req); @@ -2576,10 +2557,9 @@ gf_cli3_1_quota (call_frame_t *frame, xlator_t *this,          }          ret = cli_cmd_submit (&req, frame, cli_rpc_prog, -                               GLUSTER_CLI_QUOTA, NULL, -                               gf_xdr_from_cli_quota_req, -                               this, gf_cli3_1_quota_cbk, -                               (xdrproc_t) xdr_gf1_cli_quota_req); +                              GLUSTER_CLI_QUOTA, NULL, +                              this, gf_cli3_1_quota_cbk, +                              (xdrproc_t) xdr_gf1_cli_quota_req);          GF_FREE (req.dict.dict_val);  out: @@ -2606,7 +2586,6 @@ gf_cli3_1_pmap_b2p (call_frame_t *frame, xlator_t *this, void *data)          ret = cli_cmd_submit (&req, frame, &cli_pmap_prog,                                GF_PMAP_PORTBYBRICK, NULL, -                              xdr_from_pmap_port_by_brick_req,                                this, gf_cli3_1_pmap_b2p_cbk,                                (xdrproc_t) xdr_pmap_port_by_brick_req); @@ -2635,7 +2614,7 @@ gf_cli3_1_fsm_log_cbk (struct rpc_req *req, struct iovec *iov,                  goto out;          } -        ret = gf_xdr_to_cli_fsm_log_rsp (*iov, &rsp); +        ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_fsm_log_rsp);          if (ret < 0) {                  gf_log ("", GF_LOG_ERROR, "error");                  goto out; @@ -2721,7 +2700,6 @@ gf_cli3_1_fsm_log (call_frame_t *frame, xlator_t *this, void *data)          req.name = data;          ret = cli_cmd_submit (&req, frame, cli_rpc_prog,                                GLUSTER_CLI_FSM_LOG, NULL, -                              gf_xdr_from_cli_fsm_log_req,                                this, gf_cli3_1_fsm_log_cbk,                                (xdrproc_t) xdr_gf1_cli_fsm_log_req); @@ -2844,7 +2822,7 @@ gf_cli3_1_gsync_set_cbk (struct rpc_req *req, struct iovec *iov,                  goto out;          } -        ret = gf_xdr_to_cli_gsync_set_rsp (*iov, &rsp); +        ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_gsync_set_rsp);          if (ret < 0) {                  gf_log ("", GF_LOG_ERROR,                          "Unable to get response structure"); @@ -2937,7 +2915,6 @@ gf_cli3_1_gsync_set (call_frame_t *frame, xlator_t *this,          ret = cli_cmd_submit (&req, frame, cli_rpc_prog,                                GLUSTER_CLI_GSYNC_SET, NULL, -                              gf_xdr_from_cli_gsync_set_req,                                this, gf_cli3_1_gsync_set_cbk,                                (xdrproc_t) xdr_gf1_cli_gsync_set_req); @@ -3171,7 +3148,7 @@ gf_cli3_1_profile_volume_cbk (struct rpc_req *req, struct iovec *iov,          }          gf_log ("cli", GF_LOG_DEBUG, "Received resp to profile"); -        ret = gf_xdr_to_cli_stats_volume_rsp (*iov, &rsp); +        ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_stats_volume_rsp);          if (ret < 0) {                  gf_log ("", GF_LOG_ERROR, "error");                  goto out; @@ -3289,7 +3266,6 @@ gf_cli3_1_profile_volume (call_frame_t *frame, xlator_t *this, void *data)          ret = cli_cmd_submit (&req, frame, cli_rpc_prog,                                GLUSTER_CLI_PROFILE_VOLUME, NULL, -                              gf_xdr_from_cli_stats_volume_req,                                this, gf_cli3_1_profile_volume_cbk,                                (xdrproc_t) xdr_gf1_cli_stats_volume_req); @@ -3331,7 +3307,7 @@ gf_cli3_1_top_volume_cbk (struct rpc_req *req, struct iovec *iov,          }          gf_log ("cli", GF_LOG_DEBUG, "Received resp to top"); -        ret = gf_xdr_to_cli_stats_volume_rsp (*iov, &rsp); +        ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_stats_volume_rsp);          if (ret < 0) {                  gf_log ("", GF_LOG_ERROR, "Unable to decode response");                  goto out; @@ -3505,7 +3481,6 @@ gf_cli3_1_top_volume (call_frame_t *frame, xlator_t *this, void *data)          ret = cli_cmd_submit (&req, frame, cli_rpc_prog,                                GLUSTER_CLI_PROFILE_VOLUME, NULL, -                              gf_xdr_from_cli_stats_volume_req,                                this, gf_cli3_1_top_volume_cbk,                                (xdrproc_t) xdr_gf1_cli_stats_volume_req); @@ -3526,7 +3501,7 @@ gf_cli3_1_getwd_cbk (struct rpc_req *req, struct iovec *iov,                  goto out;          } -        ret = gf_xdr_to_cli_getwd_rsp (*iov, &rsp); +        ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_getwd_rsp);          if (ret < 0 || rsp.op_ret == -1) {                  gf_log ("", GF_LOG_ERROR, "error");                  goto out; @@ -3557,7 +3532,6 @@ gf_cli3_1_getwd (call_frame_t *frame, xlator_t *this, void *data)          ret = cli_cmd_submit (&req, frame, cli_rpc_prog,                                GLUSTER_CLI_GETWD, NULL, -                              gf_xdr_from_cli_getwd_req,                                this, gf_cli3_1_getwd_cbk,                                (xdrproc_t) xdr_gf1_cli_getwd_req); @@ -3588,7 +3562,7 @@ gf_cli3_1_status_cbk (struct rpc_req *req, struct iovec *iov,          if (req->rpc_status == -1)                  goto out; -        ret = gf_xdr_to_cli_status_volume_rsp (*iov, &rsp); +        ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf1_cli_status_volume_rsp);          if (ret < 0) {                  gf_log ("cli", GF_LOG_ERROR, "Volume status response error");                  goto out; @@ -3683,7 +3657,6 @@ gf_cli3_1_status_volume (call_frame_t *frame, xlator_t *this,          ret = cli_cmd_submit (&req, frame, cli_rpc_prog,                                GLUSTER_CLI_STATUS_VOLUME, NULL, -                              gf_xdr_from_cli_status_volume_req,                                this, gf_cli3_1_status_cbk,                                (xdrproc_t)xdr_gf1_cli_status_volume_req); diff --git a/cli/src/cli.c b/cli/src/cli.c index eec14d6fad0..51270f8a00a 100644 --- a/cli/src/cli.c +++ b/cli/src/cli.c @@ -74,6 +74,8 @@  #include "call-stub.h"  #include <fnmatch.h> +#include "xdr-generic.h" +  extern int connected;  /* using argp for command line parsing */  static char gf_doc[] = ""; @@ -265,8 +267,7 @@ int  cli_submit_request (void *req, call_frame_t *frame,                      rpc_clnt_prog_t *prog,                      int procnum, struct iobref *iobref, -                    cli_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;          int                     count      = 0; @@ -278,30 +279,30 @@ cli_submit_request (void *req, call_frame_t *frame,          GF_ASSERT (this); -        xdr_size = xdr_sizeof (xdrproc, req); -        iobuf = iobuf_get2 (this->ctx->iobuf_pool, xdr_size); -        if (!iobuf) { -                goto out; -        }; +        if (req) { +                xdr_size = xdr_sizeof (xdrproc, req); +                iobuf = iobuf_get2 (this->ctx->iobuf_pool, xdr_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_size (iobuf); +                iov.iov_base = iobuf->ptr; +                iov.iov_len  = iobuf_size (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;                  } diff --git a/cli/src/cli.h b/cli/src/cli.h index 55d0d89f1d0..b8db0bec840 100644 --- a/cli/src/cli.h +++ b/cli/src/cli.h @@ -184,8 +184,7 @@ int  cli_submit_request (void *req, call_frame_t *frame,                      rpc_clnt_prog_t *prog,                      int procnum, struct iobref *iobref, -                    cli_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  cli_cmd_volume_create_parse (const char **words, int wordcount,  | 
