diff options
author | Varsha Rao <varao@redhat.com> | 2019-01-09 15:10:37 +0530 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2019-01-11 07:42:56 +0000 |
commit | 5a152a7a70f771d951af713ab9701bcbc651e7e2 (patch) | |
tree | 7765dd46c87ac75dd19a3798b4df85f7580ea0f2 /libglusterfs | |
parent | 8c1eda9b5a19861be7e02f89cefae942c624d677 (diff) | |
download | glusterfs-5a152a7a70f771d951af713ab9701bcbc651e7e2.tar.gz glusterfs-5a152a7a70f771d951af713ab9701bcbc651e7e2.tar.xz glusterfs-5a152a7a70f771d951af713ab9701bcbc651e7e2.zip |
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>
Diffstat (limited to 'libglusterfs')
-rw-r--r-- | libglusterfs/src/common-utils.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index b6e4fbecf8..b8c3e2de12 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -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 */ |