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