summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr/src/pump.c
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/pump.c
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/pump.c')
-rw-r--r--xlators/cluster/afr/src/pump.c81
1 files changed, 40 insertions, 41 deletions
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;