Patchwork rpc: cleanup the way rpc procedure counts are handled in cli/glusterd

login
register
Submitter Amar Tumballi
Date 2011-01-14 06:26:07
Message ID <AANLkTikH9dCF5pyhqvsZG3tqdMYRt3ZfcmusmGOAwo3t@mail.gmail.com>
Download mbox | patch
Permalink /patch/5985/
State RFC
Headers show

Comments

Amar Tumballi - 2011-01-14 06:26:07
Even the attached small patch can fix the issues..

Regards,
Amar

On Fri, Jan 14, 2011 at 11:46 AM, Amar Tumballi <amar@gluster.com> wrote:

> the main purpose of this patch is to separate out enum of 'GD_MGMT'
> procedures,
> and 'GF_CLI' procedures. In the codebase the enums are having a tight bond
> as
> GF_CLI_* starts from GD_MGMT_MAXVALUE+1, which is not proper as if someone
> adds
> a field to GD_MGMT_* it will alter the value of GF_CLI_* too.
>
> This is just the first effort of cleaning up the way its done now in cli
> and
> glusterd. Meantime I am coming out with RPC Howto document/guidelines,
> which
> should help devlopers to decide upon versioning for new RPC procedures.
>
> Pranith/Shishir, your profile implementation will change a bit in RPC
> layer,
> as you may have to rebase with this release
>
>
>
> Signed-off-by: Amar Tumballi <amar@gluster.com>
> ---
>  cli/src/cli-cmd-peer.c                       |    6 +-
>  cli/src/cli-cmd-system.c                     |    6 +-
>  cli/src/cli-cmd-volume.c                     |   36 ++++++------
>  cli/src/cli.c                                |    3 +-
>  cli/src/cli3_1-cops.c                        |   75
> +++++++++++++++++++-------
>  rpc/rpc-lib/src/protocol-common.h            |   68
> +++++++++++++++++++++++
>  xlators/mgmt/glusterd/src/glusterd.c         |   11 ++++
>  xlators/mgmt/glusterd/src/glusterd3_1-mops.c |   64 ++++++++++++++++++++++
>  8 files changed, 224 insertions(+), 45 deletions(-)
>
> diff --git a/cli/src/cli-cmd-peer.c b/cli/src/cli-cmd-peer.c
> index ca89592..5c082a5 100644
> --- a/cli/src/cli-cmd-peer.c
> +++ b/cli/src/cli-cmd-peer.c
> @@ -57,7 +57,7 @@ cli_cmd_peer_probe_cbk (struct cli_state *state, struct
> cli_cmd_word *word,
>                 goto out;
>         }
>
> -        proc = &cli_rpc_prog->proctable[GF1_CLI_PROBE];
> +        proc = &cli_rpc_prog->proctable[GF2_CLI_PROBE];
>
>         frame = create_frame (THIS, THIS->ctx->pool);
>         if (!frame)
> @@ -108,7 +108,7 @@ cli_cmd_peer_deprobe_cbk (struct cli_state *state,
> struct cli_cmd_word *word,
>                 goto out;
>         }
>
> -        proc = &cli_rpc_prog->proctable[GF1_CLI_DEPROBE];
> +        proc = &cli_rpc_prog->proctable[GF2_CLI_DEPROBE];
>
>         frame = create_frame (THIS, THIS->ctx->pool);
>         if (!frame)
> @@ -156,7 +156,7 @@ cli_cmd_peer_status_cbk (struct cli_state *state,
> struct cli_cmd_word *word,
>                 goto out;
>         }
>
> -        proc = &cli_rpc_prog->proctable[GF1_CLI_LIST_FRIENDS];
> +        proc = &cli_rpc_prog->proctable[GF2_CLI_LIST_FRIENDS];
>
>         frame = create_frame (THIS, THIS->ctx->pool);
>         if (!frame)
> diff --git a/cli/src/cli-cmd-system.c b/cli/src/cli-cmd-system.c
> index e92376c..36580cb 100644
> --- a/cli/src/cli-cmd-system.c
> +++ b/cli/src/cli-cmd-system.c
> @@ -69,7 +69,7 @@ cli_cmd_getspec_cbk (struct cli_state *state, struct
> cli_cmd_word *word,
>         if (ret)
>                 goto out;
>
> -        proc = &cli_rpc_prog->proctable[GF1_CLI_GETSPEC];
> +        proc = &cli_rpc_prog->proctable[GF2_CLI_GETSPEC];
>         if (proc->fn) {
>                 ret = proc->fn (frame, THIS, dict);
>         }
> @@ -112,7 +112,7 @@ cli_cmd_pmap_b2p_cbk (struct cli_state *state, struct
> cli_cmd_word *word,
>         if (ret)
>                 goto out;
>
> -        proc = &cli_rpc_prog->proctable[GF1_CLI_PMAP_PORTBYBRICK];
> +        proc = &cli_rpc_prog->proctable[GF2_CLI_PMAP_PORTBYBRICK];
>         if (proc->fn) {
>                 ret = proc->fn (frame, THIS, dict);
>         }
> @@ -145,7 +145,7 @@ cli_cmd_fsm_log (struct cli_state *state, struct
> cli_cmd_word *word,
>
>         if (wordcount == 3)
>                 name = (char*)words[2];
> -        proc = &cli_rpc_prog->proctable[GF1_CLI_FSM_LOG];
> +        proc = &cli_rpc_prog->proctable[GF2_CLI_FSM_LOG];
>         if (proc && proc->fn) {
>                 frame = create_frame (THIS, THIS->ctx->pool);
>                 if (!frame)
> diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
> index 0b6e2dd..8beebd1 100644
> --- a/cli/src/cli-cmd-volume.c
> +++ b/cli/src/cli-cmd-volume.c
> @@ -53,7 +53,7 @@ cli_cmd_volume_info_cbk (struct cli_state *state, struct
> cli_cmd_word *word,
>         int                             sent = 0;
>         int                             parse_error = 0;
>
> -        proc = &cli_rpc_prog->proctable[GF1_CLI_GET_VOLUME];
> +        proc = &cli_rpc_prog->proctable[GF2_CLI_GET_VOLUME];
>
>         frame = create_frame (THIS, THIS->ctx->pool);
>         if (!frame)
> @@ -62,7 +62,7 @@ cli_cmd_volume_info_cbk (struct cli_state *state, struct
> cli_cmd_word *word,
>         if ((wordcount == 2)  || (wordcount == 3 &&
>                                   !strcmp (words[2], "all"))) {
>                 ctx.flags = GF_CLI_GET_NEXT_VOLUME;
> -                proc = &cli_rpc_prog->proctable[GF1_CLI_GET_NEXT_VOLUME];
> +                proc = &cli_rpc_prog->proctable[GF2_CLI_GET_NEXT_VOLUME];
>         } else if (wordcount == 3) {
>                 ctx.flags = GF_CLI_GET_VOLUME;
>                 ctx.volname = (char *)words[2];
> @@ -70,7 +70,7 @@ cli_cmd_volume_info_cbk (struct cli_state *state, struct
> cli_cmd_word *word,
>                         cli_out ("Invalid volume name");
>                         goto out;
>                 }
> -                proc = &cli_rpc_prog->proctable[GF1_CLI_GET_VOLUME];
> +                proc = &cli_rpc_prog->proctable[GF2_CLI_GET_VOLUME];
>         } else {
>                 cli_usage_out (word->pattern);
>                 parse_error = 1;
> @@ -129,7 +129,7 @@ cli_cmd_sync_volume_cbk (struct cli_state *state,
> struct cli_cmd_word *word,
>
>         req.hostname = (char *)words[2];
>
> -        proc = &cli_rpc_prog->proctable[GF1_CLI_SYNC_VOLUME];
> +        proc = &cli_rpc_prog->proctable[GF2_CLI_SYNC_VOLUME];
>
>         frame = create_frame (THIS, THIS->ctx->pool);
>         if (!frame)
> @@ -160,7 +160,7 @@ cli_cmd_volume_create_cbk (struct cli_state *state,
> struct cli_cmd_word *word,
>         int                     sent = 0;
>         int                     parse_error = 0;
>
> -        proc = &cli_rpc_prog->proctable[GF1_CLI_CREATE_VOLUME];
> +        proc = &cli_rpc_prog->proctable[GF2_CLI_CREATE_VOLUME];
>
>         frame = create_frame (THIS, THIS->ctx->pool);
>         if (!frame)
> @@ -206,7 +206,7 @@ cli_cmd_volume_delete_cbk (struct cli_state *state,
> struct cli_cmd_word *word,
>
>         question = "Deleting volume will erase all information about the
> volume."
>                    "Do you want to continue?";
> -        proc = &cli_rpc_prog->proctable[GF1_CLI_DELETE_VOLUME];
> +        proc = &cli_rpc_prog->proctable[GF2_CLI_DELETE_VOLUME];
>
>         frame = create_frame (THIS, THIS->ctx->pool);
>         if (!frame)
> @@ -277,7 +277,7 @@ cli_cmd_volume_start_cbk (struct cli_state *state,
> struct cli_cmd_word *word,
>                 }
>         }
>
> -        proc = &cli_rpc_prog->proctable[GF1_CLI_START_VOLUME];
> +        proc = &cli_rpc_prog->proctable[GF2_CLI_START_VOLUME];
>
>         if (proc->fn) {
>                 ret = proc->fn (frame, THIS, &req);
> @@ -381,7 +381,7 @@ cli_cmd_volume_stop_cbk (struct cli_state *state,
> struct cli_cmd_word *word,
>         }
>
>         req.flags = flags;
> -        proc = &cli_rpc_prog->proctable[GF1_CLI_STOP_VOLUME];
> +        proc = &cli_rpc_prog->proctable[GF2_CLI_STOP_VOLUME];
>
>         if (proc->fn) {
>                 ret = proc->fn (frame, THIS, &req);
> @@ -434,7 +434,7 @@ cli_cmd_volume_rename_cbk (struct cli_state *state,
> struct cli_cmd_word *word,
>         if (ret)
>                 goto out;
>
> -        proc = &cli_rpc_prog->proctable[GF1_CLI_RENAME_VOLUME];
> +        proc = &cli_rpc_prog->proctable[GF2_CLI_RENAME_VOLUME];
>
>         if (proc->fn) {
>                 ret = proc->fn (frame, THIS, dict);
> @@ -486,7 +486,7 @@ cli_cmd_volume_defrag_cbk (struct cli_state *state,
> struct cli_cmd_word *word,
>         if (ret)
>                 goto out;
>
> -        proc = &cli_rpc_prog->proctable[GF1_CLI_DEFRAG_VOLUME];
> +        proc = &cli_rpc_prog->proctable[GF2_CLI_DEFRAG_VOLUME];
>
>         if (proc->fn) {
>                 ret = proc->fn (frame, THIS, dict);
> @@ -517,7 +517,7 @@ cli_cmd_volume_reset_cbk (struct cli_state *state,
> struct cli_cmd_word *word,
>         call_frame_t            *frame = NULL;
>         dict_t                  *options = NULL;
>
> -        proc = &cli_rpc_prog->proctable[GF1_CLI_RESET_VOLUME];
> +        proc = &cli_rpc_prog->proctable[GF2_CLI_RESET_VOLUME];
>
>         frame = create_frame (THIS, THIS->ctx->pool);
>         if (!frame)
> @@ -562,7 +562,7 @@ cli_cmd_volume_set_cbk (struct cli_state *state, struct
> cli_cmd_word *word,
>         call_frame_t            *frame = NULL;
>         dict_t                  *options = NULL;
>
> -        proc = &cli_rpc_prog->proctable[GF1_CLI_SET_VOLUME];
> +        proc = &cli_rpc_prog->proctable[GF2_CLI_SET_VOLUME];
>
>         frame = create_frame (THIS, THIS->ctx->pool);
>         if (!frame)
> @@ -618,7 +618,7 @@ cli_cmd_volume_add_brick_cbk (struct cli_state *state,
>                 goto out;
>         }
>
> -        proc = &cli_rpc_prog->proctable[GF1_CLI_ADD_BRICK];
> +        proc = &cli_rpc_prog->proctable[GF2_CLI_ADD_BRICK];
>
>         if (proc->fn) {
>                 ret = proc->fn (frame, THIS, options);
> @@ -673,7 +673,7 @@ cli_cmd_volume_remove_brick_cbk (struct cli_state
> *state,
>                 goto out;
>         }
>
> -        proc = &cli_rpc_prog->proctable[GF1_CLI_REMOVE_BRICK];
> +        proc = &cli_rpc_prog->proctable[GF2_CLI_REMOVE_BRICK];
>
>         if (proc->fn) {
>                 ret = proc->fn (frame, THIS, options);
> @@ -705,7 +705,7 @@ cli_cmd_volume_replace_brick_cbk (struct cli_state
> *state,
>         int                     sent = 0;
>         int                     parse_error = 0;
>
> -        proc = &cli_rpc_prog->proctable[GF1_CLI_REPLACE_BRICK];
> +        proc = &cli_rpc_prog->proctable[GF2_CLI_REPLACE_BRICK];
>
>         frame = create_frame (THIS, THIS->ctx->pool);
>         if (!frame)
> @@ -763,7 +763,7 @@ cli_cmd_log_filename_cbk (struct cli_state *state,
> struct cli_cmd_word *word,
>                 goto out;
>         }
>
> -        proc = &cli_rpc_prog->proctable[GF1_CLI_LOG_FILENAME];
> +        proc = &cli_rpc_prog->proctable[GF2_CLI_LOG_FILENAME];
>
>         frame = create_frame (THIS, THIS->ctx->pool);
>         if (!frame)
> @@ -808,7 +808,7 @@ cli_cmd_log_locate_cbk (struct cli_state *state, struct
> cli_cmd_word *word,
>                 goto out;
>         }
>
> -        proc = &cli_rpc_prog->proctable[GF1_CLI_LOG_LOCATE];
> +        proc = &cli_rpc_prog->proctable[GF2_CLI_LOG_LOCATE];
>
>         frame = create_frame (THIS, THIS->ctx->pool);
>         if (!frame)
> @@ -852,7 +852,7 @@ cli_cmd_log_rotate_cbk (struct cli_state *state, struct
> cli_cmd_word *word,
>                 goto out;
>         }
>
> -        proc = &cli_rpc_prog->proctable[GF1_CLI_LOG_ROTATE];
> +        proc = &cli_rpc_prog->proctable[GF2_CLI_LOG_ROTATE];
>
>         frame = create_frame (THIS, THIS->ctx->pool);
>         if (!frame)
> diff --git a/cli/src/cli.c b/cli/src/cli.c
> index 075b7f4..4464617 100644
> --- a/cli/src/cli.c
> +++ b/cli/src/cli.c
> @@ -102,6 +102,7 @@ rpc_clnt_prog_t *cli_rpc_prog;
>
>
>  extern struct rpc_clnt_program cli3_1_prog;
> +extern struct rpc_clnt_program cli3_1_prog2;
>
>  static error_t
>  parse_opts (int key, char *arg, struct argp_state *argp_state)
> @@ -499,7 +500,7 @@ cli_rpc_init (struct cli_state *state)
>
>
>         this = THIS;
> -        cli_rpc_prog = &cli3_1_prog;
> +        cli_rpc_prog = &cli3_1_prog2;
>         options = dict_new ();
>         if (!options)
>                 goto out;
> diff --git a/cli/src/cli3_1-cops.c b/cli/src/cli3_1-cops.c
> index 3003469..6bee9f9 100644
> --- a/cli/src/cli3_1-cops.c
> +++ b/cli/src/cli3_1-cops.c
> @@ -1407,7 +1407,7 @@ gf_cli3_1_probe (call_frame_t *frame, xlator_t *this,
>         req.port     = port;
>
>         ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
> -                              GD_MGMT_CLI_PROBE, NULL,
> gf_xdr_from_cli_probe_req,
> +                              GD2_MGMT_CLI_PROBE, NULL,
> gf_xdr_from_cli_probe_req,
>                               this, gf_cli3_1_probe_cbk);
>
>  out:
> @@ -1443,7 +1443,7 @@ gf_cli3_1_deprobe (call_frame_t *frame, xlator_t
> *this,
>         req.port     = port;
>
>         ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
> -                              GD_MGMT_CLI_DEPROBE, NULL,
> +                              GD2_MGMT_CLI_DEPROBE, NULL,
>                               gf_xdr_from_cli_deprobe_req,
>                               this, gf_cli3_1_deprobe_cbk);
>
> @@ -1467,7 +1467,7 @@ gf_cli3_1_list_friends (call_frame_t *frame, xlator_t
> *this,
>         req.flags = GF_CLI_LIST_ALL;
>
>         ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
> -                              GD_MGMT_CLI_LIST_FRIENDS, NULL,
> +                              GD2_MGMT_CLI_LIST_FRIENDS, NULL,
>                               gf_xdr_from_cli_peer_list_req,
>                               this, gf_cli3_1_list_friends_cbk);
>
> @@ -1546,7 +1546,7 @@ gf_cli3_1_get_volume (call_frame_t *frame, xlator_t
> *this,
>                                            (size_t *)&req.dict.dict_len);
>
>         ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
> -                              GD_MGMT_CLI_GET_VOLUME, NULL,
> +                              GD2_MGMT_CLI_GET_VOLUME, NULL,
>                               gf_xdr_from_cli_get_vol_req,
>                               this, gf_cli3_1_get_volume_cbk);
>
> @@ -1603,7 +1603,7 @@ gf_cli3_1_create_volume (call_frame_t *frame,
> xlator_t *this,
>         }
>
>         ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
> -                              GD_MGMT_CLI_CREATE_VOLUME, NULL,
> +                              GD2_MGMT_CLI_CREATE_VOLUME, NULL,
>                               gf_xdr_from_cli_create_vol_req,
>                               this, gf_cli3_1_create_volume_cbk);
>
> @@ -1645,7 +1645,7 @@ gf_cli3_1_delete_volume (call_frame_t *frame,
> xlator_t *this,
>         req.volname = data;
>
>         ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
> -                              GD_MGMT_CLI_DELETE_VOLUME, NULL,
> +                              GD2_MGMT_CLI_DELETE_VOLUME, NULL,
>                               gf_xdr_from_cli_delete_vol_req,
>                               this, gf_cli3_1_delete_volume_cbk);
>
> @@ -1678,7 +1678,7 @@ gf_cli3_1_start_volume (call_frame_t *frame, xlator_t
> *this,
>         }
>
>         ret = cli_cmd_submit (req, frame, cli_rpc_prog,
> -                              GD_MGMT_CLI_START_VOLUME, NULL,
> +                              GD2_MGMT_CLI_START_VOLUME, NULL,
>                               gf_xdr_from_cli_start_vol_req,
>                               this, gf_cli3_1_start_volume_cbk);
>
> @@ -1711,7 +1711,7 @@ gf_cli3_1_stop_volume (call_frame_t *frame, xlator_t
> *this,
>         }
>
>         ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
> -                              GD_MGMT_CLI_STOP_VOLUME, NULL,
> +                              GD2_MGMT_CLI_STOP_VOLUME, NULL,
>                               gf_xdr_from_cli_stop_vol_req,
>                               this, gf_cli3_1_stop_volume_cbk);
>
> @@ -1769,7 +1769,7 @@ gf_cli3_1_defrag_volume (call_frame_t *frame,
> xlator_t *this,
>         req.volname = volname;
>
>         ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
> -                              GD_MGMT_CLI_DEFRAG_VOLUME, NULL,
> +                              GD2_MGMT_CLI_DEFRAG_VOLUME, NULL,
>                               gf_xdr_from_cli_defrag_vol_req,
>                               this, gf_cli3_1_defrag_volume_cbk);
>
> @@ -1805,7 +1805,7 @@ gf_cli3_1_rename_volume (call_frame_t *frame,
> xlator_t *this,
>                 goto out;
>
>         ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
> -                              GD_MGMT_CLI_RENAME_VOLUME, NULL,
> +                              GD2_MGMT_CLI_RENAME_VOLUME, NULL,
>                               gf_xdr_from_cli_rename_vol_req,
>                               this, gf_cli3_1_rename_volume_cbk);
>
> @@ -1846,7 +1846,7 @@ gf_cli3_1_reset_volume (call_frame_t *frame, xlator_t
> *this,
>
>
>         ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
> -                               GD_MGMT_CLI_RESET_VOLUME, NULL,
> +                               GD2_MGMT_CLI_RESET_VOLUME, NULL,
>                                gf_xdr_from_cli_reset_vol_req,
>                                this, gf_cli3_1_reset_volume_cbk);
>
> @@ -1887,7 +1887,7 @@ gf_cli3_1_set_volume (call_frame_t *frame, xlator_t
> *this,
>
>
>         ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
> -                              GD_MGMT_CLI_SET_VOLUME, NULL,
> +                              GD2_MGMT_CLI_SET_VOLUME, NULL,
>                               gf_xdr_from_cli_set_vol_req,
>                               this, gf_cli3_1_set_volume_cbk);
>
> @@ -1932,7 +1932,7 @@ gf_cli3_1_add_brick (call_frame_t *frame, xlator_t
> *this,
>         }
>
>         ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
> -                              GD_MGMT_CLI_ADD_BRICK, NULL,
> +                              GD2_MGMT_CLI_ADD_BRICK, NULL,
>                               gf_xdr_from_cli_add_brick_req,
>                               this, gf_cli3_1_add_brick_cbk);
>
> @@ -1981,7 +1981,7 @@ gf_cli3_1_remove_brick (call_frame_t *frame, xlator_t
> *this,
>         }
>
>         ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
> -                              GD_MGMT_CLI_REMOVE_BRICK, NULL,
> +                              GD2_MGMT_CLI_REMOVE_BRICK, NULL,
>                               gf_xdr_from_cli_remove_brick_req,
>                               this, gf_cli3_1_remove_brick_cbk);
>
> @@ -2076,7 +2076,7 @@ gf_cli3_1_replace_brick (call_frame_t *frame,
> xlator_t *this,
>         }
>
>         ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
> -                              GD_MGMT_CLI_REPLACE_BRICK, NULL,
> +                              GD2_MGMT_CLI_REPLACE_BRICK, NULL,
>                               gf_xdr_from_cli_replace_brick_req,
>                               this, gf_cli3_1_replace_brick_cbk);
>
> @@ -2118,7 +2118,7 @@ gf_cli3_1_log_filename (call_frame_t *frame, xlator_t
> *this,
>                 goto out;
>
>         ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
> -                              GD_MGMT_CLI_LOG_FILENAME, NULL,
> +                              GD2_MGMT_CLI_LOG_FILENAME, NULL,
>                               gf_xdr_from_cli_log_filename_req,
>                               this, gf_cli3_1_log_filename_cbk);
>
> @@ -2153,7 +2153,7 @@ gf_cli3_1_log_locate (call_frame_t *frame, xlator_t
> *this,
>                 req.brick = "";
>
>         ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
> -                              GD_MGMT_CLI_LOG_LOCATE, NULL,
> +                              GD2_MGMT_CLI_LOG_LOCATE, NULL,
>                               gf_xdr_from_cli_log_locate_req,
>                               this, gf_cli3_1_log_locate_cbk);
>
> @@ -2187,7 +2187,7 @@ gf_cli3_1_log_rotate (call_frame_t *frame, xlator_t
> *this,
>                 req.brick = "";
>
>         ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
> -                              GD_MGMT_CLI_LOG_ROTATE, NULL,
> +                              GD2_MGMT_CLI_LOG_ROTATE, NULL,
>                               gf_xdr_from_cli_log_rotate_req,
>                               this, gf_cli3_1_log_rotate_cbk);
>
> @@ -2210,7 +2210,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, GD_MGMT_CLI_SYNC_VOLUME,
> +                              cli_rpc_prog, GD2_MGMT_CLI_SYNC_VOLUME,
>                               NULL, gf_xdr_from_cli_sync_volume_req,
>                               this, gf_cli3_1_sync_volume_cbk);
>
> @@ -2385,7 +2385,7 @@ gf_cli3_1_fsm_log (call_frame_t *frame, xlator_t
> *this, void *data)
>                 goto out;
>         req.name = data;
>         ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
> -                              GD_MGMT_CLI_FSM_LOG, NULL,
> +                              GD2_MGMT_CLI_FSM_LOG, NULL,
>                               gf_xdr_from_cli_fsm_log_req,
>                               this, gf_cli3_1_fsm_log_cbk);
>
> @@ -2429,3 +2429,38 @@ struct rpc_clnt_program cli3_1_prog = {
>         .proctable  = gluster3_1_cli_actors,
>         .numproc  = GLUSTER3_1_CLI_PROCCNT,
>  };
> +
> +struct rpc_clnt_procedure gluster3_1_cli2_actors[GF2_CLI_MAXVALUE] = {
> +        [GF2_CLI_NULL]        = {"NULL", NULL },
> +        [GF2_CLI_PROBE]  = { "PROBE_QUERY",  gf_cli3_1_probe},
> +        [GF2_CLI_DEPROBE]  = { "DEPROBE_QUERY",  gf_cli3_1_deprobe},
> +        [GF2_CLI_LIST_FRIENDS]  = { "LIST_FRIENDS",
>  gf_cli3_1_list_friends},
> +        [GF2_CLI_CREATE_VOLUME] = {"CREATE_VOLUME",
> gf_cli3_1_create_volume},
> +        [GF2_CLI_DELETE_VOLUME] = {"DELETE_VOLUME",
> gf_cli3_1_delete_volume},
> +        [GF2_CLI_START_VOLUME] = {"START_VOLUME", gf_cli3_1_start_volume},
> +        [GF2_CLI_STOP_VOLUME] = {"STOP_VOLUME", gf_cli3_1_stop_volume},
> +        [GF2_CLI_RENAME_VOLUME] = {"RENAME_VOLUME",
> gf_cli3_1_rename_volume},
> +        [GF2_CLI_DEFRAG_VOLUME] = {"DEFRAG_VOLUME",
> gf_cli3_1_defrag_volume},
> +        [GF2_CLI_GET_VOLUME] = {"GET_VOLUME", gf_cli3_1_get_volume},
> +        [GF2_CLI_GET_NEXT_VOLUME] = {"GET_NEXT_VOLUME",
> gf_cli3_1_get_next_volume},
> +        [GF2_CLI_SET_VOLUME] = {"SET_VOLUME", gf_cli3_1_set_volume},
> +        [GF2_CLI_ADD_BRICK] = {"ADD_BRICK", gf_cli3_1_add_brick},
> +        [GF2_CLI_REMOVE_BRICK] = {"REMOVE_BRICK", gf_cli3_1_remove_brick},
> +        [GF2_CLI_REPLACE_BRICK] = {"REPLACE_BRICK",
> gf_cli3_1_replace_brick},
> +        [GF2_CLI_LOG_FILENAME] = {"LOG FILENAME", gf_cli3_1_log_filename},
> +        [GF2_CLI_LOG_LOCATE] = {"LOG LOCATE", gf_cli3_1_log_locate},
> +        [GF2_CLI_LOG_ROTATE] = {"LOG ROTATE", gf_cli3_1_log_rotate},
> +        [GF2_CLI_GETSPEC] = {"GETSPEC", gf_cli3_1_getspec},
> +        [GF2_CLI_PMAP_PORTBYBRICK] = {"PMAP PORTBYBRICK",
> gf_cli3_1_pmap_b2p},
> +        [GF2_CLI_SYNC_VOLUME] = {"SYNC_VOLUME", gf_cli3_1_sync_volume},
> +        [GF2_CLI_RESET_VOLUME] = {"RESET_VOLUME", gf_cli3_1_reset_volume},
> +        [GF2_CLI_FSM_LOG] = {"FSM_LOG", gf_cli3_1_fsm_log}
> +};
> +
> +struct rpc_clnt_program cli3_1_prog2 = {
> +        .progname = "CLI 3.1 - v2",
> +        .prognum  = GLUSTERD2_MGMT_PROGRAM,
> +        .progver  = GLUSTERD2_MGMT_VERSION,
> +        .proctable  = gluster3_1_cli2_actors,
> +        .numproc  = GLUSTERD2_MGMT_PROCCNT,
> +};
> diff --git a/rpc/rpc-lib/src/protocol-common.h
> b/rpc/rpc-lib/src/protocol-common.h
> index 2fe7040..3e176b3 100644
> --- a/rpc/rpc-lib/src/protocol-common.h
> +++ b/rpc/rpc-lib/src/protocol-common.h
> @@ -138,6 +138,66 @@ enum gf_cli_procnum {
>         GF1_CLI_MAXVALUE,
>  };
>
> +enum gf_mgmt2_procnum_ {
> +        GD2_MGMT_NULL,    /* 0 */
> +        GD2_MGMT_PROBE_QUERY,
> +        GD2_MGMT_FRIEND_ADD,
> +        GD2_MGMT_CLUSTER_LOCK,
> +        GD2_MGMT_CLUSTER_UNLOCK,
> +        GD2_MGMT_STAGE_OP,
> +        GD2_MGMT_COMMIT_OP,
> +        GD2_MGMT_FRIEND_REMOVE,
> +        GD2_MGMT_FRIEND_UPDATE,
> +        GD2_MGMT_CLI_PROBE,
> +        GD2_MGMT_CLI_DEPROBE,
> +        GD2_MGMT_CLI_LIST_FRIENDS,
> +        GD2_MGMT_CLI_CREATE_VOLUME,
> +        GD2_MGMT_CLI_GET_VOLUME,
> +        GD2_MGMT_CLI_DELETE_VOLUME,
> +        GD2_MGMT_CLI_START_VOLUME,
> +        GD2_MGMT_CLI_STOP_VOLUME,
> +        GD2_MGMT_CLI_RENAME_VOLUME,
> +        GD2_MGMT_CLI_DEFRAG_VOLUME,
> +        GD2_MGMT_CLI_SET_VOLUME,
> +        GD2_MGMT_CLI_ADD_BRICK,
> +        GD2_MGMT_CLI_REMOVE_BRICK,
> +        GD2_MGMT_CLI_REPLACE_BRICK,
> +        GD2_MGMT_CLI_LOG_FILENAME,
> +        GD2_MGMT_CLI_LOG_LOCATE,
> +        GD2_MGMT_CLI_LOG_ROTATE,
> +        GD2_MGMT_CLI_SYNC_VOLUME,
> +        GD2_MGMT_CLI_RESET_VOLUME,
> +        GD2_MGMT_CLI_FSM_LOG,
> +        GD2_MGMT_MAXVALUE,
> +};
> +
> +enum gf_cli2_procnum {
> +        GF2_CLI_NULL,    /* 0 */
> +        GF2_CLI_PROBE,
> +        GF2_CLI_DEPROBE,
> +        GF2_CLI_LIST_FRIENDS,
> +        GF2_CLI_CREATE_VOLUME,
> +        GF2_CLI_GET_VOLUME,
> +        GF2_CLI_GET_NEXT_VOLUME,
> +        GF2_CLI_DELETE_VOLUME,
> +        GF2_CLI_START_VOLUME,
> +        GF2_CLI_STOP_VOLUME,
> +        GF2_CLI_RENAME_VOLUME,
> +        GF2_CLI_DEFRAG_VOLUME,
> +        GF2_CLI_SET_VOLUME,
> +        GF2_CLI_ADD_BRICK,
> +        GF2_CLI_REMOVE_BRICK,
> +        GF2_CLI_REPLACE_BRICK,
> +        GF2_CLI_LOG_FILENAME,
> +        GF2_CLI_LOG_LOCATE,
> +        GF2_CLI_LOG_ROTATE,
> +        GF2_CLI_GETSPEC,
> +        GF2_CLI_PMAP_PORTBYBRICK,
> +        GF2_CLI_SYNC_VOLUME,
> +        GF2_CLI_RESET_VOLUME,
> +        GF2_CLI_FSM_LOG,
> +        GF2_CLI_MAXVALUE,
> +};
>
>  enum gf_pmap_procnum {
>         GF_PMAP_NULL = 0,
> @@ -194,6 +254,14 @@ enum gf_cbk_procnum {
>  #define GLUSTER3_1_CLI_VERSION   1   /* 0.0.1 */
>  #define GLUSTER3_1_CLI_PROCCNT   GF1_CLI_MAXVALUE
>
> +#define GLUSTERD2_MGMT_PROGRAM   1298433 /* Completely random */
> +#define GLUSTERD2_MGMT_VERSION   2   /* 0.0.1 */
> +#define GLUSTERD2_MGMT_PROCCNT   GD2_MGMT_MAXVALUE
> +
> +#define GLUSTER3_1_CLI2_PROGRAM   1298434 /* Completely random */
> +#define GLUSTER3_1_CLI2_VERSION   2   /* 0.0.1 */
> +#define GLUSTER3_1_CLI2_PROCCNT   GF2_CLI_MAXVALUE
> +
>  #define GLUSTER_HNDSK_PROGRAM    14398633 /* Completely random */
>  #define GLUSTER_HNDSK_VERSION    1   /* 0.0.1 */
>
> diff --git a/xlators/mgmt/glusterd/src/glusterd.c
> b/xlators/mgmt/glusterd/src/glusterd.c
> index a018966..449d69d 100644
> --- a/xlators/mgmt/glusterd/src/glusterd.c
> +++ b/xlators/mgmt/glusterd/src/glusterd.c
> @@ -52,6 +52,9 @@ extern struct rpc_clnt_program glusterd3_1_mgmt_prog;
>  extern struct rpcsvc_program gluster_pmap_prog;
>  extern glusterd_op_info_t opinfo;
>
> +extern struct rpcsvc_program glusterd2_mop_prog;
> +extern struct rpc_clnt_program glusterd3_1_mgmt2_prog;
> +
>  rpcsvc_cbk_program_t glusterd_cbk_prog = {
>         .progname  = "Gluster Callback",
>         .prognum   = GLUSTER_CBK_PROGRAM,
> @@ -355,15 +358,23 @@ init (xlator_t *this)
>                 goto out;
>         }
>
> +        ret = glusterd_program_register (this, rpc, &glusterd2_mop_prog);
> +        if (ret) {
> +                rpcsvc_program_unregister (rpc, &glusterd1_mop_prog);
> +                goto out;
> +        }
> +
>         ret = glusterd_program_register (this, rpc, &gluster_pmap_prog);
>         if (ret) {
>                 rpcsvc_program_unregister (rpc, &glusterd1_mop_prog);
> +                rpcsvc_program_unregister (rpc, &glusterd2_mop_prog);
>                 goto out;
>         }
>
>         ret = glusterd_program_register (this, rpc,
> &gluster_handshake_prog);
>         if (ret) {
>                 rpcsvc_program_unregister (rpc, &glusterd1_mop_prog);
> +                rpcsvc_program_unregister (rpc, &glusterd2_mop_prog);
>                 rpcsvc_program_unregister (rpc, &gluster_handshake_prog);
>                 goto out;
>         }
> diff --git a/xlators/mgmt/glusterd/src/glusterd3_1-mops.c
> b/xlators/mgmt/glusterd/src/glusterd3_1-mops.c
> index b5ac571..0bb97e6 100644
> --- a/xlators/mgmt/glusterd/src/glusterd3_1-mops.c
> +++ b/xlators/mgmt/glusterd/src/glusterd3_1-mops.c
> @@ -1552,6 +1552,47 @@ struct rpcsvc_program glusterd1_mop_prog = {
>         .actors    = glusterd1_mgmt_actors,
>  };
>
> +rpcsvc_actor_t glusterd2_mgmt_actors[] = {
> +        [GD2_MGMT_NULL]        = { "NULL",       GD2_MGMT_NULL,
> glusterd_null, NULL, NULL},
> +        [GD2_MGMT_PROBE_QUERY] = { "PROBE_QUERY", GD2_MGMT_PROBE_QUERY,
> glusterd_handle_rpc_msg, NULL, NULL},
> +        [GD2_MGMT_FRIEND_ADD] = { "FRIEND_ADD", GD2_MGMT_FRIEND_ADD,
> glusterd_handle_rpc_msg, NULL, NULL},
> +        [GD2_MGMT_FRIEND_REMOVE] = { "FRIEND_REMOVE",
> GD2_MGMT_FRIEND_REMOVE, glusterd_handle_rpc_msg, NULL, NULL},
> +        [GD2_MGMT_FRIEND_UPDATE] = { "FRIEND_UPDATE",
> GD2_MGMT_FRIEND_UPDATE, glusterd_handle_rpc_msg, NULL, NULL},
> +        [GD2_MGMT_CLUSTER_LOCK] = { "CLUSTER_LOCK", GD2_MGMT_CLUSTER_LOCK,
> glusterd_handle_rpc_msg, NULL, NULL},
> +        [GD2_MGMT_CLUSTER_UNLOCK] = { "CLUSTER_UNLOCK",
> GD2_MGMT_CLUSTER_UNLOCK, glusterd_handle_rpc_msg, NULL, NULL},
> +        [GD2_MGMT_STAGE_OP] = { "STAGE_OP", GD2_MGMT_STAGE_OP,
> glusterd_handle_rpc_msg, NULL, NULL},
> +        [GD2_MGMT_COMMIT_OP] = { "COMMIT_OP", GD2_MGMT_COMMIT_OP,
> glusterd_handle_rpc_msg, NULL, NULL},
> +        [GD2_MGMT_CLI_PROBE] = { "CLI_PROBE", GD2_MGMT_CLI_PROBE,
> glusterd_handle_rpc_msg, NULL, NULL},
> +        [GD2_MGMT_CLI_CREATE_VOLUME] = { "CLI_CREATE_VOLUME",
> GD2_MGMT_CLI_CREATE_VOLUME, glusterd_handle_rpc_msg, NULL,NULL},
> +        [GD2_MGMT_CLI_DEFRAG_VOLUME] = { "CLI_DEFRAG_VOLUME",
> GD2_MGMT_CLI_DEFRAG_VOLUME, glusterd_handle_defrag_volume, NULL,NULL},
> +        [GD2_MGMT_CLI_DEPROBE] = { "FRIEND_REMOVE", GD2_MGMT_CLI_DEPROBE,
> glusterd_handle_rpc_msg, NULL, NULL},
> +        [GD2_MGMT_CLI_LIST_FRIENDS] = { "LIST_FRIENDS",
> GD2_MGMT_CLI_LIST_FRIENDS, glusterd_handle_rpc_msg, NULL, NULL},
> +        [GD2_MGMT_CLI_START_VOLUME] = { "START_VOLUME",
> GD2_MGMT_CLI_START_VOLUME, glusterd_handle_rpc_msg, NULL, NULL},
> +        [GD2_MGMT_CLI_STOP_VOLUME] = { "STOP_VOLUME",
> GD2_MGMT_CLI_STOP_VOLUME, glusterd_handle_rpc_msg, NULL, NULL},
> +        [GD2_MGMT_CLI_DELETE_VOLUME] = { "DELETE_VOLUME",
> GD2_MGMT_CLI_DELETE_VOLUME, glusterd_handle_rpc_msg, NULL, NULL},
> +        [GD2_MGMT_CLI_GET_VOLUME] = { "GET_VOLUME",
> GD2_MGMT_CLI_GET_VOLUME, glusterd_handle_rpc_msg, NULL, NULL},
> +        [GD2_MGMT_CLI_ADD_BRICK] = { "ADD_BRICK", GD2_MGMT_CLI_ADD_BRICK,
> glusterd_handle_rpc_msg, NULL, NULL},
> +        [GD2_MGMT_CLI_REPLACE_BRICK] = { "REPLACE_BRICK",
> GD2_MGMT_CLI_REPLACE_BRICK, glusterd_handle_rpc_msg, NULL, NULL},
> +        [GD2_MGMT_CLI_REMOVE_BRICK] = { "REMOVE_BRICK",
> GD2_MGMT_CLI_REMOVE_BRICK, glusterd_handle_rpc_msg, NULL, NULL},
> +        [GD2_MGMT_CLI_LOG_FILENAME] = { "LOG FILENAME",
> GD2_MGMT_CLI_LOG_FILENAME, glusterd_handle_rpc_msg, NULL, NULL},
> +        [GD2_MGMT_CLI_LOG_LOCATE] = { "LOG LOCATE",
> GD2_MGMT_CLI_LOG_LOCATE, glusterd_handle_log_locate, NULL, NULL},
> +        [GD2_MGMT_CLI_LOG_ROTATE] = { "LOG FILENAME",
> GD2_MGMT_CLI_LOG_ROTATE, glusterd_handle_rpc_msg, NULL, NULL},
> +        [GD2_MGMT_CLI_SET_VOLUME] = { "SET_VOLUME",
> GD2_MGMT_CLI_SET_VOLUME, glusterd_handle_rpc_msg, NULL, NULL},
> +        [GD2_MGMT_CLI_SYNC_VOLUME] = { "SYNC_VOLUME",
> GD2_MGMT_CLI_SYNC_VOLUME, glusterd_handle_rpc_msg, NULL, NULL},
> +        [GD2_MGMT_CLI_RESET_VOLUME] = { "RESET_VOLUME",
> GD2_MGMT_CLI_RESET_VOLUME, glusterd_handle_rpc_msg, NULL, NULL},
> +        [GD2_MGMT_CLI_FSM_LOG] = { "FSM_LOG", GD2_MGMT_CLI_FSM_LOG,
> glusterd_handle_rpc_msg, NULL, NULL}
> +};
> +
> +
> +struct rpcsvc_program glusterd2_mop_prog = {
> +        .progname  = "GlusterD0.0.2",
> +        .prognum   = GLUSTERD2_MGMT_PROGRAM,
> +        .progver   = GLUSTERD2_MGMT_VERSION,
> +        .numactors = GLUSTERD2_MGMT_PROCCNT,
> +        .actors    = glusterd2_mgmt_actors,
> +};
> +
> +
>
>  struct rpc_clnt_procedure glusterd3_1_clnt_mgmt_actors[GD_MGMT_MAXVALUE] =
> {
>         [GD_MGMT_NULL]        = {"NULL", NULL },
> @@ -1574,3 +1615,26 @@ struct rpc_clnt_program glusterd3_1_mgmt_prog = {
>         .proctable    = glusterd3_1_clnt_mgmt_actors,
>         .numproc  = GLUSTERD1_MGMT_PROCCNT,
>  };
> +
> +
> +struct rpc_clnt_procedure glusterd3_1_clnt2_mgmt_actors[GD2_MGMT_MAXVALUE]
> = {
> +        [GD2_MGMT_NULL]        = {"NULL", NULL },
> +        [GD2_MGMT_PROBE_QUERY]  = { "PROBE_QUERY",  glusterd3_1_probe},
> +        [GD2_MGMT_FRIEND_ADD]  = { "FRIEND_ADD",  glusterd3_1_friend_add
> },
> +        [GD2_MGMT_CLUSTER_LOCK] = {"CLUSTER_LOCK",
> glusterd3_1_cluster_lock},
> +        [GD2_MGMT_CLUSTER_UNLOCK] = {"CLUSTER_UNLOCK",
> glusterd3_1_cluster_unlock},
> +        [GD2_MGMT_STAGE_OP] = {"STAGE_OP", glusterd3_1_stage_op},
> +        [GD2_MGMT_COMMIT_OP] = {"COMMIT_OP", glusterd3_1_commit_op},
> +        [GD2_MGMT_FRIEND_REMOVE]  = { "FRIEND_REMOVE",
>  glusterd3_1_friend_remove},
> +        [GD2_MGMT_FRIEND_UPDATE]  = { "FRIEND_UPDATE",
>  glusterd3_1_friend_update},
> +};
> +
> +
> +
> +struct rpc_clnt_program glusterd3_1_mgmt2_prog = {
> +        .progname = "Mgmt 3.1 - v2",
> +        .prognum  = GLUSTERD2_MGMT_PROGRAM,
> +        .progver  = GLUSTERD2_MGMT_VERSION,
> +        .proctable    = glusterd3_1_clnt2_mgmt_actors,
> +        .numproc  = GLUSTERD2_MGMT_PROCCNT,
> +};
> --
> 1.7.0.4
>
> _______________________________________________
> glusterfs mailing list
> glusterfs@dev.gluster.com
> http://dev.gluster.com/cgi-bin/mailman/listinfo/glusterfs
>

Patch

From 65a61b8c2babb412d88954e796010aa5311b079c Mon Sep 17 00:00:00 2001
From: Amar Tumballi <amar@gluster.com>
Date: Fri, 14 Jan 2011 11:53:58 +0530
Subject: [PATCH] rpc program version related fixes for cli and mgmt


Signed-off-by: Amar Tumballi <amar@gluster.com>
---
 cli/src/cli3_1-cops.c             |    6 +++---
 rpc/rpc-lib/src/protocol-common.h |    6 +-----
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/cli/src/cli3_1-cops.c b/cli/src/cli3_1-cops.c
index 3003469..6132cd0 100644
--- a/cli/src/cli3_1-cops.c
+++ b/cli/src/cli3_1-cops.c
@@ -2424,8 +2424,8 @@  struct rpc_clnt_procedure gluster3_1_cli_actors[GF1_CLI_MAXVALUE] = {
 
 struct rpc_clnt_program cli3_1_prog = {
         .progname = "CLI 3.1",
-        .prognum  = GLUSTER3_1_CLI_PROGRAM,
-        .progver  = GLUSTER3_1_CLI_VERSION,
+        .prognum  = GLUSTERD1_MGMT_PROGRAM,
+        .progver  = GLUSTERD1_MGMT_VERSION,
         .proctable  = gluster3_1_cli_actors,
-        .numproc  = GLUSTER3_1_CLI_PROCCNT,
+        .numproc  = GLUSTERD1_MGMT_PROCCNT,
 };
diff --git a/rpc/rpc-lib/src/protocol-common.h b/rpc/rpc-lib/src/protocol-common.h
index 2fe7040..be1b091 100644
--- a/rpc/rpc-lib/src/protocol-common.h
+++ b/rpc/rpc-lib/src/protocol-common.h
@@ -111,7 +111,7 @@  enum gf_mgmt_procnum_ {
 typedef enum gf_mgmt_procnum_ gf_mgmt_procnum;
 
 enum gf_cli_procnum {
-        GF1_CLI_NULL = GD_MGMT_MAXVALUE+1,    /* 0 */
+        GF1_CLI_NULL,
         GF1_CLI_PROBE,
         GF1_CLI_DEPROBE,
         GF1_CLI_LIST_FRIENDS,
@@ -190,10 +190,6 @@  enum gf_cbk_procnum {
 #define GLUSTERD1_MGMT_VERSION   1   /* 0.0.1 */
 #define GLUSTERD1_MGMT_PROCCNT   GD_MGMT_MAXVALUE
 
-#define GLUSTER3_1_CLI_PROGRAM   1298433 /* Completely random */
-#define GLUSTER3_1_CLI_VERSION   1   /* 0.0.1 */
-#define GLUSTER3_1_CLI_PROCCNT   GF1_CLI_MAXVALUE
-
 #define GLUSTER_HNDSK_PROGRAM    14398633 /* Completely random */
 #define GLUSTER_HNDSK_VERSION    1   /* 0.0.1 */
 
-- 
1.7.0.4