Patchwork [BUG:2333] glusterd: make it more RPC friendly

login
register
Submitter Amar Tumballi
Date 2011-02-19 07:22:22
Message ID <20110219072222.GA22654@gluster.com>
Download mbox | patch
Permalink /patch/6222/
State Accepted
Delegated to: Anand Avati
Headers show

Comments

Amar Tumballi - 2011-02-19 07:22:22
make sure each procedure has a actor associated with it.
that way proper versioning can be implemented in modules

Signed-off-by: Amar Tumballi <amar@gluster.com>
---
 xlators/mgmt/glusterd/src/glusterd-handler.c |  259 +++++++++++++++++++++++++-
 xlators/mgmt/glusterd/src/glusterd3_1-mops.c |  219 +++-------------------
 2 files changed, 282 insertions(+), 196 deletions(-)

Patch

diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 5888a26..6f8cf0c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -436,6 +436,9 @@  glusterd_handle_cluster_lock (rpcsvc_request_t *req)
 out:
         gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
 
+        glusterd_friend_sm ();
+        glusterd_op_sm ();
+
         return ret;
 }
 
@@ -483,6 +486,10 @@  glusterd_handle_stage_op (rpcsvc_request_t *req)
 out:
         if (stage_req.buf.buf_val)
                 free (stage_req.buf.buf_val);//malloced by xdr
+
+        glusterd_friend_sm ();
+        glusterd_op_sm ();
+
         return ret;
 }
 
@@ -530,6 +537,10 @@  glusterd_handle_commit_op (rpcsvc_request_t *req)
 out:
         if (commit_req.buf.buf_val)
                 free (commit_req.buf.buf_val);//malloced by xdr
+
+        glusterd_friend_sm ();
+        glusterd_op_sm ();
+
         return ret;
 }
 
@@ -574,9 +585,17 @@  glusterd_handle_cli_probe (rpcsvc_request_t *req)
 
         gf_cmd_log ("peer probe","on host %s:%d %s",cli_req.hostname, cli_req.port,
                     (ret) ? "FAILED" : "SUCCESS");
+
+        if (ret == GLUSTERD_CONNECTION_AWAITED)
+                return 0;
+
 out:
         if (cli_req.hostname)
                 free (cli_req.hostname);//its malloced by xdr
+
+        glusterd_friend_sm ();
+        glusterd_op_sm ();
+
         return ret;
 }
 
@@ -644,6 +663,10 @@  out:
 
         if (cli_req.hostname)
                 free (cli_req.hostname);//malloced by xdr
+
+        glusterd_friend_sm ();
+        glusterd_op_sm ();
+
         return ret;
 }
 
@@ -686,6 +709,10 @@  glusterd_handle_cli_list_friends (rpcsvc_request_t *req)
 out:
         if (dict)
                 dict_unref (dict);
+
+        glusterd_friend_sm ();
+        glusterd_op_sm ();
+
         return ret;
 }
 
@@ -728,6 +755,10 @@  glusterd_handle_cli_get_volume (rpcsvc_request_t *req)
 out:
         if (dict)
                 dict_unref (dict);
+
+        glusterd_friend_sm ();
+        glusterd_op_sm ();
+
         return ret;
 }
 
@@ -756,9 +787,18 @@  glusterd_handle_create_volume (rpcsvc_request_t *req)
         uuid_t                  volume_id   = {0,};
         glusterd_brickinfo_t    *tmpbrkinfo = NULL;
         glusterd_volinfo_t      tmpvolinfo = {{0},};
+        int                     lock_fail = 0;
 
         GF_ASSERT (req);
 
+        ret = glusterd_op_set_cli_op (req->procnum);
+        if (ret) {
+                gf_log ("", GF_LOG_ERROR, "Unable to set cli op: %d",
+                        ret);
+                lock_fail = 1;
+                goto out;
+        }
+
         this = THIS;
         GF_ASSERT(this);
 
@@ -903,6 +943,13 @@  out:
                 glusterd_brickinfo_delete (brickinfo);
         if (cli_req.volname)
                 free (cli_req.volname); // its a malloced by xdr
+
+        glusterd_friend_sm ();
+        glusterd_op_sm ();
+
+        if (!lock_fail)
+                (void) glusterd_opinfo_unlock ();
+
         return ret;
 }
 
@@ -911,9 +958,18 @@  glusterd_handle_cli_start_volume (rpcsvc_request_t *req)
 {
         int32_t                         ret = -1;
         gf1_cli_start_vol_req           cli_req = {0,};
+        int                             lock_fail = 0;
 
         GF_ASSERT (req);
 
+        ret = glusterd_op_set_cli_op (req->procnum);
+        if (ret) {
+                gf_log ("", GF_LOG_ERROR, "Unable to set cli op: %d",
+                        ret);
+                lock_fail = 1;
+                goto out;
+        }
+
         if (!gf_xdr_to_cli_start_vol_req (req->msg[0], &cli_req)) {
                 //failed to decode msg;
                 req->rpc_err = GARBAGE_ARGS;
@@ -931,6 +987,17 @@  glusterd_handle_cli_start_volume (rpcsvc_request_t *req)
 out:
         if (cli_req.volname)
                 free (cli_req.volname); //its malloced by xdr
+
+        glusterd_friend_sm ();
+        glusterd_op_sm ();
+
+        if (!lock_fail)
+                (void) glusterd_opinfo_unlock ();
+
+        if (ret)
+                ret = glusterd_op_send_cli_response (req->procnum, ret, 0, req,
+                                                     NULL, "operation failed");
+
         return ret;
 }
 
@@ -940,9 +1007,18 @@  glusterd_handle_cli_stop_volume (rpcsvc_request_t *req)
 {
         int32_t                         ret = -1;
         gf1_cli_stop_vol_req           cli_req = {0,};
+        int                             lock_fail = 0;
 
         GF_ASSERT (req);
 
+        ret = glusterd_op_set_cli_op (req->procnum);
+        if (ret) {
+                gf_log ("", GF_LOG_ERROR, "Unable to set cli op: %d",
+                        ret);
+                lock_fail = 1;
+                goto out;
+        }
+
         if (!gf_xdr_to_cli_stop_vol_req (req->msg[0], &cli_req)) {
                 //failed to decode msg;
                 req->rpc_err = GARBAGE_ARGS;
@@ -960,6 +1036,17 @@  glusterd_handle_cli_stop_volume (rpcsvc_request_t *req)
 out:
         if (cli_req.volname)
                 free (cli_req.volname); //its malloced by xdr
+
+        glusterd_friend_sm ();
+        glusterd_op_sm ();
+
+        if (!lock_fail)
+                (void) glusterd_opinfo_unlock ();
+
+        if (ret)
+                ret = glusterd_op_send_cli_response (req->procnum, ret, 0, req,
+                                                     NULL, "operation failed");
+
         return ret;
 }
 
@@ -969,9 +1056,18 @@  glusterd_handle_cli_delete_volume (rpcsvc_request_t *req)
         int32_t                         ret = -1;
         gf1_cli_delete_vol_req          cli_req = {0,};
         int32_t                         flags = 0;
+        int                             lock_fail = 0;
 
         GF_ASSERT (req);
 
+        ret = glusterd_op_set_cli_op (req->procnum);
+        if (ret) {
+                gf_log ("", GF_LOG_ERROR, "Unable to set cli op: %d",
+                        ret);
+                lock_fail = 1;
+                goto out;
+        }
+
         if (!gf_xdr_to_cli_delete_vol_req (req->msg[0], &cli_req)) {
                 //failed to decode msg;
                 req->rpc_err = GARBAGE_ARGS;
@@ -990,6 +1086,17 @@  glusterd_handle_cli_delete_volume (rpcsvc_request_t *req)
 out:
         if (cli_req.volname)
                 free (cli_req.volname); //its malloced by xdr
+
+        glusterd_friend_sm ();
+        glusterd_op_sm ();
+
+        if (!lock_fail)
+                (void) glusterd_opinfo_unlock ();
+
+        if (ret)
+                ret = glusterd_op_send_cli_response (req->procnum, ret, 0, req,
+                                                     NULL, "operation failed");
+
         return ret;
 }
 
@@ -1017,6 +1124,7 @@  glusterd_handle_add_brick (rpcsvc_request_t *req)
         char                            *free_ptr = NULL;
         glusterd_brickinfo_t            *tmpbrkinfo = NULL;
         glusterd_volinfo_t              tmpvolinfo = {{0},};
+        int                             lock_fail = 0;
 
         this = THIS;
         GF_ASSERT(this);
@@ -1025,6 +1133,14 @@  glusterd_handle_add_brick (rpcsvc_request_t *req)
 
         GF_ASSERT (req);
 
+        ret = glusterd_op_set_cli_op (req->procnum);
+        if (ret) {
+                gf_log ("", GF_LOG_ERROR, "Unable to set cli op: %d",
+                        ret);
+                lock_fail = 1;
+                goto out;
+        }
+
         INIT_LIST_HEAD (&tmpvolinfo.bricks);
 
         if (!gf_xdr_to_cli_add_brick_req (req->msg[0], &cli_req)) {
@@ -1198,9 +1314,18 @@  glusterd_handle_replace_brick (rpcsvc_request_t *req)
         char                            *dst_brick = NULL;
         int32_t                         op = 0;
         char                            operation[256];
+        int                             lock_fail = 0;
 
         GF_ASSERT (req);
 
+        ret = glusterd_op_set_cli_op (req->procnum);
+        if (ret) {
+                gf_log ("", GF_LOG_ERROR, "Unable to set cli op: %d",
+                        ret);
+                lock_fail = 1;
+                goto out;
+        }
+
         if (!gf_xdr_to_cli_replace_brick_req (req->msg[0], &cli_req)) {
                 //failed to decode msg;
                 req->rpc_err = GARBAGE_ARGS;
@@ -1285,6 +1410,17 @@  out:
                 dict_unref (dict);
         if (cli_req.volname)
                 free (cli_req.volname);//malloced by xdr
+
+        glusterd_friend_sm ();
+        glusterd_op_sm ();
+
+        if (!lock_fail)
+                (void) glusterd_opinfo_unlock ();
+
+        if (ret)
+                ret = glusterd_op_send_cli_response (req->procnum, ret, 0, req,
+                                                     NULL, "operation failed");
+
         return ret;
 }
 
@@ -1328,6 +1464,9 @@  out:
         if (cli_req.volname)
                 free (cli_req.volname);//malloced by xdr
 
+        glusterd_friend_sm ();
+        glusterd_op_sm ();
+
         return ret;
 }
 
@@ -1364,6 +1503,9 @@  glusterd_handle_gsync_set (rpcsvc_request_t *req)
         ret = glusterd_gsync_set (req, dict);
 
 out:
+        glusterd_friend_sm ();
+        glusterd_op_sm ();
+
         return ret;
 }
 
@@ -1405,6 +1547,9 @@  out:
         if (cli_req.volname)
                 free (cli_req.volname);//malloced by xdr
 
+        glusterd_friend_sm ();
+        glusterd_op_sm ();
+
         return ret;
 }
 
@@ -1431,9 +1576,18 @@  glusterd_handle_remove_brick (rpcsvc_request_t *req)
         gf1_cli_remove_brick_rsp        rsp = {0,};
         void                            *cli_rsp = NULL;
         char                            vol_type[256] = {0,};
+        int                             lock_fail = 0;
 
         GF_ASSERT (req);
 
+        ret = glusterd_op_set_cli_op (req->procnum);
+        if (ret) {
+                gf_log ("", GF_LOG_ERROR, "Unable to set cli op: %d",
+                        ret);
+                lock_fail = 1;
+                goto out;
+        }
+
         if (!gf_xdr_to_cli_remove_brick_req (req->msg[0], &cli_req)) {
                 //failed to decode msg;
                 req->rpc_err = GARBAGE_ARGS;
@@ -1614,6 +1768,13 @@  out:
                 GF_FREE (err_str);
         if (cli_req.volname)
                 free (cli_req.volname); //its malloced by xdr
+
+        glusterd_friend_sm ();
+        glusterd_op_sm ();
+
+        if (!lock_fail)
+                (void) glusterd_opinfo_unlock ();
+
         return ret;
 }
 
@@ -1623,9 +1784,18 @@  glusterd_handle_log_filename (rpcsvc_request_t *req)
         int32_t                   ret     = -1;
         gf1_cli_log_filename_req  cli_req = {0,};
         dict_t                   *dict    = NULL;
+        int                       lock_fail = 0;
 
         GF_ASSERT (req);
 
+        ret = glusterd_op_set_cli_op (req->procnum);
+        if (ret) {
+                gf_log ("", GF_LOG_ERROR, "Unable to set cli op: %d",
+                        ret);
+                lock_fail = 1;
+                goto out;
+        }
+
         if (!gf_xdr_to_cli_log_filename_req (req->msg[0], &cli_req)) {
                 //failed to decode msg;
                 req->rpc_err = GARBAGE_ARGS;
@@ -1654,6 +1824,17 @@  glusterd_handle_log_filename (rpcsvc_request_t *req)
 out:
         if (ret && dict)
                 dict_unref (dict);
+
+        glusterd_friend_sm ();
+        glusterd_op_sm ();
+
+        if (!lock_fail)
+                (void) glusterd_opinfo_unlock ();
+
+        if (ret)
+                ret = glusterd_op_send_cli_response (req->procnum, ret, 0, req,
+                                                     NULL, "operation failed");
+
         return ret;
 }
 
@@ -1670,11 +1851,20 @@  glusterd_handle_log_locate (rpcsvc_request_t *req)
         char                   *tmp_brick = NULL;
         uint32_t                found = 0;
         glusterd_brickinfo_t   *tmpbrkinfo = NULL;
+        int                     lock_fail = 0;
 
         GF_ASSERT (req);
 
         priv    = THIS->private;
 
+        ret = glusterd_op_set_cli_op (req->procnum);
+        if (ret) {
+                gf_log ("", GF_LOG_ERROR, "Unable to set cli op: %d",
+                        ret);
+                lock_fail = 1;
+                goto out;
+        }
+
         if (!gf_xdr_to_cli_log_locate_req (req->msg[0], &cli_req)) {
                 //failed to decode msg;
                 req->rpc_err = GARBAGE_ARGS;
@@ -1754,6 +1944,13 @@  out:
                 free (cli_req.brick); //its malloced by xdr
         if (cli_req.volname)
                 free (cli_req.volname); //its malloced by xdr
+
+        glusterd_friend_sm ();
+        glusterd_op_sm ();
+
+        if (!lock_fail)
+                (void) glusterd_opinfo_unlock ();
+
         return ret;
 }
 
@@ -1763,9 +1960,18 @@  glusterd_handle_log_rotate (rpcsvc_request_t *req)
         int32_t                 ret     = -1;
         gf1_cli_log_rotate_req  cli_req = {0,};
         dict_t                 *dict    = NULL;
+        int                     lock_fail = 0;
 
         GF_ASSERT (req);
 
+        ret = glusterd_op_set_cli_op (req->procnum);
+        if (ret) {
+                gf_log ("", GF_LOG_ERROR, "Unable to set cli op: %d",
+                        ret);
+                lock_fail = 1;
+                goto out;
+        }
+
         if (!gf_xdr_to_cli_log_rotate_req (req->msg[0], &cli_req)) {
                 //failed to decode msg;
                 req->rpc_err = GARBAGE_ARGS;
@@ -1796,6 +2002,17 @@  glusterd_handle_log_rotate (rpcsvc_request_t *req)
 out:
         if (ret && dict)
                 dict_unref (dict);
+
+        glusterd_friend_sm ();
+        glusterd_op_sm ();
+
+        if (!lock_fail)
+                (void) glusterd_opinfo_unlock ();
+
+        if (ret)
+                ret = glusterd_op_send_cli_response (req->procnum, ret, 0, req,
+                                                     NULL, "operation failed");
+
         return ret;
 }
 
@@ -1810,9 +2027,18 @@  glusterd_handle_sync_volume (rpcsvc_request_t *req)
         gf_boolean_t                     free_hostname = _gf_true;
         gf_boolean_t                     free_volname = _gf_true;
         glusterd_volinfo_t               *volinfo = NULL;
+        int                              lock_fail = 0;
 
         GF_ASSERT (req);
 
+        ret = glusterd_op_set_cli_op (req->procnum);
+        if (ret) {
+                gf_log ("", GF_LOG_ERROR, "Unable to set cli op: %d",
+                        ret);
+                lock_fail = 1;
+                goto out;
+        }
+
         if (!gf_xdr_to_cli_sync_volume_req (req->msg[0], &cli_req)) {
                 //failed to decode msg;
                 req->rpc_err = GARBAGE_ARGS;
@@ -1892,13 +2118,16 @@  out:
                         free (cli_req.volname);
                 if (dict)
                         dict_unref (dict);
-                if (!glusterd_opinfo_unlock())
-                        gf_log ("glusterd", GF_LOG_ERROR, "Unlock on "
-                               "opinfo failed");
 
                 ret = 0; //sent error to cli, prevent second reply
         }
 
+        glusterd_friend_sm ();
+        glusterd_op_sm ();
+
+        if (!lock_fail)
+                (void) glusterd_opinfo_unlock ();
+
         return ret;
 }
 
@@ -1978,6 +2207,10 @@  out:
                 free (cli_req.name);//malloced by xdr
         if (dict)
                 dict_unref (dict);
+
+        glusterd_friend_sm ();
+        glusterd_op_sm ();
+
         return 0;//send 0 to avoid double reply
 }
 
@@ -2052,6 +2285,9 @@  glusterd_handle_cluster_unlock (rpcsvc_request_t *req)
         ret = glusterd_op_sm_inject_event (GD_OP_EVENT_UNLOCK, ctx);
 
 out:
+        glusterd_friend_sm ();
+        glusterd_op_sm ();
+
         return ret;
 }
 
@@ -2152,10 +2388,16 @@  glusterd_handle_incoming_friend_req (rpcsvc_request_t *req)
                                           friend_req.hostname, friend_req.port,
                                           &friend_req);
 
+        if (ret == GLUSTERD_CONNECTION_AWAITED)
+                return 0;
+
 out:
         if (friend_req.hostname)
                 free (friend_req.hostname);//malloced by xdr
 
+        glusterd_friend_sm ();
+        glusterd_op_sm ();
+
         return ret;
 }
 
@@ -2190,6 +2432,10 @@  out:
                 free (friend_req.hostname);//malloced by xdr
         if (friend_req.vols.vols_val)
                 free (friend_req.vols.vols_val);//malloced by xdr
+
+        glusterd_friend_sm ();
+        glusterd_op_sm ();
+
         return ret;
 }
 
@@ -2363,6 +2609,9 @@  out:
                         free (friend_req.friends.friends_val);//malloced by xdr
         }
 
+        glusterd_friend_sm ();
+        glusterd_op_sm ();
+
         return ret;
 }
 
@@ -2437,6 +2686,10 @@  glusterd_handle_probe_query (rpcsvc_request_t *req)
 out:
         if (probe_req.hostname)
                 free (probe_req.hostname);//malloced by xdr
+
+        glusterd_friend_sm ();
+        glusterd_op_sm ();
+
         return ret;
 }
 
diff --git a/xlators/mgmt/glusterd/src/glusterd3_1-mops.c b/xlators/mgmt/glusterd/src/glusterd3_1-mops.c
index 10e4dac..42f28d8 100644
--- a/xlators/mgmt/glusterd/src/glusterd3_1-mops.c
+++ b/xlators/mgmt/glusterd/src/glusterd3_1-mops.c
@@ -1321,203 +1321,36 @@  out:
         return ret;
 }
 
-
-int
-glusterd_handle_rpc_msg (rpcsvc_request_t *req)
-{
-        int             ret = -1;
-        gf_boolean_t    is_cli_req = _gf_false;
-        int             lock_fail = 0;
-
-        GF_ASSERT (req);
-
-        is_cli_req = glusterd_is_cli_op_req (req->procnum);
-
-        if (is_cli_req) {
-                ret = glusterd_op_set_cli_op (req->procnum);
-
-                if (ret) {
-                        gf_log ("", GF_LOG_ERROR, "Unable to set cli op: %d",
-                                ret);
-                        lock_fail = 1;
-                        goto out;
-                }
-        }
-
-        switch (req->procnum) {
-                case GD_MGMT_PROBE_QUERY:
-                        ret = glusterd_handle_probe_query (req);
-                        break;
-
-                case GD_MGMT_FRIEND_ADD:
-                        ret = glusterd_handle_incoming_friend_req (req);
-                        if (ret == GLUSTERD_CONNECTION_AWAITED)
-                                return 0;
-                        break;
-
-                case GD_MGMT_CLUSTER_LOCK:
-                        ret = glusterd_handle_cluster_lock (req);
-                        break;
-
-                case GD_MGMT_CLUSTER_UNLOCK:
-                        ret = glusterd_handle_cluster_unlock (req);
-                        break;
-
-                case GD_MGMT_STAGE_OP:
-                        ret = glusterd_handle_stage_op (req);
-                        break;
-
-                case GD_MGMT_COMMIT_OP:
-                        ret = glusterd_handle_commit_op (req);
-                        break;
-
-                case GD_MGMT_CLI_PROBE:
-                        ret = glusterd_handle_cli_probe (req);
-                        if (ret == GLUSTERD_CONNECTION_AWAITED)
-                                return 0;
-                        break;
-
-                case GD_MGMT_CLI_CREATE_VOLUME:
-                        ret = glusterd_handle_create_volume (req);
-                        break;
-
-                case GD_MGMT_CLI_DEPROBE:
-                        ret = glusterd_handle_cli_deprobe (req);
-                        break;
-
-                case GD_MGMT_FRIEND_REMOVE:
-                        ret = glusterd_handle_incoming_unfriend_req (req);
-                        break;
-
-                case GD_MGMT_CLI_LIST_FRIENDS:
-                        ret = glusterd_handle_cli_list_friends (req);
-                        break;
-
-                case GD_MGMT_CLI_START_VOLUME:
-                        ret = glusterd_handle_cli_start_volume (req);
-                        break;
-
-                case GD_MGMT_CLI_STOP_VOLUME:
-                        ret = glusterd_handle_cli_stop_volume (req);
-                        break;
-
-                case GD_MGMT_CLI_DELETE_VOLUME:
-                        ret = glusterd_handle_cli_delete_volume (req);
-                        break;
-
-                case GD_MGMT_FRIEND_UPDATE:
-                        ret = glusterd_handle_friend_update (req);
-                        break;
-
-                case GD_MGMT_CLI_GET_VOLUME:
-                        ret = glusterd_handle_cli_get_volume (req);
-                        break;
-
-                case GD_MGMT_CLI_DEFRAG_VOLUME:
-                        ret = glusterd_handle_defrag_volume (req);
-                        break;
-
-                case GD_MGMT_CLI_ADD_BRICK:
-                        ret = glusterd_handle_add_brick (req);
-                        break;
-
-                case GD_MGMT_CLI_REPLACE_BRICK:
-                        ret = glusterd_handle_replace_brick (req);
-                        break;
-
-                case GD_MGMT_CLI_REMOVE_BRICK:
-                        ret = glusterd_handle_remove_brick (req);
-                        break;
-
-                case GD_MGMT_CLI_LOG_FILENAME:
-                        ret = glusterd_handle_log_filename (req);
-                        break;
-
-                case GD_MGMT_CLI_LOG_LOCATE:
-                        ret = glusterd_handle_log_locate (req);
-                        break;
-
-                case GD_MGMT_CLI_LOG_ROTATE:
-                        ret = glusterd_handle_log_rotate (req);
-                        break;
-
-                case GD_MGMT_CLI_SET_VOLUME:
-                        ret = glusterd_handle_set_volume (req);
-			break;
-
-                case GD_MGMT_CLI_SYNC_VOLUME:
-                        ret = glusterd_handle_sync_volume (req);
-                        break;
-
-                case GD_MGMT_CLI_RESET_VOLUME:
-                        ret = glusterd_handle_reset_volume (req);
-                        break;
-
-                case GD_MGMT_CLI_FSM_LOG:
-                        ret = glusterd_handle_fsm_log (req);
-                        break;
-
-                case GD_MGMT_CLI_GSYNC_SET:
-                        ret = glusterd_handle_gsync_set (req);
-                        break;
-
-                default:
-			gf_log("", GF_LOG_ERROR, "Recieved Invalid procnum:%d",
-			       req->procnum);
-                        GF_ASSERT (0);
-        }
-
-        glusterd_friend_sm ();
-        glusterd_op_sm ();
-
-out:
-        if (ret && is_cli_req) {
-                /* if we are sending a reply here, then return value should
-                   be 0, and we should not point to any RPC errors, because
-                   otherwise rpcsvc.c will send an error reply for the same
-                   request, which causes double replies */
-                if (!lock_fail)
-                        (void) glusterd_opinfo_unlock ();
-                ret = glusterd_op_send_cli_response (req->procnum, ret, 0, req, NULL, "operation failed");
-        }
-
-        if (ret)
-                gf_log ("", GF_LOG_WARNING, "Returning %d", ret);
-
-        return ret;
-}
-
-
 rpcsvc_actor_t glusterd1_mgmt_actors[] = {
         [GD_MGMT_NULL]        = { "NULL",       GD_MGMT_NULL, glusterd_null, NULL, NULL},
-        [GD_MGMT_PROBE_QUERY] = { "PROBE_QUERY", GD_MGMT_PROBE_QUERY, glusterd_handle_rpc_msg, NULL, NULL},
-        [GD_MGMT_FRIEND_ADD] = { "FRIEND_ADD", GD_MGMT_FRIEND_ADD, glusterd_handle_rpc_msg, NULL, NULL},
-        [GD_MGMT_FRIEND_REMOVE] = { "FRIEND_REMOVE", GD_MGMT_FRIEND_REMOVE, glusterd_handle_rpc_msg, NULL, NULL},
-        [GD_MGMT_FRIEND_UPDATE] = { "FRIEND_UPDATE", GD_MGMT_FRIEND_UPDATE, glusterd_handle_rpc_msg, NULL, NULL},
-        [GD_MGMT_CLUSTER_LOCK] = { "CLUSTER_LOCK", GD_MGMT_CLUSTER_LOCK, glusterd_handle_rpc_msg, NULL, NULL},
-        [GD_MGMT_CLUSTER_UNLOCK] = { "CLUSTER_UNLOCK", GD_MGMT_CLUSTER_UNLOCK, glusterd_handle_rpc_msg, NULL, NULL},
-        [GD_MGMT_STAGE_OP] = { "STAGE_OP", GD_MGMT_STAGE_OP, glusterd_handle_rpc_msg, NULL, NULL},
-        [GD_MGMT_COMMIT_OP] = { "COMMIT_OP", GD_MGMT_COMMIT_OP, glusterd_handle_rpc_msg, NULL, NULL},
-        [GD_MGMT_CLI_PROBE] = { "CLI_PROBE", GD_MGMT_CLI_PROBE, glusterd_handle_rpc_msg, NULL, NULL},
-        [GD_MGMT_CLI_CREATE_VOLUME] = { "CLI_CREATE_VOLUME", GD_MGMT_CLI_CREATE_VOLUME, glusterd_handle_rpc_msg, NULL,NULL},
+        [GD_MGMT_PROBE_QUERY] = { "PROBE_QUERY", GD_MGMT_PROBE_QUERY, glusterd_handle_probe_query, NULL, NULL},
+        [GD_MGMT_FRIEND_ADD] = { "FRIEND_ADD", GD_MGMT_FRIEND_ADD, glusterd_handle_incoming_friend_req, NULL, NULL},
+        [GD_MGMT_FRIEND_REMOVE] = { "FRIEND_REMOVE", GD_MGMT_FRIEND_REMOVE, glusterd_handle_incoming_unfriend_req, NULL, NULL},
+        [GD_MGMT_FRIEND_UPDATE] = { "FRIEND_UPDATE", GD_MGMT_FRIEND_UPDATE, glusterd_handle_friend_update, NULL, NULL},
+        [GD_MGMT_CLUSTER_LOCK] = { "CLUSTER_LOCK", GD_MGMT_CLUSTER_LOCK, glusterd_handle_cluster_lock, NULL, NULL},
+        [GD_MGMT_CLUSTER_UNLOCK] = { "CLUSTER_UNLOCK", GD_MGMT_CLUSTER_UNLOCK, glusterd_handle_cluster_unlock, NULL, NULL},
+        [GD_MGMT_STAGE_OP] = { "STAGE_OP", GD_MGMT_STAGE_OP, glusterd_handle_stage_op, NULL, NULL},
+        [GD_MGMT_COMMIT_OP] = { "COMMIT_OP", GD_MGMT_COMMIT_OP, glusterd_handle_commit_op, NULL, NULL},
+        [GD_MGMT_CLI_PROBE] = { "CLI_PROBE", GD_MGMT_CLI_PROBE, glusterd_handle_cli_probe, NULL, NULL},
+        [GD_MGMT_CLI_CREATE_VOLUME] = { "CLI_CREATE_VOLUME", GD_MGMT_CLI_CREATE_VOLUME, glusterd_handle_create_volume, NULL,NULL},
         [GD_MGMT_CLI_DEFRAG_VOLUME] = { "CLI_DEFRAG_VOLUME", GD_MGMT_CLI_DEFRAG_VOLUME, glusterd_handle_defrag_volume, NULL,NULL},
-        [GD_MGMT_CLI_DEPROBE] = { "FRIEND_REMOVE", GD_MGMT_CLI_DEPROBE, glusterd_handle_rpc_msg, NULL, NULL},
-        [GD_MGMT_CLI_LIST_FRIENDS] = { "LIST_FRIENDS", GD_MGMT_CLI_LIST_FRIENDS, glusterd_handle_rpc_msg, NULL, NULL},
-        [GD_MGMT_CLI_START_VOLUME] = { "START_VOLUME", GD_MGMT_CLI_START_VOLUME, glusterd_handle_rpc_msg, NULL, NULL},
-        [GD_MGMT_CLI_STOP_VOLUME] = { "STOP_VOLUME", GD_MGMT_CLI_STOP_VOLUME, glusterd_handle_rpc_msg, NULL, NULL},
-        [GD_MGMT_CLI_DELETE_VOLUME] = { "DELETE_VOLUME", GD_MGMT_CLI_DELETE_VOLUME, glusterd_handle_rpc_msg, NULL, NULL},
-        [GD_MGMT_CLI_GET_VOLUME] = { "GET_VOLUME", GD_MGMT_CLI_GET_VOLUME, glusterd_handle_rpc_msg, NULL, NULL},
-        [GD_MGMT_CLI_ADD_BRICK] = { "ADD_BRICK", GD_MGMT_CLI_ADD_BRICK, glusterd_handle_rpc_msg, NULL, NULL},
-        [GD_MGMT_CLI_REPLACE_BRICK] = { "REPLACE_BRICK", GD_MGMT_CLI_REPLACE_BRICK, glusterd_handle_rpc_msg, NULL, NULL},
-        [GD_MGMT_CLI_REMOVE_BRICK] = { "REMOVE_BRICK", GD_MGMT_CLI_REMOVE_BRICK, glusterd_handle_rpc_msg, NULL, NULL},
-        [GD_MGMT_CLI_LOG_FILENAME] = { "LOG FILENAME", GD_MGMT_CLI_LOG_FILENAME, glusterd_handle_rpc_msg, NULL, NULL},
+        [GD_MGMT_CLI_DEPROBE] = { "FRIEND_REMOVE", GD_MGMT_CLI_DEPROBE, glusterd_handle_cli_deprobe, NULL, NULL},
+        [GD_MGMT_CLI_LIST_FRIENDS] = { "LIST_FRIENDS", GD_MGMT_CLI_LIST_FRIENDS, glusterd_handle_cli_list_friends, NULL, NULL},
+        [GD_MGMT_CLI_START_VOLUME] = { "START_VOLUME", GD_MGMT_CLI_START_VOLUME, glusterd_handle_cli_start_volume, NULL, NULL},
+        [GD_MGMT_CLI_STOP_VOLUME] = { "STOP_VOLUME", GD_MGMT_CLI_STOP_VOLUME, glusterd_handle_cli_stop_volume, NULL, NULL},
+        [GD_MGMT_CLI_DELETE_VOLUME] = { "DELETE_VOLUME", GD_MGMT_CLI_DELETE_VOLUME, glusterd_handle_cli_delete_volume, NULL, NULL},
+        [GD_MGMT_CLI_GET_VOLUME] = { "GET_VOLUME", GD_MGMT_CLI_GET_VOLUME, glusterd_handle_cli_get_volume, NULL, NULL},
+        [GD_MGMT_CLI_ADD_BRICK] = { "ADD_BRICK", GD_MGMT_CLI_ADD_BRICK, glusterd_handle_add_brick, NULL, NULL},
+        [GD_MGMT_CLI_REPLACE_BRICK] = { "REPLACE_BRICK", GD_MGMT_CLI_REPLACE_BRICK, glusterd_handle_replace_brick, NULL, NULL},
+        [GD_MGMT_CLI_REMOVE_BRICK] = { "REMOVE_BRICK", GD_MGMT_CLI_REMOVE_BRICK, glusterd_handle_remove_brick, NULL, NULL},
+        [GD_MGMT_CLI_LOG_FILENAME] = { "LOG FILENAME", GD_MGMT_CLI_LOG_FILENAME, glusterd_handle_log_filename, NULL, NULL},
         [GD_MGMT_CLI_LOG_LOCATE] = { "LOG LOCATE", GD_MGMT_CLI_LOG_LOCATE, glusterd_handle_log_locate, NULL, NULL},
-        [GD_MGMT_CLI_LOG_ROTATE] = { "LOG FILENAME", GD_MGMT_CLI_LOG_ROTATE, glusterd_handle_rpc_msg, NULL, NULL},
-        [GD_MGMT_CLI_SET_VOLUME] = { "SET_VOLUME", GD_MGMT_CLI_SET_VOLUME, glusterd_handle_rpc_msg, NULL, NULL},
-        [GD_MGMT_CLI_SYNC_VOLUME] = { "SYNC_VOLUME", GD_MGMT_CLI_SYNC_VOLUME, glusterd_handle_rpc_msg, NULL, NULL},
-        [GD_MGMT_CLI_RESET_VOLUME] = { "RESET_VOLUME", GD_MGMT_CLI_RESET_VOLUME, glusterd_handle_rpc_msg, NULL, NULL},
-        [GD_MGMT_CLI_FSM_LOG] = { "FSM_LOG", GD_MGMT_CLI_FSM_LOG, glusterd_handle_rpc_msg, NULL, NULL},
-        [GD_MGMT_CLI_GSYNC_SET] = {"GSYNC_SET", GD_MGMT_CLI_GSYNC_SET, glusterd_handle_rpc_msg, NULL, NULL},
+        [GD_MGMT_CLI_LOG_ROTATE] = { "LOG FILENAME", GD_MGMT_CLI_LOG_ROTATE, glusterd_handle_log_rotate, NULL, NULL},
+        [GD_MGMT_CLI_SET_VOLUME] = { "SET_VOLUME", GD_MGMT_CLI_SET_VOLUME, glusterd_handle_set_volume, NULL, NULL},
+        [GD_MGMT_CLI_SYNC_VOLUME] = { "SYNC_VOLUME", GD_MGMT_CLI_SYNC_VOLUME, glusterd_handle_sync_volume, NULL, NULL},
+        [GD_MGMT_CLI_RESET_VOLUME] = { "RESET_VOLUME", GD_MGMT_CLI_RESET_VOLUME, glusterd_handle_reset_volume, NULL, NULL},
+        [GD_MGMT_CLI_FSM_LOG] = { "FSM_LOG", GD_MGMT_CLI_FSM_LOG, glusterd_handle_fsm_log, NULL, NULL},
+        [GD_MGMT_CLI_GSYNC_SET] = {"GSYNC_SET", GD_MGMT_CLI_GSYNC_SET, glusterd_handle_gsync_set, NULL, NULL},
 };
 
 /*rpcsvc_actor_t glusterd1_mgmt_actors[] = {