From c8a23cc6cd289dd28deb136bf2550f28e2761ef3 Mon Sep 17 00:00:00 2001 From: Jeff Darcy Date: Thu, 27 Oct 2016 11:51:47 -0400 Subject: libglusterfs+transport+io-threads: fix 256KB stack abuse Some functions were allocating 64K booleans, which are (crazily) mapped to 4-byte ints, for a total of 256KB per call. Changed to use bitfields instead, so usage is now only 8KB per call. This was the impediment to changing the io-threads stack size, so that has been adjusted too. Change-Id: I8781c4f2c8f2b830f4535e366995fac8dd0a8653 BUG: 1418095 Signed-off-by: Jeff Darcy Reviewed-on: https://review.gluster.org/15745 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: N Balachandran Reviewed-by: Shyamsundar Ranganathan --- libglusterfs/src/common-utils.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'libglusterfs/src/common-utils.c') diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index e180dd3eec0..c0884de8a5e 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -3005,14 +3005,11 @@ out: } int -gf_process_reserved_ports (gf_boolean_t *ports, uint32_t ceiling) +gf_process_reserved_ports (unsigned char *ports, uint32_t ceiling) { int ret = -1; - int i = 0; - for (i = 0; i < GF_PORT_MAX; i++) { - *(ports + i) = _gf_false; - } + memset (ports, 0, GF_PORT_ARRAY_SIZE); #if defined GF_LINUX_HOST_OS char *ports_info = NULL; @@ -3048,7 +3045,7 @@ out: } gf_boolean_t -gf_ports_reserved (char *blocked_port, gf_boolean_t *ports, uint32_t ceiling) +gf_ports_reserved (char *blocked_port, unsigned char *ports, uint32_t ceiling) { gf_boolean_t result = _gf_false; char *range_port = NULL; @@ -3070,7 +3067,7 @@ gf_ports_reserved (char *blocked_port, gf_boolean_t *ports, uint32_t ceiling) } else { gf_msg_debug ("glusterfs", 0, "blocking port " "%d", tmp_port1); - ports[tmp_port1] = _gf_true; + BIT_SET (ports, tmp_port1); } } else { gf_msg ("glusterfs-socket", GF_LOG_WARNING, 0, @@ -3108,7 +3105,7 @@ gf_ports_reserved (char *blocked_port, gf_boolean_t *ports, uint32_t ceiling) gf_msg_debug ("glusterfs", 0, "lower: %d, higher: %d", tmp_port1, tmp_port2); for (; tmp_port1 <= tmp_port2; tmp_port1++) - ports[tmp_port1] = _gf_true; + BIT_SET (ports, tmp_port1); } out: -- cgit