14f8ab
From ac5b1b38e705bd0e4c00cc50580a71dfaa4d3b5f Mon Sep 17 00:00:00 2001
14f8ab
From: Krutika Dhananjay <kdhananj@redhat.com>
14f8ab
Date: Wed, 7 Aug 2019 12:12:43 +0530
14f8ab
Subject: [PATCH 375/375] features/shard: Send correct size when reads are sent
14f8ab
 beyond file size
14f8ab
14f8ab
Backport of:
14f8ab
> https://review.gluster.org/c/glusterfs/+/23175
14f8ab
> Change-Id: I0cebaaf55c09eb1fb77a274268ff564e871b743b
14f8ab
> fixes bz#1738419
14f8ab
> Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
14f8ab
14f8ab
Change-Id: I0cebaaf55c09eb1fb77a274268ff564e871b743b
14f8ab
BUG: 1802013
14f8ab
Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
14f8ab
Reviewed-on: https://code.engineering.redhat.com/gerrit/199570
14f8ab
Tested-by: RHGS Build Bot <nigelb@redhat.com>
14f8ab
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
14f8ab
---
14f8ab
 tests/bugs/shard/bug-1738419.t     | 29 +++++++++++++++++++++++++++++
14f8ab
 xlators/features/shard/src/shard.c |  2 ++
14f8ab
 2 files changed, 31 insertions(+)
14f8ab
 create mode 100644 tests/bugs/shard/bug-1738419.t
14f8ab
14f8ab
diff --git a/tests/bugs/shard/bug-1738419.t b/tests/bugs/shard/bug-1738419.t
14f8ab
new file mode 100644
14f8ab
index 0000000..8d0a31d
14f8ab
--- /dev/null
14f8ab
+++ b/tests/bugs/shard/bug-1738419.t
14f8ab
@@ -0,0 +1,29 @@
14f8ab
+#!/bin/bash
14f8ab
+
14f8ab
+. $(dirname $0)/../../include.rc
14f8ab
+. $(dirname $0)/../../volume.rc
14f8ab
+
14f8ab
+cleanup
14f8ab
+
14f8ab
+TEST glusterd
14f8ab
+TEST pidof glusterd
14f8ab
+TEST $CLI volume create $V0 replica 3 $H0:$B0/${V0}{0,1,2}
14f8ab
+TEST $CLI volume set $V0 features.shard on
14f8ab
+TEST $CLI volume set $V0 network.remote-dio off
14f8ab
+TEST $CLI volume set $V0 performance.io-cache off
14f8ab
+TEST $CLI volume set $V0 performance.quick-read off
14f8ab
+TEST $CLI volume set $V0 performance.read-ahead off
14f8ab
+TEST $CLI volume set $V0 performance.strict-o-direct on
14f8ab
+TEST $CLI volume start $V0
14f8ab
+
14f8ab
+TEST $GFS --volfile-id=$V0 --volfile-server=$H0 $M0
14f8ab
+
14f8ab
+TEST dd if=/dev/zero of=$M0/metadata bs=501 count=1
14f8ab
+
14f8ab
+EXPECT "501" echo $("dd" if=$M0/metadata bs=4096 count=1 of=/dev/null iflag=direct 2>&1 | awk '/bytes/ {print $1}')
14f8ab
+
14f8ab
+EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
14f8ab
+TEST $CLI volume stop $V0
14f8ab
+TEST $CLI volume delete $V0
14f8ab
+
14f8ab
+cleanup
14f8ab
diff --git a/xlators/features/shard/src/shard.c b/xlators/features/shard/src/shard.c
14f8ab
index b224abd..9ed597b 100644
14f8ab
--- a/xlators/features/shard/src/shard.c
14f8ab
+++ b/xlators/features/shard/src/shard.c
14f8ab
@@ -4433,6 +4433,8 @@ out:
14f8ab
       if (xdata)
14f8ab
         local->xattr_rsp = dict_ref(xdata);
14f8ab
       vec.iov_base = local->iobuf->ptr;
14f8ab
+      if (local->offset + local->req_size > local->prebuf.ia_size)
14f8ab
+          local->total_size = local->prebuf.ia_size - local->offset;
14f8ab
       vec.iov_len = local->total_size;
14f8ab
       local->op_ret = local->total_size;
14f8ab
       SHARD_STACK_UNWIND(readv, frame, local->op_ret, local->op_errno, &vec, 1,
14f8ab
-- 
14f8ab
1.8.3.1
14f8ab