Blob Blame History Raw
From 913d932b2367c2a2d519d51ee294ce037664c8e0 Mon Sep 17 00:00:00 2001
From: Atin Mukherjee <amukherj@redhat.com>
Date: Tue, 9 May 2017 21:05:50 +0530
Subject: [PATCH 429/473] glusterfsd: send PARENT_UP on brick attach

With brick multiplexing being enabled, if a brick is instance attached to a
process then a PARENT_UP event is needed so that it reaches right till
posix layer and then from posix CHILD_UP event is sent back to all the
children.

>Reviewed-on: https://review.gluster.org/17225
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
>Smoke: Gluster Build System <jenkins@build.gluster.org>
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
>Reviewed-by: Jeff Darcy <jeff@pl.atyp.us>

Change-Id: Ic341086adb3bbbde0342af518e1b273dd2f669b9
BUG: 1443941
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/106137
---
 glusterfsd/src/glusterfsd-mgmt.c | 15 +++++++++++++--
 libglusterfs/src/glusterfs.h     |  4 +++-
 libglusterfs/src/graph.c         |  5 +++--
 3 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c
index 36a658f..607eac7 100644
--- a/glusterfsd/src/glusterfsd-mgmt.c
+++ b/glusterfsd/src/glusterfsd-mgmt.c
@@ -829,6 +829,7 @@ glusterfs_handle_attach (rpcsvc_request_t *req)
         int32_t                 ret             = -1;
         gd1_mgmt_brick_op_req   xlator_req      = {0,};
         xlator_t                *this           = NULL;
+        glusterfs_graph_t       *newgraph       = NULL;
 
         GF_ASSERT (req);
         this = THIS;
@@ -842,13 +843,22 @@ glusterfs_handle_attach (rpcsvc_request_t *req)
                 req->rpc_err = GARBAGE_ARGS;
                 return -1;
         }
+        ret = 0;
 
         if (this->ctx->active) {
                 gf_log (this->name, GF_LOG_INFO,
                         "got attach for %s", xlator_req.name);
                 ret = glusterfs_graph_attach (this->ctx->active,
-                                              xlator_req.name);
+                                              xlator_req.name, &newgraph);
                 if (ret == 0) {
+                        ret = glusterfs_graph_parent_up (newgraph);
+                        if (ret) {
+                                gf_msg (this->name, GF_LOG_ERROR, 0,
+                                        LG_MSG_EVENT_NOTIFY_FAILED,
+                                        "Parent up notification "
+                                        "failed");
+                                goto out;
+                        }
                         glusterfs_autoscale_threads (this->ctx, 1);
                 }
         } else {
@@ -859,10 +869,11 @@ glusterfs_handle_attach (rpcsvc_request_t *req)
 
         glusterfs_translator_info_response_send (req, ret, NULL, NULL);
 
+out:
         free (xlator_req.input.input_val);
         free (xlator_req.name);
 
-        return 0;
+        return ret;
 }
 
 int
diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h
index 3e613d3..f77f5f8 100644
--- a/libglusterfs/src/glusterfs.h
+++ b/libglusterfs/src/glusterfs.h
@@ -564,7 +564,9 @@ int glusterfs_graph_init (glusterfs_graph_t *graph);
 glusterfs_graph_t *glusterfs_graph_new (void);
 int glusterfs_graph_reconfigure (glusterfs_graph_t *oldgraph,
                                   glusterfs_graph_t *newgraph);
-int glusterfs_graph_attach (glusterfs_graph_t *orig_graph, char *path);
+int glusterfs_graph_attach (glusterfs_graph_t *orig_graph, char *path,
+                            glusterfs_graph_t **newgraph);
+int glusterfs_graph_parent_up (glusterfs_graph_t *graph);
 
 void
 gf_free_mig_locks (lock_migration_info_t *locks);
diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c
index 254eb0c..4c6321e 100644
--- a/libglusterfs/src/graph.c
+++ b/libglusterfs/src/graph.c
@@ -1031,7 +1031,8 @@ out:
 
 
 int
-glusterfs_graph_attach (glusterfs_graph_t *orig_graph, char *path)
+glusterfs_graph_attach (glusterfs_graph_t *orig_graph, char *path,
+                        glusterfs_graph_t **newgraph)
 {
         xlator_t                *this   = THIS;
         FILE                    *fp;
@@ -1068,7 +1069,7 @@ glusterfs_graph_attach (glusterfs_graph_t *orig_graph, char *path)
                 xl = FIRST_CHILD(xl);
         }
         graph->first = xl;
-
+        *newgraph = graph;
 
         volfile_id = strstr (path, "/snaps/");
         if (!volfile_id) {
-- 
1.8.3.1