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