Skip to content

Commit 3d50206

Browse files
Ursula Braundavem330
authored andcommitted
net/smc: simplify wait when closing listen socket
Closing of a listen socket wakes up kernel_accept() of smc_tcp_listen_worker(), and then has to wait till smc_tcp_listen_worker() gives up the internal clcsock. The wait logic introduced with commit 127f497 ("net/smc: release clcsock from tcp_listen_worker") might wait longer than necessary. This patch implements the idea to implement the wait just with flush_work(), and gets rid of the extra smc_close_wait_listen_clcsock() function. Fixes: 127f497 ("net/smc: release clcsock from tcp_listen_worker") Reported-by: Hans Wippel <[email protected]> Signed-off-by: Ursula Braun <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent cf55612 commit 3d50206

File tree

2 files changed

+3
-26
lines changed

2 files changed

+3
-26
lines changed

net/smc/af_smc.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -978,10 +978,6 @@ static void smc_tcp_listen_work(struct work_struct *work)
978978
lsmc->clcsock = NULL;
979979
}
980980
release_sock(lsk);
981-
/* no more listening, wake up smc_close_wait_listen_clcsock and
982-
* accept
983-
*/
984-
lsk->sk_state_change(lsk);
985981
sock_put(&lsmc->sk); /* sock_hold in smc_listen */
986982
}
987983

net/smc/smc_close.c

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,6 @@ static void smc_close_cleanup_listen(struct sock *parent)
3030
smc_close_non_accepted(sk);
3131
}
3232

33-
static void smc_close_wait_listen_clcsock(struct smc_sock *smc)
34-
{
35-
DEFINE_WAIT_FUNC(wait, woken_wake_function);
36-
struct sock *sk = &smc->sk;
37-
signed long timeout;
38-
39-
timeout = SMC_CLOSE_WAIT_LISTEN_CLCSOCK_TIME;
40-
add_wait_queue(sk_sleep(sk), &wait);
41-
do {
42-
release_sock(sk);
43-
if (smc->clcsock)
44-
timeout = wait_woken(&wait, TASK_UNINTERRUPTIBLE,
45-
timeout);
46-
sched_annotate_sleep();
47-
lock_sock(sk);
48-
if (!smc->clcsock)
49-
break;
50-
} while (timeout);
51-
remove_wait_queue(sk_sleep(sk), &wait);
52-
}
53-
5433
/* wait for sndbuf data being transmitted */
5534
static void smc_close_stream_wait(struct smc_sock *smc, long timeout)
5635
{
@@ -204,9 +183,11 @@ int smc_close_active(struct smc_sock *smc)
204183
rc = kernel_sock_shutdown(smc->clcsock, SHUT_RDWR);
205184
/* wake up kernel_accept of smc_tcp_listen_worker */
206185
smc->clcsock->sk->sk_data_ready(smc->clcsock->sk);
207-
smc_close_wait_listen_clcsock(smc);
208186
}
209187
smc_close_cleanup_listen(sk);
188+
release_sock(sk);
189+
flush_work(&smc->tcp_listen_work);
190+
lock_sock(sk);
210191
break;
211192
case SMC_ACTIVE:
212193
smc_close_stream_wait(smc, timeout);

0 commit comments

Comments
 (0)