sock/posix: Automatically set a reasonable sndbuf size
For new connections, just set the size to a good value for storage automatically. Change-Id: Ida2b21eac512a8a25ef70f486b43d5c47be16b63 Signed-off-by: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470510 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Alexey Marchuk <alexeymar@mellanox.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
7171d7d4e3
commit
418992173b
@ -46,6 +46,7 @@
|
||||
#define MAX_TMPBUF 1024
|
||||
#define PORTNUMLEN 32
|
||||
#define SO_RCVBUF_SIZE (2 * 1024 * 1024)
|
||||
#define SO_SNDBUF_SIZE (2 * 1024 * 1024)
|
||||
|
||||
struct spdk_posix_sock {
|
||||
struct spdk_sock base;
|
||||
@ -185,6 +186,26 @@ spdk_posix_sock_set_recvbuf(struct spdk_sock *_sock, int sz)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
spdk_posix_sock_set_sendbuf(struct spdk_sock *_sock, int sz)
|
||||
{
|
||||
struct spdk_posix_sock *sock = __posix_sock(_sock);
|
||||
int rc;
|
||||
|
||||
assert(sock != NULL);
|
||||
|
||||
if (sz < SO_SNDBUF_SIZE) {
|
||||
sz = SO_SNDBUF_SIZE;
|
||||
}
|
||||
|
||||
rc = setsockopt(sock->fd, SOL_SOCKET, SO_SNDBUF, &sz, sizeof(sz));
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct spdk_sock *
|
||||
spdk_posix_sock_create(const char *ip, int port, enum spdk_posix_sock_create_type type)
|
||||
{
|
||||
@ -323,6 +344,11 @@ retry:
|
||||
/* Not fatal */
|
||||
}
|
||||
|
||||
rc = spdk_posix_sock_set_sendbuf(&sock->base, SO_SNDBUF_SIZE);
|
||||
if (rc) {
|
||||
/* Not fatal */
|
||||
}
|
||||
|
||||
return &sock->base;
|
||||
}
|
||||
|
||||
@ -382,6 +408,11 @@ spdk_posix_sock_accept(struct spdk_sock *_sock)
|
||||
/* Not fatal */
|
||||
}
|
||||
|
||||
rc = spdk_posix_sock_set_sendbuf(&new_sock->base, SO_SNDBUF_SIZE);
|
||||
if (rc) {
|
||||
/* Not fatal */
|
||||
}
|
||||
|
||||
return &new_sock->base;
|
||||
}
|
||||
|
||||
@ -440,17 +471,6 @@ spdk_posix_sock_set_recvlowat(struct spdk_sock *_sock, int nbytes)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
spdk_posix_sock_set_sendbuf(struct spdk_sock *_sock, int sz)
|
||||
{
|
||||
struct spdk_posix_sock *sock = __posix_sock(_sock);
|
||||
|
||||
assert(sock != NULL);
|
||||
|
||||
return setsockopt(sock->fd, SOL_SOCKET, SO_SNDBUF,
|
||||
&sz, sizeof(sz));
|
||||
}
|
||||
|
||||
static int
|
||||
spdk_posix_sock_set_priority(struct spdk_sock *_sock, int priority)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user