summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr/src
diff options
context:
space:
mode:
authorPranith Kumar K <pranithk@gluster.com>2011-12-28 12:09:08 +0530
committerVijay Bellur <vijay@gluster.com>2011-12-28 22:07:16 -0800
commite9659b4103680eb82e7004b411d2db18c5fbb9bd (patch)
tree9b5b170bc30e900fe0dfac8558ddb07e5796a203 /xlators/cluster/afr/src
parente1f6ebc1a41d1759c2c4ec1d81a9b8a777b7a25d (diff)
cluster/afr: Handle error cases in local init
- Fop should unwind with appropriate errno - Local is de-allocated on errors Signed-off-by: Pranith Kumar K <pranithk@gluster.com> Change-Id: I4db40342ae184fe1cc29e51072e8fea72ef2cb15 BUG: 770513 Reviewed-on: http://review.gluster.com/2539 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'xlators/cluster/afr/src')
-rw-r--r--xlators/cluster/afr/src/afr-common.c240
-rw-r--r--xlators/cluster/afr/src/afr-dir-read.c44
-rw-r--r--xlators/cluster/afr/src/afr-dir-write.c163
-rw-r--r--xlators/cluster/afr/src/afr-inode-read.c172
-rw-r--r--xlators/cluster/afr/src/afr-inode-write.c148
-rw-r--r--xlators/cluster/afr/src/afr-lk-common.c26
-rw-r--r--xlators/cluster/afr/src/afr-open.c24
-rw-r--r--xlators/cluster/afr/src/afr.h2
-rw-r--r--xlators/cluster/afr/src/pump.c81
9 files changed, 384 insertions, 516 deletions
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
index 209024bbeda..8720f8ab778 100644
--- a/xlators/cluster/afr/src/afr-common.c
+++ b/xlators/cluster/afr/src/afr-common.c
@@ -2284,12 +2284,11 @@ afr_flush_done (call_frame_t *frame, xlator_t *this)
int
afr_flush (call_frame_t *frame, xlator_t *this, fd_t *fd)
{
- afr_private_t * priv = NULL;
- afr_local_t * local = NULL;
- call_frame_t * transaction_frame = NULL;
- int ret = -1;
- int op_ret = -1;
- int op_errno = 0;
+ afr_private_t *priv = NULL;
+ afr_local_t *local = NULL;
+ call_frame_t *transaction_frame = NULL;
+ int ret = -1;
+ int op_errno = 0;
VALIDATE_OR_GOTO (frame, out);
VALIDATE_OR_GOTO (this, out);
@@ -2297,21 +2296,18 @@ afr_flush (call_frame_t *frame, xlator_t *this, fd_t *fd)
priv = this->private;
- ALLOC_OR_GOTO (local, afr_local_t, out);
-
- ret = AFR_LOCAL_INIT (local, priv);
- if (ret < 0) {
- op_errno = -ret;
- goto out;
- }
-
transaction_frame = copy_frame (frame);
if (!transaction_frame) {
op_errno = ENOMEM;
goto out;
}
- transaction_frame->local = local;
+ ALLOC_OR_GOTO (transaction_frame->local, afr_local_t, out);
+ local = transaction_frame->local;
+
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
+ goto out;
local->op = GF_FOP_FLUSH;
@@ -2327,20 +2323,19 @@ afr_flush (call_frame_t *frame, xlator_t *this, fd_t *fd)
ret = afr_open_fd_fix (transaction_frame, this, _gf_false);
if (ret) {
- op_ret = -1;
op_errno = -ret;
goto out;
}
afr_transaction (transaction_frame, this, AFR_DATA_TRANSACTION);
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
+ if (ret < 0) {
if (transaction_frame)
AFR_STACK_DESTROY (transaction_frame);
- AFR_STACK_UNWIND (flush, frame, op_ret, op_errno);
+ AFR_STACK_UNWIND (flush, frame, -1, op_errno);
}
return 0;
@@ -2484,7 +2479,6 @@ afr_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd,
int ret = -1;
int i = 0;
int32_t call_count = 0;
- int32_t op_ret = -1;
int32_t op_errno = 0;
VALIDATE_OR_GOTO (frame, out);
@@ -2493,16 +2487,14 @@ afr_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd,
priv = this->private;
- ALLOC_OR_GOTO (local, afr_local_t, out);
+ ALLOC_OR_GOTO (frame->local, afr_local_t, out);
+ local = frame->local;
- ret = AFR_LOCAL_INIT (local, priv);
- if (ret < 0) {
- op_errno = -ret;
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
call_count = local->call_count;
- frame->local = local;
local->fd = fd_ref (fd);
@@ -2518,11 +2510,10 @@ afr_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd,
}
}
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
- AFR_STACK_UNWIND (fsync, frame, op_ret, op_errno, NULL, NULL);
- }
+ if (ret < 0)
+ AFR_STACK_UNWIND (fsync, frame, -1, op_errno, NULL, NULL);
return 0;
}
@@ -2567,7 +2558,6 @@ afr_fsyncdir (call_frame_t *frame, xlator_t *this, fd_t *fd,
int ret = -1;
int i = 0;
int32_t call_count = 0;
- int32_t op_ret = -1;
int32_t op_errno = 0;
VALIDATE_OR_GOTO (frame, out);
@@ -2576,16 +2566,14 @@ afr_fsyncdir (call_frame_t *frame, xlator_t *this, fd_t *fd,
priv = this->private;
- ALLOC_OR_GOTO (local, afr_local_t, out);
+ ALLOC_OR_GOTO (frame->local, afr_local_t, out);
+ local = frame->local;
- ret = AFR_LOCAL_INIT (local, priv);
- if (ret < 0) {
- op_errno = -ret;
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
call_count = local->call_count;
- frame->local = local;
for (i = 0; i < priv->child_count; i++) {
if (local->child_up[i]) {
@@ -2598,11 +2586,10 @@ afr_fsyncdir (call_frame_t *frame, xlator_t *this, fd_t *fd,
}
}
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
- AFR_STACK_UNWIND (fsyncdir, frame, op_ret, op_errno);
- }
+ if (ret < 0)
+ AFR_STACK_UNWIND (fsyncdir, frame, -1, op_errno);
return 0;
}
@@ -2648,7 +2635,6 @@ afr_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc,
int ret = -1;
int i = 0;
int32_t call_count = 0;
- int32_t op_ret = -1;
int32_t op_errno = 0;
VALIDATE_OR_GOTO (frame, out);
@@ -2657,16 +2643,14 @@ afr_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc,
priv = this->private;
- ALLOC_OR_GOTO (local, afr_local_t, out);
+ ALLOC_OR_GOTO (frame->local, afr_local_t, out);
+ local = frame->local;
- ret = AFR_LOCAL_INIT (local, priv);
- if (ret < 0) {
- op_errno = -ret;
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
call_count = local->call_count;
- frame->local = local;
for (i = 0; i < priv->child_count; i++) {
if (local->child_up[i]) {
@@ -2679,11 +2663,10 @@ afr_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc,
}
}
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
- AFR_STACK_UNWIND (xattrop, frame, op_ret, op_errno, NULL);
- }
+ if (ret < 0)
+ AFR_STACK_UNWIND (xattrop, frame, -1, op_errno, NULL);
return 0;
}
@@ -2730,7 +2713,6 @@ afr_fxattrop (call_frame_t *frame, xlator_t *this, fd_t *fd,
int ret = -1;
int i = 0;
int32_t call_count = 0;
- int32_t op_ret = -1;
int32_t op_errno = 0;
VALIDATE_OR_GOTO (frame, out);
@@ -2739,16 +2721,14 @@ afr_fxattrop (call_frame_t *frame, xlator_t *this, fd_t *fd,
priv = this->private;
- ALLOC_OR_GOTO (local, afr_local_t, out);
+ ALLOC_OR_GOTO (frame->local, afr_local_t, out);
+ local = frame->local;
- ret = AFR_LOCAL_INIT (local, priv);
- if (ret < 0) {
- op_errno = -ret;
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
call_count = local->call_count;
- frame->local = local;
for (i = 0; i < priv->child_count; i++) {
if (local->child_up[i]) {
@@ -2761,11 +2741,10 @@ afr_fxattrop (call_frame_t *frame, xlator_t *this, fd_t *fd,
}
}
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
- AFR_STACK_UNWIND (fxattrop, frame, op_ret, op_errno, NULL);
- }
+ if (ret < 0)
+ AFR_STACK_UNWIND (fxattrop, frame, -1, op_errno, NULL);
return 0;
}
@@ -2810,7 +2789,6 @@ afr_inodelk (call_frame_t *frame, xlator_t *this,
int ret = -1;
int i = 0;
int32_t call_count = 0;
- int32_t op_ret = -1;
int32_t op_errno = 0;
VALIDATE_OR_GOTO (frame, out);
@@ -2819,16 +2797,14 @@ afr_inodelk (call_frame_t *frame, xlator_t *this,
priv = this->private;
- ALLOC_OR_GOTO (local, afr_local_t, out);
+ ALLOC_OR_GOTO (frame->local, afr_local_t, out);
+ local = frame->local;
- ret = AFR_LOCAL_INIT (local, priv);
- if (ret < 0) {
- op_errno = -ret;
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
call_count = local->call_count;
- frame->local = local;
for (i = 0; i < priv->child_count; i++) {
if (local->child_up[i]) {
@@ -2842,11 +2818,10 @@ afr_inodelk (call_frame_t *frame, xlator_t *this,
}
}
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
- AFR_STACK_UNWIND (inodelk, frame, op_ret, op_errno);
- }
+ if (ret < 0)
+ AFR_STACK_UNWIND (inodelk, frame, -1, op_errno);
return 0;
}
@@ -2889,7 +2864,6 @@ afr_finodelk (call_frame_t *frame, xlator_t *this,
int ret = -1;
int i = 0;
int32_t call_count = 0;
- int32_t op_ret = -1;
int32_t op_errno = 0;
VALIDATE_OR_GOTO (frame, out);
@@ -2898,16 +2872,14 @@ afr_finodelk (call_frame_t *frame, xlator_t *this,
priv = this->private;
- ALLOC_OR_GOTO (local, afr_local_t, out);
+ ALLOC_OR_GOTO (frame->local, afr_local_t, out);
+ local = frame->local;
- ret = AFR_LOCAL_INIT (local, priv);
- if (ret < 0) {
- op_errno = -ret;
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
call_count = local->call_count;
- frame->local = local;
for (i = 0; i < priv->child_count; i++) {
if (local->child_up[i]) {
@@ -2921,11 +2893,10 @@ afr_finodelk (call_frame_t *frame, xlator_t *this,
}
}
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
- AFR_STACK_UNWIND (finodelk, frame, op_ret, op_errno);
- }
+ if (ret < 0)
+ AFR_STACK_UNWIND (finodelk, frame, -1, op_errno);
return 0;
}
@@ -2969,7 +2940,6 @@ afr_entrylk (call_frame_t *frame, xlator_t *this,
int ret = -1;
int i = 0;
int32_t call_count = 0;
- int32_t op_ret = -1;
int32_t op_errno = 0;
VALIDATE_OR_GOTO (frame, out);
@@ -2978,16 +2948,14 @@ afr_entrylk (call_frame_t *frame, xlator_t *this,
priv = this->private;
- ALLOC_OR_GOTO (local, afr_local_t, out);
+ ALLOC_OR_GOTO (frame->local, afr_local_t, out);
+ local = frame->local;
- ret = AFR_LOCAL_INIT (local, priv);
- if (ret < 0) {
- op_errno = -ret;
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
call_count = local->call_count;
- frame->local = local;
for (i = 0; i < priv->child_count; i++) {
if (local->child_up[i]) {
@@ -3001,11 +2969,10 @@ afr_entrylk (call_frame_t *frame, xlator_t *this,
}
}
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
- AFR_STACK_UNWIND (entrylk, frame, op_ret, op_errno);
- }
+ if (ret < 0)
+ AFR_STACK_UNWIND (entrylk, frame, -1, op_errno);
return 0;
}
@@ -3050,7 +3017,6 @@ afr_fentrylk (call_frame_t *frame, xlator_t *this,
int ret = -1;
int i = 0;
int32_t call_count = 0;
- int32_t op_ret = -1;
int32_t op_errno = 0;
VALIDATE_OR_GOTO (frame, out);
@@ -3059,16 +3025,14 @@ afr_fentrylk (call_frame_t *frame, xlator_t *this,
priv = this->private;
- ALLOC_OR_GOTO (local, afr_local_t, out);
+ ALLOC_OR_GOTO (frame->local, afr_local_t, out);
+ local = frame->local;
- ret = AFR_LOCAL_INIT (local, priv);
- if (ret < 0) {
- op_errno = -ret;
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
call_count = local->call_count;
- frame->local = local;
for (i = 0; i < priv->child_count; i++) {
if (local->child_up[i]) {
@@ -3082,11 +3046,10 @@ afr_fentrylk (call_frame_t *frame, xlator_t *this,
}
}
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
- AFR_STACK_UNWIND (fentrylk, frame, op_ret, op_errno);
- }
+ if (ret < 0)
+ AFR_STACK_UNWIND (fentrylk, frame, -1, op_errno);
return 0;
}
@@ -3140,7 +3103,6 @@ afr_statfs (call_frame_t *frame, xlator_t *this,
int i = 0;
int ret = -1;
int call_count = 0;
- int32_t op_ret = -1;
int32_t op_errno = 0;
VALIDATE_OR_GOTO (this, out);
@@ -3150,15 +3112,13 @@ afr_statfs (call_frame_t *frame, xlator_t *this,
priv = this->private;
child_count = priv->child_count;
- ALLOC_OR_GOTO (local, afr_local_t, out);
+ ALLOC_OR_GOTO (frame->local, afr_local_t, out);
+ local = frame->local;
- ret = AFR_LOCAL_INIT (local, priv);
- if (ret < 0) {
- op_errno = -ret;
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
- frame->local = local;
call_count = local->call_count;
for (i = 0; i < child_count; i++) {
@@ -3172,11 +3132,10 @@ afr_statfs (call_frame_t *frame, xlator_t *this,
}
}
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
- AFR_STACK_UNWIND (statfs, frame, op_ret, op_errno, NULL);
- }
+ if (ret < 0)
+ AFR_STACK_UNWIND (statfs, frame, -1, op_errno, NULL);
return 0;
}
@@ -3314,8 +3273,8 @@ afr_lk (call_frame_t *frame, xlator_t *this,
afr_private_t *priv = NULL;
afr_local_t *local = NULL;
int i = 0;
- int32_t op_ret = -1;
int32_t op_errno = 0;
+ int ret = -1;
VALIDATE_OR_GOTO (frame, out);
VALIDATE_OR_GOTO (this, out);
@@ -3323,10 +3282,12 @@ afr_lk (call_frame_t *frame, xlator_t *this,
priv = this->private;
- ALLOC_OR_GOTO (local, afr_local_t, out);
- AFR_LOCAL_INIT (local, priv);
+ ALLOC_OR_GOTO (frame->local, afr_local_t, out);
+ local = frame->local;
- frame->local = local;
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
+ goto out;
local->cont.lk.locked_nodes = GF_CALLOC (priv->child_count,
sizeof (*local->cont.lk.locked_nodes),
@@ -3347,11 +3308,10 @@ afr_lk (call_frame_t *frame, xlator_t *this,
priv->children[i]->fops->lk,
fd, cmd, flock);
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
- AFR_STACK_UNWIND (lk, frame, op_ret, op_errno, NULL);
- }
+ if (ret < 0)
+ AFR_STACK_UNWIND (lk, frame, -1, op_errno, NULL);
return 0;
}
@@ -3628,29 +3588,35 @@ afr_first_up_child (unsigned char *child_up, size_t child_count)
}
int
-AFR_LOCAL_INIT (afr_local_t *local, afr_private_t *priv)
+afr_local_init (afr_local_t *local, afr_private_t *priv, int32_t *op_errno)
{
+ int ret = -1;
+
local->op_ret = -1;
local->op_errno = EUCLEAN;
- local->call_count = afr_up_children_count (priv->child_up,
- priv->child_count);
- if (local->call_count == 0) {
- gf_log (THIS->name, GF_LOG_INFO, "no subvolumes up");
- return -ENOTCONN;
- }
-
local->child_up = GF_CALLOC (sizeof (*local->child_up),
priv->child_count,
gf_afr_mt_char);
if (!local->child_up) {
- return -ENOMEM;
+ if (op_errno)
+ *op_errno = ENOMEM;
+ goto out;
}
memcpy (local->child_up, priv->child_up,
sizeof (*local->child_up) * priv->child_count);
-
- return 0;
+ local->call_count = afr_up_children_count (local->child_up,
+ priv->child_count);
+ if (local->call_count == 0) {
+ gf_log (THIS->name, GF_LOG_INFO, "no subvolumes up");
+ if (op_errno)
+ *op_errno = ENOTCONN;
+ goto out;
+ }
+ ret = 0;
+out:
+ return ret;
}
int
diff --git a/xlators/cluster/afr/src/afr-dir-read.c b/xlators/cluster/afr/src/afr-dir-read.c
index f5a7b47a41f..d41102e7eea 100644
--- a/xlators/cluster/afr/src/afr-dir-read.c
+++ b/xlators/cluster/afr/src/afr-dir-read.c
@@ -307,7 +307,6 @@ afr_opendir (call_frame_t *frame, xlator_t *this,
int i = 0;
int ret = -1;
int call_count = -1;
- int32_t op_ret = -1;
int32_t op_errno = 0;
VALIDATE_OR_GOTO (frame, out);
@@ -318,16 +317,15 @@ afr_opendir (call_frame_t *frame, xlator_t *this,
child_count = priv->child_count;
- ALLOC_OR_GOTO (local, afr_local_t, out);
- ret = AFR_LOCAL_INIT (local, priv);
- if (ret < 0) {
- op_errno = -ret;
+ ALLOC_OR_GOTO (frame->local, afr_local_t, out);
+ local = frame->local;
+
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
loc_copy (&local->loc, loc);
- frame->local = local;
local->fd = fd_ref (fd);
call_count = local->call_count;
@@ -345,11 +343,10 @@ afr_opendir (call_frame_t *frame, xlator_t *this,
}
}
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
- AFR_STACK_UNWIND (opendir, frame, op_ret, op_errno, fd);
- }
+ if (ret < 0)
+ AFR_STACK_UNWIND (opendir, frame, -1, op_errno, fd);
return 0;
}
@@ -640,7 +637,6 @@ afr_do_readdir (call_frame_t *frame, xlator_t *this,
uint64_t ctx = 0;
afr_fd_ctx_t *fd_ctx = NULL;
int ret = -1;
- int32_t op_ret = -1;
int32_t op_errno = 0;
uint64_t read_child = 0;
@@ -651,14 +647,12 @@ afr_do_readdir (call_frame_t *frame, xlator_t *this,
priv = this->private;
children = priv->children;
- ALLOC_OR_GOTO (local, afr_local_t, out);
- frame->local = local;
+ ALLOC_OR_GOTO (frame->local, afr_local_t, out);
+ local = frame->local;
- ret = AFR_LOCAL_INIT (local, priv);
- if (ret < 0) {
- op_errno = -ret;
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
local->fresh_children = afr_children_create (priv->child_count);
if (!local->fresh_children) {
@@ -668,13 +662,12 @@ afr_do_readdir (call_frame_t *frame, xlator_t *this,
read_child = afr_inode_get_read_ctx (this, fd->inode,
local->fresh_children);
- op_ret = afr_get_call_child (this, local->child_up, read_child,
+ ret = afr_get_call_child (this, local->child_up, read_child,
local->fresh_children,
&call_child,
&local->cont.readdir.last_index);
- if (op_ret < 0) {
- op_errno = -op_ret;
- op_ret = -1;
+ if (ret < 0) {
+ op_errno = -ret;
goto out;
}
@@ -718,11 +711,10 @@ afr_do_readdir (call_frame_t *frame, xlator_t *this,
children[call_child]->fops->readdirp, fd,
size, offset);
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
- AFR_STACK_UNWIND (readdir, frame, op_ret, op_errno, NULL);
- }
+ if (ret < 0)
+ AFR_STACK_UNWIND (readdir, frame, -1, op_errno, NULL);
return 0;
}
diff --git a/xlators/cluster/afr/src/afr-dir-write.c b/xlators/cluster/afr/src/afr-dir-write.c
index 7ed8c52052e..4d2fcd226da 100644
--- a/xlators/cluster/afr/src/afr-dir-write.c
+++ b/xlators/cluster/afr/src/afr-dir-write.c
@@ -266,12 +266,11 @@ afr_create (call_frame_t *frame, xlator_t *this,
loc_t *loc, int32_t flags, mode_t mode,
fd_t *fd, dict_t *params)
{
- afr_private_t * priv = NULL;
- afr_local_t * local = NULL;
- call_frame_t * transaction_frame = NULL;
- int ret = -1;
- int op_ret = -1;
- int op_errno = 0;
+ afr_private_t *priv = NULL;
+ afr_local_t *local = NULL;
+ call_frame_t *transaction_frame = NULL;
+ int ret = -1;
+ int op_errno = 0;
VALIDATE_OR_GOTO (frame, out);
VALIDATE_OR_GOTO (this, out);
@@ -283,18 +282,16 @@ afr_create (call_frame_t *frame, xlator_t *this,
transaction_frame = copy_frame (frame);
if (!transaction_frame) {
+ op_errno = ENOMEM;
goto out;
}
- ALLOC_OR_GOTO (local, afr_local_t, out);
+ ALLOC_OR_GOTO (transaction_frame->local, afr_local_t, out);
+ local = transaction_frame->local;
- ret = AFR_LOCAL_INIT (local, priv);
- if (ret < 0) {
- op_errno = -ret;
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
-
- transaction_frame->local = local;
loc_copy (&local->loc, loc);
@@ -322,12 +319,12 @@ afr_create (call_frame_t *frame, xlator_t *this,
afr_transaction (transaction_frame, this, AFR_ENTRY_TRANSACTION);
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
+ if (ret < 0) {
if (transaction_frame)
AFR_STACK_DESTROY (transaction_frame);
- AFR_STACK_UNWIND (create, frame, op_ret, op_errno,
+ AFR_STACK_UNWIND (create, frame, -1, op_errno,
NULL, NULL, NULL, NULL, NULL);
}
@@ -495,7 +492,6 @@ afr_mknod (call_frame_t *frame, xlator_t *this,
afr_local_t * local = NULL;
call_frame_t * transaction_frame = NULL;
int ret = -1;
- int op_ret = -1;
int op_errno = 0;
VALIDATE_OR_GOTO (frame, out);
@@ -508,18 +504,16 @@ afr_mknod (call_frame_t *frame, xlator_t *this,
transaction_frame = copy_frame (frame);
if (!transaction_frame) {
+ op_errno = ENOMEM;
goto out;
}
- ALLOC_OR_GOTO (local, afr_local_t, out);
+ ALLOC_OR_GOTO (transaction_frame->local, afr_local_t, out);
+ local = transaction_frame->local;
- ret = AFR_LOCAL_INIT (local, priv);
- if (ret < 0) {
- op_errno = -ret;
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
-
- transaction_frame->local = local;
loc_copy (&local->loc, loc);
@@ -546,12 +540,12 @@ afr_mknod (call_frame_t *frame, xlator_t *this,
afr_transaction (transaction_frame, this, AFR_ENTRY_TRANSACTION);
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
+ if (ret < 0) {
if (transaction_frame)
AFR_STACK_DESTROY (transaction_frame);
- AFR_STACK_UNWIND (mknod, frame, op_ret, op_errno,
+ AFR_STACK_UNWIND (mknod, frame, -1, op_errno,
NULL, NULL, NULL, NULL);
}
@@ -721,7 +715,6 @@ afr_mkdir (call_frame_t *frame, xlator_t *this,
afr_local_t * local = NULL;
call_frame_t * transaction_frame = NULL;
int ret = -1;
- int op_ret = -1;
int op_errno = 0;
VALIDATE_OR_GOTO (frame, out);
@@ -734,18 +727,16 @@ afr_mkdir (call_frame_t *frame, xlator_t *this,
transaction_frame = copy_frame (frame);
if (!transaction_frame) {
+ op_errno = ENOMEM;
goto out;
}
- ALLOC_OR_GOTO (local, afr_local_t, out);
+ ALLOC_OR_GOTO (transaction_frame->local, afr_local_t, out);
+ local = transaction_frame->local;
- ret = AFR_LOCAL_INIT (local, priv);
- if (ret < 0) {
- op_errno = -ret;
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
-
- transaction_frame->local = local;
loc_copy (&local->loc, loc);
@@ -771,13 +762,13 @@ afr_mkdir (call_frame_t *frame, xlator_t *this,
afr_transaction (transaction_frame, this, AFR_ENTRY_TRANSACTION);
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
+ if (ret < 0) {
if (transaction_frame)
AFR_STACK_DESTROY (transaction_frame);
- AFR_STACK_UNWIND (mkdir, frame, op_ret, op_errno,
+ AFR_STACK_UNWIND (mkdir, frame, -1, op_errno,
NULL, NULL, NULL, NULL);
}
@@ -946,7 +937,6 @@ afr_link (call_frame_t *frame, xlator_t *this,
afr_local_t * local = NULL;
call_frame_t * transaction_frame = NULL;
int ret = -1;
- int op_ret = -1;
int op_errno = 0;
VALIDATE_OR_GOTO (frame, out);
@@ -959,18 +949,16 @@ afr_link (call_frame_t *frame, xlator_t *this,
transaction_frame = copy_frame (frame);
if (!transaction_frame) {
+ op_errno = ENOMEM;
goto out;
}
- ALLOC_OR_GOTO (local, afr_local_t, out);
+ ALLOC_OR_GOTO (transaction_frame->local, afr_local_t, out);
+ local = transaction_frame->local;
- ret = AFR_LOCAL_INIT (local, priv);
- if (ret < 0) {
- op_errno = -ret;
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
-
- transaction_frame->local = local;
loc_copy (&local->loc, oldloc);
loc_copy (&local->newloc, newloc);
@@ -994,12 +982,12 @@ afr_link (call_frame_t *frame, xlator_t *this,
afr_transaction (transaction_frame, this, AFR_ENTRY_TRANSACTION);
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
+ if (ret < 0) {
if (transaction_frame)
AFR_STACK_DESTROY (transaction_frame);
- AFR_STACK_UNWIND (link, frame, op_ret, op_errno,
+ AFR_STACK_UNWIND (link, frame, -1, op_errno,
NULL, NULL, NULL, NULL);
}
@@ -1170,7 +1158,6 @@ afr_symlink (call_frame_t *frame, xlator_t *this,
afr_local_t * local = NULL;
call_frame_t * transaction_frame = NULL;
int ret = -1;
- int op_ret = -1;
int op_errno = 0;
VALIDATE_OR_GOTO (frame, out);
@@ -1183,18 +1170,16 @@ afr_symlink (call_frame_t *frame, xlator_t *this,
transaction_frame = copy_frame (frame);
if (!transaction_frame) {
+ op_errno = ENOMEM;
goto out;
}
- ALLOC_OR_GOTO (local, afr_local_t, out);
+ ALLOC_OR_GOTO (transaction_frame->local, afr_local_t, out);
+ local = transaction_frame->local;
- ret = AFR_LOCAL_INIT (local, priv);
- if (ret < 0) {
- op_errno = -ret;
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
-
- transaction_frame->local = local;
loc_copy (&local->loc, loc);
@@ -1220,12 +1205,12 @@ afr_symlink (call_frame_t *frame, xlator_t *this,
afr_transaction (transaction_frame, this, AFR_ENTRY_TRANSACTION);
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
+ if (ret < 0) {
if (transaction_frame)
AFR_STACK_DESTROY (transaction_frame);
- AFR_STACK_UNWIND (symlink, frame, op_ret, op_errno,
+ AFR_STACK_UNWIND (symlink, frame, -1, op_errno,
NULL, NULL, NULL, NULL);
}
@@ -1388,7 +1373,6 @@ afr_rename (call_frame_t *frame, xlator_t *this,
afr_local_t * local = NULL;
call_frame_t * transaction_frame = NULL;
int ret = -1;
- int op_ret = -1;
int op_errno = 0;
VALIDATE_OR_GOTO (frame, out);
@@ -1401,18 +1385,16 @@ afr_rename (call_frame_t *frame, xlator_t *this,
transaction_frame = copy_frame (frame);
if (!transaction_frame) {
+ op_errno = ENOMEM;
goto out;
}
- ALLOC_OR_GOTO (local, afr_local_t, out);
+ ALLOC_OR_GOTO (transaction_frame->local, afr_local_t, out);
+ local = transaction_frame->local;
- ret = AFR_LOCAL_INIT (local, priv);
- if (ret < 0) {
- op_errno = -ret;
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
-
- transaction_frame->local = local;
loc_copy (&local->loc, oldloc);
loc_copy (&local->newloc, newloc);
@@ -1432,13 +1414,13 @@ afr_rename (call_frame_t *frame, xlator_t *this,
afr_transaction (transaction_frame, this, AFR_ENTRY_RENAME_TRANSACTION);
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
+ if (ret < 0) {
if (transaction_frame)
AFR_STACK_DESTROY (transaction_frame);
- AFR_STACK_UNWIND (rename, frame, op_ret, op_errno,
+ AFR_STACK_UNWIND (rename, frame, -1, op_errno,
NULL, NULL, NULL, NULL, NULL);
}
@@ -1587,7 +1569,6 @@ afr_unlink (call_frame_t *frame, xlator_t *this,
afr_local_t * local = NULL;
call_frame_t * transaction_frame = NULL;
int ret = -1;
- int op_ret = -1;
int op_errno = 0;
VALIDATE_OR_GOTO (frame, out);
@@ -1600,18 +1581,16 @@ afr_unlink (call_frame_t *frame, xlator_t *this,
transaction_frame = copy_frame (frame);
if (!transaction_frame) {
+ op_errno = ENOMEM;
goto out;
}
- ALLOC_OR_GOTO (local, afr_local_t, out);
+ ALLOC_OR_GOTO (transaction_frame->local, afr_local_t, out);
+ local = transaction_frame->local;
- ret = AFR_LOCAL_INIT (local, priv);
- if (ret < 0) {
- op_errno = -ret;
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
-
- transaction_frame->local = local;
loc_copy (&local->loc, loc);
@@ -1626,12 +1605,12 @@ afr_unlink (call_frame_t *frame, xlator_t *this,
afr_transaction (transaction_frame, this, AFR_ENTRY_TRANSACTION);
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
+ if (ret < 0) {
if (transaction_frame)
AFR_STACK_DESTROY (transaction_frame);
- AFR_STACK_UNWIND (unlink, frame, op_ret, op_errno,
+ AFR_STACK_UNWIND (unlink, frame, -1, op_errno,
NULL, NULL);
}
@@ -1783,7 +1762,6 @@ afr_rmdir (call_frame_t *frame, xlator_t *this,
afr_local_t * local = NULL;
call_frame_t * transaction_frame = NULL;
int ret = -1;
- int op_ret = -1;
int op_errno = 0;
VALIDATE_OR_GOTO (frame, out);
@@ -1796,18 +1774,16 @@ afr_rmdir (call_frame_t *frame, xlator_t *this,
transaction_frame = copy_frame (frame);
if (!transaction_frame) {
+ op_errno = ENOMEM;
goto out;
}
- ALLOC_OR_GOTO (local, afr_local_t, out);
+ ALLOC_OR_GOTO (transaction_frame->local, afr_local_t, out);
+ local = transaction_frame->local;
- ret = AFR_LOCAL_INIT (local, priv);
- if (ret < 0) {
- op_errno = -ret;
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
-
- transaction_frame->local = local;
local->cont.rmdir.flags = flags;
loc_copy (&local->loc, loc);
@@ -1823,13 +1799,12 @@ afr_rmdir (call_frame_t *frame, xlator_t *this,
afr_transaction (transaction_frame, this, AFR_ENTRY_TRANSACTION);
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
+ if (ret < 0) {
if (transaction_frame)
AFR_STACK_DESTROY (transaction_frame);
- AFR_STACK_UNWIND (rmdir, frame, op_ret, op_errno,
- NULL, NULL);
+ AFR_STACK_UNWIND (rmdir, frame, -1, op_errno, NULL, NULL);
}
return 0;
diff --git a/xlators/cluster/afr/src/afr-inode-read.c b/xlators/cluster/afr/src/afr-inode-read.c
index 82a9d27c075..162c7eed47b 100644
--- a/xlators/cluster/afr/src/afr-inode-read.c
+++ b/xlators/cluster/afr/src/afr-inode-read.c
@@ -111,9 +111,9 @@ afr_access (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t mask)
xlator_t **children = NULL;
int call_child = 0;
afr_local_t *local = NULL;
- int32_t op_ret = -1;
int32_t op_errno = 0;
int32_t read_child = -1;
+ int ret = -1;
VALIDATE_OR_GOTO (frame, out);
VALIDATE_OR_GOTO (this, out);
@@ -124,14 +124,12 @@ afr_access (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t mask)
children = priv->children;
- ALLOC_OR_GOTO (local, afr_local_t, out);
- frame->local = local;
+ ALLOC_OR_GOTO (frame->local, afr_local_t, out);
+ local = frame->local;
- op_ret = AFR_LOCAL_INIT (local, priv);
- if (op_ret < 0) {
- op_errno = -op_ret;
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
local->fresh_children = afr_children_create (priv->child_count);
if (!local->fresh_children) {
@@ -142,13 +140,12 @@ afr_access (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t mask)
read_child = afr_inode_get_read_ctx (this, loc->inode,
local->fresh_children);
- op_ret = afr_get_call_child (this, local->child_up, read_child,
+ ret = afr_get_call_child (this, local->child_up, read_child,
local->fresh_children,
&call_child,
&local->cont.access.last_index);
- if (op_ret < 0) {
- op_errno = -op_ret;
- op_ret = -1;
+ if (ret < 0) {
+ op_errno = -ret;
goto out;
}
@@ -161,11 +158,10 @@ afr_access (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t mask)
children[call_child]->fops->access,
loc, mask);
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
- AFR_STACK_UNWIND (access, frame, op_ret, op_errno);
- }
+ if (ret < 0)
+ AFR_STACK_UNWIND (access, frame, -1, op_errno);
return 0;
}
@@ -230,9 +226,9 @@ afr_stat (call_frame_t *frame, xlator_t *this, loc_t *loc)
afr_local_t *local = NULL;
xlator_t **children = NULL;
int call_child = 0;
- int32_t op_ret = -1;
int32_t op_errno = 0;
int32_t read_child = -1;
+ int ret = -1;
VALIDATE_OR_GOTO (frame, out);
VALIDATE_OR_GOTO (this, out);
@@ -243,13 +239,12 @@ afr_stat (call_frame_t *frame, xlator_t *this, loc_t *loc)
children = priv->children;
- ALLOC_OR_GOTO (local, afr_local_t, out);
- frame->local = local;
- op_ret = AFR_LOCAL_INIT (local, priv);
- if (op_ret < 0) {
- op_errno = -op_ret;
+ ALLOC_OR_GOTO (frame->local, afr_local_t, out);
+ local = frame->local;
+
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
local->fresh_children = afr_children_create (priv->child_count);
if (!local->fresh_children) {
@@ -259,13 +254,12 @@ afr_stat (call_frame_t *frame, xlator_t *this, loc_t *loc)
read_child = afr_inode_get_read_ctx (this, loc->inode,
local->fresh_children);
- op_ret = afr_get_call_child (this, local->child_up, read_child,
+ ret = afr_get_call_child (this, local->child_up, read_child,
local->fresh_children,
&call_child,
&local->cont.stat.last_index);
- if (op_ret < 0) {
- op_errno = -op_ret;
- op_ret = -1;
+ if (ret < 0) {
+ op_errno = -ret;
goto out;
}
loc_copy (&local->loc, loc);
@@ -275,11 +269,10 @@ afr_stat (call_frame_t *frame, xlator_t *this, loc_t *loc)
children[call_child]->fops->stat,
loc);
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
- AFR_STACK_UNWIND (stat, frame, op_ret, op_errno, NULL);
- }
+ if (ret < 0)
+ AFR_STACK_UNWIND (stat, frame, -1, op_errno, NULL);
return 0;
}
@@ -345,9 +338,9 @@ afr_fstat (call_frame_t *frame, xlator_t *this,
afr_local_t *local = NULL;
xlator_t **children = NULL;
int call_child = 0;
- int32_t op_ret = -1;
int32_t op_errno = 0;
int32_t read_child = 0;
+ int ret = -1;
VALIDATE_OR_GOTO (frame, out);
VALIDATE_OR_GOTO (this, out);
@@ -361,14 +354,12 @@ afr_fstat (call_frame_t *frame, xlator_t *this,
VALIDATE_OR_GOTO (fd->inode, out);
- ALLOC_OR_GOTO (local, afr_local_t, out);
- frame->local = local;
+ ALLOC_OR_GOTO (frame->local, afr_local_t, out);
+ local = frame->local;
- op_ret = AFR_LOCAL_INIT (local, priv);
- if (op_ret < 0) {
- op_errno = -op_ret;
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
local->fresh_children = afr_children_create (priv->child_count);
if (!local->fresh_children) {
@@ -381,22 +372,20 @@ afr_fstat (call_frame_t *frame, xlator_t *this,
- op_ret = afr_get_call_child (this, local->child_up, read_child,
+ ret = afr_get_call_child (this, local->child_up, read_child,
local->fresh_children,
&call_child,
&local->cont.fstat.last_index);
- if (op_ret < 0) {
- op_errno = -op_ret;
- op_ret = -1;
+ if (ret < 0) {
+ op_errno = -ret;
goto out;
}
local->fd = fd_ref (fd);
- op_ret = afr_open_fd_fix (frame, this, _gf_false);
- if (op_ret) {
- op_errno = -op_ret;
- op_ret = -1;
+ ret = afr_open_fd_fix (frame, this, _gf_false);
+ if (ret) {
+ op_errno = -ret;
goto out;
}
STACK_WIND_COOKIE (frame, afr_fstat_cbk, (void *) (long) call_child,
@@ -404,11 +393,10 @@ afr_fstat (call_frame_t *frame, xlator_t *this,
children[call_child]->fops->fstat,
fd);
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
- AFR_STACK_UNWIND (fstat, frame, op_ret, op_errno, NULL);
- }
+ if (ret < 0)
+ AFR_STACK_UNWIND (fstat, frame, -1, op_errno, NULL);
return 0;
}
@@ -474,9 +462,9 @@ afr_readlink (call_frame_t *frame, xlator_t *this,
xlator_t **children = NULL;
int call_child = 0;
afr_local_t *local = NULL;
- int32_t op_ret = -1;
int32_t op_errno = 0;
int32_t read_child = -1;
+ int ret = -1;
VALIDATE_OR_GOTO (frame, out);
VALIDATE_OR_GOTO (this, out);
@@ -487,13 +475,12 @@ afr_readlink (call_frame_t *frame, xlator_t *this,
children = priv->children;
- ALLOC_OR_GOTO (local, afr_local_t, out);
- frame->local = local;
- op_ret = AFR_LOCAL_INIT (local, priv);
- if (op_ret < 0) {
- op_errno = -op_ret;
+ ALLOC_OR_GOTO (frame->local, afr_local_t, out);
+ local = frame->local;
+
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
local->fresh_children = afr_children_create (priv->child_count);
if (!local->fresh_children) {
@@ -502,13 +489,12 @@ afr_readlink (call_frame_t *frame, xlator_t *this,
}
read_child = afr_inode_get_read_ctx (this, loc->inode,
local->fresh_children);
- op_ret = afr_get_call_child (this, local->child_up, read_child,
+ ret = afr_get_call_child (this, local->child_up, read_child,
local->fresh_children,
&call_child,
&local->cont.readlink.last_index);
- if (op_ret < 0) {
- op_errno = -op_ret;
- op_ret = -1;
+ if (ret < 0) {
+ op_errno = -ret;
goto out;
}
@@ -522,11 +508,10 @@ afr_readlink (call_frame_t *frame, xlator_t *this,
children[call_child]->fops->readlink,
loc, size);
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
- AFR_STACK_UNWIND (readlink, frame, op_ret, op_errno, NULL, NULL);
- }
+ if (ret < 0)
+ AFR_STACK_UNWIND (readlink, frame, -1, op_errno, NULL, NULL);
return 0;
}
@@ -761,9 +746,9 @@ afr_getxattr (call_frame_t *frame, xlator_t *this,
xlator_list_t *trav = NULL;
xlator_t **sub_volumes = NULL;
int i = 0;
- int32_t op_ret = -1;
int32_t op_errno = 0;
int32_t read_child = -1;
+ int ret = -1;
VALIDATE_OR_GOTO (frame, out);
@@ -775,14 +760,12 @@ afr_getxattr (call_frame_t *frame, xlator_t *this,
children = priv->children;
- ALLOC_OR_GOTO (local, afr_local_t, out);
- frame->local = local;
+ ALLOC_OR_GOTO (frame->local, afr_local_t, out);
+ local = frame->local;
- op_ret = AFR_LOCAL_INIT (local, priv);
- if (op_ret < 0) {
- op_errno = -op_ret;
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
loc_copy (&local->loc, loc);
if (name)
@@ -885,13 +868,12 @@ afr_getxattr (call_frame_t *frame, xlator_t *this,
}
read_child = afr_inode_get_read_ctx (this, loc->inode, local->fresh_children);
- op_ret = afr_get_call_child (this, local->child_up, read_child,
+ ret = afr_get_call_child (this, local->child_up, read_child,
local->fresh_children,
&call_child,
&local->cont.getxattr.last_index);
- if (op_ret < 0) {
- op_errno = -op_ret;
- op_ret = -1;
+ if (ret < 0) {
+ op_errno = -ret;
goto out;
}
@@ -901,11 +883,10 @@ afr_getxattr (call_frame_t *frame, xlator_t *this,
children[call_child]->fops->getxattr,
loc, name);
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
- AFR_STACK_UNWIND (getxattr, frame, op_ret, op_errno, NULL);
- }
+ if (ret < 0)
+ AFR_STACK_UNWIND (getxattr, frame, -1, op_errno, NULL);
return 0;
}
@@ -992,9 +973,9 @@ afr_readv (call_frame_t *frame, xlator_t *this,
afr_local_t * local = NULL;
xlator_t ** children = NULL;
int call_child = 0;
- int32_t op_ret = -1;
int32_t op_errno = 0;
int32_t read_child = -1;
+ int ret = -1;
VALIDATE_OR_GOTO (frame, out);
VALIDATE_OR_GOTO (this, out);
@@ -1004,13 +985,12 @@ afr_readv (call_frame_t *frame, xlator_t *this,
priv = this->private;
children = priv->children;
- ALLOC_OR_GOTO (local, afr_local_t, out);
- frame->local = local;
- op_ret = AFR_LOCAL_INIT (local, priv);
- if (op_ret < 0) {
- op_errno = -op_ret;
+ ALLOC_OR_GOTO (frame->local, afr_local_t, out);
+ local = frame->local;
+
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
local->fresh_children = afr_children_create (priv->child_count);
if (!local->fresh_children) {
@@ -1019,13 +999,12 @@ afr_readv (call_frame_t *frame, xlator_t *this,
}
read_child = afr_inode_get_read_ctx (this, fd->inode, local->fresh_children);
- op_ret = afr_get_call_child (this, local->child_up, read_child,
+ ret = afr_get_call_child (this, local->child_up, read_child,
local->fresh_children,
&call_child,
&local->cont.readv.last_index);
- if (op_ret < 0) {
- op_errno = -op_ret;
- op_ret = -1;
+ if (ret < 0) {
+ op_errno = -ret;
goto out;
}
@@ -1034,10 +1013,9 @@ afr_readv (call_frame_t *frame, xlator_t *this,
local->cont.readv.size = size;
local->cont.readv.offset = offset;
- op_ret = afr_open_fd_fix (frame, this, _gf_false);
- if (op_ret) {
- op_errno = -op_ret;
- op_ret = -1;
+ ret = afr_open_fd_fix (frame, this, _gf_false);
+ if (ret) {
+ op_errno = -ret;
goto out;
}
STACK_WIND_COOKIE (frame, afr_readv_cbk,
@@ -1046,10 +1024,10 @@ afr_readv (call_frame_t *frame, xlator_t *this,
children[call_child]->fops->readv,
fd, size, offset);
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
- AFR_STACK_UNWIND (readv, frame, op_ret, op_errno, NULL, 0, NULL,
+ if (ret < 0) {
+ AFR_STACK_UNWIND (readv, frame, -1, op_errno, NULL, 0, NULL,
NULL);
}
return 0;
diff --git a/xlators/cluster/afr/src/afr-inode-write.c b/xlators/cluster/afr/src/afr-inode-write.c
index 2fd2538cd2b..48094931f2e 100644
--- a/xlators/cluster/afr/src/afr-inode-write.c
+++ b/xlators/cluster/afr/src/afr-inode-write.c
@@ -440,7 +440,6 @@ afr_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
afr_private_t * priv = NULL;
afr_local_t * local = NULL;
int ret = -1;
- int op_ret = -1;
int op_errno = 0;
VALIDATE_OR_GOTO (frame, out);
@@ -451,15 +450,12 @@ afr_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
QUORUM_CHECK(writev,out);
- ALLOC_OR_GOTO (local, afr_local_t, out);
+ ALLOC_OR_GOTO (frame->local, afr_local_t, out);
+ local = frame->local;
- ret = AFR_LOCAL_INIT (local, priv);
- if (ret < 0) {
- op_errno = -ret;
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
-
- frame->local = local;
local->cont.writev.vector = iov_dup (vector, count);
local->cont.writev.count = count;
@@ -475,11 +471,10 @@ afr_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
goto out;
}
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
- AFR_STACK_UNWIND (writev, frame, op_ret, op_errno, NULL, NULL);
- }
+ if (ret < 0)
+ AFR_STACK_UNWIND (writev, frame, -1, op_errno, NULL, NULL);
return 0;
}
@@ -640,7 +635,6 @@ afr_truncate (call_frame_t *frame, xlator_t *this,
afr_local_t * local = NULL;
call_frame_t *transaction_frame = NULL;
int ret = -1;
- int op_ret = -1;
int op_errno = 0;
VALIDATE_OR_GOTO (frame, out);
@@ -653,20 +647,16 @@ afr_truncate (call_frame_t *frame, xlator_t *this,
transaction_frame = copy_frame (frame);
if (!transaction_frame) {
+ op_errno = ENOMEM;
goto out;
}
- ALLOC_OR_GOTO (local, afr_local_t, out);
+ ALLOC_OR_GOTO (transaction_frame->local, afr_local_t, out);
+ local = transaction_frame->local;
- ret = AFR_LOCAL_INIT (local, priv);
- if (ret < 0) {
- op_errno = -ret;
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
-
- transaction_frame->local = local;
-
- local->op_ret = -1;
local->cont.truncate.offset = offset;
@@ -682,12 +672,12 @@ afr_truncate (call_frame_t *frame, xlator_t *this,
afr_transaction (transaction_frame, this, AFR_DATA_TRANSACTION);
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
+ if (ret < 0) {
if (transaction_frame)
AFR_STACK_DESTROY (transaction_frame);
- AFR_STACK_UNWIND (truncate, frame, op_ret, op_errno, NULL, NULL);
+ AFR_STACK_UNWIND (truncate, frame, -1, op_errno, NULL, NULL);
}
return 0;
@@ -891,7 +881,6 @@ afr_ftruncate (call_frame_t *frame, xlator_t *this,
afr_local_t * local = NULL;
call_frame_t *transaction_frame = NULL;
int ret = -1;
- int op_ret = -1;
int op_errno = 0;
VALIDATE_OR_GOTO (frame, out);
@@ -902,15 +891,12 @@ afr_ftruncate (call_frame_t *frame, xlator_t *this,
QUORUM_CHECK(ftruncate,out);
- ALLOC_OR_GOTO (local, afr_local_t, out);
- ret = AFR_LOCAL_INIT (local, priv);
+ ALLOC_OR_GOTO (frame->local, afr_local_t, out);
+ local = frame->local;
- if (ret < 0) {
- op_errno = -ret;
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
-
- frame->local = local;
local->cont.ftruncate.offset = offset;
@@ -923,12 +909,12 @@ afr_ftruncate (call_frame_t *frame, xlator_t *this,
goto out;
}
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
+ if (ret < 0) {
if (transaction_frame)
AFR_STACK_DESTROY (transaction_frame);
- AFR_STACK_UNWIND (ftruncate, frame, op_ret, op_errno, NULL, NULL);
+ AFR_STACK_UNWIND (ftruncate, frame, -1, op_errno, NULL, NULL);
}
return 0;
@@ -1090,7 +1076,6 @@ afr_setattr (call_frame_t *frame, xlator_t *this,
afr_local_t * local = NULL;
call_frame_t *transaction_frame = NULL;
int ret = -1;
- int op_ret = -1;
int op_errno = 0;
VALIDATE_OR_GOTO (frame, out);
@@ -1103,20 +1088,16 @@ afr_setattr (call_frame_t *frame, xlator_t *this,
transaction_frame = copy_frame (frame);
if (!transaction_frame) {
+ op_errno = ENOMEM;
goto out;
}
- ALLOC_OR_GOTO (local, afr_local_t, out);
+ ALLOC_OR_GOTO (transaction_frame->local, afr_local_t, out);
+ local = transaction_frame->local;
- ret = AFR_LOCAL_INIT (local, priv);
- if (ret < 0) {
- op_errno = -ret;
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
-
- transaction_frame->local = local;
-
- local->op_ret = -1;
local->cont.setattr.in_buf = *buf;
local->cont.setattr.valid = valid;
@@ -1133,12 +1114,12 @@ afr_setattr (call_frame_t *frame, xlator_t *this,
afr_transaction (transaction_frame, this, AFR_METADATA_TRANSACTION);
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
+ if (ret < 0) {
if (transaction_frame)
AFR_STACK_DESTROY (transaction_frame);
- AFR_STACK_UNWIND (setattr, frame, op_ret, op_errno, NULL, NULL);
+ AFR_STACK_UNWIND (setattr, frame, -1, op_errno, NULL, NULL);
}
return 0;
@@ -1297,7 +1278,6 @@ afr_fsetattr (call_frame_t *frame, xlator_t *this,
afr_local_t * local = NULL;
call_frame_t *transaction_frame = NULL;
int ret = -1;
- int op_ret = -1;
int op_errno = 0;
VALIDATE_OR_GOTO (frame, out);
@@ -1314,16 +1294,12 @@ afr_fsetattr (call_frame_t *frame, xlator_t *this,
goto out;
}
- ALLOC_OR_GOTO (local, afr_local_t, out);
- transaction_frame->local = local;
+ ALLOC_OR_GOTO (transaction_frame->local, afr_local_t, out);
+ local = transaction_frame->local;
- ret = AFR_LOCAL_INIT (local, priv);
- if (ret < 0) {
- op_errno = -ret;
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
-
- local->op_ret = -1;
local->cont.fsetattr.in_buf = *buf;
local->cont.fsetattr.valid = valid;
@@ -1334,10 +1310,9 @@ afr_fsetattr (call_frame_t *frame, xlator_t *this,
local->fd = fd_ref (fd);
- op_ret = afr_open_fd_fix (transaction_frame, this, _gf_false);
+ ret = afr_open_fd_fix (transaction_frame, this, _gf_false);
if (ret) {
- op_errno = -op_ret;
- op_ret = -1;
+ op_errno = -ret;
goto out;
}
@@ -1347,12 +1322,12 @@ afr_fsetattr (call_frame_t *frame, xlator_t *this,
afr_transaction (transaction_frame, this, AFR_METADATA_TRANSACTION);
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
+ if (ret < 0) {
if (transaction_frame)
AFR_STACK_DESTROY (transaction_frame);
- AFR_STACK_UNWIND (fsetattr, frame, op_ret, op_errno, NULL, NULL);
+ AFR_STACK_UNWIND (fsetattr, frame, -1, op_errno, NULL, NULL);
}
return 0;
@@ -1488,7 +1463,6 @@ afr_setxattr (call_frame_t *frame, xlator_t *this,
afr_local_t * local = NULL;
call_frame_t *transaction_frame = NULL;
int ret = -1;
- int op_ret = -1;
int op_errno = 0;
VALIDATE_OR_GOTO (frame, out);
@@ -1498,23 +1472,18 @@ afr_setxattr (call_frame_t *frame, xlator_t *this,
priv = this->private;
QUORUM_CHECK(setxattr,out);
-
- ALLOC_OR_GOTO (local, afr_local_t, out);
-
- ret = AFR_LOCAL_INIT (local, priv);
- if (ret < 0) {
- op_errno = -ret;
- goto out;
- }
-
transaction_frame = copy_frame (frame);
if (!transaction_frame) {
+ op_errno = ENOMEM;
goto out;
}
- transaction_frame->local = local;
+ ALLOC_OR_GOTO (transaction_frame->local, afr_local_t, out);
+ local = transaction_frame->local;
- local->op_ret = -1;
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
+ goto out;
local->cont.setxattr.dict = dict_ref (dict);
local->cont.setxattr.flags = flags;
@@ -1531,12 +1500,12 @@ afr_setxattr (call_frame_t *frame, xlator_t *this,
afr_transaction (transaction_frame, this, AFR_METADATA_TRANSACTION);
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
+ if (ret < 0) {
if (transaction_frame)
AFR_STACK_DESTROY (transaction_frame);
- AFR_STACK_UNWIND (setxattr, frame, op_ret, op_errno);
+ AFR_STACK_UNWIND (setxattr, frame, -1, op_errno);
}
return 0;
@@ -1673,7 +1642,6 @@ afr_removexattr (call_frame_t *frame, xlator_t *this,
afr_local_t * local = NULL;
call_frame_t *transaction_frame = NULL;
int ret = -1;
- int op_ret = -1;
int op_errno = 0;
VALIDATE_OR_GOTO (frame, out);
@@ -1687,20 +1655,16 @@ afr_removexattr (call_frame_t *frame, xlator_t *this,
transaction_frame = copy_frame (frame);
if (!transaction_frame) {
+ op_errno = ENOMEM;
goto out;
}
- ALLOC_OR_GOTO (local, afr_local_t, out);
+ ALLOC_OR_GOTO (transaction_frame->local, afr_local_t, out);
+ local = transaction_frame->local;
- ret = AFR_LOCAL_INIT (local, priv);
- if (ret < 0) {
- op_errno = -ret;
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
-
- transaction_frame->local = local;
-
- local->op_ret = -1;
local->cont.removexattr.name = gf_strdup (name);
@@ -1716,12 +1680,12 @@ afr_removexattr (call_frame_t *frame, xlator_t *this,
afr_transaction (transaction_frame, this, AFR_METADATA_TRANSACTION);
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
+ if (ret < 0) {
if (transaction_frame)
AFR_STACK_DESTROY (transaction_frame);
- AFR_STACK_UNWIND (removexattr, frame, op_ret, op_errno);
+ AFR_STACK_UNWIND (removexattr, frame, -1, op_errno);
}
return 0;
diff --git a/xlators/cluster/afr/src/afr-lk-common.c b/xlators/cluster/afr/src/afr-lk-common.c
index 0680f59c294..41fa8a30bab 100644
--- a/xlators/cluster/afr/src/afr-lk-common.c
+++ b/xlators/cluster/afr/src/afr-lk-common.c
@@ -2165,13 +2165,14 @@ out:
int
afr_attempt_lock_recovery (xlator_t *this, int32_t child_index)
{
- call_frame_t *frame = NULL;
- afr_private_t *priv = NULL;
- afr_local_t *local = NULL;
- afr_locked_fd_t *locked_fd = NULL;
+ call_frame_t *frame = NULL;
+ afr_private_t *priv = NULL;
+ afr_local_t *local = NULL;
+ afr_locked_fd_t *locked_fd = NULL;
afr_locked_fd_t *tmp = NULL;
- int ret = 0;
+ int ret = -1;
struct list_head locks_list = {0,};
+ int32_t op_errno = 0;
priv = this->private;
@@ -2185,15 +2186,10 @@ afr_attempt_lock_recovery (xlator_t *this, int32_t child_index)
goto out;
}
- local = GF_CALLOC (1, sizeof (*local),
- gf_afr_mt_afr_local_t);
- if (!local) {
- ret = -1;
- goto out;
- }
-
- AFR_LOCAL_INIT (local, priv);
- if (!local) {
+ ALLOC_OR_GOTO (frame->local, afr_local_t, out);
+ local = frame->local;
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0) {
ret = -1;
goto out;
}
@@ -2231,6 +2227,8 @@ afr_attempt_lock_recovery (xlator_t *this, int32_t child_index)
}
out:
+ if ((ret < 0) && frame)
+ AFR_STACK_DESTROY (frame);
return ret;
}
diff --git a/xlators/cluster/afr/src/afr-open.c b/xlators/cluster/afr/src/afr-open.c
index 0b46f213f4b..813b3c451cc 100644
--- a/xlators/cluster/afr/src/afr-open.c
+++ b/xlators/cluster/afr/src/afr-open.c
@@ -202,7 +202,6 @@ afr_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
int i = 0;
int ret = -1;
int32_t call_count = 0;
- int32_t op_ret = -1;
int32_t op_errno = 0;
int32_t wind_flags = flags & (~O_TRUNC);
//We can't let truncation to happen outside transaction.
@@ -226,15 +225,13 @@ afr_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
goto out;
}
- ALLOC_OR_GOTO (local, afr_local_t, out);
+ ALLOC_OR_GOTO (frame->local, afr_local_t, out);
+ local = frame->local;
- ret = AFR_LOCAL_INIT (local, priv);
- if (ret < 0) {
- op_errno = -ret;
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
- frame->local = local;
call_count = local->call_count;
loc_copy (&local->loc, loc);
@@ -255,11 +252,10 @@ afr_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
}
}
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
- AFR_STACK_UNWIND (open, frame, op_ret, op_errno, fd);
- }
+ if (ret < 0)
+ AFR_STACK_UNWIND (open, frame, -1, op_errno, fd);
return 0;
}
@@ -395,9 +391,9 @@ afr_fix_open (call_frame_t *frame, xlator_t *this, afr_fd_ctx_t *fd_ctx,
ret = -ENOMEM;
goto out;
}
- ALLOC_OR_GOTO (open_local, afr_local_t, out);
- open_frame->local = open_local;
- ret = AFR_LOCAL_INIT (open_local, priv);
+ ALLOC_OR_GOTO (open_frame->local, afr_local_t, out);
+ open_local = open_frame->local;
+ ret = afr_local_init (open_local, priv, &op_errno);
if (ret < 0)
goto out;
loc_copy (&open_local->loc, &local->loc);
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
index 37a13d5de2a..70239d2c69b 100644
--- a/xlators/cluster/afr/src/afr.h
+++ b/xlators/cluster/afr/src/afr.h
@@ -902,7 +902,7 @@ int32_t *
afr_children_create (int32_t child_count);
int
-AFR_LOCAL_INIT (afr_local_t *local, afr_private_t *priv);
+afr_local_init (afr_local_t *local, afr_private_t *priv, int32_t *op_errno);
int
afr_internal_lock_init (afr_internal_lock_t *lk, size_t child_count,
diff --git a/xlators/cluster/afr/src/pump.c b/xlators/cluster/afr/src/pump.c
index 007daa6f11d..5bb602bcdcf 100644
--- a/xlators/cluster/afr/src/pump.c
+++ b/xlators/cluster/afr/src/pump.c
@@ -1374,7 +1374,7 @@ pump_getxattr (call_frame_t *frame, xlator_t *this,
xlator_t ** children = NULL;
int call_child = 0;
afr_local_t *local = NULL;
- int32_t op_ret = -1;
+ int32_t ret = -1;
int32_t op_errno = 0;
uint64_t read_child = 0;
@@ -1387,15 +1387,21 @@ pump_getxattr (call_frame_t *frame, xlator_t *this,
VALIDATE_OR_GOTO (priv->children, out);
children = priv->children;
+ if (!priv->use_afr_in_pump) {
+ STACK_WIND (frame, default_getxattr_cbk,
+ FIRST_CHILD (this),
+ (FIRST_CHILD (this))->fops->getxattr,
+ loc, name);
+ return 0;
+ }
- ALLOC_OR_GOTO (local, afr_local_t, out);
- frame->local = local;
- op_ret = AFR_LOCAL_INIT (local, priv);
- if (op_ret < 0) {
- op_errno = -op_ret;
+ ALLOC_OR_GOTO (frame->local, afr_local_t, out);
+ local = frame->local;
+
+ ret = afr_local_init (local, priv, &op_errno);
+ if (ret < 0)
goto out;
- }
if (name) {
if (!strncmp (name, AFR_XATTR_PREFIX,
@@ -1409,35 +1415,27 @@ pump_getxattr (call_frame_t *frame, xlator_t *this,
gf_log (this->name, GF_LOG_DEBUG,
"Hit pump command - status");
pump_execute_status (frame, this);
- op_ret = 0;
+ ret = 0;
goto out;
}
}
- if (!priv->use_afr_in_pump) {
- STACK_WIND (frame, default_getxattr_cbk,
- FIRST_CHILD (this),
- (FIRST_CHILD (this))->fops->getxattr,
- loc, name);
- return 0;
- }
-
local->fresh_children = GF_CALLOC (priv->child_count,
sizeof (*local->fresh_children),
gf_afr_mt_int32_t);
- if (local->fresh_children) {
+ if (!local->fresh_children) {
+ ret = -1;
op_errno = ENOMEM;
goto out;
}
read_child = afr_inode_get_read_ctx (this, loc->inode, local->fresh_children);
- op_ret = afr_get_call_child (this, local->child_up, read_child,
+ ret = afr_get_call_child (this, local->child_up, read_child,
local->fresh_children,
&call_child,
&local->cont.getxattr.last_index);
- if (op_ret < 0) {
- op_errno = -op_ret;
- op_ret = -1;
+ if (ret < 0) {
+ op_errno = -ret;
goto out;
}
loc_copy (&local->loc, loc);
@@ -1449,11 +1447,10 @@ pump_getxattr (call_frame_t *frame, xlator_t *this,
children[call_child], children[call_child]->fops->getxattr,
loc, name);
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
- AFR_STACK_UNWIND (getxattr, frame, op_ret, op_errno, NULL);
- }
+ if (ret < 0)
+ AFR_STACK_UNWIND (getxattr, frame, -1, op_errno, NULL);
return 0;
}
@@ -1651,7 +1648,6 @@ pump_setxattr (call_frame_t *frame, xlator_t *this,
int ret = -1;
- int op_ret = -1;
int op_errno = 0;
VALIDATE_OR_GOTO (frame, out);
@@ -1659,34 +1655,37 @@ pump_setxattr (call_frame_t *frame, xlator_t *this,
VALIDATE_OR_GOTO (this->private, out);
priv = this->private;
+ if (!priv->use_afr_in_pump) {
+ STACK_WIND (frame, default_setxattr_cbk,
+ FIRST_CHILD (this),
+ (FIRST_CHILD (this))->fops->setxattr,
+ loc, dict, flags);
+ return 0;
+ }
+
ALLOC_OR_GOTO (local, afr_local_t, out);
- ret = AFR_LOCAL_INIT (local, priv);
+ ret = afr_local_init (local, priv, &op_errno);
if (ret < 0) {
- op_errno = -ret;
+ afr_local_cleanup (local, this);
goto out;
- }
+ }
ret = pump_parse_command (frame, this,
local, dict);
if (ret >= 0) {
- op_ret = 0;
+ ret = 0;
goto out;
}
- if (!priv->use_afr_in_pump) {
- STACK_WIND (frame, default_setxattr_cbk,
- FIRST_CHILD (this),
- (FIRST_CHILD (this))->fops->setxattr,
- loc, dict, flags);
- return 0;
- }
-
transaction_frame = copy_frame (frame);
if (!transaction_frame) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory.");
+ op_errno = ENOMEM;
+ ret = -1;
+ afr_local_cleanup (local, this);
goto out;
}
@@ -1709,12 +1708,12 @@ pump_setxattr (call_frame_t *frame, xlator_t *this,
afr_transaction (transaction_frame, this, AFR_METADATA_TRANSACTION);
- op_ret = 0;
+ ret = 0;
out:
- if (op_ret == -1) {
+ if (ret < 0) {
if (transaction_frame)
AFR_STACK_DESTROY (transaction_frame);
- AFR_STACK_UNWIND (setxattr, frame, op_ret, op_errno);
+ AFR_STACK_UNWIND (setxattr, frame, -1, op_errno);
}
return 0;