Skip to content

Commit

Permalink
SUNRPC: Use the discard iterator rather than MSG_TRUNC
Browse files Browse the repository at this point in the history
When discarding message data from the stream, we're better off using
the discard iterator, since that will work with non-TCP streams.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
  • Loading branch information
Trond Myklebust committed Dec 5, 2018
1 parent 26781ea commit b76a5af
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions net/sunrpc/xprtsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,8 @@ static ssize_t
xs_read_discard(struct socket *sock, struct msghdr *msg, int flags,
size_t count)
{
struct kvec kvec = { 0 };
return xs_read_kvec(sock, msg, flags | MSG_TRUNC, &kvec, count, 0);
iov_iter_discard(&msg->msg_iter, READ, count);
return sock_recvmsg(sock, msg, flags);
}

static ssize_t
Expand Down Expand Up @@ -616,6 +616,7 @@ xs_read_stream(struct sock_xprt *transport, int flags)
if (transport->recv.offset < transport->recv.len) {
if (!(msg.msg_flags & MSG_TRUNC))
return read;
msg.msg_flags = 0;
ret = xs_read_discard(transport->sock, &msg, flags,
transport->recv.len - transport->recv.offset);
if (ret <= 0)
Expand Down

0 comments on commit b76a5af

Please sign in to comment.