Commit 0d1ad06a authored by David S. Miller's avatar David S. Miller

Merge branch 'csock-seqpoacket-small-fixes'

Stefano Garzarella says:

====================
vsock: small fixes for seqpacket support

This series contains few patches to clean up a bit the code
of seqpacket recently merged in the net-next tree.

No functionality changes.
====================
Signed-off-by: default avatarStefano Garzarella <sgarzare@redhat.com>
parents 7437a223 91aa49a8
...@@ -860,7 +860,7 @@ s64 vsock_stream_has_data(struct vsock_sock *vsk) ...@@ -860,7 +860,7 @@ s64 vsock_stream_has_data(struct vsock_sock *vsk)
} }
EXPORT_SYMBOL_GPL(vsock_stream_has_data); EXPORT_SYMBOL_GPL(vsock_stream_has_data);
static s64 vsock_has_data(struct vsock_sock *vsk) static s64 vsock_connectible_has_data(struct vsock_sock *vsk)
{ {
struct sock *sk = sk_vsock(vsk); struct sock *sk = sk_vsock(vsk);
...@@ -1866,10 +1866,11 @@ static int vsock_connectible_sendmsg(struct socket *sock, struct msghdr *msg, ...@@ -1866,10 +1866,11 @@ static int vsock_connectible_sendmsg(struct socket *sock, struct msghdr *msg,
return err; return err;
} }
static int vsock_wait_data(struct sock *sk, struct wait_queue_entry *wait, static int vsock_connectible_wait_data(struct sock *sk,
long timeout, struct wait_queue_entry *wait,
struct vsock_transport_recv_notify_data *recv_data, long timeout,
size_t target) struct vsock_transport_recv_notify_data *recv_data,
size_t target)
{ {
const struct vsock_transport *transport; const struct vsock_transport *transport;
struct vsock_sock *vsk; struct vsock_sock *vsk;
...@@ -1880,7 +1881,7 @@ static int vsock_wait_data(struct sock *sk, struct wait_queue_entry *wait, ...@@ -1880,7 +1881,7 @@ static int vsock_wait_data(struct sock *sk, struct wait_queue_entry *wait,
err = 0; err = 0;
transport = vsk->transport; transport = vsk->transport;
while ((data = vsock_has_data(vsk)) == 0) { while ((data = vsock_connectible_has_data(vsk)) == 0) {
prepare_to_wait(sk_sleep(sk), wait, TASK_INTERRUPTIBLE); prepare_to_wait(sk_sleep(sk), wait, TASK_INTERRUPTIBLE);
if (sk->sk_err != 0 || if (sk->sk_err != 0 ||
...@@ -1967,7 +1968,8 @@ static int __vsock_stream_recvmsg(struct sock *sk, struct msghdr *msg, ...@@ -1967,7 +1968,8 @@ static int __vsock_stream_recvmsg(struct sock *sk, struct msghdr *msg,
while (1) { while (1) {
ssize_t read; ssize_t read;
err = vsock_wait_data(sk, &wait, timeout, &recv_data, target); err = vsock_connectible_wait_data(sk, &wait, timeout,
&recv_data, target);
if (err <= 0) if (err <= 0)
break; break;
...@@ -2022,7 +2024,7 @@ static int __vsock_seqpacket_recvmsg(struct sock *sk, struct msghdr *msg, ...@@ -2022,7 +2024,7 @@ static int __vsock_seqpacket_recvmsg(struct sock *sk, struct msghdr *msg,
timeout = sock_rcvtimeo(sk, flags & MSG_DONTWAIT); timeout = sock_rcvtimeo(sk, flags & MSG_DONTWAIT);
err = vsock_wait_data(sk, &wait, timeout, NULL, 0); err = vsock_connectible_wait_data(sk, &wait, timeout, NULL, 0);
if (err <= 0) if (err <= 0)
goto out; goto out;
......
...@@ -413,7 +413,6 @@ static int virtio_transport_seqpacket_do_dequeue(struct vsock_sock *vsk, ...@@ -413,7 +413,6 @@ static int virtio_transport_seqpacket_do_dequeue(struct vsock_sock *vsk,
struct virtio_vsock_pkt *pkt; struct virtio_vsock_pkt *pkt;
int dequeued_len = 0; int dequeued_len = 0;
size_t user_buf_len = msg_data_left(msg); size_t user_buf_len = msg_data_left(msg);
bool copy_failed = false;
bool msg_ready = false; bool msg_ready = false;
spin_lock_bh(&vvs->rx_lock); spin_lock_bh(&vvs->rx_lock);
...@@ -426,7 +425,7 @@ static int virtio_transport_seqpacket_do_dequeue(struct vsock_sock *vsk, ...@@ -426,7 +425,7 @@ static int virtio_transport_seqpacket_do_dequeue(struct vsock_sock *vsk,
while (!msg_ready) { while (!msg_ready) {
pkt = list_first_entry(&vvs->rx_queue, struct virtio_vsock_pkt, list); pkt = list_first_entry(&vvs->rx_queue, struct virtio_vsock_pkt, list);
if (!copy_failed) { if (dequeued_len >= 0) {
size_t pkt_len; size_t pkt_len;
size_t bytes_to_copy; size_t bytes_to_copy;
...@@ -443,11 +442,9 @@ static int virtio_transport_seqpacket_do_dequeue(struct vsock_sock *vsk, ...@@ -443,11 +442,9 @@ static int virtio_transport_seqpacket_do_dequeue(struct vsock_sock *vsk,
err = memcpy_to_msg(msg, pkt->buf, bytes_to_copy); err = memcpy_to_msg(msg, pkt->buf, bytes_to_copy);
if (err) { if (err) {
/* Copy of message failed, set flag to skip /* Copy of message failed. Rest of
* copy path for rest of fragments. Rest of
* fragments will be freed without copy. * fragments will be freed without copy.
*/ */
copy_failed = true;
dequeued_len = err; dequeued_len = err;
} else { } else {
user_buf_len -= bytes_to_copy; user_buf_len -= bytes_to_copy;
......
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