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