diff options
author | Jeff Darcy <jdarcy@redhat.com> | 2016-10-27 11:51:47 -0400 |
---|---|---|
committer | Shyamsundar Ranganathan <srangana@redhat.com> | 2017-02-02 12:32:49 -0500 |
commit | c10507ce75547a7a7899fbf36be650ddc89ba467 (patch) | |
tree | 52d68f08ab01ee91454c254dd60fa268dfd70089 /libglusterfs/src/common-utils.h | |
parent | 83803b4b2d70e9e6e16bb050d7ac8e49ba420893 (diff) |
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.
Backport of:
> Change-Id: I8781c4f2c8f2b830f4535e366995fac8dd0a8653
> BUG: 1418095
> Reviewed-on: https://review.gluster.org/15745
Change-Id: Ia5dada61703e6bea95f2511da71feb573fc9a429
BUG: 1418536
Signed-off-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-on: https://review.gluster.org/16511
Reviewed-by: N Balachandran <nbalacha@redhat.com>
Smoke: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Diffstat (limited to 'libglusterfs/src/common-utils.h')
-rw-r--r-- | libglusterfs/src/common-utils.h | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h index b77b7ad97de..dbd2489ec8c 100644 --- a/libglusterfs/src/common-utils.h +++ b/libglusterfs/src/common-utils.h @@ -100,6 +100,7 @@ void trap (void); #define GF_IANA_PRIV_PORTS_START 49152 /* RFC 6335 */ #define GF_CLNT_INSECURE_PORT_CEILING (GF_IANA_PRIV_PORTS_START - 1) #define GF_PORT_MAX 65535 +#define GF_PORT_ARRAY_SIZE ((GF_PORT_MAX + 7) / 8) #define GF_MINUTE_IN_SECONDS 60 #define GF_HOUR_IN_SECONDS (60*60) @@ -237,6 +238,33 @@ void gf_print_trace (int32_t signal, glusterfs_ctx_t *ctx); int gf_set_log_file_path (cmd_args_t *cmd_args, glusterfs_ctx_t *ctx); int gf_set_log_ident (cmd_args_t *cmd_args); +static inline void +BIT_SET (unsigned char *array, unsigned int index) +{ + unsigned int offset = index / 8; + unsigned int shift = index % 8; + + array[offset] |= (1 << shift); +} + +static inline void +BIT_CLEAR (unsigned char *array, unsigned int index) +{ + unsigned int offset = index / 8; + unsigned int shift = index % 8; + + array[offset] &= ~(1 << shift); +} + +static inline unsigned int +BIT_VALUE (unsigned char *array, unsigned int index) +{ + unsigned int offset = index / 8; + unsigned int shift = index % 8; + + return (array[offset] >> shift) & 0x1; +} + #define VECTORSIZE(count) (count * (sizeof (struct iovec))) #define STRLEN_0(str) (strlen(str) + 1) @@ -780,9 +808,9 @@ int gf_strip_whitespace (char *str, int len); int gf_canonicalize_path (char *path); char *generate_glusterfs_ctx_id (void); char *gf_get_reserved_ports(void); -int gf_process_reserved_ports (gf_boolean_t ports[], uint32_t ceiling); +int gf_process_reserved_ports (unsigned char *ports, uint32_t ceiling); 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); int gf_get_hostname_from_ip (char *client_ip, char **hostname); gf_boolean_t gf_is_local_addr (char *hostname); gf_boolean_t gf_is_same_address (char *host1, char *host2); |