summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2010-09-06 11:46:01 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-09-06 11:13:45 -0700
commitedad666e5165dec75ed1970d9e5f7927b43c5bd2 (patch)
tree5bb454c4655d057636f96e4523be1cb89317cb24 /xlators/mgmt
parente3a44226b3ed746260c4f3cf30d2f9f930fb7349 (diff)
glusterd-volgen: write new nfs options in nfs.vol
Signed-off-by: Amar Tumballi <amar@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 1548 (nfs should be able to get different uuid for different subvolumes) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1548
Diffstat (limited to 'xlators/mgmt')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c75
1 files changed, 50 insertions, 25 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 5e93100150a..ec5ad2e1e7f 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -1767,7 +1767,7 @@ out:
}
static int
-glusterfsd_write_nfs_xlator (int fd, char *subvols)
+glusterfsd_write_nfs_xlator (int fd, char *subvols, char *volume_ids)
{
char *dup_subvols = NULL;
char *subvols_remain = NULL;
@@ -1797,6 +1797,12 @@ glusterfsd_write_nfs_xlator (int fd, char *subvols)
write (fd, str, strlen (str));
subvol = strtok_r (NULL, " \n", &subvols_remain);
}
+ str = "option nfs.dynamic-volumes on\n";
+ write (fd, str, strlen (str));
+
+ /* Write fsids */
+ write (fd, volume_ids, strlen (volume_ids));
+
str = "subvolumes ";
write (fd, str, strlen (str));
write (fd, subvols, strlen (subvols));
@@ -1810,19 +1816,23 @@ glusterfsd_write_nfs_xlator (int fd, char *subvols)
int
volgen_generate_nfs_volfile (glusterd_volinfo_t *volinfo)
{
- char *nfs_filepath = NULL;
- char *fuse_filepath = NULL;
- int nfs_fd = -1;
- int fuse_fd = -1;
- int ret = -1;
- char nfs_orig_path[PATH_MAX] = {0,};
- char *pad = NULL;
- char *nfs_subvols = NULL;
- char fuse_subvols[2048] = {0,};
- int subvol_len = 0;
- glusterd_volinfo_t *voliter = NULL;
- glusterd_conf_t *priv = NULL;
- xlator_t *this = NULL;
+ char *nfs_filepath = NULL;
+ char *fuse_filepath = NULL;
+ int nfs_fd = -1;
+ int fuse_fd = -1;
+ int ret = -1;
+ char nfs_orig_path[PATH_MAX] = {0,};
+ char *pad = NULL;
+ char *nfs_subvols = NULL;
+ char fuse_subvols[2048] = {0,};
+ int subvol_len = 0;
+ char *nfs_vol_id = NULL;
+ char nfs_vol_id_opt[512] = {0,};
+ char volume_id[64] = {0,};
+ int nfs_volid_len = 0;
+ glusterd_volinfo_t *voliter = NULL;
+ glusterd_conf_t *priv = NULL;
+ xlator_t *this = NULL;
this = THIS;
GF_ASSERT (this);
@@ -1849,23 +1859,34 @@ volgen_generate_nfs_volfile (glusterd_volinfo_t *volinfo)
list_for_each_entry (voliter, &priv->volumes, vol_list) {
if (voliter->status != GLUSTERD_STATUS_STARTED)
continue;
- else
+ else {
subvol_len += (strlen (voliter->volname) + 1); // ' '
+ // "option nfs3.<volume>.volume-id <uuid>\n"
+ nfs_volid_len += (7 + 4 + 11 + 40 +
+ strlen (voliter->volname));
+ }
}
if (subvol_len == 0) {
gf_log ("", GF_LOG_ERROR, "No volumes started");
ret = -1;
goto out;
- } else {
- subvol_len++; //null character
- nfs_subvols = GF_CALLOC (subvol_len, sizeof(*nfs_subvols),
- gf_common_mt_char);
- if (!nfs_subvols) {
- gf_log ("", GF_LOG_ERROR, "Memory not available");
- ret = -1;
- goto out;
- }
+ }
+ subvol_len++; //null character
+ nfs_subvols = GF_CALLOC (subvol_len, sizeof(*nfs_subvols),
+ gf_common_mt_char);
+ if (!nfs_subvols) {
+ gf_log ("", GF_LOG_ERROR, "Memory not available");
+ ret = -1;
+ goto out;
+ }
+
+ nfs_vol_id = GF_CALLOC (nfs_volid_len, sizeof (char),
+ gf_common_mt_char);
+ if (!nfs_vol_id) {
+ gf_log ("", GF_LOG_ERROR, "Memory not available");
+ ret = -1;
+ goto out;
}
voliter = NULL;
@@ -1906,9 +1927,13 @@ volgen_generate_nfs_volfile (glusterd_volinfo_t *volinfo)
gf_log ("", GF_LOG_ERROR, "Too many subvolumes");
goto out;
}
+ uuid_unparse (voliter->volume_id, volume_id);
+ snprintf (nfs_vol_id_opt, 512, "option nfs3.%s.volume-id %s\n",
+ voliter->volname, volume_id);
+ strcat (nfs_vol_id, nfs_vol_id_opt);
}
- ret = glusterfsd_write_nfs_xlator (nfs_fd, nfs_subvols);
+ ret = glusterfsd_write_nfs_xlator (nfs_fd, nfs_subvols, nfs_vol_id);
if (ret)
goto out;