diff options
author | Csaba Henk <csaba@gluster.com> | 2010-09-15 08:11:22 +0000 |
---|---|---|
committer | Vijay Bellur <vijay@dev.gluster.com> | 2010-09-16 23:08:01 -0700 |
commit | c92a4ad01f81de34e1955a19e42ab28a2865ea84 (patch) | |
tree | 28580609990d874e06845bcc83aa95d886daa9fd /xlators/mgmt/glusterd | |
parent | 3b27ee5d59cfd08e419dfbf1b71b54e724b1ed14 (diff) |
portmap: add support for registering multiple bricks on one port
Rationale: if a brick serves multiple volumes, all of them need
to be registered for the port the brick server listens on.
Implementation: to register volumes "foo" and "bar" for port 6543,
you have to send a SIGNUP for brick: "foo bar", port: 6543.
Upon a pmap lookup, we match the search term to
whitespace tokenized bricknames on server side.
Signed-off-by: Csaba Henk <csaba@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
BUG: 1570 (geosync related changes)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1570
Diffstat (limited to 'xlators/mgmt/glusterd')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-pmap.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-pmap.c b/xlators/mgmt/glusterd/src/glusterd-pmap.c index e68f7dafa66..aaa6ed13169 100644 --- a/xlators/mgmt/glusterd/src/glusterd-pmap.c +++ b/xlators/mgmt/glusterd/src/glusterd-pmap.c @@ -105,27 +105,43 @@ pmap_registry_get (xlator_t *this) } +static char* +nextword (char *str) +{ + while (*str && !isspace (*str)) + str++; + while (*str && isspace (*str)) + str++; + + return str; +} + int pmap_registry_search (xlator_t *this, const char *brickname, gf_pmap_port_type_t type) { struct pmap_registry *pmap = NULL; int p = 0; - int port = 0; + char *brck = NULL; + char *nbrck = NULL; pmap = pmap_registry_get (this); for (p = pmap->base_port; p <= pmap->last_alloc; p++) { - if (!pmap->ports[p].brickname) + if (!pmap->ports[p].brickname || pmap->ports[p].type != type) continue; - if (strcmp (pmap->ports[p].brickname, brickname) == 0 && - pmap->ports[p].type == type) { - port = p; - break; + + for (brck = pmap->ports[p].brickname;;) { + nbrck = strtail (brck, brickname); + if (nbrck && (!*nbrck || isspace (*nbrck))) + return p; + brck = nextword (brck); + if (!*brck) + break; } } - return port; + return 0; } int |