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#1684029 > Change-Id: I1508f000e8c9895588b6011b8b6cc0eda7102193 > BUG: bz#1685120 > Signed-off-by: Sanju Rakonde <srakonde@redhat.com> > (cherry picked from commit 073444b693b7a91c42963512e0fdafb57ad46670) Change-Id: I1508f000e8c9895588b6011b8b6cc0eda7102193
This commit is contained in:
parent
9c441360ac
commit
7964a320f3
@ -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_5_4)
|
||||
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)
|
||||
|
@ -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 *
|
||||
|
@ -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_VERSION_6_0 60000 /* Op-version for GlusterFS 6.0 */
|
||||
|
||||
#define GD_OP_VER_PERSISTENT_AFR_XATTRS GD_OP_VERSION_3_6_0
|
||||
|
@ -2806,7 +2806,7 @@ glusterd_volume_compute_cksum(glusterd_volinfo_t *volinfo, char *cksum_path,
|
||||
|
||||
cksum_path_final = is_quota_conf ? filepath : sort_filepath;
|
||||
|
||||
ret = get_checksum_for_path(cksum_path_final, &cksum);
|
||||
ret = get_checksum_for_path(cksum_path_final, &cksum, priv->op_version);
|
||||
if (ret) {
|
||||
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_CKSUM_GET_FAIL,
|
||||
"unable to get "
|
||||
@ -2823,7 +2823,7 @@ glusterd_volume_compute_cksum(glusterd_volinfo_t *volinfo, char *cksum_path,
|
||||
}
|
||||
}
|
||||
|
||||
ret = get_checksum_for_file(fd, &cksum);
|
||||
ret = get_checksum_for_file(fd, &cksum, priv->op_version);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
@ -9383,12 +9383,16 @@ glusterd_check_files_identical(char *filename1, char *filename2,
|
||||
uint32_t cksum1 = 0;
|
||||
uint32_t cksum2 = 0;
|
||||
xlator_t *this = NULL;
|
||||
glusterd_conf_t *priv = NULL;
|
||||
|
||||
GF_ASSERT(filename1);
|
||||
GF_ASSERT(filename2);
|
||||
GF_ASSERT(identical);
|
||||
|
||||
this = THIS;
|
||||
GF_VALIDATE_OR_GOTO("glusterd", this, out);
|
||||
priv = this->private;
|
||||
GF_VALIDATE_OR_GOTO(this->name, priv, out);
|
||||
|
||||
ret = sys_stat(filename1, &buf1);
|
||||
|
||||
@ -9415,11 +9419,11 @@ glusterd_check_files_identical(char *filename1, char *filename2,
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = get_checksum_for_path(filename1, &cksum1);
|
||||
ret = get_checksum_for_path(filename1, &cksum1, priv->op_version);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
ret = get_checksum_for_path(filename2, &cksum2);
|
||||
ret = get_checksum_for_path(filename2, &cksum2, priv->op_version);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user