summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2010-08-27 06:45:38 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-08-27 05:53:56 -0700
commit8071909e84b6a479a6b5be1eddd15e8b16fc1a80 (patch)
treedb3a56cef557a3c86fd983e778927c70a8665363 /xlators/mgmt/glusterd/src
parentfd282c4299a5354aa272345e312ac600d9dcc680 (diff)
rpc: server to client callback mechanism
Signed-off-by: Amar Tumballi <amar@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c91
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.h2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.c48
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.h5
6 files changed, 44 insertions, 106 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index ecbe7b150ff..11fca774a9f 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -254,87 +254,6 @@ out:
return ret;
}
-int
-glusterd_volume_create_generate_volfiles (glusterd_volinfo_t *volinfo)
-{
- int32_t ret = -1;
- char cmd_str[8192] = {0,};
- char path[PATH_MAX] = {0,};
- glusterd_conf_t *priv = NULL;
- xlator_t *this = NULL;
- char bricks[8192] = {0,};
- glusterd_brickinfo_t *brickinfo = NULL;
- int32_t len = 0;
-
- this = THIS;
- GF_ASSERT (this);
- priv = this->private;
-
- GF_ASSERT (priv);
- GF_ASSERT (volinfo);
-
- GLUSTERD_GET_VOLUME_DIR(path, volinfo, priv);
- if (!volinfo->port) {
- //volinfo->port = ++glusterfs_port;
- }
-
- list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
- snprintf (bricks + len, 8192 - len, "%s:%s ",
- brickinfo->hostname, brickinfo->path);
- len = strlen (bricks);
- }
-
- gf_log ("", GF_LOG_DEBUG, "Brick string: %s", bricks);
-
- switch (volinfo->type) {
-
- case GF_CLUSTER_TYPE_REPLICATE:
- {
- snprintf (cmd_str, 8192,
- "%s/bin/glusterfs-volgen --portmapper-mode -n %s "
- " -c %s -r 1 %s -p %d --num-replica %d",
- GFS_PREFIX, volinfo->volname, path, bricks,
- volinfo->port, volinfo->sub_count);
- ret = gf_system (cmd_str);
- gf_log ("", 1, "%s", cmd_str);
- break;
- }
-
- case GF_CLUSTER_TYPE_STRIPE:
- {
- snprintf (cmd_str, 8192,
- "%s/bin/glusterfs-volgen --portmapper-mode -n %s "
- " -c %s -r 0 %s -p %d --num-stripe %d",
- GFS_PREFIX, volinfo->volname, path, bricks,
- volinfo->port, volinfo->sub_count);
- ret = gf_system (cmd_str);
- gf_log ("", 1, "%s", cmd_str);
- break;
- }
-
- case GF_CLUSTER_TYPE_NONE:
- {
- snprintf (cmd_str, 8192,
- "%s/bin/glusterfs-volgen --portmapper-mode "
- " -n %s -c %s %s -p %d",
- GFS_PREFIX, volinfo->volname, path, bricks,
- volinfo->port);
- ret = gf_system (cmd_str);
- gf_log ("", 1, "%s", cmd_str);
- break;
- }
-
- default:
- gf_log ("", GF_LOG_ERROR, "Unkown type: %d",
- volinfo->type);
- ret = -1;
- }
-//out:
- gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
- return ret;
-}
-
-
static int
glusterd_op_stage_create_volume (gd1_mgmt_stage_op_req *req)
@@ -952,8 +871,7 @@ glusterd_op_add_brick (gd1_mgmt_stage_op_req *req)
if (!ret && (!uuid_compare (brickinfo->uuid, priv->uuid)) &&
(GLUSTERD_STATUS_STARTED == volinfo->status)) {
- ret =
- glusterd_volume_create_generate_volfiles (volinfo);
+ ret = glusterd_create_volfiles (volinfo);
if (ret)
goto out;
@@ -975,7 +893,7 @@ glusterd_op_add_brick (gd1_mgmt_stage_op_req *req)
}
if (!glfs_started) {
- ret = glusterd_volume_create_generate_volfiles (volinfo);
+ ret = glusterd_create_volfiles (volinfo);
if (ret)
goto out;
}
@@ -1892,8 +1810,7 @@ glusterd_op_remove_brick (gd1_mgmt_stage_op_req *req)
if ((!uuid_compare (brickinfo->uuid, priv->uuid)) &&
(GLUSTERD_STATUS_STARTED == volinfo->status)) {
- ret =
- glusterd_volume_create_generate_volfiles (volinfo);
+ ret = glusterd_create_volfiles (volinfo);
if (ret)
goto out;
@@ -1918,7 +1835,7 @@ glusterd_op_remove_brick (gd1_mgmt_stage_op_req *req)
}
if (!glfs_stopped) {
- ret = glusterd_volume_create_generate_volfiles (volinfo);
+ ret = glusterd_create_volfiles (volinfo);
if (ret)
goto out;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 770ee86d43c..cbafb81ec4b 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -1356,7 +1356,7 @@ glusterd_import_friend_volume (dict_t *vols, int count)
ret = glusterd_store_update_volume (volinfo);
}
- ret = glusterd_volume_create_generate_volfiles (volinfo);
+ ret = glusterd_create_volfiles (volinfo);
if (ret)
goto out;
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
index 1e9469ce0fd..6af21a490fe 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
@@ -127,6 +127,4 @@ glusterd_compare_friend_data (dict_t *vols, int32_t *status);
int
glusterd_volume_compute_cksum (glusterd_volinfo_t *volinfo);
-int
-glusterd_volume_create_generate_volfiles (glusterd_volinfo_t *volinfo);
#endif
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 10ee80e359c..ee7d6839197 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -1683,6 +1683,8 @@ glusterd_create_volfiles (glusterd_volinfo_t *volinfo)
goto out;
}
+ ret = glusterd_fetchspec_notify (THIS);
+
out:
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c
index 1d19c7ed80a..d23f06190d7 100644
--- a/xlators/mgmt/glusterd/src/glusterd.c
+++ b/xlators/mgmt/glusterd/src/glusterd.c
@@ -52,6 +52,12 @@ extern struct rpc_clnt_program glusterd3_1_mgmt_prog;
extern struct rpcsvc_program gluster_pmap_prog;
extern glusterd_op_info_t opinfo;
+rpcsvc_cbk_program_t glusterd_cbk_prog = {
+ .progname = "Gluster Callback",
+ .prognum = GLUSTER_CBK_PROGRAM,
+ .progver = GLUSTER_CBK_VERSION,
+};
+
static int
glusterd_opinfo_init ()
@@ -100,7 +106,24 @@ glusterd_uuid_init ()
return 0;
}
+int
+glusterd_fetchspec_notify (xlator_t *this)
+{
+ int ret = -1;
+ glusterd_conf_t *priv = NULL;
+ rpc_transport_t *trans = NULL;
+
+ priv = this->private;
+ list_for_each_entry (trans, &priv->xprt_list, list) {
+ rpcsvc_callback_submit (priv->rpc, trans, &glusterd_cbk_prog,
+ GF_CBK_FETCHSPEC, NULL, 0);
+ }
+
+ ret = 0;
+
+ return ret;
+}
int
glusterd_priv (xlator_t *this)
@@ -135,6 +158,7 @@ glusterd_rpcsvc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event,
{
xlator_t *this = NULL;
rpc_transport_t *xprt = NULL;
+ glusterd_conf_t *priv = NULL;
if (!xl || !data) {
gf_log ("glusterd", GF_LOG_WARNING,
@@ -145,13 +169,19 @@ glusterd_rpcsvc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event,
this = xl;
xprt = data;
+ priv = this->private;
+
switch (event) {
case RPCSVC_EVENT_ACCEPT:
{
+ INIT_LIST_HEAD (&xprt->list);
+
+ list_add_tail (&xprt->list, &priv->xprt_list);
break;
}
case RPCSVC_EVENT_DISCONNECT:
{
+ list_del (&xprt->list);
pmap_registry_remove (this, 0, NULL, xprt);
break;
}
@@ -328,11 +358,12 @@ init (xlator_t *this)
conf->mgmt = &glusterd3_1_mgmt_prog;
strncpy (conf->workdir, dirname, PATH_MAX);
+ INIT_LIST_HEAD (&conf->xprt_list);
+
this->private = conf;
//this->ctx->top = this;
ret = glusterd_uuid_init ();
-
if (ret < 0)
goto out;
@@ -390,22 +421,11 @@ int
notify (xlator_t *this, int32_t event, void *data, ...)
{
int ret = 0;
- //transport_t *trans = data;
- //peer_info_t *peerinfo = NULL;
- //peer_info_t *myinfo = NULL;
-/* if (trans != NULL) {
- peerinfo = &(trans->peerinfo);
- myinfo = &(trans->myinfo);
- }
-*/
switch (event) {
-
case GF_EVENT_POLLIN:
- // ret = glusterd_pollin (this, trans);
break;
-
case GF_EVENT_POLLERR:
break;
@@ -422,10 +442,6 @@ notify (xlator_t *this, int32_t event, void *data, ...)
}
-
-//struct xlator_mops mops = {
-//};
-
struct xlator_fops fops = {
};
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
index 0f2004779c8..f3e864a5f6e 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -69,6 +69,7 @@ typedef struct {
struct pmap_registry *pmap;
struct list_head volumes;
struct list_head hostnames;
+ struct list_head xprt_list;
glusterd_store_handle_t *handle;
} glusterd_conf_t;
@@ -337,4 +338,8 @@ glusterd_remove_brick (rpcsvc_request_t *req, dict_t *dict);
int
glusterd_xfer_cli_deprobe_resp (rpcsvc_request_t *req, int32_t op_ret,
int32_t op_errno, char *hostname);
+
+int
+glusterd_fetchspec_notify (xlator_t *this);
+
#endif