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