11
#include "glusterd-utils.h"
12
#include "glusterd-locks.h"
13
#include "glusterd-mgmt.h"
14
#include "glusterd-op-sm.h"
15
#include "glusterd-messages.h"
18
glusterd_mgmt_v3_null(rpcsvc_request_t *req)
24
glusterd_mgmt_v3_lock_send_resp(rpcsvc_request_t *req, int32_t status,
27
gd1_mgmt_v3_lock_rsp rsp = {
36
rsp.op_errno = op_errno;
38
glusterd_get_uuid(&rsp.uuid);
40
ret = glusterd_submit_reply(req, &rsp, NULL, 0, NULL,
41
(xdrproc_t)xdr_gd1_mgmt_v3_lock_rsp);
43
gf_msg_debug(THIS->name, 0, "Responded to mgmt_v3 lock, ret: %d", ret);
49
glusterd_synctasked_mgmt_v3_lock(rpcsvc_request_t *req,
50
gd1_mgmt_v3_lock_req *lock_req,
51
glusterd_op_lock_ctx_t *ctx)
54
xlator_t *this = THIS;
55
uint32_t op_errno = 0;
62
ret = glusterd_multiple_mgmt_v3_lock(ctx->dict, ctx->uuid, &op_errno);
64
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_MGMTV3_LOCK_GET_FAIL,
65
"Failed to acquire mgmt_v3 locks for %s", uuid_utoa(ctx->uuid));
67
ret = glusterd_mgmt_v3_lock_send_resp(req, ret, op_errno);
69
gf_msg_trace(this->name, 0, "Returning %d", ret);
74
glusterd_op_state_machine_mgmt_v3_lock(rpcsvc_request_t *req,
75
gd1_mgmt_v3_lock_req *lock_req,
76
glusterd_op_lock_ctx_t *ctx)
79
xlator_t *this = THIS;
80
glusterd_op_info_t txn_op_info = {
86
glusterd_txn_opinfo_init(&txn_op_info, 0, &lock_req->op, ctx->dict, req);
88
ret = glusterd_set_txn_opinfo(&lock_req->txn_id, &txn_op_info);
90
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_OPINFO_SET_FAIL,
91
"Unable to set transaction's opinfo");
95
ret = glusterd_op_sm_inject_event(GD_OP_EVENT_LOCK, &lock_req->txn_id, ctx);
97
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_OP_EVENT_LOCK_FAIL,
98
"Failed to inject event GD_OP_EVENT_LOCK");
101
glusterd_friend_sm();
104
gf_msg_trace(this->name, 0, "Returning %d", ret);
109
glusterd_handle_mgmt_v3_lock_fn(rpcsvc_request_t *req)
111
gd1_mgmt_v3_lock_req lock_req = {
115
glusterd_op_lock_ctx_t *ctx = NULL;
116
xlator_t *this = THIS;
117
gf_boolean_t is_synctasked = _gf_false;
118
gf_boolean_t free_ctx = _gf_false;
119
glusterd_conf_t *conf = NULL;
122
conf = this->private;
126
ret = xdr_to_generic(req->msg[0], &lock_req,
127
(xdrproc_t)xdr_gd1_mgmt_v3_lock_req);
129
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_REQ_DECODE_FAIL,
130
"Failed to decode lock "
131
"request received from peer");
132
req->rpc_err = GARBAGE_ARGS;
136
gf_msg_debug(this->name, 0,
137
"Received mgmt_v3 lock req "
139
uuid_utoa(lock_req.uuid));
141
if (glusterd_peerinfo_find_by_uuid(lock_req.uuid) == NULL) {
142
gf_msg(this->name, GF_LOG_WARNING, 0, GD_MSG_PEER_NOT_FOUND,
144
"belong to the cluster. Ignoring request.",
145
uuid_utoa(lock_req.uuid));
150
ctx = GF_CALLOC(1, sizeof(*ctx), gf_gld_mt_op_lock_ctx_t);
152
gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_NO_MEMORY, NULL);
157
gf_uuid_copy(ctx->uuid, lock_req.uuid);
160
ctx->dict = dict_new();
162
gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_CREATE_FAIL, NULL);
167
ret = dict_unserialize(lock_req.dict.dict_val, lock_req.dict.dict_len,
170
gf_smsg(this->name, GF_LOG_WARNING, 0, GD_MSG_DICT_UNSERIALIZE_FAIL,
180
ret = dict_get_time(ctx->dict, "timeout", &timeout);
182
conf->mgmt_v3_lock_timeout = timeout + 120;
184
is_synctasked = dict_get_str_boolean(ctx->dict, "is_synctasked", _gf_false);
186
ret = glusterd_synctasked_mgmt_v3_lock(req, &lock_req, ctx);
188
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_MGMTV3_LOCK_GET_FAIL,
189
"Failed to acquire mgmt_v3_locks");
205
ret = glusterd_op_state_machine_mgmt_v3_lock(req, &lock_req, ctx);
207
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_MGMTV3_LOCK_GET_FAIL,
208
"Failed to acquire mgmt_v3_locks");
213
if (ctx && (ret || free_ctx)) {
215
dict_unref(ctx->dict);
220
free(lock_req.dict.dict_val);
222
gf_msg_trace(this->name, 0, "Returning %d", ret);
227
glusterd_mgmt_v3_pre_validate_send_resp(rpcsvc_request_t *req, int32_t op,
228
int32_t status, char *op_errstr,
229
dict_t *rsp_dict, uint32_t op_errno)
231
gd1_mgmt_v3_pre_val_rsp rsp = {
235
xlator_t *this = THIS;
240
glusterd_get_uuid(&rsp.uuid);
242
rsp.op_errno = op_errno;
244
rsp.op_errstr = op_errstr;
248
ret = dict_allocate_and_serialize(rsp_dict, &rsp.dict.dict_val,
251
gf_smsg(this->name, GF_LOG_ERROR, 0,
252
GD_MSG_DICT_ALLOC_AND_SERL_LENGTH_GET_FAIL, NULL);
256
ret = glusterd_submit_reply(req, &rsp, NULL, 0, NULL,
257
(xdrproc_t)xdr_gd1_mgmt_v3_pre_val_rsp);
259
GF_FREE(rsp.dict.dict_val);
261
gf_msg_debug(this->name, 0, "Responded to pre validation, ret: %d", ret);
266
glusterd_handle_pre_validate_fn(rpcsvc_request_t *req)
269
gd1_mgmt_v3_pre_val_req op_req = {
272
xlator_t *this = THIS;
273
char *op_errstr = NULL;
275
dict_t *rsp_dict = NULL;
276
uint32_t op_errno = 0;
280
ret = xdr_to_generic(req->msg[0], &op_req,
281
(xdrproc_t)xdr_gd1_mgmt_v3_pre_val_req);
283
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_REQ_DECODE_FAIL,
284
"Failed to decode pre validation "
285
"request received from peer");
286
req->rpc_err = GARBAGE_ARGS;
290
if (glusterd_peerinfo_find_by_uuid(op_req.uuid) == NULL) {
291
gf_msg(this->name, GF_LOG_WARNING, 0, GD_MSG_PEER_NOT_FOUND,
293
"belong to the cluster. Ignoring request.",
294
uuid_utoa(op_req.uuid));
301
gf_smsg(this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_CREATE_FAIL, NULL);
305
ret = dict_unserialize(op_req.dict.dict_val, op_req.dict.dict_len, &dict);
307
gf_smsg(this->name, GF_LOG_WARNING, 0, GD_MSG_DICT_UNSERIALIZE_FAIL,
312
rsp_dict = dict_new();
314
gf_smsg(this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_CREATE_FAIL, NULL);
318
ret = gd_mgmt_v3_pre_validate_fn(op_req.op, dict, &op_errstr, rsp_dict,
321
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_PRE_VALIDATION_FAIL,
322
"Pre Validation failed on operation %s", gd_op_list[op_req.op]);
325
ret = glusterd_mgmt_v3_pre_validate_send_resp(
326
req, op_req.op, ret, op_errstr, rsp_dict, op_errno);
328
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_MGMTV3_OP_RESP_FAIL,
329
"Failed to send Pre Validation "
330
"response for operation %s",
331
gd_op_list[op_req.op]);
336
if (op_errstr && (strcmp(op_errstr, "")))
339
free(op_req.dict.dict_val);
345
dict_unref(rsp_dict);
352
glusterd_mgmt_v3_brick_op_send_resp(rpcsvc_request_t *req, int32_t op,
353
int32_t status, char *op_errstr,
356
gd1_mgmt_v3_brick_op_rsp rsp = {
360
xlator_t *this = THIS;
365
glusterd_get_uuid(&rsp.uuid);
368
rsp.op_errstr = op_errstr;
372
ret = dict_allocate_and_serialize(rsp_dict, &rsp.dict.dict_val,
375
gf_smsg(this->name, GF_LOG_ERROR, 0,
376
GD_MSG_DICT_ALLOC_AND_SERL_LENGTH_GET_FAIL, NULL);
380
ret = glusterd_submit_reply(req, &rsp, NULL, 0, NULL,
381
(xdrproc_t)xdr_gd1_mgmt_v3_brick_op_rsp);
383
GF_FREE(rsp.dict.dict_val);
385
gf_msg_debug(this->name, 0, "Responded to brick op, ret: %d", ret);
390
glusterd_handle_brick_op_fn(rpcsvc_request_t *req)
393
gd1_mgmt_v3_brick_op_req op_req = {
396
xlator_t *this = THIS;
397
char *op_errstr = NULL;
399
dict_t *rsp_dict = NULL;
403
ret = xdr_to_generic(req->msg[0], &op_req,
404
(xdrproc_t)xdr_gd1_mgmt_v3_brick_op_req);
406
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_REQ_DECODE_FAIL,
407
"Failed to decode brick op "
408
"request received from peer");
409
req->rpc_err = GARBAGE_ARGS;
413
if (glusterd_peerinfo_find_by_uuid(op_req.uuid) == NULL) {
414
gf_msg(this->name, GF_LOG_WARNING, 0, GD_MSG_PEER_NOT_FOUND,
416
"belong to the cluster. Ignoring request.",
417
uuid_utoa(op_req.uuid));
424
gf_smsg(this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_CREATE_FAIL, NULL);
428
ret = dict_unserialize(op_req.dict.dict_val, op_req.dict.dict_len, &dict);
430
gf_smsg(this->name, GF_LOG_WARNING, 0, GD_MSG_DICT_UNSERIALIZE_FAIL,
435
rsp_dict = dict_new();
437
gf_smsg(this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_CREATE_FAIL, NULL);
441
ret = gd_mgmt_v3_brick_op_fn(op_req.op, dict, &op_errstr, rsp_dict);
444
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_BRICK_OP_FAIL,
445
"Brick Op failed on operation %s", gd_op_list[op_req.op]);
448
ret = glusterd_mgmt_v3_brick_op_send_resp(req, op_req.op, ret, op_errstr,
451
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_PRE_VALD_RESP_FAIL,
452
"Failed to send brick op "
453
"response for operation %s",
454
gd_op_list[op_req.op]);
459
if (op_errstr && (strcmp(op_errstr, "")))
462
free(op_req.dict.dict_val);
468
dict_unref(rsp_dict);
475
glusterd_mgmt_v3_commit_send_resp(rpcsvc_request_t *req, int32_t op,
476
int32_t status, char *op_errstr,
477
uint32_t op_errno, dict_t *rsp_dict)
479
gd1_mgmt_v3_commit_rsp rsp = {
483
xlator_t *this = THIS;
488
glusterd_get_uuid(&rsp.uuid);
490
rsp.op_errno = op_errno;
492
rsp.op_errstr = op_errstr;
496
ret = dict_allocate_and_serialize(rsp_dict, &rsp.dict.dict_val,
499
gf_smsg(this->name, GF_LOG_ERROR, 0,
500
GD_MSG_DICT_ALLOC_AND_SERL_LENGTH_GET_FAIL, NULL);
504
ret = glusterd_submit_reply(req, &rsp, NULL, 0, NULL,
505
(xdrproc_t)xdr_gd1_mgmt_v3_commit_rsp);
507
GF_FREE(rsp.dict.dict_val);
509
gf_msg_debug(this->name, 0, "Responded to commit, ret: %d", ret);
514
glusterd_handle_commit_fn(rpcsvc_request_t *req)
517
gd1_mgmt_v3_commit_req op_req = {
520
xlator_t *this = THIS;
521
char *op_errstr = NULL;
523
dict_t *rsp_dict = NULL;
524
uint32_t op_errno = 0;
528
ret = xdr_to_generic(req->msg[0], &op_req,
529
(xdrproc_t)xdr_gd1_mgmt_v3_commit_req);
531
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_REQ_DECODE_FAIL,
532
"Failed to decode commit "
533
"request received from peer");
534
req->rpc_err = GARBAGE_ARGS;
538
if (glusterd_peerinfo_find_by_uuid(op_req.uuid) == NULL) {
539
gf_msg(this->name, GF_LOG_WARNING, 0, GD_MSG_PEER_NOT_FOUND,
541
"belong to the cluster. Ignoring request.",
542
uuid_utoa(op_req.uuid));
549
gf_smsg(this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_CREATE_FAIL, NULL);
553
ret = dict_unserialize(op_req.dict.dict_val, op_req.dict.dict_len, &dict);
555
gf_smsg(this->name, GF_LOG_WARNING, 0, GD_MSG_DICT_UNSERIALIZE_FAIL,
560
rsp_dict = dict_new();
562
gf_smsg(this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_CREATE_FAIL, NULL);
566
ret = gd_mgmt_v3_commit_fn(op_req.op, dict, &op_errstr, &op_errno,
570
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_COMMIT_OP_FAIL,
571
"commit failed on operation %s", gd_op_list[op_req.op]);
574
ret = glusterd_mgmt_v3_commit_send_resp(req, op_req.op, ret, op_errstr,
577
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_MGMTV3_OP_RESP_FAIL,
578
"Failed to send commit "
579
"response for operation %s",
580
gd_op_list[op_req.op]);
585
if (op_errstr && (strcmp(op_errstr, "")))
588
free(op_req.dict.dict_val);
594
dict_unref(rsp_dict);
601
glusterd_mgmt_v3_post_commit_send_resp(rpcsvc_request_t *req, int32_t op,
602
int32_t status, char *op_errstr,
603
uint32_t op_errno, dict_t *rsp_dict)
605
gd1_mgmt_v3_post_commit_rsp rsp = {
609
xlator_t *this = THIS;
614
glusterd_get_uuid(&rsp.uuid);
616
rsp.op_errno = op_errno;
618
rsp.op_errstr = op_errstr;
622
ret = dict_allocate_and_serialize(rsp_dict, &rsp.dict.dict_val,
625
gf_smsg(this->name, GF_LOG_ERROR, 0,
626
GD_MSG_DICT_ALLOC_AND_SERL_LENGTH_GET_FAIL, NULL);
630
ret = glusterd_submit_reply(req, &rsp, NULL, 0, NULL,
631
(xdrproc_t)xdr_gd1_mgmt_v3_post_commit_rsp);
633
GF_FREE(rsp.dict.dict_val);
635
gf_msg_debug(this->name, 0, "Responded to post commit, ret: %d", ret);
640
glusterd_handle_post_commit_fn(rpcsvc_request_t *req)
643
gd1_mgmt_v3_post_commit_req op_req = {
646
xlator_t *this = THIS;
647
char *op_errstr = NULL;
649
dict_t *rsp_dict = NULL;
650
uint32_t op_errno = 0;
654
ret = xdr_to_generic(req->msg[0], &op_req,
655
(xdrproc_t)xdr_gd1_mgmt_v3_post_commit_req);
657
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_REQ_DECODE_FAIL,
658
"Failed to decode post commit "
659
"request received from peer");
660
req->rpc_err = GARBAGE_ARGS;
664
if (glusterd_peerinfo_find_by_uuid(op_req.uuid) == NULL) {
665
gf_msg(this->name, GF_LOG_WARNING, 0, GD_MSG_PEER_NOT_FOUND,
667
"belong to the cluster. Ignoring request.",
668
uuid_utoa(op_req.uuid));
675
gf_smsg(this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_CREATE_FAIL, NULL);
679
ret = dict_unserialize(op_req.dict.dict_val, op_req.dict.dict_len, &dict);
681
gf_smsg(this->name, GF_LOG_WARNING, 0, GD_MSG_DICT_UNSERIALIZE_FAIL,
686
rsp_dict = dict_new();
688
gf_smsg(this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_CREATE_FAIL, NULL);
692
ret = gd_mgmt_v3_post_commit_fn(op_req.op, dict, &op_errstr, &op_errno,
696
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_POST_COMMIT_OP_FAIL,
697
"post commit failed on operation %s", gd_op_list[op_req.op]);
700
ret = glusterd_mgmt_v3_post_commit_send_resp(req, op_req.op, ret, op_errstr,
703
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_MGMTV3_OP_RESP_FAIL,
704
"Failed to send post commit "
705
"response for operation %s",
706
gd_op_list[op_req.op]);
711
if (op_errstr && (strcmp(op_errstr, "")))
714
free(op_req.dict.dict_val);
720
dict_unref(rsp_dict);
727
glusterd_mgmt_v3_post_validate_send_resp(rpcsvc_request_t *req, int32_t op,
728
int32_t status, char *op_errstr,
731
gd1_mgmt_v3_post_val_rsp rsp = {
735
xlator_t *this = THIS;
740
glusterd_get_uuid(&rsp.uuid);
743
rsp.op_errstr = op_errstr;
747
ret = dict_allocate_and_serialize(rsp_dict, &rsp.dict.dict_val,
750
gf_smsg(this->name, GF_LOG_ERROR, 0,
751
GD_MSG_DICT_ALLOC_AND_SERL_LENGTH_GET_FAIL, NULL);
755
ret = glusterd_submit_reply(req, &rsp, NULL, 0, NULL,
756
(xdrproc_t)xdr_gd1_mgmt_v3_post_val_rsp);
758
GF_FREE(rsp.dict.dict_val);
760
gf_msg_debug(this->name, 0, "Responded to post validation, ret: %d", ret);
765
glusterd_handle_post_validate_fn(rpcsvc_request_t *req)
768
gd1_mgmt_v3_post_val_req op_req = {
771
xlator_t *this = THIS;
772
char *op_errstr = NULL;
774
dict_t *rsp_dict = NULL;
778
ret = xdr_to_generic(req->msg[0], &op_req,
779
(xdrproc_t)xdr_gd1_mgmt_v3_post_val_req);
781
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_REQ_DECODE_FAIL,
782
"Failed to decode post validation "
783
"request received from peer");
784
req->rpc_err = GARBAGE_ARGS;
788
if (glusterd_peerinfo_find_by_uuid(op_req.uuid) == NULL) {
789
gf_msg(this->name, GF_LOG_WARNING, 0, GD_MSG_PEER_NOT_FOUND,
791
"belong to the cluster. Ignoring request.",
792
uuid_utoa(op_req.uuid));
799
gf_smsg(this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_CREATE_FAIL, NULL);
803
ret = dict_unserialize(op_req.dict.dict_val, op_req.dict.dict_len, &dict);
805
gf_smsg(this->name, GF_LOG_WARNING, 0, GD_MSG_DICT_UNSERIALIZE_FAIL,
810
rsp_dict = dict_new();
812
gf_smsg(this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_CREATE_FAIL, NULL);
816
ret = gd_mgmt_v3_post_validate_fn(op_req.op, op_req.op_ret, dict,
817
&op_errstr, rsp_dict);
820
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_POST_VALIDATION_FAIL,
821
"Post Validation failed on operation %s", gd_op_list[op_req.op]);
824
ret = glusterd_mgmt_v3_post_validate_send_resp(req, op_req.op, ret,
825
op_errstr, rsp_dict);
827
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_MGMTV3_OP_RESP_FAIL,
828
"Failed to send Post Validation "
829
"response for operation %s",
830
gd_op_list[op_req.op]);
835
if (op_errstr && (strcmp(op_errstr, "")))
838
free(op_req.dict.dict_val);
844
dict_unref(rsp_dict);
851
glusterd_mgmt_v3_unlock_send_resp(rpcsvc_request_t *req, int32_t status)
853
gd1_mgmt_v3_unlock_rsp rsp = {
862
rsp.op_errno = errno;
864
glusterd_get_uuid(&rsp.uuid);
866
ret = glusterd_submit_reply(req, &rsp, NULL, 0, NULL,
867
(xdrproc_t)xdr_gd1_mgmt_v3_unlock_rsp);
869
gf_msg_debug(THIS->name, 0, "Responded to mgmt_v3 unlock, ret: %d", ret);
875
glusterd_syctasked_mgmt_v3_unlock(rpcsvc_request_t *req,
876
gd1_mgmt_v3_unlock_req *unlock_req,
877
glusterd_op_lock_ctx_t *ctx)
880
xlator_t *this = THIS;
886
ret = glusterd_multiple_mgmt_v3_unlock(ctx->dict, ctx->uuid);
888
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_MGMTV3_UNLOCK_FAIL,
889
"Failed to release mgmt_v3 locks for %s", uuid_utoa(ctx->uuid));
892
ret = glusterd_mgmt_v3_unlock_send_resp(req, ret);
894
gf_msg_trace(this->name, 0, "Returning %d", ret);
899
glusterd_op_state_machine_mgmt_v3_unlock(rpcsvc_request_t *req,
900
gd1_mgmt_v3_unlock_req *lock_req,
901
glusterd_op_lock_ctx_t *ctx)
904
xlator_t *this = THIS;
908
ret = glusterd_op_sm_inject_event(GD_OP_EVENT_UNLOCK, &lock_req->txn_id,
911
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_OP_EVENT_UNLOCK_FAIL,
912
"Failed to inject event GD_OP_EVENT_UNLOCK");
914
glusterd_friend_sm();
917
gf_msg_trace(this->name, 0, "Returning %d", ret);
922
glusterd_handle_mgmt_v3_unlock_fn(rpcsvc_request_t *req)
924
gd1_mgmt_v3_unlock_req lock_req = {
928
glusterd_op_lock_ctx_t *ctx = NULL;
929
xlator_t *this = THIS;
930
gf_boolean_t is_synctasked = _gf_false;
931
gf_boolean_t free_ctx = _gf_false;
935
ret = xdr_to_generic(req->msg[0], &lock_req,
936
(xdrproc_t)xdr_gd1_mgmt_v3_unlock_req);
938
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_REQ_DECODE_FAIL,
939
"Failed to decode unlock "
940
"request received from peer");
941
req->rpc_err = GARBAGE_ARGS;
945
gf_msg_debug(this->name, 0,
946
"Received volume unlock req "
948
uuid_utoa(lock_req.uuid));
950
if (glusterd_peerinfo_find_by_uuid(lock_req.uuid) == NULL) {
951
gf_msg(this->name, GF_LOG_WARNING, 0, GD_MSG_PEER_NOT_FOUND,
953
"belong to the cluster. Ignoring request.",
954
uuid_utoa(lock_req.uuid));
959
ctx = GF_CALLOC(1, sizeof(*ctx), gf_gld_mt_op_lock_ctx_t);
961
gf_smsg(this->name, GF_LOG_ERROR, 0, GD_MSG_NO_MEMORY, NULL);
966
gf_uuid_copy(ctx->uuid, lock_req.uuid);
969
ctx->dict = dict_new();
971
gf_smsg(this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_CREATE_FAIL, NULL);
976
ret = dict_unserialize(lock_req.dict.dict_val, lock_req.dict.dict_len,
979
gf_smsg(this->name, GF_LOG_WARNING, 0, GD_MSG_DICT_UNSERIALIZE_FAIL,
984
is_synctasked = dict_get_str_boolean(ctx->dict, "is_synctasked", _gf_false);
986
ret = glusterd_syctasked_mgmt_v3_unlock(req, &lock_req, ctx);
988
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_MGMTV3_UNLOCK_FAIL,
989
"Failed to release mgmt_v3_locks");
1005
ret = glusterd_op_state_machine_mgmt_v3_unlock(req, &lock_req, ctx);
1007
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_MGMTV3_UNLOCK_FAIL,
1008
"Failed to release mgmt_v3_locks");
1013
if (ctx && (ret || free_ctx)) {
1015
dict_unref(ctx->dict);
1020
free(lock_req.dict.dict_val);
1022
gf_msg_trace(this->name, 0, "Returning %d", ret);
1027
glusterd_handle_mgmt_v3_lock(rpcsvc_request_t *req)
1029
return glusterd_big_locked_handler(req, glusterd_handle_mgmt_v3_lock_fn);
1033
glusterd_handle_pre_validate(rpcsvc_request_t *req)
1035
return glusterd_big_locked_handler(req, glusterd_handle_pre_validate_fn);
1039
glusterd_handle_brick_op(rpcsvc_request_t *req)
1041
return glusterd_big_locked_handler(req, glusterd_handle_brick_op_fn);
1045
glusterd_handle_commit(rpcsvc_request_t *req)
1047
return glusterd_big_locked_handler(req, glusterd_handle_commit_fn);
1051
glusterd_handle_post_commit(rpcsvc_request_t *req)
1053
return glusterd_big_locked_handler(req, glusterd_handle_post_commit_fn);
1057
glusterd_handle_post_validate(rpcsvc_request_t *req)
1059
return glusterd_big_locked_handler(req, glusterd_handle_post_validate_fn);
1063
glusterd_handle_mgmt_v3_unlock(rpcsvc_request_t *req)
1065
return glusterd_big_locked_handler(req, glusterd_handle_mgmt_v3_unlock_fn);
1068
static rpcsvc_actor_t gd_svc_mgmt_v3_actors[GLUSTERD_MGMT_V3_MAXVALUE] = {
1069
[GLUSTERD_MGMT_V3_NULL] = {"NULL", glusterd_mgmt_v3_null, NULL,
1070
GLUSTERD_MGMT_V3_NULL, DRC_NA, 0},
1071
[GLUSTERD_MGMT_V3_LOCK] = {"MGMT_V3_LOCK", glusterd_handle_mgmt_v3_lock,
1072
NULL, GLUSTERD_MGMT_V3_LOCK, DRC_NA, 0},
1073
[GLUSTERD_MGMT_V3_PRE_VALIDATE] = {"PRE_VAL", glusterd_handle_pre_validate,
1074
NULL, GLUSTERD_MGMT_V3_PRE_VALIDATE,
1076
[GLUSTERD_MGMT_V3_BRICK_OP] = {"BRCK_OP", glusterd_handle_brick_op, NULL,
1077
GLUSTERD_MGMT_V3_BRICK_OP, DRC_NA, 0},
1078
[GLUSTERD_MGMT_V3_COMMIT] = {"COMMIT", glusterd_handle_commit, NULL,
1079
GLUSTERD_MGMT_V3_COMMIT, DRC_NA, 0},
1080
[GLUSTERD_MGMT_V3_POST_VALIDATE] = {"POST_VAL",
1081
glusterd_handle_post_validate, NULL,
1082
GLUSTERD_MGMT_V3_POST_VALIDATE, DRC_NA,
1084
[GLUSTERD_MGMT_V3_UNLOCK] = {"MGMT_V3_UNLOCK",
1085
glusterd_handle_mgmt_v3_unlock, NULL,
1086
GLUSTERD_MGMT_V3_UNLOCK, DRC_NA, 0},
1087
[GLUSTERD_MGMT_V3_POST_COMMIT] = {"POST_COMMIT",
1088
glusterd_handle_post_commit, NULL,
1089
GLUSTERD_MGMT_V3_POST_COMMIT, DRC_NA, 0},
1093
struct rpcsvc_program gd_svc_mgmt_v3_prog = {
1094
.progname = "GlusterD svc mgmt v3",
1095
.prognum = GD_MGMT_PROGRAM,
1096
.progver = GD_MGMT_V3_VERSION,
1097
.numactors = GLUSTERD_MGMT_V3_MAXVALUE,
1098
.actors = gd_svc_mgmt_v3_actors,
1099
.synctask = _gf_true,