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