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