Skip to content

Commit 408afb8

Browse files
committed
Merge branch 'work.aio-1' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull aio updates from Al Viro: "Majority of AIO stuff this cycle. aio-fsync and aio-poll, mostly. The only thing I'm holding back for a day or so is Adam's aio ioprio - his last-minute fixup is trivial (missing stub in !CONFIG_BLOCK case), but let it sit in -next for decency sake..." * 'work.aio-1' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (46 commits) aio: sanitize the limit checking in io_submit(2) aio: fold do_io_submit() into callers aio: shift copyin of iocb into io_submit_one() aio_read_events_ring(): make a bit more readable aio: all callers of aio_{read,write,fsync,poll} treat 0 and -EIOCBQUEUED the same way aio: take list removal to (some) callers of aio_complete() aio: add missing break for the IOCB_CMD_FDSYNC case random: convert to ->poll_mask timerfd: convert to ->poll_mask eventfd: switch to ->poll_mask pipe: convert to ->poll_mask crypto: af_alg: convert to ->poll_mask net/rxrpc: convert to ->poll_mask net/iucv: convert to ->poll_mask net/phonet: convert to ->poll_mask net/nfc: convert to ->poll_mask net/caif: convert to ->poll_mask net/bluetooth: convert to ->poll_mask net/sctp: convert to ->poll_mask net/tipc: convert to ->poll_mask ...
2 parents b058efc + 1da9277 commit 408afb8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+849
-595
lines changed

Documentation/filesystems/Locking

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,9 @@ prototypes:
440440
ssize_t (*write_iter) (struct kiocb *, struct iov_iter *);
441441
int (*iterate) (struct file *, struct dir_context *);
442442
int (*iterate_shared) (struct file *, struct dir_context *);
443-
unsigned int (*poll) (struct file *, struct poll_table_struct *);
443+
__poll_t (*poll) (struct file *, struct poll_table_struct *);
444+
struct wait_queue_head * (*get_poll_head)(struct file *, __poll_t);
445+
__poll_t (*poll_mask) (struct file *, __poll_t);
444446
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
445447
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
446448
int (*mmap) (struct file *, struct vm_area_struct *);
@@ -471,7 +473,7 @@ prototypes:
471473
};
472474

473475
locking rules:
474-
All may block.
476+
All except for ->poll_mask may block.
475477

476478
->llseek() locking has moved from llseek to the individual llseek
477479
implementations. If your fs is not using generic_file_llseek, you
@@ -503,6 +505,9 @@ in sys_read() and friends.
503505
the lease within the individual filesystem to record the result of the
504506
operation
505507

508+
->poll_mask can be called with or without the waitqueue lock for the waitqueue
509+
returned from ->get_poll_head.
510+
506511
--------------------------- dquot_operations -------------------------------
507512
prototypes:
508513
int (*write_dquot) (struct dquot *);

Documentation/filesystems/vfs.txt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,9 @@ struct file_operations {
856856
ssize_t (*read_iter) (struct kiocb *, struct iov_iter *);
857857
ssize_t (*write_iter) (struct kiocb *, struct iov_iter *);
858858
int (*iterate) (struct file *, struct dir_context *);
859-
unsigned int (*poll) (struct file *, struct poll_table_struct *);
859+
__poll_t (*poll) (struct file *, struct poll_table_struct *);
860+
struct wait_queue_head * (*get_poll_head)(struct file *, __poll_t);
861+
__poll_t (*poll_mask) (struct file *, __poll_t);
860862
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
861863
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
862864
int (*mmap) (struct file *, struct vm_area_struct *);
@@ -901,6 +903,17 @@ otherwise noted.
901903
activity on this file and (optionally) go to sleep until there
902904
is activity. Called by the select(2) and poll(2) system calls
903905

906+
get_poll_head: Returns the struct wait_queue_head that callers can
907+
wait on. Callers need to check the returned events using ->poll_mask
908+
once woken. Can return NULL to indicate polling is not supported,
909+
or any error code using the ERR_PTR convention to indicate that a
910+
grave error occured and ->poll_mask shall not be called.
911+
912+
poll_mask: return the mask of EPOLL* values describing the file descriptor
913+
state. Called either before going to sleep on the waitqueue returned by
914+
get_poll_head, or after it has been woken. If ->get_poll_head and
915+
->poll_mask are implemented ->poll does not need to be implement.
916+
904917
unlocked_ioctl: called by the ioctl(2) system call.
905918

906919
compat_ioctl: called by the ioctl(2) system call when 32 bit system calls

arch/x86/entry/syscalls/syscall_32.tbl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,3 +396,4 @@
396396
382 i386 pkey_free sys_pkey_free __ia32_sys_pkey_free
397397
383 i386 statx sys_statx __ia32_sys_statx
398398
384 i386 arch_prctl sys_arch_prctl __ia32_compat_sys_arch_prctl
399+
385 i386 io_pgetevents sys_io_pgetevents __ia32_compat_sys_io_pgetevents

arch/x86/entry/syscalls/syscall_64.tbl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@
341341
330 common pkey_alloc __x64_sys_pkey_alloc
342342
331 common pkey_free __x64_sys_pkey_free
343343
332 common statx __x64_sys_statx
344+
333 common io_pgetevents __x64_sys_io_pgetevents
344345

345346
#
346347
# x32-specific system call numbers start at 512 to avoid cache impact

crypto/af_alg.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@ static const struct proto_ops alg_proto_ops = {
347347
.sendpage = sock_no_sendpage,
348348
.sendmsg = sock_no_sendmsg,
349349
.recvmsg = sock_no_recvmsg,
350-
.poll = sock_no_poll,
351350

352351
.bind = alg_bind,
353352
.release = af_alg_release,
@@ -1061,19 +1060,12 @@ void af_alg_async_cb(struct crypto_async_request *_req, int err)
10611060
}
10621061
EXPORT_SYMBOL_GPL(af_alg_async_cb);
10631062

1064-
/**
1065-
* af_alg_poll - poll system call handler
1066-
*/
1067-
__poll_t af_alg_poll(struct file *file, struct socket *sock,
1068-
poll_table *wait)
1063+
__poll_t af_alg_poll_mask(struct socket *sock, __poll_t events)
10691064
{
10701065
struct sock *sk = sock->sk;
10711066
struct alg_sock *ask = alg_sk(sk);
10721067
struct af_alg_ctx *ctx = ask->private;
1073-
__poll_t mask;
1074-
1075-
sock_poll_wait(file, sk_sleep(sk), wait);
1076-
mask = 0;
1068+
__poll_t mask = 0;
10771069

10781070
if (!ctx->more || ctx->used)
10791071
mask |= EPOLLIN | EPOLLRDNORM;
@@ -1083,7 +1075,7 @@ __poll_t af_alg_poll(struct file *file, struct socket *sock,
10831075

10841076
return mask;
10851077
}
1086-
EXPORT_SYMBOL_GPL(af_alg_poll);
1078+
EXPORT_SYMBOL_GPL(af_alg_poll_mask);
10871079

10881080
/**
10891081
* af_alg_alloc_areq - allocate struct af_alg_async_req

crypto/algif_aead.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ static struct proto_ops algif_aead_ops = {
375375
.sendmsg = aead_sendmsg,
376376
.sendpage = af_alg_sendpage,
377377
.recvmsg = aead_recvmsg,
378-
.poll = af_alg_poll,
378+
.poll_mask = af_alg_poll_mask,
379379
};
380380

381381
static int aead_check_key(struct socket *sock)
@@ -471,7 +471,7 @@ static struct proto_ops algif_aead_ops_nokey = {
471471
.sendmsg = aead_sendmsg_nokey,
472472
.sendpage = aead_sendpage_nokey,
473473
.recvmsg = aead_recvmsg_nokey,
474-
.poll = af_alg_poll,
474+
.poll_mask = af_alg_poll_mask,
475475
};
476476

477477
static void *aead_bind(const char *name, u32 type, u32 mask)

crypto/algif_hash.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,6 @@ static struct proto_ops algif_hash_ops = {
288288
.mmap = sock_no_mmap,
289289
.bind = sock_no_bind,
290290
.setsockopt = sock_no_setsockopt,
291-
.poll = sock_no_poll,
292291

293292
.release = af_alg_release,
294293
.sendmsg = hash_sendmsg,
@@ -396,7 +395,6 @@ static struct proto_ops algif_hash_ops_nokey = {
396395
.mmap = sock_no_mmap,
397396
.bind = sock_no_bind,
398397
.setsockopt = sock_no_setsockopt,
399-
.poll = sock_no_poll,
400398

401399
.release = af_alg_release,
402400
.sendmsg = hash_sendmsg_nokey,

crypto/algif_rng.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ static struct proto_ops algif_rng_ops = {
106106
.bind = sock_no_bind,
107107
.accept = sock_no_accept,
108108
.setsockopt = sock_no_setsockopt,
109-
.poll = sock_no_poll,
110109
.sendmsg = sock_no_sendmsg,
111110
.sendpage = sock_no_sendpage,
112111

crypto/algif_skcipher.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ static struct proto_ops algif_skcipher_ops = {
205205
.sendmsg = skcipher_sendmsg,
206206
.sendpage = af_alg_sendpage,
207207
.recvmsg = skcipher_recvmsg,
208-
.poll = af_alg_poll,
208+
.poll_mask = af_alg_poll_mask,
209209
};
210210

211211
static int skcipher_check_key(struct socket *sock)
@@ -301,7 +301,7 @@ static struct proto_ops algif_skcipher_ops_nokey = {
301301
.sendmsg = skcipher_sendmsg_nokey,
302302
.sendpage = skcipher_sendpage_nokey,
303303
.recvmsg = skcipher_recvmsg_nokey,
304-
.poll = af_alg_poll,
304+
.poll_mask = af_alg_poll_mask,
305305
};
306306

307307
static void *skcipher_bind(const char *name, u32 type, u32 mask)

drivers/char/random.c

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,7 @@ static struct poolinfo {
402402
/*
403403
* Static global variables
404404
*/
405-
static DECLARE_WAIT_QUEUE_HEAD(random_read_wait);
406-
static DECLARE_WAIT_QUEUE_HEAD(random_write_wait);
405+
static DECLARE_WAIT_QUEUE_HEAD(random_wait);
407406
static struct fasync_struct *fasync;
408407

409408
static DEFINE_SPINLOCK(random_ready_list_lock);
@@ -722,8 +721,8 @@ static void credit_entropy_bits(struct entropy_store *r, int nbits)
722721

723722
/* should we wake readers? */
724723
if (entropy_bits >= random_read_wakeup_bits &&
725-
wq_has_sleeper(&random_read_wait)) {
726-
wake_up_interruptible(&random_read_wait);
724+
wq_has_sleeper(&random_wait)) {
725+
wake_up_interruptible_poll(&random_wait, POLLIN);
727726
kill_fasync(&fasync, SIGIO, POLL_IN);
728727
}
729728
/* If the input pool is getting full, send some
@@ -1397,7 +1396,7 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
13971396
trace_debit_entropy(r->name, 8 * ibytes);
13981397
if (ibytes &&
13991398
(r->entropy_count >> ENTROPY_SHIFT) < random_write_wakeup_bits) {
1400-
wake_up_interruptible(&random_write_wait);
1399+
wake_up_interruptible_poll(&random_wait, POLLOUT);
14011400
kill_fasync(&fasync, SIGIO, POLL_OUT);
14021401
}
14031402

@@ -1839,7 +1838,7 @@ _random_read(int nonblock, char __user *buf, size_t nbytes)
18391838
if (nonblock)
18401839
return -EAGAIN;
18411840

1842-
wait_event_interruptible(random_read_wait,
1841+
wait_event_interruptible(random_wait,
18431842
ENTROPY_BITS(&input_pool) >=
18441843
random_read_wakeup_bits);
18451844
if (signal_pending(current))
@@ -1876,14 +1875,17 @@ urandom_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
18761875
return ret;
18771876
}
18781877

1878+
static struct wait_queue_head *
1879+
random_get_poll_head(struct file *file, __poll_t events)
1880+
{
1881+
return &random_wait;
1882+
}
1883+
18791884
static __poll_t
1880-
random_poll(struct file *file, poll_table * wait)
1885+
random_poll_mask(struct file *file, __poll_t events)
18811886
{
1882-
__poll_t mask;
1887+
__poll_t mask = 0;
18831888

1884-
poll_wait(file, &random_read_wait, wait);
1885-
poll_wait(file, &random_write_wait, wait);
1886-
mask = 0;
18871889
if (ENTROPY_BITS(&input_pool) >= random_read_wakeup_bits)
18881890
mask |= EPOLLIN | EPOLLRDNORM;
18891891
if (ENTROPY_BITS(&input_pool) < random_write_wakeup_bits)
@@ -1990,7 +1992,8 @@ static int random_fasync(int fd, struct file *filp, int on)
19901992
const struct file_operations random_fops = {
19911993
.read = random_read,
19921994
.write = random_write,
1993-
.poll = random_poll,
1995+
.get_poll_head = random_get_poll_head,
1996+
.poll_mask = random_poll_mask,
19941997
.unlocked_ioctl = random_ioctl,
19951998
.fasync = random_fasync,
19961999
.llseek = noop_llseek,
@@ -2323,7 +2326,7 @@ void add_hwgenerator_randomness(const char *buffer, size_t count,
23232326
* We'll be woken up again once below random_write_wakeup_thresh,
23242327
* or when the calling thread is about to terminate.
23252328
*/
2326-
wait_event_interruptible(random_write_wait, kthread_should_stop() ||
2329+
wait_event_interruptible(random_wait, kthread_should_stop() ||
23272330
ENTROPY_BITS(&input_pool) <= random_write_wakeup_bits);
23282331
mix_pool_bytes(poolp, buffer, count);
23292332
credit_entropy_bits(poolp, entropy);

drivers/isdn/mISDN/socket.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ static const struct proto_ops data_sock_ops = {
588588
.getname = data_sock_getname,
589589
.sendmsg = mISDN_sock_sendmsg,
590590
.recvmsg = mISDN_sock_recvmsg,
591-
.poll = datagram_poll,
591+
.poll_mask = datagram_poll_mask,
592592
.listen = sock_no_listen,
593593
.shutdown = sock_no_shutdown,
594594
.setsockopt = data_sock_setsockopt,
@@ -745,7 +745,6 @@ static const struct proto_ops base_sock_ops = {
745745
.getname = sock_no_getname,
746746
.sendmsg = sock_no_sendmsg,
747747
.recvmsg = sock_no_recvmsg,
748-
.poll = sock_no_poll,
749748
.listen = sock_no_listen,
750749
.shutdown = sock_no_shutdown,
751750
.setsockopt = sock_no_setsockopt,

drivers/net/ppp/pppoe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,7 @@ static const struct proto_ops pppoe_ops = {
11071107
.socketpair = sock_no_socketpair,
11081108
.accept = sock_no_accept,
11091109
.getname = pppoe_getname,
1110-
.poll = datagram_poll,
1110+
.poll_mask = datagram_poll_mask,
11111111
.listen = sock_no_listen,
11121112
.shutdown = sock_no_shutdown,
11131113
.setsockopt = sock_no_setsockopt,

drivers/net/ppp/pptp.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,6 @@ static const struct proto_ops pptp_ops = {
624624
.socketpair = sock_no_socketpair,
625625
.accept = sock_no_accept,
626626
.getname = pptp_getname,
627-
.poll = sock_no_poll,
628627
.listen = sock_no_listen,
629628
.shutdown = sock_no_shutdown,
630629
.setsockopt = sock_no_setsockopt,

drivers/staging/comedi/drivers/serial2002.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static void serial2002_tty_read_poll_wait(struct file *f, int timeout)
113113
long elapsed;
114114
__poll_t mask;
115115

116-
mask = f->f_op->poll(f, &table.pt);
116+
mask = vfs_poll(f, &table.pt);
117117
if (mask & (EPOLLRDNORM | EPOLLRDBAND | EPOLLIN |
118118
EPOLLHUP | EPOLLERR)) {
119119
break;
@@ -136,7 +136,7 @@ static int serial2002_tty_read(struct file *f, int timeout)
136136

137137
result = -1;
138138
if (!IS_ERR(f)) {
139-
if (f->f_op->poll) {
139+
if (file_can_poll(f)) {
140140
serial2002_tty_read_poll_wait(f, timeout);
141141

142142
if (kernel_read(f, &ch, 1, &pos) == 1)

drivers/staging/ipx/af_ipx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1965,7 +1965,7 @@ static const struct proto_ops ipx_dgram_ops = {
19651965
.socketpair = sock_no_socketpair,
19661966
.accept = sock_no_accept,
19671967
.getname = ipx_getname,
1968-
.poll = datagram_poll,
1968+
.poll_mask = datagram_poll_mask,
19691969
.ioctl = ipx_ioctl,
19701970
#ifdef CONFIG_COMPAT
19711971
.compat_ioctl = ipx_compat_ioctl,

drivers/vfio/virqfd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ int vfio_virqfd_enable(void *opaque,
166166
init_waitqueue_func_entry(&virqfd->wait, virqfd_wakeup);
167167
init_poll_funcptr(&virqfd->pt, virqfd_ptable_queue_proc);
168168

169-
events = irqfd.file->f_op->poll(irqfd.file, &virqfd->pt);
169+
events = vfs_poll(irqfd.file, &virqfd->pt);
170170

171171
/*
172172
* Check if there was an event already pending on the eventfd

drivers/vhost/vhost.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ int vhost_poll_start(struct vhost_poll *poll, struct file *file)
208208
if (poll->wqh)
209209
return 0;
210210

211-
mask = file->f_op->poll(file, &poll->table);
211+
mask = vfs_poll(file, &poll->table);
212212
if (mask)
213213
vhost_poll_wakeup(&poll->wait, 0, 0, poll_to_key(mask));
214214
if (mask & EPOLLERR) {

0 commit comments

Comments
 (0)