summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2011-06-17 06:10:38 +0000
committerAnand Avati <avati@gluster.com>2011-06-19 02:16:28 -0700
commit3d6efb17f12fa23482936ec7a5a666bbf9c0f78b (patch)
tree5efa50838093f555ac074bbcb7a479ea6a668a69
parent9d9e67f7e7749141b6b616c34208386799a2dcc2 (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: 2258 (enhance gluster volume rebalance) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2258
-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.c107
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.h2
4 files changed, 98 insertions, 18 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index c5fa46021..771c95bef 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -1996,10 +1996,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 657083ede..b55204f31 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -1179,6 +1179,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 3a1fa00f2..23bd8929d 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -163,6 +163,7 @@ static struct volopt_map_entry glusterd_volopt_map[] = {
{"nfs.volume-access", "nfs/server", "!nfs-volume-access", NULL, DOC},
{"nfs.export-dir", "nfs/server", "!nfs-export-dir", NULL, DOC},
{"nfs.disable", "nfs/server", "!nfs-disable", NULL, DOC},
+ {"nfs.transport-type", "nfs/server", "!nfs.transport-type", NULL, DOC},
{NULL, }
};
@@ -1112,6 +1113,54 @@ server_spec_option_handler (glusterfs_graph_t *graph,
static void get_vol_tstamp_file (char *filename, glusterd_volinfo_t *volinfo);
+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_graph_builder (glusterfs_graph_t *graph, glusterd_volinfo_t *volinfo,
dict_t *set_dict, void *param)
@@ -1260,7 +1309,6 @@ client_graph_builder (glusterfs_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;
@@ -1297,11 +1345,10 @@ client_graph_builder (glusterfs_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) {
@@ -1607,6 +1654,7 @@ build_nfs_graph (glusterfs_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);
@@ -1664,15 +1712,15 @@ build_nfs_graph (glusterfs_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;
@@ -1690,8 +1738,6 @@ build_nfs_graph (glusterfs_graph_t *graph, dict_t *mod_dict)
goto out;
}
-
-
out:
dict_destroy (set_dict);
@@ -1987,11 +2033,35 @@ glusterd_delete_volfile (glusterd_volinfo_t *volinfo,
int
validate_nfsopts (glusterd_volinfo_t *volinfo,
- dict_t *val_dict,
- char **op_errstr)
+ dict_t *val_dict,
+ char **op_errstr)
{
glusterfs_graph_t graph = {{0,},};
int ret = -1;
+ char transport_type[16] = {0,};
+ char *tt = NULL;
+ char err_str[4096] = {0,};
+
+ 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)
@@ -1999,6 +2069,7 @@ validate_nfsopts (glusterd_volinfo_t *volinfo,
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 72529f792..9e139fd95 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -164,6 +164,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,
@@ -197,6 +198,7 @@ struct glusterd_volinfo_ {
int version;
uint32_t cksum;
gf_transport_type transport_type;
+ gf_transport_type nfs_transport_type;
dict_t *dict;