diff options
| -rw-r--r-- | cli/src/cli-cmd-probe.c | 51 | ||||
| -rw-r--r-- | cli/src/cli-cmd-volume.c | 3 | ||||
| -rw-r--r-- | cli/src/cli3_1-cops.c | 46 | ||||
| -rw-r--r-- | rpc/xdr/src/cli1-xdr.c | 6 | ||||
| -rw-r--r-- | rpc/xdr/src/cli1-xdr.h | 3 | ||||
| -rw-r--r-- | rpc/xdr/src/glusterd1-xdr.c | 14 | ||||
| -rw-r--r-- | rpc/xdr/src/glusterd1-xdr.h | 7 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handler.c | 77 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-sm.c | 44 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-sm.h | 2 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd.h | 12 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd3_1-mops.c | 27 | 
12 files changed, 209 insertions, 83 deletions
diff --git a/cli/src/cli-cmd-probe.c b/cli/src/cli-cmd-probe.c index a9f15a423..9f7a1da77 100644 --- a/cli/src/cli-cmd-probe.c +++ b/cli/src/cli-cmd-probe.c @@ -40,19 +40,19 @@ extern rpc_clnt_prog_t *cli_rpc_prog;  void  cli_cmd_probe_usage ()  { -        cli_out ("Usage: probe <hostname>\n"); +        cli_out ("Usage: probe <hostname> [port]\n");  }  void  cli_cmd_deprobe_usage ()  { -        cli_out ("Usage: detach <hostname>\n"); +        cli_out ("Usage: detach <hostname> [port]\n");  }  void  cli_cmd_peer_status_usage ()  { -        cli_out ("Usage: peer status <hostname>\n"); +        cli_out ("Usage: peer status <hostname> [port]\n");  }  int @@ -62,8 +62,9 @@ cli_cmd_probe_cbk (struct cli_state *state, struct cli_cmd_word *word,          int                     ret = -1;          rpc_clnt_procedure_t    *proc = NULL;          call_frame_t            *frame = NULL; +        dict_t                  *dict = NULL; -        if (wordcount != 2) { +        if (!((wordcount == 3) || (wordcount == 2))) {                  cli_cmd_probe_usage ();                  goto out;          } @@ -74,8 +75,22 @@ cli_cmd_probe_cbk (struct cli_state *state, struct cli_cmd_word *word,          if (!frame)                  goto out; +        dict = dict_new (); +        if (!dict) +                goto out; + +        ret = dict_set_str (dict, "hostname", (char *)words[1]); +        if (ret) +                goto out; + +        if (words[2]) { +                ret = dict_set_str (dict, "port", (char *)words[2]); +                if (ret) +                        goto out; +        } +          if (proc->fn) { -                ret = proc->fn (frame, THIS, (char *)words[1] ); +                ret = proc->fn (frame, THIS, dict);          }  out: @@ -89,11 +104,12 @@ int  cli_cmd_deprobe_cbk (struct cli_state *state, struct cli_cmd_word *word,                       const char **words, int wordcount)  { -        int             ret = -1; -        rpc_clnt_procedure_t    *proc = NULL; -        call_frame_t            *frame = NULL; +        int                   ret   = -1; +        rpc_clnt_procedure_t *proc  = NULL; +        call_frame_t         *frame = NULL; +        dict_t               *dict  = NULL; -        if (wordcount != 2) { +        if (!((wordcount == 2) || (wordcount == 3))) {                  cli_cmd_deprobe_usage ();                  goto out;          } @@ -104,13 +120,26 @@ cli_cmd_deprobe_cbk (struct cli_state *state, struct cli_cmd_word *word,          if (!frame)                  goto out; +        dict = dict_new (); + +        ret = dict_set_str (dict, "hostname", (char *)words[1]); +        if (ret) +                goto out; + +        if (words[2]) { +                ret = dict_set_str (dict, "port", (char *)words[2]); +                if (ret) +                        goto out; +        } +          if (proc->fn) { -                ret = proc->fn (frame, THIS, (char *)words[1] ); +                ret = proc->fn (frame, THIS, dict);          }  out:          if (ret)                  cli_out ("Detach failed\n"); +          return ret;  } @@ -144,7 +173,7 @@ out:  }  struct cli_cmd cli_probe_cmds[] = { -        { "probe <HOSTNAME>", +        { "probe <HOSTNAME> [PORT]",            cli_cmd_probe_cbk },          { "detach <HOSTNAME>", diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index af06d8961..7aafddccc 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -91,6 +91,9 @@ out:                  char *volname = (char *) words[2];                  cli_out ("Creating Volume %s failed",volname );          } +        if (options) +                dict_destroy (options); +          return ret;  } diff --git a/cli/src/cli3_1-cops.c b/cli/src/cli3_1-cops.c index f0d20ec6b..1f9feeac0 100644 --- a/cli/src/cli3_1-cops.c +++ b/cli/src/cli3_1-cops.c @@ -106,6 +106,7 @@ gf_cli3_1_list_friends_cbk (struct rpc_req *req, struct iovec *iov,          int32_t                    i = 1;          char                       key[256] = {0,};          int32_t                    state = 0; +        int32_t                    port = 0;          if (-1 == req->rpc_status) {                  goto out; @@ -167,13 +168,18 @@ gf_cli3_1_list_friends_cbk (struct rpc_req *req, struct iovec *iov,                          if (ret)                                  goto out; +                        snprintf (key, 256, "friend%d.port", i); +                        ret = dict_get_int32 (dict, key, &port); +                        if (ret) +                                goto out; +                          snprintf (key, 256, "friend%d.state", i);                          ret = dict_get_int32 (dict, key, &state);                          if (ret)                                  goto out; -                        cli_out ("hostname:%s, uuid:%s, state:%d\n", -                                  hostname_buf, uuid_buf, state); +                        cli_out ("hostname:%s, port:%d, uuid:%s, state:%d\n", +                                 hostname_buf, port, uuid_buf, state);                          i++;                  }          } else { @@ -586,18 +592,28 @@ int32_t  gf_cli3_1_probe (call_frame_t *frame, xlator_t *this,                   void *data)  { -        gf1_cli_probe_req      req = {0,}; -        int                     ret = 0; -        char                    *hostname = NULL; +        gf1_cli_probe_req  req      = {0,}; +        int                ret      = 0; +        dict_t            *dict     = NULL; +        char              *hostname = NULL; +        int                port     = 0;          if (!frame || !this ||  !data) {                  ret = -1;                  goto out;          } -        hostname = data; +        dict = data; +        ret = dict_get_str (dict, "hostname", &hostname); +        if (ret) +                goto out; + +        ret = dict_get_int32 (dict, "port", &port); +        if (ret) +                port = CLI_GLUSTERD_PORT;          req.hostname = hostname; +        req.port     = port;          ret = cli_submit_request (&req, frame, cli_rpc_prog,                                     GD_MGMT_CLI_PROBE, NULL, gf_xdr_from_cli_probe_req, @@ -615,18 +631,28 @@ int32_t  gf_cli3_1_deprobe (call_frame_t *frame, xlator_t *this,                     void *data)  { -        gf1_cli_deprobe_req      req = {0,}; -        int                      ret = 0; -        char                     *hostname = NULL; +        gf1_cli_deprobe_req  req      = {0,}; +        int                  ret      = 0; +        dict_t              *dict     = NULL; +        char                *hostname = NULL; +        int                  port     = 0;          if (!frame || !this ||  !data) {                  ret = -1;                  goto out;          } -        hostname = data; +        dict = data; +        ret = dict_get_str (dict, "hostname", &hostname); +        if (ret) +                goto out; + +        ret = dict_get_int32 (dict, "port", &port); +        if (ret) +                port = CLI_GLUSTERD_PORT;          req.hostname = hostname; +        req.port     = port;          ret = cli_submit_request (&req, frame, cli_rpc_prog,                                     GD_MGMT_CLI_DEPROBE, NULL, diff --git a/rpc/xdr/src/cli1-xdr.c b/rpc/xdr/src/cli1-xdr.c index e5dd310f1..0ffdf5bfe 100644 --- a/rpc/xdr/src/cli1-xdr.c +++ b/rpc/xdr/src/cli1-xdr.c @@ -47,6 +47,8 @@ xdr_gf1_cli_probe_req (XDR *xdrs, gf1_cli_probe_req *objp)  	 if (!xdr_string (xdrs, &objp->hostname, ~0))  		 return FALSE; +	 if (!xdr_int (xdrs, &objp->port)) +		 return FALSE;  	return TRUE;  } @@ -60,6 +62,8 @@ xdr_gf1_cli_probe_rsp (XDR *xdrs, gf1_cli_probe_rsp *objp)  		 return FALSE;  	 if (!xdr_string (xdrs, &objp->hostname, ~0))  		 return FALSE; +	 if (!xdr_int (xdrs, &objp->port)) +		 return FALSE;  	return TRUE;  } @@ -69,6 +73,8 @@ xdr_gf1_cli_deprobe_req (XDR *xdrs, gf1_cli_deprobe_req *objp)  	 if (!xdr_string (xdrs, &objp->hostname, ~0))  		 return FALSE; +	 if (!xdr_int (xdrs, &objp->port)) +		 return FALSE;  	return TRUE;  } diff --git a/rpc/xdr/src/cli1-xdr.h b/rpc/xdr/src/cli1-xdr.h index b2060e187..50a26760a 100644 --- a/rpc/xdr/src/cli1-xdr.h +++ b/rpc/xdr/src/cli1-xdr.h @@ -43,6 +43,7 @@ typedef enum gf1_cli_get_volume gf1_cli_get_volume;  struct gf1_cli_probe_req {  	char *hostname; +        int port;  };  typedef struct gf1_cli_probe_req gf1_cli_probe_req; @@ -50,11 +51,13 @@ struct gf1_cli_probe_rsp {  	int op_ret;  	int op_errno;  	char *hostname; +        int port;  };  typedef struct gf1_cli_probe_rsp gf1_cli_probe_rsp;  struct gf1_cli_deprobe_req {  	char *hostname; +        int port;  };  typedef struct gf1_cli_deprobe_req gf1_cli_deprobe_req; diff --git a/rpc/xdr/src/glusterd1-xdr.c b/rpc/xdr/src/glusterd1-xdr.c index 3ad32d948..cbca582ee 100644 --- a/rpc/xdr/src/glusterd1-xdr.c +++ b/rpc/xdr/src/glusterd1-xdr.c @@ -23,6 +23,8 @@ xdr_gd1_mgmt_probe_req (XDR *xdrs, gd1_mgmt_probe_req *objp)  		 return FALSE;  	 if (!xdr_string (xdrs, &objp->hostname, ~0))  		 return FALSE; +	 if (!xdr_int (xdrs, &objp->port)) +		 return FALSE;  	return TRUE;  } @@ -35,6 +37,8 @@ xdr_gd1_mgmt_probe_rsp (XDR *xdrs, gd1_mgmt_probe_rsp *objp)  		 return FALSE;  	 if (!xdr_string (xdrs, &objp->hostname, ~0))  		 return FALSE; +	 if (!xdr_int (xdrs, &objp->port)) +		 return FALSE;  	return TRUE;  } @@ -47,6 +51,8 @@ xdr_gd1_mgmt_friend_req (XDR *xdrs, gd1_mgmt_friend_req *objp)  		 return FALSE;  	 if (!xdr_string (xdrs, &objp->hostname, ~0))  		 return FALSE; +	 if (!xdr_int (xdrs, &objp->port)) +		 return FALSE;  	return TRUE;  } @@ -59,6 +65,8 @@ xdr_gd1_mgmt_friend_rsp (XDR *xdrs, gd1_mgmt_friend_rsp *objp)  		 return FALSE;  	 if (!xdr_string (xdrs, &objp->hostname, ~0))  		 return FALSE; +	 if (!xdr_int (xdrs, &objp->port)) +		 return FALSE;  	 if (!xdr_int (xdrs, &objp->op_ret))  		 return FALSE;  	 if (!xdr_int (xdrs, &objp->op_errno)) @@ -75,6 +83,8 @@ xdr_gd1_mgmt_unfriend_req (XDR *xdrs, gd1_mgmt_unfriend_req *objp)  		 return FALSE;  	 if (!xdr_string (xdrs, &objp->hostname, ~0))  		 return FALSE; +	 if (!xdr_int (xdrs, &objp->port)) +		 return FALSE;  	return TRUE;  } @@ -87,6 +97,8 @@ xdr_gd1_mgmt_unfriend_rsp (XDR *xdrs, gd1_mgmt_unfriend_rsp *objp)  		 return FALSE;  	 if (!xdr_string (xdrs, &objp->hostname, ~0))  		 return FALSE; +	 if (!xdr_int (xdrs, &objp->port)) +		 return FALSE;  	 if (!xdr_int (xdrs, &objp->op_ret))  		 return FALSE;  	 if (!xdr_int (xdrs, &objp->op_errno)) @@ -214,5 +226,7 @@ xdr_gd1_mgmt_friend_update (XDR *xdrs, gd1_mgmt_friend_update *objp)  		 return FALSE;  	 if (!xdr_string (xdrs, &objp->hostname, ~0))  		 return FALSE; +	 if (!xdr_int (xdrs, &objp->port)) +		 return FALSE;  	return TRUE;  } diff --git a/rpc/xdr/src/glusterd1-xdr.h b/rpc/xdr/src/glusterd1-xdr.h index 2fab3fd3b..0fc186ed6 100644 --- a/rpc/xdr/src/glusterd1-xdr.h +++ b/rpc/xdr/src/glusterd1-xdr.h @@ -24,24 +24,28 @@ typedef enum glusterd_volume_status glusterd_volume_status;  struct gd1_mgmt_probe_req {  	u_char uuid[16];  	char *hostname; +        int port;  };  typedef struct gd1_mgmt_probe_req gd1_mgmt_probe_req;  struct gd1_mgmt_probe_rsp {  	u_char uuid[16];  	char *hostname; +        int port;  };  typedef struct gd1_mgmt_probe_rsp gd1_mgmt_probe_rsp;  struct gd1_mgmt_friend_req {  	u_char uuid[16];  	char *hostname; +        int port;  };  typedef struct gd1_mgmt_friend_req gd1_mgmt_friend_req;  struct gd1_mgmt_friend_rsp {  	u_char uuid[16];  	char *hostname; +        int port;  	int op_ret;  	int op_errno;  }; @@ -50,12 +54,14 @@ typedef struct gd1_mgmt_friend_rsp gd1_mgmt_friend_rsp;  struct gd1_mgmt_unfriend_req {  	u_char uuid[16];  	char *hostname; +        int port;  };  typedef struct gd1_mgmt_unfriend_req gd1_mgmt_unfriend_req;  struct gd1_mgmt_unfriend_rsp {  	u_char uuid[16];  	char *hostname; +        int port;  	int op_ret;  	int op_errno;  }; @@ -125,6 +131,7 @@ struct gd1_mgmt_friend_update {  	u_char uuid[16];  	u_char friend_uuid[16];  	char *hostname; +        int port;  };  typedef struct gd1_mgmt_friend_update gd1_mgmt_friend_update; diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index cd23362a6..308a761fd 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -126,13 +126,16 @@ glusterd_friend_find_by_uuid (uuid_t uuid,  }  static int -glusterd_handle_friend_req (rpcsvc_request_t *req, uuid_t  uuid, char *hostname) +glusterd_handle_friend_req (rpcsvc_request_t *req, uuid_t  uuid, char *hostname, int port)  {          int                             ret = -1;          glusterd_peerinfo_t             *peerinfo = NULL;          glusterd_friend_sm_event_t      *event = NULL;          glusterd_friend_req_ctx_t       *ctx = NULL; +        if (!port) +                port = 6969; // TODO: use define values. +          ret = glusterd_friend_find (uuid, hostname, &peerinfo);          if (ret) { @@ -189,13 +192,17 @@ out:  static int -glusterd_handle_unfriend_req (rpcsvc_request_t *req, uuid_t  uuid, char *hostname) +glusterd_handle_unfriend_req (rpcsvc_request_t *req, uuid_t  uuid, +                              char *hostname, int port)  {          int                             ret = -1;          glusterd_peerinfo_t             *peerinfo = NULL;          glusterd_friend_sm_event_t      *event = NULL;          glusterd_friend_req_ctx_t       *ctx = NULL; +        if (!port) +                port = 6969; //TODO: use define'd macro +          ret = glusterd_friend_find (uuid, hostname, &peerinfo);          if (ret) { @@ -272,6 +279,11 @@ glusterd_add_peer_detail_to_dict (glusterd_peerinfo_t   *peerinfo,          if (ret)                  goto out; +        snprintf (key, 256, "friend%d.port", count); +        ret = dict_set_int32 (friends, key, peerinfo->port); +        if (ret) +                goto out; +          snprintf (key, 256, "friend%d.state", count);          ret = dict_set_int32 (friends, key, (int32_t)peerinfo->state.state);          if (ret) @@ -519,14 +531,16 @@ glusterd_handle_cli_probe (rpcsvc_request_t *req)          if (!gf_xdr_to_cli_probe_req (req->msg[0], &cli_req)) {                  //failed to decode msg; +                gf_log ("", 1, "error");                  req->rpc_err = GARBAGE_ARGS;                  goto out;          } -        gf_log ("glusterd", GF_LOG_NORMAL, "Received CLI probe req"); +        gf_log ("glusterd", GF_LOG_NORMAL, "Received CLI probe req %s %d", +                cli_req.hostname, cli_req.port); -        ret = glusterd_probe_begin (req, cli_req.hostname); +        ret = glusterd_probe_begin (req, cli_req.hostname, cli_req.port);  out:          return ret; @@ -549,7 +563,7 @@ glusterd_handle_cli_deprobe (rpcsvc_request_t *req)          gf_log ("glusterd", GF_LOG_NORMAL, "Received CLI deprobe req"); -        ret = glusterd_deprobe_begin (req, cli_req.hostname); +        ret = glusterd_deprobe_begin (req, cli_req.hostname, cli_req.port);  out:          return ret; @@ -937,7 +951,7 @@ glusterd_handle_incoming_friend_req (rpcsvc_request_t *req)                  "Received probe from uuid: %s", str);          ret = glusterd_handle_friend_req (req, friend_req.uuid, -                                          friend_req.hostname); +                                          friend_req.hostname, friend_req.port);  out: @@ -963,7 +977,7 @@ glusterd_handle_incoming_unfriend_req (rpcsvc_request_t *req)                  "Received unfriend from uuid: %s", str);          ret = glusterd_handle_unfriend_req (req, friend_req.uuid, -                                            friend_req.hostname); +                                            friend_req.hostname, friend_req.port);  out: @@ -1003,7 +1017,7 @@ glusterd_handle_friend_update (rpcsvc_request_t *req)          if (!ret)                  goto out; -        ret = glusterd_friend_add (friend_req.hostname, +        ret = glusterd_friend_add (friend_req.hostname, friend_req.port,                                     GD_FRIEND_STATE_BEFRIENDED,                                     &friend_req.uuid, NULL, &peerinfo); @@ -1391,7 +1405,7 @@ unwind:  int -glusterd_friend_add (const char *hoststr, +glusterd_friend_add (const char *hoststr, int port,                       glusterd_friend_sm_state_t state,                       uuid_t *uuid,                       struct rpc_clnt    *rpc, @@ -1401,8 +1415,6 @@ glusterd_friend_add (const char *hoststr,          glusterd_conf_t         *priv = NULL;          glusterd_peerinfo_t     *peerinfo = NULL;          dict_t                  *options = NULL; -        char                    *port_str = NULL; -        int                     port_num = 0;          struct rpc_clnt_config  rpc_cfg = {0,};          glusterd_peer_hostname_t *name = NULL; @@ -1444,16 +1456,12 @@ glusterd_friend_add (const char *hoststr,                          goto out; -                port_str = getenv ("GLUSTERD_REMOTE_PORT"); -                if (port_str) -                        port_num = atoi (port_str); -                else -                        port_num = GLUSTERD_DEFAULT_PORT; +                if (!port) +                        port = GLUSTERD_DEFAULT_PORT; -                rpc_cfg.remote_port = port_num; -                gf_log ("glusterd", GF_LOG_NORMAL, "remote-port: %d", port_num); +                rpc_cfg.remote_port = port; -                ret = dict_set_int32 (options, "remote-port", port_num); +                ret = dict_set_int32 (options, "remote-port", port);                  if (ret)                          goto out; @@ -1487,7 +1495,7 @@ out:  int -glusterd_probe_begin (rpcsvc_request_t *req, const char *hoststr) +glusterd_probe_begin (rpcsvc_request_t *req, const char *hoststr, int port)  {          int                             ret = -1;          glusterd_peerinfo_t             *peerinfo = NULL; @@ -1501,8 +1509,8 @@ glusterd_probe_begin (rpcsvc_request_t *req, const char *hoststr)          if (ret) {                  gf_log ("glusterd", GF_LOG_NORMAL, "Unable to find peerinfo" -                                " for host: %s", hoststr); -                ret = glusterd_friend_add ((char *)hoststr, +                        " for host: %s (%d)", hoststr, port); +                ret = glusterd_friend_add ((char *)hoststr, port,                                             GD_FRIEND_STATE_DEFAULT,                                             NULL, NULL, &peerinfo);          } @@ -1522,6 +1530,7 @@ glusterd_probe_begin (rpcsvc_request_t *req, const char *hoststr)          }          ctx->hostname = gf_strdup (hoststr); +        ctx->port = port;          ctx->req = req;          event->peerinfo = peerinfo; @@ -1539,7 +1548,7 @@ glusterd_probe_begin (rpcsvc_request_t *req, const char *hoststr)  }  int -glusterd_deprobe_begin (rpcsvc_request_t *req, const char *hoststr) +glusterd_deprobe_begin (rpcsvc_request_t *req, const char *hoststr, int port)  {          int                             ret = -1;          glusterd_peerinfo_t             *peerinfo = NULL; @@ -1553,7 +1562,7 @@ glusterd_deprobe_begin (rpcsvc_request_t *req, const char *hoststr)          if (ret) {                  gf_log ("glusterd", GF_LOG_NORMAL, "Unable to find peerinfo" -                                " for host: %s", hoststr); +                        " for host: %s %d", hoststr, port);                  goto out;          } @@ -1573,10 +1582,11 @@ glusterd_deprobe_begin (rpcsvc_request_t *req, const char *hoststr)          ctx = GF_CALLOC (1, sizeof(*ctx), gf_gld_mt_probe_ctx_t);          if (!ctx) { -                return ret; +                goto out;          }          ctx->hostname = gf_strdup (hoststr); +        ctx->port = port;          ctx->req = req;          event->peerinfo = peerinfo; @@ -1587,7 +1597,7 @@ glusterd_deprobe_begin (rpcsvc_request_t *req, const char *hoststr)          if (ret) {                  gf_log ("glusterd", GF_LOG_ERROR, "Unable to inject event %d, "                          "ret = %d", event->event, ret); -                return ret; +                goto out;          }  out: @@ -1596,7 +1606,7 @@ out:  int -glusterd_xfer_friend_remove_resp (rpcsvc_request_t *req, char *hostname) +glusterd_xfer_friend_remove_resp (rpcsvc_request_t *req, char *hostname, int port)  {          gd1_mgmt_friend_rsp  rsp = {{0}, };          int32_t              ret = -1; @@ -1613,17 +1623,17 @@ glusterd_xfer_friend_remove_resp (rpcsvc_request_t *req, char *hostname)          uuid_copy (rsp.uuid, conf->uuid);          rsp.hostname = hostname; - +        rsp.port = port;          ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL,                                       gd_xdr_serialize_mgmt_friend_rsp);          gf_log ("glusterd", GF_LOG_NORMAL, -                "Responded to %s, ret: %d", hostname, ret); +                "Responded to %s (%d), ret: %d", hostname, port, ret);          return ret;  }  int -glusterd_xfer_friend_add_resp (rpcsvc_request_t *req, char *hostname) +glusterd_xfer_friend_add_resp (rpcsvc_request_t *req, char *hostname, int port)  {          gd1_mgmt_friend_rsp  rsp = {{0}, };          int32_t              ret = -1; @@ -1640,19 +1650,19 @@ glusterd_xfer_friend_add_resp (rpcsvc_request_t *req, char *hostname)          uuid_copy (rsp.uuid, conf->uuid);          rsp.hostname = gf_strdup (hostname); - +        rsp.port = port;          ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL,                                       gd_xdr_serialize_mgmt_friend_rsp);          gf_log ("glusterd", GF_LOG_NORMAL, -                "Responded to %s, ret: %d", hostname, ret); +                "Responded to %s (%d), ret: %d", hostname, port, ret);          return ret;  }  int  glusterd_xfer_cli_probe_resp (rpcsvc_request_t *req, int32_t op_ret, -                              int32_t op_errno, char *hostname) +                              int32_t op_errno, char *hostname, int port)  {          gf1_cli_probe_rsp    rsp = {0, };          int32_t              ret = -1; @@ -1662,6 +1672,7 @@ glusterd_xfer_cli_probe_resp (rpcsvc_request_t *req, int32_t op_ret,          rsp.op_ret = op_ret;          rsp.op_errno = op_errno;          rsp.hostname = hostname; +        rsp.port = port;          ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL,                                       gf_xdr_serialize_cli_probe_rsp); diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.c b/xlators/mgmt/glusterd/src/glusterd-sm.c index a5f760f36..817d520e1 100644 --- a/xlators/mgmt/glusterd/src/glusterd-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-sm.c @@ -75,7 +75,6 @@ glusterd_ac_friend_add (glusterd_friend_sm_event_t *event, void *ctx)          glusterd_conf_t         *conf = NULL;          xlator_t                *this = NULL; -          GF_ASSERT (event);          peerinfo = event->peerinfo; @@ -105,17 +104,16 @@ static int  glusterd_ac_friend_probe (glusterd_friend_sm_event_t *event, void *ctx)  {          int                     ret = -1; -        char                    *hostname = NULL;          rpc_clnt_procedure_t    *proc = NULL;          call_frame_t            *frame = NULL;          glusterd_conf_t         *conf = NULL;          xlator_t                *this = NULL;          glusterd_probe_ctx_t    *probe_ctx = NULL; +        dict_t                  *dict = NULL;          GF_ASSERT (ctx);          probe_ctx = ctx; -        hostname = probe_ctx->hostname;          this = THIS; @@ -135,11 +133,26 @@ glusterd_ac_friend_probe (glusterd_friend_sm_event_t *event, void *ctx)                          goto out;                  }                  frame->local = ctx; -                ret = proc->fn (frame, this, hostname); +                dict = dict_new (); +                if (!dict) +                        goto out; +                ret = dict_set_str (dict, "hostname", probe_ctx->hostname); +                if (ret) +                        goto out; + +                ret = dict_set_int32 (dict, "port", probe_ctx->port); +                if (ret) +                        goto out; +                ret = proc->fn (frame, this, dict); +                if (ret) +                        goto out; +          }  out: +        if (dict) +                dict_destroy (dict);          gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret);          return ret; @@ -233,7 +246,8 @@ glusterd_ac_handle_friend_remove_req (glusterd_friend_sm_event_t *event,          uuid_clear (peerinfo->uuid); -        ret = glusterd_xfer_friend_remove_resp (ev_ctx->req, ev_ctx->hostname); +        ret = glusterd_xfer_friend_remove_resp (ev_ctx->req, ev_ctx->hostname, +                                                ev_ctx->port);          rpc_clnt_destroy (peerinfo->rpc);          peerinfo->rpc = NULL; @@ -316,7 +330,8 @@ glusterd_ac_handle_friend_add_req (glusterd_friend_sm_event_t *event, void *ctx)          glusterd_friend_sm_inject_event (new_event); -        ret = glusterd_xfer_friend_add_resp (ev_ctx->req, ev_ctx->hostname); +        ret = glusterd_xfer_friend_add_resp (ev_ctx->req, ev_ctx->hostname, +                                             ev_ctx->port);  out:          gf_log ("", GF_LOG_DEBUG, "Returning with %d", ret); @@ -503,13 +518,14 @@ glusterd_friend_sm_inject_event (glusterd_friend_sm_event_t *event)  int  glusterd_friend_sm ()  { -        glusterd_friend_sm_event_t      *event = NULL; -        glusterd_friend_sm_event_t      *tmp = NULL; -        int                             ret = -1; -        glusterd_friend_sm_ac_fn        handler = NULL; -        glusterd_sm_t      *state = NULL; -        glusterd_peerinfo_t             *peerinfo = NULL; -        glusterd_friend_sm_event_type_t event_type = 0; +        glusterd_friend_sm_event_t      *event      = NULL; +        glusterd_friend_sm_event_t      *tmp        = NULL; +        int                              ret        = -1; +        glusterd_friend_sm_ac_fn         handler    = NULL; +        glusterd_sm_t                   *state      = NULL; +        glusterd_peerinfo_t             *peerinfo   = NULL; +        glusterd_friend_sm_event_type_t  event_type = 0; +        int                              port       = 6969; //TODO, use standard          while (!list_empty (&gd_friend_sm_queue)) {                  list_for_each_entry_safe (event, tmp, &gd_friend_sm_queue, list) { @@ -521,7 +537,7 @@ glusterd_friend_sm ()                          if (!peerinfo &&                             (GD_FRIEND_EVENT_PROBE == event_type ||                              GD_FRIEND_EVENT_RCVD_FRIEND_REQ == event_type)) { -                                ret = glusterd_friend_add (NULL, +                                ret = glusterd_friend_add (NULL, port,                                                            GD_FRIEND_STATE_DEFAULT,                                                            NULL, NULL, &peerinfo); diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.h b/xlators/mgmt/glusterd/src/glusterd-sm.h index ee1b4cc6b..72fc811e7 100644 --- a/xlators/mgmt/glusterd/src/glusterd-sm.h +++ b/xlators/mgmt/glusterd/src/glusterd-sm.h @@ -111,6 +111,7 @@ typedef struct glusterd_friend_req_ctx_ {          uuid_t                  uuid;          char                    *hostname;          rpcsvc_request_t        *req; +        int                      port;  } glusterd_friend_req_ctx_t;  typedef glusterd_friend_req_ctx_t glusterd_friend_update_ctx_t; @@ -118,6 +119,7 @@ typedef glusterd_friend_req_ctx_t glusterd_friend_update_ctx_t;  typedef struct glusterd_probe_ctx_ {          char                    *hostname;          rpcsvc_request_t        *req; +        int                      port;  } glusterd_probe_ctx_t;  int  glusterd_friend_sm_new_event (glusterd_friend_sm_event_type_t event_type, diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h index 1c483920a..963541b68 100644 --- a/xlators/mgmt/glusterd/src/glusterd.h +++ b/xlators/mgmt/glusterd/src/glusterd.h @@ -90,17 +90,17 @@ typedef ssize_t (*gd_serialize_t) (struct iovec outmsg, void *args);  #define GLUSTERD_GET_BRICK_PIDFILE(pidfile, volpath, hostname)\          snprintf (pidfile, PATH_MAX, "%s/run/%s.pid", volpath, hostname);  int -glusterd_probe_begin (rpcsvc_request_t *req, const char *hoststr); +glusterd_probe_begin (rpcsvc_request_t *req, const char *hoststr, int port);  int -glusterd_xfer_friend_add_resp (rpcsvc_request_t *req, char *hostname); +glusterd_xfer_friend_add_resp (rpcsvc_request_t *req, char *hostname, int port);  int  glusterd_friend_find (uuid_t uuid, char *hostname,                        glusterd_peerinfo_t **peerinfo);  int -glusterd_friend_add (const char *hoststr, +glusterd_friend_add (const char *hoststr, int port,                       glusterd_friend_sm_state_t state,                       uuid_t *uuid, struct rpc_clnt    *rpc,                       glusterd_peerinfo_t **friend); @@ -156,17 +156,17 @@ glusterd_handle_defrag_volume (rpcsvc_request_t *req);  int  glusterd_xfer_cli_probe_resp (rpcsvc_request_t *req, int32_t op_ret, -                              int32_t op_errno, char *hostname); +                              int32_t op_errno, char *hostname, int port);  int  glusterd_op_commit_send_resp (rpcsvc_request_t *req,                                 int32_t op, int32_t status);  int -glusterd_xfer_friend_remove_resp (rpcsvc_request_t *req, char *hostname); +glusterd_xfer_friend_remove_resp (rpcsvc_request_t *req, char *hostname, int port);  int -glusterd_deprobe_begin (rpcsvc_request_t *req, const char *hoststr); +glusterd_deprobe_begin (rpcsvc_request_t *req, const char *hoststr, int port);  int  glusterd_handle_cli_deprobe (rpcsvc_request_t *req); diff --git a/xlators/mgmt/glusterd/src/glusterd3_1-mops.c b/xlators/mgmt/glusterd/src/glusterd3_1-mops.c index 2dff9d654..8e0a958d8 100644 --- a/xlators/mgmt/glusterd/src/glusterd3_1-mops.c +++ b/xlators/mgmt/glusterd/src/glusterd3_1-mops.c @@ -163,8 +163,8 @@ glusterd3_1_friend_add_cbk (struct rpc_req * req, struct iovec *iov,          op_errno = rsp.op_errno;          gf_log ("glusterd", GF_LOG_NORMAL, -                "Received %s from uuid: %s, host: %s", -                (op_ret)?"RJT":"ACC", str, rsp.hostname); +                "Received %s from uuid: %s, host: %s, port: %d", +                (op_ret)?"RJT":"ACC", str, rsp.hostname, rsp.port);          ret = glusterd_friend_find (rsp.uuid, rsp.hostname, &peerinfo); @@ -206,7 +206,7 @@ glusterd3_1_friend_add_cbk (struct rpc_req * req, struct iovec *iov,          GF_ASSERT (ctx);          ret = glusterd_xfer_cli_probe_resp (ctx->req, op_ret, op_errno, -                                            ctx->hostname); +                                            ctx->hostname, ctx->port);          if (!ret) {                  glusterd_friend_sm ();                  glusterd_op_sm (); @@ -256,8 +256,8 @@ glusterd3_1_friend_remove_cbk (struct rpc_req * req, struct iovec *iov,          op_errno = rsp.op_errno;          gf_log ("glusterd", GF_LOG_NORMAL, -                "Received %s from uuid: %s, host: %s", -                (op_ret)?"RJT":"ACC", str, rsp.hostname); +                "Received %s from uuid: %s, host: %s, port: %d", +                (op_ret)?"RJT":"ACC", str, rsp.hostname, rsp.port);          if (op_ret)                  goto respond; @@ -292,7 +292,7 @@ glusterd3_1_friend_remove_cbk (struct rpc_req * req, struct iovec *iov,  respond:          ret = glusterd_xfer_cli_probe_resp (ctx->req, op_ret, op_errno, -                                            ctx->hostname); +                                            ctx->hostname, ctx->port);          if (!ret) {                  glusterd_friend_sm ();                  glusterd_op_sm (); @@ -580,19 +580,27 @@ glusterd3_1_probe (call_frame_t *frame, xlator_t *this,  {          gd1_mgmt_probe_req      req = {{0},};          int                     ret = 0; +        int                     port = 0;          char                    *hostname = NULL;          glusterd_peerinfo_t     *peerinfo = NULL;          glusterd_conf_t         *priv = NULL; +        dict_t                  *dict = NULL;          if (!frame || !this ||  !data) {                  ret = -1;                  goto out;          } -        hostname = data; +        dict = data;          priv = this->private;          GF_ASSERT (priv); +        ret = dict_get_str (dict, "hostname", &hostname); +        if (ret) +                goto out; +        ret = dict_get_int32 (dict, "port", &port); +        if (ret) +                port = 6969;          ret = glusterd_friend_find (NULL, hostname, &peerinfo); @@ -604,6 +612,7 @@ glusterd3_1_probe (call_frame_t *frame, xlator_t *this,          uuid_copy (req.uuid, priv->uuid);          req.hostname = gf_strdup (hostname); +        req.port = port;          ret = glusterd_submit_request (peerinfo, &req, frame, priv->mgmt,                                         GD_MGMT_PROBE_QUERY, @@ -644,7 +653,7 @@ glusterd3_1_friend_add (call_frame_t *frame, xlator_t *this,          uuid_copy (req.uuid, priv->uuid);          req.hostname = gf_strdup (peerinfo->hostname); - +        req.port = peerinfo->port;          ret = glusterd_submit_request (peerinfo, &req, frame, priv->mgmt,                                         GD_MGMT_FRIEND_ADD,                                         NULL, gd_xdr_from_mgmt_friend_req, @@ -683,7 +692,7 @@ glusterd3_1_friend_remove (call_frame_t *frame, xlator_t *this,          uuid_copy (req.uuid, priv->uuid);          req.hostname = peerinfo->hostname; - +        req.port = peerinfo->port;          ret = glusterd_submit_request (peerinfo, &req, frame, priv->mgmt,                                         GD_MGMT_FRIEND_REMOVE,                                         NULL, gd_xdr_from_mgmt_friend_req,  | 
