From da9f8bd6e9421209243afeabbad350cc1d70fdc5 Mon Sep 17 00:00:00 2001 From: Ravishankar N Date: Mon, 26 Oct 2015 14:14:18 +0530 Subject: afr: fixes in transaction code Backport of http://review.gluster.org/#/c/12368/ and http://review.gluster.org/#/c/12415/ 1. When winding the pre-op, transaction.pre_op[i] is set. If the pre-op fails, transaction.failed_subvols[i] is set. If if fails on all chidren, we can directly proceed to unlock (via afr_changelog_post_op_now) without trying to wind the write, fail and then going to unlock. 2. 'fop_subvols' seems to be an unused variable, hence removing it. 3. Call local->transaction.wind() only on subvols where pre-op succeeded. Change-Id: I9525628daf48082e979b0093fa0478934495e61f BUG: 1273334 Signed-off-by: Ravishankar N Reviewed-on: http://review.gluster.org/12399 Tested-by: NetBSD Build System Tested-by: Gluster Build System Reviewed-by: Pranith Kumar Karampuri --- xlators/cluster/afr/src/afr-transaction.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'xlators/cluster/afr/src/afr-transaction.c') diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c index 915b68ef07d..4c85a4b0d03 100644 --- a/xlators/cluster/afr/src/afr-transaction.c +++ b/xlators/cluster/afr/src/afr-transaction.c @@ -44,12 +44,16 @@ __afr_txn_write_fop (call_frame_t *frame, xlator_t *this) afr_local_t *local = NULL; afr_private_t *priv = NULL; int call_count = -1; + unsigned char *failed_subvols = NULL; int i = 0; local = frame->local; priv = this->private; - call_count = AFR_COUNT (local->transaction.pre_op, priv->child_count); + failed_subvols = local->transaction.failed_subvols; + + call_count = priv->child_count - AFR_COUNT (failed_subvols, + priv->child_count); if (call_count == 0) { local->transaction.resume (frame, this); @@ -59,7 +63,7 @@ __afr_txn_write_fop (call_frame_t *frame, xlator_t *this) local->call_count = call_count; for (i = 0; i < priv->child_count; i++) { - if (local->transaction.pre_op[i]) { + if (local->transaction.pre_op[i] && !failed_subvols[i]) { local->transaction.wind (frame, this, i); if (!--call_count) @@ -973,8 +977,10 @@ afr_changelog_cbk (call_frame_t *frame, void *cookie, xlator_t *this, priv = this->private; child_index = (long) cookie; - if (op_ret == -1) + if (op_ret == -1) { + local->op_errno = op_errno; afr_transaction_fop_failed (frame, this, child_index); + } if (priv->arbiter_count == 1 && !op_ret) { if (xattr) -- cgit