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