17b94a
From 220b95085847b5f6a9e5bee7a9519efe72600e6a Mon Sep 17 00:00:00 2001
17b94a
From: Pranith Kumar K <pkarampu@redhat.com>
17b94a
Date: Thu, 18 Jul 2019 11:25:31 +0530
17b94a
Subject: [PATCH 272/276] cluster/ec: Always read from good-mask
17b94a
17b94a
There are cases where fop->mask may have fop->healing added
17b94a
and readv shouldn't be wound on fop->healing. To avoid this
17b94a
always wind readv to lock->good_mask
17b94a
17b94a
Upstream-patch: https://review.gluster.org/c/glusterfs/+/23069
17b94a
fixes: bz#1730914
17b94a
Change-Id: I2226ef0229daf5ff315d51e868b980ee48060b87
17b94a
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
17b94a
Reviewed-on: https://code.engineering.redhat.com/gerrit/177976
17b94a
Tested-by: RHGS Build Bot <nigelb@redhat.com>
17b94a
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
17b94a
---
17b94a
 xlators/cluster/ec/src/ec-common.c      |  3 +++
17b94a
 xlators/cluster/ec/src/ec-inode-write.c | 27 ++++++++++++++++++++++-----
17b94a
 2 files changed, 25 insertions(+), 5 deletions(-)
17b94a
17b94a
diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c
17b94a
index db1ff5b..28b31c9 100644
17b94a
--- a/xlators/cluster/ec/src/ec-common.c
17b94a
+++ b/xlators/cluster/ec/src/ec-common.c
17b94a
@@ -654,6 +654,9 @@ ec_child_select(ec_fop_data_t *fop)
17b94a
      * unlock should go on all subvols where lock is performed*/
17b94a
     if (fop->parent && !ec_internal_op(fop)) {
17b94a
         fop->mask &= (fop->parent->mask & ~fop->parent->healing);
17b94a
+        if (ec_is_data_fop(fop->id)) {
17b94a
+            fop->healing |= fop->parent->healing;
17b94a
+        }
17b94a
     }
17b94a
 
17b94a
     if ((fop->mask & ~ec->xl_up) != 0) {
17b94a
diff --git a/xlators/cluster/ec/src/ec-inode-write.c b/xlators/cluster/ec/src/ec-inode-write.c
17b94a
index a45e6d6..4f35b6d 100644
17b94a
--- a/xlators/cluster/ec/src/ec-inode-write.c
17b94a
+++ b/xlators/cluster/ec/src/ec-inode-write.c
17b94a
@@ -1977,6 +1977,20 @@ ec_get_and_merge_stripe(ec_t *ec, ec_fop_data_t *fop, ec_stripe_part_t which)
17b94a
     return found;
17b94a
 }
17b94a
 
17b94a
+static uintptr_t
17b94a
+ec_get_lock_good_mask(inode_t *inode, xlator_t *xl)
17b94a
+{
17b94a
+    ec_lock_t *lock = NULL;
17b94a
+    ec_inode_t *ictx = NULL;
17b94a
+    LOCK(&inode->lock);
17b94a
+    {
17b94a
+        ictx = __ec_inode_get(inode, xl);
17b94a
+        lock = ictx->inode_lock;
17b94a
+    }
17b94a
+    UNLOCK(&inode->lock);
17b94a
+    return lock->good_mask;
17b94a
+}
17b94a
+
17b94a
 void
17b94a
 ec_writev_start(ec_fop_data_t *fop)
17b94a
 {
17b94a
@@ -2022,9 +2036,10 @@ ec_writev_start(ec_fop_data_t *fop)
17b94a
                     err = -ENOMEM;
17b94a
                     goto failed_xdata;
17b94a
                 }
17b94a
-                ec_readv(fop->frame, fop->xl, -1, EC_MINIMUM_MIN,
17b94a
-                         ec_writev_merge_head, NULL, fd, ec->stripe_size,
17b94a
-                         fop->offset, 0, xdata);
17b94a
+                ec_readv(fop->frame, fop->xl,
17b94a
+                         ec_get_lock_good_mask(fop->fd->inode, fop->xl),
17b94a
+                         EC_MINIMUM_MIN, ec_writev_merge_head, NULL, fd,
17b94a
+                         ec->stripe_size, fop->offset, 0, xdata);
17b94a
             }
17b94a
         } else {
17b94a
             memset(fop->vector[0].iov_base, 0, fop->head);
17b94a
@@ -2047,8 +2062,10 @@ ec_writev_start(ec_fop_data_t *fop)
17b94a
                     err = -ENOMEM;
17b94a
                     goto failed_xdata;
17b94a
                 }
17b94a
-                ec_readv(fop->frame, fop->xl, -1, EC_MINIMUM_MIN,
17b94a
-                         ec_writev_merge_tail, NULL, fd, ec->stripe_size,
17b94a
+                ec_readv(fop->frame, fop->xl,
17b94a
+                         ec_get_lock_good_mask(fop->fd->inode, fop->xl),
17b94a
+                         EC_MINIMUM_MIN, ec_writev_merge_tail, NULL, fd,
17b94a
+                         ec->stripe_size,
17b94a
                          fop->offset + fop->size - ec->stripe_size, 0, xdata);
17b94a
             }
17b94a
         } else {
17b94a
-- 
17b94a
1.8.3.1
17b94a