|
|
21ab4e |
From 564fe08f7819b5a6fd75b6c7fa5181fa8fcdce62 Mon Sep 17 00:00:00 2001
|
|
|
21ab4e |
From: Jeff Darcy <jdarcy@redhat.com>
|
|
|
21ab4e |
Date: Thu, 27 Oct 2016 11:51:47 -0400
|
|
|
21ab4e |
Subject: [PATCH 320/361] libglusterfs+transport+io-threads: fix 256KB stack
|
|
|
21ab4e |
abuse
|
|
|
21ab4e |
|
|
|
21ab4e |
Some functions were allocating 64K booleans, which are (crazily) mapped to
|
|
|
21ab4e |
4-byte ints, for a total of 256KB per call. Changed to use bitfields instead,
|
|
|
21ab4e |
so usage is now only 8KB per call. This was the impediment to changing the
|
|
|
21ab4e |
io-threads stack size, so that has been adjusted too.
|
|
|
21ab4e |
|
|
|
21ab4e |
mainline:
|
|
|
21ab4e |
> BUG: 1418095
|
|
|
21ab4e |
> Reviewed-on: https://review.gluster.org/15745
|
|
|
21ab4e |
> Smoke: Gluster Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
> Reviewed-by: N Balachandran <nbalacha@redhat.com>
|
|
|
21ab4e |
> Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
|
|
|
21ab4e |
(cherry picked from commit 17d25a2a42eebd4b60c03c8f5a315f953d2c03fe)
|
|
|
21ab4e |
|
|
|
21ab4e |
BUG: 1417815
|
|
|
21ab4e |
Change-Id: I8781c4f2c8f2b830f4535e366995fac8dd0a8653
|
|
|
21ab4e |
Signed-off-by: Jeff Darcy <jdarcy@redhat.com>
|
|
|
21ab4e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/101301
|
|
|
21ab4e |
Tested-by: Milind Changire <mchangir@redhat.com>
|
|
|
21ab4e |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
21ab4e |
---
|
|
|
21ab4e |
libglusterfs/src/common-utils.c | 13 ++++------
|
|
|
21ab4e |
libglusterfs/src/common-utils.h | 34 ++++++++++++++++++++++---
|
|
|
21ab4e |
rpc/rpc-transport/rdma/src/name.c | 12 ++++-----
|
|
|
21ab4e |
rpc/rpc-transport/socket/src/name.c | 12 ++++-----
|
|
|
21ab4e |
xlators/performance/io-threads/src/io-threads.h | 2 +-
|
|
|
21ab4e |
5 files changed, 49 insertions(+), 24 deletions(-)
|
|
|
21ab4e |
|
|
|
21ab4e |
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
|
|
|
21ab4e |
index e17dd3f..e335e94 100644
|
|
|
21ab4e |
--- a/libglusterfs/src/common-utils.c
|
|
|
21ab4e |
+++ b/libglusterfs/src/common-utils.c
|
|
|
21ab4e |
@@ -3006,14 +3006,11 @@ out:
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
int
|
|
|
21ab4e |
-gf_process_reserved_ports (gf_boolean_t *ports, uint32_t ceiling)
|
|
|
21ab4e |
+gf_process_reserved_ports (unsigned char *ports, uint32_t ceiling)
|
|
|
21ab4e |
{
|
|
|
21ab4e |
int ret = -1;
|
|
|
21ab4e |
- int i = 0;
|
|
|
21ab4e |
|
|
|
21ab4e |
- for (i = 0; i < GF_PORT_MAX; i++) {
|
|
|
21ab4e |
- *(ports + i) = _gf_false;
|
|
|
21ab4e |
- }
|
|
|
21ab4e |
+ memset (ports, 0, GF_PORT_ARRAY_SIZE);
|
|
|
21ab4e |
|
|
|
21ab4e |
#if defined GF_LINUX_HOST_OS
|
|
|
21ab4e |
char *ports_info = NULL;
|
|
|
21ab4e |
@@ -3049,7 +3046,7 @@ out:
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
gf_boolean_t
|
|
|
21ab4e |
-gf_ports_reserved (char *blocked_port, gf_boolean_t *ports, uint32_t ceiling)
|
|
|
21ab4e |
+gf_ports_reserved (char *blocked_port, unsigned char *ports, uint32_t ceiling)
|
|
|
21ab4e |
{
|
|
|
21ab4e |
gf_boolean_t result = _gf_false;
|
|
|
21ab4e |
char *range_port = NULL;
|
|
|
21ab4e |
@@ -3071,7 +3068,7 @@ gf_ports_reserved (char *blocked_port, gf_boolean_t *ports, uint32_t ceiling)
|
|
|
21ab4e |
} else {
|
|
|
21ab4e |
gf_msg_debug ("glusterfs", 0, "blocking port "
|
|
|
21ab4e |
"%d", tmp_port1);
|
|
|
21ab4e |
- ports[tmp_port1] = _gf_true;
|
|
|
21ab4e |
+ BIT_SET (ports, tmp_port1);
|
|
|
21ab4e |
}
|
|
|
21ab4e |
} else {
|
|
|
21ab4e |
gf_msg ("glusterfs-socket", GF_LOG_WARNING, 0,
|
|
|
21ab4e |
@@ -3109,7 +3106,7 @@ gf_ports_reserved (char *blocked_port, gf_boolean_t *ports, uint32_t ceiling)
|
|
|
21ab4e |
gf_msg_debug ("glusterfs", 0, "lower: %d, higher: %d",
|
|
|
21ab4e |
tmp_port1, tmp_port2);
|
|
|
21ab4e |
for (; tmp_port1 <= tmp_port2; tmp_port1++)
|
|
|
21ab4e |
- ports[tmp_port1] = _gf_true;
|
|
|
21ab4e |
+ BIT_SET (ports, tmp_port1);
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
out:
|
|
|
21ab4e |
diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h
|
|
|
21ab4e |
index ccda0d9..9109de9 100644
|
|
|
21ab4e |
--- a/libglusterfs/src/common-utils.h
|
|
|
21ab4e |
+++ b/libglusterfs/src/common-utils.h
|
|
|
21ab4e |
@@ -98,6 +98,7 @@ void trap (void);
|
|
|
21ab4e |
#define GF_IANA_PRIV_PORTS_START 49152 /* RFC 6335 */
|
|
|
21ab4e |
#define GF_CLNT_INSECURE_PORT_CEILING (GF_IANA_PRIV_PORTS_START - 1)
|
|
|
21ab4e |
#define GF_PORT_MAX 65535
|
|
|
21ab4e |
+#define GF_PORT_ARRAY_SIZE ((GF_PORT_MAX + 7) / 8)
|
|
|
21ab4e |
|
|
|
21ab4e |
#define GF_MINUTE_IN_SECONDS 60
|
|
|
21ab4e |
#define GF_HOUR_IN_SECONDS (60*60)
|
|
|
21ab4e |
@@ -233,6 +234,33 @@ void gf_print_trace (int32_t signal, glusterfs_ctx_t *ctx);
|
|
|
21ab4e |
int gf_set_log_file_path (cmd_args_t *cmd_args, glusterfs_ctx_t *ctx);
|
|
|
21ab4e |
int gf_set_log_ident (cmd_args_t *cmd_args);
|
|
|
21ab4e |
|
|
|
21ab4e |
+static inline void
|
|
|
21ab4e |
+BIT_SET (unsigned char *array, unsigned int index)
|
|
|
21ab4e |
+{
|
|
|
21ab4e |
+ unsigned int offset = index / 8;
|
|
|
21ab4e |
+ unsigned int shift = index % 8;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ array[offset] |= (1 << shift);
|
|
|
21ab4e |
+}
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+static inline void
|
|
|
21ab4e |
+BIT_CLEAR (unsigned char *array, unsigned int index)
|
|
|
21ab4e |
+{
|
|
|
21ab4e |
+ unsigned int offset = index / 8;
|
|
|
21ab4e |
+ unsigned int shift = index % 8;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ array[offset] &= ~(1 << shift);
|
|
|
21ab4e |
+}
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+static inline unsigned int
|
|
|
21ab4e |
+BIT_VALUE (unsigned char *array, unsigned int index)
|
|
|
21ab4e |
+{
|
|
|
21ab4e |
+ unsigned int offset = index / 8;
|
|
|
21ab4e |
+ unsigned int shift = index % 8;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ return (array[offset] >> shift) & 0x1;
|
|
|
21ab4e |
+}
|
|
|
21ab4e |
+
|
|
|
21ab4e |
#define VECTORSIZE(count) (count * (sizeof (struct iovec)))
|
|
|
21ab4e |
|
|
|
21ab4e |
#define STRLEN_0(str) (strlen(str) + 1)
|
|
|
21ab4e |
@@ -769,10 +797,10 @@ uint64_t get_mem_size ();
|
|
|
21ab4e |
int gf_strip_whitespace (char *str, int len);
|
|
|
21ab4e |
int gf_canonicalize_path (char *path);
|
|
|
21ab4e |
char *generate_glusterfs_ctx_id (void);
|
|
|
21ab4e |
-char *gf_get_reserved_ports();
|
|
|
21ab4e |
-int gf_process_reserved_ports (gf_boolean_t ports[], uint32_t ceiling);
|
|
|
21ab4e |
+char *gf_get_reserved_ports(void);
|
|
|
21ab4e |
+int gf_process_reserved_ports (unsigned char *ports, uint32_t ceiling);
|
|
|
21ab4e |
gf_boolean_t
|
|
|
21ab4e |
-gf_ports_reserved (char *blocked_port, gf_boolean_t *ports, uint32_t ceiling);
|
|
|
21ab4e |
+gf_ports_reserved (char *blocked_port, unsigned char *ports, uint32_t ceiling);
|
|
|
21ab4e |
int gf_get_hostname_from_ip (char *client_ip, char **hostname);
|
|
|
21ab4e |
gf_boolean_t gf_is_local_addr (char *hostname);
|
|
|
21ab4e |
gf_boolean_t gf_is_same_address (char *host1, char *host2);
|
|
|
21ab4e |
diff --git a/rpc/rpc-transport/rdma/src/name.c b/rpc/rpc-transport/rdma/src/name.c
|
|
|
21ab4e |
index 8003b1c..5064427 100644
|
|
|
21ab4e |
--- a/rpc/rpc-transport/rdma/src/name.c
|
|
|
21ab4e |
+++ b/rpc/rpc-transport/rdma/src/name.c
|
|
|
21ab4e |
@@ -54,10 +54,10 @@ af_inet_bind_to_port_lt_ceiling (struct rdma_cm_id *cm_id,
|
|
|
21ab4e |
struct sockaddr *sockaddr,
|
|
|
21ab4e |
socklen_t sockaddr_len, uint32_t ceiling)
|
|
|
21ab4e |
{
|
|
|
21ab4e |
- int32_t ret = -1;
|
|
|
21ab4e |
- uint16_t port = ceiling - 1;
|
|
|
21ab4e |
- gf_boolean_t ports[GF_PORT_MAX];
|
|
|
21ab4e |
- int i = 0;
|
|
|
21ab4e |
+ int32_t ret = -1;
|
|
|
21ab4e |
+ uint16_t port = ceiling - 1;
|
|
|
21ab4e |
+ unsigned char ports[GF_PORT_ARRAY_SIZE] = {0,};
|
|
|
21ab4e |
+ int i = 0;
|
|
|
21ab4e |
|
|
|
21ab4e |
loop:
|
|
|
21ab4e |
ret = gf_process_reserved_ports (ports, ceiling);
|
|
|
21ab4e |
@@ -69,7 +69,7 @@ loop:
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
/* ignore the reserved ports */
|
|
|
21ab4e |
- if (ports[port] == _gf_true) {
|
|
|
21ab4e |
+ if (BIT_VALUE (ports, port)) {
|
|
|
21ab4e |
port--;
|
|
|
21ab4e |
continue;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
@@ -95,7 +95,7 @@ loop:
|
|
|
21ab4e |
if (!port) {
|
|
|
21ab4e |
ceiling = port = GF_CLNT_INSECURE_PORT_CEILING;
|
|
|
21ab4e |
for (i = 0; i <= ceiling; i++)
|
|
|
21ab4e |
- ports[i] = _gf_false;
|
|
|
21ab4e |
+ BIT_CLEAR (ports, i);
|
|
|
21ab4e |
goto loop;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
diff --git a/rpc/rpc-transport/socket/src/name.c b/rpc/rpc-transport/socket/src/name.c
|
|
|
21ab4e |
index 0e34dc2..acd1dc7 100644
|
|
|
21ab4e |
--- a/rpc/rpc-transport/socket/src/name.c
|
|
|
21ab4e |
+++ b/rpc/rpc-transport/socket/src/name.c
|
|
|
21ab4e |
@@ -42,10 +42,10 @@ static int32_t
|
|
|
21ab4e |
af_inet_bind_to_port_lt_ceiling (int fd, struct sockaddr *sockaddr,
|
|
|
21ab4e |
socklen_t sockaddr_len, uint32_t ceiling)
|
|
|
21ab4e |
{
|
|
|
21ab4e |
- int32_t ret = -1;
|
|
|
21ab4e |
- uint16_t port = ceiling - 1;
|
|
|
21ab4e |
- gf_boolean_t ports[GF_PORT_MAX];
|
|
|
21ab4e |
- int i = 0;
|
|
|
21ab4e |
+ int32_t ret = -1;
|
|
|
21ab4e |
+ uint16_t port = ceiling - 1;
|
|
|
21ab4e |
+ unsigned char ports[GF_PORT_ARRAY_SIZE] = {0,};
|
|
|
21ab4e |
+ int i = 0;
|
|
|
21ab4e |
|
|
|
21ab4e |
loop:
|
|
|
21ab4e |
ret = gf_process_reserved_ports (ports, ceiling);
|
|
|
21ab4e |
@@ -57,7 +57,7 @@ loop:
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
/* ignore the reserved ports */
|
|
|
21ab4e |
- if (ports[port] == _gf_true) {
|
|
|
21ab4e |
+ if (BIT_VALUE (ports, port)) {
|
|
|
21ab4e |
port--;
|
|
|
21ab4e |
continue;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
@@ -83,7 +83,7 @@ loop:
|
|
|
21ab4e |
if (!port) {
|
|
|
21ab4e |
ceiling = port = GF_CLNT_INSECURE_PORT_CEILING;
|
|
|
21ab4e |
for (i = 0; i <= ceiling; i++)
|
|
|
21ab4e |
- ports[i] = _gf_false;
|
|
|
21ab4e |
+ BIT_CLEAR (ports, i);
|
|
|
21ab4e |
goto loop;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
diff --git a/xlators/performance/io-threads/src/io-threads.h b/xlators/performance/io-threads/src/io-threads.h
|
|
|
21ab4e |
index fa955b5..2ba2e8e 100644
|
|
|
21ab4e |
--- a/xlators/performance/io-threads/src/io-threads.h
|
|
|
21ab4e |
+++ b/xlators/performance/io-threads/src/io-threads.h
|
|
|
21ab4e |
@@ -37,7 +37,7 @@ struct iot_conf;
|
|
|
21ab4e |
#define IOT_MAX_THREADS 64
|
|
|
21ab4e |
|
|
|
21ab4e |
|
|
|
21ab4e |
-#define IOT_THREAD_STACK_SIZE ((size_t)(1024*1024))
|
|
|
21ab4e |
+#define IOT_THREAD_STACK_SIZE ((size_t)(256*1024))
|
|
|
21ab4e |
|
|
|
21ab4e |
|
|
|
21ab4e |
typedef enum {
|
|
|
21ab4e |
--
|
|
|
21ab4e |
1.8.3.1
|
|
|
21ab4e |
|