summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Imbrenda <imbrenda@linux.vnet.ibm.com>2016-03-22 17:05:52 +0100
committerAlistair Strachan <astrachan@google.com>2019-01-15 17:08:33 -0800
commit4c634053305d57cb88880a3d6cddb4f3dcafaa27 (patch)
tree2efbdfa67c48bdb7a612b9202a188bb5c4dd4d92
parent6c81476a7cbccdcf79f32ada4422b2884e29ff5a (diff)
BACKPORT: AF_VSOCK: Shrink the area influenced by prepare_to_wait
When a thread is prepared for waiting by calling prepare_to_wait, sleeping is not allowed until either the wait has taken place or finish_wait has been called. The existing code in af_vsock imposed unnecessary no-sleep assumptions to a broad list of backend functions. This patch shrinks the influence of prepare_to_wait to the area where it is strictly needed, therefore relaxing the no-sleep restriction there. Signed-off-by: Claudio Imbrenda <imbrenda@linux.vnet.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net> (cherry picked from commit f7f9b5e7f8eccfd68ffa7b8d74b07c478bb9e7f0) [astrachan: Backported around stable backport 3223ea1 ("vsock: use new wait API for vsock_stream_sendmsg()")] Bug: 121166534 Test: Ran cuttlefish with android-4.4 + VSOCKETS, VMWARE_VMCI_VSOCKETS Signed-off-by: Cody Schuffelen <schuffelen@google.com> Change-Id: Ic1d7bae4b1187ad48194bf4d0b1dd09ab0275734
-rw-r--r--net/vmw_vsock/af_vsock.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 7f1d166ce612..2cb12fe3b60d 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -1559,7 +1559,7 @@ static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg,
while (total_written < len) {
ssize_t written;
- add_wait_queue(sk_sleep(sk), &wait);
+ prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
while (vsock_stream_has_space(vsk) == 0 &&
sk->sk_err == 0 &&
!(sk->sk_shutdown & SEND_SHUTDOWN) &&
@@ -1568,13 +1568,13 @@ static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg,
/* Don't wait for non-blocking sockets. */
if (timeout == 0) {
err = -EAGAIN;
- remove_wait_queue(sk_sleep(sk), &wait);
+ finish_wait(sk_sleep(sk), &wait);
goto out_err;
}
err = transport->notify_send_pre_block(vsk, &send_data);
if (err < 0) {
- remove_wait_queue(sk_sleep(sk), &wait);
+ finish_wait(sk_sleep(sk), &wait);
goto out_err;
}
@@ -1583,15 +1583,15 @@ static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg,
lock_sock(sk);
if (signal_pending(current)) {
err = sock_intr_errno(timeout);
- remove_wait_queue(sk_sleep(sk), &wait);
+ finish_wait(sk_sleep(sk), &wait);
goto out_err;
} else if (timeout == 0) {
err = -EAGAIN;
- remove_wait_queue(sk_sleep(sk), &wait);
+ finish_wait(sk_sleep(sk), &wait);
goto out_err;
}
}
- remove_wait_queue(sk_sleep(sk), &wait);
+ finish_wait(sk_sleep(sk), &wait);
/* These checks occur both as part of and after the loop
* conditional since we need to check before and after