summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
diff options
context:
space:
mode:
authorAvra Sengupta <asengupt@redhat.com>2015-05-05 18:08:25 +0530
committerKrishnan Parthasarathi <kparthas@redhat.com>2015-06-09 07:18:38 -0700
commit952ea9ae43d7668cf9661eb694757e17a2a6ae9e (patch)
treefdf91e44d69642e1c374b0ef374ed3f978544e5d /xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
parent4b32816d226b04066b36f569ea34bebfff25d16e (diff)
glusterd/snapshot: Return correct errno in events of failure - PATCH 2
Backport of http://review.gluster.org/#/c/10588/ 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: 1226117 Signed-off-by: Avra Sengupta <asengupt@redhat.com> (cherry picked from commit 2df57ab7dc7b9d7deb0eebad96036149760d607b) Reviewed-on: http://review.gluster.org/11042 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Rajesh Joseph <rjoseph@redhat.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
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;
}