diff options
author | Avra Sengupta <asengupt@redhat.com> | 2015-05-05 18:08:25 +0530 |
---|---|---|
committer | Krishnan Parthasarathi <kparthas@redhat.com> | 2015-06-02 02:59:34 -0700 |
commit | 2df57ab7dc7b9d7deb0eebad96036149760d607b (patch) | |
tree | 9bf8673e338dca506add2d00011fdc4fa2e186a0 /xlators/mgmt/glusterd/src/glusterd-mgmt.c | |
parent | 59981aeb1cd02dcc534ec43ec4ec5bca5cbbd1fb (diff) |
glusterd/snapshot: Return correct errno in events of failure - PATCH 2
ENUM RETCODE ERROR
-------------------------------------------------------------
EG_INTRNL 30800 Internal Error
EG_OPNOTSUP 30801 Gluster Op Not Supported
EG_ANOTRANS 30802 Another Transaction in Progress
EG_BRCKDWN 30803 One or more brick is down
EG_NODEDWN 30804 One or more node is down
EG_HRDLMT 30805 Hard Limit is reached
EG_NOVOL 30806 Volume does not exist
EG_NOSNAP 30807 Snap does not exist
EG_RBALRUN 30808 Rebalance is running
EG_VOLRUN 30809 Volume is running
EG_VOLSTP 30810 Volume is not running
EG_VOLEXST 30811 Volume exists
EG_SNAPEXST 30812 Snapshot exists
EG_ISSNAP 30813 Volume is a snap volume
EG_GEOREPRUN 30814 Geo-Replication is running
EG_NOTTHINP 30815 Bricks are not thinly provisioned
Change-Id: I49a170cdfd77df11fe677e09f4e063d99b159275
BUG: 1212413
Signed-off-by: Avra Sengupta <asengupt@redhat.com>
Reviewed-on: http://review.gluster.org/10588
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-mgmt.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-mgmt.c | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-mgmt.c index 954ff039085..f8e65acd2b5 100644 --- a/xlators/mgmt/glusterd/src/glusterd-mgmt.c +++ b/xlators/mgmt/glusterd/src/glusterd-mgmt.c @@ -144,7 +144,8 @@ gd_mgmt_v3_collate_errors (struct syncargs *args, int op_ret, int op_errno, int32_t gd_mgmt_v3_pre_validate_fn (glusterd_op_t op, dict_t *dict, - char **op_errstr, dict_t *rsp_dict) + char **op_errstr, dict_t *rsp_dict, + uint32_t *op_errno) { int32_t ret = -1; xlator_t *this = NULL; @@ -154,11 +155,12 @@ gd_mgmt_v3_pre_validate_fn (glusterd_op_t op, dict_t *dict, GF_ASSERT (dict); GF_ASSERT (op_errstr); GF_ASSERT (rsp_dict); + GF_VALIDATE_OR_GOTO (this->name, op_errno, out); switch (op) { case GD_OP_SNAP: ret = glusterd_snapshot_prevalidate (dict, op_errstr, - rsp_dict); + rsp_dict, op_errno); if (ret) { gf_msg (this->name, GF_LOG_WARNING, 0, @@ -216,7 +218,8 @@ out: int32_t gd_mgmt_v3_commit_fn (glusterd_op_t op, dict_t *dict, - char **op_errstr, dict_t *rsp_dict) + char **op_errstr, uint32_t *op_errno, + dict_t *rsp_dict) { int32_t ret = -1; xlator_t *this = NULL; @@ -225,12 +228,14 @@ gd_mgmt_v3_commit_fn (glusterd_op_t op, dict_t *dict, GF_ASSERT (this); GF_ASSERT (dict); GF_ASSERT (op_errstr); + GF_VALIDATE_OR_GOTO (this->name, op_errno, out); GF_ASSERT (rsp_dict); switch (op) { case GD_OP_SNAP: { - ret = glusterd_snapshot (dict, op_errstr, rsp_dict); + ret = glusterd_snapshot (dict, op_errstr, + op_errno, rsp_dict); if (ret) { gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_COMMIT_OP_FAIL, @@ -683,7 +688,7 @@ out: int glusterd_mgmt_v3_pre_validate (glusterd_op_t op, dict_t *req_dict, - char **op_errstr, + char **op_errstr, uint32_t *op_errno, uint32_t txn_generation) { int32_t ret = -1; @@ -702,6 +707,7 @@ glusterd_mgmt_v3_pre_validate (glusterd_op_t op, dict_t *req_dict, GF_ASSERT (req_dict); GF_ASSERT (op_errstr); + GF_VALIDATE_OR_GOTO (this->name, op_errno, out); rsp_dict = dict_new (); if (!rsp_dict) { @@ -713,7 +719,7 @@ glusterd_mgmt_v3_pre_validate (glusterd_op_t op, dict_t *req_dict, /* Pre Validation on local node */ ret = gd_mgmt_v3_pre_validate_fn (op, req_dict, op_errstr, - rsp_dict); + rsp_dict, op_errno); if (ret) { gf_msg (this->name, GF_LOG_ERROR, 0, @@ -790,6 +796,7 @@ glusterd_mgmt_v3_pre_validate (glusterd_op_t op, dict_t *req_dict, } ret = args.op_ret; + *op_errno = args.op_errno; gf_msg_debug (this->name, 0, "Sent pre valaidation req for %s " "to %d peers. Returning %d", gd_op_list[op], peer_cnt, ret); @@ -1191,7 +1198,8 @@ out: int glusterd_mgmt_v3_commit (glusterd_op_t op, dict_t *op_ctx, dict_t *req_dict, - char **op_errstr, uint32_t txn_generation) + char **op_errstr, uint32_t *op_errno, + uint32_t txn_generation) { int32_t ret = -1; int32_t peer_cnt = 0; @@ -1210,6 +1218,7 @@ glusterd_mgmt_v3_commit (glusterd_op_t op, dict_t *op_ctx, dict_t *req_dict, GF_ASSERT (op_ctx); GF_ASSERT (req_dict); GF_ASSERT (op_errstr); + GF_VALIDATE_OR_GOTO (this->name, op_errno, out); rsp_dict = dict_new (); if (!rsp_dict) { @@ -1221,7 +1230,7 @@ glusterd_mgmt_v3_commit (glusterd_op_t op, dict_t *op_ctx, dict_t *req_dict, /* Commit on local node */ ret = gd_mgmt_v3_commit_fn (op, req_dict, op_errstr, - rsp_dict); + op_errno, rsp_dict); if (ret) { gf_msg (this->name, GF_LOG_ERROR, 0, @@ -1298,6 +1307,7 @@ glusterd_mgmt_v3_commit (glusterd_op_t op, dict_t *op_ctx, dict_t *req_dict, } ret = args.op_ret; + *op_errno = args.op_errno; gf_msg_debug (this->name, 0, "Sent commit req for %s to %d " "peers. Returning %d", gd_op_list[op], peer_cnt, ret); @@ -1801,7 +1811,7 @@ glusterd_mgmt_v3_initiate_all_phases (rpcsvc_request_t *req, glusterd_op_t op, /* PRE-COMMIT VALIDATE PHASE */ ret = glusterd_mgmt_v3_pre_validate (op, req_dict, &op_errstr, - txn_generation); + &op_errno, txn_generation); if (ret) { gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_PRE_VALIDATION_FAIL, "Pre Validation Failed"); @@ -1810,7 +1820,7 @@ glusterd_mgmt_v3_initiate_all_phases (rpcsvc_request_t *req, glusterd_op_t op, /* COMMIT OP PHASE */ ret = glusterd_mgmt_v3_commit (op, dict, req_dict, &op_errstr, - txn_generation); + &op_errno, txn_generation); if (ret) { gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_COMMIT_OP_FAIL, "Commit Op Failed"); @@ -1850,8 +1860,8 @@ out: } } - if (ret && (op_errno == 0)) - op_errno = EINTRNL; + if (op_ret && (op_errno == 0)) + op_errno = EG_INTRNL; /* SEND CLI RESPONSE */ glusterd_op_send_cli_response (op, op_ret, op_errno, req, @@ -2035,7 +2045,7 @@ glusterd_mgmt_v3_initiate_snap_phases (rpcsvc_request_t *req, glusterd_op_t op, /* PRE-COMMIT VALIDATE PHASE */ ret = glusterd_mgmt_v3_pre_validate (op, req_dict, &op_errstr, - txn_generation); + &op_errno, txn_generation); if (ret) { gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_PRE_VALIDATION_FAIL, "Pre Validation Failed"); @@ -2043,7 +2053,8 @@ glusterd_mgmt_v3_initiate_snap_phases (rpcsvc_request_t *req, glusterd_op_t op, } /* quorum check of the volume is done here */ - ret = glusterd_snap_quorum_check (req_dict, _gf_false, &op_errstr); + ret = glusterd_snap_quorum_check (req_dict, _gf_false, &op_errstr, + &op_errno); if (ret) { gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_QUORUM_CHECK_FAIL, "Volume quorum check failed"); @@ -2095,7 +2106,7 @@ glusterd_mgmt_v3_initiate_snap_phases (rpcsvc_request_t *req, glusterd_op_t op, } ret = glusterd_mgmt_v3_commit (op, dict, req_dict, &op_errstr, - txn_generation); + &op_errno, txn_generation); if (ret) { gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_COMMIT_OP_FAIL, "Commit Op Failed"); @@ -2134,7 +2145,8 @@ unbarrier: /*Do a quorum check if the commit phase is successful*/ if (success) { //quorum check of the snapshot volume - ret = glusterd_snap_quorum_check (dict, _gf_true, &op_errstr); + ret = glusterd_snap_quorum_check (dict, _gf_true, &op_errstr, + &op_errno); if (ret) { gf_msg (this->name, GF_LOG_WARNING, 0, GD_MSG_QUORUM_CHECK_FAIL, @@ -2189,8 +2201,8 @@ out: } } - if (ret && (op_errno == 0)) - op_errno = EINTRNL; + if (op_ret && (op_errno == 0)) + op_errno = EG_INTRNL; /* SEND CLI RESPONSE */ glusterd_op_send_cli_response (op, op_ret, op_errno, req, |