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