diff options
Diffstat (limited to 'net/socket.c')
-rw-r--r-- | net/socket.c | 48 |
1 files changed, 5 insertions, 43 deletions
diff --git a/net/socket.c b/net/socket.c index 8a109012608a..a564c6ed19d5 100644 --- a/net/socket.c +++ b/net/socket.c | |||
@@ -117,10 +117,8 @@ static ssize_t sock_write_iter(struct kiocb *iocb, struct iov_iter *from); | |||
117 | static int sock_mmap(struct file *file, struct vm_area_struct *vma); | 117 | static int sock_mmap(struct file *file, struct vm_area_struct *vma); |
118 | 118 | ||
119 | static int sock_close(struct inode *inode, struct file *file); | 119 | static int sock_close(struct inode *inode, struct file *file); |
120 | static struct wait_queue_head *sock_get_poll_head(struct file *file, | 120 | static __poll_t sock_poll(struct file *file, |
121 | __poll_t events); | 121 | struct poll_table_struct *wait); |
122 | static __poll_t sock_poll_mask(struct file *file, __poll_t); | ||
123 | static __poll_t sock_poll(struct file *file, struct poll_table_struct *wait); | ||
124 | static long sock_ioctl(struct file *file, unsigned int cmd, unsigned long arg); | 122 | static long sock_ioctl(struct file *file, unsigned int cmd, unsigned long arg); |
125 | #ifdef CONFIG_COMPAT | 123 | #ifdef CONFIG_COMPAT |
126 | static long compat_sock_ioctl(struct file *file, | 124 | static long compat_sock_ioctl(struct file *file, |
@@ -143,8 +141,6 @@ static const struct file_operations socket_file_ops = { | |||
143 | .llseek = no_llseek, | 141 | .llseek = no_llseek, |
144 | .read_iter = sock_read_iter, | 142 | .read_iter = sock_read_iter, |
145 | .write_iter = sock_write_iter, | 143 | .write_iter = sock_write_iter, |
146 | .get_poll_head = sock_get_poll_head, | ||
147 | .poll_mask = sock_poll_mask, | ||
148 | .poll = sock_poll, | 144 | .poll = sock_poll, |
149 | .unlocked_ioctl = sock_ioctl, | 145 | .unlocked_ioctl = sock_ioctl, |
150 | #ifdef CONFIG_COMPAT | 146 | #ifdef CONFIG_COMPAT |
@@ -1130,48 +1126,14 @@ out_release: | |||
1130 | } | 1126 | } |
1131 | EXPORT_SYMBOL(sock_create_lite); | 1127 | EXPORT_SYMBOL(sock_create_lite); |
1132 | 1128 | ||
1133 | static struct wait_queue_head *sock_get_poll_head(struct file *file, | ||
1134 | __poll_t events) | ||
1135 | { | ||
1136 | struct socket *sock = file->private_data; | ||
1137 | |||
1138 | if (!sock->ops->poll_mask) | ||
1139 | return NULL; | ||
1140 | sock_poll_busy_loop(sock, events); | ||
1141 | return sk_sleep(sock->sk); | ||
1142 | } | ||
1143 | |||
1144 | static __poll_t sock_poll_mask(struct file *file, __poll_t events) | ||
1145 | { | ||
1146 | struct socket *sock = file->private_data; | ||
1147 | |||
1148 | /* | ||
1149 | * We need to be sure we are in sync with the socket flags modification. | ||
1150 | * | ||
1151 | * This memory barrier is paired in the wq_has_sleeper. | ||
1152 | */ | ||
1153 | smp_mb(); | ||
1154 | |||
1155 | /* this socket can poll_ll so tell the system call */ | ||
1156 | return sock->ops->poll_mask(sock, events) | | ||
1157 | (sk_can_busy_loop(sock->sk) ? POLL_BUSY_LOOP : 0); | ||
1158 | } | ||
1159 | |||
1160 | /* No kernel lock held - perfect */ | 1129 | /* No kernel lock held - perfect */ |
1161 | static __poll_t sock_poll(struct file *file, poll_table *wait) | 1130 | static __poll_t sock_poll(struct file *file, poll_table *wait) |
1162 | { | 1131 | { |
1163 | struct socket *sock = file->private_data; | 1132 | struct socket *sock = file->private_data; |
1164 | __poll_t events = poll_requested_events(wait), mask = 0; | 1133 | __poll_t events = poll_requested_events(wait); |
1165 | |||
1166 | if (sock->ops->poll) { | ||
1167 | sock_poll_busy_loop(sock, events); | ||
1168 | mask = sock->ops->poll(file, sock, wait); | ||
1169 | } else if (sock->ops->poll_mask) { | ||
1170 | sock_poll_wait(file, sock_get_poll_head(file, events), wait); | ||
1171 | mask = sock->ops->poll_mask(sock, events); | ||
1172 | } | ||
1173 | 1134 | ||
1174 | return mask | sock_poll_busy_flag(sock); | 1135 | sock_poll_busy_loop(sock, events); |
1136 | return sock->ops->poll(file, sock, wait) | sock_poll_busy_flag(sock); | ||
1175 | } | 1137 | } |
1176 | 1138 | ||
1177 | static int sock_mmap(struct file *file, struct vm_area_struct *vma) | 1139 | static int sock_mmap(struct file *file, struct vm_area_struct *vma) |