2
Copyright (c) 2012-2012 Red Hat, Inc. <http://www.redhat.com>
3
This file is part of GlusterFS.
5
This file is licensed to you under your choice of the GNU Lesser
6
General Public License, version 3 or any later version (LGPLv3 or
7
later), or the GNU General Public License, version 2 (GPLv2), in all
8
cases as published by the Free Software Foundation.
10
/* rpc related syncops */
11
#include "glusterd-syncop.h"
12
#include "glusterd-mgmt.h"
15
#include "glusterd-op-sm.h"
16
#include "glusterd-utils.h"
17
#include "glusterd-server-quorum.h"
18
#include "glusterd-locks.h"
19
#include "glusterd-snapshot-utils.h"
20
#include "glusterd-messages.h"
21
#include "glusterd-errno.h"
23
extern glusterd_op_info_t opinfo;
26
gd_synctask_barrier_wait(struct syncargs *args, int count)
28
glusterd_conf_t *conf = THIS->private;
30
synclock_unlock(&conf->big_lock);
31
synctask_barrier_wait(args, count);
32
synclock_lock(&conf->big_lock);
36
gd_collate_errors(struct syncargs *args, int op_ret, int op_errno,
37
char *op_errstr, int op_code, uuid_t peerid, u_char *uuid)
39
char err_str[PATH_MAX] = "Please check log file for details.";
40
char op_err[PATH_MAX] = "";
42
char *peer_str = NULL;
43
glusterd_peerinfo_t *peerinfo = NULL;
46
args->op_ret = op_ret;
47
args->op_errno = op_errno;
50
peerinfo = glusterd_peerinfo_find(peerid, NULL);
52
peer_str = gf_strdup(peerinfo->hostname);
54
peer_str = gf_strdup(uuid_utoa(uuid));
57
if (op_errstr && strcmp(op_errstr, "")) {
58
len = snprintf(err_str, sizeof(err_str) - 1, "Error: %s",
64
case GLUSTERD_MGMT_CLUSTER_LOCK: {
65
len = snprintf(op_err, sizeof(op_err) - 1,
66
"Locking failed on %s. %s", peer_str, err_str);
69
case GLUSTERD_MGMT_CLUSTER_UNLOCK: {
70
len = snprintf(op_err, sizeof(op_err) - 1,
71
"Unlocking failed on %s. %s", peer_str, err_str);
74
case GLUSTERD_MGMT_STAGE_OP: {
75
len = snprintf(op_err, sizeof(op_err) - 1,
76
"Staging failed on %s. %s", peer_str, err_str);
79
case GLUSTERD_MGMT_COMMIT_OP: {
80
len = snprintf(op_err, sizeof(op_err) - 1,
81
"Commit failed on %s. %s", peer_str, err_str);
90
len = snprintf(err_str, sizeof(err_str) - 1, "%s\n%s", args->errstr,
92
GF_FREE(args->errstr);
95
len = snprintf(err_str, sizeof(err_str) - 1, "%s", op_err);
98
gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_MGMT_OP_FAIL, "%s", op_err);
99
args->errstr = gf_strdup(err_str);
108
gd_syncargs_init(struct syncargs *args, dict_t *op_ctx)
112
ret = pthread_mutex_init(&args->lock_dict, NULL);
116
ret = synctask_barrier_init(args);
118
pthread_mutex_destroy(&args->lock_dict);
127
gd_syncargs_fini(struct syncargs *args)
129
if (args->barrier.initialized) {
130
pthread_mutex_destroy(&args->lock_dict);
131
syncbarrier_destroy(&args->barrier);
136
gd_stage_op_req_free(gd1_mgmt_stage_op_req *req)
141
GF_FREE(req->buf.buf_val);
146
gd_commit_op_req_free(gd1_mgmt_commit_op_req *req)
151
GF_FREE(req->buf.buf_val);
156
gd_brick_op_req_free(gd1_mgmt_brick_op_req *req)
161
if (req->dict.dict_val)
162
GF_FREE(req->dict.dict_val);
163
GF_FREE(req->input.input_val);
168
gd_syncop_submit_request(struct rpc_clnt *rpc, void *req, void *local,
169
void *cookie, rpc_clnt_prog_t *prog, int procnum,
170
fop_cbk_fn_t cbkfn, xdrproc_t xdrproc)
173
struct iobuf *iobuf = NULL;
174
struct iobref *iobref = NULL;
179
ssize_t req_size = 0;
180
call_frame_t *frame = NULL;
186
req_size = xdr_sizeof(xdrproc, req);
187
iobuf = iobuf_get2(rpc->ctx->iobuf_pool, req_size);
191
iobref = iobref_new();
195
frame = create_frame(THIS, THIS->ctx->pool);
199
iobref_add(iobref, iobuf);
201
iov.iov_base = iobuf->ptr;
202
iov.iov_len = iobuf_pagesize(iobuf);
204
/* Create the xdr payload */
205
ret = xdr_serialize_generic(iov, req, xdrproc);
212
frame->local = local;
213
frame->cookie = cookie;
216
ret = rpc_clnt_submit(rpc, prog, procnum, cbkfn, &iov, count, NULL, 0,
217
iobref, frame, NULL, 0, NULL, 0, NULL);
219
/* TODO: do we need to start ping also? */
220
/* In case of error the frame will be destroy by rpc_clnt_submit */
224
iobref_unref(iobref);
228
STACK_DESTROY(frame->root);
232
/* Defined in glusterd-rpc-ops.c */
233
extern struct rpc_clnt_program gd_mgmt_prog;
234
extern struct rpc_clnt_program gd_brick_prog;
235
extern struct rpc_clnt_program gd_mgmt_v3_prog;
238
glusterd_append_gsync_status(dict_t *dst, dict_t *src)
241
char *stop_msg = NULL;
243
ret = dict_get_str(src, "gsync-status", &stop_msg);
245
gf_smsg("glusterd", GF_LOG_ERROR, -ret, GD_MSG_DICT_GET_FAILED,
246
"Key=gsync-status", NULL);
251
ret = dict_set_dynstr_with_alloc(dst, "gsync-status", stop_msg);
253
gf_msg("glusterd", GF_LOG_WARNING, 0, GD_MSG_DICT_SET_FAILED,
254
"Unable to set the stop"
255
"message in the ctx dictionary");
261
gf_msg_debug("glusterd", 0, "Returning %d", ret);
266
glusterd_append_status_dicts(dict_t *dst, dict_t *src)
268
char sts_val_name[PATH_MAX] = "";
273
gf_gsync_status_t *sts_val = NULL;
274
gf_gsync_status_t *dst_sts_val = NULL;
281
ret = dict_get_int32(dst, "gsync-count", &dst_count);
285
ret = dict_get_int32(src, "gsync-count", &src_count);
286
if (ret || !src_count) {
287
gf_msg_debug("glusterd", 0, "Source brick empty");
292
for (i = 0; i < src_count; i++) {
293
snprintf(sts_val_name, sizeof(sts_val_name), "status_value%d", i);
295
ret = dict_get_bin(src, sts_val_name, (void **)&sts_val);
299
dst_sts_val = GF_MALLOC(sizeof(gf_gsync_status_t),
300
gf_common_mt_gsync_status_t);
302
gf_msg("glusterd", GF_LOG_ERROR, ENOMEM, GD_MSG_NO_MEMORY,
307
memcpy(dst_sts_val, sts_val, sizeof(gf_gsync_status_t));
309
snprintf(sts_val_name, sizeof(sts_val_name), "status_value%d",
312
ret = dict_set_bin(dst, sts_val_name, dst_sts_val,
313
sizeof(gf_gsync_status_t));
315
GF_FREE(dst_sts_val);
320
ret = dict_set_int32_sizen(dst, "gsync-count", dst_count + src_count);
323
gf_msg_debug("glusterd", 0, "Returning %d", ret);
328
glusterd_gsync_use_rsp_dict(dict_t *aggr, dict_t *rsp_dict, char *op_errstr)
332
char *conf_path = NULL;
338
ctx = glusterd_op_get_ctx();
340
gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_OPCTX_GET_FAIL,
341
"Operation Context is not present");
347
ret = glusterd_append_status_dicts(ctx, rsp_dict);
351
ret = glusterd_append_gsync_status(ctx, rsp_dict);
355
ret = dict_get_str(rsp_dict, "conf_path", &conf_path);
356
if (!ret && conf_path) {
357
ret = dict_set_dynstr_with_alloc(ctx, "conf_path", conf_path);
359
gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED,
360
"Unable to store conf path.");
365
if ((op_errstr) && (strcmp("", op_errstr))) {
366
ret = dict_set_dynstr_with_alloc(ctx, "errstr", op_errstr);
373
gf_msg_debug("glusterd", 0, "Returning %d ", ret);
378
glusterd_max_opversion_use_rsp_dict(dict_t *dst, dict_t *src)
381
int src_max_opversion = -1;
382
int max_opversion = -1;
384
GF_VALIDATE_OR_GOTO(THIS->name, dst, out);
385
GF_VALIDATE_OR_GOTO(THIS->name, src, out);
387
ret = dict_get_int32(dst, "max-opversion", &max_opversion);
389
gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
390
"Maximum supported op-version not set in destination "
393
ret = dict_get_int32(src, "max-opversion", &src_max_opversion);
395
gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
396
"Failed to get maximum supported op-version from source");
400
if (max_opversion == -1 || src_max_opversion < max_opversion)
401
max_opversion = src_max_opversion;
403
ret = dict_set_int32_sizen(dst, "max-opversion", max_opversion);
405
gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED,
406
"Failed to set max op-version");
414
glusterd_volume_bitrot_scrub_use_rsp_dict(dict_t *aggr, dict_t *rsp_dict)
421
char *last_scrub_time = NULL;
422
char *scrub_time = NULL;
423
char *volname = NULL;
424
char *node_uuid = NULL;
425
char *node_uuid_str = NULL;
426
char *bitd_log = NULL;
427
char *scrub_log = NULL;
428
char *scrub_freq = NULL;
429
char *scrub_state = NULL;
430
char *scrub_impact = NULL;
431
char *bad_gfid_str = NULL;
432
xlator_t *this = THIS;
433
glusterd_conf_t *priv = NULL;
434
glusterd_volinfo_t *volinfo = NULL;
437
int8_t scrub_running = 0;
439
priv = this->private;
442
ret = dict_get_str(aggr, "volname", &volname);
444
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
445
"Unable to get volume name");
449
ret = glusterd_volinfo_find(volname, &volinfo);
451
gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_VOL_NOT_FOUND,
452
"Unable to find volinfo for volume: %s", volname);
456
ret = dict_get_int32(aggr, "count", &dst_count);
458
ret = dict_get_int32(rsp_dict, "count", &src_count);
460
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
461
"failed to get count value");
466
ret = dict_set_int32_sizen(aggr, "count", src_count + dst_count);
468
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED,
469
"Failed to set count in dictonary");
471
keylen = snprintf(key, sizeof(key), "node-uuid-%d", src_count);
472
ret = dict_get_strn(rsp_dict, key, keylen, &node_uuid);
474
node_uuid_str = gf_strdup(node_uuid);
475
keylen = snprintf(key, sizeof(key), "node-uuid-%d",
476
src_count + dst_count);
477
ret = dict_set_dynstrn(aggr, key, keylen, node_uuid_str);
479
gf_msg_debug(this->name, 0, "failed to set node-uuid");
483
snprintf(key, sizeof(key), "scrub-running-%d", src_count);
484
ret = dict_get_int8(rsp_dict, key, &scrub_running);
486
snprintf(key, sizeof(key), "scrub-running-%d", src_count + dst_count);
487
ret = dict_set_int8(aggr, key, scrub_running);
489
gf_msg_debug(this->name, 0,
491
"scrub-running value");
495
snprintf(key, sizeof(key), "scrubbed-files-%d", src_count);
496
ret = dict_get_uint64(rsp_dict, key, &value);
498
snprintf(key, sizeof(key), "scrubbed-files-%d", src_count + dst_count);
499
ret = dict_set_uint64(aggr, key, value);
501
gf_msg_debug(this->name, 0,
503
"scrubbed-file value");
507
snprintf(key, sizeof(key), "unsigned-files-%d", src_count);
508
ret = dict_get_uint64(rsp_dict, key, &value);
510
snprintf(key, sizeof(key), "unsigned-files-%d", src_count + dst_count);
511
ret = dict_set_uint64(aggr, key, value);
513
gf_msg_debug(this->name, 0,
515
"unsigned-file value");
519
keylen = snprintf(key, sizeof(key), "last-scrub-time-%d", src_count);
520
ret = dict_get_strn(rsp_dict, key, keylen, &last_scrub_time);
522
scrub_time = gf_strdup(last_scrub_time);
523
keylen = snprintf(key, sizeof(key), "last-scrub-time-%d",
524
src_count + dst_count);
525
ret = dict_set_dynstrn(aggr, key, keylen, scrub_time);
527
gf_msg_debug(this->name, 0,
529
"last scrub time value");
533
snprintf(key, sizeof(key), "scrub-duration-%d", src_count);
534
ret = dict_get_uint64(rsp_dict, key, &value);
536
snprintf(key, sizeof(key), "scrub-duration-%d", src_count + dst_count);
537
ret = dict_set_uint64(aggr, key, value);
539
gf_msg_debug(this->name, 0,
541
"scrubbed-duration value");
545
snprintf(key, sizeof(key), "error-count-%d", src_count);
546
ret = dict_get_uint64(rsp_dict, key, &value);
548
snprintf(key, sizeof(key), "error-count-%d", src_count + dst_count);
549
ret = dict_set_uint64(aggr, key, value);
551
gf_msg_debug(this->name, 0,
552
"Failed to set error "
556
/* Storing all the bad files in the dictionary */
557
for (j = 0; j < value; j++) {
558
keylen = snprintf(key, sizeof(key), "quarantine-%d-%d", j,
560
ret = dict_get_strn(rsp_dict, key, keylen, &bad_gfid_str);
562
snprintf(key, sizeof(key), "quarantine-%d-%d", j,
563
src_count + dst_count);
564
ret = dict_set_dynstr_with_alloc(aggr, key, bad_gfid_str);
566
gf_msg_debug(this->name, 0,
574
ret = dict_get_str(rsp_dict, "bitrot_log_file", &bitd_log);
576
ret = dict_set_dynstr_with_alloc(aggr, "bitrot_log_file", bitd_log);
578
gf_msg_debug(this->name, 0,
580
"bitrot log file location");
585
ret = dict_get_str(rsp_dict, "scrub_log_file", &scrub_log);
587
ret = dict_set_dynstr_with_alloc(aggr, "scrub_log_file", scrub_log);
589
gf_msg_debug(this->name, 0,
591
"scrubber log file location");
596
ret = dict_get_str(rsp_dict, "features.scrub-freq", &scrub_freq);
598
ret = dict_set_dynstr_with_alloc(aggr, "features.scrub-freq",
601
gf_msg_debug(this->name, 0,
603
"scrub-frequency value to dictionary");
608
ret = dict_get_str(rsp_dict, "features.scrub-throttle", &scrub_impact);
610
ret = dict_set_dynstr_with_alloc(aggr, "features.scrub-throttle",
613
gf_msg_debug(this->name, 0,
615
"scrub-throttle value to dictionary");
620
ret = dict_get_str(rsp_dict, "features.scrub", &scrub_state);
622
ret = dict_set_dynstr_with_alloc(aggr, "features.scrub", scrub_state);
624
gf_msg_debug(this->name, 0,
626
"scrub state value to dictionary");
637
glusterd_sys_exec_output_rsp_dict(dict_t *dst, dict_t *src)
639
char output_name[64] = "";
644
int src_output_count = 0;
645
int dst_output_count = 0;
648
gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_DICT_EMPTY,
649
"Source or Destination "
654
ret = dict_get_int32(dst, "output_count", &dst_output_count);
656
ret = dict_get_int32(src, "output_count", &src_output_count);
658
gf_msg_debug("glusterd", 0, "No output from source");
663
for (i = 1; i <= src_output_count; i++) {
664
keylen = snprintf(output_name, sizeof(output_name), "output_%d", i);
665
if (keylen <= 0 || keylen >= sizeof(output_name)) {
669
ret = dict_get_strn(src, output_name, keylen, &output);
671
gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
672
"Unable to fetch %s", output_name);
676
keylen = snprintf(output_name, sizeof(output_name), "output_%d",
677
i + dst_output_count);
678
if (keylen <= 0 || keylen >= sizeof(output_name)) {
683
ret = dict_set_dynstrn(dst, output_name, keylen, gf_strdup(output));
685
gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED,
686
"Unable to set %s", output_name);
691
ret = dict_set_int32_sizen(dst, "output_count",
692
dst_output_count + src_output_count);
694
gf_msg_debug("glusterd", 0, "Returning %d", ret);
699
glusterd_use_rsp_dict(dict_t *aggr, dict_t *rsp_dict)
707
dict_copy(rsp_dict, aggr);
713
glusterd_volume_heal_use_rsp_dict(dict_t *aggr, dict_t *rsp_dict)
716
dict_t *ctx_dict = NULL;
717
uuid_t *txn_id = NULL;
718
glusterd_op_info_t txn_op_info = {
721
glusterd_op_t op = GD_OP_NONE;
725
ret = dict_get_bin(aggr, "transaction_id", (void **)&txn_id);
728
gf_msg_debug(THIS->name, 0, "transaction ID = %s", uuid_utoa(*txn_id));
730
ret = glusterd_get_txn_opinfo(txn_id, &txn_op_info);
732
gf_msg_callingfn(THIS->name, GF_LOG_ERROR, 0,
733
GD_MSG_TRANS_OPINFO_GET_FAIL,
734
"Unable to get transaction opinfo "
735
"for transaction ID : %s",
741
GF_ASSERT(GD_OP_HEAL_VOLUME == op);
747
ctx_dict = txn_op_info.op_ctx;
752
dict_copy(rsp_dict, ctx_dict);
758
glusterd_volume_quota_copy_to_op_ctx_dict(dict_t *dict, dict_t *rsp_dict)
763
int rsp_dict_count = 0;
764
char *uuid_str = NULL;
765
char *uuid_str_dup = NULL;
768
xlator_t *this = THIS;
769
int type = GF_QUOTA_OPTION_TYPE_NONE;
771
ret = dict_get_int32(dict, "type", &type);
773
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
774
"Failed to get quota opcode");
778
if ((type != GF_QUOTA_OPTION_TYPE_LIMIT_USAGE) &&
779
(type != GF_QUOTA_OPTION_TYPE_LIMIT_OBJECTS) &&
780
(type != GF_QUOTA_OPTION_TYPE_REMOVE) &&
781
(type != GF_QUOTA_OPTION_TYPE_REMOVE_OBJECTS)) {
782
dict_copy(rsp_dict, dict);
787
ret = dict_get_int32(rsp_dict, "count", &rsp_dict_count);
789
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
790
"Failed to get the count of "
791
"gfids from the rsp dict");
795
ret = dict_get_int32(dict, "count", &count);
797
/* The key "count" is absent in op_ctx when this function is
798
* called after self-staging on the originator. This must not
799
* be treated as error.
801
gf_msg_debug(this->name, 0,
802
"Failed to get count of gfids"
803
" from req dict. This could be because count is not yet"
804
" copied from rsp_dict into op_ctx");
806
for (i = 0; i < rsp_dict_count; i++) {
807
keylen = snprintf(key, sizeof(key), "gfid%d", i);
808
ret = dict_get_strn(rsp_dict, key, keylen, &uuid_str);
810
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
811
"Failed to get gfid "
816
uuid_str_dup = gf_strdup(uuid_str);
822
keylen = snprintf(key, sizeof(key), "gfid%d", i + count);
823
ret = dict_set_dynstrn(dict, key, keylen, uuid_str_dup);
825
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED,
826
"Failed to set gfid "
827
"from rsp dict into req dict");
828
GF_FREE(uuid_str_dup);
833
ret = dict_set_int32_sizen(dict, "count", rsp_dict_count + count);
835
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED,
836
"Failed to set aggregated "
837
"count in req dict");
846
glusterd_syncop_aggr_rsp_dict(glusterd_op_t op, dict_t *aggr, dict_t *rsp)
851
case GD_OP_CREATE_VOLUME:
852
case GD_OP_ADD_BRICK:
853
case GD_OP_START_VOLUME:
854
ret = glusterd_aggr_brick_mount_dirs(aggr, rsp);
856
gf_msg(THIS->name, GF_LOG_ERROR, 0,
857
GD_MSG_BRICK_MOUNDIRS_AGGR_FAIL,
859
"aggregate brick mount dirs");
864
case GD_OP_REPLACE_BRICK:
865
case GD_OP_RESET_BRICK:
866
ret = glusterd_rb_use_rsp_dict(aggr, rsp);
871
case GD_OP_SYNC_VOLUME:
872
ret = glusterd_sync_use_rsp_dict(aggr, rsp);
877
case GD_OP_GSYNC_CREATE:
880
case GD_OP_GSYNC_SET:
881
ret = glusterd_gsync_use_rsp_dict(aggr, rsp, NULL);
886
case GD_OP_STATUS_VOLUME:
887
ret = glusterd_volume_status_copy_to_op_ctx_dict(aggr, rsp);
892
case GD_OP_HEAL_VOLUME:
893
ret = glusterd_volume_heal_use_rsp_dict(aggr, rsp);
899
case GD_OP_CLEARLOCKS_VOLUME:
900
ret = glusterd_use_rsp_dict(aggr, rsp);
906
ret = glusterd_volume_quota_copy_to_op_ctx_dict(aggr, rsp);
912
ret = glusterd_sys_exec_output_rsp_dict(aggr, rsp);
918
ret = glusterd_snap_use_rsp_dict(aggr, rsp);
923
case GD_OP_SCRUB_STATUS:
924
ret = glusterd_volume_bitrot_scrub_use_rsp_dict(aggr, rsp);
927
case GD_OP_SCRUB_ONDEMAND:
930
case GD_OP_MAX_OPVERSION:
931
ret = glusterd_max_opversion_use_rsp_dict(aggr, rsp);
934
case GD_OP_PROFILE_VOLUME:
935
ret = glusterd_profile_volume_use_rsp_dict(aggr, rsp);
938
case GD_OP_REBALANCE:
939
case GD_OP_DEFRAG_BRICK_VOLUME:
940
ret = glusterd_volume_rebalance_use_rsp_dict(aggr, rsp);
951
gd_syncop_mgmt_v3_lock_cbk_fn(struct rpc_req *req, struct iovec *iov, int count,
955
struct syncargs *args = NULL;
956
gd1_mgmt_v3_lock_rsp rsp = {
959
call_frame_t *frame = NULL;
962
uuid_t *peerid = NULL;
969
peerid = frame->cookie;
971
frame->cookie = NULL;
973
if (-1 == req->rpc_status) {
978
GF_VALIDATE_OR_GOTO_WITH_ERROR(THIS->name, iov, out, op_errno, EINVAL);
980
ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gd1_mgmt_v3_lock_rsp);
984
gf_uuid_copy(args->uuid, rsp.uuid);
987
op_errno = rsp.op_errno;
989
gd_mgmt_v3_collate_errors(args, op_ret, op_errno, NULL,
990
GLUSTERD_MGMT_V3_LOCK, *peerid, rsp.uuid);
993
/* req->rpc_status set to -1 means, STACK_DESTROY will be called from
994
* the caller function.
996
if (req->rpc_status != -1)
997
STACK_DESTROY(frame->root);
998
synctask_barrier_wake(args);
1003
gd_syncop_mgmt_v3_lock_cbk(struct rpc_req *req, struct iovec *iov, int count,
1006
return glusterd_big_locked_cbk(req, iov, count, myframe,
1007
gd_syncop_mgmt_v3_lock_cbk_fn);
1011
gd_syncop_mgmt_v3_lock(glusterd_op_t op, dict_t *op_ctx,
1012
glusterd_peerinfo_t *peerinfo, struct syncargs *args,
1013
uuid_t my_uuid, uuid_t recv_uuid, uuid_t txn_id)
1016
gd1_mgmt_v3_lock_req req = {
1019
uuid_t *peerid = NULL;
1022
GF_ASSERT(peerinfo);
1025
ret = dict_allocate_and_serialize(op_ctx, &req.dict.dict_val,
1026
&req.dict.dict_len);
1028
gf_smsg("glusterd", GF_LOG_ERROR, errno,
1029
GD_MSG_DICT_ALLOC_AND_SERL_LENGTH_GET_FAIL, NULL);
1033
gf_uuid_copy(req.uuid, my_uuid);
1034
gf_uuid_copy(req.txn_id, txn_id);
1037
GD_ALLOC_COPY_UUID(peerid, peerinfo->uuid, ret);
1041
ret = gd_syncop_submit_request(peerinfo->rpc, &req, args, peerid,
1042
&gd_mgmt_v3_prog, GLUSTERD_MGMT_V3_LOCK,
1043
gd_syncop_mgmt_v3_lock_cbk,
1044
(xdrproc_t)xdr_gd1_mgmt_v3_lock_req);
1046
GF_FREE(req.dict.dict_val);
1047
gf_msg_debug("glusterd", 0, "Returning %d", ret);
1052
gd_syncop_mgmt_v3_unlock_cbk_fn(struct rpc_req *req, struct iovec *iov,
1053
int count, void *myframe)
1056
struct syncargs *args = NULL;
1057
gd1_mgmt_v3_unlock_rsp rsp = {
1060
call_frame_t *frame = NULL;
1063
uuid_t *peerid = NULL;
1069
args = frame->local;
1070
peerid = frame->cookie;
1071
frame->local = NULL;
1072
frame->cookie = NULL;
1074
if (-1 == req->rpc_status) {
1075
op_errno = ENOTCONN;
1079
GF_VALIDATE_OR_GOTO_WITH_ERROR(THIS->name, iov, out, op_errno, EINVAL);
1081
ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gd1_mgmt_v3_unlock_rsp);
1085
gf_uuid_copy(args->uuid, rsp.uuid);
1087
op_ret = rsp.op_ret;
1088
op_errno = rsp.op_errno;
1090
gd_mgmt_v3_collate_errors(args, op_ret, op_errno, NULL,
1091
GLUSTERD_MGMT_V3_UNLOCK, *peerid, rsp.uuid);
1094
/* req->rpc_status set to -1 means, STACK_DESTROY will be called from
1095
* the caller function.
1097
if (req->rpc_status != -1)
1098
STACK_DESTROY(frame->root);
1099
synctask_barrier_wake(args);
1104
gd_syncop_mgmt_v3_unlock_cbk(struct rpc_req *req, struct iovec *iov, int count,
1107
return glusterd_big_locked_cbk(req, iov, count, myframe,
1108
gd_syncop_mgmt_v3_unlock_cbk_fn);
1112
gd_syncop_mgmt_v3_unlock(dict_t *op_ctx, glusterd_peerinfo_t *peerinfo,
1113
struct syncargs *args, uuid_t my_uuid,
1114
uuid_t recv_uuid, uuid_t txn_id)
1117
gd1_mgmt_v3_unlock_req req = {
1120
uuid_t *peerid = NULL;
1123
GF_ASSERT(peerinfo);
1126
ret = dict_allocate_and_serialize(op_ctx, &req.dict.dict_val,
1127
&req.dict.dict_len);
1129
gf_smsg("glusterd", GF_LOG_ERROR, errno,
1130
GD_MSG_DICT_ALLOC_AND_SERL_LENGTH_GET_FAIL, NULL);
1134
gf_uuid_copy(req.uuid, my_uuid);
1135
gf_uuid_copy(req.txn_id, txn_id);
1137
GD_ALLOC_COPY_UUID(peerid, peerinfo->uuid, ret);
1141
ret = gd_syncop_submit_request(peerinfo->rpc, &req, args, peerid,
1142
&gd_mgmt_v3_prog, GLUSTERD_MGMT_V3_UNLOCK,
1143
gd_syncop_mgmt_v3_unlock_cbk,
1144
(xdrproc_t)xdr_gd1_mgmt_v3_unlock_req);
1146
GF_FREE(req.dict.dict_val);
1147
gf_msg_debug("glusterd", 0, "Returning %d", ret);
1152
_gd_syncop_mgmt_lock_cbk(struct rpc_req *req, struct iovec *iov, int count,
1156
struct syncargs *args = NULL;
1157
glusterd_peerinfo_t *peerinfo = NULL;
1158
gd1_mgmt_cluster_lock_rsp rsp = {
1161
call_frame_t *frame = NULL;
1164
xlator_t *this = THIS;
1165
uuid_t *peerid = NULL;
1168
args = frame->local;
1169
peerid = frame->cookie;
1170
frame->local = NULL;
1171
frame->cookie = NULL;
1173
if (-1 == req->rpc_status) {
1174
op_errno = ENOTCONN;
1178
GF_VALIDATE_OR_GOTO_WITH_ERROR(this->name, iov, out, op_errno, EINVAL);
1180
ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gd1_mgmt_cluster_lock_rsp);
1184
gf_uuid_copy(args->uuid, rsp.uuid);
1187
peerinfo = glusterd_peerinfo_find(*peerid, NULL);
1189
/* Set peer as locked, so we unlock only the locked peers */
1190
if (rsp.op_ret == 0)
1191
peerinfo->locked = _gf_true;
1196
gf_msg(this->name, GF_LOG_ERROR, EINVAL, GD_MSG_PEER_NOT_FOUND,
1197
"Could not find peer with "
1199
uuid_utoa(*peerid));
1202
op_ret = rsp.op_ret;
1203
op_errno = rsp.op_errno;
1205
gd_collate_errors(args, op_ret, op_errno, NULL, GLUSTERD_MGMT_CLUSTER_LOCK,
1209
/* req->rpc_status set to -1 means, STACK_DESTROY will be called from
1210
* the caller function.
1212
if (req->rpc_status != -1)
1213
STACK_DESTROY(frame->root);
1214
synctask_barrier_wake(args);
1219
gd_syncop_mgmt_lock_cbk(struct rpc_req *req, struct iovec *iov, int count,
1222
return glusterd_big_locked_cbk(req, iov, count, myframe,
1223
_gd_syncop_mgmt_lock_cbk);
1227
gd_syncop_mgmt_lock(glusterd_peerinfo_t *peerinfo, struct syncargs *args,
1228
uuid_t my_uuid, uuid_t recv_uuid)
1231
gd1_mgmt_cluster_lock_req req = {
1234
uuid_t *peerid = NULL;
1236
gf_uuid_copy(req.uuid, my_uuid);
1237
GD_ALLOC_COPY_UUID(peerid, peerinfo->uuid, ret);
1241
ret = gd_syncop_submit_request(peerinfo->rpc, &req, args, peerid,
1242
&gd_mgmt_prog, GLUSTERD_MGMT_CLUSTER_LOCK,
1243
gd_syncop_mgmt_lock_cbk,
1244
(xdrproc_t)xdr_gd1_mgmt_cluster_lock_req);
1250
_gd_syncop_mgmt_unlock_cbk(struct rpc_req *req, struct iovec *iov, int count,
1254
struct syncargs *args = NULL;
1255
glusterd_peerinfo_t *peerinfo = NULL;
1256
gd1_mgmt_cluster_unlock_rsp rsp = {
1259
call_frame_t *frame = NULL;
1262
xlator_t *this = THIS;
1263
uuid_t *peerid = NULL;
1266
args = frame->local;
1267
peerid = frame->cookie;
1268
frame->local = NULL;
1269
frame->cookie = NULL;
1271
if (-1 == req->rpc_status) {
1272
op_errno = ENOTCONN;
1276
GF_VALIDATE_OR_GOTO_WITH_ERROR(this->name, iov, out, op_errno, EINVAL);
1278
ret = xdr_to_generic(*iov, &rsp,
1279
(xdrproc_t)xdr_gd1_mgmt_cluster_unlock_rsp);
1283
gf_uuid_copy(args->uuid, rsp.uuid);
1286
peerinfo = glusterd_peerinfo_find(*peerid, NULL);
1288
peerinfo->locked = _gf_false;
1293
gf_msg(this->name, GF_LOG_ERROR, EINVAL, GD_MSG_PEER_NOT_FOUND,
1294
"Could not find peer with "
1296
uuid_utoa(*peerid));
1299
op_ret = rsp.op_ret;
1300
op_errno = rsp.op_errno;
1302
gd_collate_errors(args, op_ret, op_errno, NULL,
1303
GLUSTERD_MGMT_CLUSTER_UNLOCK, *peerid, rsp.uuid);
1306
/* req->rpc_status set to -1 means, STACK_DESTROY will be called from
1307
* the caller function.
1309
if (req->rpc_status != -1)
1310
STACK_DESTROY(frame->root);
1311
synctask_barrier_wake(args);
1316
gd_syncop_mgmt_unlock_cbk(struct rpc_req *req, struct iovec *iov, int count,
1319
return glusterd_big_locked_cbk(req, iov, count, myframe,
1320
_gd_syncop_mgmt_unlock_cbk);
1324
gd_syncop_mgmt_unlock(glusterd_peerinfo_t *peerinfo, struct syncargs *args,
1325
uuid_t my_uuid, uuid_t recv_uuid)
1328
gd1_mgmt_cluster_unlock_req req = {
1331
uuid_t *peerid = NULL;
1333
gf_uuid_copy(req.uuid, my_uuid);
1334
GD_ALLOC_COPY_UUID(peerid, peerinfo->uuid, ret);
1338
ret = gd_syncop_submit_request(peerinfo->rpc, &req, args, peerid,
1339
&gd_mgmt_prog, GLUSTERD_MGMT_CLUSTER_UNLOCK,
1340
gd_syncop_mgmt_unlock_cbk,
1341
(xdrproc_t)xdr_gd1_mgmt_cluster_lock_req);
1347
_gd_syncop_stage_op_cbk(struct rpc_req *req, struct iovec *iov, int count,
1351
gd1_mgmt_stage_op_rsp rsp = {
1354
struct syncargs *args = NULL;
1355
xlator_t *this = THIS;
1356
dict_t *rsp_dict = NULL;
1357
call_frame_t *frame = NULL;
1360
uuid_t *peerid = NULL;
1363
args = frame->local;
1364
peerid = frame->cookie;
1365
frame->local = NULL;
1366
frame->cookie = NULL;
1368
if (-1 == req->rpc_status) {
1369
op_errno = ENOTCONN;
1373
GF_VALIDATE_OR_GOTO_WITH_ERROR(this->name, iov, out, op_errno, EINVAL);
1375
ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gd1_mgmt_stage_op_rsp);
1379
if (rsp.dict.dict_len) {
1380
/* Unserialize the dictionary */
1381
rsp_dict = dict_new();
1383
ret = dict_unserialize(rsp.dict.dict_val, rsp.dict.dict_len, &rsp_dict);
1385
GF_FREE(rsp.dict.dict_val);
1388
rsp_dict->extra_stdfree = rsp.dict.dict_val;
1393
ret = (glusterd_peerinfo_find(rsp.uuid, NULL) == NULL);
1397
gf_msg(this->name, GF_LOG_CRITICAL, 0, GD_MSG_RESP_FROM_UNKNOWN_PEER,
1399
"for 'Volume %s' received from unknown "
1401
gd_op_list[rsp.op], uuid_utoa(rsp.uuid));
1405
gf_uuid_copy(args->uuid, rsp.uuid);
1406
if (rsp.op == GD_OP_REPLACE_BRICK || rsp.op == GD_OP_QUOTA ||
1407
rsp.op == GD_OP_CREATE_VOLUME || rsp.op == GD_OP_ADD_BRICK ||
1408
rsp.op == GD_OP_START_VOLUME) {
1409
pthread_mutex_lock(&args->lock_dict);
1411
ret = glusterd_syncop_aggr_rsp_dict(rsp.op, args->dict, rsp_dict);
1413
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_RESP_AGGR_FAIL, "%s",
1414
"Failed to aggregate response from "
1417
pthread_mutex_unlock(&args->lock_dict);
1420
op_ret = rsp.op_ret;
1421
op_errno = rsp.op_errno;
1424
gd_collate_errors(args, op_ret, op_errno, rsp.op_errstr,
1425
GLUSTERD_MGMT_STAGE_OP, *peerid, rsp.uuid);
1428
dict_unref(rsp_dict);
1430
/* req->rpc_status set to -1 means, STACK_DESTROY will be called from
1431
* the caller function.
1433
if (req->rpc_status != -1)
1434
STACK_DESTROY(frame->root);
1435
synctask_barrier_wake(args);
1440
gd_syncop_stage_op_cbk(struct rpc_req *req, struct iovec *iov, int count,
1443
return glusterd_big_locked_cbk(req, iov, count, myframe,
1444
_gd_syncop_stage_op_cbk);
1448
gd_syncop_mgmt_stage_op(glusterd_peerinfo_t *peerinfo, struct syncargs *args,
1449
uuid_t my_uuid, uuid_t recv_uuid, int op,
1450
dict_t *dict_out, dict_t *op_ctx)
1452
gd1_mgmt_stage_op_req *req = NULL;
1454
uuid_t *peerid = NULL;
1456
req = GF_CALLOC(1, sizeof(*req), gf_gld_mt_mop_stage_req_t);
1458
gf_smsg("glusterd", GF_LOG_ERROR, errno, GD_MSG_NO_MEMORY, NULL);
1462
gf_uuid_copy(req->uuid, my_uuid);
1465
ret = dict_allocate_and_serialize(dict_out, &req->buf.buf_val,
1468
gf_smsg("glusterd", GF_LOG_ERROR, errno,
1469
GD_MSG_DICT_ALLOC_AND_SERL_LENGTH_GET_FAIL, NULL);
1473
GD_ALLOC_COPY_UUID(peerid, peerinfo->uuid, ret);
1477
ret = gd_syncop_submit_request(
1478
peerinfo->rpc, req, args, peerid, &gd_mgmt_prog, GLUSTERD_MGMT_STAGE_OP,
1479
gd_syncop_stage_op_cbk, (xdrproc_t)xdr_gd1_mgmt_stage_op_req);
1481
gd_stage_op_req_free(req);
1486
_gd_syncop_brick_op_cbk(struct rpc_req *req, struct iovec *iov, int count,
1489
struct syncargs *args = NULL;
1490
gd1_mgmt_brick_op_rsp rsp = {
1494
call_frame_t *frame = NULL;
1495
xlator_t *this = THIS;
1498
args = frame->local;
1499
frame->local = NULL;
1503
args->op_errno = EINVAL;
1505
if (-1 == req->rpc_status) {
1506
args->op_errno = ENOTCONN;
1510
GF_VALIDATE_OR_GOTO_WITH_ERROR(this->name, iov, out, args->op_errno,
1513
ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gd1_mgmt_brick_op_rsp);
1517
if (rsp.output.output_len) {
1518
args->dict = dict_new();
1520
gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_CREATE_FAIL,
1523
args->op_errno = ENOMEM;
1527
ret = dict_unserialize(rsp.output.output_val, rsp.output.output_len,
1530
gf_smsg(this->name, GF_LOG_ERROR, errno,
1531
GD_MSG_DICT_UNSERIALIZE_FAIL, NULL);
1536
args->op_ret = rsp.op_ret;
1537
args->op_errno = rsp.op_errno;
1538
args->errstr = gf_strdup(rsp.op_errstr);
1541
if ((rsp.op_errstr) && (strcmp(rsp.op_errstr, "") != 0))
1542
free(rsp.op_errstr);
1543
free(rsp.output.output_val);
1545
/* req->rpc_status set to -1 means, STACK_DESTROY will be called from
1546
* the caller function.
1548
if (req->rpc_status != -1)
1549
STACK_DESTROY(frame->root);
1556
gd_syncop_brick_op_cbk(struct rpc_req *req, struct iovec *iov, int count,
1559
return glusterd_big_locked_cbk(req, iov, count, myframe,
1560
_gd_syncop_brick_op_cbk);
1564
gd_syncop_mgmt_brick_op(struct rpc_clnt *rpc, glusterd_pending_node_t *pnode,
1565
int op, dict_t *dict_out, dict_t *op_ctx, char **errstr)
1567
struct syncargs args = {
1570
gd1_mgmt_brick_op_req *req = NULL;
1574
args.op_errno = ENOTCONN;
1576
if ((pnode->type == GD_NODE_NFS) || (pnode->type == GD_NODE_QUOTAD) ||
1577
(pnode->type == GD_NODE_SCRUB) ||
1578
((pnode->type == GD_NODE_SHD) && (op == GD_OP_STATUS_VOLUME))) {
1579
ret = glusterd_node_op_build_payload(op, &req, dict_out);
1582
ret = glusterd_brick_op_build_payload(op, pnode->node, &req, dict_out);
1588
GD_SYNCOP(rpc, (&args), NULL, gd_syncop_brick_op_cbk, req, &gd_brick_prog,
1589
req->op, xdr_gd1_mgmt_brick_op_req);
1592
if ((strlen(args.errstr) > 0) && errstr)
1593
*errstr = args.errstr;
1595
GF_FREE(args.errstr);
1598
if (GD_OP_STATUS_VOLUME == op) {
1599
ret = dict_set_int32(args.dict, "index", pnode->index);
1601
gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED,
1602
"Error setting index on brick status"
1609
if (req->op == GLUSTERD_BRICK_TERMINATE) {
1610
if (args.op_ret && (args.op_errno == ENOTCONN)) {
1612
* This is actually OK. It happens when the target
1613
* brick process exits and we saw the closed connection
1614
* before we read the response. If we didn't read the
1615
* response quickly enough that's kind of our own
1616
* fault, and the fact that the process exited means
1617
* that our goal of terminating the brick was achieved.
1623
if (args.op_ret == 0)
1624
glusterd_handle_node_rsp(dict_out, pnode->node, op, args.dict, op_ctx,
1625
errstr, pnode->type);
1628
errno = args.op_errno;
1630
dict_unref(args.dict);
1631
if (args.op_ret && errstr && (*errstr == NULL)) {
1632
if (op == GD_OP_HEAL_VOLUME) {
1634
"Glusterd Syncop Mgmt brick op '%s' failed."
1635
" Please check glustershd log file for details.",
1639
"Glusterd Syncop Mgmt brick op '%s' failed."
1640
" Please check brick log file for details.",
1644
gd_brick_op_req_free(req);
1649
_gd_syncop_commit_op_cbk(struct rpc_req *req, struct iovec *iov, int count,
1653
gd1_mgmt_commit_op_rsp rsp = {
1656
struct syncargs *args = NULL;
1657
xlator_t *this = THIS;
1658
dict_t *rsp_dict = NULL;
1659
call_frame_t *frame = NULL;
1662
int type = GF_QUOTA_OPTION_TYPE_NONE;
1663
uuid_t *peerid = NULL;
1666
args = frame->local;
1667
peerid = frame->cookie;
1668
frame->local = NULL;
1669
frame->cookie = NULL;
1671
if (-1 == req->rpc_status) {
1672
op_errno = ENOTCONN;
1676
GF_VALIDATE_OR_GOTO_WITH_ERROR(this->name, iov, out, op_errno, EINVAL);
1678
ret = xdr_to_generic(*iov, &rsp, (xdrproc_t)xdr_gd1_mgmt_commit_op_rsp);
1683
if (rsp.dict.dict_len) {
1684
/* Unserialize the dictionary */
1685
rsp_dict = dict_new();
1687
ret = dict_unserialize(rsp.dict.dict_val, rsp.dict.dict_len, &rsp_dict);
1689
GF_FREE(rsp.dict.dict_val);
1692
rsp_dict->extra_stdfree = rsp.dict.dict_val;
1697
ret = (glusterd_peerinfo_find(rsp.uuid, NULL) == 0);
1701
gf_msg(this->name, GF_LOG_CRITICAL, 0, GD_MSG_RESP_FROM_UNKNOWN_PEER,
1703
"for 'Volume %s' received from unknown "
1705
gd_op_list[rsp.op], uuid_utoa(rsp.uuid));
1709
gf_uuid_copy(args->uuid, rsp.uuid);
1710
if (rsp.op == GD_OP_QUOTA) {
1711
ret = dict_get_int32(args->dict, "type", &type);
1713
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
1720
if ((rsp.op != GD_OP_QUOTA) || (type == GF_QUOTA_OPTION_TYPE_LIST)) {
1721
pthread_mutex_lock(&args->lock_dict);
1723
ret = glusterd_syncop_aggr_rsp_dict(rsp.op, args->dict, rsp_dict);
1725
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_RESP_AGGR_FAIL, "%s",
1726
"Failed to aggregate response from "
1729
pthread_mutex_unlock(&args->lock_dict);
1732
op_ret = rsp.op_ret;
1733
op_errno = rsp.op_errno;
1736
gd_collate_errors(args, op_ret, op_errno, rsp.op_errstr,
1737
GLUSTERD_MGMT_COMMIT_OP, *peerid, rsp.uuid);
1739
dict_unref(rsp_dict);
1741
/* req->rpc_status set to -1 means, STACK_DESTROY will be called from
1742
* the caller function.
1744
if (req->rpc_status != -1)
1745
STACK_DESTROY(frame->root);
1746
synctask_barrier_wake(args);
1752
gd_syncop_commit_op_cbk(struct rpc_req *req, struct iovec *iov, int count,
1755
return glusterd_big_locked_cbk(req, iov, count, myframe,
1756
_gd_syncop_commit_op_cbk);
1760
gd_syncop_mgmt_commit_op(glusterd_peerinfo_t *peerinfo, struct syncargs *args,
1761
uuid_t my_uuid, uuid_t recv_uuid, int op,
1762
dict_t *dict_out, dict_t *op_ctx)
1764
gd1_mgmt_commit_op_req *req = NULL;
1766
uuid_t *peerid = NULL;
1768
req = GF_CALLOC(1, sizeof(*req), gf_gld_mt_mop_commit_req_t);
1770
gf_smsg("glusterd", GF_LOG_ERROR, errno, GD_MSG_NO_MEMORY, NULL);
1774
gf_uuid_copy(req->uuid, my_uuid);
1777
ret = dict_allocate_and_serialize(dict_out, &req->buf.buf_val,
1780
gf_smsg("glusterd", GF_LOG_ERROR, errno,
1781
GD_MSG_DICT_ALLOC_AND_SERL_LENGTH_GET_FAIL, NULL);
1785
GD_ALLOC_COPY_UUID(peerid, peerinfo->uuid, ret);
1789
ret = gd_syncop_submit_request(peerinfo->rpc, req, args, peerid,
1790
&gd_mgmt_prog, GLUSTERD_MGMT_COMMIT_OP,
1791
gd_syncop_commit_op_cbk,
1792
(xdrproc_t)xdr_gd1_mgmt_commit_op_req);
1794
gd_commit_op_req_free(req);
1799
gd_lock_op_phase(glusterd_conf_t *conf, glusterd_op_t op, dict_t *op_ctx,
1800
char **op_errstr, uuid_t txn_id,
1801
glusterd_op_info_t *txn_opinfo, gf_boolean_t cluster_lock)
1805
uuid_t peer_uuid = {0};
1806
xlator_t *this = THIS;
1807
glusterd_peerinfo_t *peerinfo = NULL;
1808
struct syncargs args = {0};
1810
ret = synctask_barrier_init((&args));
1817
cds_list_for_each_entry_rcu(peerinfo, &conf->peers, uuid_list)
1819
/* Only send requests to peers who were available before the
1820
* transaction started
1822
if (peerinfo->generation > txn_opinfo->txn_generation)
1825
if (!peerinfo->connected)
1827
if (op != GD_OP_SYNC_VOLUME &&
1828
peerinfo->state != GD_FRIEND_STATE_BEFRIENDED)
1832
/* Reset lock status */
1833
peerinfo->locked = _gf_false;
1834
gd_syncop_mgmt_lock(peerinfo, &args, MY_UUID, peer_uuid);
1836
gd_syncop_mgmt_v3_lock(op, op_ctx, peerinfo, &args, MY_UUID,
1842
if (0 == peer_cnt) {
1847
gd_synctask_barrier_wait((&args), peer_cnt);
1851
*op_errstr = gf_strdup(args.errstr);
1853
ret = gf_asprintf(op_errstr,
1854
"Another transaction "
1855
"could be in progress. Please try "
1856
"again after some time.");
1860
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_PEER_LOCK_FAIL,
1861
"Failed to acquire lock");
1867
gf_msg_debug(this->name, 0,
1868
"Sent lock op req for 'Volume %s' "
1869
"to %d peers. Returning %d",
1870
gd_op_list[op], peer_cnt, ret);
1876
glusterd_validate_and_set_gfid(dict_t *op_ctx, dict_t *req_dict,
1882
int op_code = GF_QUOTA_OPTION_TYPE_NONE;
1890
char *uuid1_str = NULL;
1891
char *uuid1_str_dup = NULL;
1892
char *uuid2_str = NULL;
1894
ret = dict_get_int32(op_ctx, "type", &op_code);
1896
gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
1897
"Failed to get quota opcode");
1901
if ((op_code != GF_QUOTA_OPTION_TYPE_LIMIT_USAGE) &&
1902
(op_code != GF_QUOTA_OPTION_TYPE_LIMIT_OBJECTS) &&
1903
(op_code != GF_QUOTA_OPTION_TYPE_REMOVE) &&
1904
(op_code != GF_QUOTA_OPTION_TYPE_REMOVE_OBJECTS)) {
1909
ret = dict_get_str(op_ctx, "path", &path);
1911
gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
1912
"Failed to get path");
1916
ret = dict_get_int32(op_ctx, "count", &count);
1918
gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
1919
"Failed to get count");
1923
/* If count is 0, fail the command with ENOENT.
1925
* If count is 1, treat gfid0 as the gfid on which the operation
1926
* is to be performed and resume the command.
1928
* if count > 1, get the 0th gfid from the op_ctx and,
1929
* compare it with the remaining 'count -1' gfids.
1930
* If they are found to be the same, set gfid0 in the op_ctx and
1931
* resume the operation, else error out.
1935
gf_asprintf(op_errstr,
1936
"Failed to get trusted.gfid attribute "
1937
"on path %s. Reason : %s",
1938
path, strerror(ENOENT));
1943
keylen = snprintf(key, sizeof(key), "gfid%d", 0);
1945
ret = dict_get_strn(op_ctx, key, keylen, &uuid1_str);
1947
gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
1948
"Failed to get key '%s'", key);
1952
gf_uuid_parse(uuid1_str, uuid1);
1954
for (i = 1; i < count; i++) {
1955
keylen = snprintf(key, sizeof(key), "gfid%d", i);
1957
ret = dict_get_strn(op_ctx, key, keylen, &uuid2_str);
1959
gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
1960
"Failed to get key "
1966
gf_uuid_parse(uuid2_str, uuid2);
1968
if (gf_uuid_compare(uuid1, uuid2)) {
1969
gf_asprintf(op_errstr,
1970
"gfid mismatch between %s and "
1972
uuid1_str, uuid2_str, path);
1979
uuid1_str_dup = gf_strdup(uuid1_str);
1980
if (!uuid1_str_dup) {
1985
ret = dict_set_dynstr_sizen(req_dict, "gfid", uuid1_str_dup);
1987
gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED,
1988
"Failed to set gfid");
1989
GF_FREE(uuid1_str_dup);
1993
gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_DICT_ITER_FAIL,
1994
"Failed to iterate through %d"
1995
" entries in the req dict",
2007
gd_stage_op_phase(glusterd_op_t op, dict_t *op_ctx, dict_t *req_dict,
2008
char **op_errstr, glusterd_op_info_t *txn_opinfo)
2012
dict_t *rsp_dict = NULL;
2013
char *hostname = NULL;
2014
xlator_t *this = THIS;
2015
glusterd_conf_t *conf = NULL;
2016
glusterd_peerinfo_t *peerinfo = NULL;
2017
uuid_t tmp_uuid = {0};
2018
char *errstr = NULL;
2019
struct syncargs args = {0};
2020
dict_t *aggr_dict = NULL;
2022
conf = this->private;
2025
rsp_dict = dict_new();
2027
gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_CREATE_FAIL, NULL);
2031
if ((op == GD_OP_CREATE_VOLUME) || (op == GD_OP_ADD_BRICK) ||
2032
(op == GD_OP_START_VOLUME))
2033
aggr_dict = req_dict;
2037
ret = glusterd_validate_quorum(this, op, req_dict, op_errstr);
2039
gf_msg(this->name, GF_LOG_CRITICAL, 0, GD_MSG_SERVER_QUORUM_NOT_MET,
2040
"Server quorum not met. Rejecting operation.");
2044
ret = glusterd_op_stage_validate(op, req_dict, op_errstr, rsp_dict);
2046
hostname = "localhost";
2050
if ((op == GD_OP_REPLACE_BRICK || op == GD_OP_QUOTA ||
2051
op == GD_OP_CREATE_VOLUME || op == GD_OP_ADD_BRICK ||
2052
op == GD_OP_START_VOLUME)) {
2053
ret = glusterd_syncop_aggr_rsp_dict(op, aggr_dict, rsp_dict);
2055
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_RESP_AGGR_FAIL, "%s",
2056
"Failed to aggregate response from node/brick");
2060
dict_unref(rsp_dict);
2065
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_VALIDATE_FAILED,
2066
LOGSTR_STAGE_FAIL, gd_op_list[op], hostname,
2067
(*op_errstr) ? ":" : " ", (*op_errstr) ? *op_errstr : " ");
2068
if (*op_errstr == NULL)
2069
gf_asprintf(op_errstr, OPERRSTR_STAGE_FAIL, hostname);
2073
ret = gd_syncargs_init(&args, aggr_dict);
2080
cds_list_for_each_entry_rcu(peerinfo, &conf->peers, uuid_list)
2082
/* Only send requests to peers who were available before the
2083
* transaction started
2085
if (peerinfo->generation > txn_opinfo->txn_generation)
2088
if (!peerinfo->connected)
2090
if (op != GD_OP_SYNC_VOLUME &&
2091
peerinfo->state != GD_FRIEND_STATE_BEFRIENDED)
2094
(void)gd_syncop_mgmt_stage_op(peerinfo, &args, MY_UUID, tmp_uuid, op,
2100
if (0 == peer_cnt) {
2105
gf_msg_debug(this->name, 0,
2106
"Sent stage op req for 'Volume %s' "
2108
gd_op_list[op], peer_cnt);
2110
gd_synctask_barrier_wait((&args), peer_cnt);
2113
*op_errstr = gf_strdup(args.errstr);
2114
else if (dict_get_str(aggr_dict, "errstr", &errstr) == 0)
2115
*op_errstr = gf_strdup(errstr);
2120
if ((ret == 0) && (op == GD_OP_QUOTA)) {
2121
ret = glusterd_validate_and_set_gfid(op_ctx, req_dict, op_errstr);
2123
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_GFID_VALIDATE_SET_FAIL,
2124
"Failed to validate and set gfid");
2128
dict_unref(rsp_dict);
2130
gd_syncargs_fini(&args);
2135
gd_commit_op_phase(glusterd_op_t op, dict_t *op_ctx, dict_t *req_dict,
2136
char **op_errstr, glusterd_op_info_t *txn_opinfo)
2138
dict_t *rsp_dict = NULL;
2141
char *hostname = NULL;
2142
glusterd_peerinfo_t *peerinfo = NULL;
2143
xlator_t *this = THIS;
2144
glusterd_conf_t *conf = NULL;
2145
uuid_t tmp_uuid = {0};
2146
char *errstr = NULL;
2147
struct syncargs args = {0};
2148
int type = GF_QUOTA_OPTION_TYPE_NONE;
2150
gf_boolean_t origin_glusterd = _gf_false;
2152
conf = this->private;
2155
rsp_dict = dict_new();
2157
gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_CREATE_FAIL, NULL);
2162
ret = glusterd_op_commit_perform(op, req_dict, op_errstr, rsp_dict);
2164
hostname = "localhost";
2168
if (op == GD_OP_QUOTA) {
2169
ret = dict_get_int32(op_ctx, "type", &type);
2171
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
2178
if (((op == GD_OP_QUOTA) &&
2179
((type == GF_QUOTA_OPTION_TYPE_LIST) ||
2180
(type == GF_QUOTA_OPTION_TYPE_LIST_OBJECTS))) ||
2181
((op != GD_OP_SYNC_VOLUME) && (op != GD_OP_QUOTA))) {
2182
ret = glusterd_syncop_aggr_rsp_dict(op, op_ctx, rsp_dict);
2184
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_RESP_AGGR_FAIL, "%s",
2185
"Failed to aggregate "
2186
"response from node/brick");
2191
dict_unref(rsp_dict);
2196
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_COMMIT_OP_FAIL,
2197
LOGSTR_COMMIT_FAIL, gd_op_list[op], hostname,
2198
(*op_errstr) ? ":" : " ", (*op_errstr) ? *op_errstr : " ");
2199
if (*op_errstr == NULL)
2200
gf_asprintf(op_errstr, OPERRSTR_COMMIT_FAIL, hostname);
2204
ret = gd_syncargs_init(&args, op_ctx);
2209
origin_glusterd = is_origin_glusterd(req_dict);
2211
if (op == GD_OP_STATUS_VOLUME) {
2212
ret = dict_get_uint32(req_dict, "cmd", &cmd);
2214
gf_smsg(this->name, GF_LOG_ERROR, -ret, GD_MSG_DICT_GET_FAILED,
2219
if (origin_glusterd) {
2220
if ((cmd & GF_CLI_STATUS_ALL)) {
2228
cds_list_for_each_entry_rcu(peerinfo, &conf->peers, uuid_list)
2230
/* Only send requests to peers who were available before the
2231
* transaction started
2233
if (peerinfo->generation > txn_opinfo->txn_generation)
2236
if (!peerinfo->connected)
2238
if (op != GD_OP_SYNC_VOLUME &&
2239
peerinfo->state != GD_FRIEND_STATE_BEFRIENDED)
2242
(void)gd_syncop_mgmt_commit_op(peerinfo, &args, MY_UUID, tmp_uuid, op,
2248
if (0 == peer_cnt) {
2253
gd_synctask_barrier_wait((&args), peer_cnt);
2256
*op_errstr = gf_strdup(args.errstr);
2257
else if (dict_get_str(op_ctx, "errstr", &errstr) == 0)
2258
*op_errstr = gf_strdup(errstr);
2260
gf_msg_debug(this->name, 0,
2261
"Sent commit op req for 'Volume %s' "
2263
gd_op_list[op], peer_cnt);
2266
glusterd_op_modify_op_ctx(op, op_ctx);
2269
dict_unref(rsp_dict);
2271
GF_FREE(args.errstr);
2274
gd_syncargs_fini(&args);
2279
gd_unlock_op_phase(glusterd_conf_t *conf, glusterd_op_t op, int *op_ret,
2280
rpcsvc_request_t *req, dict_t *op_ctx, char *op_errstr,
2281
char *volname, gf_boolean_t is_acquired, uuid_t txn_id,
2282
glusterd_op_info_t *txn_opinfo, gf_boolean_t cluster_lock)
2284
glusterd_peerinfo_t *peerinfo = NULL;
2285
uuid_t tmp_uuid = {0};
2288
xlator_t *this = THIS;
2289
struct syncargs args = {0};
2293
/* If the lock has not been held during this
2294
* transaction, do not send unlock requests */
2300
ret = synctask_barrier_init((&args));
2308
cds_list_for_each_entry_rcu(peerinfo, &conf->peers, uuid_list)
2310
/* Only send requests to peers who were available before
2311
* the transaction started
2313
if (peerinfo->generation > txn_opinfo->txn_generation)
2316
if (!peerinfo->connected)
2318
if (op != GD_OP_SYNC_VOLUME &&
2319
peerinfo->state != GD_FRIEND_STATE_BEFRIENDED)
2322
/* Only unlock peers that were locked */
2323
if (peerinfo->locked) {
2324
gd_syncop_mgmt_unlock(peerinfo, &args, MY_UUID, tmp_uuid);
2330
ret = dict_get_int32(op_ctx, "hold_global_locks", &global);
2335
if (volname || global) {
2337
cds_list_for_each_entry_rcu(peerinfo, &conf->peers, uuid_list)
2339
/* Only send requests to peers who were
2340
* available before the transaction started
2342
if (peerinfo->generation > txn_opinfo->txn_generation)
2345
if (!peerinfo->connected)
2347
if (op != GD_OP_SYNC_VOLUME &&
2348
peerinfo->state != GD_FRIEND_STATE_BEFRIENDED)
2351
gd_syncop_mgmt_v3_unlock(op_ctx, peerinfo, &args, MY_UUID,
2359
if (0 == peer_cnt) {
2364
gd_synctask_barrier_wait((&args), peer_cnt);
2368
gf_msg_debug(this->name, 0,
2369
"Sent unlock op req for 'Volume %s' "
2370
"to %d peers. Returning %d",
2371
gd_op_list[op], peer_cnt, ret);
2373
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_PEER_UNLOCK_FAIL,
2379
/* If unlock failed, and op_ret was previously set
2380
* priority is given to the op_ret. If op_ret was
2381
* not set, and unlock failed, then set op_ret */
2386
/* Based on the op-version,
2387
* we release the cluster or mgmt_v3 lock
2388
* and clear the op */
2390
glusterd_op_clear_op();
2392
glusterd_unlock(MY_UUID);
2395
ret = glusterd_mgmt_v3_unlock(volname, MY_UUID, type);
2397
gf_msg(this->name, GF_LOG_ERROR, 0,
2398
GD_MSG_MGMTV3_UNLOCK_FAIL,
2399
"Unable to release lock for %s", volname);
2408
* If there are any quorum events while the OP is in progress, process
2411
if (conf->pending_quorum_action)
2412
glusterd_do_quorum_action();
2418
gd_get_brick_count(struct cds_list_head *bricks)
2420
glusterd_pending_node_t *pending_node = NULL;
2422
cds_list_for_each_entry(pending_node, bricks, list)
2430
gd_brick_op_phase(glusterd_op_t op, dict_t *op_ctx, dict_t *req_dict,
2433
glusterd_pending_node_t *pending_node = NULL;
2434
glusterd_pending_node_t *tmp = NULL;
2435
struct cds_list_head selected = {
2438
xlator_t *this = THIS;
2439
int brick_count = 0;
2441
rpc_clnt_t *rpc = NULL;
2442
dict_t *rsp_dict = NULL;
2443
int32_t cmd = GF_OP_CMD_NONE;
2444
glusterd_volinfo_t *volinfo = NULL;
2446
rsp_dict = dict_new();
2448
gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_CREATE_FAIL, NULL);
2453
CDS_INIT_LIST_HEAD(&selected);
2454
ret = glusterd_op_bricks_select(op, req_dict, op_errstr, &selected,
2457
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_BRICK_OP_FAIL, "%s",
2458
(*op_errstr) ? *op_errstr
2459
: "Brick op failed. Check "
2460
"glusterd log file for more details.");
2464
if (op == GD_OP_HEAL_VOLUME) {
2465
ret = glusterd_syncop_aggr_rsp_dict(op, op_ctx, rsp_dict);
2469
dict_unref(rsp_dict);
2473
cds_list_for_each_entry_safe(pending_node, tmp, &selected, list)
2475
rpc = glusterd_pending_node_get_rpc(pending_node);
2476
/* In the case of rebalance if the rpc object is null, we try to
2477
* create the rpc object. if the rebalance daemon is down, it returns
2478
* -1. otherwise, rpc object will be created and referenced.
2481
if (pending_node->type == GD_NODE_REBALANCE && pending_node->node) {
2482
volinfo = pending_node->node;
2483
glusterd_defrag_ref(volinfo->rebal.defrag);
2484
ret = glusterd_rebalance_rpc_create(volinfo);
2487
glusterd_defrag_volume_node_rsp(req_dict, NULL, op_ctx);
2490
rpc = glusterd_defrag_rpc_get(volinfo->rebal.defrag);
2494
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_RPC_FAILURE,
2496
"due to rpc failure.");
2501
ret = gd_syncop_mgmt_brick_op(rpc, pending_node, op, req_dict, op_ctx,
2503
if (op == GD_OP_STATUS_VOLUME) {
2504
/* for client-list its enough to quit the loop
2505
* once we get the value from one brick
2507
ret = dict_get_int32(req_dict, "cmd", &cmd);
2508
if (!ret && (cmd & GF_CLI_STATUS_CLIENT_LIST)) {
2509
if (dict_get(op_ctx, "client-count"))
2517
glusterd_pending_node_put_rpc(pending_node);
2518
GF_FREE(pending_node);
2521
pending_node = NULL;
2524
if (pending_node && pending_node->node)
2525
glusterd_pending_node_put_rpc(pending_node);
2528
dict_unref(rsp_dict);
2529
gf_msg_debug(this->name, 0, "Sent op req to %d bricks", brick_count);
2534
gd_sync_task_begin(dict_t *op_ctx, rpcsvc_request_t *req)
2538
dict_t *req_dict = NULL;
2539
glusterd_conf_t *conf = NULL;
2540
glusterd_op_t op = GD_OP_NONE;
2542
char *op_errstr = NULL;
2544
char *global = NULL;
2545
char *volname = NULL;
2546
xlator_t *this = THIS;
2547
gf_boolean_t is_acquired = _gf_false;
2548
gf_boolean_t is_global = _gf_false;
2549
uuid_t *txn_id = NULL;
2550
glusterd_op_info_t txn_opinfo = {
2551
GD_OP_STATE_DEFAULT,
2553
uint32_t op_errno = 0;
2556
conf = this->private;
2559
ret = dict_get_int32(op_ctx, GD_SYNC_OPCODE_KEY, &tmp_op);
2561
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
2562
"Failed to get volume "
2568
/* Generate a transaction-id for this operation and
2569
* save it in the dict */
2570
ret = glusterd_generate_txn_id(op_ctx, &txn_id);
2572
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_TRANS_IDGEN_FAIL,
2573
"Failed to generate transaction id");
2577
/* Save opinfo for this transaction with the transaction id. */
2578
glusterd_txn_opinfo_init(&txn_opinfo, 0, (int *)&op, NULL, NULL);
2579
ret = glusterd_set_txn_opinfo(txn_id, &txn_opinfo);
2581
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_TRANS_OPINFO_SET_FAIL,
2582
"Unable to set transaction's opinfo");
2584
gf_msg_debug(this->name, 0, "Transaction ID : %s", uuid_utoa(*txn_id));
2586
/* Save the MY_UUID as the originator_uuid */
2587
ret = glusterd_set_originator_uuid(op_ctx);
2589
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_UUID_SET_FAIL,
2590
"Failed to set originator_uuid.");
2594
/* Cli will add timeout key to dict if the default timeout is
2595
* other than 2 minutes. Here we use this value to check whether
2596
* mgmt_v3_lock_timeout should be set to default value or we
2597
* need to change the value according to timeout value
2598
* i.e, timeout + 120 seconds. */
2599
ret = dict_get_time(op_ctx, "timeout", &timeout);
2601
conf->mgmt_v3_lock_timeout = timeout + 120;
2603
ret = dict_get_str(op_ctx, "globalname", &global);
2605
is_global = _gf_true;
2609
/* If no volname is given as a part of the command, locks will
2611
ret = dict_get_str(op_ctx, "volname", &tmp);
2613
gf_msg_debug("glusterd", 0, "Failed to get volume name");
2614
goto local_locking_done;
2616
/* Use a copy of volname, as cli response will be
2617
* sent before the unlock, and the volname in the
2618
* dict, might be removed */
2619
volname = gf_strdup(tmp);
2624
ret = glusterd_mgmt_v3_lock(volname, MY_UUID, &op_errno, "vol");
2626
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_MGMTV3_LOCK_GET_FAIL,
2627
"Unable to acquire lock for %s", volname);
2628
gf_asprintf(&op_errstr,
2629
"Another transaction is in progress "
2630
"for %s. Please try again after some time.",
2637
ret = glusterd_mgmt_v3_lock(global, MY_UUID, &op_errno, "global");
2639
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_MGMTV3_LOCK_GET_FAIL,
2640
"Unable to acquire lock for %s", global);
2641
gf_asprintf(&op_errstr,
2642
"Another transaction is in progress "
2643
"for %s. Please try again after some time.",
2645
is_global = _gf_false;
2650
is_acquired = _gf_true;
2654
/* If no volname is given as a part of the command, locks will
2656
if (volname || is_global) {
2657
ret = gd_lock_op_phase(conf, op, op_ctx, &op_errstr, *txn_id,
2658
&txn_opinfo, _gf_false);
2660
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_PEER_LOCK_FAIL,
2661
"Locking Peers Failed.");
2666
ret = glusterd_op_build_payload(&req_dict, &op_errstr, op_ctx);
2668
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_BRICK_OP_PAYLOAD_BUILD_FAIL,
2669
LOGSTR_BUILD_PAYLOAD, gd_op_list[op]);
2670
if (op_errstr == NULL)
2671
gf_asprintf(&op_errstr, OPERRSTR_BUILD_PAYLOAD);
2675
ret = gd_stage_op_phase(op, op_ctx, req_dict, &op_errstr, &txn_opinfo);
2679
ret = gd_brick_op_phase(op, op_ctx, req_dict, &op_errstr);
2683
ret = gd_commit_op_phase(op, op_ctx, req_dict, &op_errstr, &txn_opinfo);
2692
(void)gd_unlock_op_phase(conf, op, &op_ret, req, op_ctx, op_errstr,
2693
global, is_acquired, *txn_id, &txn_opinfo,
2696
(void)gd_unlock_op_phase(conf, op, &op_ret, req, op_ctx, op_errstr,
2697
volname, is_acquired, *txn_id, &txn_opinfo,
2700
/* Clearing the transaction opinfo */
2701
ret = glusterd_clear_txn_opinfo(txn_id);
2703
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_TRANS_OPINFO_CLEAR_FAIL,
2704
"Unable to clear transaction's "
2705
"opinfo for transaction ID : %s",
2706
uuid_utoa(*txn_id));
2709
if (op_ret && (op_errno == 0))
2710
op_errno = EG_INTRNL;
2712
glusterd_op_send_cli_response(op, op_ret, op_errno, req, op_ctx, op_errstr);
2718
dict_unref(req_dict);
2729
glusterd_op_begin_synctask(rpcsvc_request_t *req, glusterd_op_t op, void *dict)
2733
ret = dict_set_int32(dict, GD_SYNC_OPCODE_KEY, op);
2735
gf_msg(THIS->name, GF_LOG_ERROR, 0, GD_MSG_DICT_GET_FAILED,
2736
"dict set failed for setting operations");
2740
gd_sync_task_begin(dict, req);