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