a3470f
From 5b28188f7a970ccea32d6ed65b75c38703f25045 Mon Sep 17 00:00:00 2001
a3470f
From: Sunil Kumar Acharya <sheggodu@redhat.com>
a3470f
Date: Wed, 22 Nov 2017 15:12:26 +0530
a3470f
Subject: [PATCH 149/180] cluster/ec: EC DISCARD doesn't punch hole properly
a3470f
a3470f
Problem:
a3470f
DISCARD operation on EC volume was punching hole of lesser
a3470f
size than the specified size in some cases.
a3470f
a3470f
Solution:
a3470f
EC was not handling punch hole for tail part in some cases.
a3470f
Updated the code to handle it appropriately.
a3470f
a3470f
>BUG: 1516206
a3470f
>Change-Id: If3e69e417c3e5034afee04e78f5f78855e65f932
a3470f
>Signed-off-by: Sunil Kumar Acharya <sheggodu@redhat.com>
a3470f
a3470f
Upstream patch: https://review.gluster.org/#/c/18838/
a3470f
a3470f
BUG: 1518260
a3470f
Change-Id: If3e69e417c3e5034afee04e78f5f78855e65f932
a3470f
Signed-off-by: Sunil Kumar Acharya <sheggodu@redhat.com>
a3470f
Reviewed-on: https://code.engineering.redhat.com/gerrit/124648
a3470f
Tested-by: RHGS Build Bot <nigelb@redhat.com>
a3470f
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
a3470f
---
a3470f
 tests/basic/ec/ec-discard.t             | 10 +++++++++-
a3470f
 xlators/cluster/ec/src/ec-inode-write.c |  6 ++++--
a3470f
 2 files changed, 13 insertions(+), 3 deletions(-)
a3470f
a3470f
diff --git a/tests/basic/ec/ec-discard.t b/tests/basic/ec/ec-discard.t
a3470f
index 4a44cec..001f449 100644
a3470f
--- a/tests/basic/ec/ec-discard.t
a3470f
+++ b/tests/basic/ec/ec-discard.t
a3470f
@@ -137,6 +137,15 @@ TEST md5_sum=`get_md5_sum $B0/test_file`
a3470f
 EXPECT $md5_sum get_md5_sum $M0/test_file
a3470f
 TEST rm -f $B0/test_file $M0/test_file
a3470f
 
a3470f
+#Offset and Size not at boundary covering a stripe
a3470f
+TEST dd if=/dev/urandom of=$B0/test_file bs=1024 count=8
a3470f
+TEST cp $B0/test_file $M0/test_file
a3470f
+TEST fallocate -p -o 1500 -l 3000 $B0/test_file
a3470f
+TEST fallocate -p -o 1500 -l 3000 $M0/test_file
a3470f
+TEST md5_sum=`get_md5_sum $B0/test_file`
a3470f
+EXPECT $md5_sum get_md5_sum $M0/test_file
a3470f
+TEST rm -f $B0/test_file $M0/test_file
a3470f
+
a3470f
 #Offset and Size not at boundary
a3470f
 TEST dd if=/dev/urandom of=$B0/test_file bs=1024 count=8
a3470f
 TEST cp $B0/test_file $M0/test_file
a3470f
@@ -144,7 +153,6 @@ TEST fallocate -p -o 1000 -l 3072 $B0/test_file
a3470f
 TEST fallocate -p -o 1000 -l 3072 $M0/test_file
a3470f
 TEST md5_sum=`get_md5_sum $B0/test_file`
a3470f
 EXPECT $md5_sum get_md5_sum $M0/test_file
a3470f
-#TEST rm -f $B0/test_file $M0/test_file
a3470f
 
a3470f
 #Data Corruption Tests
a3470f
 #Kill brick1 and brick2
a3470f
diff --git a/xlators/cluster/ec/src/ec-inode-write.c b/xlators/cluster/ec/src/ec-inode-write.c
a3470f
index ae51202..2c1165b 100644
a3470f
--- a/xlators/cluster/ec/src/ec-inode-write.c
a3470f
+++ b/xlators/cluster/ec/src/ec-inode-write.c
a3470f
@@ -1144,11 +1144,13 @@ void ec_update_discard_write(ec_fop_data_t *fop, uintptr_t mask)
a3470f
             error = ec_update_write (fop, mask, off_head, fop->user_size);
a3470f
     } else {
a3470f
             size_head = fop->int32;
a3470f
-            size_tail = (fop->user_size - fop->int32) % ec->stripe_size;
a3470f
+            size_tail = (off_head + fop->user_size) % ec->stripe_size;
a3470f
             off_tail = off_head + fop->user_size - size_tail;
a3470f
             if (size_head) {
a3470f
                     error = ec_update_write (fop, mask, off_head, size_head);
a3470f
-                    goto out;
a3470f
+                    if (error) {
a3470f
+                        goto out;
a3470f
+                    }
a3470f
             }
a3470f
             if (size_tail) {
a3470f
                     error = ec_update_write (fop, mask, off_tail, size_tail);
a3470f
-- 
a3470f
1.8.3.1
a3470f