summaryrefslogtreecommitdiffstats
path: root/xlators/cluster
diff options
context:
space:
mode:
authorRavishankar N <ravishankar@redhat.com>2018-07-02 12:40:41 +0530
committerRavishankar N <ravishankar@redhat.com>2018-07-06 07:12:54 +0530
commita4d67a1e0572a3bdb353c03eb3cff9646c6e2a5d (patch)
treecbda8ab45b335bd0b055a854172939264a3b47cb /xlators/cluster
parent4328790e246eb43bdc87cf5071f81dc4114900cd (diff)
afr: add quorum checks in pre-op
Backport of https://review.gluster.org/#/c/19781/ Problem: We seem to be winding the FOP if pre-op did not succeed on quorum bricks and then failing the FOP with EROFS since the fop did not meet quorum. This essentially masks the actual error due to which pre-op failed. (See BZ). Fix: Skip FOP phase if pre-op quorum is not met and go to post-op. Change-Id: Ie58a41e8fa1ad79aa06093706e96db8eef61b6d9 BUG: 1597154 Signed-off-by: Ravishankar N <ravishankar@redhat.com>
Diffstat (limited to 'xlators/cluster')
-rw-r--r--xlators/cluster/afr/src/afr-transaction.c60
1 files changed, 31 insertions, 29 deletions
diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c
index 19740e18b18..98886246df4 100644
--- a/xlators/cluster/afr/src/afr-transaction.c
+++ b/xlators/cluster/afr/src/afr-transaction.c
@@ -137,6 +137,29 @@ afr_needs_changelog_update (afr_local_t *local)
return _gf_false;
}
+gf_boolean_t
+afr_changelog_has_quorum (afr_local_t *local, xlator_t *this)
+{
+ afr_private_t *priv = NULL;
+ int i = 0;
+ unsigned char *success_children = NULL;
+
+ priv = this->private;
+ success_children = alloca0 (priv->child_count);
+
+ for (i = 0; i < priv->child_count; i++) {
+ if (!local->transaction.failed_subvols[i]) {
+ success_children[i] = 1;
+ }
+ }
+
+ if (afr_has_quorum (success_children, this)) {
+ return _gf_true;
+ }
+
+ return _gf_false;
+}
+
int
__afr_txn_write_fop (call_frame_t *frame, xlator_t *this)
{
@@ -154,7 +177,10 @@ __afr_txn_write_fop (call_frame_t *frame, xlator_t *this)
call_count = priv->child_count - AFR_COUNT (failed_subvols,
priv->child_count);
- if (call_count == 0) {
+ /* Fail if pre-op did not succeed on quorum no. of bricks. */
+ if (!afr_changelog_has_quorum (local, this) || !call_count) {
+ local->op_ret = -1;
+ /* local->op_errno is already captured in changelog cbk. */
local->transaction.resume (frame, this);
return 0;
}
@@ -533,33 +559,6 @@ afr_lock_server_count (afr_private_t *priv, afr_transaction_type type)
/* {{{ pending */
-
-void
-afr_handle_post_op_quorum (afr_local_t *local, xlator_t *this)
-{
- afr_private_t *priv = NULL;
- int i = 0;
- unsigned char *post_op_children = NULL;
-
- priv = this->private;
- post_op_children = alloca0 (priv->child_count);
-
- for (i = 0; i < priv->child_count; i++) {
- if (!local->transaction.failed_subvols[i]) {
- post_op_children[i] = 1;
- }
- }
-
- if (afr_has_quorum (post_op_children, this)) {
- return;
- }
-
- local->op_ret = -1;
- /*local->op_errno is already captured in post-op callback.*/
-
- return;
-}
-
int
afr_changelog_post_op_done (call_frame_t *frame, xlator_t *this)
{
@@ -572,7 +571,10 @@ afr_changelog_post_op_done (call_frame_t *frame, xlator_t *this)
int_lock = &local->internal_lock;
/* Fail the FOP if post-op did not succeed on quorum no. of bricks. */
- afr_handle_post_op_quorum (local, this);
+ if (!afr_changelog_has_quorum (local, this)) {
+ local->op_ret = -1;
+ /*local->op_errno is already captured in changelog cbk*/
+ }
if (local->transaction.resume_stub) {
call_resume (local->transaction.resume_stub);