summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src
diff options
context:
space:
mode:
authorSanju Rakonde <srakonde@redhat.com>2019-03-04 16:53:01 +0530
committerAmar Tumballi <amarts@redhat.com>2019-03-07 05:01:04 +0000
commit073444b693b7a91c42963512e0fdafb57ad46670 (patch)
treed5f31d17d52c695502f71a62999ff432b81c8105 /libglusterfs/src
parent27f6375df009c8c4798b72aeafce79456007d21f (diff)
core: make compute_cksum function op_version compatible
Problem: commit 5a152a changed the mechansim of computing the checksum. In heterogeneous cluster, peers are running into rejected state because we have different cksum computation mechansims in upgraded and non-upgraded nodes. Solution: add a check for op-version so that all the nodes in the cluster follow the same mechanism for computing the cksum. Change-Id: I1508f000e8c9895588b6011b8b6cc0eda7102193 fixes: bz#1685120 Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
Diffstat (limited to 'libglusterfs/src')
-rw-r--r--libglusterfs/src/common-utils.c15
-rw-r--r--libglusterfs/src/glusterfs/common-utils.h4
2 files changed, 12 insertions, 7 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index 2a74d7bf239..e9237714498 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -49,6 +49,7 @@
#include "glusterfs/lkowner.h"
#include "glusterfs/syscall.h"
#include "cli1-xdr.h"
+#include "glusterfs/globals.h"
#define XXH_INLINE_ALL
#include "xxhash.h"
#include <ifaddrs.h>
@@ -2002,7 +2003,7 @@ compute_checksum(char *buf, const ssize_t size, uint32_t *checksum)
#define GF_CHECKSUM_BUF_SIZE 1024
int
-get_checksum_for_file(int fd, uint32_t *checksum)
+get_checksum_for_file(int fd, uint32_t *checksum, int op_version)
{
int ret = -1;
char buf[GF_CHECKSUM_BUF_SIZE] = {
@@ -2013,8 +2014,12 @@ get_checksum_for_file(int fd, uint32_t *checksum)
sys_lseek(fd, 0L, SEEK_SET);
do {
ret = sys_read(fd, &buf, GF_CHECKSUM_BUF_SIZE);
- if (ret > 0)
- compute_checksum(buf, ret, checksum);
+ if (ret > 0) {
+ if (op_version < GD_OP_VERSION_6_0)
+ compute_checksum(buf, GF_CHECKSUM_BUF_SIZE, checksum);
+ else
+ compute_checksum(buf, ret, checksum);
+ }
} while (ret > 0);
/* set it back */
@@ -2024,7 +2029,7 @@ get_checksum_for_file(int fd, uint32_t *checksum)
}
int
-get_checksum_for_path(char *path, uint32_t *checksum)
+get_checksum_for_path(char *path, uint32_t *checksum, int op_version)
{
int ret = -1;
int fd = -1;
@@ -2040,7 +2045,7 @@ get_checksum_for_path(char *path, uint32_t *checksum)
goto out;
}
- ret = get_checksum_for_file(fd, checksum);
+ ret = get_checksum_for_file(fd, checksum, op_version);
out:
if (fd != -1)
diff --git a/libglusterfs/src/glusterfs/common-utils.h b/libglusterfs/src/glusterfs/common-utils.h
index 1418c6531c7..0140f7b9fd5 100644
--- a/libglusterfs/src/glusterfs/common-utils.h
+++ b/libglusterfs/src/glusterfs/common-utils.h
@@ -833,12 +833,12 @@ int
gf_unlockfd(int fd);
int
-get_checksum_for_file(int fd, uint32_t *checksum);
+get_checksum_for_file(int fd, uint32_t *checksum, int op_version);
int
log_base2(unsigned long x);
int
-get_checksum_for_path(char *path, uint32_t *checksum);
+get_checksum_for_path(char *path, uint32_t *checksum, int op_version);
int
get_file_mtime(const char *path, time_t *stamp);
char *