f338ef
From 7c2d6e82d7d3430ad8a557b6ae726765f7e874e9 Mon Sep 17 00:00:00 2001
f338ef
From: Kinglong Mee <kinglongmee@gmail.com>
f338ef
Date: Fri, 12 Apr 2019 11:35:55 +0800
f338ef
Subject: [PATCH 269/276] ec: fix truncate lock to cover the write in tuncate
f338ef
 clean
f338ef
f338ef
ec_truncate_clean does writing under the lock granted for truncate,
f338ef
but the lock is calculated by ec_adjust_offset_up, so that,
f338ef
the write in ec_truncate_clean is out of lock.
f338ef
f338ef
fixes: bz#1732770
f338ef
Upstream-patch: https://review.gluster.org/c/glusterfs/+/22552
f338ef
Change-Id: Idbe1fd48d26afe49c36b77db9f12e0907f5a4134
f338ef
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
f338ef
Reviewed-on: https://code.engineering.redhat.com/gerrit/177973
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-inode-write.c | 8 ++++++--
f338ef
 1 file changed, 6 insertions(+), 2 deletions(-)
f338ef
f338ef
diff --git a/xlators/cluster/ec/src/ec-inode-write.c b/xlators/cluster/ec/src/ec-inode-write.c
f338ef
index a903664..ea55140 100644
f338ef
--- a/xlators/cluster/ec/src/ec-inode-write.c
f338ef
+++ b/xlators/cluster/ec/src/ec-inode-write.c
f338ef
@@ -1405,6 +1405,7 @@ int32_t
f338ef
 ec_manager_truncate(ec_fop_data_t *fop, int32_t state)
f338ef
 {
f338ef
     ec_cbk_data_t *cbk;
f338ef
+    off_t offset_down;
f338ef
 
f338ef
     switch (state) {
f338ef
         case EC_STATE_INIT:
f338ef
@@ -1416,16 +1417,19 @@ ec_manager_truncate(ec_fop_data_t *fop, int32_t state)
f338ef
             /* Fall through */
f338ef
 
f338ef
         case EC_STATE_LOCK:
f338ef
+            offset_down = fop->user_size;
f338ef
+            ec_adjust_offset_down(fop->xl->private, &offset_down, _gf_true);
f338ef
+
f338ef
             if (fop->id == GF_FOP_TRUNCATE) {
f338ef
                 ec_lock_prepare_inode(
f338ef
                     fop, &fop->loc[0],
f338ef
                     EC_UPDATE_DATA | EC_UPDATE_META | EC_QUERY_INFO,
f338ef
-                    fop->offset, EC_RANGE_FULL);
f338ef
+                    offset_down, EC_RANGE_FULL);
f338ef
             } else {
f338ef
                 ec_lock_prepare_fd(
f338ef
                     fop, fop->fd,
f338ef
                     EC_UPDATE_DATA | EC_UPDATE_META | EC_QUERY_INFO,
f338ef
-                    fop->offset, EC_RANGE_FULL);
f338ef
+                    offset_down, EC_RANGE_FULL);
f338ef
             }
f338ef
             ec_lock(fop);
f338ef
 
f338ef
-- 
f338ef
1.8.3.1
f338ef