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