summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/mgmt/glusterd')
-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 9ebe971874a..2eb88d7239a 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -2728,10 +2728,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 f589a8dfcec..095385c7c7b 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -1558,6 +1558,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 44d3f757ee3..6d09c7d2a0c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -173,6 +173,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},
@@ -1135,6 +1136,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)
@@ -1459,7 +1508,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;
@@ -1496,11 +1544,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) {
@@ -1816,6 +1863,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);
@@ -1872,15 +1920,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);
@@ -1898,8 +1946,6 @@ build_nfs_graph (volgen_graph_t *graph, dict_t *mod_dict)
}
-
-
out:
dict_destroy (set_dict);
@@ -2231,15 +2277,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 3411d3d3e40..2ddd830f847 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -171,6 +171,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,
@@ -204,6 +205,7 @@ struct glusterd_volinfo_ {
int version;
uint32_t cksum;
gf_transport_type transport_type;
+ gf_transport_type nfs_transport_type;
dict_t *dict;