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