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