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