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