diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2014-11-28 19:40:50 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-02-04 01:34:15 -0500 |
commit | 8ae5e030f30e50a81df1b269d5a5c32d023aa66d (patch) | |
tree | 4aa306c3e26eb3f6a46084c3bced217f28e1c94e /net/socket.c | |
parent | 6d65233020765ea25541952276217d49e3ecbf9e (diff) |
net: switch sockets to ->read_iter/->write_iter
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'net/socket.c')
-rw-r--r-- | net/socket.c | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/net/socket.c b/net/socket.c index 4d08b50cad65..bbedbfcb42c2 100644 --- a/net/socket.c +++ b/net/socket.c | |||
@@ -113,10 +113,8 @@ unsigned int sysctl_net_busy_read __read_mostly; | |||
113 | unsigned int sysctl_net_busy_poll __read_mostly; | 113 | unsigned int sysctl_net_busy_poll __read_mostly; |
114 | #endif | 114 | #endif |
115 | 115 | ||
116 | static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov, | 116 | static ssize_t sock_read_iter(struct kiocb *iocb, struct iov_iter *to); |
117 | unsigned long nr_segs, loff_t pos); | 117 | static ssize_t sock_write_iter(struct kiocb *iocb, struct iov_iter *from); |
118 | static ssize_t sock_aio_write(struct kiocb *iocb, const struct iovec *iov, | ||
119 | unsigned long nr_segs, loff_t pos); | ||
120 | static int sock_mmap(struct file *file, struct vm_area_struct *vma); | 118 | static int sock_mmap(struct file *file, struct vm_area_struct *vma); |
121 | 119 | ||
122 | static int sock_close(struct inode *inode, struct file *file); | 120 | 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, | |||
142 | static const struct file_operations socket_file_ops = { | 140 | static const struct file_operations socket_file_ops = { |
143 | .owner = THIS_MODULE, | 141 | .owner = THIS_MODULE, |
144 | .llseek = no_llseek, | 142 | .llseek = no_llseek, |
145 | .aio_read = sock_aio_read, | 143 | .read = new_sync_read, |
146 | .aio_write = sock_aio_write, | 144 | .write = new_sync_write, |
145 | .read_iter = sock_read_iter, | ||
146 | .write_iter = sock_write_iter, | ||
147 | .poll = sock_poll, | 147 | .poll = sock_poll, |
148 | .unlocked_ioctl = sock_ioctl, | 148 | .unlocked_ioctl = sock_ioctl, |
149 | #ifdef CONFIG_COMPAT | 149 | #ifdef CONFIG_COMPAT |
@@ -845,49 +845,47 @@ static ssize_t sock_splice_read(struct file *file, loff_t *ppos, | |||
845 | return sock->ops->splice_read(sock, ppos, pipe, len, flags); | 845 | return sock->ops->splice_read(sock, ppos, pipe, len, flags); |
846 | } | 846 | } |
847 | 847 | ||
848 | static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov, | 848 | static ssize_t sock_read_iter(struct kiocb *iocb, struct iov_iter *to) |
849 | unsigned long nr_segs, loff_t pos) | ||
850 | { | 849 | { |
851 | struct file *file = iocb->ki_filp; | 850 | struct file *file = iocb->ki_filp; |
852 | struct socket *sock = file->private_data; | 851 | struct socket *sock = file->private_data; |
853 | struct msghdr msg; | 852 | struct msghdr msg = {.msg_iter = *to}; |
853 | ssize_t res; | ||
854 | |||
855 | if (file->f_flags & O_NONBLOCK) | ||
856 | msg.msg_flags = MSG_DONTWAIT; | ||
854 | 857 | ||
855 | if (pos != 0) | 858 | if (iocb->ki_pos != 0) |
856 | return -ESPIPE; | 859 | return -ESPIPE; |
857 | 860 | ||
858 | if (iocb->ki_nbytes == 0) /* Match SYS5 behaviour */ | 861 | if (iocb->ki_nbytes == 0) /* Match SYS5 behaviour */ |
859 | return 0; | 862 | return 0; |
860 | 863 | ||
861 | msg.msg_name = NULL; | 864 | res = __sock_recvmsg(iocb, sock, &msg, |
862 | msg.msg_namelen = 0; | 865 | iocb->ki_nbytes, msg.msg_flags); |
863 | msg.msg_control = NULL; | 866 | *to = msg.msg_iter; |
864 | msg.msg_controllen = 0; | 867 | return res; |
865 | iov_iter_init(&msg.msg_iter, READ, iov, nr_segs, iocb->ki_nbytes); | ||
866 | msg.msg_flags = (file->f_flags & O_NONBLOCK) ? MSG_DONTWAIT : 0; | ||
867 | |||
868 | return __sock_recvmsg(iocb, sock, &msg, iocb->ki_nbytes, msg.msg_flags); | ||
869 | } | 868 | } |
870 | 869 | ||
871 | static ssize_t sock_aio_write(struct kiocb *iocb, const struct iovec *iov, | 870 | static ssize_t sock_write_iter(struct kiocb *iocb, struct iov_iter *from) |
872 | unsigned long nr_segs, loff_t pos) | ||
873 | { | 871 | { |
874 | struct file *file = iocb->ki_filp; | 872 | struct file *file = iocb->ki_filp; |
875 | struct socket *sock = file->private_data; | 873 | struct socket *sock = file->private_data; |
876 | struct msghdr msg; | 874 | struct msghdr msg = {.msg_iter = *from}; |
875 | ssize_t res; | ||
877 | 876 | ||
878 | if (pos != 0) | 877 | if (iocb->ki_pos != 0) |
879 | return -ESPIPE; | 878 | return -ESPIPE; |
880 | 879 | ||
881 | msg.msg_name = NULL; | 880 | if (file->f_flags & O_NONBLOCK) |
882 | msg.msg_namelen = 0; | 881 | msg.msg_flags = MSG_DONTWAIT; |
883 | msg.msg_control = NULL; | 882 | |
884 | msg.msg_controllen = 0; | ||
885 | iov_iter_init(&msg.msg_iter, WRITE, iov, nr_segs, iocb->ki_nbytes); | ||
886 | msg.msg_flags = (file->f_flags & O_NONBLOCK) ? MSG_DONTWAIT : 0; | ||
887 | if (sock->type == SOCK_SEQPACKET) | 883 | if (sock->type == SOCK_SEQPACKET) |
888 | msg.msg_flags |= MSG_EOR; | 884 | msg.msg_flags |= MSG_EOR; |
889 | 885 | ||
890 | return __sock_sendmsg(iocb, sock, &msg, iocb->ki_nbytes); | 886 | res = __sock_sendmsg(iocb, sock, &msg, iocb->ki_nbytes); |
887 | *from = msg.msg_iter; | ||
888 | return res; | ||
891 | } | 889 | } |
892 | 890 | ||
893 | /* | 891 | /* |