diff options
author | Csaba Henk <csaba@redhat.com> | 2012-02-27 05:41:17 +0100 |
---|---|---|
committer | Vijay Bellur <vijay@gluster.com> | 2012-03-14 10:59:01 -0700 |
commit | 6826e046157a6ea1a07ba2a38a1825b05eb0b666 (patch) | |
tree | 9dfbb5ac0616a64d59bad98fed007e5d87f62aea | |
parent | 48adf93423ba52f2a0e6d9d59060e6f2f1aa203c (diff) |
glusterd/mountbroker: enhance mountbroker-geo-replication.* option to take multiple volumes
Comma can be used in the value of a "mountbroker-geo-replication.*" option
with semantics as of these examples:
option mountbroker-geo-replication.foolabel vol1,vol2,vol3:geouser
and
option mountbroker-geo-replication.geouser vol1,vol2,vol3
will allow geouser to mount any of the volumes vol{1,2,3} with params of a
geo-rep aux mount under label foolabel, resp. geouser
Also fix memleak in parsing of this option.
Change-Id: I5311388812f503a078a52a14f2679f5ddb33b248
BUG: 765214
Signed-off-by: Csaba Henk <csaba@redhat.com>
Reviewed-on: http://review.gluster.com/2818
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Venky Shankar <vshankar@redhat.com>
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-mem-types.h | 7 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-mountbroker.c | 65 |
2 files changed, 63 insertions, 9 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-mem-types.h b/xlators/mgmt/glusterd/src/glusterd-mem-types.h index 3bb446d1a90..0ef904c7c14 100644 --- a/xlators/mgmt/glusterd/src/glusterd-mem-types.h +++ b/xlators/mgmt/glusterd/src/glusterd-mem-types.h @@ -70,9 +70,10 @@ typedef enum gf_gld_mem_types_ { gf_gld_mt_mount_comp_container = gf_common_mt_end + 44, gf_gld_mt_mount_component = gf_common_mt_end + 45, gf_gld_mt_mount_spec = gf_common_mt_end + 46, - gf_gld_mt_nodesrv_t = gf_common_mt_end + 47, - gf_gld_mt_charptr = gf_common_mt_end + 48, - gf_gld_mt_end = gf_common_mt_end + 49, + gf_gld_mt_georep_meet_spec = gf_common_mt_end + 47, + gf_gld_mt_nodesrv_t = gf_common_mt_end + 48, + gf_gld_mt_charptr = gf_common_mt_end + 49, + gf_gld_mt_end = gf_common_mt_end + 50, } gf_gld_mem_types_t; #endif diff --git a/xlators/mgmt/glusterd/src/glusterd-mountbroker.c b/xlators/mgmt/glusterd/src/glusterd-mountbroker.c index 4bd062c143f..14cbb3d5de0 100644 --- a/xlators/mgmt/glusterd/src/glusterd-mountbroker.c +++ b/xlators/mgmt/glusterd/src/glusterd-mountbroker.c @@ -244,12 +244,15 @@ const char *georep_mnt_desc_template = "xlator-option=\\*-dht.assert-no-child-down=true " "volfile-server=localhost " "client-pid=%d " - "volfile-id=%s " "user-map-root=%s " ")" "SUB+(" "log-file="DEFAULT_LOG_FILE_DIRECTORY"/"GEOREP"*/* " "log-level=* " + "volfile-id=* " + ")" + "MEET(" + "%s" ")"; const char *hadoop_mnt_desc_template = @@ -265,18 +268,68 @@ const char *hadoop_mnt_desc_template = ")"; int -make_georep_mountspec (gf_mount_spec_t *mspec, const char *volname, +make_georep_mountspec (gf_mount_spec_t *mspec, const char *volnames, char *user) { char *georep_mnt_desc = NULL; + char *meetspec = NULL; + char *vols = NULL; + char *vol = NULL; + char *p = NULL; + char *fa[3] = {0,}; + size_t siz = 0; + int vc = 0; + int i = 0; int ret = 0; + vols = gf_strdup ((char *)volnames); + if (!vols) + goto out; + + for (vc = 1, p = vols; *p; p++) { + if (*p == ',') + vc++; + } + siz = strlen (volnames) + vc * strlen("volfile-id="); + meetspec = GF_CALLOC (1, siz + 1, gf_gld_mt_georep_meet_spec); + if (!meetspec) + goto out; + + for (p = vols;;) { + vol = strtok (p, ","); + if (!vol) { + GF_ASSERT (vc == 0); + break; + } + p = NULL; + strcat (meetspec, "volfile-id="); + strcat (meetspec, vol); + if (--vc > 0) + strcat (meetspec, " "); + } + ret = gf_asprintf (&georep_mnt_desc, georep_mnt_desc_template, - GF_CLIENT_PID_GSYNCD, volname, user); - if (ret == -1) - return ret; + GF_CLIENT_PID_GSYNCD, user, meetspec); + if (ret == -1) { + georep_mnt_desc = NULL; + goto out; + } + + ret = parse_mount_pattern_desc (mspec, georep_mnt_desc); + + out: + fa[0] = meetspec; + fa[1] = vols; + fa[2] = georep_mnt_desc; + + for (i = 0; i < 3; i++) { + if (fa[i]) + GF_FREE (fa[i]); + else + ret = -1; + } - return parse_mount_pattern_desc (mspec, georep_mnt_desc); + return ret; } int |