From 3d75e32d6ada03c979077681ff414d948800f07e Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Fri, 27 May 2016 15:47:07 +0530 Subject: cluster/afr: Unwind xdata_rsp even in case of failures DHT expects GF_PREOP_CHECK_FAILED to be present in xdata_rsp in case of mkdir failures because of stale layout. But AFR was unwinding null xdata_rsp in case of failures. This was leading to mkdir failures just after remove-brick. Unwind the xdata_rsp in case of failures to make sure the response from brick reaches dht. BUG: 1340623 Change-Id: Idd3f7b95730e8ea987b608e892011ff190e181d1 Signed-off-by: Pranith Kumar K Reviewed-on: http://review.gluster.org/14553 NetBSD-regression: NetBSD Build System Reviewed-by: Ravishankar N Smoke: Gluster Build System CentOS-regression: Gluster Build System Reviewed-by: Anuradha Talur Reviewed-by: Krutika Dhananjay --- xlators/cluster/afr/src/afr-common.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'xlators/cluster/afr/src/afr-common.c') diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c index 2043e11d1e8..c20c53218f9 100644 --- a/xlators/cluster/afr/src/afr-common.c +++ b/xlators/cluster/afr/src/afr-common.c @@ -1269,6 +1269,7 @@ afr_inode_read_subvol_type_get (inode_t *inode, xlator_t *this, int afr_read_subvol_get (inode_t *inode, xlator_t *this, int *subvol_p, + unsigned char *readables, int *event_p, afr_transaction_type type, afr_read_subvol_args_t *args) { @@ -1305,6 +1306,9 @@ afr_read_subvol_get (inode_t *inode, xlator_t *this, int *subvol_p, *subvol_p = subvol; if (event_p) *event_p = event; + if (readables) + memcpy (readables, readable, + sizeof (*readables) * priv->child_count); return subvol; } @@ -1434,6 +1438,7 @@ afr_local_cleanup (afr_local_t *local, xlator_t *this) GF_FREE (local->read_attempted); GF_FREE (local->readable); + GF_FREE (local->readable2); if (local->inode) inode_unref (local->inode); @@ -1593,8 +1598,8 @@ afr_get_parent_read_subvol (xlator_t *this, inode_t *parent, priv = this->private; if (parent) - par_read_subvol = afr_data_subvol_get (parent, this, 0, 0, - NULL); + par_read_subvol = afr_data_subvol_get (parent, this, NULL, NULL, + NULL, NULL); for (i = 0; i < priv->child_count; i++) { if (!replies[i].valid) @@ -1633,8 +1638,7 @@ afr_read_subvol_decide (inode_t *inode, xlator_t *this, int data_subvol = -1; int mdata_subvol = -1; - data_subvol = afr_data_subvol_get (inode, this, - 0, 0, args); + data_subvol = afr_data_subvol_get (inode, this, NULL, NULL, NULL, args); mdata_subvol = afr_metadata_subvol_get (inode, this, 0, 0, args); if (data_subvol == -1 || mdata_subvol == -1) @@ -1782,7 +1786,7 @@ afr_lookup_done (call_frame_t *frame, xlator_t *this) goto cant_interpret; } else { read_subvol = afr_data_subvol_get (local->inode, this, - 0, 0, &args); + NULL, NULL, NULL, &args); } } else { cant_interpret: @@ -2409,7 +2413,7 @@ afr_discover (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xattr_req return 0; } - afr_read_subvol_get (loc->inode, this, NULL, &event, + afr_read_subvol_get (loc->inode, this, NULL, NULL, &event, AFR_DATA_TRANSACTION, NULL); if (event != local->event_generation) @@ -2560,7 +2564,7 @@ afr_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xattr_req) } } - afr_read_subvol_get (loc->parent, this, NULL, &event, + afr_read_subvol_get (loc->parent, this, NULL, NULL, &event, AFR_DATA_TRANSACTION, NULL); if (event != local->event_generation) @@ -2883,7 +2887,8 @@ afr_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this, local = frame->local; - read_subvol = afr_data_subvol_get (local->inode, this, 0, 0, NULL); + read_subvol = afr_data_subvol_get (local->inode, this, NULL, NULL, + NULL, NULL); LOCK (&frame->lock); { @@ -4283,6 +4288,14 @@ afr_local_init (afr_local_t *local, afr_private_t *priv, int32_t *op_errno) goto out; } + local->readable2 = GF_CALLOC (priv->child_count, sizeof (char), + gf_afr_mt_char); + if (!local->readable2) { + if (op_errno) + *op_errno = ENOMEM; + goto out; + } + local->replies = GF_CALLOC(priv->child_count, sizeof(*local->replies), gf_afr_mt_reply_t); if (!local->replies) { -- cgit