Commit 66c1a12c authored by Nicolas Dichtel's avatar Nicolas Dichtel Committed by David S. Miller

socket: use ki_nbytes instead of iov_length()

This field already contains the length of the iovec, no need to calculate it
again.
Suggested-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarNicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7b68b2f7
...@@ -882,16 +882,15 @@ static ssize_t do_sock_read(struct msghdr *msg, struct kiocb *iocb, ...@@ -882,16 +882,15 @@ static ssize_t do_sock_read(struct msghdr *msg, struct kiocb *iocb,
unsigned long nr_segs) unsigned long nr_segs)
{ {
struct socket *sock = file->private_data; struct socket *sock = file->private_data;
size_t size = iov_length(iov, nr_segs);
msg->msg_name = NULL; msg->msg_name = NULL;
msg->msg_namelen = 0; msg->msg_namelen = 0;
msg->msg_control = NULL; msg->msg_control = NULL;
msg->msg_controllen = 0; msg->msg_controllen = 0;
iov_iter_init(&msg->msg_iter, READ, iov, nr_segs, size); iov_iter_init(&msg->msg_iter, READ, iov, nr_segs, iocb->ki_nbytes);
msg->msg_flags = (file->f_flags & O_NONBLOCK) ? MSG_DONTWAIT : 0; msg->msg_flags = (file->f_flags & O_NONBLOCK) ? MSG_DONTWAIT : 0;
return __sock_recvmsg(iocb, sock, msg, size, msg->msg_flags); return __sock_recvmsg(iocb, sock, msg, iocb->ki_nbytes, msg->msg_flags);
} }
static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov, static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
...@@ -917,18 +916,17 @@ static ssize_t do_sock_write(struct msghdr *msg, struct kiocb *iocb, ...@@ -917,18 +916,17 @@ static ssize_t do_sock_write(struct msghdr *msg, struct kiocb *iocb,
unsigned long nr_segs) unsigned long nr_segs)
{ {
struct socket *sock = file->private_data; struct socket *sock = file->private_data;
size_t size = iov_length(iov, nr_segs);
msg->msg_name = NULL; msg->msg_name = NULL;
msg->msg_namelen = 0; msg->msg_namelen = 0;
msg->msg_control = NULL; msg->msg_control = NULL;
msg->msg_controllen = 0; msg->msg_controllen = 0;
iov_iter_init(&msg->msg_iter, WRITE, iov, nr_segs, size); iov_iter_init(&msg->msg_iter, WRITE, iov, nr_segs, iocb->ki_nbytes);
msg->msg_flags = (file->f_flags & O_NONBLOCK) ? MSG_DONTWAIT : 0; msg->msg_flags = (file->f_flags & O_NONBLOCK) ? MSG_DONTWAIT : 0;
if (sock->type == SOCK_SEQPACKET) if (sock->type == SOCK_SEQPACKET)
msg->msg_flags |= MSG_EOR; msg->msg_flags |= MSG_EOR;
return __sock_sendmsg(iocb, sock, msg, size); return __sock_sendmsg(iocb, sock, msg, iocb->ki_nbytes);
} }
static ssize_t sock_aio_write(struct kiocb *iocb, const struct iovec *iov, static ssize_t sock_aio_write(struct kiocb *iocb, const struct iovec *iov,
......
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