sock: Add ack_timeout to spdk_sock_opts
Due to the same reason as transport_ack_timeout for RDMA transport, TCP transport also needs ack timeout. This timeout in msec will make TCP socket to wait for ack util closes connection. Signed-off-by: zhangduan <zhangd28@chinatelecom.cn> Change-Id: I81c0089ac0d4afe4afdd2f2c7e5bff1790f59199 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12214 Community-CI: Mellanox Build Bot Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
37b68d7287
commit
87cfed8442
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
## v22.05: (Upcoming Release)
|
## v22.05: (Upcoming Release)
|
||||||
|
|
||||||
|
### sock
|
||||||
|
|
||||||
|
A new option `ack_timeout` was added to the `spdk_sock_opts` structure.
|
||||||
|
|
||||||
### util
|
### util
|
||||||
|
|
||||||
A new parameter `bounce_iovcnt` was added to `spdk_dif_generate_copy` and `spdk_dif_verify_copy`.
|
A new parameter `bounce_iovcnt` was added to `spdk_dif_generate_copy` and `spdk_dif_verify_copy`.
|
||||||
|
@ -164,6 +164,11 @@ struct spdk_sock_opts {
|
|||||||
* Used to enable or disable zero copy on socket layer.
|
* Used to enable or disable zero copy on socket layer.
|
||||||
*/
|
*/
|
||||||
bool zcopy;
|
bool zcopy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Time in msec to wait ack until connection is closed forcefully.
|
||||||
|
*/
|
||||||
|
uint32_t ack_timeout;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,6 +42,8 @@
|
|||||||
|
|
||||||
#define SPDK_SOCK_DEFAULT_PRIORITY 0
|
#define SPDK_SOCK_DEFAULT_PRIORITY 0
|
||||||
#define SPDK_SOCK_DEFAULT_ZCOPY true
|
#define SPDK_SOCK_DEFAULT_ZCOPY true
|
||||||
|
#define SPDK_SOCK_DEFAULT_ACK_TIMEOUT 0
|
||||||
|
|
||||||
#define SPDK_SOCK_OPTS_FIELD_OK(opts, field) (offsetof(struct spdk_sock_opts, field) + sizeof(opts->field) <= (opts->opts_size))
|
#define SPDK_SOCK_OPTS_FIELD_OK(opts, field) (offsetof(struct spdk_sock_opts, field) + sizeof(opts->field) <= (opts->opts_size))
|
||||||
|
|
||||||
static STAILQ_HEAD(, spdk_net_impl) g_net_impls = STAILQ_HEAD_INITIALIZER(g_net_impls);
|
static STAILQ_HEAD(, spdk_net_impl) g_net_impls = STAILQ_HEAD_INITIALIZER(g_net_impls);
|
||||||
@ -267,6 +269,10 @@ spdk_sock_get_default_opts(struct spdk_sock_opts *opts)
|
|||||||
if (SPDK_SOCK_OPTS_FIELD_OK(opts, zcopy)) {
|
if (SPDK_SOCK_OPTS_FIELD_OK(opts, zcopy)) {
|
||||||
opts->zcopy = SPDK_SOCK_DEFAULT_ZCOPY;
|
opts->zcopy = SPDK_SOCK_DEFAULT_ZCOPY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SPDK_SOCK_OPTS_FIELD_OK(opts, ack_timeout)) {
|
||||||
|
opts->ack_timeout = SPDK_SOCK_DEFAULT_ACK_TIMEOUT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -291,6 +297,10 @@ sock_init_opts(struct spdk_sock_opts *opts, struct spdk_sock_opts *opts_user)
|
|||||||
if (SPDK_SOCK_OPTS_FIELD_OK(opts, zcopy)) {
|
if (SPDK_SOCK_OPTS_FIELD_OK(opts, zcopy)) {
|
||||||
opts->zcopy = opts_user->zcopy;
|
opts->zcopy = opts_user->zcopy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SPDK_SOCK_OPTS_FIELD_OK(opts, ack_timeout)) {
|
||||||
|
opts->ack_timeout = opts_user->ack_timeout;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct spdk_sock *
|
struct spdk_sock *
|
||||||
|
@ -366,6 +366,9 @@ posix_fd_create(struct addrinfo *res, struct spdk_sock_opts *opts)
|
|||||||
int fd;
|
int fd;
|
||||||
int val = 1;
|
int val = 1;
|
||||||
int rc, sz;
|
int rc, sz;
|
||||||
|
#if defined(__linux__)
|
||||||
|
int to;
|
||||||
|
#endif
|
||||||
|
|
||||||
fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
|
fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
@ -417,6 +420,21 @@ posix_fd_create(struct addrinfo *res, struct spdk_sock_opts *opts)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts->ack_timeout) {
|
||||||
|
#if defined(__linux__)
|
||||||
|
to = opts->ack_timeout;
|
||||||
|
rc = setsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &to, sizeof(to));
|
||||||
|
if (rc != 0) {
|
||||||
|
close(fd);
|
||||||
|
/* error */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
SPDK_WARNLOG("TCP_USER_TIMEOUT is not supported.\n");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -457,6 +457,23 @@ retry:
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts->ack_timeout) {
|
||||||
|
#if defined(__linux__)
|
||||||
|
val = opts->ack_timeout;
|
||||||
|
rc = setsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &val, sizeof val);
|
||||||
|
if (rc != 0) {
|
||||||
|
close(fd);
|
||||||
|
fd = -1;
|
||||||
|
/* error */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
SPDK_WARNLOG("TCP_USER_TIMEOUT is not supported.\n");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(SO_PRIORITY)
|
#if defined(SO_PRIORITY)
|
||||||
if (opts != NULL && opts->priority) {
|
if (opts != NULL && opts->priority) {
|
||||||
rc = setsockopt(fd, SOL_SOCKET, SO_PRIORITY, &opts->priority, sizeof val);
|
rc = setsockopt(fd, SOL_SOCKET, SO_PRIORITY, &opts->priority, sizeof val);
|
||||||
|
Loading…
Reference in New Issue
Block a user