diff options
author | Ravishankar N <ravishankar@redhat.com> | 2017-12-11 16:14:03 +0530 |
---|---|---|
committer | Ravishankar N <ravishankar@redhat.com> | 2017-12-19 04:35:57 +0000 |
commit | 0ca374178e95baaa9dbfc516263520e9a5526464 (patch) | |
tree | d616487a0dcbf35c72c07a894ba26cd57ec409bd | |
parent | 0679490c0414646d781f96020f8e85b7a8c3c828 (diff) |
feature/bitrot: remove internal xattrs from lookup cbk
Problem:
afr requests all xattrs in lookup via the list-xattr key. If bitrot is
enabled and later disabled, or if the bitrot xattrs were present due to
an older version of bitrot which used to create the xattrs without
enabling the feature, the xattrs (trusted.bit-rot.version in particular)
was not getting filtered and ended up reaching the client stack. AFR, on
noticing different values of the xattr across bricks of the replica,
started triggering spurious metadata heals.
Fix:
Filter all internal xattrs in bitrot xlator before unwinding lookup,
(f)getxattr.
Thanks to Kotresh for the help in RCA'ing.
Change-Id: I5bc70e4b901359c3daefc67b8e4fa6ddb47f046c
BUG: 1527275
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
(cherry picked from commit d341f20230b9921391aff22337eaf9be82f44d88)
-rw-r--r-- | xlators/features/bit-rot/src/stub/bit-rot-stub.c | 23 | ||||
-rw-r--r-- | xlators/features/bit-rot/src/stub/bit-rot-stub.h | 5 |
2 files changed, 21 insertions, 7 deletions
diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub.c b/xlators/features/bit-rot/src/stub/bit-rot-stub.c index 10a1d81a6fa..af95681f145 100644 --- a/xlators/features/bit-rot/src/stub/bit-rot-stub.c +++ b/xlators/features/bit-rot/src/stub/bit-rot-stub.c @@ -1585,6 +1585,7 @@ br_stub_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t ret = 0; size_t totallen = 0; size_t signaturelen = 0; + br_stub_private_t *priv = NULL; br_version_t *obuf = NULL; br_signature_t *sbuf = NULL; br_isignature_out_t *sign = NULL; @@ -1592,9 +1593,15 @@ br_stub_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, br_stub_local_t *local = NULL; inode_t *inode = NULL; gf_boolean_t bad_object = _gf_false; + gf_boolean_t ver_enabled = _gf_false; + + BR_STUB_VER_ENABLED_IN_CALLPATH(frame, ver_enabled); + priv = this->private; if (op_ret < 0) goto unwind; + BR_STUB_VER_COND_GOTO (priv, (!ver_enabled), delkeys); + if (cookie != (void *) BR_STUB_REQUEST_COOKIE) goto unwind; @@ -1740,8 +1747,7 @@ br_stub_getxattr (call_frame_t *frame, xlator_t *this, goto unwind; priv = this->private; - if (!priv->do_versioning) - goto wind; + BR_STUB_VER_NOT_ACTIVE_THEN_GOTO (frame, priv, wind); /** * If xattr is node-uuid and the inode is marked bad, return EIO. @@ -1762,6 +1768,7 @@ br_stub_getxattr (call_frame_t *frame, xlator_t *this, strlen (GLUSTERFS_GET_BR_STUB_INIT_TIME)) == 0) && ((gf_uuid_compare (loc->gfid, rootgfid) == 0) || (gf_uuid_compare (loc->inode->gfid, rootgfid) == 0))) { + BR_STUB_RESET_LOCAL_NULL (frame); br_stub_send_stub_init_time (frame, this); return 0; } @@ -1792,6 +1799,7 @@ br_stub_getxattr (call_frame_t *frame, xlator_t *this, FIRST_CHILD (this)->fops->getxattr, loc, name, xdata); return 0; unwind: + BR_STUB_RESET_LOCAL_NULL (frame); STACK_UNWIND_STRICT (getxattr, frame, op_ret, op_errno, NULL, NULL); return 0; } @@ -1809,6 +1817,7 @@ br_stub_fgetxattr (call_frame_t *frame, xlator_t *this, br_stub_private_t *priv = NULL; rootgfid[15] = 1; + priv = this->private; if (!name) { cbk = br_stub_listxattr_cbk; @@ -1818,9 +1827,7 @@ br_stub_fgetxattr (call_frame_t *frame, xlator_t *this, if (br_stub_is_internal_xattr (name)) goto unwind; - priv = this->private; - if (!priv->do_versioning) - goto wind; + BR_STUB_VER_NOT_ACTIVE_THEN_GOTO (frame, priv, wind); /** * If xattr is node-uuid and the inode is marked bad, return EIO. @@ -1840,6 +1847,7 @@ br_stub_fgetxattr (call_frame_t *frame, xlator_t *this, && (strncmp (name, GLUSTERFS_GET_BR_STUB_INIT_TIME, strlen (GLUSTERFS_GET_BR_STUB_INIT_TIME)) == 0) && (gf_uuid_compare (fd->inode->gfid, rootgfid) == 0)) { + BR_STUB_RESET_LOCAL_NULL (frame); br_stub_send_stub_init_time (frame, this); return 0; } @@ -1870,6 +1878,7 @@ br_stub_fgetxattr (call_frame_t *frame, xlator_t *this, FIRST_CHILD (this)->fops->fgetxattr, fd, name, xdata); return 0; unwind: + BR_STUB_RESET_LOCAL_NULL (frame); STACK_UNWIND_STRICT (fgetxattr, frame, op_ret, op_errno, NULL, NULL); return 0; } @@ -2867,13 +2876,14 @@ br_stub_lookup_cbk (call_frame_t *frame, void *cookie, BR_STUB_VER_ENABLED_IN_CALLPATH(frame, ver_enabled); priv = this->private; - BR_STUB_VER_COND_GOTO (priv, (!ver_enabled), unwind); if (op_ret < 0) { (void) br_stub_handle_lookup_error (this, inode, op_errno); goto unwind; } + BR_STUB_VER_COND_GOTO (priv, (!ver_enabled), delkey); + if (!IA_ISREG (stbuf->ia_type)) goto unwind; @@ -2892,7 +2902,6 @@ br_stub_lookup_cbk (call_frame_t *frame, void *cookie, op_errno = EIO; goto unwind; } - goto delkey; } diff --git a/xlators/features/bit-rot/src/stub/bit-rot-stub.h b/xlators/features/bit-rot/src/stub/bit-rot-stub.h index d8c8b6beb9e..737990aa56d 100644 --- a/xlators/features/bit-rot/src/stub/bit-rot-stub.h +++ b/xlators/features/bit-rot/src/stub/bit-rot-stub.h @@ -57,6 +57,11 @@ frame->local = NULL; \ } while (0) +#define BR_STUB_RESET_LOCAL_NULL(frame) do { \ + if (frame->local == (void *)0x1) \ + frame->local = NULL; \ + } while (0) + typedef int (br_stub_version_cbk) (call_frame_t *, void *, xlator_t *, int32_t, int32_t, dict_t *); |