summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cli/src/cli-cmd-system.c37
-rw-r--r--cli/src/cli3_1-cops.c127
-rw-r--r--rpc/rpc-lib/src/protocol-common.h2
-rw-r--r--rpc/xdr/src/cli1-xdr.c35
-rw-r--r--rpc/xdr/src/cli1-xdr.h24
-rw-r--r--rpc/xdr/src/cli1.c28
-rw-r--r--rpc/xdr/src/cli1.h11
-rw-r--r--rpc/xdr/src/cli1.x14
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c278
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-mem-types.h3
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c22
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.h6
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-sm.c22
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-sm.h22
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c296
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.h19
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.c8
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.h6
-rw-r--r--xlators/mgmt/glusterd/src/glusterd3_1-mops.c7
19 files changed, 799 insertions, 168 deletions
diff --git a/cli/src/cli-cmd-system.c b/cli/src/cli-cmd-system.c
index 08fc44a..8d55144 100644
--- a/cli/src/cli-cmd-system.c
+++ b/cli/src/cli-cmd-system.c
@@ -129,6 +129,39 @@ out:
return ret;
}
+void
+cli_cmd_fsm_log_usage ()
+{
+ cli_out ("Usage: fsm log [<peer-name>]");
+}
+
+int
+cli_cmd_fsm_log (struct cli_state *state, struct cli_cmd_word *in_word,
+ const char **words, int wordcount)
+{
+ int ret = -1;
+ rpc_clnt_procedure_t *proc = NULL;
+ call_frame_t *frame = NULL;
+ char *name = "";
+
+ if ((wordcount != 3) && (wordcount != 2)) {
+ cli_cmd_fsm_log_usage ();
+ goto out;
+ }
+
+ if (wordcount == 3)
+ name = (char*)words[2];
+ proc = &cli_rpc_prog->proctable[GF1_CLI_FSM_LOG];
+ if (proc && proc->fn) {
+ frame = create_frame (THIS, THIS->ctx->pool);
+ if (!frame)
+ goto out;
+ ret = proc->fn (frame, THIS, (void*)name);
+ }
+out:
+ return ret;
+}
+
struct cli_cmd cli_system_cmds[] = {
{ GETSPEC_SYNTAX,
cli_cmd_getspec_cbk,
@@ -142,6 +175,10 @@ struct cli_cmd cli_system_cmds[] = {
cli_cmd_system_help_cbk,
"display help for system commands"},
+ { "fsm log [<peer-name>]",
+ cli_cmd_fsm_log,
+ "display fsm transitions"},
+
{ NULL, NULL, NULL }
};
diff --git a/cli/src/cli3_1-cops.c b/cli/src/cli3_1-cops.c
index b8985f7..7e885a0 100644
--- a/cli/src/cli3_1-cops.c
+++ b/cli/src/cli3_1-cops.c
@@ -330,15 +330,15 @@ out:
return ret;
}
-void
+void
cli_out_options ( char *substr, char *optstr, char *valstr)
{
char *ptr1 = NULL;
char *ptr2 = NULL;
-
+
ptr1 = substr;
ptr2 = optstr;
-
+
while (ptr1)
{
if (*ptr1 != *ptr2)
@@ -350,7 +350,7 @@ cli_out_options ( char *substr, char *optstr, char *valstr)
if (!ptr2)
return;
}
-
+
if (*ptr2 == '\0')
return;
cli_out ("%s: %s",ptr2 , valstr);
@@ -2228,6 +2228,122 @@ out:
return ret;
}
+static int
+gf_cli3_1_fsm_log_cbk (struct rpc_req *req, struct iovec *iov,
+ int count, void *myframe)
+{
+ gf1_cli_fsm_log_rsp rsp = {0,};
+ int ret = -1;
+ dict_t *dict = NULL;
+ int tr_count = 0;
+ char key[256] = {0};
+ int i = 0;
+ char *old_state = NULL;
+ char *new_state = NULL;
+ char *event = NULL;
+ char *time = NULL;
+
+ if (-1 == req->rpc_status) {
+ goto out;
+ }
+
+ ret = gf_xdr_to_cli_fsm_log_rsp (*iov, &rsp);
+ if (ret < 0) {
+ gf_log ("", GF_LOG_ERROR, "error");
+ goto out;
+ }
+
+ if (rsp.op_ret) {
+ if (strcmp (rsp.op_errstr, "")) {
+ cli_out (rsp.op_errstr);
+ } else if (rsp.op_ret) {
+ cli_out ("fsm log unsuccessful");
+ }
+ ret = rsp.op_ret;
+ goto out;
+ }
+
+ dict = dict_new ();
+ if (!dict) {
+ ret = -1;
+ goto out;
+ }
+
+ ret = dict_unserialize (rsp.fsm_log.fsm_log_val,
+ rsp.fsm_log.fsm_log_len,
+ &dict);
+
+ if (ret) {
+ cli_out ("bad response");
+ goto out;
+ }
+
+ ret = dict_get_int32 (dict, "count", &tr_count);
+ if (tr_count)
+ cli_out("number of transitions: %d", tr_count);
+ else
+ cli_out("No transitions");
+ for (i = 0; i < tr_count; i++) {
+ memset (key, 0, sizeof (key));
+ snprintf (key, sizeof (key), "log%d-old-state", i);
+ ret = dict_get_str (dict, key, &old_state);
+ if (ret)
+ goto out;
+
+ memset (key, 0, sizeof (key));
+ snprintf (key, sizeof (key), "log%d-event", i);
+ ret = dict_get_str (dict, key, &event);
+ if (ret)
+ goto out;
+
+ memset (key, 0, sizeof (key));
+ snprintf (key, sizeof (key), "log%d-new-state", i);
+ ret = dict_get_str (dict, key, &new_state);
+ if (ret)
+ goto out;
+
+ memset (key, 0, sizeof (key));
+ snprintf (key, sizeof (key), "log%d-time", i);
+ ret = dict_get_str (dict, key, &time);
+ if (ret)
+ goto out;
+ cli_out ("Old State: [%s]\n"
+ "New State: [%s]\n"
+ "Event : [%s]\n"
+ "timestamp: [%s]\n", old_state, new_state, event, time);
+ }
+
+ ret = rsp.op_ret;
+
+out:
+ cli_cmd_broadcast_response (ret);
+ return ret;
+}
+
+int32_t
+gf_cli3_1_fsm_log (call_frame_t *frame, xlator_t *this, void *data)
+{
+ int ret = -1;
+ gf1_cli_fsm_log_req req = {0,};
+
+ GF_ASSERT (frame);
+ GF_ASSERT (this);
+ GF_ASSERT (data);
+
+ if (!frame || !this || !data)
+ goto out;
+ req.name = data;
+ ret = cli_cmd_submit (&req, frame, cli_rpc_prog,
+ GD_MGMT_CLI_FSM_LOG, NULL,
+ gf_xdr_from_cli_fsm_log_req,
+ this, gf_cli3_1_fsm_log_cbk);
+
+out:
+ gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
+
+ return ret;
+}
+
struct rpc_clnt_procedure gluster3_1_cli_actors[GF1_CLI_MAXVALUE] = {
[GF1_CLI_NULL] = {"NULL", NULL },
[GF1_CLI_PROBE] = { "PROBE_QUERY", gf_cli3_1_probe},
@@ -2251,7 +2367,8 @@ struct rpc_clnt_procedure gluster3_1_cli_actors[GF1_CLI_MAXVALUE] = {
[GF1_CLI_GETSPEC] = {"GETSPEC", gf_cli3_1_getspec},
[GF1_CLI_PMAP_PORTBYBRICK] = {"PMAP PORTBYBRICK", gf_cli3_1_pmap_b2p},
[GF1_CLI_SYNC_VOLUME] = {"SYNC_VOLUME", gf_cli3_1_sync_volume},
- [GF1_CLI_RESET_VOLUME] = {"RESET_VOLUME", gf_cli3_1_reset_volume}
+ [GF1_CLI_RESET_VOLUME] = {"RESET_VOLUME", gf_cli3_1_reset_volume},
+ [GF1_CLI_FSM_LOG] = {"FSM_LOG", gf_cli3_1_fsm_log}
};
struct rpc_clnt_program cli3_1_prog = {
diff --git a/rpc/rpc-lib/src/protocol-common.h b/rpc/rpc-lib/src/protocol-common.h
index bfd043e..2fe7040 100644
--- a/rpc/rpc-lib/src/protocol-common.h
+++ b/rpc/rpc-lib/src/protocol-common.h
@@ -104,6 +104,7 @@ enum gf_mgmt_procnum_ {
GD_MGMT_CLI_LOG_ROTATE,
GD_MGMT_CLI_SYNC_VOLUME,
GD_MGMT_CLI_RESET_VOLUME,
+ GD_MGMT_CLI_FSM_LOG,
GD_MGMT_MAXVALUE,
};
@@ -133,6 +134,7 @@ enum gf_cli_procnum {
GF1_CLI_PMAP_PORTBYBRICK,
GF1_CLI_SYNC_VOLUME,
GF1_CLI_RESET_VOLUME,
+ GF1_CLI_FSM_LOG,
GF1_CLI_MAXVALUE,
};
diff --git a/rpc/xdr/src/cli1-xdr.c b/rpc/xdr/src/cli1-xdr.c
index 713648f..2db0c7c 100644
--- a/rpc/xdr/src/cli1-xdr.c
+++ b/rpc/xdr/src/cli1-xdr.c
@@ -25,6 +25,7 @@
#include "cli1.h"
#include "compat.h"
+
bool_t
xdr_gf1_cluster_type (XDR *xdrs, gf1_cluster_type *objp)
{
@@ -316,9 +317,9 @@ xdr_gf1_cli_stop_vol_rsp (XDR *xdrs, gf1_cli_stop_vol_rsp *objp)
return FALSE;
if (!xdr_string (xdrs, &objp->volname, ~0))
return FALSE;
- if (!xdr_string (xdrs, &objp->op_errstr, ~0))
- return FALSE;
- return TRUE;
+ if (!xdr_string (xdrs, &objp->op_errstr, ~0))
+ return FALSE;
+ return TRUE;
}
bool_t
@@ -512,8 +513,8 @@ xdr_gf1_cli_set_vol_rsp (XDR *xdrs, gf1_cli_set_vol_rsp *objp)
return FALSE;
if (!xdr_string (xdrs, &objp->volname, ~0))
return FALSE;
- if (!xdr_string (xdrs, &objp->op_errstr, ~0))
- return FALSE;
+ if (!xdr_string (xdrs, &objp->op_errstr, ~0))
+ return FALSE;
if (!xdr_bytes (xdrs, (char **)&objp->dict.dict_val, (u_int *) &objp->dict.dict_len, ~0))
return FALSE;
return TRUE;
@@ -618,3 +619,27 @@ xdr_gf1_cli_sync_volume_rsp (XDR *xdrs, gf1_cli_sync_volume_rsp *objp)
return FALSE;
return TRUE;
}
+
+bool_t
+xdr_gf1_cli_fsm_log_req (XDR *xdrs, gf1_cli_fsm_log_req *objp)
+{
+
+ if (!xdr_string (xdrs, &objp->name, ~0))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_gf1_cli_fsm_log_rsp (XDR *xdrs, gf1_cli_fsm_log_rsp *objp)
+{
+
+ if (!xdr_int (xdrs, &objp->op_ret))
+ return FALSE;
+ if (!xdr_int (xdrs, &objp->op_errno))
+ return FALSE;
+ if (!xdr_string (xdrs, &objp->op_errstr, ~0))
+ return FALSE;
+ if (!xdr_bytes (xdrs, (char **)&objp->fsm_log.fsm_log_val, (u_int *) &objp->fsm_log.fsm_log_len, ~0))
+ return FALSE;
+ return TRUE;
+}
diff --git a/rpc/xdr/src/cli1-xdr.h b/rpc/xdr/src/cli1-xdr.h
index 5bc3b03..38b5843 100644
--- a/rpc/xdr/src/cli1-xdr.h
+++ b/rpc/xdr/src/cli1-xdr.h
@@ -194,7 +194,7 @@ struct gf1_cli_stop_vol_rsp {
int op_ret;
int op_errno;
char *volname;
- char *op_errstr;
+ char *op_errstr;
};
typedef struct gf1_cli_stop_vol_rsp gf1_cli_stop_vol_rsp;
@@ -314,7 +314,7 @@ struct gf1_cli_set_vol_rsp {
int op_ret;
int op_errno;
char *volname;
- char *op_errstr;
+ char *op_errstr;
struct {
u_int dict_len;
char *dict_val;
@@ -376,6 +376,22 @@ struct gf1_cli_sync_volume_rsp {
};
typedef struct gf1_cli_sync_volume_rsp gf1_cli_sync_volume_rsp;
+struct gf1_cli_fsm_log_req {
+ char *name;
+};
+typedef struct gf1_cli_fsm_log_req gf1_cli_fsm_log_req;
+
+struct gf1_cli_fsm_log_rsp {
+ int op_ret;
+ int op_errno;
+ char *op_errstr;
+ struct {
+ u_int fsm_log_len;
+ char *fsm_log_val;
+ } fsm_log;
+};
+typedef struct gf1_cli_fsm_log_rsp gf1_cli_fsm_log_rsp;
+
/* the xdr functions */
#if defined(__STDC__) || defined(__cplusplus)
@@ -423,6 +439,8 @@ extern bool_t xdr_gf1_cli_log_locate_rsp (XDR *, gf1_cli_log_locate_rsp*);
extern bool_t xdr_gf1_cli_log_rotate_req (XDR *, gf1_cli_log_rotate_req*);
extern bool_t xdr_gf1_cli_log_rotate_rsp (XDR *, gf1_cli_log_rotate_rsp*);
extern bool_t xdr_gf1_cli_sync_volume_rsp (XDR *, gf1_cli_sync_volume_rsp*);
+extern bool_t xdr_gf1_cli_fsm_log_req (XDR *, gf1_cli_fsm_log_req*);
+extern bool_t xdr_gf1_cli_fsm_log_rsp (XDR *, gf1_cli_fsm_log_rsp*);
#else /* K&R C */
extern bool_t xdr_gf1_cluster_type ();
@@ -469,6 +487,8 @@ extern bool_t xdr_gf1_cli_log_locate_rsp ();
extern bool_t xdr_gf1_cli_log_rotate_req ();
extern bool_t xdr_gf1_cli_log_rotate_rsp ();
extern bool_t xdr_gf1_cli_sync_volume_rsp ();
+extern bool_t xdr_gf1_cli_fsm_log_req ();
+extern bool_t xdr_gf1_cli_fsm_log_rsp ();
#endif /* K&R C */
diff --git a/rpc/xdr/src/cli1.c b/rpc/xdr/src/cli1.c
index 41a97f9..14f3839 100644
--- a/rpc/xdr/src/cli1.c
+++ b/rpc/xdr/src/cli1.c
@@ -581,3 +581,31 @@ gf_xdr_from_cli_sync_volume_rsp (struct iovec outmsg, void *args)
return xdr_serialize_generic (outmsg, (void *)args,
(xdrproc_t)xdr_gf1_cli_sync_volume_rsp);
}
+
+ssize_t
+gf_xdr_to_cli_fsm_log_req (struct iovec inmsg, void *args)
+{
+ return xdr_to_generic (inmsg, (void *)args,
+ (xdrproc_t)xdr_gf1_cli_fsm_log_req);
+}
+
+ssize_t
+gf_xdr_from_cli_fsm_log_req (struct iovec outmsg, void *args)
+{
+ return xdr_serialize_generic (outmsg, (void *)args,
+ (xdrproc_t)xdr_gf1_cli_fsm_log_req);
+}
+
+ssize_t
+gf_xdr_to_cli_fsm_log_rsp (struct iovec inmsg, void *args)
+{
+ return xdr_to_generic (inmsg, (void *)args,
+ (xdrproc_t)xdr_gf1_cli_fsm_log_rsp);
+}
+
+ssize_t
+gf_xdr_from_cli_fsm_log_rsp (struct iovec outmsg, void *args)
+{
+ return xdr_serialize_generic (outmsg, (void *)args,
+ (xdrproc_t)xdr_gf1_cli_fsm_log_rsp);
+}
diff --git a/rpc/xdr/src/cli1.h b/rpc/xdr/src/cli1.h
index 8d9e167..d0c43d8 100644
--- a/rpc/xdr/src/cli1.h
+++ b/rpc/xdr/src/cli1.h
@@ -258,4 +258,15 @@ gf_xdr_to_cli_sync_volume_rsp (struct iovec inmsg, void *args);
ssize_t
gf_xdr_from_cli_sync_volume_rsp (struct iovec outmsg, void *args);
+ssize_t
+gf_xdr_to_cli_fsm_log_req (struct iovec inmsg, void *args);
+
+ssize_t
+gf_xdr_from_cli_fsm_log_req (struct iovec outmsg, void *args);
+
+ssize_t
+gf_xdr_to_cli_fsm_log_rsp (struct iovec inmsg, void *args);
+
+ssize_t
+gf_xdr_from_cli_fsm_log_rsp (struct iovec outmsg, void *args);
#endif /* !_CLI1_H */
diff --git a/rpc/xdr/src/cli1.x b/rpc/xdr/src/cli1.x
index d729548..0ac34ae 100644
--- a/rpc/xdr/src/cli1.x
+++ b/rpc/xdr/src/cli1.x
@@ -10,7 +10,8 @@
GF_REPLACE_OP_COMMIT,
GF_REPLACE_OP_PAUSE,
GF_REPLACE_OP_ABORT,
- GF_REPLACE_OP_STATUS
+ GF_REPLACE_OP_STATUS,
+ GF_REPLACE_OP_COMMIT_FORCE
} ;
enum gf1_cli_friends_list {
@@ -269,3 +270,14 @@ struct gf1_cli_sync_volume_rsp {
int op_errno;
string op_errstr<>;
};
+
+struct gf1_cli_fsm_log_req {
+ string name<>;
+};
+
+struct gf1_cli_fsm_log_rsp {
+ int op_ret;
+ int op_errno;
+ string op_errstr<>;
+ opaque fsm_log<>;
+};
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 930c3a4..20d2efa 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -86,6 +86,8 @@ glusterd_handle_friend_req (rpcsvc_request_t *req, uuid_t uuid,
if (ret) {
ret = glusterd_xfer_friend_add_resp (req, rhost, port, -1,
GF_PROBE_UNKNOWN_PEER);
+ if (friend_req->vols.vols_val)
+ free (friend_req->vols.vols_val);
goto out;
}
@@ -164,7 +166,6 @@ out:
return ret;
}
-
static int
glusterd_handle_unfriend_req (rpcsvc_request_t *req, uuid_t uuid,
char *hostname, int port)
@@ -1879,6 +1880,85 @@ out:
}
int
+glusterd_fsm_log_send_resp (rpcsvc_request_t *req, int op_ret,
+ char *op_errstr, dict_t *dict)
+{
+
+ int ret = -1;
+ gf1_cli_fsm_log_rsp rsp = {0};
+
+ GF_ASSERT (req);
+ GF_ASSERT (op_errstr);
+
+ rsp.op_ret = op_ret;
+ rsp.op_errstr = op_errstr;
+ if (rsp.op_ret == 0)
+ ret = dict_allocate_and_serialize (dict, &rsp.fsm_log.fsm_log_val,
+ (size_t *)&rsp.fsm_log.fsm_log_len);
+
+ ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL,
+ gf_xdr_from_cli_fsm_log_rsp);
+ if (rsp.fsm_log.fsm_log_val)
+ GF_FREE (rsp.fsm_log.fsm_log_val);
+
+ gf_log ("glusterd", GF_LOG_DEBUG, "Responded, ret: %d", ret);
+
+ return 0;
+}
+
+int
+glusterd_handle_fsm_log (rpcsvc_request_t *req)
+{
+ int32_t ret = -1;
+ gf1_cli_fsm_log_req cli_req = {0,};
+ dict_t *dict = NULL;
+ glusterd_sm_tr_log_t *log = NULL;
+ xlator_t *this = NULL;
+ glusterd_conf_t *conf = NULL;
+ char msg[2048] = {0};
+ glusterd_peerinfo_t *peerinfo = NULL;
+
+ GF_ASSERT (req);
+
+ if (!gf_xdr_to_cli_fsm_log_req (req->msg[0], &cli_req)) {
+ //failed to decode msg;
+ req->rpc_err = GARBAGE_ARGS;
+ snprintf (msg, sizeof (msg), "Garbage request");
+ goto out;
+ }
+
+ if (strcmp ("", cli_req.name) == 0) {
+ this = THIS;
+ conf = this->private;
+ log = &conf->op_sm_log;
+ } else {
+ ret = glusterd_friend_find_by_hostname (cli_req.name,
+ &peerinfo);
+ if (ret) {
+ snprintf (msg, sizeof (msg), "%s is not a peer",
+ cli_req.name);
+ goto out;
+ }
+ log = &peerinfo->sm_log;
+ }
+
+ dict = dict_new ();
+ if (!dict) {
+ ret = -1;
+ goto out;
+ }
+
+ ret = glusterd_sm_tr_log_add_to_dict (dict, log);
+out:
+ (void)glusterd_fsm_log_send_resp (req, ret, msg, dict);
+ if (cli_req.name)
+ free (cli_req.name);//malloced by xdr
+ if (dict)
+ dict_unref (dict);
+ return 0;//send 0 to avoid double reply
+}
+
+int
glusterd_op_lock_send_resp (rpcsvc_request_t *req, int32_t status)
{
@@ -2335,147 +2415,157 @@ out:
}
int
-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,
- gf_boolean_t restore,
- glusterd_peerctx_args_t *args)
+glusterd_friend_rpc_create (struct rpc_clnt **rpc,
+ const char *hoststr, int port,
+ glusterd_peerctx_t *peerctx)
{
- int ret = 0;
- glusterd_conf_t *priv = NULL;
- glusterd_peerinfo_t *peerinfo = NULL;
+ struct rpc_clnt *new_rpc = NULL;
dict_t *options = NULL;
struct rpc_clnt_config rpc_cfg = {0,};
- glusterd_peer_hostname_t *name = NULL;
+ int ret = -1;
char *hostname = NULL;
- glusterd_peerctx_t *peerctx = NULL;
int32_t intvl = 0;
+ xlator_t *this = NULL;
- priv = THIS->private;
+ GF_ASSERT (hoststr);
+ this = THIS;
+ GF_ASSERT (this);
- peerctx = GF_CALLOC (1, sizeof (*peerctx), gf_gld_mt_peerctx_t);
- if (!peerctx) {
- ret = -1;
+ options = dict_new ();
+ if (!options)
goto out;
- }
- peerinfo = GF_CALLOC (1, sizeof (*peerinfo), gf_gld_mt_peerinfo_t);
- if (!peerinfo) {
- ret = -1;
- goto out;
+ ret = dict_get_int32 (this->options,
+ "transport.socket.keepalive-interval",
+ &intvl);
+ if (!ret) {
+ ret = dict_set_int32 (options,
+ "transport.socket.keepalive-interval", intvl);
+ if (ret)
+ goto out;
}
- if (args)
- peerctx->args = *args;
- peerctx->peerinfo = peerinfo;
- if (friend)
- *friend = peerinfo;
-
- INIT_LIST_HEAD (&peerinfo->hostnames);
- peerinfo->state.state = state;
- if (hoststr) {
- ret = glusterd_peer_hostname_new ((char *)hoststr, &name);
+ ret = dict_get_int32 (this->options,
+ "transport.socket.keepalive-time",
+ &intvl);
+ if (!ret) {
+ ret = dict_set_int32 (options,
+ "transport.socket.keepalive-time", intvl);
if (ret)
goto out;
- list_add_tail (&peerinfo->hostnames, &name->hostname_list);
- rpc_cfg.remote_host = (char *)hoststr;
- peerinfo->hostname = gf_strdup (hoststr);
}
- INIT_LIST_HEAD (&peerinfo->uuid_list);
-
- list_add_tail (&peerinfo->uuid_list, &priv->peers);
- if (uuid) {
- uuid_copy (peerinfo->uuid, *uuid);
+ hostname = gf_strdup((char*)hoststr);
+ if (!hostname) {
+ ret = -1;
+ goto out;
}
+ ret = dict_set_dynstr (options, "remote-host", hostname);
+ if (ret)
+ goto out;
- if (hoststr) {
- options = dict_new ();
- if (!options) {
- ret = -1;
- goto out;
- }
+ if (!port)
+ port = GLUSTERD_DEFAULT_PORT;
- ret = dict_get_int32 (THIS->options,
- "transport.socket.keepalive-interval",
- &intvl);
- if (!ret) {
- ret = dict_set_int32 (options,
- "transport.socket.keepalive-interval", intvl);
- if (ret)
- goto out;
- }
+ rpc_cfg.remote_host = (char *)hoststr;
+ rpc_cfg.remote_port = port;
- ret = dict_get_int32 (THIS->options,
- "transport.socket.keepalive-time",
- &intvl);
- if (!ret) {
- ret = dict_set_int32 (options,
- "transport.socket.keepalive-time", intvl);
- if (ret)
- goto out;
- }
+ ret = dict_set_int32 (options, "remote-port", port);
+ if (ret)
+ goto out;
- hostname = gf_strdup((char*)hoststr);
- if (!hostname) {
- ret = -1;
- goto out;
- }
+ ret = dict_set_str (options, "transport.address-family", "inet");
+ if (ret)
+ goto out;
- ret = dict_set_dynstr (options, "remote-host", hostname);
- if (ret)
- goto out;
+ new_rpc = rpc_clnt_init (&rpc_cfg, options, this->ctx, this->name);
+ if (!new_rpc) {
+ gf_log ("glusterd", GF_LOG_ERROR,
+ "new_rpc init failed for peer: %s!", hoststr);
+ ret = -1;
+ goto out;
+ }
- if (!port)
- port = GLUSTERD_DEFAULT_PORT;
+ ret = rpc_clnt_register_notify (new_rpc, glusterd_rpc_notify,
+ peerctx);
+ *rpc = new_rpc;
+out:
+ if (ret) {
+ if (new_rpc) {
+ (void) rpc_clnt_unref (new_rpc);
+ }
+ if (options)
+ dict_unref (options);
+ *rpc = NULL;
+ }
- rpc_cfg.remote_port = port;
+ gf_log ("", GF_LOG_DEBUG, "returning %d");
+ return ret;
+}
- ret = dict_set_int32 (options, "remote-port", port);
- if (ret)
- goto out;
+int
+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,
+ gf_boolean_t restore,
+ glusterd_peerctx_args_t *args)
+{
+ int ret = 0;
+ glusterd_conf_t *conf = NULL;
+ glusterd_peerinfo_t *peerinfo = NULL;
+ glusterd_peerctx_t *peerctx = NULL;
+ gf_boolean_t is_allocated = _gf_false;
- ret = dict_set_str (options, "transport.address-family", "inet");
- if (ret)
- goto out;
+ conf = THIS->private;
+ GF_ASSERT (conf)
- rpc = rpc_clnt_init (&rpc_cfg, options, THIS->ctx, THIS->name);
+ peerctx = GF_CALLOC (1, sizeof (*peerctx), gf_gld_mt_peerctx_t);
+ if (!peerctx) {
+ ret = -1;
+ goto out;
+ }
- if (!rpc) {
- gf_log ("glusterd", GF_LOG_ERROR,
- "rpc init failed for peer: %s!", hoststr);
- ret = -1;
- goto out;
- }
+ if (args)
+ peerctx->args = *args;
- ret = rpc_clnt_register_notify (rpc, glusterd_rpc_notify,
- peerctx);
+ ret = glusterd_peerinfo_new (&peerinfo, state, uuid, hoststr);
+ if (ret)
+ goto out;
+ peerctx->peerinfo = peerinfo;
+ if (friend)
+ *friend = peerinfo;
+ if (hoststr) {
+ if (!rpc) {
+ ret = glusterd_friend_rpc_create (&rpc, hoststr, port,
+ peerctx);
+ if (ret)
+ goto out;
+ is_allocated = _gf_true;
+ }
peerinfo->rpc = rpc;
-
}
if (!restore)
ret = glusterd_store_update_peerinfo (peerinfo);
+ list_add_tail (&peerinfo->uuid_list, &conf->peers);
out:
if (ret) {
if (peerctx)
GF_FREE (peerctx);
- if (rpc) {
+ if (is_allocated && rpc) {
(void) rpc_clnt_unref (rpc);
}
if (peerinfo) {
peerinfo->rpc = NULL;
(void) glusterd_friend_cleanup (peerinfo);
}
- if (options)
- dict_unref (options);
}
gf_log ("glusterd", GF_LOG_NORMAL, "connect returned %d", ret);
diff --git a/xlators/mgmt/glusterd/src/glusterd-mem-types.h b/xlators/mgmt/glusterd/src/glusterd-mem-types.h
index 5ee9375..5a4da80 100644
--- a/xlators/mgmt/glusterd/src/glusterd-mem-types.h
+++ b/xlators/mgmt/glusterd/src/glusterd-mem-types.h
@@ -59,7 +59,8 @@ enum gf_gld_mem_types_ {
gf_gld_mt_log_locate_ctx_t = gf_common_mt_end + 33,
gf_gld_mt_log_rotate_ctx_t = gf_common_mt_end + 34,
gf_gld_mt_peerctx_t = gf_common_mt_end + 35,
- gf_gld_mt_end = gf_common_mt_end + 36
+ gf_gld_mt_sm_tr_log_t = gf_common_mt_end + 36,
+ gf_gld_mt_end = gf_common_mt_end + 37
};
#endif
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 93eeb38..bc9cb33 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -87,7 +87,7 @@ static char *glusterd_op_sm_event_names[] = {
};
char*
-glusterd_op_sm_state_name_get (glusterd_op_sm_state_t state)
+glusterd_op_sm_state_name_get (int state)
{
if (state < 0 || state >= GD_OP_STATE_MAX)
return glusterd_op_sm_state_names[GD_OP_STATE_MAX];
@@ -95,7 +95,7 @@ glusterd_op_sm_state_name_get (glusterd_op_sm_state_t state)
}
char*
-glusterd_op_sm_event_name_get (glusterd_op_sm_event_type_t event)
+glusterd_op_sm_event_name_get (int event)
{
if (event < 0 || event >= GD_OP_EVENT_MAX)
return glusterd_op_sm_event_names[GD_OP_EVENT_MAX];
@@ -4772,15 +4772,19 @@ glusterd_op_sm_transition_state (glusterd_op_info_t *opinfo,
glusterd_op_sm_t *state,
glusterd_op_sm_event_type_t event_type)
{
+ glusterd_conf_t *conf = NULL;
GF_ASSERT (state);
GF_ASSERT (opinfo);
- gf_log ("", GF_LOG_NORMAL, "Transitioning from '%s' to '%s' due to "
- "event '%s'",
- glusterd_op_sm_state_name_get (opinfo->state.state),
- glusterd_op_sm_state_name_get (state[event_type].next_state),
- glusterd_op_sm_event_name_get (event_type));
+ conf = THIS->private;
+ GF_ASSERT (conf);
+
+ (void) glusterd_sm_tr_log_transition_add (&conf->op_sm_log,
+ opinfo->state.state,
+ state[event_type].next_state,
+ event_type);
+
opinfo->state.state = state[event_type].next_state;
return 0;
}
@@ -5100,7 +5104,7 @@ glusterd_op_sm_inject_event (glusterd_op_sm_event_type_t event_type,
event->ctx = ctx;
- gf_log ("glusterd", GF_LOG_NORMAL, "Enqueuing event: '%s'",
+ gf_log ("glusterd", GF_LOG_DEBUG, "Enqueuing event: '%s'",
glusterd_op_sm_event_name_get (event->event));
list_add_tail (&event->list, &gd_op_sm_queue);
@@ -5148,7 +5152,7 @@ glusterd_op_sm ()
list_del_init (&event->list);
event_type = event->event;
- gf_log ("", GF_LOG_NORMAL, "Dequeued event of type: '%s'",
+ gf_log ("", GF_LOG_DEBUG, "Dequeued event of type: '%s'",
glusterd_op_sm_event_name_get(event_type));
state = glusterd_op_state_table[opinfo.state.state];
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.h b/xlators/mgmt/glusterd/src/glusterd-op-sm.h
index f658805..2731478 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.h
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.h
@@ -228,4 +228,10 @@ void
glusterd_do_replace_brick (void *data);
int
glusterd_options_reset (glusterd_volinfo_t *volinfo);
+
+char*
+glusterd_op_sm_state_name_get (int state);
+
+char*
+glusterd_op_sm_event_name_get (int event);
#endif
diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.c b/xlators/mgmt/glusterd/src/glusterd-sm.c
index d862a69..d572ee7 100644
--- a/xlators/mgmt/glusterd/src/glusterd-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-sm.c
@@ -75,7 +75,7 @@ static char *glusterd_friend_sm_event_names[] = {
};
char*
-glusterd_friend_sm_state_name_get (glusterd_friend_sm_state_t state)
+glusterd_friend_sm_state_name_get (int state)
{
if (state < 0 || state >= GD_FRIEND_STATE_MAX)
return glusterd_friend_sm_state_names[GD_FRIEND_STATE_MAX];
@@ -83,7 +83,7 @@ glusterd_friend_sm_state_name_get (glusterd_friend_sm_state_t state)
}
char*
-glusterd_friend_sm_event_name_get (glusterd_friend_sm_event_type_t event)
+glusterd_friend_sm_event_name_get (int event)
{
if (event < 0 || event >= GD_FRIEND_EVENT_MAX)
return glusterd_friend_sm_event_names[GD_FRIEND_EVENT_MAX];
@@ -538,13 +538,10 @@ glusterd_friend_sm_transition_state (glusterd_peerinfo_t *peerinfo,
GF_ASSERT (state);
GF_ASSERT (peerinfo);
- //peerinfo->state.state = state;
-
- gf_log ("", GF_LOG_NORMAL, "Transitioning from '%s' to '%s' due to "
- "event '%s'",
- glusterd_friend_sm_state_name_get (peerinfo->state.state),
- glusterd_friend_sm_state_name_get (state[event_type].next_state),
- glusterd_friend_sm_event_name_get (event_type));
+ (void) glusterd_sm_tr_log_transition_add (&peerinfo->sm_log,
+ peerinfo->state.state,
+ state[event_type].next_state,
+ event_type);
peerinfo->state.state = state[event_type].next_state;
return 0;
@@ -717,7 +714,7 @@ int
glusterd_friend_sm_inject_event (glusterd_friend_sm_event_t *event)
{
GF_ASSERT (event);
- gf_log ("glusterd", GF_LOG_NORMAL, "Enqueuing event: '%s'",
+ gf_log ("glusterd", GF_LOG_DEBUG, "Enqueuing event: '%s'",
glusterd_friend_sm_event_name_get (event->event));
list_add_tail (&event->list, &gd_friend_sm_queue);
@@ -767,11 +764,14 @@ glusterd_friend_sm ()
if (!peerinfo) {
gf_log ("glusterd", GF_LOG_CRITICAL, "Received"
" event %s with empty peer info",
- glusterd_friend_sm_event_name_get(event_type));
+ glusterd_friend_sm_event_name_get (event_type));
GF_FREE (event);
continue;
}
+ gf_log ("", GF_LOG_DEBUG, "Dequeued event of type: '%s'",
+ glusterd_friend_sm_event_name_get (event_type));
+
state = glusterd_friend_state_table[peerinfo->state.state];
diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.h b/xlators/mgmt/glusterd/src/glusterd-sm.h
index ebe6cb3..41ec269 100644
--- a/xlators/mgmt/glusterd/src/glusterd-sm.h
+++ b/xlators/mgmt/glusterd/src/glusterd-sm.h
@@ -68,6 +68,22 @@ typedef struct glusterd_peer_hostname_ {
struct list_head hostname_list;
}glusterd_peer_hostname_t;
+typedef struct glusterd_sm_transition_ {
+ int old_state;
+ int event;
+ int new_state;
+ time_t time;
+} glusterd_sm_transition_t;
+
+typedef struct glusterd_sm_tr_log_ {
+ glusterd_sm_transition_t *transitions;
+ size_t current;
+ size_t size;
+ size_t count;
+ char* (*state_name_get) (int);
+ char* (*event_name_get) (int);
+} glusterd_sm_tr_log_t;
+
struct glusterd_peerinfo_ {
uuid_t uuid;
char uuid_str[50];
@@ -80,6 +96,7 @@ struct glusterd_peerinfo_ {
struct rpc_clnt *rpc;
int connected;
glusterd_store_handle_t *shandle;
+ glusterd_sm_tr_log_t sm_log;
};
typedef struct glusterd_peerinfo_ glusterd_peerinfo_t;
@@ -178,7 +195,10 @@ void
glusterd_destroy_friend_req_ctx (glusterd_friend_req_ctx_t *ctx);
char*
-glusterd_friend_sm_state_name_get (glusterd_friend_sm_state_t state);
+glusterd_friend_sm_state_name_get (int state);
+
+char*
+glusterd_friend_sm_event_name_get (int event);
int
glusterd_broadcast_friend_delete (char *hostname, uuid_t uuid);
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 0634c4b..cffd9db 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -765,7 +765,8 @@ glusterd_friend_cleanup (glusterd_peerinfo_t *peerinfo)
peerinfo->rpc->mydata = NULL;
peerinfo->rpc = rpc_clnt_unref (peerinfo->rpc);
peerinfo->rpc = NULL;
- GF_FREE (peerctx);
+ if (peerctx)
+ GF_FREE (peerctx);
}
glusterd_peer_destroy (peerinfo);
@@ -1052,43 +1053,6 @@ out:
return ret;
}
-int32_t
-glusterd_peer_destroy (glusterd_peerinfo_t *peerinfo)
-{
- int32_t ret = -1;
- glusterd_peer_hostname_t *name = NULL;
- glusterd_peer_hostname_t *tmp = NULL;
-
- if (!peerinfo)
- goto out;
-
- ret = glusterd_store_delete_peerinfo (peerinfo);
-
- if (ret) {
- gf_log ("", GF_LOG_ERROR, "Deleting peer info failed");
- }
-
- list_del_init (&peerinfo->uuid_list);
- list_for_each_entry_safe (name, tmp, &peerinfo->hostnames,
- hostname_list) {
- list_del_init (&name->hostname_list);
- GF_FREE (name->hostname);
- GF_FREE (name);
- }
-
- list_del_init (&peerinfo->hostnames);
- if (peerinfo->hostname)
- GF_FREE (peerinfo->hostname);
- GF_FREE (peerinfo);
- peerinfo = NULL;
-
- ret = 0;
-
-out:
- return ret;
-}
-
-
gf_boolean_t
glusterd_is_cli_op_req (int32_t op)
{
@@ -2429,3 +2393,259 @@ out:
gf_log ("", GF_LOG_DEBUG, "returning %d", ret);
return ret;
}
+
+int
+glusterd_sm_tr_log_transition_add_to_dict (dict_t *dict,
+ glusterd_sm_tr_log_t *log, int i,
+ int count)
+{
+ int ret = -1;
+ char key[512] = {0};
+ char timestr[256] = {0,};
+ char *str = NULL;
+ struct tm tm = {0};
+
+ GF_ASSERT (dict);
+ GF_ASSERT (log);
+
+ memset (key, 0, sizeof (key));
+ snprintf (key, sizeof (key), "log%d-old-state", count);
+ str = log->state_name_get (log->transitions[i].old_state);
+ ret = dict_set_str (dict, key, str);
+ if (ret)
+ goto out;
+
+ memset (key, 0, sizeof (key));
+ snprintf (key, sizeof (key), "log%d-event", count);
+ str = log->event_name_get (log->transitions[i].event);
+ ret = dict_set_str (dict, key, str);
+ if (ret)
+ goto out;
+
+ memset (key, 0, sizeof (key));
+ snprintf (key, sizeof (key), "log%d-new-state", count);
+ str = log->state_name_get (log->transitions[i].new_state);
+ ret = dict_set_str (dict, key, str);
+ if (ret)
+ goto out;
+
+
+ memset (key, 0, sizeof (key));
+ snprintf (key, sizeof (key), "log%d-time", count);
+ localtime_r ((const time_t*)&log->transitions[i].time, &tm);
+ memset (timestr, 0, sizeof (timestr));
+ strftime (timestr, 256, "%Y-%m-%d %H:%M:%S", &tm);
+ str = gf_strdup (timestr);
+ ret = dict_set_dynstr (dict, key, str);
+ if (ret)
+ goto out;
+
+out:
+ gf_log ("", GF_LOG_DEBUG, "returning %d", ret);
+ return ret;
+}
+
+int
+glusterd_sm_tr_log_add_to_dict (dict_t *dict,
+ glusterd_sm_tr_log_t *circular_log)
+{
+ int ret = -1;
+ int i = 0;
+ int start = 0;
+ int end = 0;
+ int index = 0;
+ char key[256] = {0};
+ glusterd_sm_tr_log_t *log = NULL;
+ int count = 0;
+
+ GF_ASSERT (dict);
+ GF_ASSERT (circular_log);
+
+ log = circular_log;
+ if (!log->count)
+ return 0;
+
+ if (log->count == log->size)
+ start = log->current + 1;
+
+ end = start + log->count;
+ for (i = start; i < end; i++, count++) {
+ index = i % log->count;
+ ret = glusterd_sm_tr_log_transition_add_to_dict (dict, log, index,
+ count);
+ if (ret)
+ goto out;
+ }
+
+ memset (key, 0, sizeof (key));
+ snprintf (key, sizeof (key), "count");
+ ret = dict_set_int32 (dict, key, log->count);
+
+out:
+ gf_log ("", GF_LOG_DEBUG, "returning %d", ret);
+ return ret;
+}
+
+int
+glusterd_sm_tr_log_init (glusterd_sm_tr_log_t *log,
+ char * (*state_name_get) (int),
+ char * (*event_name_get) (int),
+ size_t size)
+{
+ glusterd_sm_transition_t *transitions = NULL;
+ int ret = -1;
+
+ GF_ASSERT (size > 0);
+ GF_ASSERT (log && state_name_get && event_name_get);
+
+ if (!log || !state_name_get || !event_name_get || (size <= 0))
+ goto out;
+
+ transitions = GF_CALLOC (size, sizeof (*transitions),
+ gf_gld_mt_sm_tr_log_t);
+ if (!transitions)
+ goto out;
+
+ log->transitions = transitions;
+ log->size = size;
+ log->state_name_get = state_name_get;
+ log->event_name_get = event_name_get;
+ ret = 0;
+
+out:
+ gf_log ("", GF_LOG_DEBUG, "returning %d", ret);
+ return ret;
+}
+
+void
+glusterd_sm_tr_log_delete (glusterd_sm_tr_log_t *log)
+{
+ if (!log)
+ return;
+ if (log->transitions)
+ GF_FREE (log->transitions);
+ return;
+}
+
+int
+glusterd_sm_tr_log_transition_add (glusterd_sm_tr_log_t *log,
+ int old_state, int new_state,
+ int event)
+{
+ glusterd_sm_transition_t *transitions = NULL;
+ int ret = -1;
+ int next = 0;
+
+ GF_ASSERT (log);
+ if (!log)
+ goto out;
+
+ transitions = log->transitions;
+ if (!transitions)
+ goto out;
+
+ if (log->count)
+ next = (log->current + 1) % log->size;
+ else
+ next = 0;
+
+ transitions[next].old_state = old_state;
+ transitions[next].new_state = new_state;
+ transitions[next].event = event;
+ time (&transitions[next].time);
+ log->current = next;
+ if (log->count < log->size)
+ log->count++;
+ ret = 0;
+ gf_log ("glusterd", GF_LOG_DEBUG, "Transitioning from '%s' to '%s' "
+ "due to event '%s'", log->state_name_get (old_state),
+ log->state_name_get (new_state), log->event_name_get (event));
+out:
+ gf_log ("", GF_LOG_DEBUG, "returning %d", ret);
+ return ret;
+}
+
+int
+glusterd_peerinfo_new (glusterd_peerinfo_t **peerinfo,
+ glusterd_friend_sm_state_t state,
+ uuid_t *uuid, const char *hostname)
+{
+ glusterd_peerinfo_t *new_peer = NULL;
+ glusterd_peer_hostname_t *name = NULL;
+ int ret = -1;
+
+ GF_ASSERT (peerinfo);
+ if (!peerinfo)
+ goto out;
+
+ new_peer = GF_CALLOC (1, sizeof (*new_peer), gf_gld_mt_peerinfo_t);
+ if (!new_peer)
+ goto out;
+
+ INIT_LIST_HEAD (&new_peer->hostnames);
+ new_peer->state.state = state;
+ if (hostname) {
+ ret = glusterd_peer_hostname_new ((char *)hostname, &name);
+ if (ret)
+ goto out;
+ list_add_tail (&new_peer->hostnames, &name->hostname_list);
+ new_peer->hostname = gf_strdup (hostname);
+ }
+
+ INIT_LIST_HEAD (&new_peer->uuid_list);
+
+ if (uuid) {
+ uuid_copy (new_peer->uuid, *uuid);
+ }
+
+ ret = glusterd_sm_tr_log_init (&new_peer->sm_log,
+ glusterd_friend_sm_state_name_get,
+ glusterd_friend_sm_event_name_get,
+ GLUSTERD_TR_LOG_SIZE);
+ if (ret)
+ goto out;
+
+ *peerinfo = new_peer;
+out:
+ if (ret && new_peer)
+ glusterd_friend_cleanup (new_peer);
+ gf_log ("", GF_LOG_DEBUG, "returning %d", ret);
+ return ret;
+}
+
+int32_t
+glusterd_peer_destroy (glusterd_peerinfo_t *peerinfo)
+{
+ int32_t ret = -1;
+ glusterd_peer_hostname_t *name = NULL;
+ glusterd_peer_hostname_t *tmp = NULL;
+
+ if (!peerinfo)
+ goto out;
+
+ ret = glusterd_store_delete_peerinfo (peerinfo);
+
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "Deleting peer info failed");
+ }
+
+ list_del_init (&peerinfo->uuid_list);
+ list_for_each_entry_safe (name, tmp, &peerinfo->hostnames,
+ hostname_list) {
+ list_del_init (&name->hostname_list);
+ GF_FREE (name->hostname);
+ GF_FREE (name);
+ }
+
+ list_del_init (&peerinfo->hostnames);
+ if (peerinfo->hostname)
+ GF_FREE (peerinfo->hostname);
+ glusterd_sm_tr_log_delete (&peerinfo->sm_log);
+ GF_FREE (peerinfo);
+ peerinfo = NULL;
+
+ ret = 0;
+
+out:
+ return ret;
+}
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
index 5797c35..8d4fac4 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
@@ -230,4 +230,23 @@ glusterd_rb_check_bricks (glusterd_volinfo_t *volinfo,
int
glusterd_brick_create_path (char *host, char *path, mode_t mode,
char **op_errstr);
+int
+glusterd_sm_tr_log_transition_add (glusterd_sm_tr_log_t *log,
+ int old_state, int new_state,
+ int event);
+int
+glusterd_peerinfo_new (glusterd_peerinfo_t **peerinfo,
+ glusterd_friend_sm_state_t state,
+ uuid_t *uuid, const char *hostname);
+int
+glusterd_sm_tr_log_init (glusterd_sm_tr_log_t *log,
+ char * (*state_name_get) (int),
+ char * (*event_name_get) (int),
+ size_t size);
+void
+glusterd_sm_tr_log_delete (glusterd_sm_tr_log_t *log);
+
+int
+glusterd_sm_tr_log_add_to_dict (dict_t *dict,
+ glusterd_sm_tr_log_t *circular_log);
#endif
diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c
index 9d9820e..78328b9 100644
--- a/xlators/mgmt/glusterd/src/glusterd.c
+++ b/xlators/mgmt/glusterd/src/glusterd.c
@@ -43,6 +43,7 @@
#include "glusterd-sm.h"
#include "glusterd-op-sm.h"
#include "glusterd-store.h"
+#include "glusterd-utils.h"
static uuid_t glusterd_uuid;
extern struct rpcsvc_program glusterd1_mop_prog;
@@ -386,6 +387,12 @@ init (xlator_t *this)
strncpy (conf->workdir, dirname, PATH_MAX);
INIT_LIST_HEAD (&conf->xprt_list);
+ ret = glusterd_sm_tr_log_init (&conf->op_sm_log,
+ glusterd_op_sm_state_name_get,
+ glusterd_op_sm_event_name_get,
+ GLUSTERD_TR_LOG_SIZE);
+ if (ret)
+ goto out;
this->private = conf;
//this->ctx->top = this;
@@ -437,6 +444,7 @@ fini (xlator_t *this)
FREE (conf->pmap);
if (conf->handle)
glusterd_store_handle_destroy (conf->handle);
+ glusterd_sm_tr_log_delete (&conf->op_sm_log);
GF_FREE (conf);
this->private = NULL;
out:
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
index dfa8b73..11774a3 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -49,6 +49,8 @@
#define GLUSTERD_MAX_VOLUME_NAME 1000
#define DEFAULT_LOG_FILE_DIRECTORY DATADIR "/log/glusterfs"
+#define GLUSTERD_TR_LOG_SIZE 50
+
typedef enum glusterd_op_ {
GD_OP_NONE = 0,
@@ -96,6 +98,7 @@ typedef struct {
struct list_head xprt_list;
glusterd_store_handle_t *handle;
gf_timer_t *timer;
+ glusterd_sm_tr_log_t op_sm_log;
} glusterd_conf_t;
typedef enum gf_brick_status {
@@ -440,6 +443,9 @@ int
glusterd_handle_reset_volume (rpcsvc_request_t *req);
int
+glusterd_handle_fsm_log (rpcsvc_request_t *req);
+
+int
glusterd_xfer_cli_deprobe_resp (rpcsvc_request_t *req, int32_t op_ret,
int32_t op_errno, char *hostname);
diff --git a/xlators/mgmt/glusterd/src/glusterd3_1-mops.c b/xlators/mgmt/glusterd/src/glusterd3_1-mops.c
index 8e9c080..3004954 100644
--- a/xlators/mgmt/glusterd/src/glusterd3_1-mops.c
+++ b/xlators/mgmt/glusterd/src/glusterd3_1-mops.c
@@ -1483,6 +1483,10 @@ glusterd_handle_rpc_msg (rpcsvc_request_t *req)
ret = glusterd_handle_reset_volume (req);
break;
+ case GD_MGMT_CLI_FSM_LOG:
+ ret = glusterd_handle_fsm_log (req);
+ break;
+
default:
gf_log("", GF_LOG_ERROR, "Recieved Invalid procnum:%d",
req->procnum);
@@ -1538,7 +1542,8 @@ rpcsvc_actor_t glusterd1_mgmt_actors[] = {
[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_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}
};
/*rpcsvc_actor_t glusterd1_mgmt_actors[] = {