7f4c2a
From 33509513fc32c010b81716128fb3d0d19d7731c6 Mon Sep 17 00:00:00 2001
7f4c2a
From: Krishnan Parthasarathi <kparthas@redhat.com>
7f4c2a
Date: Tue, 19 May 2015 14:48:01 +0530
7f4c2a
Subject: [PATCH 25/57] glusterd: fix repeated connection to nfssvc failed msgs
7f4c2a
7f4c2a
... and disable reconnect timer on rpc_clnt_disconnect.
7f4c2a
7f4c2a
Root Cause
7f4c2a
----------
7f4c2a
7f4c2a
gluster-NFS service wouldn't be started if there are no
7f4c2a
started volumes that have nfs service enabled for them.
7f4c2a
Before this fix we would initiate a connect even when
7f4c2a
the gluster-NFS service wasn't (re)started. Compounding
7f4c2a
that glusterd_conn_disconnect doesn't disable reconnect
7f4c2a
timer. So, it is possible that the reconnect timer was
7f4c2a
in execution when  the timer event was attempted to be
7f4c2a
removed.
7f4c2a
7f4c2a
Change-Id: Iadcb5cff9eafefa95eaf3a1a9413eeb682d3aaac
7f4c2a
BUG: 1227179
7f4c2a
Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com>
7f4c2a
Reviewed-on: http://review.gluster.org/10830
7f4c2a
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
7f4c2a
Reviewed-by: Gaurav Kumar Garg <ggarg@redhat.com>
7f4c2a
Reviewed-by: Kaushal M <kaushal@redhat.com>
7f4c2a
Reviewed-on: http://review.gluster.org/10963
7f4c2a
Reviewed-by: Emmanuel Dreyfus <manu@netbsd.org>
7f4c2a
Reviewed-on: https://code.engineering.redhat.com/gerrit/50387
7f4c2a
Tested-by: Atin Mukherjee <amukherj@redhat.com>
7f4c2a
---
7f4c2a
 rpc/rpc-lib/src/rpc-clnt.c                     |    6 ++++++
7f4c2a
 xlators/mgmt/glusterd/src/glusterd-conn-mgmt.c |    1 -
7f4c2a
 xlators/mgmt/glusterd/src/glusterd-nfs-svc.c   |   20 ++++++++------------
7f4c2a
 3 files changed, 14 insertions(+), 13 deletions(-)
7f4c2a
7f4c2a
diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c
7f4c2a
index 264a312..db99484 100644
7f4c2a
--- a/rpc/rpc-lib/src/rpc-clnt.c
7f4c2a
+++ b/rpc/rpc-lib/src/rpc-clnt.c
7f4c2a
@@ -1108,6 +1108,11 @@ rpc_clnt_start (struct rpc_clnt *rpc)
7f4c2a
 
7f4c2a
         conn = &rpc->conn;
7f4c2a
 
7f4c2a
+        pthread_mutex_lock (&conn->lock);
7f4c2a
+        {
7f4c2a
+                rpc->disabled = 0;
7f4c2a
+        }
7f4c2a
+        pthread_mutex_unlock (&conn->lock);
7f4c2a
         rpc_clnt_reconnect (conn);
7f4c2a
 
7f4c2a
         return 0;
7f4c2a
@@ -1758,6 +1763,7 @@ rpc_clnt_disconnect (struct rpc_clnt *rpc)
7f4c2a
 
7f4c2a
         pthread_mutex_lock (&conn->lock);
7f4c2a
         {
7f4c2a
+                rpc->disabled = 1;
7f4c2a
                 if (conn->timer) {
7f4c2a
                         gf_timer_call_cancel (rpc->ctx, conn->timer);
7f4c2a
                         conn->timer = NULL;
7f4c2a
diff --git a/xlators/mgmt/glusterd/src/glusterd-conn-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-conn-mgmt.c
7f4c2a
index da8c909..fca9323 100644
7f4c2a
--- a/xlators/mgmt/glusterd/src/glusterd-conn-mgmt.c
7f4c2a
+++ b/xlators/mgmt/glusterd/src/glusterd-conn-mgmt.c
7f4c2a
@@ -80,7 +80,6 @@ out:
7f4c2a
 int
7f4c2a
 glusterd_conn_term (glusterd_conn_t *conn)
7f4c2a
 {
7f4c2a
-        rpc_clnt_disable (conn->rpc);
7f4c2a
         rpc_clnt_unref (conn->rpc);
7f4c2a
         return 0;
7f4c2a
 }
7f4c2a
diff --git a/xlators/mgmt/glusterd/src/glusterd-nfs-svc.c b/xlators/mgmt/glusterd/src/glusterd-nfs-svc.c
7f4c2a
index 49b1b56..cb08a20 100644
7f4c2a
--- a/xlators/mgmt/glusterd/src/glusterd-nfs-svc.c
7f4c2a
+++ b/xlators/mgmt/glusterd/src/glusterd-nfs-svc.c
7f4c2a
@@ -164,18 +164,15 @@ glusterd_nfssvc_manager (glusterd_svc_t *svc, void *data, int flags)
7f4c2a
 {
7f4c2a
         int                 ret     = -1;
7f4c2a
 
7f4c2a
-        if (glusterd_are_all_volumes_stopped ()) {
7f4c2a
-                ret = svc->stop (svc, SIGKILL);
7f4c2a
-
7f4c2a
-        } else {
7f4c2a
-                ret = glusterd_nfssvc_create_volfile ();
7f4c2a
-                if (ret)
7f4c2a
-                        goto out;
7f4c2a
+        ret = svc->stop (svc, SIGKILL);
7f4c2a
+        if (ret)
7f4c2a
+                goto out;
7f4c2a
 
7f4c2a
-                ret = svc->stop (svc, SIGKILL);
7f4c2a
-                if (ret)
7f4c2a
-                        goto out;
7f4c2a
+        ret = glusterd_nfssvc_create_volfile ();
7f4c2a
+        if (ret)
7f4c2a
+                goto out;
7f4c2a
 
7f4c2a
+        if (glusterd_nfssvc_need_start ()) {
7f4c2a
                 ret = svc->start (svc, flags);
7f4c2a
                 if (ret)
7f4c2a
                         goto out;
7f4c2a
@@ -193,8 +190,7 @@ out:
7f4c2a
 int
7f4c2a
 glusterd_nfssvc_start (glusterd_svc_t *svc, int flags)
7f4c2a
 {
7f4c2a
-        if (glusterd_nfssvc_need_start ())
7f4c2a
-                return glusterd_svc_start (svc, flags, NULL);
7f4c2a
+        return glusterd_svc_start (svc, flags, NULL);
7f4c2a
 
7f4c2a
         return 0;
7f4c2a
 }
7f4c2a
-- 
7f4c2a
1.7.1
7f4c2a