summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
index f666d4cc08e..294758b9a7f 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
@@ -33,6 +33,7 @@
#include "glusterd-snapshot-utils.h"
#include "glusterd-server-quorum.h"
#include "glusterd-messages.h"
+#include "glusterd-errno.h"
/*
* glusterd_snap_geo_rep_restore:
@@ -2620,7 +2621,8 @@ gf_boolean_t
glusterd_volume_quorum_calculate (glusterd_volinfo_t *volinfo, dict_t *dict,
int down_count, gf_boolean_t first_brick_on,
int8_t snap_force, int quorum_count,
- char *quorum_type, char **op_errstr)
+ char *quorum_type, char **op_errstr,
+ uint32_t *op_errno)
{
gf_boolean_t quorum_met = _gf_false;
char err_str[PATH_MAX] = {0, };
@@ -2629,6 +2631,7 @@ glusterd_volume_quorum_calculate (glusterd_volinfo_t *volinfo, dict_t *dict,
this = THIS;
GF_ASSERT (this);
+ GF_VALIDATE_OR_GOTO (this->name, op_errno, out);
if (!volinfo || !dict) {
gf_msg (this->name, GF_LOG_WARNING, 0,
@@ -2647,6 +2650,7 @@ glusterd_volume_quorum_calculate (glusterd_volinfo_t *volinfo, dict_t *dict,
gf_msg (this->name, GF_LOG_ERROR, 0,
GD_MSG_BRICK_DISCONNECTED, "%s", err_str);
*op_errstr = gf_strdup (err_str);
+ *op_errno = EG_BRCKDWN;
goto out;
}
@@ -2678,6 +2682,7 @@ glusterd_volume_quorum_calculate (glusterd_volinfo_t *volinfo, dict_t *dict,
gf_msg (this->name, GF_LOG_WARNING, 0,
GD_MSG_SERVER_QUORUM_NOT_MET, "%s", err_str);
*op_errstr = gf_strdup (err_str);
+ *op_errno = EG_BRCKDWN;
}
out:
@@ -2688,7 +2693,8 @@ int32_t
glusterd_volume_quorum_check (glusterd_volinfo_t *volinfo, int64_t index,
dict_t *dict, char *key_prefix,
int8_t snap_force, int quorum_count,
- char *quorum_type, char **op_errstr)
+ char *quorum_type, char **op_errstr,
+ uint32_t *op_errno)
{
int ret = 0;
xlator_t *this = NULL;
@@ -2707,6 +2713,7 @@ glusterd_volume_quorum_check (glusterd_volinfo_t *volinfo, int64_t index,
GF_ASSERT (this);
priv = this->private;
GF_ASSERT (priv);
+ GF_VALIDATE_OR_GOTO (this->name, op_errno, out);
if (!volinfo || !dict) {
gf_msg (this->name, GF_LOG_WARNING, 0,
@@ -2734,6 +2741,7 @@ glusterd_volume_quorum_check (glusterd_volinfo_t *volinfo, int64_t index,
0, GD_MSG_SERVER_QUORUM_NOT_MET, "%s",
err_str);
*op_errstr = gf_strdup (err_str);
+ *op_errno = EG_BRCKDWN;
goto out;
}
}
@@ -2770,7 +2778,8 @@ glusterd_volume_quorum_check (glusterd_volinfo_t *volinfo, int64_t index,
snap_force,
quorum_count,
quorum_type,
- op_errstr);
+ op_errstr,
+ op_errno);
/* goto out if quorum is not met */
if (!quorum_met) {
ret = -1;
@@ -2794,7 +2803,7 @@ out:
int32_t
glusterd_snap_quorum_check_for_create (dict_t *dict, gf_boolean_t snap_volume,
- char **op_errstr)
+ char **op_errstr, uint32_t *op_errno)
{
int8_t snap_force = 0;
int32_t force = 0;
@@ -2815,6 +2824,7 @@ glusterd_snap_quorum_check_for_create (dict_t *dict, gf_boolean_t snap_volume,
this = THIS;
GF_ASSERT (this);
+ GF_VALIDATE_OR_GOTO (this->name, op_errno, out);
if (!dict) {
gf_msg (this->name, GF_LOG_ERROR, 0,
@@ -2855,6 +2865,7 @@ glusterd_snap_quorum_check_for_create (dict_t *dict, gf_boolean_t snap_volume,
gf_msg (this->name, GF_LOG_WARNING, 0,
GD_MSG_SERVER_QUORUM_NOT_MET, "%s", err_str);
*op_errstr = gf_strdup (err_str);
+ *op_errno = EG_NODEDWN;
ret = -1;
goto out;
} else
@@ -2978,7 +2989,8 @@ glusterd_snap_quorum_check_for_create (dict_t *dict, gf_boolean_t snap_volume,
snap_force,
quorum_count,
quorum_type,
- op_errstr);
+ op_errstr,
+ op_errno);
if (ret) {
gf_msg (this->name, GF_LOG_WARNING, 0,
GD_MSG_VOL_NOT_FOUND, "volume %s "
@@ -2992,7 +3004,7 @@ out:
int32_t
glusterd_snap_quorum_check (dict_t *dict, gf_boolean_t snap_volume,
- char **op_errstr)
+ char **op_errstr, uint32_t *op_errno)
{
int32_t ret = -1;
xlator_t *this = NULL;
@@ -3001,6 +3013,7 @@ glusterd_snap_quorum_check (dict_t *dict, gf_boolean_t snap_volume,
this = THIS;
GF_ASSERT (this);
+ GF_VALIDATE_OR_GOTO (this->name, op_errno, out);
if (!dict) {
gf_msg (this->name, GF_LOG_ERROR, 0,
@@ -3008,7 +3021,6 @@ glusterd_snap_quorum_check (dict_t *dict, gf_boolean_t snap_volume,
goto out;
}
-
ret = dict_get_int32 (dict, "type", &snap_command);
if (ret) {
gf_msg (this->name, GF_LOG_ERROR, 0,
@@ -3020,7 +3032,8 @@ glusterd_snap_quorum_check (dict_t *dict, gf_boolean_t snap_volume,
switch (snap_command) {
case GF_SNAP_OPTION_TYPE_CREATE:
ret = glusterd_snap_quorum_check_for_create (dict, snap_volume,
- op_errstr);
+ op_errstr,
+ op_errno);
if (ret) {
gf_msg (this->name, GF_LOG_WARNING, 0,
GD_MSG_QUORUM_CHECK_FAIL, "Quorum check"
@@ -3038,6 +3051,7 @@ glusterd_snap_quorum_check (dict_t *dict, gf_boolean_t snap_volume,
GD_MSG_SERVER_QUORUM_NOT_MET, "%s",
err_str);
*op_errstr = gf_strdup (err_str);
+ *op_errno = EG_NODEDWN;
goto out;
}
@@ -3054,6 +3068,7 @@ glusterd_snap_quorum_check (dict_t *dict, gf_boolean_t snap_volume,
GD_MSG_SERVER_QUORUM_NOT_MET, "%s",
err_str);
*op_errstr = gf_strdup (err_str);
+ *op_errno = EG_NODEDWN;
goto out;
}