Blob Blame History Raw
From e41916c72748a0997dbdd56e2f33525322944ac5 Mon Sep 17 00:00:00 2001
From: Xavier Hernandez <xhernandez@datalab.es>
Date: Sun, 31 May 2015 19:53:41 +0200
Subject: [PATCH 171/190] cluster/ec: Fix incorrect check for iatt differences

A previous patch (http://review.gluster.org/10974) introduced a
bug that caused that some metadata differences could not be
detected in some circumstances. This could cause that self-heal
is not triggered and the file not repaired.

We also need to consider all differences for lookup requests, even
if there isn't any lock. Special handling of differences in lookup
is already done in lookup specific code.

Backporting patch http://review.gluster.org/#/c/11018/

cherry-pick of commit 29d5bd5fc8a7b24865801de9f2e3f10d55af6e85
>Change-Id: I3766b0f412b3201ae8a04664349578713572edc6
>BUG: 1225793
>Signed-off-by: Xavier Hernandez <xhernandez@datalab.es>
>Reviewed-on: http://review.gluster.org/11018
>Tested-by: Gluster Build System <jenkins@build.gluster.com>
>Tested-by: NetBSD Build System <jenkins@build.gluster.org>
>Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>

Change-Id: I3766b0f412b3201ae8a04664349578713572edc6
BUG: 1226149
Signed-off-by: Nandaja Varma <nvarma@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/51747
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
---
 xlators/cluster/ec/src/ec-combine.c |   24 +++++++++++++++++++-----
 1 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/xlators/cluster/ec/src/ec-combine.c b/xlators/cluster/ec/src/ec-combine.c
index bf698d9..d55e42a 100644
--- a/xlators/cluster/ec/src/ec-combine.c
+++ b/xlators/cluster/ec/src/ec-combine.c
@@ -131,6 +131,15 @@ ec_iatt_is_trusted(ec_fop_data_t *fop, struct iatt *iatt)
         fop = fop->parent;
     }
 
+    /* Lookups are special requests always done without locks taken but they
+     * require to be able to identify differences between bricks. Special
+     * handling of these differences is already done in lookup specific code
+     * so we shouldn't ignore any difference here and consider all iatt
+     * structures as trusted. */
+    if (fop->id == GF_FOP_LOOKUP) {
+        return _gf_true;
+    }
+
     /* Check if the iatt references an inode locked by the current fop */
     for (i = 0; i < fop->lock_count; i++) {
         ino = gfid_to_ino(fop->locks[i].lock->loc.inode->gfid);
@@ -168,15 +177,20 @@ int32_t ec_iatt_combine(ec_fop_data_t *fop, struct iatt *dst, struct iatt *src,
                          (dst[i].ia_size != src[i].ia_size)) ||
                         (st_mode_from_ia(dst[i].ia_prot, dst[i].ia_type) !=
                          st_mode_from_ia(src[i].ia_prot, src[i].ia_type)))) {
-            if (!ec_iatt_is_trusted(fop, dst)) {
-                /* If the iatt contains information from an inode that is not
-                 * locked, we ignore these differences and don't care which
+            if (ec_iatt_is_trusted(fop, dst)) {
+                /* If the iatt contains information from an inode that is
+                 * locked, these differences are real problems, so we need to
+                 * report them. Otherwise we ignore them and don't care which
                  * data is returned. */
-                failed = _gf_false;
+                failed = _gf_true;
+            } else {
+                gf_log(fop->xl->name, GF_LOG_DEBUG,
+                       "Ignoring iatt differences because inode is not "
+                       "locked");
             }
         }
         if (failed) {
-            gf_log(THIS->name, GF_LOG_WARNING,
+            gf_log(fop->xl->name, GF_LOG_WARNING,
                    "Failed to combine iatt (inode: %lu-%lu, links: %u-%u, "
                    "uid: %u-%u, gid: %u-%u, rdev: %lu-%lu, size: %lu-%lu, "
                    "mode: %o-%o)",
-- 
1.7.1