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