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