libglusterfs/common-utils.c: Fix buffer size for checksum computation
Problem: When quorum count option is updated, the change is not reflected in the nfs-server.vol file. This is because in get_checksum_for_file(), when the last part of the file read has size less than buffer size, the read buffer stores old data value along with correct data value. Solution: Pass the bytes read instead of fixed buffer size, for calculating checksum. Change-Id: I4b641607c8a262961b3f3da0028a54e08c3f8589 fixes: bz#1657744 Signed-off-by: Varsha Rao <varao@redhat.com>
This commit is contained in:
parent
8c1eda9b5a
commit
5a152a7a70
@ -1972,7 +1972,7 @@ gf_unlockfd(int fd)
|
||||
}
|
||||
|
||||
static void
|
||||
compute_checksum(char *buf, size_t size, uint32_t *checksum)
|
||||
compute_checksum(char *buf, const ssize_t size, uint32_t *checksum)
|
||||
{
|
||||
int ret = -1;
|
||||
char *checksum_buf = NULL;
|
||||
@ -2015,7 +2015,7 @@ get_checksum_for_file(int fd, uint32_t *checksum)
|
||||
do {
|
||||
ret = sys_read(fd, &buf, GF_CHECKSUM_BUF_SIZE);
|
||||
if (ret > 0)
|
||||
compute_checksum(buf, GF_CHECKSUM_BUF_SIZE, checksum);
|
||||
compute_checksum(buf, ret, checksum);
|
||||
} while (ret > 0);
|
||||
|
||||
/* set it back */
|
||||
|
35
tests/bugs/glusterd/quorum-value-check.t
Executable file
35
tests/bugs/glusterd/quorum-value-check.t
Executable file
@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
|
||||
. $(dirname $0)/../../include.rc
|
||||
. $(dirname $0)/../../volume.rc
|
||||
|
||||
function check_quorum_nfs() {
|
||||
local qnfs="$(less /var/lib/glusterd/nfs/nfs-server.vol | grep "quorum-count"| awk '{print $3}')"
|
||||
local qinfo="$($CLI volume info $V0| grep "cluster.quorum-count"| awk '{print $2}')"
|
||||
|
||||
if [ $qnfs = $qinfo ]; then
|
||||
echo "Y"
|
||||
else
|
||||
echo "N"
|
||||
fi
|
||||
}
|
||||
|
||||
cleanup;
|
||||
|
||||
TEST glusterd
|
||||
TEST pidof glusterd
|
||||
TEST $CLI volume create $V0 replica 3 $H0:$B0/${V0}{0,1,2}
|
||||
TEST $CLI volume set $V0 nfs.disable off
|
||||
TEST $CLI volume set $V0 performance.write-behind off
|
||||
TEST $CLI volume set $V0 cluster.self-heal-daemon off
|
||||
TEST $CLI volume set $V0 cluster.quorum-type fixed
|
||||
TEST $CLI volume start $V0
|
||||
|
||||
TEST $CLI volume set $V0 cluster.quorum-count 1
|
||||
EXPECT_WITHIN $CONFIG_UPDATE_TIMEOUT "Y" check_quorum_nfs
|
||||
TEST $CLI volume set $V0 cluster.quorum-count 2
|
||||
EXPECT_WITHIN $CONFIG_UPDATE_TIMEOUT "Y" check_quorum_nfs
|
||||
TEST $CLI volume set $V0 cluster.quorum-count 3
|
||||
EXPECT_WITHIN $CONFIG_UPDATE_TIMEOUT "Y" check_quorum_nfs
|
||||
|
||||
cleanup;
|
Loading…
x
Reference in New Issue
Block a user