From 81a6a069c49c4d13a2f7471e8d5d452f7dae2286 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Sun, 27 Oct 2013 12:26:34 +0100 Subject: [PATCH] Add option to specify a different base-port Resolves: 1023653 --- ...fs-3.4.1.add.base-port.config.option.patch | 156 ++++++++++++++++++ glusterfs.spec | 5 + 2 files changed, 161 insertions(+) create mode 100644 glusterfs-3.4.1.add.base-port.config.option.patch diff --git a/glusterfs-3.4.1.add.base-port.config.option.patch b/glusterfs-3.4.1.add.base-port.config.option.patch new file mode 100644 index 0000000..4282a03 --- /dev/null +++ b/glusterfs-3.4.1.add.base-port.config.option.patch @@ -0,0 +1,156 @@ +From http://review.gluster.org/6147 +From b1d288f6d24a3fe439730c2f4e28bcc7a9ae7ecd Mon Sep 17 00:00:00 2001 +From: Kaleb S. KEITHLEY +Date: Fri, 25 Oct 2013 09:05:18 -0400 +Subject: [PATCH] mgmt/glusterd: add option to specify a different base-port + +This is (arguably) a hack to work around a bug in libvirt which is not +well behaved wrt to using TCP ports in the unreserved space between +49152-65535. (See RFC 6335) + +Normally glusterd starts and binds to the first available port in range, +usually 49152. libvirt's live migration also tries to use ports in this +range, but has no fallback to use (an)other port(s) when the one it wants +is already in use. + +libvirt cannot fix this in time for their impending release. This is +submitted to gerrit to provide some minimal visibility upstream to justify +hacking this change (as a temporary patch) into the glusterfs-3.4.1 RPMs +for Fedora 18-21 until libvirt can fix their implementation. + +Change-Id: Ie77b00ac60730d1e48907dd0b38ddae92f3ac345 +Signed-off-by: Kaleb S. KEITHLEY +--- + doc/glusterd.vol | 1 + + xlators/mgmt/glusterd/src/glusterd-pmap.c | 10 +++++----- + xlators/mgmt/glusterd/src/glusterd-store.c | 5 ++--- + xlators/mgmt/glusterd/src/glusterd.c | 12 ++++++++++-- + xlators/mgmt/glusterd/src/glusterd.h | 1 + + 5 files changed, 19 insertions(+), 10 deletions(-) + +diff --git a/doc/glusterd.vol b/doc/glusterd.vol +index de17d8f..9bac52a 100644 +--- a/doc/glusterd.vol ++++ b/doc/glusterd.vol +@@ -5,4 +5,5 @@ volume management + option transport.socket.keepalive-time 10 + option transport.socket.keepalive-interval 2 + option transport.socket.read-fail-log off ++# option base-port 49152 + end-volume +diff --git a/xlators/mgmt/glusterd/src/glusterd-pmap.c b/xlators/mgmt/glusterd/src/glusterd-pmap.c +index aab6744..7dec27c 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-pmap.c ++++ b/xlators/mgmt/glusterd/src/glusterd-pmap.c +@@ -52,8 +52,8 @@ pmap_port_isfree (int port) + } + + +-struct pmap_registry * +-pmap_registry_new (void) ++static struct pmap_registry * ++pmap_registry_new (xlator_t *this) + { + struct pmap_registry *pmap = NULL; + int i = 0; +@@ -69,8 +69,8 @@ pmap_registry_new (void) + pmap->ports[i].type = GF_PMAP_PORT_FOREIGN; + } + +- pmap->base_port = GF_IANA_PRIV_PORTS_START; +- pmap->last_alloc = GF_IANA_PRIV_PORTS_START; ++ pmap->base_port = ((glusterd_conf_t *)(this->private))->base_port; ++ pmap->last_alloc = ((glusterd_conf_t *)(this->private))->base_port; + + return pmap; + } +@@ -86,7 +86,7 @@ pmap_registry_get (xlator_t *this) + + pmap = priv->pmap; + if (!pmap) { +- pmap = pmap_registry_new (); ++ pmap = pmap_registry_new (this); + if (!pmap) + return NULL; + priv->pmap = pmap; +diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c +index ae0c4e8..1790c5a 100644 +--- a/xlators/mgmt/glusterd/src/glusterd-store.c ++++ b/xlators/mgmt/glusterd/src/glusterd-store.c +@@ -1484,7 +1484,7 @@ glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo) + strlen (GLUSTERD_STORE_KEY_BRICK_PORT))) { + gf_string2int (value, &brickinfo->port); + +- if (brickinfo->port < GF_IANA_PRIV_PORTS_START){ ++ if (brickinfo->port < priv->base_port){ + /* This is required to adhere to the + IANA standards */ + brickinfo->port = 0; +@@ -1500,8 +1500,7 @@ glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo) + strlen (GLUSTERD_STORE_KEY_BRICK_RDMA_PORT))) { + gf_string2int (value, &brickinfo->rdma_port); + +- if (brickinfo->rdma_port < +- GF_IANA_PRIV_PORTS_START){ ++ if (brickinfo->rdma_port < priv->base_port) { + /* This is required to adhere to the + IANA standards */ + brickinfo->rdma_port = 0; +diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c +index 785e67a..62c4a57 100644 +--- a/xlators/mgmt/glusterd/src/glusterd.c ++++ b/xlators/mgmt/glusterd/src/glusterd.c +@@ -916,7 +916,6 @@ init (xlator_t *this) + int first_time = 0; + char *mountbroker_root = NULL; + int i = 0; +- + #ifdef DEBUG + char *valgrind_str = NULL; + #endif +@@ -1101,6 +1100,12 @@ init (xlator_t *this) + if (ret) + goto out; + ++ conf->base_port = GF_IANA_PRIV_PORTS_START; ++ if (dict_get_uint32(this->options, "base-port", &conf->base_port) == 0) { ++ gf_log (this->name, GF_LOG_INFO, ++ "base-port override: %d", conf->base_port); ++ } ++ + /* Set option to run bricks on valgrind if enabled in glusterd.vol */ + #ifdef DEBUG + conf->valgrind = _gf_false; +@@ -1116,7 +1121,6 @@ init (xlator_t *this) + } + } + #endif +- + this->private = conf; + (void) glusterd_nodesvc_set_online_status ("glustershd", _gf_false); + +@@ -1309,5 +1313,9 @@ struct volume_options options[] = { + .description = "Sets the quorum percentage for the trusted " + "storage pool." + }, ++ { .key = {"base-port"}, ++ .type = GF_OPTION_TYPE_INT, ++ .description = "Sets the base port for portmap query" ++ }, + { .key = {NULL} }, + }; +diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h +index 0033125..1054574 100644 +--- a/xlators/mgmt/glusterd/src/glusterd.h ++++ b/xlators/mgmt/glusterd/src/glusterd.h +@@ -148,6 +148,7 @@ typedef struct { + dict_t *opts; + synclock_t big_lock; + gf_boolean_t restart_done; ++ uint32_t base_port; + } glusterd_conf_t; + + +-- +1.7.1 + diff --git a/glusterfs.spec b/glusterfs.spec index 548bdf9..9478f4b 100644 --- a/glusterfs.spec +++ b/glusterfs.spec @@ -74,6 +74,7 @@ Source13: glusterfsd.init Patch0: %{name}-3.2.5.configure.ac.patch Patch1: %{name}-3.3.0.libglusterfs.Makefile.patch Patch2: %{name}-3.3.1.rpc.rpcxprt.rdma.name.c.patch +Patch3: %{name}-3.4.1.add.base-port.config.option.patch %else Source0: @PACKAGE_NAME@-@PACKAGE_VERSION@.tar.gz %endif @@ -370,6 +371,7 @@ This package provides the api include files. %if ( "%{version}" == "3.3.1" ) %patch2 -p1 %endif +%patch3 -p1 %endif %build @@ -763,6 +765,9 @@ if [ $1 -ge 1 ]; then fi %changelog +* Sat Oct 26 2013 Niels de Vos +- add base-port config option to /etc/glusterd/glusterd.vol (#1023653) + * Wed Oct 9 2013 Kaleb S. KEITHLEY - nit, sync with upstream spec