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