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