diff options
author | Shehjar Tikoo <shehjart@gluster.com> | 2009-05-26 03:40:27 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2009-05-26 02:43:55 -0700 |
commit | f6bcb43d4adca26337f9a933e61eac8d6815cc7e (patch) | |
tree | 1c683602415b35fb2021390a9aeb0e13c9e8cdbb /transport | |
parent | 78ed845bc98ced0b2edd14875f5a7ef755802984 (diff) |
ib-verbs: Set receive and send window size
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
Diffstat (limited to 'transport')
-rw-r--r-- | transport/ib-verbs/src/ib-verbs.c | 49 | ||||
-rw-r--r-- | transport/ib-verbs/src/ib-verbs.h | 8 |
2 files changed, 57 insertions, 0 deletions
diff --git a/transport/ib-verbs/src/ib-verbs.c b/transport/ib-verbs/src/ib-verbs.c index 7f6f4d852a7..d44d1f3acc7 100644 --- a/transport/ib-verbs/src/ib-verbs.c +++ b/transport/ib-verbs/src/ib-verbs.c @@ -1485,6 +1485,8 @@ ib_verbs_init (transport_t *this) struct ibv_device **dev_list; struct ibv_device *ib_dev = NULL; int32_t i; + uint64_t windowsize = GF_DEFAULT_IBV_WINDOW_SIZE; + char *wsizestr = NULL; ib_verbs_options_init (this); @@ -1537,6 +1539,16 @@ ib_verbs_init (transport_t *this) return -1; } ibv_free_device_list (dev_list); + + if (dict_get_str (this->xl->options, "window-size", + &wsizestr) == 0) { + if (gf_string2bytesize (wsizestr, &windowsize) != 0) { + gf_log (this->xl->name, GF_LOG_ERROR, + "invalid number format: %s", wsizestr); + return -1; + } + } + priv->windowsize = windowsize; } priv->peer.trans = this; @@ -2082,6 +2094,24 @@ ib_verbs_connect (struct transport *this) gf_log (this->xl->name, GF_LOG_TRACE, "socket fd = %d", priv->sock); + if (setsockopt (priv->sock, SOL_SOCKET, SO_RCVBUF, + &priv->windowsize, + sizeof (priv->windowsize)) < 0) { + gf_log (this->xl->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->xl->name, GF_LOG_ERROR, + "setting send window size failed: %d: %d: " + "%s", priv->sock, priv->windowsize, + strerror (errno)); + } + memcpy (&this->peerinfo.sockaddr, &sockaddr, sockaddr_len); this->peerinfo.sockaddr_len = sockaddr_len; @@ -2281,6 +2311,20 @@ ib_verbs_listen (transport_t *this) goto err; } + if (setsockopt (priv->sock, SOL_SOCKET, SO_RCVBUF, &priv->windowsize, + sizeof (priv->windowsize)) < 0) { + gf_log (this->xl->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->xl->name, GF_LOG_ERROR, + "setting send window size failed: %d: %d: %s", + priv->sock, priv->windowsize, strerror (errno)); + } + if (listen (priv->sock, 10) != 0) { gf_log ("ib-verbs/server", GF_LOG_ERROR, "init: listen () failed on socket for %s (%s)", @@ -2390,5 +2434,10 @@ struct volume_options options[] = { "unix", "inet-sdp" }, .type = GF_OPTION_TYPE_STR }, + { .key = {"transport.window-size"}, + .type = GF_OPTION_TYPE_SIZET, + .min = GF_MIN_IBV_WINDOW_SIZE, + .max = GF_MAX_IBV_WINDOW_SIZE, + }, { .key = {NULL} } }; diff --git a/transport/ib-verbs/src/ib-verbs.h b/transport/ib-verbs/src/ib-verbs.h index a5513f8821d..d41fece5cf9 100644 --- a/transport/ib-verbs/src/ib-verbs.h +++ b/transport/ib-verbs/src/ib-verbs.h @@ -40,6 +40,13 @@ #define GF_DEFAULT_IBVERBS_LISTEN_PORT 6997 +/* Perhaps these should be larger for a high + * speed link like IB. + */ +#define GF_DEFAULT_IBV_WINDOW_SIZE (512 * GF_UNIT_KB) +#define GF_MAX_IBV_WINDOW_SIZE (1 * GF_UNIT_MB) +#define GF_MIN_IBV_WINDOW_SIZE (128 * GF_UNIT_KB) + /* options per transport end point */ struct _ib_verbs_options { int32_t port; @@ -212,6 +219,7 @@ struct _ib_verbs_private { char *buf; size_t size; } handshake; + int windowsize; }; typedef struct _ib_verbs_private ib_verbs_private_t; |