Blob Blame History Raw
From 609555c6610ff61cdf435053cc2186481e677b74 Mon Sep 17 00:00:00 2001
From: Pranith Kumar K <pkarampu@redhat.com>
Date: Wed, 4 Jan 2017 13:37:23 +0530
Subject: [PATCH 265/267] cluster/ec: Do lookup on an existing file in link

Problem:
In link fop lookup is happening on the new fop which doesn't exist so the iatt
ec serves parent xlators has size as zero which leads to 'cat' giving empty output

Fix:
Change code so that lookup happens on the existing link instead.

 >BUG: 1409730
 >Change-Id: I70eb02fe0633e61d1d110575589cc2dbe5235d76
 >Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
 >Reviewed-on: http://review.gluster.org/16320
 >Smoke: Gluster Build System <jenkins@build.gluster.org>
 >Reviewed-by: Xavier Hernandez <xhernandez@datalab.es>
 >Tested-by: Xavier Hernandez <xhernandez@datalab.es>
 >CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
 >NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>

BUG: 1408836
Change-Id: I7761048197f8196d5b9db21cf119fe819abd4e8a
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/94322
---
 xlators/cluster/ec/src/ec-common.c    |  7 ++++---
 xlators/cluster/ec/src/ec-common.h    |  2 +-
 xlators/cluster/ec/src/ec-dir-write.c | 26 +++++++++++++-------------
 3 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c
index 6688ac1..c068cc3 100644
--- a/xlators/cluster/ec/src/ec-common.c
+++ b/xlators/cluster/ec/src/ec-common.c
@@ -788,10 +788,10 @@ void ec_lock_prepare_inode(ec_fop_data_t *fop, loc_t *loc, uint32_t flags)
     ec_lock_prepare_inode_internal(fop, loc, flags, NULL);
 }
 
-void ec_lock_prepare_parent_inode(ec_fop_data_t *fop, loc_t *loc,
+void ec_lock_prepare_parent_inode(ec_fop_data_t *fop, loc_t *loc, loc_t *base,
                                   uint32_t flags)
 {
-    loc_t tmp, *base = NULL;
+    loc_t tmp;
     int32_t err;
 
     if (fop->error != 0) {
@@ -806,8 +806,9 @@ void ec_lock_prepare_parent_inode(ec_fop_data_t *fop, loc_t *loc,
     }
 
     if ((flags & EC_INODE_SIZE) != 0) {
-        base = loc;
         flags ^= EC_INODE_SIZE;
+    } else {
+            base = NULL;
     }
 
     ec_lock_prepare_inode_internal(fop, &tmp, flags, base);
diff --git a/xlators/cluster/ec/src/ec-common.h b/xlators/cluster/ec/src/ec-common.h
index 5851b5d..e3fc3ce 100644
--- a/xlators/cluster/ec/src/ec-common.h
+++ b/xlators/cluster/ec/src/ec-common.h
@@ -90,7 +90,7 @@ gf_boolean_t
 ec_cbk_set_error(ec_cbk_data_t *cbk, int32_t error, gf_boolean_t ro);
 
 void ec_lock_prepare_inode(ec_fop_data_t *fop, loc_t *loc, uint32_t flags);
-void ec_lock_prepare_parent_inode(ec_fop_data_t *fop, loc_t *loc,
+void ec_lock_prepare_parent_inode(ec_fop_data_t *fop, loc_t *loc, loc_t *base,
                                   uint32_t flags);
 void ec_lock_prepare_fd(ec_fop_data_t *fop, fd_t *fd, uint32_t flags);
 void ec_lock(ec_fop_data_t * fop);
diff --git a/xlators/cluster/ec/src/ec-dir-write.c b/xlators/cluster/ec/src/ec-dir-write.c
index e181170..e068d77 100644
--- a/xlators/cluster/ec/src/ec-dir-write.c
+++ b/xlators/cluster/ec/src/ec-dir-write.c
@@ -177,7 +177,7 @@ int32_t ec_manager_create(ec_fop_data_t * fop, int32_t state)
         /* Fall through */
 
         case EC_STATE_LOCK:
-            ec_lock_prepare_parent_inode(fop, &fop->loc[0],
+            ec_lock_prepare_parent_inode(fop, &fop->loc[0], NULL,
                                          EC_UPDATE_DATA | EC_UPDATE_META);
             ec_lock(fop);
 
@@ -355,9 +355,9 @@ int32_t ec_manager_link(ec_fop_data_t * fop, int32_t state)
     {
         case EC_STATE_INIT:
         case EC_STATE_LOCK:
-            ec_lock_prepare_parent_inode(fop, &fop->loc[1], EC_UPDATE_DATA |
-                                                            EC_UPDATE_META |
-                                                            EC_INODE_SIZE);
+            ec_lock_prepare_parent_inode(fop, &fop->loc[1], &fop->loc[0],
+                                         EC_UPDATE_DATA | EC_UPDATE_META |
+                                         EC_INODE_SIZE);
             ec_lock(fop);
 
             return EC_STATE_DISPATCH;
@@ -540,7 +540,7 @@ int32_t ec_manager_mkdir(ec_fop_data_t * fop, int32_t state)
         /* Fall through */
 
         case EC_STATE_LOCK:
-            ec_lock_prepare_parent_inode(fop, &fop->loc[0],
+            ec_lock_prepare_parent_inode(fop, &fop->loc[0], NULL,
                                          EC_UPDATE_DATA | EC_UPDATE_META);
             ec_lock(fop);
 
@@ -746,7 +746,7 @@ int32_t ec_manager_mknod(ec_fop_data_t * fop, int32_t state)
         /* Fall through */
 
         case EC_STATE_LOCK:
-            ec_lock_prepare_parent_inode(fop, &fop->loc[0],
+            ec_lock_prepare_parent_inode(fop, &fop->loc[0], NULL,
                                          EC_UPDATE_DATA | EC_UPDATE_META);
             ec_lock(fop);
 
@@ -905,10 +905,10 @@ int32_t ec_manager_rename(ec_fop_data_t * fop, int32_t state)
     {
         case EC_STATE_INIT:
         case EC_STATE_LOCK:
-            ec_lock_prepare_parent_inode(fop, &fop->loc[0], EC_UPDATE_DATA |
-                                                            EC_UPDATE_META |
-                                                            EC_INODE_SIZE);
-            ec_lock_prepare_parent_inode(fop, &fop->loc[1],
+            ec_lock_prepare_parent_inode(fop, &fop->loc[0], &fop->loc[0],
+                                         EC_UPDATE_DATA | EC_UPDATE_META |
+                                         EC_INODE_SIZE);
+            ec_lock_prepare_parent_inode(fop, &fop->loc[1], NULL,
                                          EC_UPDATE_DATA | EC_UPDATE_META);
             ec_lock(fop);
 
@@ -1067,7 +1067,7 @@ int32_t ec_manager_rmdir(ec_fop_data_t * fop, int32_t state)
     {
         case EC_STATE_INIT:
         case EC_STATE_LOCK:
-            ec_lock_prepare_parent_inode(fop, &fop->loc[0],
+            ec_lock_prepare_parent_inode(fop, &fop->loc[0], NULL,
                                          EC_UPDATE_DATA | EC_UPDATE_META);
             ec_lock(fop);
 
@@ -1213,7 +1213,7 @@ int32_t ec_manager_symlink(ec_fop_data_t * fop, int32_t state)
     {
         case EC_STATE_INIT:
         case EC_STATE_LOCK:
-            ec_lock_prepare_parent_inode(fop, &fop->loc[0],
+            ec_lock_prepare_parent_inode(fop, &fop->loc[0], NULL,
                                          EC_UPDATE_DATA | EC_UPDATE_META);
             ec_lock(fop);
 
@@ -1379,7 +1379,7 @@ int32_t ec_manager_unlink(ec_fop_data_t * fop, int32_t state)
     {
         case EC_STATE_INIT:
         case EC_STATE_LOCK:
-            ec_lock_prepare_parent_inode(fop, &fop->loc[0],
+            ec_lock_prepare_parent_inode(fop, &fop->loc[0], NULL,
                                          EC_UPDATE_DATA | EC_UPDATE_META);
             ec_lock(fop);
 
-- 
2.9.3