net: switch sockets to ->read_iter/->write_iter
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
6d65233020
commit
8ae5e030f3
56
net/socket.c
56
net/socket.c
|
@ -113,10 +113,8 @@ unsigned int sysctl_net_busy_read __read_mostly;
|
||||||
unsigned int sysctl_net_busy_poll __read_mostly;
|
unsigned int sysctl_net_busy_poll __read_mostly;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
|
static ssize_t sock_read_iter(struct kiocb *iocb, struct iov_iter *to);
|
||||||
unsigned long nr_segs, loff_t pos);
|
static ssize_t sock_write_iter(struct kiocb *iocb, struct iov_iter *from);
|
||||||
static ssize_t sock_aio_write(struct kiocb *iocb, const struct iovec *iov,
|
|
||||||
unsigned long nr_segs, loff_t pos);
|
|
||||||
static int sock_mmap(struct file *file, struct vm_area_struct *vma);
|
static int sock_mmap(struct file *file, struct vm_area_struct *vma);
|
||||||
|
|
||||||
static int sock_close(struct inode *inode, struct file *file);
|
static int sock_close(struct inode *inode, struct file *file);
|
||||||
|
@ -142,8 +140,10 @@ static ssize_t sock_splice_read(struct file *file, loff_t *ppos,
|
||||||
static const struct file_operations socket_file_ops = {
|
static const struct file_operations socket_file_ops = {
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
.llseek = no_llseek,
|
.llseek = no_llseek,
|
||||||
.aio_read = sock_aio_read,
|
.read = new_sync_read,
|
||||||
.aio_write = sock_aio_write,
|
.write = new_sync_write,
|
||||||
|
.read_iter = sock_read_iter,
|
||||||
|
.write_iter = sock_write_iter,
|
||||||
.poll = sock_poll,
|
.poll = sock_poll,
|
||||||
.unlocked_ioctl = sock_ioctl,
|
.unlocked_ioctl = sock_ioctl,
|
||||||
#ifdef CONFIG_COMPAT
|
#ifdef CONFIG_COMPAT
|
||||||
|
@ -845,49 +845,47 @@ static ssize_t sock_splice_read(struct file *file, loff_t *ppos,
|
||||||
return sock->ops->splice_read(sock, ppos, pipe, len, flags);
|
return sock->ops->splice_read(sock, ppos, pipe, len, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
|
static ssize_t sock_read_iter(struct kiocb *iocb, struct iov_iter *to)
|
||||||
unsigned long nr_segs, loff_t pos)
|
|
||||||
{
|
{
|
||||||
struct file *file = iocb->ki_filp;
|
struct file *file = iocb->ki_filp;
|
||||||
struct socket *sock = file->private_data;
|
struct socket *sock = file->private_data;
|
||||||
struct msghdr msg;
|
struct msghdr msg = {.msg_iter = *to};
|
||||||
|
ssize_t res;
|
||||||
|
|
||||||
if (pos != 0)
|
if (file->f_flags & O_NONBLOCK)
|
||||||
|
msg.msg_flags = MSG_DONTWAIT;
|
||||||
|
|
||||||
|
if (iocb->ki_pos != 0)
|
||||||
return -ESPIPE;
|
return -ESPIPE;
|
||||||
|
|
||||||
if (iocb->ki_nbytes == 0) /* Match SYS5 behaviour */
|
if (iocb->ki_nbytes == 0) /* Match SYS5 behaviour */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
msg.msg_name = NULL;
|
res = __sock_recvmsg(iocb, sock, &msg,
|
||||||
msg.msg_namelen = 0;
|
iocb->ki_nbytes, msg.msg_flags);
|
||||||
msg.msg_control = NULL;
|
*to = msg.msg_iter;
|
||||||
msg.msg_controllen = 0;
|
return res;
|
||||||
iov_iter_init(&msg.msg_iter, READ, iov, nr_segs, iocb->ki_nbytes);
|
|
||||||
msg.msg_flags = (file->f_flags & O_NONBLOCK) ? MSG_DONTWAIT : 0;
|
|
||||||
|
|
||||||
return __sock_recvmsg(iocb, sock, &msg, iocb->ki_nbytes, msg.msg_flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t sock_aio_write(struct kiocb *iocb, const struct iovec *iov,
|
static ssize_t sock_write_iter(struct kiocb *iocb, struct iov_iter *from)
|
||||||
unsigned long nr_segs, loff_t pos)
|
|
||||||
{
|
{
|
||||||
struct file *file = iocb->ki_filp;
|
struct file *file = iocb->ki_filp;
|
||||||
struct socket *sock = file->private_data;
|
struct socket *sock = file->private_data;
|
||||||
struct msghdr msg;
|
struct msghdr msg = {.msg_iter = *from};
|
||||||
|
ssize_t res;
|
||||||
|
|
||||||
if (pos != 0)
|
if (iocb->ki_pos != 0)
|
||||||
return -ESPIPE;
|
return -ESPIPE;
|
||||||
|
|
||||||
msg.msg_name = NULL;
|
if (file->f_flags & O_NONBLOCK)
|
||||||
msg.msg_namelen = 0;
|
msg.msg_flags = MSG_DONTWAIT;
|
||||||
msg.msg_control = NULL;
|
|
||||||
msg.msg_controllen = 0;
|
|
||||||
iov_iter_init(&msg.msg_iter, WRITE, iov, nr_segs, iocb->ki_nbytes);
|
|
||||||
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, iocb->ki_nbytes);
|
res = __sock_sendmsg(iocb, sock, &msg, iocb->ki_nbytes);
|
||||||
|
*from = msg.msg_iter;
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue