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