diff options
author | Rajesh Amaravathi <rajesh@redhat.com> | 2012-02-22 14:51:53 +0530 |
---|---|---|
committer | Vijay Bellur <vijay@gluster.com> | 2012-02-29 02:10:44 -0800 |
commit | 2da18b6724b7daf7c3a973515fc3d59e7d2c4622 (patch) | |
tree | 3af50b4e3040fd562a0383209a184b625a093522 /rpc/rpc-transport/socket/src/socket.c | |
parent | 5ad1c2caed743fc10a0645055a825252dfbf77ba (diff) |
transport/socket: configuring tcp window-size
Till now, send and recieve buffer window sizes for sockets
were set to a default glusterfs-specific value.
Linux's default window sizes have been found to be better
w.r.t performance, and hence, no more setting it to any
default value.
However, if one wishes, there's the new configuration option:
network.tcp-window-size <sane_size>
which takes a size value (int or human readable) and will set
the window size of sockets for both clients and servers.
Nfs clients will also be updated with the same.
Change-Id: I841479bbaea791b01086c42f58401ed297ff16ea
BUG: 795635
Signed-off-by: Rajesh Amaravathi <rajesh@redhat.com>
Reviewed-on: http://review.gluster.com/2821
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'rpc/rpc-transport/socket/src/socket.c')
-rw-r--r-- | rpc/rpc-transport/socket/src/socket.c | 106 |
1 files changed, 59 insertions, 47 deletions
diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c index 120e193dd..615f69f1b 100644 --- a/rpc/rpc-transport/socket/src/socket.c +++ b/rpc/rpc-transport/socket/src/socket.c @@ -2048,30 +2048,24 @@ socket_connect (rpc_transport_t *this, int port) /* Cant help if setting socket options fails. We can continue * working nonetheless. */ - if (setsockopt (priv->sock, SOL_SOCKET, SO_RCVBUF, - &priv->windowsize, - sizeof (priv->windowsize)) < 0) { - gf_log (this->name, GF_LOG_ERROR, - "setting receive window size failed: %d: %d: " - "%s", priv->sock, priv->windowsize, - strerror (errno)); - } - - if (setsockopt (priv->sock, SOL_SOCKET, SO_SNDBUF, - &priv->windowsize, - sizeof (priv->windowsize)) < 0) { - gf_log (this->name, GF_LOG_ERROR, - "setting send window size failed: %d: %d: " - "%s", priv->sock, priv->windowsize, - strerror (errno)); - } - + if (priv->windowsize != 0) { + if (setsockopt (priv->sock, SOL_SOCKET, SO_RCVBUF, + &priv->windowsize, + sizeof (priv->windowsize)) < 0) { + gf_log (this->name, GF_LOG_ERROR, + "setting receive window " + "size failed: %d: %d: %s", + priv->sock, priv->windowsize, + strerror (errno)); + } - if (priv->nodelay) { - ret = __socket_nodelay (priv->sock); - if (ret == -1) { + if (setsockopt (priv->sock, SOL_SOCKET, SO_SNDBUF, + &priv->windowsize, + sizeof (priv->windowsize)) < 0) { gf_log (this->name, GF_LOG_ERROR, - "setsockopt() failed for NODELAY (%s)", + "setting send window size " + "failed: %d: %d: %s", + priv->sock, priv->windowsize, strerror (errno)); } } @@ -2204,22 +2198,26 @@ socket_listen (rpc_transport_t *this) /* Cant help if setting socket options fails. We can continue * working nonetheless. */ - if (setsockopt (priv->sock, SOL_SOCKET, SO_RCVBUF, - &priv->windowsize, - sizeof (priv->windowsize)) < 0) { - gf_log (this->name, GF_LOG_ERROR, - "setting receive window size failed: %d: %d: " - "%s", priv->sock, priv->windowsize, - strerror (errno)); - } + if (priv->windowsize != 0) { + if (setsockopt (priv->sock, SOL_SOCKET, SO_RCVBUF, + &priv->windowsize, + sizeof (priv->windowsize)) < 0) { + gf_log (this->name, GF_LOG_ERROR, + "setting receive window size " + "failed: %d: %d: %s", priv->sock, + priv->windowsize, + strerror (errno)); + } - if (setsockopt (priv->sock, SOL_SOCKET, SO_SNDBUF, - &priv->windowsize, - sizeof (priv->windowsize)) < 0) { - gf_log (this->name, GF_LOG_ERROR, - "setting send window size failed: %d: %d: " - "%s", priv->sock, priv->windowsize, - strerror (errno)); + if (setsockopt (priv->sock, SOL_SOCKET, SO_SNDBUF, + &priv->windowsize, + sizeof (priv->windowsize)) < 0) { + gf_log (this->name, GF_LOG_ERROR, + "setting send window size failed:" + " %d: %d: %s", priv->sock, + priv->windowsize, + strerror (errno)); + } } if (priv->nodelay) { @@ -2510,10 +2508,11 @@ struct rpc_transport_ops tops = { int reconfigure (rpc_transport_t *this, dict_t *options) { - socket_private_t *priv = NULL; - gf_boolean_t tmp_bool = _gf_false; - char *optstr = NULL; - int ret = 0; + socket_private_t *priv = NULL; + gf_boolean_t tmp_bool = _gf_false; + char *optstr = NULL; + int ret = 0; + uint64_t windowsize = 0; GF_VALIDATE_OR_GOTO ("socket", this, out); GF_VALIDATE_OR_GOTO ("socket", this->private, out); @@ -2541,6 +2540,19 @@ reconfigure (rpc_transport_t *this, dict_t *options) } else priv->keepalive = 1; + + optstr = NULL; + if (dict_get_str (this->options, "tcp-window-size", + &optstr) == 0) { + if (gf_string2bytesize (optstr, &windowsize) != 0) { + gf_log (this->name, GF_LOG_ERROR, + "invalid number format: %s", optstr); + goto out; + } + } + + priv->windowsize = (int)windowsize; + ret = 0; out: return ret; @@ -2620,9 +2632,8 @@ socket_init (rpc_transport_t *this) } } - optstr = NULL; - if (dict_get_str (this->options, "transport.window-size", + if (dict_get_str (this->options, "tcp-window-size", &optstr) == 0) { if (gf_string2bytesize (optstr, &windowsize) != 0) { gf_log (this->name, GF_LOG_ERROR, @@ -2631,8 +2642,9 @@ socket_init (rpc_transport_t *this) } } - optstr = NULL; + priv->windowsize = (int)windowsize; + optstr = NULL; /* Enable Keep-alive by default. */ priv->keepalive = 1; priv->keepaliveintvl = 2; @@ -2684,7 +2696,7 @@ socket_init (rpc_transport_t *this) } } - priv->windowsize = (int)windowsize; + optstr = NULL; out: this->private = priv; @@ -2766,10 +2778,10 @@ struct volume_options options[] = { { .key = {"non-blocking-io"}, .type = GF_OPTION_TYPE_BOOL }, - { .key = {"transport.window-size"}, + { .key = {"tcp-window-size"}, .type = GF_OPTION_TYPE_SIZET, .min = GF_MIN_SOCKET_WINDOW_SIZE, - .max = GF_MAX_SOCKET_WINDOW_SIZE, + .max = GF_MAX_SOCKET_WINDOW_SIZE }, { .key = {"transport.socket.nodelay"}, .type = GF_OPTION_TYPE_BOOL |