233933
From c429d3c63601e6ea15af76aa684c30bbeb746467 Mon Sep 17 00:00:00 2001
233933
From: Mohammed Rafi KC <rkavunga@redhat.com>
233933
Date: Tue, 23 Apr 2019 13:03:28 +0530
233933
Subject: [PATCH 120/124] glusterd/shd: Keep a ref on volinfo until attach rpc
233933
 execute cbk
233933
233933
When svc attach execute for multiplexing a daemon, we have to keep
233933
a ref on volinfo until it finish the execution. Because, if the attach
233933
is an aysnc call, then a parallel volume delete can lead to free the
233933
volinfo
233933
233933
> upstream patch : https://review.gluster.org/#/c/glusterfs/+/22606/
233933
233933
>Change-Id: Ibc02b89557baaed2f63db63d7fb1a7480444ae0d
233933
>fixes: bz#1702185
233933
>Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
233933
233933
Change-Id: Ibc02b89557baaed2f63db63d7fb1a7480444ae0d
233933
BUG: 1702240
233933
Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
233933
Reviewed-on: https://code.engineering.redhat.com/gerrit/168616
233933
Tested-by: RHGS Build Bot <nigelb@redhat.com>
233933
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
233933
---
233933
 xlators/mgmt/glusterd/src/glusterd-shd-svc.c    | 3 +++
233933
 xlators/mgmt/glusterd/src/glusterd-svc-helper.c | 4 ++++
233933
 2 files changed, 7 insertions(+)
233933
233933
diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
233933
index 19eca9f..a9eab42 100644
233933
--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
233933
+++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
233933
@@ -452,8 +452,11 @@ glusterd_shdsvc_start(glusterd_svc_t *svc, int flags)
233933
     }
233933
 
233933
     if (shd->attached) {
233933
+        glusterd_volinfo_ref(volinfo);
233933
+        /* Unref will happen from glusterd_svc_attach_cbk */
233933
         ret = glusterd_attach_svc(svc, volinfo, flags);
233933
         if (ret) {
233933
+            glusterd_volinfo_unref(volinfo);
233933
             gf_msg("glusterd", GF_LOG_ERROR, 0, GD_MSG_VOLINFO_GET_FAIL,
233933
                    "Failed to attach shd svc(volume=%s) to pid=%d. Starting"
233933
                    "a new process",
233933
diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
233933
index 02945b1..f7be394 100644
233933
--- a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
233933
+++ b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
233933
@@ -695,6 +695,10 @@ out:
233933
     if (flag) {
233933
         GF_FREE(flag);
233933
     }
233933
+
233933
+    if (volinfo)
233933
+        glusterd_volinfo_unref(volinfo);
233933
+
233933
     GF_ATOMIC_DEC(conf->blockers);
233933
     STACK_DESTROY(frame->root);
233933
     return 0;
233933
-- 
233933
1.8.3.1
233933