14f8ab
From 79fff98f9ca5f815cf0227312b9a997d555dad29 Mon Sep 17 00:00:00 2001
14f8ab
From: Mohammed Rafi KC <rkavunga@redhat.com>
14f8ab
Date: Wed, 22 May 2019 13:32:23 +0530
14f8ab
Subject: [PATCH 166/169] glusterd/svc: glusterd_svcs_stop should call
14f8ab
 individual wrapper function
14f8ab
14f8ab
glusterd_svcs_stop should call individual wrapper function to stop a
14f8ab
daemon rather than calling glusterd_svc_stop. For example for shd,
14f8ab
it should call glusterd_shdsvc_stop instead of calling basic API
14f8ab
function to stop. Because the individual functions for each daemon
14f8ab
could be doing some specific operation in their wrapper function.
14f8ab
14f8ab
Upstream patch: https://review.gluster.org/#/c/glusterfs/+/22761/
14f8ab
14f8ab
>Change-Id: Ie6d40590251ad470ef3901d1141ab7b22c3498f5
14f8ab
>fixes: bz#1712741
14f8ab
>Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
14f8ab
14f8ab
Change-Id: I6df03e53f08c337d5d9b0e855a0b77894a2aacc9
14f8ab
BUG: 1716865
14f8ab
Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
14f8ab
Reviewed-on: https://code.engineering.redhat.com/gerrit/172288
14f8ab
Tested-by: RHGS Build Bot <nigelb@redhat.com>
14f8ab
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
14f8ab
---
14f8ab
 xlators/mgmt/glusterd/src/glusterd-shd-svc.c    | 12 ++++++++++--
14f8ab
 xlators/mgmt/glusterd/src/glusterd-svc-helper.c | 10 +++++-----
14f8ab
 2 files changed, 15 insertions(+), 7 deletions(-)
14f8ab
14f8ab
diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
14f8ab
index 75f9a07..981cc87 100644
14f8ab
--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
14f8ab
+++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
14f8ab
@@ -656,10 +656,18 @@ glusterd_shdsvc_stop(glusterd_svc_t *svc, int sig)
14f8ab
     int pid = -1;
14f8ab
 
14f8ab
     conf = THIS->private;
14f8ab
+    GF_VALIDATE_OR_GOTO("glusterd", conf, out);
14f8ab
     GF_VALIDATE_OR_GOTO("glusterd", svc, out);
14f8ab
     svc_proc = svc->svc_proc;
14f8ab
-    GF_VALIDATE_OR_GOTO("glusterd", svc_proc, out);
14f8ab
-    GF_VALIDATE_OR_GOTO("glusterd", conf, out);
14f8ab
+    if (!svc_proc) {
14f8ab
+        /*
14f8ab
+         * This can happen when stop was called on a volume that is not shd
14f8ab
+         * compatible.
14f8ab
+         */
14f8ab
+        gf_msg_debug("glusterd", 0, "svc_proc is null, ie shd already stopped");
14f8ab
+        ret = 0;
14f8ab
+        goto out;
14f8ab
+    }
14f8ab
 
14f8ab
     /* Get volinfo->shd from svc object */
14f8ab
     shd = cds_list_entry(svc, glusterd_shdsvc_t, svc);
14f8ab
diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
14f8ab
index f7be394..6a3ca52 100644
14f8ab
--- a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
14f8ab
+++ b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
14f8ab
@@ -86,25 +86,25 @@ glusterd_svcs_stop(glusterd_volinfo_t *volinfo)
14f8ab
     priv = this->private;
14f8ab
     GF_ASSERT(priv);
14f8ab
 
14f8ab
-    ret = glusterd_svc_stop(&(priv->nfs_svc), SIGKILL);
14f8ab
+    ret = priv->nfs_svc.stop(&(priv->nfs_svc), SIGKILL);
14f8ab
     if (ret)
14f8ab
         goto out;
14f8ab
 
14f8ab
-    ret = glusterd_svc_stop(&(priv->quotad_svc), SIGTERM);
14f8ab
+    ret = priv->quotad_svc.stop(&(priv->quotad_svc), SIGTERM);
14f8ab
     if (ret)
14f8ab
         goto out;
14f8ab
 
14f8ab
     if (volinfo) {
14f8ab
-        ret = glusterd_svc_stop(&(volinfo->shd.svc), PROC_START_NO_WAIT);
14f8ab
+        ret = volinfo->shd.svc.stop(&(volinfo->shd.svc), SIGTERM);
14f8ab
         if (ret)
14f8ab
             goto out;
14f8ab
     }
14f8ab
 
14f8ab
-    ret = glusterd_svc_stop(&(priv->bitd_svc), SIGTERM);
14f8ab
+    ret = priv->bitd_svc.stop(&(priv->bitd_svc), SIGTERM);
14f8ab
     if (ret)
14f8ab
         goto out;
14f8ab
 
14f8ab
-    ret = glusterd_svc_stop(&(priv->scrub_svc), SIGTERM);
14f8ab
+    ret = priv->scrub_svc.stop(&(priv->scrub_svc), SIGTERM);
14f8ab
 out:
14f8ab
     return ret;
14f8ab
 }
14f8ab
-- 
14f8ab
1.8.3.1
14f8ab