From 7abed939a7cc61880aed7547f12ace80e6128170 Mon Sep 17 00:00:00 2001 From: Atin Mukherjee Date: Mon, 18 Jul 2016 12:54:38 +0530 Subject: glusterd: search for free port from base_port When a volume is deleted, the freed up ports are never considered for further allocation since pmap_registry_alloc () always starts scanning from last_alloc. So in use cases where gluster volumes are frequently created and deleted managing ports become nightmare as for every new volume creation ports need to be opened up by the admin based on the volume topology. Solution: Instead of scanning from last_alloc, pmap_registry_alloc () always starts from base_port now. What that means is glusterd will always try to find out the ports which have been freed from earlier volumes and reallocate them for the newer ones. There could be possibilities that when a volume is stopped and started back their brick ports are changed which is completely acceptible IMHO. Change-Id: I99ccc11732b6a75527fcb6abafaf249ed02b3b78 BUG: 1221623 Signed-off-by: Atin Mukherjee Reviewed-on: http://review.gluster.org/14939 CentOS-regression: Gluster Build System NetBSD-regression: NetBSD Build System Reviewed-by: Jeff Darcy Smoke: Gluster Build System --- xlators/mgmt/glusterd/src/glusterd-pmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'xlators/mgmt/glusterd') diff --git a/xlators/mgmt/glusterd/src/glusterd-pmap.c b/xlators/mgmt/glusterd/src/glusterd-pmap.c index 8181e478e09..7ed03905774 100644 --- a/xlators/mgmt/glusterd/src/glusterd-pmap.c +++ b/xlators/mgmt/glusterd/src/glusterd-pmap.c @@ -184,7 +184,7 @@ pmap_registry_alloc (xlator_t *this) pmap = pmap_registry_get (this); - for (p = pmap->last_alloc; p <= GF_PORT_MAX; p++) { + for (p = pmap->base_port; p <= GF_PORT_MAX; p++) { /* GF_PMAP_PORT_FOREIGN may be freed up ? */ if ((pmap->ports[p].type == GF_PMAP_PORT_FREE) || (pmap->ports[p].type == GF_PMAP_PORT_FOREIGN)) { @@ -197,7 +197,7 @@ pmap_registry_alloc (xlator_t *this) } } - if (port) + if (port > pmap->last_alloc) pmap->last_alloc = port; return port; -- cgit