From 0a20e56d07de3e467e09da885a6b71cdc165de17 Mon Sep 17 00:00:00 2001 From: Mohammed Rafi KC Date: Mon, 29 May 2017 16:00:24 +0530 Subject: protocol/server: make listen backlog value as configurable problem: When we call listen from protocol/server, we are giving a hard coded valie of 10 if it is not manually given. With multiplexing, especially when glusterd restarts all clients may try to connect to the server at a time. Which will result in overflowing the queue, and kernel will complain about the errors. Solution: This patch will introduce a volume set command to make backlog value as a configurable. This patch also changes the default values for backlog from 10 to 128. This changes is only applicable for sockets listening from protocol. Example: gluster volume set transport.listen-backlog 1024 Note: 1 Brick has to be restarted to get this value in effect 2 This changes won't be reflected in glusterd, or other xlators which calls listen. If you need, you have to add this option to the volfile. Change-Id: I0c5a2bbf28b5db612f9979e7560e05dd82b41477 BUG: 1456405 Signed-off-by: Mohammed Rafi KC Reviewed-on: https://review.gluster.org/17411 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Raghavendra G Reviewed-by: Raghavendra Talur Reviewed-by: Atin Mukherjee Reviewed-by: Niels de Vos Reviewed-by: Jeff Darcy --- xlators/mgmt/glusterd/src/glusterd-volume-set.c | 56 +++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'xlators/mgmt/glusterd/src/glusterd-volume-set.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c index d42a0ce47e8..900d4be2068 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c @@ -714,6 +714,52 @@ out: return ret; } +static int +validate_server_options (glusterd_volinfo_t *volinfo, dict_t *dict, char *key, + char *value, char **op_errstr) +{ + char errstr[2048] = ""; + xlator_t *this = NULL; + int ret = -1; + int origin_val = 0; + + this = THIS; + GF_ASSERT (this); + + if (volinfo->status == GLUSTERD_STATUS_STARTED) { + gf_msg (this->name, GF_LOG_INFO, 0, + GD_MSG_VOL_SET_VALIDATION_INFO, "Please note that " + "volume %s is started. This option will only get " + "effected after a brick restart.", volinfo->volname); + } + + ret = gf_string2int (value, &origin_val); + if (ret) { + snprintf (errstr, sizeof (errstr), "%s is not a compatible " + "value. %s expects an integer value.", value, key); + ret = -1; + goto out; + } + + if (origin_val < 0) { + snprintf (errstr, sizeof (errstr), "%s is not a " + "compatible value. %s expects a positive" + "integer value.", value, key); + ret = -1; + goto out; + } + + ret = 0; +out: + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, EINVAL, + GD_MSG_INCOMPATIBLE_VALUE, "%s", errstr); + *op_errstr = gf_strdup (errstr); + } + + return ret; +} + static int validate_stripe (glusterd_volinfo_t *volinfo, dict_t *dict, char *key, char *value, char **op_errstr) @@ -1969,6 +2015,16 @@ struct volopt_map_entry glusterd_volopt_map[] = { .op_version = GD_OP_VERSION_3_10_2, .value = "9", }, + { .key = "transport.listen-backlog", + .voltype = "protocol/server", + .option = "transport.listen-backlog", + .op_version = GD_OP_VERSION_3_11_1, + .validate_fn = validate_server_options, + .description = "This option uses the value of backlog argument that " + "defines the maximum length to which the queue of " + "pending connections for socket fd may grow.", + .value = "10", + }, /* Generic transport options */ { .key = SSL_OWN_CERT_OPT, -- cgit