summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt
diff options
context:
space:
mode:
authorRaghavendra Bhat <raghavendrabhat@gluster.com>2011-06-08 09:18:58 +0000
committerAnand Avati <avati@gluster.com>2011-06-08 11:19:22 -0700
commit60079f55d3fda6c16d391ababcfa44aa7d65923e (patch)
tree0ed58d234c2e430d079f0120798fb394ce72b0b1 /xlators/mgmt
parentc9f61338fadc69ad1da6f8100fe0c37057d622a0 (diff)
nfs:command to change the transport type of nfs server for volumes of transport tcp, rdma
Signed-off-by: Raghavendra Bhat <raghavendrabhat@gluster.com> Signed-off-by: Amar Tumballi <amar@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 2294 (Currently there is no way through cli to make a volume listen on both the transports (socket/rdma)) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2294
Diffstat (limited to 'xlators/mgmt')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c3
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c103
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.h2
4 files changed, 96 insertions, 16 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index db4d649c7..8c87dcc25 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -2624,10 +2624,13 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr)
if (strcasecmp (trans_type, "rdma") == 0) {
volinfo->transport_type = GF_TRANSPORT_RDMA;
+ volinfo->nfs_transport_type = GF_TRANSPORT_RDMA;
} else if (strcasecmp (trans_type, "tcp") == 0) {
volinfo->transport_type = GF_TRANSPORT_TCP;
+ volinfo->nfs_transport_type = GF_TRANSPORT_TCP;
} else {
volinfo->transport_type = GF_TRANSPORT_BOTH_TCP_RDMA;
+ volinfo->nfs_transport_type = GF_DEFAULT_NFS_TRANSPORT;
}
volinfo->sub_count = sub_count;
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index bd932b26a..ba59d790e 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -1523,6 +1523,10 @@ glusterd_store_retrieve_volume (char *volname)
} else if (!strncmp (key, GLUSTERD_STORE_KEY_VOL_TRANSPORT,
strlen (GLUSTERD_STORE_KEY_VOL_TRANSPORT))) {
volinfo->transport_type = atoi (value);
+ volinfo->nfs_transport_type = volinfo->transport_type;
+ if (volinfo->transport_type == GF_TRANSPORT_BOTH_TCP_RDMA) {
+ volinfo->nfs_transport_type = GF_DEFAULT_NFS_TRANSPORT;
+ }
} else if (!strncmp (key, GLUSTERD_STORE_KEY_VOL_ID,
strlen (GLUSTERD_STORE_KEY_VOL_ID))) {
ret = uuid_parse (value, volinfo->volume_id);
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 24df80dbb..252c4907d 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -172,6 +172,7 @@ static struct volopt_map_entry glusterd_volopt_map[] = {
{"nfs.rpc-auth-allow", "nfs/server", "!nfs.rpc-auth.addr.allow", NULL, DOC, 0},
{"nfs.rpc-auth-reject", "nfs/server", "!nfs.rpc-auth.addr.reject", NULL, DOC, 0},
{"nfs.ports-insecure", "nfs/server", "!nfs.auth.ports.insecure", NULL, DOC, 0},
+ {"nfs.transport-type", "nfs/server", "!nfs.transport-type", NULL, DOC, 0},
{"nfs.trusted-sync", "nfs/server", "!nfs-trusted-sync", NULL, DOC, 0},
{"nfs.trusted-write", "nfs/server", "!nfs-trusted-write", NULL, DOC, 0},
@@ -1134,6 +1135,54 @@ get_vol_transport_type (glusterd_volinfo_t *volinfo, char *tt)
}
}
+static void
+get_vol_nfs_transport_type (glusterd_volinfo_t *volinfo, char *tt)
+{
+ switch (volinfo->nfs_transport_type) {
+ case GF_TRANSPORT_RDMA:
+ strcpy (tt, "rdma");
+ break;
+ case GF_TRANSPORT_TCP:
+ strcpy (tt, "tcp");
+ break;
+ case GF_TRANSPORT_BOTH_TCP_RDMA:
+ gf_log ("", GF_LOG_ERROR, "%s:nfs transport cannot be both"
+ " tcp and rdma", volinfo->volname);
+ GF_ASSERT (0);
+ }
+}
+
+/* gets the volinfo, dict, a character array for filling in
+ * the transport type and a boolean option which says whether
+ * the transport type is required for nfs or not. If its not
+ * for nfs, then it is considered as the client transport
+ * and client transport type is filled in the character array
+ */
+static void
+get_transport_type (glusterd_volinfo_t *volinfo, dict_t *set_dict,
+ char *transt, gf_boolean_t is_nfs)
+{
+ int ret = -1;
+ char *tt = NULL;
+ char *key = NULL;
+ typedef void (*transport_type) (glusterd_volinfo_t *volinfo, char *tt);
+ transport_type get_transport;
+
+ if (is_nfs == _gf_false) {
+ key = "client-transport-type";
+ get_transport = get_vol_transport_type;
+ } else {
+ key = "nfs.transport-type";
+ get_transport = get_vol_nfs_transport_type;
+ }
+
+ ret = dict_get_str (set_dict, key, &tt);
+ if (ret)
+ get_transport (volinfo, transt);
+ if (!ret)
+ strcpy (transt, tt);
+}
+
static int
server_auth_option_handler (volgen_graph_t *graph,
struct volopt_map_entry *vme, void *param)
@@ -1391,7 +1440,6 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
{
int dist_count = 0;
char transt[16] = {0,};
- char *tt = NULL;
char *volname = NULL;
dict_t *dict = NULL;
glusterd_brickinfo_t *brick = NULL;
@@ -1428,11 +1476,10 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
return -1;
}
- ret = dict_get_str (set_dict, "client-transport-type", &tt);
- if (ret)
- get_vol_transport_type (volinfo, transt);
- if (!ret)
- strcpy (transt, tt);
+ get_transport_type (volinfo, set_dict, transt, _gf_false);
+
+ if (!strcmp (transt, "tcp,rdma"))
+ strcpy (transt, "tcp");
i = 0;
list_for_each_entry (brick, &volinfo->bricks, brick_list) {
@@ -1748,6 +1795,7 @@ build_nfs_graph (volgen_graph_t *graph, dict_t *mod_dict)
xlator_t *nfsxl = NULL;
char *skey = NULL;
int ret = 0;
+ char nfs_xprt[16] = {0,};
this = THIS;
GF_ASSERT (this);
@@ -1804,15 +1852,15 @@ build_nfs_graph (volgen_graph_t *graph, dict_t *mod_dict)
/* If both RDMA and TCP are the transport_type, use RDMA
for NFS client protocols */
- if (voliter->transport_type == GF_TRANSPORT_BOTH_TCP_RDMA) {
- ret = dict_set_str (set_dict, "client-transport-type",
- "rdma");
- if (ret)
- goto out;
- }
-
memset (&cgraph, 0, sizeof (cgraph));
- ret = build_client_graph (&cgraph, voliter, mod_dict);
+ if (mod_dict)
+ get_transport_type (voliter, mod_dict, nfs_xprt, _gf_true);
+ else
+ get_transport_type (voliter, voliter->dict, nfs_xprt, _gf_true);
+
+ ret = dict_set_str (set_dict, "client-transport-type",
+ nfs_xprt);
+ ret = build_client_graph (&cgraph, voliter, set_dict);
if (ret)
goto out;;
ret = volgen_graph_merge_sub (graph, &cgraph);
@@ -1830,8 +1878,6 @@ build_nfs_graph (volgen_graph_t *graph, dict_t *mod_dict)
}
-
-
out:
dict_destroy (set_dict);
@@ -2128,15 +2174,40 @@ validate_nfsopts (glusterd_volinfo_t *volinfo,
{
volgen_graph_t graph = {0,};
int ret = -1;
+ char transport_type[16] = {0,};
+ char *tt = NULL;
+ char err_str[4096] = {0,};
graph.errstr = op_errstr;
+ get_vol_transport_type (volinfo, transport_type);
+ ret = dict_get_str (val_dict, "nfs.transport-type", &tt);
+ if (!ret) {
+ if (volinfo->transport_type != GF_TRANSPORT_BOTH_TCP_RDMA) {
+ snprintf (err_str, sizeof (err_str), "Changing nfs "
+ "transport type is allowed only for volumes "
+ "of transport type tcp,rdma");
+ gf_log ("", GF_LOG_ERROR, "%s", err_str);
+ *op_errstr = gf_strdup (err_str);
+ ret = -1;
+ goto out;
+ }
+ if (strcmp (tt,"tcp") && strcmp (tt,"rdma")) {
+ snprintf (err_str, sizeof (err_str), "wrong transport "
+ "type %s", tt);
+ *op_errstr = gf_strdup (err_str);
+ ret = -1;
+ goto out;
+ }
+ }
+
ret = build_nfs_graph (&graph, val_dict);
if (!ret)
ret = graph_reconf_validateopt (&graph.graph, op_errstr);
volgen_graph_free (&graph);
+out:
gf_log ("glusterd", GF_LOG_DEBUG, "Returning %d", ret);
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
index 8a14b20e4..deef597af 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -170,6 +170,7 @@ typedef enum gf_transport_type_ {
GF_TRANSPORT_BOTH_TCP_RDMA,
} gf_transport_type;
+#define GF_DEFAULT_NFS_TRANSPORT GF_TRANSPORT_RDMA
typedef enum gf_rb_status_ {
GF_RB_STATUS_NONE,
@@ -203,6 +204,7 @@ struct glusterd_volinfo_ {
int version;
uint32_t cksum;
gf_transport_type transport_type;
+ gf_transport_type nfs_transport_type;
dict_t *dict;