Blob Blame History Raw
From ad552c08bab5cb17cc0aecff3fa782d6ec1e2eb4 Mon Sep 17 00:00:00 2001
From: Pranith Kumar K <pkarampu@redhat.com>
Date: Mon, 6 Jul 2015 14:23:56 +0530
Subject: [PATCH 205/212] cluster/ec: Don't read from bad subvols

        Backport of http://review.gluster.org/11531

Change-Id: Ic22813371faca4e8198c9b0b20518e68d275f3c1
BUG: 1230513
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/52367
---
 xlators/cluster/ec/src/ec-common.c |   41 ++++++++++++++++++++---------------
 1 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c
index 455df99..200aeda 100644
--- a/xlators/cluster/ec/src/ec-common.c
+++ b/xlators/cluster/ec/src/ec-common.c
@@ -382,6 +382,24 @@ void ec_complete(ec_fop_data_t * fop)
     ec_fop_data_release(fop);
 }
 
+/* There could be already granted locks sitting on the bricks, unlock for which
+ * must be wound at all costs*/
+static gf_boolean_t
+ec_must_wind (ec_fop_data_t *fop)
+{
+        if ((fop->id == GF_FOP_INODELK) || (fop->id == GF_FOP_FINODELK) ||
+            (fop->id == GF_FOP_LK)) {
+                if (fop->flock.l_type == F_UNLCK)
+                        return _gf_true;
+        } else if ((fop->id == GF_FOP_ENTRYLK) ||
+                   (fop->id == GF_FOP_FENTRYLK)) {
+                if (fop->entrylk_cmd == ENTRYLK_UNLOCK)
+                        return _gf_true;
+        }
+
+        return _gf_false;
+}
+
 int32_t ec_child_select(ec_fop_data_t * fop)
 {
     ec_t * ec = fop->xl->private;
@@ -391,6 +409,11 @@ int32_t ec_child_select(ec_fop_data_t * fop)
     ec_fop_cleanup(fop);
 
     fop->mask &= ec->node_mask;
+    /* Wind the fop on same subvols as parent for any internal extra fops like
+     * head/tail read in case of writev fop. Unlocks shouldn't do this because
+     * unlock should go on all subvols where lock is performed*/
+    if (fop->parent && !ec_must_wind (fop))
+            fop->mask &= fop->parent->mask;
 
     mask = ec->xl_up;
     if (fop->parent == NULL)
@@ -1868,24 +1891,6 @@ void ec_lock_reuse(ec_fop_data_t *fop)
     }
 }
 
-/* There could be already granted locks sitting on the bricks, unlock for which
- * must be wound at all costs*/
-static gf_boolean_t
-ec_must_wind (ec_fop_data_t *fop)
-{
-        if ((fop->id == GF_FOP_INODELK) || (fop->id == GF_FOP_FINODELK) ||
-            (fop->id == GF_FOP_LK)) {
-                if (fop->flock.l_type == F_UNLCK)
-                        return _gf_true;
-        } else if ((fop->id == GF_FOP_ENTRYLK) ||
-                   (fop->id == GF_FOP_FENTRYLK)) {
-                if (fop->entrylk_cmd == ENTRYLK_UNLOCK)
-                        return _gf_true;
-        }
-
-        return _gf_false;
-}
-
 void __ec_manager(ec_fop_data_t * fop, int32_t error)
 {
     ec_t *ec = fop->xl->private;
-- 
1.7.1