233933
From 783f53b0b09845cd6c38f145eac685a094767ce0 Mon Sep 17 00:00:00 2001
233933
From: Pranith Kumar K <pkarampu@redhat.com>
233933
Date: Mon, 27 May 2019 11:43:26 +0530
233933
Subject: [PATCH 194/221] stack: Make sure to have unique call-stacks in all
233933
 cases
233933
233933
At the moment new stack doesn't populate frame->root->unique in all cases. This
233933
makes it difficult to debug hung frames by examining successive state dumps.
233933
Fuse and server xlators populate it whenever they can, but other xlators won't
233933
be able to assign 'unique' when they need to create a new frame/stack because
233933
they don't know what 'unique' fuse/server xlators already used. What we need is
233933
for unique to be correct. If a stack with same unique is present in successive
233933
statedumps, that means the same operation is still in progress. This makes
233933
'finding hung frames' part of debugging hung frames easier.
233933
233933
 >upstream: bz#1714098
233933
 >Upstream-patch: https://review.gluster.org/c/glusterfs/+/22773
233933
fixes bz#1716760
233933
Change-Id: I3e9a8f6b4111e260106c48a2ac3a41ef29361b9e
233933
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
233933
Reviewed-on: https://code.engineering.redhat.com/gerrit/172304
233933
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
233933
Tested-by: RHGS Build Bot <nigelb@redhat.com>
233933
---
233933
 libglusterfs/src/stack.c                     |  2 ++
233933
 xlators/features/quota/src/quotad-helpers.c  |  3 ---
233933
 xlators/mount/fuse/src/fuse-bridge.c         | 15 ++++++++-------
233933
 xlators/mount/fuse/src/fuse-helpers.c        |  1 -
233933
 xlators/protocol/server/src/server-helpers.c |  3 ---
233933
 5 files changed, 10 insertions(+), 14 deletions(-)
233933
233933
diff --git a/libglusterfs/src/stack.c b/libglusterfs/src/stack.c
233933
index 82b3577..371f60c 100644
233933
--- a/libglusterfs/src/stack.c
233933
+++ b/libglusterfs/src/stack.c
233933
@@ -17,6 +17,7 @@ create_frame(xlator_t *xl, call_pool_t *pool)
233933
 {
233933
     call_stack_t *stack = NULL;
233933
     call_frame_t *frame = NULL;
233933
+    static uint64_t unique = 0;
233933
 
233933
     if (!xl || !pool) {
233933
         return NULL;
233933
@@ -52,6 +53,7 @@ create_frame(xlator_t *xl, call_pool_t *pool)
233933
     {
233933
         list_add(&stack->all_frames, &pool->all_frames);
233933
         pool->cnt++;
233933
+        stack->unique = unique++;
233933
     }
233933
     UNLOCK(&pool->lock);
233933
     GF_ATOMIC_INC(pool->total_count);
233933
diff --git a/xlators/features/quota/src/quotad-helpers.c b/xlators/features/quota/src/quotad-helpers.c
233933
index be8f908..d9f0351 100644
233933
--- a/xlators/features/quota/src/quotad-helpers.c
233933
+++ b/xlators/features/quota/src/quotad-helpers.c
233933
@@ -73,7 +73,6 @@ quotad_aggregator_alloc_frame(rpcsvc_request_t *req)
233933
         goto out;
233933
 
233933
     frame->root->state = state;
233933
-    frame->root->unique = 0;
233933
 
233933
     frame->this = this;
233933
 out:
233933
@@ -93,8 +92,6 @@ quotad_aggregator_get_frame_from_req(rpcsvc_request_t *req)
233933
 
233933
     frame->root->op = req->procnum;
233933
 
233933
-    frame->root->unique = req->xid;
233933
-
233933
     frame->root->uid = req->uid;
233933
     frame->root->gid = req->gid;
233933
     frame->root->pid = req->pid;
233933
diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c
233933
index c3945d7..c05866b 100644
233933
--- a/xlators/mount/fuse/src/fuse-bridge.c
233933
+++ b/xlators/mount/fuse/src/fuse-bridge.c
233933
@@ -3270,11 +3270,11 @@ fuse_release(xlator_t *this, fuse_in_header_t *finh, void *msg,
233933
 
233933
     priv = this->private;
233933
 
233933
-    fuse_log_eh(this, "RELEASE(): %" PRIu64 ":, fd: %p, gfid: %s", finh->unique,
233933
-                fd, uuid_utoa(fd->inode->gfid));
233933
+    fuse_log_eh(this, "RELEASE(): finh->unique: %" PRIu64 ":, fd: %p, gfid: %s",
233933
+                finh->unique, fd, uuid_utoa(fd->inode->gfid));
233933
 
233933
-    gf_log("glusterfs-fuse", GF_LOG_TRACE, "%" PRIu64 ": RELEASE %p",
233933
-           finh->unique, state->fd);
233933
+    gf_log("glusterfs-fuse", GF_LOG_TRACE,
233933
+           "finh->unique: %" PRIu64 ": RELEASE %p", finh->unique, state->fd);
233933
 
233933
     fuse_fd_ctx_destroy(this, state->fd);
233933
     fd_unref(fd);
233933
@@ -3759,11 +3759,12 @@ fuse_releasedir(xlator_t *this, fuse_in_header_t *finh, void *msg,
233933
 
233933
     priv = this->private;
233933
 
233933
-    fuse_log_eh(this, "RELEASEDIR (): %" PRIu64 ": fd: %p, gfid: %s",
233933
+    fuse_log_eh(this,
233933
+                "RELEASEDIR (): finh->unique: %" PRIu64 ": fd: %p, gfid: %s",
233933
                 finh->unique, state->fd, uuid_utoa(state->fd->inode->gfid));
233933
 
233933
-    gf_log("glusterfs-fuse", GF_LOG_TRACE, "%" PRIu64 ": RELEASEDIR %p",
233933
-           finh->unique, state->fd);
233933
+    gf_log("glusterfs-fuse", GF_LOG_TRACE,
233933
+           "finh->unique: %" PRIu64 ": RELEASEDIR %p", finh->unique, state->fd);
233933
 
233933
     fuse_fd_ctx_destroy(this, state->fd);
233933
     fd_unref(state->fd);
233933
diff --git a/xlators/mount/fuse/src/fuse-helpers.c b/xlators/mount/fuse/src/fuse-helpers.c
233933
index cf4f8e1..5bfc40c 100644
233933
--- a/xlators/mount/fuse/src/fuse-helpers.c
233933
+++ b/xlators/mount/fuse/src/fuse-helpers.c
233933
@@ -358,7 +358,6 @@ get_call_frame_for_req(fuse_state_t *state)
233933
         frame->root->uid = finh->uid;
233933
         frame->root->gid = finh->gid;
233933
         frame->root->pid = finh->pid;
233933
-        frame->root->unique = finh->unique;
233933
         set_lk_owner_from_uint64(&frame->root->lk_owner, state->lk_owner);
233933
     }
233933
 
233933
diff --git a/xlators/protocol/server/src/server-helpers.c b/xlators/protocol/server/src/server-helpers.c
233933
index 1a34239..e74a24d 100644
233933
--- a/xlators/protocol/server/src/server-helpers.c
233933
+++ b/xlators/protocol/server/src/server-helpers.c
233933
@@ -459,7 +459,6 @@ server_alloc_frame(rpcsvc_request_t *req)
233933
 
233933
     frame->root->client = client;
233933
     frame->root->state = state; /* which socket */
233933
-    frame->root->unique = 0;    /* which call */
233933
 
233933
     frame->this = client->this;
233933
 out:
233933
@@ -487,8 +486,6 @@ get_frame_from_request(rpcsvc_request_t *req)
233933
 
233933
     frame->root->op = req->procnum;
233933
 
233933
-    frame->root->unique = req->xid;
233933
-
233933
     client = req->trans->xl_private;
233933
     this = req->trans->xl;
233933
     priv = this->private;
233933
-- 
233933
1.8.3.1
233933