d1681e
From aad829320132fb2399e8fd8edfa573561a7c03e1 Mon Sep 17 00:00:00 2001
d1681e
From: Mohit Agrawal <moagrawa@redhat.com>
d1681e
Date: Sun, 13 May 2018 12:01:01 +0530
d1681e
Subject: [PATCH 270/271] glusterfs: Resolve brick crashes at the time of
d1681e
 inode_unref
d1681e
d1681e
Problem: Sometimes brick process is getting crash at the time
d1681e
         of calling inode_unref in fd_destroy
d1681e
d1681e
Solution: Brick process is getting crash because inode is already
d1681e
          free by xlator_mem_cleanup call by server_rpc_notify.To
d1681e
          resolve the same move code specific to call transport_unref
d1681e
          in last in free_state.
d1681e
d1681e
> BUG: 1577574
d1681e
> Change-Id: Ia517c230d68af4e929b6b753e4c374a26c39dc1a
d1681e
> fixes: bz#1577574
d1681e
> (cherry picked from commit 8e2289b1e76ac777b71897dc709d9651341bd241)
d1681e
> (Upstream link for review https://review.gluster.org/#/c/20014/)
d1681e
d1681e
BUG: 1575840
d1681e
Change-Id: I62df8dd6f4df545250a977897697c960adba1c4c
d1681e
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
d1681e
Reviewed-on: https://code.engineering.redhat.com/gerrit/138797
d1681e
Tested-by: RHGS Build Bot <nigelb@redhat.com>
d1681e
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
d1681e
---
d1681e
 xlators/protocol/server/src/server-helpers.c | 15 +++++++++++----
d1681e
 xlators/protocol/server/src/server.c         |  6 +++---
d1681e
 2 files changed, 14 insertions(+), 7 deletions(-)
d1681e
d1681e
diff --git a/xlators/protocol/server/src/server-helpers.c b/xlators/protocol/server/src/server-helpers.c
d1681e
index c8f5382..c492ab1 100644
d1681e
--- a/xlators/protocol/server/src/server-helpers.c
d1681e
+++ b/xlators/protocol/server/src/server-helpers.c
d1681e
@@ -177,10 +177,6 @@ server_resolve_wipe (server_resolve_t *resolve)
d1681e
 void
d1681e
 free_state (server_state_t *state)
d1681e
 {
d1681e
-        if (state->xprt) {
d1681e
-                rpc_transport_unref (state->xprt);
d1681e
-                state->xprt = NULL;
d1681e
-        }
d1681e
         if (state->fd) {
d1681e
                 fd_unref (state->fd);
d1681e
                 state->fd = NULL;
d1681e
@@ -223,6 +219,17 @@ free_state (server_state_t *state)
d1681e
 
d1681e
         compound_args_cleanup (state->args);
d1681e
 
d1681e
+        /* Call rpc_trnasport_unref to avoid crashes at last after free
d1681e
+           all resources because of server_rpc_notify (for transport destroy)
d1681e
+           call's xlator_mem_cleanup if all xprt are destroyed that internally
d1681e
+           call's inode_table_destroy.
d1681e
+        */
d1681e
+        if (state->xprt) {
d1681e
+                rpc_transport_unref (state->xprt);
d1681e
+                state->xprt = NULL;
d1681e
+        }
d1681e
+
d1681e
+
d1681e
         GF_FREE (state);
d1681e
 }
d1681e
 
d1681e
diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c
d1681e
index 2ba5da3..d40457c 100644
d1681e
--- a/xlators/protocol/server/src/server.c
d1681e
+++ b/xlators/protocol/server/src/server.c
d1681e
@@ -208,9 +208,6 @@ server_submit_reply (call_frame_t *frame, rpcsvc_request_t *req, void *arg,
d1681e
 
d1681e
         ret = 0;
d1681e
 ret:
d1681e
-        if (state)
d1681e
-                free_state (state);
d1681e
-
d1681e
         if (client)
d1681e
                 gf_client_unref (client);
d1681e
 
d1681e
@@ -220,6 +217,9 @@ ret:
d1681e
         if (new_iobref)
d1681e
                 iobref_unref (iobref);
d1681e
 
d1681e
+        if (state)
d1681e
+                free_state (state);
d1681e
+
d1681e
         return ret;
d1681e
 }
d1681e
 
d1681e
-- 
d1681e
1.8.3.1
d1681e