From e9a37d5a3471db02e1c7922cee93bf290e2f326d Mon Sep 17 00:00:00 2001 From: Avra Sengupta Date: Tue, 5 May 2015 10:58:10 +0530 Subject: glusterd/snapshot: Return correct errno in events of failure - PATCH 1 Backport of patch http://review.gluster.org/#/c/10313/ RETCODE ERROR ------------------------------------------- 30800 Internal Error 30801 Another Transaction In Progress >Change-Id: Ica7fd2e513b2c28717b6df73cfb2667725dbf057 >BUG: 1226117 >Signed-off-by: Avra Sengupta >Reviewed-on: http://review.gluster.org/10313 >Reviewed-by: Rajesh Joseph >Tested-by: Gluster Build System >Tested-by: NetBSD Build System >Reviewed-by: Krishnan Parthasarathi >(cherry picked from commit 4397d7e72fdff6f01c59b72eebea421f23c1a392) Change-Id: Iace6ac0f150919cead94e6c5d99a23d28d45046e BUG: 1226117 Signed-off-by: Avra Sengupta Reviewed-on: http://review.gluster.org/11011 Tested-by: NetBSD Build System Reviewed-by: Kaushal M --- xlators/mgmt/glusterd/src/glusterd-locks.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'xlators/mgmt/glusterd/src/glusterd-locks.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-locks.c b/xlators/mgmt/glusterd/src/glusterd-locks.c index c86dc8069da..0f9c2b26084 100644 --- a/xlators/mgmt/glusterd/src/glusterd-locks.c +++ b/xlators/mgmt/glusterd/src/glusterd-locks.c @@ -21,6 +21,7 @@ #include "glusterd-utils.h" #include "glusterd-volgen.h" #include "glusterd-locks.h" +#include "glusterd-errno.h" #include "run.h" #include "syscall.h" @@ -191,6 +192,7 @@ out: * volumes */ static int32_t glusterd_acquire_multiple_locks_per_entity (dict_t *dict, uuid_t uuid, + uint32_t *op_errno, int32_t count, char *type) { char name_buf[PATH_MAX] = ""; @@ -220,7 +222,7 @@ glusterd_acquire_multiple_locks_per_entity (dict_t *dict, uuid_t uuid, break; } - ret = glusterd_mgmt_v3_lock (name, uuid, type); + ret = glusterd_mgmt_v3_lock (name, uuid, op_errno, type); if (ret) { gf_log (this->name, GF_LOG_ERROR, "Failed to acquire lock for %s %s " @@ -330,8 +332,8 @@ out: * if the type is "vol", this function will accordingly lock a single volume * * or multiple volumes */ static int32_t -glusterd_mgmt_v3_lock_entity (dict_t *dict, uuid_t uuid, char *type, - gf_boolean_t default_value) +glusterd_mgmt_v3_lock_entity (dict_t *dict, uuid_t uuid, uint32_t *op_errno, + char *type, gf_boolean_t default_value) { char name_buf[PATH_MAX] = ""; char *name = NULL; @@ -369,7 +371,7 @@ glusterd_mgmt_v3_lock_entity (dict_t *dict, uuid_t uuid, char *type, goto out; } - ret = glusterd_mgmt_v3_lock (name, uuid, type); + ret = glusterd_mgmt_v3_lock (name, uuid, op_errno, type); if (ret) { gf_log (this->name, GF_LOG_ERROR, "Failed to acquire lock for %s %s " @@ -381,6 +383,7 @@ glusterd_mgmt_v3_lock_entity (dict_t *dict, uuid_t uuid, char *type, /* Locking one element name after another */ ret = glusterd_acquire_multiple_locks_per_entity (dict, uuid, + op_errno, count, type); if (ret) { @@ -437,7 +440,7 @@ out: /* Try to acquire locks on multiple entities like * * volume, snaps etc. */ int32_t -glusterd_multiple_mgmt_v3_lock (dict_t *dict, uuid_t uuid) +glusterd_multiple_mgmt_v3_lock (dict_t *dict, uuid_t uuid, uint32_t *op_errno) { int32_t i = -1; int32_t ret = -1; @@ -456,7 +459,7 @@ glusterd_multiple_mgmt_v3_lock (dict_t *dict, uuid_t uuid) /* Locking one entity after other */ for (i = 0; valid_types[i].type; i++) { ret = glusterd_mgmt_v3_lock_entity - (dict, uuid, + (dict, uuid, op_errno, valid_types[i].type, valid_types[i].default_value); if (ret) { @@ -494,7 +497,8 @@ out: int32_t -glusterd_mgmt_v3_lock (const char *name, uuid_t uuid, char *type) +glusterd_mgmt_v3_lock (const char *name, uuid_t uuid, uint32_t *op_errno, + char *type) { char key[PATH_MAX] = ""; int32_t ret = -1; @@ -550,6 +554,7 @@ glusterd_mgmt_v3_lock (const char *name, uuid_t uuid, char *type) "Lock for %s held by %s", name, uuid_utoa (owner)); ret = -1; + *op_errno = EANOTRANS; goto out; } -- cgit