|
|
d1681e |
From b027d2fdd184d2ee2b2c4236603200be344156f8 Mon Sep 17 00:00:00 2001
|
|
|
d1681e |
From: Atin Mukherjee <amukherj@redhat.com>
|
|
|
d1681e |
Date: Thu, 10 Aug 2017 18:31:55 +0530
|
|
|
d1681e |
Subject: [PATCH 45/74] glusterd: introduce max-port range
|
|
|
d1681e |
|
|
|
d1681e |
glusterd.vol file always had an option (commented out) to indicate the
|
|
|
d1681e |
base-port to start the portmapper allocation. This patch brings in the
|
|
|
d1681e |
max-port configuration where one can limit the range of ports which
|
|
|
d1681e |
gluster can be allowed to bind.
|
|
|
d1681e |
|
|
|
d1681e |
>Fixes: #305
|
|
|
d1681e |
>Change-Id: Id7a864f818227b9530a07e13d605138edacd9aa9
|
|
|
d1681e |
>Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
d1681e |
>Reviewed-on: https://review.gluster.org/18016
|
|
|
d1681e |
>Smoke: Gluster Build System <jenkins@build.gluster.org>
|
|
|
d1681e |
>Reviewed-by: Prashanth Pai <ppai@redhat.com>
|
|
|
d1681e |
>Reviewed-by: Niels de Vos <ndevos@redhat.com>
|
|
|
d1681e |
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
|
|
|
d1681e |
>Reviewed-by: Gaurav Yadav <gyadav@redhat.com>
|
|
|
d1681e |
|
|
|
d1681e |
Change-Id: Id7a864f818227b9530a07e13d605138edacd9aa9
|
|
|
d1681e |
BUG: 1474745
|
|
|
d1681e |
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
d1681e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/123060
|
|
|
d1681e |
Reviewed-by: Gaurav Yadav <gyadav@redhat.com>
|
|
|
d1681e |
---
|
|
|
d1681e |
extras/glusterd.vol.in | 1 +
|
|
|
d1681e |
xlators/mgmt/glusterd/src/glusterd-messages.h | 10 +++++++++-
|
|
|
d1681e |
xlators/mgmt/glusterd/src/glusterd-pmap.c | 20 +++++++++++---------
|
|
|
d1681e |
xlators/mgmt/glusterd/src/glusterd-pmap.h | 3 ++-
|
|
|
d1681e |
xlators/mgmt/glusterd/src/glusterd-snapd-svc.c | 8 ++++++++
|
|
|
d1681e |
xlators/mgmt/glusterd/src/glusterd-utils.c | 18 +++++++++++++++++-
|
|
|
d1681e |
xlators/mgmt/glusterd/src/glusterd.c | 17 +++++++++++++++--
|
|
|
d1681e |
xlators/mgmt/glusterd/src/glusterd.h | 1 +
|
|
|
d1681e |
8 files changed, 64 insertions(+), 14 deletions(-)
|
|
|
d1681e |
|
|
|
d1681e |
diff --git a/extras/glusterd.vol.in b/extras/glusterd.vol.in
|
|
|
d1681e |
index 957b277..0152996 100644
|
|
|
d1681e |
--- a/extras/glusterd.vol.in
|
|
|
d1681e |
+++ b/extras/glusterd.vol.in
|
|
|
d1681e |
@@ -9,4 +9,5 @@ volume management
|
|
|
d1681e |
option event-threads 1
|
|
|
d1681e |
# option transport.address-family inet6
|
|
|
d1681e |
# option base-port 49152
|
|
|
d1681e |
+# option max-port 65535
|
|
|
d1681e |
end-volume
|
|
|
d1681e |
diff --git a/xlators/mgmt/glusterd/src/glusterd-messages.h b/xlators/mgmt/glusterd/src/glusterd-messages.h
|
|
|
d1681e |
index 8bb4c43..de9ae92 100644
|
|
|
d1681e |
--- a/xlators/mgmt/glusterd/src/glusterd-messages.h
|
|
|
d1681e |
+++ b/xlators/mgmt/glusterd/src/glusterd-messages.h
|
|
|
d1681e |
@@ -41,7 +41,7 @@
|
|
|
d1681e |
|
|
|
d1681e |
#define GLUSTERD_COMP_BASE GLFS_MSGID_GLUSTERD
|
|
|
d1681e |
|
|
|
d1681e |
-#define GLFS_NUM_MESSAGES 611
|
|
|
d1681e |
+#define GLFS_NUM_MESSAGES 612
|
|
|
d1681e |
|
|
|
d1681e |
#define GLFS_MSGID_END (GLUSTERD_COMP_BASE + GLFS_NUM_MESSAGES + 1)
|
|
|
d1681e |
/* Messaged with message IDs */
|
|
|
d1681e |
@@ -4945,6 +4945,14 @@
|
|
|
d1681e |
*/
|
|
|
d1681e |
#define GD_MSG_SVC_START_FAIL (GLUSTERD_COMP_BASE + 590)
|
|
|
d1681e |
|
|
|
d1681e |
+/*!
|
|
|
d1681e |
+ * @messageid
|
|
|
d1681e |
+ * @diagnosis
|
|
|
d1681e |
+ * @recommendedaction
|
|
|
d1681e |
+ *
|
|
|
d1681e |
+ */
|
|
|
d1681e |
+#define GD_MSG_PORTS_EXHAUSTED (GLUSTERD_COMP_BASE + 612)
|
|
|
d1681e |
+
|
|
|
d1681e |
/*------------*/
|
|
|
d1681e |
|
|
|
d1681e |
#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages"
|
|
|
d1681e |
diff --git a/xlators/mgmt/glusterd/src/glusterd-pmap.c b/xlators/mgmt/glusterd/src/glusterd-pmap.c
|
|
|
d1681e |
index 1b547e7..4f045ab 100644
|
|
|
d1681e |
--- a/xlators/mgmt/glusterd/src/glusterd-pmap.c
|
|
|
d1681e |
+++ b/xlators/mgmt/glusterd/src/glusterd-pmap.c
|
|
|
d1681e |
@@ -61,8 +61,8 @@ pmap_registry_new (xlator_t *this)
|
|
|
d1681e |
|
|
|
d1681e |
pmap->base_port = pmap->last_alloc =
|
|
|
d1681e |
((glusterd_conf_t *)(this->private))->base_port;
|
|
|
d1681e |
-
|
|
|
d1681e |
- for (i = pmap->base_port; i <= GF_PORT_MAX; i++) {
|
|
|
d1681e |
+ pmap->max_port = ((glusterd_conf_t *)(this->private))->max_port;
|
|
|
d1681e |
+ for (i = pmap->base_port; i <= pmap->max_port; i++) {
|
|
|
d1681e |
if (pmap_port_isfree (i))
|
|
|
d1681e |
pmap->ports[i].type = GF_PMAP_PORT_FREE;
|
|
|
d1681e |
else
|
|
|
d1681e |
@@ -184,10 +184,12 @@ pmap_registry_search_by_xprt (xlator_t *this, void *xprt,
|
|
|
d1681e |
static char *
|
|
|
d1681e |
pmap_registry_search_by_port (xlator_t *this, int port)
|
|
|
d1681e |
{
|
|
|
d1681e |
- struct pmap_registry *pmap = NULL;
|
|
|
d1681e |
- char *brickname = NULL;
|
|
|
d1681e |
+ struct pmap_registry *pmap = NULL;
|
|
|
d1681e |
+ char *brickname = NULL;
|
|
|
d1681e |
+ int max_port = 0;
|
|
|
d1681e |
|
|
|
d1681e |
- if (port > GF_PORT_MAX)
|
|
|
d1681e |
+ max_port = ((glusterd_conf_t *)(this->private))->max_port;
|
|
|
d1681e |
+ if (port > max_port)
|
|
|
d1681e |
goto out;
|
|
|
d1681e |
|
|
|
d1681e |
pmap = pmap_registry_get (this);
|
|
|
d1681e |
@@ -209,7 +211,7 @@ pmap_registry_alloc (xlator_t *this)
|
|
|
d1681e |
|
|
|
d1681e |
pmap = pmap_registry_get (this);
|
|
|
d1681e |
|
|
|
d1681e |
- for (p = pmap->base_port; p <= GF_PORT_MAX; p++) {
|
|
|
d1681e |
+ for (p = pmap->base_port; p <= pmap->max_port; p++) {
|
|
|
d1681e |
/* GF_PMAP_PORT_FOREIGN may be freed up ? */
|
|
|
d1681e |
if ((pmap->ports[p].type == GF_PMAP_PORT_FREE) ||
|
|
|
d1681e |
(pmap->ports[p].type == GF_PMAP_PORT_FOREIGN)) {
|
|
|
d1681e |
@@ -261,7 +263,7 @@ pmap_registry_bind (xlator_t *this, int port, const char *brickname,
|
|
|
d1681e |
|
|
|
d1681e |
pmap = pmap_registry_get (this);
|
|
|
d1681e |
|
|
|
d1681e |
- if (port > GF_PORT_MAX)
|
|
|
d1681e |
+ if (port > pmap->max_port)
|
|
|
d1681e |
goto out;
|
|
|
d1681e |
|
|
|
d1681e |
p = port;
|
|
|
d1681e |
@@ -297,7 +299,7 @@ pmap_registry_extend (xlator_t *this, int port, const char *brickname)
|
|
|
d1681e |
|
|
|
d1681e |
pmap = pmap_registry_get (this);
|
|
|
d1681e |
|
|
|
d1681e |
- if (port > GF_PORT_MAX) {
|
|
|
d1681e |
+ if (port > pmap->max_port) {
|
|
|
d1681e |
return -1;
|
|
|
d1681e |
}
|
|
|
d1681e |
|
|
|
d1681e |
@@ -357,7 +359,7 @@ pmap_registry_remove (xlator_t *this, int port, const char *brickname,
|
|
|
d1681e |
goto out;
|
|
|
d1681e |
|
|
|
d1681e |
if (port) {
|
|
|
d1681e |
- if (port > GF_PORT_MAX)
|
|
|
d1681e |
+ if (port > pmap->max_port)
|
|
|
d1681e |
goto out;
|
|
|
d1681e |
|
|
|
d1681e |
p = port;
|
|
|
d1681e |
diff --git a/xlators/mgmt/glusterd/src/glusterd-pmap.h b/xlators/mgmt/glusterd/src/glusterd-pmap.h
|
|
|
d1681e |
index 253b4cc..f642d66 100644
|
|
|
d1681e |
--- a/xlators/mgmt/glusterd/src/glusterd-pmap.h
|
|
|
d1681e |
+++ b/xlators/mgmt/glusterd/src/glusterd-pmap.h
|
|
|
d1681e |
@@ -31,8 +31,9 @@ struct pmap_port_status {
|
|
|
d1681e |
|
|
|
d1681e |
struct pmap_registry {
|
|
|
d1681e |
int base_port;
|
|
|
d1681e |
+ int max_port;
|
|
|
d1681e |
int last_alloc;
|
|
|
d1681e |
- struct pmap_port_status ports[65536];
|
|
|
d1681e |
+ struct pmap_port_status ports[GF_PORT_MAX + 1];
|
|
|
d1681e |
};
|
|
|
d1681e |
|
|
|
d1681e |
int pmap_assign_port (xlator_t *this, int port, const char *path);
|
|
|
d1681e |
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c b/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c
|
|
|
d1681e |
index 59d8fbd..5621852 100644
|
|
|
d1681e |
--- a/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c
|
|
|
d1681e |
+++ b/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c
|
|
|
d1681e |
@@ -300,6 +300,14 @@ glusterd_snapdsvc_start (glusterd_svc_t *svc, int flags)
|
|
|
d1681e |
"-S", svc->conn.sockpath, NULL);
|
|
|
d1681e |
|
|
|
d1681e |
snapd_port = pmap_assign_port (THIS, volinfo->snapd.port, snapd_id);
|
|
|
d1681e |
+ if (!snapd_port) {
|
|
|
d1681e |
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_PORTS_EXHAUSTED,
|
|
|
d1681e |
+ "All the ports in the range are exhausted, can't start "
|
|
|
d1681e |
+ "snapd for volume %s", volinfo->volname);
|
|
|
d1681e |
+ ret = -1;
|
|
|
d1681e |
+ goto out;
|
|
|
d1681e |
+ }
|
|
|
d1681e |
+
|
|
|
d1681e |
volinfo->snapd.port = snapd_port;
|
|
|
d1681e |
|
|
|
d1681e |
runner_add_arg (&runner, "--brick-port");
|
|
|
d1681e |
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
|
|
|
d1681e |
index 18de517..55c4fa7 100644
|
|
|
d1681e |
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
|
|
|
d1681e |
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
|
|
|
d1681e |
@@ -2002,7 +2002,14 @@ glusterd_volume_start_glusterfs (glusterd_volinfo_t *volinfo,
|
|
|
d1681e |
}
|
|
|
d1681e |
|
|
|
d1681e |
port = pmap_assign_port (THIS, brickinfo->port, brickinfo->path);
|
|
|
d1681e |
-
|
|
|
d1681e |
+ if (!port) {
|
|
|
d1681e |
+ gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_PORTS_EXHAUSTED,
|
|
|
d1681e |
+ "All the ports in the range are exhausted, can't start "
|
|
|
d1681e |
+ "brick %s for volume %s", brickinfo->path,
|
|
|
d1681e |
+ volinfo->volname);
|
|
|
d1681e |
+ ret = -1;
|
|
|
d1681e |
+ goto out;
|
|
|
d1681e |
+ }
|
|
|
d1681e |
/* Build the exp_path, before starting the glusterfsd even in
|
|
|
d1681e |
valgrind mode. Otherwise all the glusterfsd processes start
|
|
|
d1681e |
writing the valgrind log to the same file.
|
|
|
d1681e |
@@ -2076,6 +2083,15 @@ retry:
|
|
|
d1681e |
brickinfo->path);
|
|
|
d1681e |
rdma_port = pmap_assign_port (THIS, brickinfo->rdma_port,
|
|
|
d1681e |
rdma_brick_path);
|
|
|
d1681e |
+ if (!rdma_port) {
|
|
|
d1681e |
+ gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
d1681e |
+ GD_MSG_PORTS_EXHAUSTED, "All rdma ports in the "
|
|
|
d1681e |
+ "range are exhausted, can't start brick %s for "
|
|
|
d1681e |
+ "volume %s", rdma_brick_path,
|
|
|
d1681e |
+ volinfo->volname);
|
|
|
d1681e |
+ ret = -1;
|
|
|
d1681e |
+ goto out;
|
|
|
d1681e |
+ }
|
|
|
d1681e |
runner_argprintf (&runner, "%d,%d", port, rdma_port);
|
|
|
d1681e |
runner_add_arg (&runner, "--xlator-option");
|
|
|
d1681e |
runner_argprintf (&runner, "%s-server.transport.rdma.listen-port=%d",
|
|
|
d1681e |
diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c
|
|
|
d1681e |
index 81a3206..68d3e90 100644
|
|
|
d1681e |
--- a/xlators/mgmt/glusterd/src/glusterd.c
|
|
|
d1681e |
+++ b/xlators/mgmt/glusterd/src/glusterd.c
|
|
|
d1681e |
@@ -1824,12 +1824,20 @@ init (xlator_t *this)
|
|
|
d1681e |
if (ret)
|
|
|
d1681e |
goto out;
|
|
|
d1681e |
|
|
|
d1681e |
- conf->base_port = GF_IANA_PRIV_PORTS_START;
|
|
|
d1681e |
- if (dict_get_uint32(this->options, "base-port", &conf->base_port) == 0) {
|
|
|
d1681e |
+ conf->base_port = GF_IANA_PRIV_PORTS_START;
|
|
|
d1681e |
+ if (dict_get_uint32 (this->options, "base-port",
|
|
|
d1681e |
+ &conf->base_port) == 0) {
|
|
|
d1681e |
gf_msg (this->name, GF_LOG_INFO, 0,
|
|
|
d1681e |
GD_MSG_DICT_SET_FAILED,
|
|
|
d1681e |
"base-port override: %d", conf->base_port);
|
|
|
d1681e |
}
|
|
|
d1681e |
+ conf->max_port = GF_PORT_MAX;
|
|
|
d1681e |
+ if (dict_get_uint32 (this->options, "max-port",
|
|
|
d1681e |
+ &conf->max_port) == 0) {
|
|
|
d1681e |
+ gf_msg (this->name, GF_LOG_INFO, 0,
|
|
|
d1681e |
+ GD_MSG_DICT_SET_FAILED,
|
|
|
d1681e |
+ "max-port override: %d", conf->max_port);
|
|
|
d1681e |
+ }
|
|
|
d1681e |
|
|
|
d1681e |
/* Set option to run bricks on valgrind if enabled in glusterd.vol */
|
|
|
d1681e |
this->ctx->cmd_args.valgrind = valgrind;
|
|
|
d1681e |
@@ -2135,6 +2143,11 @@ struct volume_options options[] = {
|
|
|
d1681e |
.type = GF_OPTION_TYPE_INT,
|
|
|
d1681e |
.description = "Sets the base port for portmap query"
|
|
|
d1681e |
},
|
|
|
d1681e |
+ { .key = {"max-port"},
|
|
|
d1681e |
+ .type = GF_OPTION_TYPE_INT,
|
|
|
d1681e |
+ .max = GF_PORT_MAX,
|
|
|
d1681e |
+ .description = "Sets the max port for portmap query"
|
|
|
d1681e |
+ },
|
|
|
d1681e |
{ .key = {"snap-brick-path"},
|
|
|
d1681e |
.type = GF_OPTION_TYPE_STR,
|
|
|
d1681e |
.description = "directory where the bricks for the snapshots will be created"
|
|
|
d1681e |
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
|
|
|
d1681e |
index d4bb236..291f2f7 100644
|
|
|
d1681e |
--- a/xlators/mgmt/glusterd/src/glusterd.h
|
|
|
d1681e |
+++ b/xlators/mgmt/glusterd/src/glusterd.h
|
|
|
d1681e |
@@ -187,6 +187,7 @@ typedef struct {
|
|
|
d1681e |
gf_boolean_t restart_done;
|
|
|
d1681e |
rpcsvc_t *uds_rpc; /* RPCSVC for the unix domain socket */
|
|
|
d1681e |
uint32_t base_port;
|
|
|
d1681e |
+ uint32_t max_port;
|
|
|
d1681e |
char *snap_bricks_directory;
|
|
|
d1681e |
gf_store_handle_t *missed_snaps_list_shandle;
|
|
|
d1681e |
struct cds_list_head missed_snaps_list;
|
|
|
d1681e |
--
|
|
|
d1681e |
1.8.3.1
|
|
|
d1681e |
|