Skip to content

Commit

Permalink
net/smc: simplify wait when closing listen socket
Browse files Browse the repository at this point in the history
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 <hwippel@linux.vnet.ibm.com>
Signed-off-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Ursula Braun authored and davem330 committed Mar 15, 2018
1 parent cf55612 commit 3d50206
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 26 deletions.
4 changes: 0 additions & 4 deletions net/smc/af_smc.c
Original file line number Diff line number Diff line change
Expand Up @@ -978,10 +978,6 @@ static void smc_tcp_listen_work(struct work_struct *work)
lsmc->clcsock = NULL;
}
release_sock(lsk);
/* no more listening, wake up smc_close_wait_listen_clcsock and
* accept
*/
lsk->sk_state_change(lsk);
sock_put(&lsmc->sk); /* sock_hold in smc_listen */
}

Expand Down
25 changes: 3 additions & 22 deletions net/smc/smc_close.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,6 @@ static void smc_close_cleanup_listen(struct sock *parent)
smc_close_non_accepted(sk);
}

static void smc_close_wait_listen_clcsock(struct smc_sock *smc)
{
DEFINE_WAIT_FUNC(wait, woken_wake_function);
struct sock *sk = &smc->sk;
signed long timeout;

timeout = SMC_CLOSE_WAIT_LISTEN_CLCSOCK_TIME;
add_wait_queue(sk_sleep(sk), &wait);
do {
release_sock(sk);
if (smc->clcsock)
timeout = wait_woken(&wait, TASK_UNINTERRUPTIBLE,
timeout);
sched_annotate_sleep();
lock_sock(sk);
if (!smc->clcsock)
break;
} while (timeout);
remove_wait_queue(sk_sleep(sk), &wait);
}

/* wait for sndbuf data being transmitted */
static void smc_close_stream_wait(struct smc_sock *smc, long timeout)
{
Expand Down Expand Up @@ -204,9 +183,11 @@ int smc_close_active(struct smc_sock *smc)
rc = kernel_sock_shutdown(smc->clcsock, SHUT_RDWR);
/* wake up kernel_accept of smc_tcp_listen_worker */
smc->clcsock->sk->sk_data_ready(smc->clcsock->sk);
smc_close_wait_listen_clcsock(smc);
}
smc_close_cleanup_listen(sk);
release_sock(sk);
flush_work(&smc->tcp_listen_work);
lock_sock(sk);
break;
case SMC_ACTIVE:
smc_close_stream_wait(smc, timeout);
Expand Down

0 comments on commit 3d50206

Please sign in to comment.