cead9d
From 341d75642ecc4e27bc6fecb56eb98a0ba03d8544 Mon Sep 17 00:00:00 2001
cead9d
From: Krutika Dhananjay <kdhananj@redhat.com>
cead9d
Date: Mon, 23 Mar 2020 11:47:10 +0530
cead9d
Subject: [PATCH 376/379] features/shard: Fix crash during shards cleanup in
cead9d
 error cases
cead9d
cead9d
Backport of:
cead9d
> https://review.gluster.org/c/glusterfs/+/24244
cead9d
> Change-Id: I0b49f2b58becd0d8874b3d4b14ff8d92a89d02d5
cead9d
> Fixes: #1127
cead9d
> Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
cead9d
cead9d
A crash is seen during a reattempt to clean up shards in background
cead9d
upon remount. And this happens even on remount (which means a remount
cead9d
is no workaround for the crash).
cead9d
cead9d
In such a situation, the in-memory base inode object will not be
cead9d
existent (new process, non-existent base shard).
cead9d
So local->resolver_base_inode will be NULL.
cead9d
cead9d
In the event of an error (in this case, of space running out), the
cead9d
process would crash at the time of logging the error in the following line -
cead9d
cead9d
        gf_msg(this->name, GF_LOG_ERROR, local->op_errno, SHARD_MSG_FOP_FAILED,
cead9d
               "failed to delete shards of %s",
cead9d
               uuid_utoa(local->resolver_base_inode->gfid));
cead9d
cead9d
Fixed that by using local->base_gfid as the source of gfid when
cead9d
local->resolver_base_inode is NULL.
cead9d
cead9d
Change-Id: I0b49f2b58becd0d8874b3d4b14ff8d92a89d02d5
cead9d
BUG: 1836233
cead9d
Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
cead9d
Reviewed-on: https://code.engineering.redhat.com/gerrit/200689
cead9d
Tested-by: RHGS Build Bot <nigelb@redhat.com>
cead9d
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
cead9d
---
cead9d
 xlators/features/shard/src/shard.c | 11 +++++++++--
cead9d
 1 file changed, 9 insertions(+), 2 deletions(-)
cead9d
cead9d
diff --git a/xlators/features/shard/src/shard.c b/xlators/features/shard/src/shard.c
cead9d
index 9ed597b..ee38ed2 100644
cead9d
--- a/xlators/features/shard/src/shard.c
cead9d
+++ b/xlators/features/shard/src/shard.c
cead9d
@@ -2729,13 +2729,20 @@ int shard_unlink_shards_do(call_frame_t *frame, xlator_t *this, inode_t *inode);
cead9d
 int shard_post_lookup_shards_unlink_handler(call_frame_t *frame,
cead9d
                                             xlator_t *this) {
cead9d
   shard_local_t *local = NULL;
cead9d
+    uuid_t gfid = {
cead9d
+        0,
cead9d
+    };
cead9d
 
cead9d
   local = frame->local;
cead9d
 
cead9d
+    if (local->resolver_base_inode)
cead9d
+        gf_uuid_copy(gfid, local->resolver_base_inode->gfid);
cead9d
+    else
cead9d
+        gf_uuid_copy(gfid, local->base_gfid);
cead9d
+
cead9d
   if ((local->op_ret < 0) && (local->op_errno != ENOENT)) {
cead9d
     gf_msg(this->name, GF_LOG_ERROR, local->op_errno, SHARD_MSG_FOP_FAILED,
cead9d
-           "failed to delete shards of %s",
cead9d
-           uuid_utoa(local->resolver_base_inode->gfid));
cead9d
+           "failed to delete shards of %s", uuid_utoa(gfid));
cead9d
     return 0;
cead9d
   }
cead9d
   local->op_ret = 0;
cead9d
-- 
cead9d
1.8.3.1
cead9d