15
#include <glusterfs/compat-uuid.h>
18
#include <glusterfs/compat.h>
19
#include <glusterfs/list.h>
20
#include "glusterd-messages.h"
21
#include <glusterfs/dict.h>
22
#include <glusterfs/compat.h>
23
#include <glusterfs/compat-errno.h>
24
#include "glusterd-sm.h"
25
#include "glusterd-op-sm.h"
26
#include "glusterd-utils.h"
27
#include "glusterd-store.h"
28
#include "glusterd-svc-helper.h"
29
#include "glusterd-snapshot-utils.h"
30
#include "glusterd-server-quorum.h"
31
#include "glusterd-gfproxyd-svc-helper.h"
33
char local_node_hostname[PATH_MAX] = {
37
static struct cds_list_head gd_friend_sm_queue;
39
static char *glusterd_friend_sm_state_names[] = {
40
"Establishing Connection",
42
"Probe Received from Peer",
44
"Accepted peer request",
45
"Sent and Received peer request",
47
"Peer detach in progress",
48
"Probe Received from peer",
50
"Peer is connected and Accepted",
53
static char *glusterd_friend_sm_event_names[] = {
54
"GD_FRIEND_EVENT_NONE",
55
"GD_FRIEND_EVENT_PROBE",
56
"GD_FRIEND_EVENT_INIT_FRIEND_REQ",
57
"GD_FRIEND_EVENT_RCVD_ACC",
58
"GD_FRIEND_EVENT_LOCAL_ACC",
59
"GD_FRIEND_EVENT_RCVD_RJT",
60
"GD_FRIEND_EVENT_LOCAL_RJT",
61
"GD_FRIEND_EVENT_RCVD_FRIEND_REQ",
62
"GD_FRIEND_EVENT_INIT_REMOVE_FRIEND",
63
"GD_FRIEND_EVENT_RCVD_REMOVE_FRIEND",
64
"GD_FRIEND_EVENT_REMOVE_FRIEND",
65
"GD_FRIEND_EVENT_CONNECTED",
66
"GD_FRIEND_EVENT_NEW_NAME",
67
"GD_FRIEND_EVENT_MAX"};
70
glusterd_friend_sm_state_name_get(int state)
72
if (state < 0 || state >= GD_FRIEND_STATE_MAX)
73
return glusterd_friend_sm_state_names[GD_FRIEND_STATE_MAX];
74
return glusterd_friend_sm_state_names[state];
78
glusterd_friend_sm_event_name_get(int event)
80
if (event < 0 || event >= GD_FRIEND_EVENT_MAX)
81
return glusterd_friend_sm_event_names[GD_FRIEND_EVENT_MAX];
82
return glusterd_friend_sm_event_names[event];
86
glusterd_destroy_probe_ctx(glusterd_probe_ctx_t *ctx)
91
GF_FREE(ctx->hostname);
96
glusterd_destroy_friend_req_ctx(glusterd_friend_req_ctx_t *ctx)
102
dict_unref(ctx->vols);
104
dict_unref(ctx->peer_ver);
105
GF_FREE(ctx->hostname);
110
glusterd_destroy_friend_update_ctx(glusterd_friend_update_ctx_t *ctx)
114
GF_FREE(ctx->hostname);
119
glusterd_broadcast_friend_delete(char *hostname, uuid_t uuid)
122
rpc_clnt_procedure_t *proc = NULL;
123
xlator_t *this = THIS;
124
glusterd_friend_update_ctx_t ctx = {
127
glusterd_peerinfo_t *peerinfo = NULL;
128
glusterd_conf_t *priv = NULL;
129
dict_t *friends = NULL;
136
priv = this->private;
140
ctx.hostname = hostname;
141
ctx.op = GD_FRIEND_UPDATE_DEL;
143
friends = dict_new();
145
gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_CREATE_FAIL, NULL);
149
keylen = snprintf(key, sizeof(key), "op");
150
ret = dict_set_int32n(friends, key, keylen, ctx.op);
152
gf_smsg(this->name, GF_LOG_ERROR, -ret, GD_MSG_DICT_SET_FAILED,
153
"Key=%s", key, NULL);
157
keylen = snprintf(key, sizeof(key), "hostname");
158
ret = dict_set_strn(friends, key, keylen, hostname);
160
gf_smsg(this->name, GF_LOG_ERROR, -ret, GD_MSG_DICT_SET_FAILED,
161
"Key=%s", key, NULL);
165
ret = dict_set_int32_sizen(friends, "count", count);
167
gf_smsg(this->name, GF_LOG_ERROR, -ret, GD_MSG_DICT_SET_FAILED,
168
"Key=%s", key, NULL);
173
cds_list_for_each_entry_rcu(peerinfo, &priv->peers, uuid_list)
175
if (!peerinfo->connected || !peerinfo->peer)
182
ret = dict_set_static_ptr(friends, "peerinfo", peerinfo);
185
gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED,
186
"failed to set peerinfo");
190
proc = &peerinfo->peer->proctable[GLUSTERD_FRIEND_UPDATE];
192
ret = proc->fn(NULL, this, friends);
201
gf_msg_debug("glusterd", 0, "Returning with %d", ret);
206
glusterd_ac_none(glusterd_friend_sm_event_t *event, void *ctx)
210
gf_msg_debug("glusterd", 0, "Returning with %d", ret);
216
glusterd_ac_error(glusterd_friend_sm_event_t *event, void *ctx)
220
gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_AC_ERROR, "Received event %d ",
227
glusterd_ac_reverse_probe_begin(glusterd_friend_sm_event_t *event, void *ctx)
230
glusterd_peerinfo_t *peerinfo = NULL;
231
glusterd_friend_sm_event_t *new_event = NULL;
232
glusterd_probe_ctx_t *new_ev_ctx = NULL;
237
new_ev_ctx = GF_CALLOC(1, sizeof(*new_ev_ctx), gf_gld_mt_probe_ctx_t);
241
peerinfo = glusterd_peerinfo_find(event->peerid, event->peername);
245
gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_PEER_NOT_FOUND,
246
"Could not find peer %s(%s)", event->peername,
247
uuid_utoa(event->peerid));
251
ret = glusterd_friend_sm_new_event(GD_FRIEND_EVENT_PROBE, &new_event);
255
gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_EVENT_NEW_GET_FAIL,
256
"Unable to get new new_event");
267
new_ev_ctx->hostname = gf_strdup(peerinfo->hostname);
268
new_ev_ctx->port = peerinfo->port;
269
new_ev_ctx->req = NULL;
271
new_event->peername = gf_strdup(peerinfo->hostname);
272
gf_uuid_copy(new_event->peerid, peerinfo->uuid);
273
new_event->ctx = new_ev_ctx;
275
ret = glusterd_friend_sm_inject_event(new_event);
280
gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_EVENT_INJECT_FAIL,
281
"Unable to inject new_event %d, "
283
new_event->event, ret);
289
GF_FREE(new_event->peername);
292
GF_FREE(new_ev_ctx->hostname);
295
gf_msg_debug("glusterd", 0, "returning with %d", ret);
300
glusterd_ac_friend_add(glusterd_friend_sm_event_t *event, void *ctx)
303
glusterd_peerinfo_t *peerinfo = NULL;
304
rpc_clnt_procedure_t *proc = NULL;
305
call_frame_t *frame = NULL;
306
glusterd_conf_t *conf = NULL;
307
xlator_t *this = THIS;
311
conf = this->private;
317
peerinfo = glusterd_peerinfo_find(event->peerid, event->peername);
320
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_PEER_NOT_FOUND,
321
"Could not find peer %s(%s)", event->peername,
322
uuid_utoa(event->peerid));
326
if (!peerinfo->peer) {
330
proc = &peerinfo->peer->proctable[GLUSTERD_FRIEND_ADD];
332
frame = create_frame(this, this->ctx->pool);
338
ret = proc->fn(frame, this, event);
344
STACK_DESTROY(frame->root);
346
gf_msg_debug("glusterd", 0, "Returning with %d", ret);
351
glusterd_ac_friend_probe(glusterd_friend_sm_event_t *event, void *ctx)
354
rpc_clnt_procedure_t *proc = NULL;
355
call_frame_t *frame = NULL;
356
glusterd_conf_t *conf = NULL;
357
xlator_t *this = THIS;
358
glusterd_probe_ctx_t *probe_ctx = NULL;
359
glusterd_peerinfo_t *peerinfo = NULL;
366
conf = this->private;
371
peerinfo = glusterd_peerinfo_find(NULL, probe_ctx->hostname);
372
if (peerinfo == NULL) {
374
gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_PEER_NOT_FOUND, NULL);
379
if (!peerinfo->peer) {
380
gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_PEER_ADDRESS_GET_FAIL,
384
proc = &peerinfo->peer->proctable[GLUSTERD_PROBE_QUERY];
386
frame = create_frame(this, this->ctx->pool);
388
gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_FRAME_CREATE_FAIL,
395
gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_CREATE_FAIL,
399
ret = dict_set_str_sizen(dict, "hostname", probe_ctx->hostname);
401
gf_smsg(this->name, GF_LOG_ERROR, -ret, GD_MSG_DICT_SET_FAILED,
402
"Key=hostname", NULL);
406
ret = dict_set_int32_sizen(dict, "port", probe_ctx->port);
408
gf_smsg(this->name, GF_LOG_ERROR, -ret, GD_MSG_DICT_SET_FAILED,
417
ret = dict_set_static_ptr(dict, "peerinfo", peerinfo);
420
gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED,
421
"failed to set peerinfo");
425
ret = proc->fn(frame, this, dict);
435
gf_msg_debug("glusterd", 0, "Returning with %d", ret);
438
STACK_DESTROY(frame->root);
444
glusterd_ac_send_friend_remove_req(glusterd_friend_sm_event_t *event,
448
glusterd_peerinfo_t *peerinfo = NULL;
449
rpc_clnt_procedure_t *proc = NULL;
450
call_frame_t *frame = NULL;
451
glusterd_conf_t *conf = NULL;
452
xlator_t *this = THIS;
453
glusterd_friend_sm_event_type_t event_type = GD_FRIEND_EVENT_NONE;
454
glusterd_probe_ctx_t *ctx = NULL;
455
glusterd_friend_sm_event_t *new_event = NULL;
459
conf = this->private;
465
peerinfo = glusterd_peerinfo_find(event->peerid, event->peername);
469
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_PEER_NOT_FOUND,
470
"Could not find peer %s(%s)", event->peername,
471
uuid_utoa(event->peerid));
476
if (!peerinfo->connected) {
477
event_type = GD_FRIEND_EVENT_REMOVE_FRIEND;
479
ret = glusterd_friend_sm_new_event(event_type, &new_event);
482
new_event->peername = peerinfo->hostname;
483
gf_uuid_copy(new_event->peerid, peerinfo->uuid);
484
ret = glusterd_friend_sm_inject_event(new_event);
486
gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_EVENT_NEW_GET_FAIL,
487
"Unable to get event");
491
ret = glusterd_xfer_cli_deprobe_resp(ctx->req, ret, 0, NULL,
492
ctx->hostname, ctx->dict);
493
glusterd_broadcast_friend_delete(ctx->hostname, NULL);
494
glusterd_destroy_probe_ctx(ctx);
499
if (!peerinfo->peer) {
500
gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_PEER_ADDRESS_GET_FAIL,
504
proc = &peerinfo->peer->proctable[GLUSTERD_FRIEND_REMOVE];
506
frame = create_frame(this, this->ctx->pool);
508
gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_FRAME_CREATE_FAIL,
513
ret = proc->fn(frame, this, event);
520
gf_msg_debug("glusterd", 0, "Returning with %d", ret);
523
STACK_DESTROY(frame->root);
529
glusterd_should_update_peer(glusterd_peerinfo_t *peerinfo,
530
glusterd_peerinfo_t *cur_peerinfo)
532
if ((peerinfo == cur_peerinfo) ||
533
(peerinfo->state == GD_FRIEND_STATE_BEFRIENDED))
540
glusterd_ac_send_friend_update(glusterd_friend_sm_event_t *event, void *ctx)
543
glusterd_peerinfo_t *cur_peerinfo = NULL;
544
glusterd_peerinfo_t *peerinfo = NULL;
545
rpc_clnt_procedure_t *proc = NULL;
546
xlator_t *this = THIS;
547
glusterd_friend_update_ctx_t ev_ctx = {{0}};
548
glusterd_conf_t *priv = NULL;
549
dict_t *friends = NULL;
558
priv = this->private;
562
keylen = snprintf(key, sizeof(key), "op");
563
friends = dict_new();
567
cur_peerinfo = glusterd_peerinfo_find(event->peerid, event->peername);
571
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_PEER_NOT_FOUND,
572
"Could not find peer %s(%s)", event->peername,
573
uuid_utoa(event->peerid));
578
gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_CREATE_FAIL, NULL);
582
ev_ctx.op = GD_FRIEND_UPDATE_ADD;
583
ret = dict_set_int32n(friends, key, keylen, ev_ctx.op);
585
gf_smsg(this->name, GF_LOG_ERROR, -ret, GD_MSG_DICT_SET_FAILED,
586
"Key=%s", key, NULL);
590
cds_list_for_each_entry_rcu(peerinfo, &priv->peers, uuid_list)
592
if (!glusterd_should_update_peer(peerinfo, cur_peerinfo))
597
snprintf(key, sizeof(key), "friend%d", count);
598
ret = gd_add_friend_to_dict(peerinfo, friends, key);
603
ret = dict_set_int32_sizen(friends, "count", count);
605
gf_smsg(this->name, GF_LOG_ERROR, -ret, GD_MSG_DICT_SET_FAILED,
610
cds_list_for_each_entry_rcu(peerinfo, &priv->peers, uuid_list)
612
if (!peerinfo->connected || !peerinfo->peer)
615
if (!glusterd_should_update_peer(peerinfo, cur_peerinfo))
618
ret = dict_set_static_ptr(friends, "peerinfo", peerinfo);
621
gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED,
622
"failed to set peerinfo");
626
proc = &peerinfo->peer->proctable[GLUSTERD_FRIEND_UPDATE];
628
ret = proc->fn(NULL, this, friends);
639
gf_msg_debug("glusterd", 0, "Returning with %d", ret);
647
glusterd_ac_update_friend(glusterd_friend_sm_event_t *event, void *ctx)
650
glusterd_peerinfo_t *cur_peerinfo = NULL;
651
glusterd_peerinfo_t *peerinfo = NULL;
652
rpc_clnt_procedure_t *proc = NULL;
653
xlator_t *this = THIS;
654
glusterd_friend_update_ctx_t ev_ctx = {{0}};
655
glusterd_conf_t *priv = NULL;
656
dict_t *friends = NULL;
665
priv = this->private;
669
friends = dict_new();
670
keylen = snprintf(key, sizeof(key), "op");
674
cur_peerinfo = glusterd_peerinfo_find(event->peerid, event->peername);
678
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_PEER_NOT_FOUND,
679
"Could not find peer %s(%s)", event->peername,
680
uuid_utoa(event->peerid));
688
if (!cur_peerinfo->connected || !cur_peerinfo->peer) {
694
gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_CREATE_FAIL, NULL);
698
ev_ctx.op = GD_FRIEND_UPDATE_ADD;
699
ret = dict_set_int32n(friends, key, keylen, ev_ctx.op);
701
gf_smsg(this->name, GF_LOG_ERROR, -ret, GD_MSG_DICT_SET_FAILED,
702
"Key=%s", key, NULL);
706
cds_list_for_each_entry_rcu(peerinfo, &priv->peers, uuid_list)
708
if (!glusterd_should_update_peer(peerinfo, cur_peerinfo))
713
snprintf(key, sizeof(key), "friend%d", count);
714
ret = gd_add_friend_to_dict(peerinfo, friends, key);
719
ret = dict_set_int32_sizen(friends, "count", count);
721
gf_smsg(this->name, GF_LOG_ERROR, -ret, GD_MSG_DICT_SET_FAILED,
726
ret = dict_set_static_ptr(friends, "peerinfo", cur_peerinfo);
729
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED,
730
"failed to set peerinfo");
734
proc = &cur_peerinfo->peer->proctable[GLUSTERD_FRIEND_UPDATE];
736
ret = proc->fn(NULL, this, friends);
738
gf_msg_debug(this->name, 0, "Returning with %d", ret);
754
glusterd_peer_detach_cleanup(glusterd_conf_t *priv)
757
glusterd_volinfo_t *volinfo = NULL;
758
glusterd_volinfo_t *tmp_volinfo = NULL;
759
glusterd_svc_t *svc = NULL;
763
cds_list_for_each_entry_safe(volinfo, tmp_volinfo, &priv->volumes, vol_list)
771
if (!glusterd_friend_contains_vol_bricks(volinfo, MY_UUID)) {
772
gf_msg(THIS->name, GF_LOG_INFO, 0, GD_MSG_STALE_VOL_DELETE_INFO,
773
"Deleting stale volume %s", volinfo->volname);
776
if (!volinfo->is_snap_volume) {
777
svc = &(volinfo->snapd.svc);
778
ret = svc->stop(svc, SIGTERM);
780
gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_SVC_STOP_FAIL,
782
"to stop snapd daemon service");
786
if (glusterd_is_shd_compatible_volume(volinfo)) {
787
svc = &(volinfo->shd.svc);
788
ret = svc->stop(svc, SIGTERM);
790
gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_SVC_STOP_FAIL,
792
"to stop shd daemon service");
796
if (glusterd_is_gfproxyd_enabled(volinfo)) {
797
svc = &(volinfo->gfproxyd.svc);
798
ret = svc->stop(svc, SIGTERM);
800
gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_SVC_STOP_FAIL,
802
"to stop gfproxyd daemon service");
806
ret = glusterd_cleanup_snaps_for_volume(volinfo);
808
gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_VOL_DELETE_FAIL,
809
"Error deleting snapshots for volume %s",
813
ret = glusterd_delete_volume(volinfo);
815
gf_msg(THIS->name, GF_LOG_ERROR, 0,
816
GD_MSG_STALE_VOL_REMOVE_FAIL,
817
"Error deleting stale volume");
823
ret = glusterd_svcs_reconfigure(NULL);
825
gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_SVC_STOP_FAIL,
826
"Failed to reconfigure all daemon services.");
831
glusterd_ac_handle_friend_remove_req(glusterd_friend_sm_event_t *event,
835
glusterd_peerinfo_t *peerinfo = NULL;
836
glusterd_friend_req_ctx_t *ev_ctx = NULL;
837
glusterd_friend_sm_event_t *new_event = NULL;
838
glusterd_conf_t *priv = NULL;
843
priv = THIS->private;
846
ret = glusterd_xfer_friend_remove_resp(ev_ctx->req, ev_ctx->hostname,
850
cds_list_for_each_entry_rcu(peerinfo, &priv->peers, uuid_list)
852
ret = glusterd_friend_sm_new_event(GD_FRIEND_EVENT_REMOVE_FRIEND,
859
new_event->peername = gf_strdup(peerinfo->hostname);
860
gf_uuid_copy(new_event->peerid, peerinfo->uuid);
862
ret = glusterd_friend_sm_inject_event(new_event);
872
glusterd_peer_detach_cleanup(priv);
875
GF_FREE(new_event->peername);
878
gf_msg_debug(THIS->name, 0, "Returning with %d", ret);
883
glusterd_ac_friend_remove(glusterd_friend_sm_event_t *event, void *ctx)
886
glusterd_peerinfo_t *peerinfo = NULL;
892
peerinfo = glusterd_peerinfo_find(event->peerid, event->peername);
895
gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_PEER_NOT_FOUND,
896
"Could not find peer %s(%s)", event->peername,
897
uuid_utoa(event->peerid));
900
ret = glusterd_friend_remove_cleanup_vols(peerinfo->uuid);
903
gf_msg(THIS->name, GF_LOG_WARNING, 0, GD_MSG_VOL_CLEANUP_FAIL,
904
"Volumes cleanup failed");
910
ret = glusterd_peerinfo_cleanup(peerinfo);
912
gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_PEER_DETACH_CLEANUP_FAIL,
913
"Cleanup returned: %d", ret);
930
glusterd_ac_handle_friend_add_req(glusterd_friend_sm_event_t *event, void *ctx)
934
glusterd_peerinfo_t *peerinfo = NULL;
935
glusterd_friend_req_ctx_t *ev_ctx = NULL;
936
glusterd_friend_update_ctx_t *new_ev_ctx = NULL;
937
glusterd_friend_sm_event_t *new_event = NULL;
938
glusterd_friend_sm_event_type_t event_type = GD_FRIEND_EVENT_NONE;
939
glusterd_conf_t *conf = NULL;
942
int32_t op_errno = 0;
943
xlator_t *this = THIS;
944
char *hostname = NULL;
948
gf_uuid_copy(uuid, ev_ctx->uuid);
951
peerinfo = glusterd_peerinfo_find(event->peerid, event->peername);
955
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_PEER_NOT_FOUND,
956
"Could not find peer %s(%s)", event->peername,
957
uuid_utoa(event->peerid));
965
gf_uuid_copy(peerinfo->uuid, ev_ctx->uuid);
969
conf = this->private;
979
pthread_mutex_lock(&conf->import_volumes);
981
ret = glusterd_compare_friend_data(ev_ctx->vols, ev_ctx->peer_ver,
982
&status, event->peername);
984
pthread_mutex_unlock(&conf->import_volumes);
988
if (GLUSTERD_VOL_COMP_RJT != status) {
989
event_type = GD_FRIEND_EVENT_LOCAL_ACC;
992
event_type = GD_FRIEND_EVENT_LOCAL_RJT;
993
op_errno = GF_PROBE_VOLUME_CONFLICT;
1000
ret = glusterd_import_friend_missed_snap_list(ev_ctx->vols);
1002
gf_msg(this->name, GF_LOG_ERROR, 0,
1003
GD_MSG_MISSED_SNAP_LIST_STORE_FAIL,
1004
"Failed to import peer's "
1005
"missed_snaps_list.");
1006
event_type = GD_FRIEND_EVENT_LOCAL_RJT;
1007
op_errno = GF_PROBE_MISSED_SNAP_CONFLICT;
1017
ret = glusterd_compare_friend_snapshots(
1018
ev_ctx->vols, event->peername, event->peerid);
1020
gf_msg(this->name, GF_LOG_ERROR, 0,
1021
GD_MSG_SNAP_COMPARE_CONFLICT,
1022
"Conflict in comparing peer's snapshots");
1023
event_type = GD_FRIEND_EVENT_LOCAL_RJT;
1024
op_errno = GF_PROBE_SNAP_CONFLICT;
1029
pthread_mutex_unlock(&conf->import_volumes);
1030
ret = glusterd_friend_sm_new_event(event_type, &new_event);
1033
gf_msg(this->name, GF_LOG_ERROR, ENOMEM, GD_MSG_NO_MEMORY,
1038
new_event->peername = gf_strdup(event->peername);
1039
gf_uuid_copy(new_event->peerid, event->peerid);
1041
new_ev_ctx = GF_CALLOC(1, sizeof(*new_ev_ctx),
1042
gf_gld_mt_friend_update_ctx_t);
1048
gf_uuid_copy(new_ev_ctx->uuid, ev_ctx->uuid);
1049
new_ev_ctx->hostname = gf_strdup(ev_ctx->hostname);
1050
new_ev_ctx->op = GD_FRIEND_UPDATE_ADD;
1052
new_event->ctx = new_ev_ctx;
1054
ret = dict_get_str(ev_ctx->vols, "hostname_in_cluster", &hostname);
1055
if (ret || !hostname) {
1056
gf_msg_debug(this->name, 0, "Unable to fetch local hostname from peer");
1057
} else if (snprintf(local_node_hostname, sizeof(local_node_hostname), "%s",
1058
hostname) >= sizeof(local_node_hostname)) {
1059
gf_msg_debug(this->name, 0, "local_node_hostname truncated");
1064
glusterd_friend_sm_inject_event(new_event);
1067
ret = glusterd_xfer_friend_add_resp(ev_ctx->req, ev_ctx->hostname,
1068
event->peername, ev_ctx->port, op_ret,
1073
GF_FREE(new_event->peername);
1076
gf_msg_debug("glusterd", 0, "Returning with %d", ret);
1081
glusterd_friend_sm_transition_state(uuid_t peerid, char *peername,
1082
glusterd_sm_t *state,
1083
glusterd_friend_sm_event_type_t event_type)
1086
glusterd_peerinfo_t *peerinfo = NULL;
1089
GF_ASSERT(peername);
1092
peerinfo = glusterd_peerinfo_find(peerid, peername);
1094
gf_smsg(THIS->name, GF_LOG_ERROR, errno, GD_MSG_PEER_NOT_FOUND, NULL);
1098
(void)glusterd_sm_tr_log_transition_add(&peerinfo->sm_log, peerinfo->state,
1099
state[event_type].next_state,
1102
uatomic_set(&peerinfo->state, state[event_type].next_state);
1110
glusterd_sm_t glusterd_state_default[] = {
1111
{GD_FRIEND_STATE_DEFAULT, glusterd_ac_none},
1112
{GD_FRIEND_STATE_DEFAULT, glusterd_ac_friend_probe},
1113
{GD_FRIEND_STATE_REQ_SENT, glusterd_ac_friend_add},
1114
{GD_FRIEND_STATE_DEFAULT, glusterd_ac_none},
1115
{GD_FRIEND_STATE_DEFAULT, glusterd_ac_none},
1116
{GD_FRIEND_STATE_DEFAULT, glusterd_ac_none},
1117
{GD_FRIEND_STATE_DEFAULT, glusterd_ac_none},
1118
{GD_FRIEND_STATE_REQ_RCVD,
1119
glusterd_ac_handle_friend_add_req},
1120
{GD_FRIEND_STATE_DEFAULT,
1121
glusterd_ac_send_friend_remove_req},
1122
{GD_FRIEND_STATE_DEFAULT, glusterd_ac_none},
1123
{GD_FRIEND_STATE_DEFAULT,
1124
glusterd_ac_friend_remove},
1125
{GD_FRIEND_STATE_DEFAULT, glusterd_ac_friend_probe},
1126
{GD_FRIEND_STATE_DEFAULT, glusterd_ac_none},
1127
{GD_FRIEND_STATE_DEFAULT, glusterd_ac_none},
1130
glusterd_sm_t glusterd_state_probe_rcvd[] = {
1131
{GD_FRIEND_STATE_PROBE_RCVD, glusterd_ac_none},
1132
{GD_FRIEND_STATE_PROBE_RCVD, glusterd_ac_none},
1133
{GD_FRIEND_STATE_PROBE_RCVD, glusterd_ac_none},
1134
{GD_FRIEND_STATE_PROBE_RCVD, glusterd_ac_none},
1135
{GD_FRIEND_STATE_PROBE_RCVD, glusterd_ac_none},
1136
{GD_FRIEND_STATE_PROBE_RCVD, glusterd_ac_none},
1137
{GD_FRIEND_STATE_PROBE_RCVD, glusterd_ac_none},
1138
{GD_FRIEND_STATE_REQ_RCVD,
1139
glusterd_ac_handle_friend_add_req},
1140
{GD_FRIEND_STATE_DEFAULT,
1141
glusterd_ac_send_friend_remove_req},
1142
{GD_FRIEND_STATE_DEFAULT, glusterd_ac_none},
1143
{GD_FRIEND_STATE_DEFAULT,
1144
glusterd_ac_friend_remove},
1145
{GD_FRIEND_STATE_CONNECTED_RCVD, glusterd_ac_none},
1146
{GD_FRIEND_STATE_DEFAULT, glusterd_ac_none},
1147
{GD_FRIEND_STATE_DEFAULT, glusterd_ac_none},
1150
glusterd_sm_t glusterd_state_connected_rcvd[] = {
1151
{GD_FRIEND_STATE_CONNECTED_RCVD, glusterd_ac_none},
1152
{GD_FRIEND_STATE_CONNECTED_RCVD, glusterd_ac_none},
1153
{GD_FRIEND_STATE_CONNECTED_RCVD, glusterd_ac_none},
1154
{GD_FRIEND_STATE_CONNECTED_RCVD, glusterd_ac_none},
1155
{GD_FRIEND_STATE_CONNECTED_ACCEPTED,
1156
glusterd_ac_reverse_probe_begin},
1157
{GD_FRIEND_STATE_CONNECTED_RCVD, glusterd_ac_none},
1158
{GD_FRIEND_STATE_REJECTED, glusterd_ac_none},
1159
{GD_FRIEND_STATE_CONNECTED_RCVD,
1160
glusterd_ac_handle_friend_add_req},
1161
{GD_FRIEND_STATE_DEFAULT,
1162
glusterd_ac_send_friend_remove_req},
1163
{GD_FRIEND_STATE_DEFAULT, glusterd_ac_none},
1164
{GD_FRIEND_STATE_DEFAULT,
1165
glusterd_ac_friend_remove},
1166
{GD_FRIEND_STATE_CONNECTED_RCVD, glusterd_ac_none},
1167
{GD_FRIEND_STATE_CONNECTED_RCVD, glusterd_ac_none},
1168
{GD_FRIEND_STATE_CONNECTED_RCVD, glusterd_ac_none},
1171
glusterd_sm_t glusterd_state_connected_accepted[] = {
1172
{GD_FRIEND_STATE_CONNECTED_ACCEPTED, glusterd_ac_none},
1173
{GD_FRIEND_STATE_CONNECTED_ACCEPTED, glusterd_ac_friend_probe},
1174
{GD_FRIEND_STATE_REQ_SENT_RCVD,
1175
glusterd_ac_friend_add},
1176
{GD_FRIEND_STATE_CONNECTED_ACCEPTED, glusterd_ac_none},
1177
{GD_FRIEND_STATE_CONNECTED_ACCEPTED,
1179
{GD_FRIEND_STATE_CONNECTED_ACCEPTED, glusterd_ac_none},
1180
{GD_FRIEND_STATE_CONNECTED_ACCEPTED,
1182
{GD_FRIEND_STATE_CONNECTED_ACCEPTED,
1184
{GD_FRIEND_STATE_DEFAULT,
1185
glusterd_ac_send_friend_remove_req},
1186
{GD_FRIEND_STATE_DEFAULT, glusterd_ac_none},
1187
{GD_FRIEND_STATE_DEFAULT,
1188
glusterd_ac_friend_remove},
1189
{GD_FRIEND_STATE_CONNECTED_ACCEPTED, glusterd_ac_none},
1190
{GD_FRIEND_STATE_CONNECTED_ACCEPTED, glusterd_ac_none},
1191
{GD_FRIEND_STATE_CONNECTED_ACCEPTED, glusterd_ac_none},
1194
glusterd_sm_t glusterd_state_req_sent[] = {
1195
{GD_FRIEND_STATE_REQ_SENT, glusterd_ac_none},
1196
{GD_FRIEND_STATE_REQ_SENT, glusterd_ac_none},
1197
{GD_FRIEND_STATE_REQ_SENT, glusterd_ac_none},
1198
{GD_FRIEND_STATE_REQ_ACCEPTED, glusterd_ac_none},
1199
{GD_FRIEND_STATE_REQ_SENT, glusterd_ac_none},
1200
{GD_FRIEND_STATE_REJECTED, glusterd_ac_none},
1201
{GD_FRIEND_STATE_REQ_SENT, glusterd_ac_none},
1202
{GD_FRIEND_STATE_REQ_SENT_RCVD,
1203
glusterd_ac_handle_friend_add_req},
1204
{GD_FRIEND_STATE_UNFRIEND_SENT,
1205
glusterd_ac_send_friend_remove_req},
1206
{GD_FRIEND_STATE_REQ_SENT, glusterd_ac_none},
1207
{GD_FRIEND_STATE_DEFAULT,
1208
glusterd_ac_friend_remove},
1209
{GD_FRIEND_STATE_REQ_SENT, glusterd_ac_none},
1210
{GD_FRIEND_STATE_REQ_SENT, glusterd_ac_none},
1211
{GD_FRIEND_STATE_REQ_SENT, glusterd_ac_none},
1214
glusterd_sm_t glusterd_state_req_rcvd[] = {
1215
{GD_FRIEND_STATE_REQ_RCVD, glusterd_ac_none},
1216
{GD_FRIEND_STATE_REQ_RCVD, glusterd_ac_none},
1217
{GD_FRIEND_STATE_REQ_SENT_RCVD,
1219
{GD_FRIEND_STATE_REQ_RCVD, glusterd_ac_none},
1220
{GD_FRIEND_STATE_REQ_ACCEPTED, glusterd_ac_none},
1221
{GD_FRIEND_STATE_REQ_RCVD, glusterd_ac_none},
1222
{GD_FRIEND_STATE_REJECTED, glusterd_ac_none},
1223
{GD_FRIEND_STATE_REQ_RCVD, glusterd_ac_none},
1224
{GD_FRIEND_STATE_DEFAULT,
1225
glusterd_ac_send_friend_remove_req},
1226
{GD_FRIEND_STATE_DEFAULT,
1227
glusterd_ac_handle_friend_remove_req},
1228
{GD_FRIEND_STATE_DEFAULT,
1229
glusterd_ac_friend_remove},
1230
{GD_FRIEND_STATE_CONNECTED_RCVD, glusterd_ac_none},
1231
{GD_FRIEND_STATE_CONNECTED_RCVD, glusterd_ac_none},
1232
{GD_FRIEND_STATE_REQ_RCVD, glusterd_ac_none},
1235
glusterd_sm_t glusterd_state_befriended[] = {
1236
{GD_FRIEND_STATE_BEFRIENDED, glusterd_ac_none},
1237
{GD_FRIEND_STATE_BEFRIENDED, glusterd_ac_none},
1238
{GD_FRIEND_STATE_BEFRIENDED, glusterd_ac_none},
1239
{GD_FRIEND_STATE_BEFRIENDED, glusterd_ac_update_friend},
1240
{GD_FRIEND_STATE_BEFRIENDED,
1241
glusterd_ac_update_friend},
1242
{GD_FRIEND_STATE_REJECTED, glusterd_ac_none},
1243
{GD_FRIEND_STATE_REJECTED, glusterd_ac_none},
1244
{GD_FRIEND_STATE_BEFRIENDED,
1245
glusterd_ac_handle_friend_add_req},
1246
{GD_FRIEND_STATE_UNFRIEND_SENT,
1247
glusterd_ac_send_friend_remove_req},
1248
{GD_FRIEND_STATE_DEFAULT,
1249
glusterd_ac_handle_friend_remove_req},
1250
{GD_FRIEND_STATE_DEFAULT,
1251
glusterd_ac_friend_remove},
1252
{GD_FRIEND_STATE_BEFRIENDED, glusterd_ac_friend_add},
1253
{GD_FRIEND_STATE_BEFRIENDED,
1254
glusterd_ac_send_friend_update},
1255
{GD_FRIEND_STATE_BEFRIENDED, glusterd_ac_none},
1258
glusterd_sm_t glusterd_state_req_sent_rcvd[] = {
1259
{GD_FRIEND_STATE_REQ_SENT_RCVD, glusterd_ac_none},
1260
{GD_FRIEND_STATE_REQ_SENT_RCVD, glusterd_ac_none},
1261
{GD_FRIEND_STATE_REQ_SENT_RCVD,
1263
{GD_FRIEND_STATE_BEFRIENDED,
1264
glusterd_ac_send_friend_update},
1265
{GD_FRIEND_STATE_REQ_SENT_RCVD, glusterd_ac_none},
1266
{GD_FRIEND_STATE_REJECTED, glusterd_ac_none},
1267
{GD_FRIEND_STATE_REQ_SENT_RCVD, glusterd_ac_none},
1268
{GD_FRIEND_STATE_REQ_SENT_RCVD, glusterd_ac_none},
1269
{GD_FRIEND_STATE_UNFRIEND_SENT,
1270
glusterd_ac_send_friend_remove_req},
1271
{GD_FRIEND_STATE_DEFAULT,
1272
glusterd_ac_handle_friend_remove_req},
1273
{GD_FRIEND_STATE_DEFAULT,
1274
glusterd_ac_friend_remove},
1275
{GD_FRIEND_STATE_REQ_SENT_RCVD, glusterd_ac_none},
1276
{GD_FRIEND_STATE_REQ_SENT_RCVD, glusterd_ac_none},
1277
{GD_FRIEND_STATE_REQ_SENT_RCVD, glusterd_ac_none},
1280
glusterd_sm_t glusterd_state_rejected[] = {
1281
{GD_FRIEND_STATE_REJECTED, glusterd_ac_none},
1282
{GD_FRIEND_STATE_REJECTED, glusterd_ac_friend_probe},
1283
{GD_FRIEND_STATE_REQ_SENT,
1284
glusterd_ac_friend_add},
1285
{GD_FRIEND_STATE_BEFRIENDED, glusterd_ac_none},
1286
{GD_FRIEND_STATE_BEFRIENDED, glusterd_ac_none},
1287
{GD_FRIEND_STATE_REJECTED, glusterd_ac_none},
1288
{GD_FRIEND_STATE_REJECTED, glusterd_ac_none},
1289
{GD_FRIEND_STATE_REQ_RCVD,
1290
glusterd_ac_handle_friend_add_req},
1291
{GD_FRIEND_STATE_DEFAULT,
1292
glusterd_ac_send_friend_remove_req},
1293
{GD_FRIEND_STATE_DEFAULT,
1294
glusterd_ac_handle_friend_remove_req},
1295
{GD_FRIEND_STATE_DEFAULT,
1296
glusterd_ac_friend_remove},
1297
{GD_FRIEND_STATE_REJECTED, glusterd_ac_friend_add},
1298
{GD_FRIEND_STATE_REJECTED, glusterd_ac_none},
1299
{GD_FRIEND_STATE_REQ_RCVD, glusterd_ac_none},
1302
glusterd_sm_t glusterd_state_req_accepted[] = {
1303
{GD_FRIEND_STATE_REQ_ACCEPTED, glusterd_ac_none},
1304
{GD_FRIEND_STATE_REQ_ACCEPTED, glusterd_ac_none},
1305
{GD_FRIEND_STATE_REQ_ACCEPTED, glusterd_ac_none},
1306
{GD_FRIEND_STATE_BEFRIENDED,
1307
glusterd_ac_send_friend_update},
1308
{GD_FRIEND_STATE_BEFRIENDED,
1309
glusterd_ac_send_friend_update},
1310
{GD_FRIEND_STATE_REJECTED, glusterd_ac_none},
1311
{GD_FRIEND_STATE_REJECTED, glusterd_ac_none},
1312
{GD_FRIEND_STATE_REQ_ACCEPTED,
1313
glusterd_ac_handle_friend_add_req},
1314
{GD_FRIEND_STATE_REQ_ACCEPTED,
1315
glusterd_ac_send_friend_remove_req},
1316
{GD_FRIEND_STATE_DEFAULT,
1317
glusterd_ac_handle_friend_remove_req},
1318
{GD_FRIEND_STATE_DEFAULT,
1319
glusterd_ac_friend_remove},
1320
{GD_FRIEND_STATE_CONNECTED_ACCEPTED,
1321
glusterd_ac_reverse_probe_begin},
1322
{GD_FRIEND_STATE_REQ_ACCEPTED, glusterd_ac_none},
1323
{GD_FRIEND_STATE_REQ_SENT, glusterd_ac_none},
1326
glusterd_sm_t glusterd_state_unfriend_sent[] = {
1327
{GD_FRIEND_STATE_UNFRIEND_SENT, glusterd_ac_none},
1328
{GD_FRIEND_STATE_UNFRIEND_SENT, glusterd_ac_error},
1329
{GD_FRIEND_STATE_UNFRIEND_SENT,
1331
{GD_FRIEND_STATE_UNFRIEND_SENT, glusterd_ac_none},
1332
{GD_FRIEND_STATE_UNFRIEND_SENT, glusterd_ac_none},
1333
{GD_FRIEND_STATE_UNFRIEND_SENT, glusterd_ac_error},
1334
{GD_FRIEND_STATE_UNFRIEND_SENT, glusterd_ac_error},
1335
{GD_FRIEND_STATE_UNFRIEND_SENT, glusterd_ac_error},
1336
{GD_FRIEND_STATE_UNFRIEND_SENT,
1338
{GD_FRIEND_STATE_UNFRIEND_SENT,
1340
{GD_FRIEND_STATE_DEFAULT,
1341
glusterd_ac_friend_remove},
1342
{GD_FRIEND_STATE_UNFRIEND_SENT, glusterd_ac_none},
1343
{GD_FRIEND_STATE_UNFRIEND_SENT, glusterd_ac_none},
1344
{GD_FRIEND_STATE_UNFRIEND_SENT, glusterd_ac_none},
1347
glusterd_sm_t *glusterd_friend_state_table[] = {
1348
glusterd_state_default, glusterd_state_req_sent,
1349
glusterd_state_req_rcvd, glusterd_state_befriended,
1350
glusterd_state_req_accepted, glusterd_state_req_sent_rcvd,
1351
glusterd_state_rejected, glusterd_state_unfriend_sent,
1352
glusterd_state_probe_rcvd, glusterd_state_connected_rcvd,
1353
glusterd_state_connected_accepted};
1356
glusterd_friend_sm_new_event(glusterd_friend_sm_event_type_t event_type,
1357
glusterd_friend_sm_event_t **new_event)
1359
glusterd_friend_sm_event_t *event = NULL;
1361
GF_ASSERT(new_event);
1362
GF_ASSERT(GD_FRIEND_EVENT_NONE <= event_type &&
1363
GD_FRIEND_EVENT_MAX > event_type);
1365
event = GF_CALLOC(1, sizeof(*event), gf_gld_mt_friend_sm_event_t);
1371
event->event = event_type;
1372
CDS_INIT_LIST_HEAD(&event->list);
1378
glusterd_friend_sm_inject_event(glusterd_friend_sm_event_t *event)
1381
gf_msg_debug("glusterd", 0, "Enqueue event: '%s'",
1382
glusterd_friend_sm_event_name_get(event->event));
1383
cds_list_add_tail(&event->list, &gd_friend_sm_queue);
1389
glusterd_destroy_friend_event_context(glusterd_friend_sm_event_t *event)
1394
switch (event->event) {
1395
case GD_FRIEND_EVENT_RCVD_FRIEND_REQ:
1396
case GD_FRIEND_EVENT_RCVD_REMOVE_FRIEND:
1397
glusterd_destroy_friend_req_ctx(event->ctx);
1399
case GD_FRIEND_EVENT_LOCAL_ACC:
1400
case GD_FRIEND_EVENT_LOCAL_RJT:
1401
case GD_FRIEND_EVENT_RCVD_ACC:
1402
case GD_FRIEND_EVENT_RCVD_RJT:
1403
glusterd_destroy_friend_update_ctx(event->ctx);
1411
gd_does_peer_affect_quorum(glusterd_friend_sm_state_t old_state,
1412
glusterd_friend_sm_event_type_t event_type,
1413
glusterd_peerinfo_t *peerinfo)
1415
gf_boolean_t affects = _gf_false;
1419
if ((old_state == GD_FRIEND_STATE_BEFRIENDED) &&
1420
(event_type != GD_FRIEND_EVENT_RCVD_ACC) &&
1421
(event_type != GD_FRIEND_EVENT_LOCAL_ACC))
1423
if ((peerinfo->state == GD_FRIEND_STATE_BEFRIENDED) &&
1424
peerinfo->connected) {
1432
glusterd_friend_sm(void)
1434
glusterd_friend_sm_event_t *event = NULL;
1435
glusterd_friend_sm_event_t *tmp = NULL;
1437
glusterd_friend_sm_ac_fn handler = NULL;
1438
glusterd_sm_t *state = NULL;
1439
glusterd_peerinfo_t *peerinfo = NULL;
1440
glusterd_friend_sm_event_type_t event_type = 0;
1441
gf_boolean_t is_await_conn = _gf_false;
1442
gf_boolean_t quorum_action = _gf_false;
1443
glusterd_friend_sm_state_t old_state = GD_FRIEND_STATE_DEFAULT;
1444
xlator_t *this = THIS;
1445
glusterd_conf_t *priv = NULL;
1447
priv = this->private;
1450
while (!cds_list_empty(&gd_friend_sm_queue)) {
1451
cds_list_for_each_entry_safe(event, tmp, &gd_friend_sm_queue, list)
1453
cds_list_del_init(&event->list);
1454
event_type = event->event;
1458
peerinfo = glusterd_peerinfo_find(event->peerid, event->peername);
1461
gf_msg("glusterd", GF_LOG_CRITICAL, 0, GD_MSG_PEER_NOT_FOUND,
1463
" event %s with empty peer info",
1464
glusterd_friend_sm_event_name_get(event_type));
1469
old_state = peerinfo->state;
1471
gf_msg_debug("glusterd", 0, "Dequeued event of type: '%s'",
1472
glusterd_friend_sm_event_name_get(event_type));
1482
state = glusterd_friend_state_table[old_state];
1486
handler = state[event_type].handler;
1489
ret = handler(event, event->ctx);
1490
if (ret == GLUSTERD_CONNECTION_AWAITED) {
1491
is_await_conn = _gf_true;
1496
gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_HANDLER_RETURNED,
1497
"handler returned: "
1500
glusterd_destroy_friend_event_context(event);
1505
if ((GD_FRIEND_EVENT_REMOVE_FRIEND == event_type) ||
1506
(GD_FRIEND_EVENT_INIT_REMOVE_FRIEND == event_type)) {
1507
glusterd_destroy_friend_event_context(event);
1512
ret = glusterd_friend_sm_transition_state(
1513
event->peerid, event->peername, state, event_type);
1516
gf_msg("glusterd", GF_LOG_ERROR, 0,
1517
GD_MSG_EVENT_STATE_TRANSITION_FAIL,
1518
"Unable to transition"
1519
" state from '%s' to '%s' for event '%s'",
1520
glusterd_friend_sm_state_name_get(old_state),
1521
glusterd_friend_sm_state_name_get(
1522
state[event_type].next_state),
1523
glusterd_friend_sm_event_name_get(event_type));
1532
peerinfo = glusterd_peerinfo_find(event->peerid, event->peername);
1542
gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_PEER_NOT_FOUND,
1543
"Cannot find peer %s(%s)", event->peername,
1544
uuid_utoa(event->peerid));
1547
if (gd_does_peer_affect_quorum(old_state, event_type, peerinfo)) {
1548
peerinfo->quorum_contrib = QUORUM_UP;
1549
if (peerinfo->quorum_action) {
1550
peerinfo->quorum_action = _gf_false;
1551
quorum_action = _gf_true;
1555
ret = glusterd_store_peerinfo(peerinfo);
1558
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_PEERINFO_CREATE_FAIL,
1559
"Failed to store peerinfo");
1562
glusterd_destroy_friend_event_context(event);
1573
if (quorum_action) {
1589
synclock_unlock(&priv->big_lock);
1590
glusterd_launch_synctask(glusterd_spawn_daemons, NULL);
1591
synclock_lock(&priv->big_lock);
1592
glusterd_do_quorum_action();
1598
glusterd_friend_sm_init(void)
1600
CDS_INIT_LIST_HEAD(&gd_friend_sm_queue);