Skip to content

Commit 9e1a27c

Browse files
committed
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: David S. Miller <[email protected]>
2 parents 9d5fd92 + aa377e6 commit 9e1a27c

File tree

7 files changed

+71
-121
lines changed

7 files changed

+71
-121
lines changed

net/smc/af_smc.c

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -581,39 +581,32 @@ static int smc_connect(struct socket *sock, struct sockaddr *addr,
581581

582582
static int smc_clcsock_accept(struct smc_sock *lsmc, struct smc_sock **new_smc)
583583
{
584-
struct sock *sk = &lsmc->sk;
585-
struct socket *new_clcsock;
584+
struct socket *new_clcsock = NULL;
585+
struct sock *lsk = &lsmc->sk;
586586
struct sock *new_sk;
587587
int rc;
588588

589-
release_sock(&lsmc->sk);
590-
new_sk = smc_sock_alloc(sock_net(sk), NULL);
589+
release_sock(lsk);
590+
new_sk = smc_sock_alloc(sock_net(lsk), NULL);
591591
if (!new_sk) {
592592
rc = -ENOMEM;
593-
lsmc->sk.sk_err = ENOMEM;
593+
lsk->sk_err = ENOMEM;
594594
*new_smc = NULL;
595-
lock_sock(&lsmc->sk);
595+
lock_sock(lsk);
596596
goto out;
597597
}
598598
*new_smc = smc_sk(new_sk);
599599

600600
rc = kernel_accept(lsmc->clcsock, &new_clcsock, 0);
601-
lock_sock(&lsmc->sk);
602-
if (rc < 0) {
603-
lsmc->sk.sk_err = -rc;
604-
new_sk->sk_state = SMC_CLOSED;
605-
sock_set_flag(new_sk, SOCK_DEAD);
606-
sk->sk_prot->unhash(new_sk);
607-
sock_put(new_sk);
608-
*new_smc = NULL;
609-
goto out;
610-
}
611-
if (lsmc->sk.sk_state == SMC_CLOSED) {
601+
lock_sock(lsk);
602+
if (rc < 0)
603+
lsk->sk_err = -rc;
604+
if (rc < 0 || lsk->sk_state == SMC_CLOSED) {
612605
if (new_clcsock)
613606
sock_release(new_clcsock);
614607
new_sk->sk_state = SMC_CLOSED;
615608
sock_set_flag(new_sk, SOCK_DEAD);
616-
sk->sk_prot->unhash(new_sk);
609+
new_sk->sk_prot->unhash(new_sk);
617610
sock_put(new_sk);
618611
*new_smc = NULL;
619612
goto out;
@@ -936,11 +929,12 @@ static void smc_tcp_listen_work(struct work_struct *work)
936929
{
937930
struct smc_sock *lsmc = container_of(work, struct smc_sock,
938931
tcp_listen_work);
932+
struct sock *lsk = &lsmc->sk;
939933
struct smc_sock *new_smc;
940934
int rc = 0;
941935

942-
lock_sock(&lsmc->sk);
943-
while (lsmc->sk.sk_state == SMC_LISTEN) {
936+
lock_sock(lsk);
937+
while (lsk->sk_state == SMC_LISTEN) {
944938
rc = smc_clcsock_accept(lsmc, &new_smc);
945939
if (rc)
946940
goto out;
@@ -949,15 +943,15 @@ static void smc_tcp_listen_work(struct work_struct *work)
949943

950944
new_smc->listen_smc = lsmc;
951945
new_smc->use_fallback = false; /* assume rdma capability first*/
952-
sock_hold(&lsmc->sk); /* sock_put in smc_listen_work */
946+
sock_hold(lsk); /* sock_put in smc_listen_work */
953947
INIT_WORK(&new_smc->smc_listen_work, smc_listen_work);
954948
smc_copy_sock_settings_to_smc(new_smc);
955949
schedule_work(&new_smc->smc_listen_work);
956950
}
957951

958952
out:
959-
release_sock(&lsmc->sk);
960-
lsmc->sk.sk_data_ready(&lsmc->sk); /* no more listening, wake accept */
953+
release_sock(lsk);
954+
lsk->sk_data_ready(lsk); /* no more listening, wake accept */
961955
}
962956

963957
static int smc_listen(struct socket *sock, int backlog)

net/smc/smc_cdc.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ static void smc_cdc_tx_handler(struct smc_wr_tx_pend_priv *pnd_snd,
5757
cdcpend->conn);
5858
}
5959
smc_tx_sndbuf_nonfull(smc);
60-
if (smc->sk.sk_state != SMC_ACTIVE)
61-
/* wake up smc_close_wait_tx_pends() */
62-
smc->sk.sk_state_change(&smc->sk);
6360
bh_unlock_sock(&smc->sk);
6461
}
6562

@@ -155,14 +152,6 @@ void smc_cdc_tx_dismiss_slots(struct smc_connection *conn)
155152
(unsigned long)conn);
156153
}
157154

158-
bool smc_cdc_tx_has_pending(struct smc_connection *conn)
159-
{
160-
struct smc_link *link = &conn->lgr->lnk[SMC_SINGLE_LINK];
161-
162-
return smc_wr_tx_has_pending(link, SMC_CDC_MSG_TYPE,
163-
smc_cdc_tx_filter, (unsigned long)conn);
164-
}
165-
166155
/********************************* receive ***********************************/
167156

168157
static inline bool smc_cdc_before(u16 seq1, u16 seq2)

net/smc/smc_cdc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ void smc_cdc_tx_dismiss_slots(struct smc_connection *conn);
214214
int smc_cdc_msg_send(struct smc_connection *conn, struct smc_wr_buf *wr_buf,
215215
struct smc_cdc_tx_pend *pend);
216216
int smc_cdc_get_slot_and_msg_send(struct smc_connection *conn);
217-
bool smc_cdc_tx_has_pending(struct smc_connection *conn);
218217
int smc_cdc_init(void) __init;
219218

220219
#endif /* SMC_CDC_H */

0 commit comments

Comments
 (0)