summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-mgmt.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-mgmt.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-mgmt.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-mgmt.c
index e6f341ada..8e2c0c689 100644
--- a/xlators/mgmt/glusterd/src/glusterd-mgmt.c
+++ b/xlators/mgmt/glusterd/src/glusterd-mgmt.c
@@ -1389,6 +1389,7 @@ glusterd_mgmt_v3_initiate_snap_phases (rpcsvc_request_t *req, glusterd_op_t op,
gf_boolean_t is_acquired = _gf_false;
uuid_t *originator_uuid = NULL;
gf_boolean_t success = _gf_false;
+ char *tmp_errstr = NULL;
this = THIS;
GF_ASSERT (this);
@@ -1470,6 +1471,13 @@ glusterd_mgmt_v3_initiate_snap_phases (rpcsvc_request_t *req, glusterd_op_t op,
&op_errstr, npeers);
if (ret) {
gf_log ("", GF_LOG_ERROR, "Commit Op Failed");
+ /* If the main op fails, we should save the error string.
+ Because, op_errstr will be used for unbarrier and
+ unlock ops also. We might lose the actual error that
+ caused the failure.
+ */
+ tmp_errstr = op_errstr;
+ op_errstr = NULL;
goto unbarrier;
}
@@ -1483,6 +1491,7 @@ unbarrier:
&op_errstr, npeers);
if (ret || (success == _gf_false)) {
gf_log ("", GF_LOG_ERROR, "Brick Ops Failed");
+ ret = -1;
goto out;
}
/* POST-COMMIT VALIDATE PHASE */
@@ -1500,6 +1509,22 @@ out:
(void) glusterd_mgmt_v3_release_peer_locks (conf, op, dict, &op_errstr,
npeers, is_acquired);
+ /* If the commit op (snapshot taking) failed, then the error is stored
+ in tmp_errstr and unbarrier is called. Suppose, if unbarrier also
+ fails, then the error happened in unbarrier is logged and freed.
+ The error happened in commit op, which is stored in tmp_errstr
+ is sent to cli.
+ */
+ if (tmp_errstr) {
+ if (ret && op_errstr) {
+ gf_log (this->name, GF_LOG_ERROR, "unbarrier brick op"
+ "failed with the error %s", op_errstr);
+ GF_FREE (op_errstr);
+ op_errstr = NULL;
+ }
+ op_errstr = tmp_errstr;
+ }
+
/* SEND CLI RESPONSE */
glusterd_op_send_cli_response (op, ret, 0, req, dict, op_errstr);