From a00953ed212a7071b152c4afccd35b92fa5a682a Mon Sep 17 00:00:00 2001 From: Sanju Rakonde Date: Mon, 4 Mar 2019 16:53:01 +0530 Subject: 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. fixes: bz#1684569 > Change-Id: I1508f000e8c9895588b6011b8b6cc0eda7102193 > BUG: bz#1685120 > Signed-off-by: Sanju Rakonde Change-Id: I1508f000e8c9895588b6011b8b6cc0eda7102193 Signed-off-by: Sanju Rakonde --- libglusterfs/src/common-utils.c | 15 ++++++++++----- libglusterfs/src/common-utils.h | 4 ++-- libglusterfs/src/globals.h | 4 +++- 3 files changed, 15 insertions(+), 8 deletions(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index bd3be7cfe12..eefb5f159fe 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -49,6 +49,7 @@ #include "lkowner.h" #include "syscall.h" #include "cli1-xdr.h" +#include "globals.h" #define XXH_INLINE_ALL #include "xxhash.h" #include @@ -2020,7 +2021,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] = { @@ -2031,8 +2032,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_5_4) + compute_checksum(buf, GF_CHECKSUM_BUF_SIZE, checksum); + else + compute_checksum(buf, ret, checksum); + } } while (ret > 0); /* set it back */ @@ -2042,7 +2047,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; @@ -2058,7 +2063,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/common-utils.h b/libglusterfs/src/common-utils.h index 6a6fd8c9893..f623e770cc7 100644 --- a/libglusterfs/src/common-utils.h +++ b/libglusterfs/src/common-utils.h @@ -830,12 +830,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 * diff --git a/libglusterfs/src/globals.h b/libglusterfs/src/globals.h index c5595ca7d7d..fe18589ee20 100644 --- a/libglusterfs/src/globals.h +++ b/libglusterfs/src/globals.h @@ -45,7 +45,7 @@ 1 /* MIN is the fresh start op-version, mostly \ should not change */ #define GD_OP_VERSION_MAX \ - GD_OP_VERSION_5_0 /* MAX VERSION is the maximum \ + GD_OP_VERSION_5_4 /* MAX VERSION is the maximum \ count in VME table, should \ keep changing with \ introduction of newer \ @@ -111,6 +111,8 @@ #define GD_OP_VERSION_5_0 50000 /* Op-version for GlusterFS 5.0 */ +#define GD_OP_VERSION_5_4 50400 /* Op-version for GlusterFS 5.4 */ + #define GD_OP_VER_PERSISTENT_AFR_XATTRS GD_OP_VERSION_3_6_0 #include "xlator.h" -- cgit