21ab4e
From 913d932b2367c2a2d519d51ee294ce037664c8e0 Mon Sep 17 00:00:00 2001
21ab4e
From: Atin Mukherjee <amukherj@redhat.com>
21ab4e
Date: Tue, 9 May 2017 21:05:50 +0530
21ab4e
Subject: [PATCH 429/473] glusterfsd: send PARENT_UP on brick attach
21ab4e
21ab4e
With brick multiplexing being enabled, if a brick is instance attached to a
21ab4e
process then a PARENT_UP event is needed so that it reaches right till
21ab4e
posix layer and then from posix CHILD_UP event is sent back to all the
21ab4e
children.
21ab4e
21ab4e
>Reviewed-on: https://review.gluster.org/17225
21ab4e
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
21ab4e
>Smoke: Gluster Build System <jenkins@build.gluster.org>
21ab4e
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
21ab4e
>Reviewed-by: Jeff Darcy <jeff@pl.atyp.us>
21ab4e
21ab4e
Change-Id: Ic341086adb3bbbde0342af518e1b273dd2f669b9
21ab4e
BUG: 1443941
21ab4e
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
21ab4e
Reviewed-on: https://code.engineering.redhat.com/gerrit/106137
21ab4e
---
21ab4e
 glusterfsd/src/glusterfsd-mgmt.c | 15 +++++++++++++--
21ab4e
 libglusterfs/src/glusterfs.h     |  4 +++-
21ab4e
 libglusterfs/src/graph.c         |  5 +++--
21ab4e
 3 files changed, 19 insertions(+), 5 deletions(-)
21ab4e
21ab4e
diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c
21ab4e
index 36a658f..607eac7 100644
21ab4e
--- a/glusterfsd/src/glusterfsd-mgmt.c
21ab4e
+++ b/glusterfsd/src/glusterfsd-mgmt.c
21ab4e
@@ -829,6 +829,7 @@ glusterfs_handle_attach (rpcsvc_request_t *req)
21ab4e
         int32_t                 ret             = -1;
21ab4e
         gd1_mgmt_brick_op_req   xlator_req      = {0,};
21ab4e
         xlator_t                *this           = NULL;
21ab4e
+        glusterfs_graph_t       *newgraph       = NULL;
21ab4e
 
21ab4e
         GF_ASSERT (req);
21ab4e
         this = THIS;
21ab4e
@@ -842,13 +843,22 @@ glusterfs_handle_attach (rpcsvc_request_t *req)
21ab4e
                 req->rpc_err = GARBAGE_ARGS;
21ab4e
                 return -1;
21ab4e
         }
21ab4e
+        ret = 0;
21ab4e
 
21ab4e
         if (this->ctx->active) {
21ab4e
                 gf_log (this->name, GF_LOG_INFO,
21ab4e
                         "got attach for %s", xlator_req.name);
21ab4e
                 ret = glusterfs_graph_attach (this->ctx->active,
21ab4e
-                                              xlator_req.name);
21ab4e
+                                              xlator_req.name, &newgraph);
21ab4e
                 if (ret == 0) {
21ab4e
+                        ret = glusterfs_graph_parent_up (newgraph);
21ab4e
+                        if (ret) {
21ab4e
+                                gf_msg (this->name, GF_LOG_ERROR, 0,
21ab4e
+                                        LG_MSG_EVENT_NOTIFY_FAILED,
21ab4e
+                                        "Parent up notification "
21ab4e
+                                        "failed");
21ab4e
+                                goto out;
21ab4e
+                        }
21ab4e
                         glusterfs_autoscale_threads (this->ctx, 1);
21ab4e
                 }
21ab4e
         } else {
21ab4e
@@ -859,10 +869,11 @@ glusterfs_handle_attach (rpcsvc_request_t *req)
21ab4e
 
21ab4e
         glusterfs_translator_info_response_send (req, ret, NULL, NULL);
21ab4e
 
21ab4e
+out:
21ab4e
         free (xlator_req.input.input_val);
21ab4e
         free (xlator_req.name);
21ab4e
 
21ab4e
-        return 0;
21ab4e
+        return ret;
21ab4e
 }
21ab4e
 
21ab4e
 int
21ab4e
diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h
21ab4e
index 3e613d3..f77f5f8 100644
21ab4e
--- a/libglusterfs/src/glusterfs.h
21ab4e
+++ b/libglusterfs/src/glusterfs.h
21ab4e
@@ -564,7 +564,9 @@ int glusterfs_graph_init (glusterfs_graph_t *graph);
21ab4e
 glusterfs_graph_t *glusterfs_graph_new (void);
21ab4e
 int glusterfs_graph_reconfigure (glusterfs_graph_t *oldgraph,
21ab4e
                                   glusterfs_graph_t *newgraph);
21ab4e
-int glusterfs_graph_attach (glusterfs_graph_t *orig_graph, char *path);
21ab4e
+int glusterfs_graph_attach (glusterfs_graph_t *orig_graph, char *path,
21ab4e
+                            glusterfs_graph_t **newgraph);
21ab4e
+int glusterfs_graph_parent_up (glusterfs_graph_t *graph);
21ab4e
 
21ab4e
 void
21ab4e
 gf_free_mig_locks (lock_migration_info_t *locks);
21ab4e
diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c
21ab4e
index 254eb0c..4c6321e 100644
21ab4e
--- a/libglusterfs/src/graph.c
21ab4e
+++ b/libglusterfs/src/graph.c
21ab4e
@@ -1031,7 +1031,8 @@ out:
21ab4e
 
21ab4e
 
21ab4e
 int
21ab4e
-glusterfs_graph_attach (glusterfs_graph_t *orig_graph, char *path)
21ab4e
+glusterfs_graph_attach (glusterfs_graph_t *orig_graph, char *path,
21ab4e
+                        glusterfs_graph_t **newgraph)
21ab4e
 {
21ab4e
         xlator_t                *this   = THIS;
21ab4e
         FILE                    *fp;
21ab4e
@@ -1068,7 +1069,7 @@ glusterfs_graph_attach (glusterfs_graph_t *orig_graph, char *path)
21ab4e
                 xl = FIRST_CHILD(xl);
21ab4e
         }
21ab4e
         graph->first = xl;
21ab4e
-
21ab4e
+        *newgraph = graph;
21ab4e
 
21ab4e
         volfile_id = strstr (path, "/snaps/");
21ab4e
         if (!volfile_id) {
21ab4e
-- 
21ab4e
1.8.3.1
21ab4e