diff options
author | Varsha Rao <varao@redhat.com> | 2019-02-04 16:32:26 +0530 |
---|---|---|
committer | Shyamsundar Ranganathan <srangana@redhat.com> | 2019-02-18 14:41:04 +0000 |
commit | 421b7071f5acee064faf02dc91bcc83efbaa6523 (patch) | |
tree | 1b3b39e39585d1b1ce3c9e73d8a1045af5c62a7d /libglusterfs/src/common-utils.c | |
parent | ea05e684e9a9d2ad7712631e88e6007f3ebc31e3 (diff) |
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#1672249
Signed-off-by: Varsha Rao <varao@redhat.com>
Diffstat (limited to 'libglusterfs/src/common-utils.c')
-rw-r--r-- | libglusterfs/src/common-utils.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index e2874602a84..70b90104b87 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -1874,7 +1874,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; @@ -1915,8 +1915,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 */ |