From f2b7ba950de1a8a634aee3daa019819779acd4ff Mon Sep 17 00:00:00 2001
From: Kotresh HR <khiremat@redhat.com>
Date: Mon, 22 May 2017 08:47:07 -0400
Subject: [PATCH 474/486] features/bitrot: Fix glusterfsd crash
With object versioning being optional, it can
so happen the bitrot stub context is not always
set. When it's not found, it's initialized. But
was not being assigned to use in the local
function. This was leading for brick crash.
Fixed the same.
> Change-Id: I0dab6435cdfe16a8c7f6a31ffec1a370822597a8
> BUG: 1454317
> Signed-off-by: Kotresh HR <khiremat@redhat.com>
> Reviewed-on: https://review.gluster.org/17357
> Smoke: Gluster Build System <jenkins@build.gluster.org>
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
> Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
Change-Id: I0dab6435cdfe16a8c7f6a31ffec1a370822597a8
BUG: 1451280
Signed-off-by: Kotresh HR <khiremat@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/107534
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
xlators/features/bit-rot/src/stub/bit-rot-stub.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 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 115b10d..2f2a3d5 100644
--- a/xlators/features/bit-rot/src/stub/bit-rot-stub.c
+++ b/xlators/features/bit-rot/src/stub/bit-rot-stub.c
@@ -358,7 +358,7 @@ br_stub_prepare_signing_request (dict_t *dict,
static int
br_stub_init_inode_versions (xlator_t *this, fd_t *fd, inode_t *inode,
unsigned long version, gf_boolean_t markdirty,
- gf_boolean_t bad_object)
+ gf_boolean_t bad_object, uint64_t *ctx_addr)
{
int32_t ret = 0;
br_stub_inode_ctx_t *ctx = NULL;
@@ -385,6 +385,9 @@ br_stub_init_inode_versions (xlator_t *this, fd_t *fd, inode_t *inode,
ret = br_stub_set_inode_ctx (this, inode, ctx);
if (ret)
goto free_ctx;
+
+ if (ctx_addr)
+ *ctx_addr = (uint64_t) ctx;
return 0;
free_ctx:
@@ -483,7 +486,8 @@ br_stub_need_versioning (xlator_t *this,
ret = br_stub_get_inode_ctx (this, fd->inode, &ctx_addr);
if (ret < 0) {
ret = br_stub_init_inode_versions (this, fd, fd->inode, version,
- _gf_true, _gf_false);
+ _gf_true, _gf_false,
+ &ctx_addr);
if (ret) {
gf_msg (this->name, GF_LOG_ERROR, 0,
BRS_MSG_GET_INODE_CONTEXT_FAILED, "failed to "
@@ -581,7 +585,8 @@ br_stub_mark_inode_modified (xlator_t *this, br_stub_local_t *local)
ret = br_stub_get_inode_ctx (this, fd->inode, &ctx_addr);
if (ret < 0) {
ret = br_stub_init_inode_versions (this, fd, fd->inode, version,
- _gf_true, _gf_false);
+ _gf_true, _gf_false,
+ &ctx_addr);
if (ret)
goto error_return;
}
@@ -626,7 +631,7 @@ br_stub_check_bad_object (xlator_t *this, inode_t *inode, int32_t *op_ret,
if (ret == -1) {
ret = br_stub_init_inode_versions (this, NULL, inode, version,
- _gf_true, _gf_false);
+ _gf_true, _gf_false, NULL);
if (ret) {
gf_msg (this->name, GF_LOG_ERROR, 0,
BRS_MSG_GET_INODE_CONTEXT_FAILED,
@@ -2326,7 +2331,8 @@ br_stub_open (call_frame_t *frame, xlator_t *this,
ret = br_stub_get_inode_ctx (this, fd->inode, &ctx_addr);
if (ret) {
ret = br_stub_init_inode_versions (this, fd, fd->inode, version,
- _gf_true, _gf_false);
+ _gf_true, _gf_false,
+ &ctx_addr);
if (ret) {
gf_msg (this->name, GF_LOG_ERROR, 0,
BRS_MSG_GET_INODE_CONTEXT_FAILED,
@@ -2428,7 +2434,8 @@ br_stub_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
ret = br_stub_get_inode_ctx (this, fd->inode, &ctx_addr);
if (ret < 0) {
ret = br_stub_init_inode_versions (this, fd, inode, version,
- _gf_true, _gf_false);
+ _gf_true, _gf_false,
+ &ctx_addr);
if (ret) {
op_ret = -1;
op_errno = EINVAL;
@@ -2484,7 +2491,7 @@ br_stub_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
goto unwind;
ret = br_stub_init_inode_versions (this, NULL, inode, version,
- _gf_true, _gf_false);
+ _gf_true, _gf_false, NULL);
/**
* Like lookup, if init_inode_versions fail, return EINVAL
*/
@@ -2575,7 +2582,7 @@ br_stub_lookup_version (xlator_t *this,
return -1;
return br_stub_init_inode_versions (this, NULL, inode, version,
- _gf_true, bad_object);
+ _gf_true, bad_object, NULL);
}
--
1.8.3.1