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