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 --- rpc/rpc-transport/rdma/src/name.c | 12 ++++++------ rpc/rpc-transport/socket/src/name.c | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'rpc') diff --git a/rpc/rpc-transport/rdma/src/name.c b/rpc/rpc-transport/rdma/src/name.c index 8003b1c87a0..5064427e01e 100644 --- a/rpc/rpc-transport/rdma/src/name.c +++ b/rpc/rpc-transport/rdma/src/name.c @@ -54,10 +54,10 @@ af_inet_bind_to_port_lt_ceiling (struct rdma_cm_id *cm_id, struct sockaddr *sockaddr, socklen_t sockaddr_len, uint32_t ceiling) { - int32_t ret = -1; - uint16_t port = ceiling - 1; - gf_boolean_t ports[GF_PORT_MAX]; - int i = 0; + int32_t ret = -1; + uint16_t port = ceiling - 1; + unsigned char ports[GF_PORT_ARRAY_SIZE] = {0,}; + int i = 0; loop: ret = gf_process_reserved_ports (ports, ceiling); @@ -69,7 +69,7 @@ loop: } /* ignore the reserved ports */ - if (ports[port] == _gf_true) { + if (BIT_VALUE (ports, port)) { port--; continue; } @@ -95,7 +95,7 @@ loop: if (!port) { ceiling = port = GF_CLNT_INSECURE_PORT_CEILING; for (i = 0; i <= ceiling; i++) - ports[i] = _gf_false; + BIT_CLEAR (ports, i); goto loop; } diff --git a/rpc/rpc-transport/socket/src/name.c b/rpc/rpc-transport/socket/src/name.c index 0e34dc211fe..acd1dc7b55e 100644 --- a/rpc/rpc-transport/socket/src/name.c +++ b/rpc/rpc-transport/socket/src/name.c @@ -42,10 +42,10 @@ static int32_t af_inet_bind_to_port_lt_ceiling (int fd, struct sockaddr *sockaddr, socklen_t sockaddr_len, uint32_t ceiling) { - int32_t ret = -1; - uint16_t port = ceiling - 1; - gf_boolean_t ports[GF_PORT_MAX]; - int i = 0; + int32_t ret = -1; + uint16_t port = ceiling - 1; + unsigned char ports[GF_PORT_ARRAY_SIZE] = {0,}; + int i = 0; loop: ret = gf_process_reserved_ports (ports, ceiling); @@ -57,7 +57,7 @@ loop: } /* ignore the reserved ports */ - if (ports[port] == _gf_true) { + if (BIT_VALUE (ports, port)) { port--; continue; } @@ -83,7 +83,7 @@ loop: if (!port) { ceiling = port = GF_CLNT_INSECURE_PORT_CEILING; for (i = 0; i <= ceiling; i++) - ports[i] = _gf_false; + BIT_CLEAR (ports, i); goto loop; } -- cgit