summaryrefslogtreecommitdiffstats
path: root/xlators
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
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')
-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
-rw-r--r--xlators/protocol/client/src/Makefile.am3
-rw-r--r--xlators/protocol/client/src/client-callback.c60
-rw-r--r--xlators/protocol/client/src/client.c5
-rw-r--r--xlators/protocol/server/src/server.c13
-rw-r--r--xlators/protocol/server/src/server.h1
11 files changed, 125 insertions, 107 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
diff --git a/xlators/protocol/client/src/Makefile.am b/xlators/protocol/client/src/Makefile.am
index 159faf268a7..007810e9901 100644
--- a/xlators/protocol/client/src/Makefile.am
+++ b/xlators/protocol/client/src/Makefile.am
@@ -8,7 +8,8 @@ client_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la \
$(top_builddir)/rpc/rpc-lib/src/libgfrpc.la \
$(top_builddir)/rpc/xdr/src/libgfxdr.la
-client_la_SOURCES = client.c client-helpers.c client3_1-fops.c client-handshake.c
+client_la_SOURCES = client.c client-helpers.c client3_1-fops.c \
+ client-handshake.c client-callback.c
noinst_HEADERS = client.h client-mem-types.h
AM_CFLAGS = -fPIC -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -Wall -D$(GF_HOST_OS) \
diff --git a/xlators/protocol/client/src/client-callback.c b/xlators/protocol/client/src/client-callback.c
new file mode 100644
index 00000000000..51bd3375845
--- /dev/null
+++ b/xlators/protocol/client/src/client-callback.c
@@ -0,0 +1,60 @@
+/*
+ Copyright (c) 2010 Gluster, Inc. <http://www.gluster.com>
+ This file is part of GlusterFS.
+
+ GlusterFS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ GlusterFS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "client.h"
+#include "rpc-clnt.h"
+
+int
+client_cbk_null (void *data)
+{
+ return 0;
+}
+
+int
+client_cbk_fetchspec (void *data)
+{
+ gf_log ("", 1, "here i am");
+ return 0;
+}
+
+int
+client_cbk_ino_flush (void *data)
+{
+ return 0;
+}
+
+rpcclnt_cb_actor_t gluster_cbk_actors[] = {
+ [GF_CBK_NULL] = {"NULL", GF_CBK_NULL, client_cbk_null },
+ [GF_CBK_FETCHSPEC] = {"FETCHSPEC", GF_CBK_FETCHSPEC, client_cbk_fetchspec },
+ [GF_CBK_INO_FLUSH] = {"INO_FLUSH", GF_CBK_INO_FLUSH, client_cbk_ino_flush },
+};
+
+
+struct rpcclnt_cb_program gluster_cbk_prog = {
+ .progname = "GlusterFS Callback",
+ .prognum = GLUSTER_CBK_PROGRAM,
+ .progver = GLUSTER_CBK_VERSION,
+ .actors = gluster_cbk_actors,
+ .numactors = GF_CBK_MAXVALUE,
+};
diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c
index c840d96f54c..458ecfa8f88 100644
--- a/xlators/protocol/client/src/client.c
+++ b/xlators/protocol/client/src/client.c
@@ -34,6 +34,7 @@
extern rpc_clnt_prog_t clnt_handshake_prog;
extern rpc_clnt_prog_t clnt_dump_prog;
+extern struct rpcclnt_cb_program gluster_cbk_prog;
int client_handshake (xlator_t *this, struct rpc_clnt *rpc);
void client_start_ping (void *data);
@@ -1730,6 +1731,10 @@ client_init_rpc (xlator_t *this)
conf->handshake = &clnt_handshake_prog;
conf->dump = &clnt_dump_prog;
+ ret = rpcclnt_cbk_program_register (conf->rpc, &gluster_cbk_prog);
+ if (ret)
+ goto out;
+
ret = 0;
gf_log (this->name, GF_LOG_DEBUG, "client init successful");
diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c
index 262da3e3158..8a7d9da0bbf 100644
--- a/xlators/protocol/server/src/server.c
+++ b/xlators/protocol/server/src/server.c
@@ -123,6 +123,10 @@ server_submit_reply (call_frame_t *frame, rpcsvc_request_t *req, void *arg,
ret = rpcsvc_submit_generic (req, &rsp, 1, payload, payloadcount,
iobref);
+ /* TODO: this is demo purpose only */
+ /* ret = rpcsvc_callback_submit (req->svc, req->trans, req->prog,
+ GF_CBK_NULL, &rsp, 1);
+ */
/* Now that we've done our job of handing the message to the RPC layer
* we can safely unref the iob in the hope that RPC layer must have
* ref'ed the iob on receiving into the txlist.
@@ -366,6 +370,7 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event,
xlator_t *this = NULL;
rpc_transport_t *xprt = NULL;
server_connection_t *conn = NULL;
+ server_conf_t *conf = NULL;
if (!xl || !data) {
@@ -376,6 +381,7 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event,
this = xl;
xprt = data;
+ conf = this->private;
switch (event) {
case RPCSVC_EVENT_ACCEPT:
@@ -388,6 +394,10 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event,
xprt->protocol_private = conn;
*/
+ INIT_LIST_HEAD (&xprt->list);
+
+ list_add_tail (&xprt->list, &conf->xprt_list);
+
break;
}
case RPCSVC_EVENT_DISCONNECT:
@@ -395,6 +405,8 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event,
if (conn)
server_connection_put (this, conn);
+ list_del (&xprt->list);
+
break;
default:
break;
@@ -449,6 +461,7 @@ init (xlator_t *this)
GF_VALIDATE_OR_GOTO(this->name, conf, out);
INIT_LIST_HEAD (&conf->conns);
+ INIT_LIST_HEAD (&conf->xprt_list);
pthread_mutex_init (&conf->mutex, NULL);
this->private = conf;
diff --git a/xlators/protocol/server/src/server.h b/xlators/protocol/server/src/server.h
index 62e5ef886cf..b58e8a5fada 100644
--- a/xlators/protocol/server/src/server.h
+++ b/xlators/protocol/server/src/server.h
@@ -99,6 +99,7 @@ struct server_conf {
dict_t *auth_modules;
pthread_mutex_t mutex;
struct list_head conns;
+ struct list_head xprt_list;
};
typedef struct server_conf server_conf_t;