summaryrefslogtreecommitdiffstats
path: root/rpc/rpc-transport/socket/src
diff options
context:
space:
mode:
authorRajesh Amaravathi <rajesh@redhat.com>2012-02-22 14:51:53 +0530
committerVijay Bellur <vijay@gluster.com>2012-02-29 02:10:44 -0800
commit2da18b6724b7daf7c3a973515fc3d59e7d2c4622 (patch)
tree3af50b4e3040fd562a0383209a184b625a093522 /rpc/rpc-transport/socket/src
parent5ad1c2caed743fc10a0645055a825252dfbf77ba (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')
-rw-r--r--rpc/rpc-transport/socket/src/socket.c106
-rw-r--r--rpc/rpc-transport/socket/src/socket.h12
2 files changed, 64 insertions, 54 deletions
diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c
index 120e193ddf1..615f69f1b5a 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
diff --git a/rpc/rpc-transport/socket/src/socket.h b/rpc/rpc-transport/socket/src/socket.h
index 7f0fb6bc356..082977a2ac5 100644
--- a/rpc/rpc-transport/socket/src/socket.h
+++ b/rpc/rpc-transport/socket/src/socket.h
@@ -41,19 +41,17 @@
#define RPC_MAX_FRAGMENT_SIZE 0x7fffffff
-/* This is the size set through setsockopt for
- * both the TCP receive window size and the
- * send buffer size.
- * Till the time iobuf size becomes configurable, this size is set to include
- * two iobufs + the GlusterFS protocol headers.
+/* The default window size will be 0, indicating not to set
+ * it to any size. Default size of Linux is found to be
+ * performance friendly.
* Linux allows us to over-ride the max values for the system.
* Should we over-ride them? Because if we set a value larger than the default
* setsockopt will fail. Having larger values might be beneficial for
* IB links.
*/
-#define GF_DEFAULT_SOCKET_WINDOW_SIZE (512 * GF_UNIT_KB)
+#define GF_DEFAULT_SOCKET_WINDOW_SIZE (0)
#define GF_MAX_SOCKET_WINDOW_SIZE (1 * GF_UNIT_MB)
-#define GF_MIN_SOCKET_WINDOW_SIZE (128 * GF_UNIT_KB)
+#define GF_MIN_SOCKET_WINDOW_SIZE (0)
#define GF_USE_DEFAULT_KEEPALIVE (-1)
typedef enum {