summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2010-08-23 01:42:47 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-08-23 00:23:47 -0700
commit436f2b329f41f28a65fc4898df5435f154bd6027 (patch)
treef37178a4d0104d93a33ccad3e38977080b6d270c
parent0d33cce6f7bbb71abe0086469f2f726151b0e62c (diff)
rpcsvc: allow creation of both rdma and socket for a single server transport.
Signed-off-by: Raghavendra G <raghavendra@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 513 (Introduce 0 copy rdma) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=513
-rw-r--r--libglusterfs/src/xlator.c4
-rw-r--r--rpc/rpc-lib/src/rpcsvc.c100
-rw-r--r--rpc/rpc-lib/src/rpcsvc.h4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.c13
-rw-r--r--xlators/protocol/server/src/server.c11
5 files changed, 112 insertions, 20 deletions
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c
index e5b97f7c4a5..fd7db3e032c 100644
--- a/libglusterfs/src/xlator.c
+++ b/libglusterfs/src/xlator.c
@@ -375,8 +375,8 @@ _volume_option_value_validate (xlator_t *xl,
for (i = 0; (i < ZR_OPTION_MAX_ARRAY_SIZE) &&
opt->value[i]; i++) {
- if (strcasecmp (opt->value[i],
- pair->value->data) == 0) {
+ if (fnmatch (opt->value[i], pair->value->data,
+ FNM_EXTMATCH) == 0) {
ret = 0;
break;
}
diff --git a/rpc/rpc-lib/src/rpcsvc.c b/rpc/rpc-lib/src/rpcsvc.c
index 88675205c90..01b441317c3 100644
--- a/rpc/rpc-lib/src/rpcsvc.c
+++ b/rpc/rpc-lib/src/rpcsvc.c
@@ -1600,11 +1600,12 @@ out:
}
-rpcsvc_listener_t *
+int32_t
rpcsvc_create_listener (rpcsvc_t *svc, dict_t *options, char *name)
{
rpc_transport_t *trans = NULL;
rpcsvc_listener_t *listener = NULL;
+ int32_t ret = -1;
if (!svc || !options) {
goto out;
@@ -1620,12 +1621,107 @@ rpcsvc_create_listener (rpcsvc_t *svc, dict_t *options, char *name)
goto out;
}
+ ret = 0;
out:
if (!listener && trans) {
rpc_transport_disconnect (trans);
}
- return listener;
+ return ret;
+}
+
+
+int32_t
+rpcsvc_create_listeners (rpcsvc_t *svc, dict_t *options, char *name)
+{
+ int32_t ret = -1, count = 0;
+ data_t *data = NULL;
+ char *str = NULL, *ptr = NULL, *transport_name = NULL;
+ char *transport_type = NULL, *saveptr = NULL;
+
+ if ((svc == NULL) || (options == NULL) || (name == NULL)) {
+ goto out;
+ }
+
+ data = dict_get (options, "transport-type");
+ if (data == NULL) {
+ gf_log (GF_RPCSVC, GF_LOG_DEBUG,
+ "option transport-type not set");
+ goto out;
+ }
+
+ transport_type = data_to_str (data);
+ if (transport_type == NULL) {
+ gf_log (GF_RPCSVC, GF_LOG_DEBUG,
+ "option transport-type not set");
+ goto out;
+ }
+
+ /* duplicate transport_type, since following dict_set will free it */
+ transport_type = gf_strdup (transport_type);
+ if (transport_type == NULL) {
+ gf_log (GF_RPCSVC, GF_LOG_ERROR, "out of memory");
+ goto out;
+ }
+
+ str = gf_strdup (transport_type);
+ if (str == NULL) {
+ gf_log (GF_RPCSVC, GF_LOG_ERROR, "out of memory");
+ goto out;
+ }
+
+ ptr = strtok_r (str, ",", &saveptr);
+
+ while (ptr != NULL) {
+ ptr = gf_strdup (ptr);
+ if (ptr == NULL) {
+ gf_log (GF_RPCSVC, GF_LOG_ERROR, "out of memory");
+ goto out;
+ }
+
+ ret = dict_set_dynstr (options, "transport-type", ptr);
+ if (ret == -1) {
+ goto out;
+ }
+
+ ret = asprintf (&transport_name, "%s.%s", ptr, name);
+ if (ret == -1) {
+ goto out;
+ }
+
+ ret = rpcsvc_create_listener (svc, options, transport_name);
+ if (ret != 0) {
+ goto out;
+ }
+
+ count++;
+
+ ptr = strtok_r (NULL, ",", &saveptr);
+ }
+
+ ptr = NULL;
+
+ ret = dict_set_dynstr (options, "transport-type", transport_type);
+ if (ret == -1) {
+ goto out;
+ }
+
+ transport_type = NULL;
+
+out:
+ if (str != NULL) {
+ GF_FREE (str);
+ }
+
+ if (transport_type != NULL) {
+ GF_FREE (transport_type);
+ }
+
+ if (ptr != NULL) {
+ GF_FREE (ptr);
+ }
+
+ return count;
}
diff --git a/rpc/rpc-lib/src/rpcsvc.h b/rpc/rpc-lib/src/rpcsvc.h
index 0a3e91da7b2..06b0aad222e 100644
--- a/rpc/rpc-lib/src/rpcsvc.h
+++ b/rpc/rpc-lib/src/rpcsvc.h
@@ -392,8 +392,8 @@ rpcsvc_program_unregister (rpcsvc_t *svc, rpcsvc_program_t *program);
* rpcsvc_program_register_portmap.
*/
/* FIXME: can multiple programs registered on same port? */
-extern rpcsvc_listener_t *
-rpcsvc_create_listener (rpcsvc_t *svc, dict_t *options, char *name);
+extern int32_t
+rpcsvc_create_listeners (rpcsvc_t *svc, dict_t *options, char *name);
void
rpcsvc_listener_destroy (rpcsvc_listener_t *listener);
diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c
index 15cc9cd86a0..28d500bdd75 100644
--- a/xlators/mgmt/glusterd/src/glusterd.c
+++ b/xlators/mgmt/glusterd/src/glusterd.c
@@ -198,7 +198,6 @@ init (xlator_t *this)
char *port_str = NULL;
int port_num = 0;
char voldir [PATH_MAX] = {0,};
- rpcsvc_listener_t *listener = NULL;
char dirname [PATH_MAX];
@@ -285,11 +284,11 @@ init (xlator_t *this)
}
/*
- * only one listener for glusterd1_mop_prog, gluster_pmap_prog and
- * gluster_handshake_prog.
+ * only one (atmost a pair - rdma and socket) listener for
+ * glusterd1_mop_prog, gluster_pmap_prog and gluster_handshake_prog.
*/
- listener = rpcsvc_create_listener (rpc, this->options, this->name);
- if (listener == NULL) {
+ ret = rpcsvc_create_listeners (rpc, this->options, this->name);
+ if (ret < 1) {
gf_log (this->name, GF_LOG_ERROR,
"creation of listener failed");
goto out;
@@ -345,10 +344,6 @@ init (xlator_t *this)
ret = 0;
out:
if (ret == -1) {
- if (listener != NULL) {
- rpcsvc_listener_destroy (listener);
- }
-
if (this->private != NULL) {
GF_FREE (this->private);
this->private = NULL;
diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c
index 7ab3de51c18..05d69c44d2d 100644
--- a/xlators/protocol/server/src/server.c
+++ b/xlators/protocol/server/src/server.c
@@ -482,12 +482,11 @@ init (xlator_t *this)
goto out;
}
- listener = rpcsvc_create_listener (conf->rpc, this->options,
- this->name);
- if (listener == NULL) {
+ ret = rpcsvc_create_listeners (conf->rpc, this->options,
+ this->name);
+ if (ret < 1) {
gf_log (this->name, GF_LOG_DEBUG,
"creation of listener failed");
- ret = -1;
goto out;
}
@@ -626,7 +625,9 @@ struct xlator_dumpops dumpops = {
struct volume_options options[] = {
{ .key = {"transport-type"},
.value = {"rpc", "rpc-over-rdma", "tcp", "socket", "ib-verbs",
- "unix", "ib-sdp", "tcp/server", "ib-verbs/server"},
+ "unix", "ib-sdp", "tcp/server", "ib-verbs/server",
+ "rdma*([ \t]),*([ \t])socket",
+ "socket*([ \t]),*([ \t])rdma"},
.type = GF_OPTION_TYPE_STR
},
{ .key = {"volume-filename.*"},