summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaghavendra Bhat <raghavendra@redhat.com>2018-11-29 12:04:45 -0500
committerKotresh HR <khiremat@redhat.com>2018-12-03 08:45:12 +0000
commitf77fb6d568616592ab25501c402c140d15235ca9 (patch)
treeb02ccf4c86402956a510bfc71cf7e1e0e684c8e3
parent4d58730c0cd6ab5db39aec8a15276f7bd3371b04 (diff)
features/bitrot: compare the signature with proper length
* The scrubber was comparing the checksum of the file that it calculated (by reading the file) with the on disk signature (stored via xattr) wrongly. It was using strlen to calculate the signature, while the actual length of the signature is given by the brick. Just use the actual length that the brick provides instead of trying to calculate the signature length via strlen API. * In posix, gfid2path was using the same string that contains the list of all the xattrs of file to save the value of the gfid2path xattr as well. This causes confusion when gfid2path xattr is queried by scrubber for getting the actual path of a corrupted file. Use separate string to fetch the value of the xattr instead of the string that contains the list of xattrs. Change-Id: I2d664ab524d2b312233476cb35863dde3122e9a9 fixes: bz#1654805 Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>
-rw-r--r--xlators/features/bit-rot/src/bitd/bit-rot-scrub.c4
-rw-r--r--xlators/storage/posix/src/posix-gfid-path.c18
2 files changed, 14 insertions, 8 deletions
diff --git a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c
index b856c16..63903b0 100644
--- a/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c
+++ b/xlators/features/bit-rot/src/bitd/bit-rot-scrub.c
@@ -130,6 +130,8 @@ bitd_scrub_post_compute_check(xlator_t *this, br_child_t *child, fd_t *fd,
(void)memcpy(*signature, signptr, sizeof(br_isignature_out_t) + signlen);
+ (*signature)->signaturelen = signlen;
+
unref_dict:
dict_unref(xattr);
out:
@@ -222,7 +224,7 @@ bitd_compare_ckum(xlator_t *this, br_isignature_out_t *sign, unsigned char *md,
GF_VALIDATE_OR_GOTO(this->name, md, out);
GF_VALIDATE_OR_GOTO(this->name, entry, out);
- if (strncmp(sign->signature, (char *)md, strlen(sign->signature)) == 0) {
+ if (strncmp(sign->signature, (char *)md, sign->signaturelen) == 0) {
gf_msg_debug(this->name, 0,
"%s [GFID: %s | Brick: %s] "
"matches calculated checksum",
diff --git a/xlators/storage/posix/src/posix-gfid-path.c b/xlators/storage/posix/src/posix-gfid-path.c
index 4a81be2..de8b4d7 100644
--- a/xlators/storage/posix/src/posix-gfid-path.c
+++ b/xlators/storage/posix/src/posix-gfid-path.c
@@ -128,9 +128,7 @@ posix_get_gfid2path(xlator_t *this, inode_t *inode, const char *real_path,
char keybuffer[4096] = {
0,
};
- char value_buf[8192] = {
- 0,
- };
+
uuid_t pargfid = {
0,
};
@@ -161,6 +159,12 @@ posix_get_gfid2path(xlator_t *this, inode_t *inode, const char *real_path,
}
found = _gf_true;
} else {
+ char value_buf[8192] = {
+ 0,
+ };
+ char xattr_value[8192] = {
+ 0,
+ };
have_val = _gf_false;
size = sys_llistxattr(real_path, value_buf, sizeof(value_buf) - 1);
if (size > 0) {
@@ -216,8 +220,8 @@ posix_get_gfid2path(xlator_t *this, inode_t *inode, const char *real_path,
}
found = _gf_true;
- size = sys_lgetxattr(real_path, keybuffer, value_buf,
- sizeof(value_buf) - 1);
+ size = sys_lgetxattr(real_path, keybuffer, xattr_value,
+ sizeof(xattr_value) - 1);
if (size == -1) {
ret = -1;
*op_errno = errno;
@@ -229,13 +233,13 @@ posix_get_gfid2path(xlator_t *this, inode_t *inode, const char *real_path,
}
/* Parse pargfid from xattr value*/
- strncpy(pargfid_str, value_buf, 36);
+ strncpy(pargfid_str, xattr_value, 36);
pargfid_str[36] = '\0';
gf_uuid_parse(pargfid_str, pargfid);
/* Convert pargfid to path */
ret = posix_resolve_dirgfid_to_path(pargfid, priv->base_path,
- &value_buf[37], &paths[i]);
+ &xattr_value[37], &paths[i]);
i++;
ignore: