diff options
author | Csaba Henk <csaba@gluster.com> | 2010-09-15 08:11:21 +0000 |
---|---|---|
committer | Vijay Bellur <vijay@dev.gluster.com> | 2010-09-16 23:07:57 -0700 |
commit | 3b27ee5d59cfd08e419dfbf1b71b54e724b1ed14 (patch) | |
tree | 368cfc9ffa0ab916f307d4655cf606b93e0dee53 | |
parent | afa6e19f6a9e1dde0f00d72c21c760a5dca341b0 (diff) |
portmap: make grounds for typed service mapping
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
-rw-r--r-- | rpc/rpc-lib/src/protocol-common.h | 9 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-pmap.c | 49 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-pmap.h | 6 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd.c | 2 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd.h | 1 |
5 files changed, 42 insertions, 25 deletions
diff --git a/rpc/rpc-lib/src/protocol-common.h b/rpc/rpc-lib/src/protocol-common.h index 4d1576446..4b8f113d0 100644 --- a/rpc/rpc-lib/src/protocol-common.h +++ b/rpc/rpc-lib/src/protocol-common.h @@ -143,6 +143,15 @@ enum gf_pmap_procnum { GF_PMAP_MAXVALUE, }; +enum gf_pmap_port_type { + GF_PMAP_PORT_FREE = 0, + GF_PMAP_PORT_FOREIGN, + GF_PMAP_PORT_LEASED, + GF_PMAP_PORT_NONE, + GF_PMAP_PORT_BRICKSERVER, +}; +typedef enum gf_pmap_port_type gf_pmap_port_type_t; + enum gf_probe_resp { GF_PROBE_SUCCESS, GF_PROBE_LOCALHOST, diff --git a/xlators/mgmt/glusterd/src/glusterd-pmap.c b/xlators/mgmt/glusterd/src/glusterd-pmap.c index a84d04fd1..e68f7dafa 100644 --- a/xlators/mgmt/glusterd/src/glusterd-pmap.c +++ b/xlators/mgmt/glusterd/src/glusterd-pmap.c @@ -72,9 +72,10 @@ pmap_registry_new (void) return NULL; for (i = 0; i < 65536; i++) { - if (!pmap_port_isfree (i)) { - pmap->ports[i].used = 1; - } + if (pmap_port_isfree (i)) + pmap->ports[i].type = GF_PMAP_PORT_FREE; + else + pmap->ports[i].type = GF_PMAP_PORT_FOREIGN; } pmap->base_port = 6971; /* 6969 default for tcp, 6970 for IB */ @@ -105,7 +106,8 @@ pmap_registry_get (xlator_t *this) int -pmap_registry_search (xlator_t *this, const char *brickname) +pmap_registry_search (xlator_t *this, const char *brickname, + gf_pmap_port_type_t type) { struct pmap_registry *pmap = NULL; int p = 0; @@ -116,7 +118,8 @@ pmap_registry_search (xlator_t *this, const char *brickname) for (p = pmap->base_port; p <= pmap->last_alloc; p++) { if (!pmap->ports[p].brickname) continue; - if (strcmp (pmap->ports[p].brickname, brickname) == 0) { + if (strcmp (pmap->ports[p].brickname, brickname) == 0 && + pmap->ports[p].type == type) { port = p; break; } @@ -126,7 +129,8 @@ pmap_registry_search (xlator_t *this, const char *brickname) } int -pmap_registry_search_by_xprt (xlator_t *this, void *xprt) +pmap_registry_search_by_xprt (xlator_t *this, void *xprt, + gf_pmap_port_type_t type) { struct pmap_registry *pmap = NULL; int p = 0; @@ -137,7 +141,8 @@ pmap_registry_search_by_xprt (xlator_t *this, void *xprt) for (p = pmap->base_port; p <= pmap->last_alloc; p++) { if (!pmap->ports[p].xprt) continue; - if (pmap->ports[p].xprt == xprt) { + if (pmap->ports[p].xprt == xprt && + pmap->ports[p].type == type) { port = p; break; } @@ -158,7 +163,7 @@ pmap_registry_search_by_port (xlator_t *this, int port) pmap = pmap_registry_get (this); - if (pmap->ports[port].used) + if (pmap->ports[port].type == GF_PMAP_PORT_BRICKSERVER) brickname = pmap->ports[port].brickname; out: @@ -176,11 +181,11 @@ pmap_registry_alloc (xlator_t *this) pmap = pmap_registry_get (this); for (p = pmap->last_alloc; p < 65535; p++) { - if (pmap->ports[p].used) + if (pmap->ports[p].type != GF_PMAP_PORT_FREE) continue; if (pmap_port_isfree (p)) { - pmap->ports[p].used = 1; + pmap->ports[p].type = GF_PMAP_PORT_LEASED; port = p; break; } @@ -193,8 +198,8 @@ pmap_registry_alloc (xlator_t *this) } int -pmap_registry_bind (xlator_t *this, int port, - const char *brickname, void *xprt) +pmap_registry_bind (xlator_t *this, int port, const char *brickname, + gf_pmap_port_type_t type, void *xprt) { struct pmap_registry *pmap = NULL; int p = 0; @@ -205,10 +210,11 @@ pmap_registry_bind (xlator_t *this, int port, goto out; p = port; - pmap->ports[p].used = 1; + pmap->ports[p].type = type; if (pmap->ports[p].brickname) free (pmap->ports[p].brickname); pmap->ports[p].brickname = strdup (brickname); + pmap->ports[p].type = type; pmap->ports[p].xprt = xprt; gf_log ("pmap", GF_LOG_INFO, "adding brick %s on port %d", @@ -221,8 +227,8 @@ out: } int -pmap_registry_remove (xlator_t *this, int port, - const char *brickname, void *xprt) +pmap_registry_remove (xlator_t *this, int port, const char *brickname, + gf_pmap_port_type_t type, void *xprt) { struct pmap_registry *pmap = NULL; int p = 0; @@ -242,13 +248,13 @@ pmap_registry_remove (xlator_t *this, int port, } if (brickname && strchr (brickname, '/')) { - p = pmap_registry_search (this, brickname); + p = pmap_registry_search (this, brickname, type); if (p) goto remove; } if (xprt) { - p = pmap_registry_search_by_xprt (this, xprt); + p = pmap_registry_search_by_xprt (this, xprt, type); if (p) goto remove; } @@ -304,7 +310,7 @@ gluster_pmap_portbybrick (rpcsvc_request_t *req) brick = args.brick; - port = pmap_registry_search (THIS, brick); + port = pmap_registry_search (THIS, brick, GF_PMAP_PORT_BRICKSERVER); if (!port) rsp.op_ret = -1; @@ -359,7 +365,8 @@ gluster_pmap_signup (rpcsvc_request_t *req) goto fail; } - rsp.op_ret = pmap_registry_bind (THIS, args.port, args.brick, req->trans); + rsp.op_ret = pmap_registry_bind (THIS, args.port, args.brick, + GF_PMAP_PORT_BRICKSERVER, req->trans); fail: glusterd_submit_reply (req, &rsp, NULL, 0, NULL, @@ -383,7 +390,7 @@ gluster_pmap_signin (rpcsvc_request_t *req) } rsp.op_ret = pmap_registry_bind (THIS, args.port, args.brick, - req->trans); + GF_PMAP_PORT_BRICKSERVER, req->trans); fail: glusterd_submit_reply (req, &rsp, NULL, 0, NULL, @@ -410,7 +417,7 @@ gluster_pmap_signout (rpcsvc_request_t *req) } rsp.op_ret = pmap_registry_remove (THIS, args.port, args.brick, - req->trans); + GF_PMAP_PORT_BRICKSERVER, req->trans); fail: glusterd_submit_reply (req, &rsp, NULL, 0, NULL, diff --git a/xlators/mgmt/glusterd/src/glusterd-pmap.h b/xlators/mgmt/glusterd/src/glusterd-pmap.h index 6db616c39..a021da030 100644 --- a/xlators/mgmt/glusterd/src/glusterd-pmap.h +++ b/xlators/mgmt/glusterd/src/glusterd-pmap.h @@ -39,7 +39,7 @@ struct pmap_port_status { - int used; + gf_pmap_port_type_t type; char *brickname; void *xprt; }; @@ -52,8 +52,8 @@ struct pmap_registry { int pmap_registry_alloc (xlator_t *this); int pmap_registry_bind (xlator_t *this, int port, const char *brickname, - void *xprt); + gf_pmap_port_type_t type, void *xprt); int pmap_registry_remove (xlator_t *this, int port, const char *brickname, - void *xprt); + gf_pmap_port_type_t type, void *xprt); #endif diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c index 94f0bd6d1..edc287318 100644 --- a/xlators/mgmt/glusterd/src/glusterd.c +++ b/xlators/mgmt/glusterd/src/glusterd.c @@ -183,7 +183,7 @@ glusterd_rpcsvc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event, case RPCSVC_EVENT_DISCONNECT: { list_del (&xprt->list); - pmap_registry_remove (this, 0, NULL, xprt); + pmap_registry_remove (this, 0, NULL, GF_PMAP_PORT_NONE, xprt); break; } diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h index e888b7c9d..947f1c23a 100644 --- a/xlators/mgmt/glusterd/src/glusterd.h +++ b/xlators/mgmt/glusterd/src/glusterd.h @@ -43,6 +43,7 @@ #include "rpcsvc.h" #include "glusterd-sm.h" #include "glusterd1-xdr.h" +#include "protocol-common.h" #include "glusterd-pmap.h" |