cb8e9e
From e41916c72748a0997dbdd56e2f33525322944ac5 Mon Sep 17 00:00:00 2001
cb8e9e
From: Xavier Hernandez <xhernandez@datalab.es>
cb8e9e
Date: Sun, 31 May 2015 19:53:41 +0200
cb8e9e
Subject: [PATCH 171/190] cluster/ec: Fix incorrect check for iatt differences
cb8e9e
cb8e9e
A previous patch (http://review.gluster.org/10974) introduced a
cb8e9e
bug that caused that some metadata differences could not be
cb8e9e
detected in some circumstances. This could cause that self-heal
cb8e9e
is not triggered and the file not repaired.
cb8e9e
cb8e9e
We also need to consider all differences for lookup requests, even
cb8e9e
if there isn't any lock. Special handling of differences in lookup
cb8e9e
is already done in lookup specific code.
cb8e9e
cb8e9e
Backporting patch http://review.gluster.org/#/c/11018/
cb8e9e
cb8e9e
cherry-pick of commit 29d5bd5fc8a7b24865801de9f2e3f10d55af6e85
cb8e9e
>Change-Id: I3766b0f412b3201ae8a04664349578713572edc6
cb8e9e
>BUG: 1225793
cb8e9e
>Signed-off-by: Xavier Hernandez <xhernandez@datalab.es>
cb8e9e
>Reviewed-on: http://review.gluster.org/11018
cb8e9e
>Tested-by: Gluster Build System <jenkins@build.gluster.com>
cb8e9e
>Tested-by: NetBSD Build System <jenkins@build.gluster.org>
cb8e9e
>Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
cb8e9e
cb8e9e
Change-Id: I3766b0f412b3201ae8a04664349578713572edc6
cb8e9e
BUG: 1226149
cb8e9e
Signed-off-by: Nandaja Varma <nvarma@redhat.com>
cb8e9e
Reviewed-on: https://code.engineering.redhat.com/gerrit/51747
cb8e9e
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
cb8e9e
Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
cb8e9e
---
cb8e9e
 xlators/cluster/ec/src/ec-combine.c |   24 +++++++++++++++++++-----
cb8e9e
 1 files changed, 19 insertions(+), 5 deletions(-)
cb8e9e
cb8e9e
diff --git a/xlators/cluster/ec/src/ec-combine.c b/xlators/cluster/ec/src/ec-combine.c
cb8e9e
index bf698d9..d55e42a 100644
cb8e9e
--- a/xlators/cluster/ec/src/ec-combine.c
cb8e9e
+++ b/xlators/cluster/ec/src/ec-combine.c
cb8e9e
@@ -131,6 +131,15 @@ ec_iatt_is_trusted(ec_fop_data_t *fop, struct iatt *iatt)
cb8e9e
         fop = fop->parent;
cb8e9e
     }
cb8e9e
 
cb8e9e
+    /* Lookups are special requests always done without locks taken but they
cb8e9e
+     * require to be able to identify differences between bricks. Special
cb8e9e
+     * handling of these differences is already done in lookup specific code
cb8e9e
+     * so we shouldn't ignore any difference here and consider all iatt
cb8e9e
+     * structures as trusted. */
cb8e9e
+    if (fop->id == GF_FOP_LOOKUP) {
cb8e9e
+        return _gf_true;
cb8e9e
+    }
cb8e9e
+
cb8e9e
     /* Check if the iatt references an inode locked by the current fop */
cb8e9e
     for (i = 0; i < fop->lock_count; i++) {
cb8e9e
         ino = gfid_to_ino(fop->locks[i].lock->loc.inode->gfid);
cb8e9e
@@ -168,15 +177,20 @@ int32_t ec_iatt_combine(ec_fop_data_t *fop, struct iatt *dst, struct iatt *src,
cb8e9e
                          (dst[i].ia_size != src[i].ia_size)) ||
cb8e9e
                         (st_mode_from_ia(dst[i].ia_prot, dst[i].ia_type) !=
cb8e9e
                          st_mode_from_ia(src[i].ia_prot, src[i].ia_type)))) {
cb8e9e
-            if (!ec_iatt_is_trusted(fop, dst)) {
cb8e9e
-                /* If the iatt contains information from an inode that is not
cb8e9e
-                 * locked, we ignore these differences and don't care which
cb8e9e
+            if (ec_iatt_is_trusted(fop, dst)) {
cb8e9e
+                /* If the iatt contains information from an inode that is
cb8e9e
+                 * locked, these differences are real problems, so we need to
cb8e9e
+                 * report them. Otherwise we ignore them and don't care which
cb8e9e
                  * data is returned. */
cb8e9e
-                failed = _gf_false;
cb8e9e
+                failed = _gf_true;
cb8e9e
+            } else {
cb8e9e
+                gf_log(fop->xl->name, GF_LOG_DEBUG,
cb8e9e
+                       "Ignoring iatt differences because inode is not "
cb8e9e
+                       "locked");
cb8e9e
             }
cb8e9e
         }
cb8e9e
         if (failed) {
cb8e9e
-            gf_log(THIS->name, GF_LOG_WARNING,
cb8e9e
+            gf_log(fop->xl->name, GF_LOG_WARNING,
cb8e9e
                    "Failed to combine iatt (inode: %lu-%lu, links: %u-%u, "
cb8e9e
                    "uid: %u-%u, gid: %u-%u, rdev: %lu-%lu, size: %lu-%lu, "
cb8e9e
                    "mode: %o-%o)",
cb8e9e
-- 
cb8e9e
1.7.1
cb8e9e