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