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