Commit 9e1a27cd authored by David S. Miller's avatar David S. Miller

Merge branch 'net-smc-socket-closing-improvements'

Ursula Braun says:

====================
net/smc: socket closing improvements

while the first 2 patches are just small cleanups, the remaing
patches affect socket closing.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 9d5fd927 aa377e68
...@@ -581,39 +581,32 @@ static int smc_connect(struct socket *sock, struct sockaddr *addr, ...@@ -581,39 +581,32 @@ static int smc_connect(struct socket *sock, struct sockaddr *addr,
static int smc_clcsock_accept(struct smc_sock *lsmc, struct smc_sock **new_smc) static int smc_clcsock_accept(struct smc_sock *lsmc, struct smc_sock **new_smc)
{ {
struct sock *sk = &lsmc->sk; struct socket *new_clcsock = NULL;
struct socket *new_clcsock; struct sock *lsk = &lsmc->sk;
struct sock *new_sk; struct sock *new_sk;
int rc; int rc;
release_sock(&lsmc->sk); release_sock(lsk);
new_sk = smc_sock_alloc(sock_net(sk), NULL); new_sk = smc_sock_alloc(sock_net(lsk), NULL);
if (!new_sk) { if (!new_sk) {
rc = -ENOMEM; rc = -ENOMEM;
lsmc->sk.sk_err = ENOMEM; lsk->sk_err = ENOMEM;
*new_smc = NULL; *new_smc = NULL;
lock_sock(&lsmc->sk); lock_sock(lsk);
goto out; goto out;
} }
*new_smc = smc_sk(new_sk); *new_smc = smc_sk(new_sk);
rc = kernel_accept(lsmc->clcsock, &new_clcsock, 0); rc = kernel_accept(lsmc->clcsock, &new_clcsock, 0);
lock_sock(&lsmc->sk); lock_sock(lsk);
if (rc < 0) { if (rc < 0)
lsmc->sk.sk_err = -rc; lsk->sk_err = -rc;
new_sk->sk_state = SMC_CLOSED; if (rc < 0 || lsk->sk_state == SMC_CLOSED) {
sock_set_flag(new_sk, SOCK_DEAD);
sk->sk_prot->unhash(new_sk);
sock_put(new_sk);
*new_smc = NULL;
goto out;
}
if (lsmc->sk.sk_state == SMC_CLOSED) {
if (new_clcsock) if (new_clcsock)
sock_release(new_clcsock); sock_release(new_clcsock);
new_sk->sk_state = SMC_CLOSED; new_sk->sk_state = SMC_CLOSED;
sock_set_flag(new_sk, SOCK_DEAD); sock_set_flag(new_sk, SOCK_DEAD);
sk->sk_prot->unhash(new_sk); new_sk->sk_prot->unhash(new_sk);
sock_put(new_sk); sock_put(new_sk);
*new_smc = NULL; *new_smc = NULL;
goto out; goto out;
...@@ -936,11 +929,12 @@ static void smc_tcp_listen_work(struct work_struct *work) ...@@ -936,11 +929,12 @@ static void smc_tcp_listen_work(struct work_struct *work)
{ {
struct smc_sock *lsmc = container_of(work, struct smc_sock, struct smc_sock *lsmc = container_of(work, struct smc_sock,
tcp_listen_work); tcp_listen_work);
struct sock *lsk = &lsmc->sk;
struct smc_sock *new_smc; struct smc_sock *new_smc;
int rc = 0; int rc = 0;
lock_sock(&lsmc->sk); lock_sock(lsk);
while (lsmc->sk.sk_state == SMC_LISTEN) { while (lsk->sk_state == SMC_LISTEN) {
rc = smc_clcsock_accept(lsmc, &new_smc); rc = smc_clcsock_accept(lsmc, &new_smc);
if (rc) if (rc)
goto out; goto out;
...@@ -949,15 +943,15 @@ static void smc_tcp_listen_work(struct work_struct *work) ...@@ -949,15 +943,15 @@ static void smc_tcp_listen_work(struct work_struct *work)
new_smc->listen_smc = lsmc; new_smc->listen_smc = lsmc;
new_smc->use_fallback = false; /* assume rdma capability first*/ new_smc->use_fallback = false; /* assume rdma capability first*/
sock_hold(&lsmc->sk); /* sock_put in smc_listen_work */ sock_hold(lsk); /* sock_put in smc_listen_work */
INIT_WORK(&new_smc->smc_listen_work, smc_listen_work); INIT_WORK(&new_smc->smc_listen_work, smc_listen_work);
smc_copy_sock_settings_to_smc(new_smc); smc_copy_sock_settings_to_smc(new_smc);
schedule_work(&new_smc->smc_listen_work); schedule_work(&new_smc->smc_listen_work);
} }
out: out:
release_sock(&lsmc->sk); release_sock(lsk);
lsmc->sk.sk_data_ready(&lsmc->sk); /* no more listening, wake accept */ lsk->sk_data_ready(lsk); /* no more listening, wake accept */
} }
static int smc_listen(struct socket *sock, int backlog) static int smc_listen(struct socket *sock, int backlog)
......
...@@ -57,9 +57,6 @@ static void smc_cdc_tx_handler(struct smc_wr_tx_pend_priv *pnd_snd, ...@@ -57,9 +57,6 @@ static void smc_cdc_tx_handler(struct smc_wr_tx_pend_priv *pnd_snd,
cdcpend->conn); cdcpend->conn);
} }
smc_tx_sndbuf_nonfull(smc); smc_tx_sndbuf_nonfull(smc);
if (smc->sk.sk_state != SMC_ACTIVE)
/* wake up smc_close_wait_tx_pends() */
smc->sk.sk_state_change(&smc->sk);
bh_unlock_sock(&smc->sk); bh_unlock_sock(&smc->sk);
} }
...@@ -155,14 +152,6 @@ void smc_cdc_tx_dismiss_slots(struct smc_connection *conn) ...@@ -155,14 +152,6 @@ void smc_cdc_tx_dismiss_slots(struct smc_connection *conn)
(unsigned long)conn); (unsigned long)conn);
} }
bool smc_cdc_tx_has_pending(struct smc_connection *conn)
{
struct smc_link *link = &conn->lgr->lnk[SMC_SINGLE_LINK];
return smc_wr_tx_has_pending(link, SMC_CDC_MSG_TYPE,
smc_cdc_tx_filter, (unsigned long)conn);
}
/********************************* receive ***********************************/ /********************************* receive ***********************************/
static inline bool smc_cdc_before(u16 seq1, u16 seq2) static inline bool smc_cdc_before(u16 seq1, u16 seq2)
......
...@@ -214,7 +214,6 @@ void smc_cdc_tx_dismiss_slots(struct smc_connection *conn); ...@@ -214,7 +214,6 @@ void smc_cdc_tx_dismiss_slots(struct smc_connection *conn);
int smc_cdc_msg_send(struct smc_connection *conn, struct smc_wr_buf *wr_buf, int smc_cdc_msg_send(struct smc_connection *conn, struct smc_wr_buf *wr_buf,
struct smc_cdc_tx_pend *pend); struct smc_cdc_tx_pend *pend);
int smc_cdc_get_slot_and_msg_send(struct smc_connection *conn); int smc_cdc_get_slot_and_msg_send(struct smc_connection *conn);
bool smc_cdc_tx_has_pending(struct smc_connection *conn);
int smc_cdc_init(void) __init; int smc_cdc_init(void) __init;
#endif /* SMC_CDC_H */ #endif /* SMC_CDC_H */
...@@ -19,8 +19,6 @@ ...@@ -19,8 +19,6 @@
#include "smc_cdc.h" #include "smc_cdc.h"
#include "smc_close.h" #include "smc_close.h"
#define SMC_CLOSE_WAIT_TX_PENDS_TIME (5 * HZ)
static void smc_close_cleanup_listen(struct sock *parent) static void smc_close_cleanup_listen(struct sock *parent)
{ {
struct sock *sk; struct sock *sk;
...@@ -30,26 +28,6 @@ static void smc_close_cleanup_listen(struct sock *parent) ...@@ -30,26 +28,6 @@ static void smc_close_cleanup_listen(struct sock *parent)
smc_close_non_accepted(sk); smc_close_non_accepted(sk);
} }
static void smc_close_wait_tx_pends(struct smc_sock *smc)
{
DEFINE_WAIT_FUNC(wait, woken_wake_function);
struct sock *sk = &smc->sk;
signed long timeout;
timeout = SMC_CLOSE_WAIT_TX_PENDS_TIME;
add_wait_queue(sk_sleep(sk), &wait);
while (!signal_pending(current) && timeout) {
int rc;
rc = sk_wait_event(sk, &timeout,
!smc_cdc_tx_has_pending(&smc->conn),
&wait);
if (rc)
break;
}
remove_wait_queue(sk_sleep(sk), &wait);
}
/* wait for sndbuf data being transmitted */ /* wait for sndbuf data being transmitted */
static void smc_close_stream_wait(struct smc_sock *smc, long timeout) static void smc_close_stream_wait(struct smc_sock *smc, long timeout)
{ {
...@@ -115,36 +93,38 @@ static int smc_close_abort(struct smc_connection *conn) ...@@ -115,36 +93,38 @@ static int smc_close_abort(struct smc_connection *conn)
*/ */
static void smc_close_active_abort(struct smc_sock *smc) static void smc_close_active_abort(struct smc_sock *smc)
{ {
struct sock *sk = &smc->sk;
struct smc_cdc_conn_state_flags *txflags = struct smc_cdc_conn_state_flags *txflags =
&smc->conn.local_tx_ctrl.conn_state_flags; &smc->conn.local_tx_ctrl.conn_state_flags;
smc->sk.sk_err = ECONNABORTED; sk->sk_err = ECONNABORTED;
if (smc->clcsock && smc->clcsock->sk) { if (smc->clcsock && smc->clcsock->sk) {
smc->clcsock->sk->sk_err = ECONNABORTED; smc->clcsock->sk->sk_err = ECONNABORTED;
smc->clcsock->sk->sk_state_change(smc->clcsock->sk); smc->clcsock->sk->sk_state_change(smc->clcsock->sk);
} }
switch (smc->sk.sk_state) { switch (sk->sk_state) {
case SMC_INIT: case SMC_INIT:
case SMC_ACTIVE: case SMC_ACTIVE:
smc->sk.sk_state = SMC_PEERABORTWAIT; sk->sk_state = SMC_PEERABORTWAIT;
break; break;
case SMC_APPCLOSEWAIT1: case SMC_APPCLOSEWAIT1:
case SMC_APPCLOSEWAIT2: case SMC_APPCLOSEWAIT2:
txflags->peer_conn_abort = 1; txflags->peer_conn_abort = 1;
sock_release(smc->clcsock); sock_release(smc->clcsock);
if (!smc_cdc_rxed_any_close(&smc->conn)) if (!smc_cdc_rxed_any_close(&smc->conn))
smc->sk.sk_state = SMC_PEERABORTWAIT; sk->sk_state = SMC_PEERABORTWAIT;
else else
smc->sk.sk_state = SMC_CLOSED; sk->sk_state = SMC_CLOSED;
break; break;
case SMC_PEERCLOSEWAIT1: case SMC_PEERCLOSEWAIT1:
case SMC_PEERCLOSEWAIT2: case SMC_PEERCLOSEWAIT2:
if (!txflags->peer_conn_closed) { if (!txflags->peer_conn_closed) {
smc->sk.sk_state = SMC_PEERABORTWAIT; sk->sk_state = SMC_PEERABORTWAIT;
txflags->peer_conn_abort = 1; txflags->peer_conn_abort = 1;
sock_release(smc->clcsock); sock_release(smc->clcsock);
} else { } else {
smc->sk.sk_state = SMC_CLOSED; sk->sk_state = SMC_CLOSED;
} }
break; break;
case SMC_PROCESSABORT: case SMC_PROCESSABORT:
...@@ -153,7 +133,7 @@ static void smc_close_active_abort(struct smc_sock *smc) ...@@ -153,7 +133,7 @@ static void smc_close_active_abort(struct smc_sock *smc)
txflags->peer_conn_abort = 1; txflags->peer_conn_abort = 1;
sock_release(smc->clcsock); sock_release(smc->clcsock);
} }
smc->sk.sk_state = SMC_CLOSED; sk->sk_state = SMC_CLOSED;
break; break;
case SMC_PEERFINCLOSEWAIT: case SMC_PEERFINCLOSEWAIT:
case SMC_PEERABORTWAIT: case SMC_PEERABORTWAIT:
...@@ -161,8 +141,8 @@ static void smc_close_active_abort(struct smc_sock *smc) ...@@ -161,8 +141,8 @@ static void smc_close_active_abort(struct smc_sock *smc)
break; break;
} }
sock_set_flag(&smc->sk, SOCK_DEAD); sock_set_flag(sk, SOCK_DEAD);
smc->sk.sk_state_change(&smc->sk); sk->sk_state_change(sk);
} }
static inline bool smc_close_sent_any_close(struct smc_connection *conn) static inline bool smc_close_sent_any_close(struct smc_connection *conn)
...@@ -185,9 +165,9 @@ int smc_close_active(struct smc_sock *smc) ...@@ -185,9 +165,9 @@ int smc_close_active(struct smc_sock *smc)
0 : sock_flag(sk, SOCK_LINGER) ? 0 : sock_flag(sk, SOCK_LINGER) ?
sk->sk_lingertime : SMC_MAX_STREAM_WAIT_TIMEOUT; sk->sk_lingertime : SMC_MAX_STREAM_WAIT_TIMEOUT;
again:
old_state = sk->sk_state; old_state = sk->sk_state;
switch (old_state) { again:
switch (sk->sk_state) {
case SMC_INIT: case SMC_INIT:
sk->sk_state = SMC_CLOSED; sk->sk_state = SMC_CLOSED;
if (smc->smc_listen_work.func) if (smc->smc_listen_work.func)
...@@ -214,6 +194,8 @@ int smc_close_active(struct smc_sock *smc) ...@@ -214,6 +194,8 @@ int smc_close_active(struct smc_sock *smc)
if (sk->sk_state == SMC_ACTIVE) { if (sk->sk_state == SMC_ACTIVE) {
/* send close request */ /* send close request */
rc = smc_close_final(conn); rc = smc_close_final(conn);
if (rc)
break;
sk->sk_state = SMC_PEERCLOSEWAIT1; sk->sk_state = SMC_PEERCLOSEWAIT1;
} else { } else {
/* peer event has changed the state */ /* peer event has changed the state */
...@@ -226,9 +208,10 @@ int smc_close_active(struct smc_sock *smc) ...@@ -226,9 +208,10 @@ int smc_close_active(struct smc_sock *smc)
!smc_close_sent_any_close(conn)) { !smc_close_sent_any_close(conn)) {
/* just shutdown wr done, send close request */ /* just shutdown wr done, send close request */
rc = smc_close_final(conn); rc = smc_close_final(conn);
if (rc)
break;
} }
sk->sk_state = SMC_CLOSED; sk->sk_state = SMC_CLOSED;
smc_close_wait_tx_pends(smc);
break; break;
case SMC_APPCLOSEWAIT1: case SMC_APPCLOSEWAIT1:
case SMC_APPCLOSEWAIT2: case SMC_APPCLOSEWAIT2:
...@@ -237,19 +220,19 @@ int smc_close_active(struct smc_sock *smc) ...@@ -237,19 +220,19 @@ int smc_close_active(struct smc_sock *smc)
release_sock(sk); release_sock(sk);
cancel_delayed_work_sync(&conn->tx_work); cancel_delayed_work_sync(&conn->tx_work);
lock_sock(sk); lock_sock(sk);
if (sk->sk_err != ECONNABORTED) { if (sk->sk_state != SMC_APPCLOSEWAIT1 &&
/* confirm close from peer */ sk->sk_state != SMC_APPCLOSEWAIT2)
rc = smc_close_final(conn); goto again;
if (rc) /* confirm close from peer */
break; rc = smc_close_final(conn);
} if (rc)
break;
if (smc_cdc_rxed_any_close(conn)) if (smc_cdc_rxed_any_close(conn))
/* peer has closed the socket already */ /* peer has closed the socket already */
sk->sk_state = SMC_CLOSED; sk->sk_state = SMC_CLOSED;
else else
/* peer has just issued a shutdown write */ /* peer has just issued a shutdown write */
sk->sk_state = SMC_PEERFINCLOSEWAIT; sk->sk_state = SMC_PEERFINCLOSEWAIT;
smc_close_wait_tx_pends(smc);
break; break;
case SMC_PEERCLOSEWAIT1: case SMC_PEERCLOSEWAIT1:
case SMC_PEERCLOSEWAIT2: case SMC_PEERCLOSEWAIT2:
...@@ -257,6 +240,8 @@ int smc_close_active(struct smc_sock *smc) ...@@ -257,6 +240,8 @@ int smc_close_active(struct smc_sock *smc)
!smc_close_sent_any_close(conn)) { !smc_close_sent_any_close(conn)) {
/* just shutdown wr done, send close request */ /* just shutdown wr done, send close request */
rc = smc_close_final(conn); rc = smc_close_final(conn);
if (rc)
break;
} }
/* peer sending PeerConnectionClosed will cause transition */ /* peer sending PeerConnectionClosed will cause transition */
break; break;
...@@ -269,7 +254,6 @@ int smc_close_active(struct smc_sock *smc) ...@@ -269,7 +254,6 @@ int smc_close_active(struct smc_sock *smc)
lock_sock(sk); lock_sock(sk);
smc_close_abort(conn); smc_close_abort(conn);
sk->sk_state = SMC_CLOSED; sk->sk_state = SMC_CLOSED;
smc_close_wait_tx_pends(smc);
break; break;
case SMC_PEERABORTWAIT: case SMC_PEERABORTWAIT:
case SMC_CLOSED: case SMC_CLOSED:
...@@ -278,7 +262,7 @@ int smc_close_active(struct smc_sock *smc) ...@@ -278,7 +262,7 @@ int smc_close_active(struct smc_sock *smc)
} }
if (old_state != sk->sk_state) if (old_state != sk->sk_state)
sk->sk_state_change(&smc->sk); sk->sk_state_change(sk);
return rc; return rc;
} }
...@@ -331,7 +315,7 @@ static void smc_close_passive_work(struct work_struct *work) ...@@ -331,7 +315,7 @@ static void smc_close_passive_work(struct work_struct *work)
struct sock *sk = &smc->sk; struct sock *sk = &smc->sk;
int old_state; int old_state;
lock_sock(&smc->sk); lock_sock(sk);
old_state = sk->sk_state; old_state = sk->sk_state;
if (!conn->alert_token_local) { if (!conn->alert_token_local) {
...@@ -340,7 +324,7 @@ static void smc_close_passive_work(struct work_struct *work) ...@@ -340,7 +324,7 @@ static void smc_close_passive_work(struct work_struct *work)
goto wakeup; goto wakeup;
} }
rxflags = &smc->conn.local_rx_ctrl.conn_state_flags; rxflags = &conn->local_rx_ctrl.conn_state_flags;
if (rxflags->peer_conn_abort) { if (rxflags->peer_conn_abort) {
smc_close_passive_abort_received(smc); smc_close_passive_abort_received(smc);
goto wakeup; goto wakeup;
...@@ -348,7 +332,7 @@ static void smc_close_passive_work(struct work_struct *work) ...@@ -348,7 +332,7 @@ static void smc_close_passive_work(struct work_struct *work)
switch (sk->sk_state) { switch (sk->sk_state) {
case SMC_INIT: case SMC_INIT:
if (atomic_read(&smc->conn.bytes_to_rcv) || if (atomic_read(&conn->bytes_to_rcv) ||
(rxflags->peer_done_writing && (rxflags->peer_done_writing &&
!smc_cdc_rxed_any_close(conn))) !smc_cdc_rxed_any_close(conn)))
sk->sk_state = SMC_APPCLOSEWAIT1; sk->sk_state = SMC_APPCLOSEWAIT1;
...@@ -365,7 +349,7 @@ static void smc_close_passive_work(struct work_struct *work) ...@@ -365,7 +349,7 @@ static void smc_close_passive_work(struct work_struct *work)
/* to check for closing */ /* to check for closing */
case SMC_PEERCLOSEWAIT2: case SMC_PEERCLOSEWAIT2:
case SMC_PEERFINCLOSEWAIT: case SMC_PEERFINCLOSEWAIT:
if (!smc_cdc_rxed_any_close(&smc->conn)) if (!smc_cdc_rxed_any_close(conn))
break; break;
if (sock_flag(sk, SOCK_DEAD) && if (sock_flag(sk, SOCK_DEAD) &&
smc_close_sent_any_close(conn)) { smc_close_sent_any_close(conn)) {
...@@ -394,12 +378,12 @@ static void smc_close_passive_work(struct work_struct *work) ...@@ -394,12 +378,12 @@ static void smc_close_passive_work(struct work_struct *work)
sk->sk_state_change(sk); sk->sk_state_change(sk);
if ((sk->sk_state == SMC_CLOSED) && if ((sk->sk_state == SMC_CLOSED) &&
(sock_flag(sk, SOCK_DEAD) || !sk->sk_socket)) { (sock_flag(sk, SOCK_DEAD) || !sk->sk_socket)) {
smc_conn_free(&smc->conn); smc_conn_free(conn);
schedule_delayed_work(&smc->sock_put_work, schedule_delayed_work(&smc->sock_put_work,
SMC_CLOSE_SOCK_PUT_DELAY); SMC_CLOSE_SOCK_PUT_DELAY);
} }
} }
release_sock(&smc->sk); release_sock(sk);
} }
void smc_close_sock_put_work(struct work_struct *work) void smc_close_sock_put_work(struct work_struct *work)
...@@ -424,20 +408,21 @@ int smc_close_shutdown_write(struct smc_sock *smc) ...@@ -424,20 +408,21 @@ int smc_close_shutdown_write(struct smc_sock *smc)
0 : sock_flag(sk, SOCK_LINGER) ? 0 : sock_flag(sk, SOCK_LINGER) ?
sk->sk_lingertime : SMC_MAX_STREAM_WAIT_TIMEOUT; sk->sk_lingertime : SMC_MAX_STREAM_WAIT_TIMEOUT;
again:
old_state = sk->sk_state; old_state = sk->sk_state;
switch (old_state) { again:
switch (sk->sk_state) {
case SMC_ACTIVE: case SMC_ACTIVE:
smc_close_stream_wait(smc, timeout); smc_close_stream_wait(smc, timeout);
release_sock(sk); release_sock(sk);
cancel_delayed_work_sync(&conn->tx_work); cancel_delayed_work_sync(&conn->tx_work);
lock_sock(sk); lock_sock(sk);
if (sk->sk_state != SMC_ACTIVE)
goto again;
/* send close wr request */ /* send close wr request */
rc = smc_close_wr(conn); rc = smc_close_wr(conn);
if (sk->sk_state == SMC_ACTIVE) if (rc)
sk->sk_state = SMC_PEERCLOSEWAIT1; break;
else sk->sk_state = SMC_PEERCLOSEWAIT1;
goto again;
break; break;
case SMC_APPCLOSEWAIT1: case SMC_APPCLOSEWAIT1:
/* passive close */ /* passive close */
...@@ -446,8 +431,12 @@ int smc_close_shutdown_write(struct smc_sock *smc) ...@@ -446,8 +431,12 @@ int smc_close_shutdown_write(struct smc_sock *smc)
release_sock(sk); release_sock(sk);
cancel_delayed_work_sync(&conn->tx_work); cancel_delayed_work_sync(&conn->tx_work);
lock_sock(sk); lock_sock(sk);
if (sk->sk_state != SMC_APPCLOSEWAIT1)
goto again;
/* confirm close from peer */ /* confirm close from peer */
rc = smc_close_wr(conn); rc = smc_close_wr(conn);
if (rc)
break;
sk->sk_state = SMC_APPCLOSEWAIT2; sk->sk_state = SMC_APPCLOSEWAIT2;
break; break;
case SMC_APPCLOSEWAIT2: case SMC_APPCLOSEWAIT2:
...@@ -462,7 +451,7 @@ int smc_close_shutdown_write(struct smc_sock *smc) ...@@ -462,7 +451,7 @@ int smc_close_shutdown_write(struct smc_sock *smc)
} }
if (old_state != sk->sk_state) if (old_state != sk->sk_state)
sk->sk_state_change(&smc->sk); sk->sk_state_change(sk);
return rc; return rc;
} }
......
...@@ -86,7 +86,7 @@ static int smc_tx_wait_memory(struct smc_sock *smc, int flags) ...@@ -86,7 +86,7 @@ static int smc_tx_wait_memory(struct smc_sock *smc, int flags)
rc = -EPIPE; rc = -EPIPE;
break; break;
} }
if (conn->local_rx_ctrl.conn_state_flags.peer_conn_abort) { if (smc_cdc_rxed_any_close(conn)) {
rc = -ECONNRESET; rc = -ECONNRESET;
break; break;
} }
...@@ -107,7 +107,7 @@ static int smc_tx_wait_memory(struct smc_sock *smc, int flags) ...@@ -107,7 +107,7 @@ static int smc_tx_wait_memory(struct smc_sock *smc, int flags)
sk_wait_event(sk, &timeo, sk_wait_event(sk, &timeo,
sk->sk_err || sk->sk_err ||
(sk->sk_shutdown & SEND_SHUTDOWN) || (sk->sk_shutdown & SEND_SHUTDOWN) ||
smc_cdc_rxed_any_close_or_senddone(conn) || smc_cdc_rxed_any_close(conn) ||
atomic_read(&conn->sndbuf_space), atomic_read(&conn->sndbuf_space),
&wait); &wait);
} }
......
...@@ -122,6 +122,7 @@ static void smc_wr_tx_tasklet_fn(unsigned long data) ...@@ -122,6 +122,7 @@ static void smc_wr_tx_tasklet_fn(unsigned long data)
again: again:
polled++; polled++;
do { do {
memset(&wc, 0, sizeof(wc));
rc = ib_poll_cq(dev->roce_cq_send, SMC_WR_MAX_POLL_CQE, wc); rc = ib_poll_cq(dev->roce_cq_send, SMC_WR_MAX_POLL_CQE, wc);
if (polled == 1) { if (polled == 1) {
ib_req_notify_cq(dev->roce_cq_send, ib_req_notify_cq(dev->roce_cq_send,
...@@ -185,7 +186,7 @@ int smc_wr_tx_get_free_slot(struct smc_link *link, ...@@ -185,7 +186,7 @@ int smc_wr_tx_get_free_slot(struct smc_link *link,
if (rc) if (rc)
return rc; return rc;
} else { } else {
rc = wait_event_interruptible_timeout( rc = wait_event_timeout(
link->wr_tx_wait, link->wr_tx_wait,
(smc_wr_tx_get_free_slot_index(link, &idx) != -EBUSY), (smc_wr_tx_get_free_slot_index(link, &idx) != -EBUSY),
SMC_WR_TX_WAIT_FREE_SLOT_TIME); SMC_WR_TX_WAIT_FREE_SLOT_TIME);
...@@ -198,8 +199,6 @@ int smc_wr_tx_get_free_slot(struct smc_link *link, ...@@ -198,8 +199,6 @@ int smc_wr_tx_get_free_slot(struct smc_link *link,
smc_lgr_terminate(lgr); smc_lgr_terminate(lgr);
return -EPIPE; return -EPIPE;
} }
if (rc == -ERESTARTSYS)
return -EINTR;
if (idx == link->wr_tx_cnt) if (idx == link->wr_tx_cnt)
return -EPIPE; return -EPIPE;
} }
...@@ -300,18 +299,18 @@ int smc_wr_reg_send(struct smc_link *link, struct ib_mr *mr) ...@@ -300,18 +299,18 @@ int smc_wr_reg_send(struct smc_link *link, struct ib_mr *mr)
return rc; return rc;
} }
void smc_wr_tx_dismiss_slots(struct smc_link *link, u8 wr_rx_hdr_type, void smc_wr_tx_dismiss_slots(struct smc_link *link, u8 wr_tx_hdr_type,
smc_wr_tx_filter filter, smc_wr_tx_filter filter,
smc_wr_tx_dismisser dismisser, smc_wr_tx_dismisser dismisser,
unsigned long data) unsigned long data)
{ {
struct smc_wr_tx_pend_priv *tx_pend; struct smc_wr_tx_pend_priv *tx_pend;
struct smc_wr_rx_hdr *wr_rx; struct smc_wr_rx_hdr *wr_tx;
int i; int i;
for_each_set_bit(i, link->wr_tx_mask, link->wr_tx_cnt) { for_each_set_bit(i, link->wr_tx_mask, link->wr_tx_cnt) {
wr_rx = (struct smc_wr_rx_hdr *)&link->wr_rx_bufs[i]; wr_tx = (struct smc_wr_rx_hdr *)&link->wr_tx_bufs[i];
if (wr_rx->type != wr_rx_hdr_type) if (wr_tx->type != wr_tx_hdr_type)
continue; continue;
tx_pend = &link->wr_tx_pends[i].priv; tx_pend = &link->wr_tx_pends[i].priv;
if (filter(tx_pend, data)) if (filter(tx_pend, data))
...@@ -319,24 +318,6 @@ void smc_wr_tx_dismiss_slots(struct smc_link *link, u8 wr_rx_hdr_type, ...@@ -319,24 +318,6 @@ void smc_wr_tx_dismiss_slots(struct smc_link *link, u8 wr_rx_hdr_type,
} }
} }
bool smc_wr_tx_has_pending(struct smc_link *link, u8 wr_rx_hdr_type,
smc_wr_tx_filter filter, unsigned long data)
{
struct smc_wr_tx_pend_priv *tx_pend;
struct smc_wr_rx_hdr *wr_rx;
int i;
for_each_set_bit(i, link->wr_tx_mask, link->wr_tx_cnt) {
wr_rx = (struct smc_wr_rx_hdr *)&link->wr_rx_bufs[i];
if (wr_rx->type != wr_rx_hdr_type)
continue;
tx_pend = &link->wr_tx_pends[i].priv;
if (filter(tx_pend, data))
return true;
}
return false;
}
/****************************** receive queue ********************************/ /****************************** receive queue ********************************/
int smc_wr_rx_register_handler(struct smc_wr_rx_handler *handler) int smc_wr_rx_register_handler(struct smc_wr_rx_handler *handler)
......
...@@ -93,8 +93,6 @@ int smc_wr_tx_put_slot(struct smc_link *link, ...@@ -93,8 +93,6 @@ int smc_wr_tx_put_slot(struct smc_link *link,
int smc_wr_tx_send(struct smc_link *link, int smc_wr_tx_send(struct smc_link *link,
struct smc_wr_tx_pend_priv *wr_pend_priv); struct smc_wr_tx_pend_priv *wr_pend_priv);
void smc_wr_tx_cq_handler(struct ib_cq *ib_cq, void *cq_context); void smc_wr_tx_cq_handler(struct ib_cq *ib_cq, void *cq_context);
bool smc_wr_tx_has_pending(struct smc_link *link, u8 wr_rx_hdr_type,
smc_wr_tx_filter filter, unsigned long data);
void smc_wr_tx_dismiss_slots(struct smc_link *lnk, u8 wr_rx_hdr_type, void smc_wr_tx_dismiss_slots(struct smc_link *lnk, u8 wr_rx_hdr_type,
smc_wr_tx_filter filter, smc_wr_tx_filter filter,
smc_wr_tx_dismisser dismisser, smc_wr_tx_dismisser dismisser,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment