projects/linux·commit 408afb8d

Merge branch 'work.aio-1' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

408afb8d · Linus Torvalds <[email protected]> · 2018-06-04 13:57:43 -07:00

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
  ...
Commit
408afb8d7847faea115508ba154346e33edfc7d5
Parents
b058efc1 · 1da92779

Merge commit. Changes below are compared with the first parent: b058efc1.

Changes

99 files changed · +849 −595

FileStatusAddDelContent
Documentation/filesystems/Lockingmodified+7−2View file
Documentation/filesystems/vfs.txtmodified+14−1View file
arch/x86/entry/syscalls/syscall_32.tblmodified+1−0View file
arch/x86/entry/syscalls/syscall_64.tblmodified+1−0View file
crypto/af_alg.cmodified+3−11View file
crypto/algif_aead.cmodified+2−2View file
crypto/algif_hash.cmodified+0−2View file
crypto/algif_rng.cmodified+0−1View file
crypto/algif_skcipher.cmodified+2−2View file
drivers/char/random.cmodified+16−13View file
drivers/isdn/mISDN/socket.cmodified+1−2View file
drivers/net/ppp/pppoe.cmodified+1−1View file
drivers/net/ppp/pptp.cmodified+0−1View file
drivers/staging/comedi/drivers/serial2002.cmodified+2−2View file
drivers/staging/ipx/af_ipx.cmodified+1−1View file
drivers/vfio/virqfd.cmodified+1−1View file
drivers/vhost/vhost.cmodified+1−1View file
fs/aio.cmodified+492−239View file
fs/eventfd.cmodified+11−4View file
fs/eventpoll.cmodified+2−3View file
fs/pipe.cmodified+13−9View file
fs/select.cmodified+49−36View file
fs/timerfd.cmodified+11−11View file
include/crypto/if_alg.hmodified+1−2View file
include/linux/aio.hmodified+0−2View file
include/linux/compat.hmodified+7−0View file
include/linux/fs.hmodified+2−0View file
include/linux/net.hmodified+1−0View file
include/linux/poll.hmodified+12−2View file
include/linux/skbuff.hmodified+1−2View file
include/linux/syscalls.hmodified+6−0View file
include/net/bluetooth/bluetooth.hmodified+1−1View file
include/net/busy_poll.hmodified+15−0View file
include/net/iucv/af_iucv.hmodified+0−2View file
include/net/sctp/sctp.hmodified+1−2View file
include/net/sock.hmodified+0−2View file
include/net/tcp.hmodified+1−2View file
include/net/udp.hmodified+1−1View file
include/uapi/asm-generic/unistd.hmodified+3−1View file
include/uapi/linux/aio_abi.hmodified+8−4View file
include/uapi/linux/types.hmodified+0−4View file
kernel/sys_ni.cmodified+2−0View file
mm/memcontrol.cmodified+1−1View file
net/9p/trans_fd.cmodified+4−14View file
net/appletalk/ddp.cmodified+1−1View file
net/atm/common.cmodified+3−8View file
net/atm/common.hmodified+1−1View file
net/atm/pvc.cmodified+1−1View file
net/atm/svc.cmodified+1−1View file
net/ax25/af_ax25.cmodified+1−1View file
net/bluetooth/af_bluetooth.cmodified+2−5View file
net/bluetooth/bnep/sock.cmodified+0−1View file
net/bluetooth/cmtp/sock.cmodified+0−1View file
net/bluetooth/hci_sock.cmodified+1−1View file
net/bluetooth/hidp/sock.cmodified+0−1View file
net/bluetooth/l2cap_sock.cmodified+1−1View file
net/bluetooth/rfcomm/sock.cmodified+1−1View file
net/bluetooth/sco.cmodified+1−1View file
net/caif/caif_socket.cmodified+4−8View file
net/can/bcm.cmodified+1−1View file
net/can/raw.cmodified+1−1View file
net/core/datagram.cmodified+4−9View file
net/core/sock.cmodified+0−6View file
net/dccp/dccp.hmodified+1−2View file
net/dccp/ipv4.cmodified+1−1View file
net/dccp/ipv6.cmodified+1−1View file
net/dccp/proto.cmodified+2−11View file
net/decnet/af_decnet.cmodified+3−3View file
net/ieee802154/socket.cmodified+2−2View file
net/ipv4/af_inet.cmodified+4−4View file
net/ipv4/tcp.cmodified+6−17View file
net/ipv4/udp.cmodified+5−5View file
net/ipv6/af_inet6.cmodified+2−2View file
net/ipv6/raw.cmodified+2−2View file
net/iucv/af_iucv.cmodified+2−5View file
net/kcm/kcmsock.cmodified+5−5View file
net/key/af_key.cmodified+1−1View file
net/l2tp/l2tp_ip.cmodified+1−1View file
net/l2tp/l2tp_ip6.cmodified+1−1View file
net/l2tp/l2tp_ppp.cmodified+1−1View file
net/llc/af_llc.cmodified+1−1View file
net/netlink/af_netlink.cmodified+1−1View file
net/netrom/af_netrom.cmodified+1−1View file
net/nfc/llcp_sock.cmodified+3−6View file
net/nfc/rawsock.cmodified+2−2View file
net/packet/af_packet.cmodified+4−5View file
net/phonet/socket.cmodified+3−6View file
net/qrtr/qrtr.cmodified+1−1View file
net/rose/af_rose.cmodified+1−1View file
net/rxrpc/af_rxrpc.cmodified+3−7View file
net/sctp/ipv6.cmodified+1−1View file
net/sctp/protocol.cmodified+1−1View file
net/sctp/socket.cmodified+1−3View file
net/socket.cmodified+40−15View file
net/tipc/socket.cmodified+5−9View file
net/unix/af_unix.cmodified+11−19View file
net/vmw_vsock/af_vsock.cmodified+6−13View file
net/x25/af_x25.cmodified+1−1View file
virt/kvm/eventfd.cmodified+1−1View file

Only the first 600 diff lines are shown. Download the complete patch.

Documentation/filesystems/Locking

View file
diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking
index 15853d5..2c39133 100644
--- a/Documentation/filesystems/Locking
+++ b/Documentation/filesystems/Locking
@@ -440,7 +440,9 @@ prototypes:
ssize_t (*write_iter) (struct kiocb *, struct iov_iter *);
int (*iterate) (struct file *, struct dir_context *);
int (*iterate_shared) (struct file *, struct dir_context *);
- unsigned int (*poll) (struct file *, struct poll_table_struct *);
+ __poll_t (*poll) (struct file *, struct poll_table_struct *);
+ struct wait_queue_head * (*get_poll_head)(struct file *, __poll_t);
+ __poll_t (*poll_mask) (struct file *, __poll_t);
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
int (*mmap) (struct file *, struct vm_area_struct *);
@@ -471,7 +473,7 @@ prototypes:
};
locking rules:
- All may block.
+ All except for ->poll_mask may block.
->llseek() locking has moved from llseek to the individual llseek
implementations. If your fs is not using generic_file_llseek, you
@@ -503,6 +505,9 @@ in sys_read() and friends.
the lease within the individual filesystem to record the result of the
operation
+->poll_mask can be called with or without the waitqueue lock for the waitqueue
+returned from ->get_poll_head.
+
--------------------------- dquot_operations -------------------------------
prototypes:
int (*write_dquot) (struct dquot *);

Documentation/filesystems/vfs.txt

View file
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt
index 5fd325d..829a7b7 100644
--- a/Documentation/filesystems/vfs.txt
+++ b/Documentation/filesystems/vfs.txt
@@ -856,7 +856,9 @@ struct file_operations {
ssize_t (*read_iter) (struct kiocb *, struct iov_iter *);
ssize_t (*write_iter) (struct kiocb *, struct iov_iter *);
int (*iterate) (struct file *, struct dir_context *);
- unsigned int (*poll) (struct file *, struct poll_table_struct *);
+ __poll_t (*poll) (struct file *, struct poll_table_struct *);
+ struct wait_queue_head * (*get_poll_head)(struct file *, __poll_t);
+ __poll_t (*poll_mask) (struct file *, __poll_t);
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
int (*mmap) (struct file *, struct vm_area_struct *);
@@ -901,6 +903,17 @@ otherwise noted.
activity on this file and (optionally) go to sleep until there
is activity. Called by the select(2) and poll(2) system calls
+ get_poll_head: Returns the struct wait_queue_head that callers can
+ wait on. Callers need to check the returned events using ->poll_mask
+ once woken. Can return NULL to indicate polling is not supported,
+ or any error code using the ERR_PTR convention to indicate that a
+ grave error occured and ->poll_mask shall not be called.
+
+ poll_mask: return the mask of EPOLL* values describing the file descriptor
+ state. Called either before going to sleep on the waitqueue returned by
+ get_poll_head, or after it has been woken. If ->get_poll_head and
+ ->poll_mask are implemented ->poll does not need to be implement.
+
unlocked_ioctl: called by the ioctl(2) system call.
compat_ioctl: called by the ioctl(2) system call when 32 bit system calls

arch/x86/entry/syscalls/syscall_32.tbl

View file
diff --git a/arch/x86/entry/syscalls/syscall_32.tbl b/arch/x86/entry/syscalls/syscall_32.tbl
index d6b27da..14a2f99 100644
--- a/arch/x86/entry/syscalls/syscall_32.tbl
+++ b/arch/x86/entry/syscalls/syscall_32.tbl
@@ -396,3 +396,4 @@
382 i386 pkey_free sys_pkey_free __ia32_sys_pkey_free
383 i386 statx sys_statx __ia32_sys_statx
384 i386 arch_prctl sys_arch_prctl __ia32_compat_sys_arch_prctl
+385 i386 io_pgetevents sys_io_pgetevents __ia32_compat_sys_io_pgetevents

arch/x86/entry/syscalls/syscall_64.tbl

View file
diff --git a/arch/x86/entry/syscalls/syscall_64.tbl b/arch/x86/entry/syscalls/syscall_64.tbl
index 4dfe426..cd36232 100644
--- a/arch/x86/entry/syscalls/syscall_64.tbl
+++ b/arch/x86/entry/syscalls/syscall_64.tbl
@@ -341,6 +341,7 @@
330 common pkey_alloc __x64_sys_pkey_alloc
331 common pkey_free __x64_sys_pkey_free
332 common statx __x64_sys_statx
+333 common io_pgetevents __x64_sys_io_pgetevents
#
# x32-specific system call numbers start at 512 to avoid cache impact

crypto/af_alg.c

View file
diff --git a/crypto/af_alg.c b/crypto/af_alg.c
index 7846c0c..89ed613 100644
--- a/crypto/af_alg.c
+++ b/crypto/af_alg.c
@@ -347,7 +347,6 @@ static const struct proto_ops alg_proto_ops = {
.sendpage = sock_no_sendpage,
.sendmsg = sock_no_sendmsg,
.recvmsg = sock_no_recvmsg,
- .poll = sock_no_poll,
.bind = alg_bind,
.release = af_alg_release,
@@ -1061,19 +1060,12 @@ void af_alg_async_cb(struct crypto_async_request *_req, int err)
}
EXPORT_SYMBOL_GPL(af_alg_async_cb);
-/**
- * af_alg_poll - poll system call handler
- */
-__poll_t af_alg_poll(struct file *file, struct socket *sock,
- poll_table *wait)
+__poll_t af_alg_poll_mask(struct socket *sock, __poll_t events)
{
struct sock *sk = sock->sk;
struct alg_sock *ask = alg_sk(sk);
struct af_alg_ctx *ctx = ask->private;
- __poll_t mask;
-
- sock_poll_wait(file, sk_sleep(sk), wait);
- mask = 0;
+ __poll_t mask = 0;
if (!ctx->more || ctx->used)
mask |= EPOLLIN | EPOLLRDNORM;
@@ -1083,7 +1075,7 @@ __poll_t af_alg_poll(struct file *file, struct socket *sock,
return mask;
}
-EXPORT_SYMBOL_GPL(af_alg_poll);
+EXPORT_SYMBOL_GPL(af_alg_poll_mask);
/**
* af_alg_alloc_areq - allocate struct af_alg_async_req

crypto/algif_aead.c

View file
diff --git a/crypto/algif_aead.c b/crypto/algif_aead.c
index 4b07edd..330cf9f 100644
--- a/crypto/algif_aead.c
+++ b/crypto/algif_aead.c
@@ -375,7 +375,7 @@ static struct proto_ops algif_aead_ops = {
.sendmsg = aead_sendmsg,
.sendpage = af_alg_sendpage,
.recvmsg = aead_recvmsg,
- .poll = af_alg_poll,
+ .poll_mask = af_alg_poll_mask,
};
static int aead_check_key(struct socket *sock)
@@ -471,7 +471,7 @@ static struct proto_ops algif_aead_ops_nokey = {
.sendmsg = aead_sendmsg_nokey,
.sendpage = aead_sendpage_nokey,
.recvmsg = aead_recvmsg_nokey,
- .poll = af_alg_poll,
+ .poll_mask = af_alg_poll_mask,
};
static void *aead_bind(const char *name, u32 type, u32 mask)

crypto/algif_hash.c

View file
diff --git a/crypto/algif_hash.c b/crypto/algif_hash.c
index 6c9b192..bfcf595 100644
--- a/crypto/algif_hash.c
+++ b/crypto/algif_hash.c
@@ -288,7 +288,6 @@ static struct proto_ops algif_hash_ops = {
.mmap = sock_no_mmap,
.bind = sock_no_bind,
.setsockopt = sock_no_setsockopt,
- .poll = sock_no_poll,
.release = af_alg_release,
.sendmsg = hash_sendmsg,
@@ -396,7 +395,6 @@ static struct proto_ops algif_hash_ops_nokey = {
.mmap = sock_no_mmap,
.bind = sock_no_bind,
.setsockopt = sock_no_setsockopt,
- .poll = sock_no_poll,
.release = af_alg_release,
.sendmsg = hash_sendmsg_nokey,

crypto/algif_rng.c

View file
diff --git a/crypto/algif_rng.c b/crypto/algif_rng.c
index 150c2b6..22df379 100644
--- a/crypto/algif_rng.c
+++ b/crypto/algif_rng.c
@@ -106,7 +106,6 @@ static struct proto_ops algif_rng_ops = {
.bind = sock_no_bind,
.accept = sock_no_accept,
.setsockopt = sock_no_setsockopt,
- .poll = sock_no_poll,
.sendmsg = sock_no_sendmsg,
.sendpage = sock_no_sendpage,

crypto/algif_skcipher.c

View file
diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c
index c4e885d..15cf3c5 100644
--- a/crypto/algif_skcipher.c
+++ b/crypto/algif_skcipher.c
@@ -205,7 +205,7 @@ static struct proto_ops algif_skcipher_ops = {
.sendmsg = skcipher_sendmsg,
.sendpage = af_alg_sendpage,
.recvmsg = skcipher_recvmsg,
- .poll = af_alg_poll,
+ .poll_mask = af_alg_poll_mask,
};
static int skcipher_check_key(struct socket *sock)
@@ -301,7 +301,7 @@ static struct proto_ops algif_skcipher_ops_nokey = {
.sendmsg = skcipher_sendmsg_nokey,
.sendpage = skcipher_sendpage_nokey,
.recvmsg = skcipher_recvmsg_nokey,
- .poll = af_alg_poll,
+ .poll_mask = af_alg_poll_mask,
};
static void *skcipher_bind(const char *name, u32 type, u32 mask)

drivers/char/random.c

View file
diff --git a/drivers/char/random.c b/drivers/char/random.c
index cd888d4..a8fb002 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -402,8 +402,7 @@ static struct poolinfo {
/*
* Static global variables
*/
-static DECLARE_WAIT_QUEUE_HEAD(random_read_wait);
-static DECLARE_WAIT_QUEUE_HEAD(random_write_wait);
+static DECLARE_WAIT_QUEUE_HEAD(random_wait);
static struct fasync_struct *fasync;
static DEFINE_SPINLOCK(random_ready_list_lock);
@@ -722,8 +721,8 @@ retry:
/* should we wake readers? */
if (entropy_bits >= random_read_wakeup_bits &&
- wq_has_sleeper(&random_read_wait)) {
- wake_up_interruptible(&random_read_wait);
+ wq_has_sleeper(&random_wait)) {
+ wake_up_interruptible_poll(&random_wait, POLLIN);
kill_fasync(&fasync, SIGIO, POLL_IN);
}
/* If the input pool is getting full, send some
@@ -1397,7 +1396,7 @@ retry:
trace_debit_entropy(r->name, 8 * ibytes);
if (ibytes &&
(r->entropy_count >> ENTROPY_SHIFT) < random_write_wakeup_bits) {
- wake_up_interruptible(&random_write_wait);
+ wake_up_interruptible_poll(&random_wait, POLLOUT);
kill_fasync(&fasync, SIGIO, POLL_OUT);
}
@@ -1839,7 +1838,7 @@ _random_read(int nonblock, char __user *buf, size_t nbytes)
if (nonblock)
return -EAGAIN;
- wait_event_interruptible(random_read_wait,
+ wait_event_interruptible(random_wait,
ENTROPY_BITS(&input_pool) >=
random_read_wakeup_bits);
if (signal_pending(current))
@@ -1876,14 +1875,17 @@ urandom_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
return ret;
}
+static struct wait_queue_head *
+random_get_poll_head(struct file *file, __poll_t events)
+{
+ return &random_wait;
+}
+
static __poll_t
-random_poll(struct file *file, poll_table * wait)
+random_poll_mask(struct file *file, __poll_t events)
{
- __poll_t mask;
+ __poll_t mask = 0;
- poll_wait(file, &random_read_wait, wait);
- poll_wait(file, &random_write_wait, wait);
- mask = 0;
if (ENTROPY_BITS(&input_pool) >= random_read_wakeup_bits)
mask |= EPOLLIN | EPOLLRDNORM;
if (ENTROPY_BITS(&input_pool) < random_write_wakeup_bits)
@@ -1990,7 +1992,8 @@ static int random_fasync(int fd, struct file *filp, int on)
const struct file_operations random_fops = {
.read = random_read,
.write = random_write,
- .poll = random_poll,
+ .get_poll_head = random_get_poll_head,
+ .poll_mask = random_poll_mask,
.unlocked_ioctl = random_ioctl,
.fasync = random_fasync,
.llseek = noop_llseek,
@@ -2323,7 +2326,7 @@ void add_hwgenerator_randomness(const char *buffer, size_t count,
* We'll be woken up again once below random_write_wakeup_thresh,
* or when the calling thread is about to terminate.
*/
- wait_event_interruptible(random_write_wait, kthread_should_stop() ||
+ wait_event_interruptible(random_wait, kthread_should_stop() ||
ENTROPY_BITS(&input_pool) <= random_write_wakeup_bits);
mix_pool_bytes(poolp, buffer, count);
credit_entropy_bits(poolp, entropy);

drivers/isdn/mISDN/socket.c

View file
diff --git a/drivers/isdn/mISDN/socket.c b/drivers/isdn/mISDN/socket.c
index 1f8f489..98f90aa 100644
--- a/drivers/isdn/mISDN/socket.c
+++ b/drivers/isdn/mISDN/socket.c
@@ -588,7 +588,7 @@ static const struct proto_ops data_sock_ops = {
.getname = data_sock_getname,
.sendmsg = mISDN_sock_sendmsg,
.recvmsg = mISDN_sock_recvmsg,
- .poll = datagram_poll,
+ .poll_mask = datagram_poll_mask,
.listen = sock_no_listen,
.shutdown = sock_no_shutdown,
.setsockopt = data_sock_setsockopt,
@@ -745,7 +745,6 @@ static const struct proto_ops base_sock_ops = {
.getname = sock_no_getname,
.sendmsg = sock_no_sendmsg,
.recvmsg = sock_no_recvmsg,
- .poll = sock_no_poll,
.listen = sock_no_listen,
.shutdown = sock_no_shutdown,
.setsockopt = sock_no_setsockopt,

drivers/net/ppp/pppoe.c

View file
diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c
index ce61231..de51e8f 100644
--- a/drivers/net/ppp/pppoe.c
+++ b/drivers/net/ppp/pppoe.c
@@ -1107,7 +1107,7 @@ static const struct proto_ops pppoe_ops = {
.socketpair = sock_no_socketpair,
.accept = sock_no_accept,
.getname = pppoe_getname,
- .poll = datagram_poll,
+ .poll_mask = datagram_poll_mask,
.listen = sock_no_listen,
.shutdown = sock_no_shutdown,
.setsockopt = sock_no_setsockopt,

drivers/net/ppp/pptp.c

View file
diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c
index c4267ec..157b67c 100644
--- a/drivers/net/ppp/pptp.c
+++ b/drivers/net/ppp/pptp.c
@@ -624,7 +624,6 @@ static const struct proto_ops pptp_ops = {
.socketpair = sock_no_socketpair,
.accept = sock_no_accept,
.getname = pptp_getname,
- .poll = sock_no_poll,
.listen = sock_no_listen,
.shutdown = sock_no_shutdown,
.setsockopt = sock_no_setsockopt,

drivers/staging/comedi/drivers/serial2002.c

View file
diff --git a/drivers/staging/comedi/drivers/serial2002.c b/drivers/staging/comedi/drivers/serial2002.c
index b3f3b4a..5471b22 100644
--- a/drivers/staging/comedi/drivers/serial2002.c
+++ b/drivers/staging/comedi/drivers/serial2002.c
@@ -113,7 +113,7 @@ static void serial2002_tty_read_poll_wait(struct file *f, int timeout)
long elapsed;
__poll_t mask;
- mask = f->f_op->poll(f, &table.pt);
+ mask = vfs_poll(f, &table.pt);
if (mask & (EPOLLRDNORM | EPOLLRDBAND | EPOLLIN |
EPOLLHUP | EPOLLERR)) {
break;
@@ -136,7 +136,7 @@ static int serial2002_tty_read(struct file *f, int timeout)
result = -1;
if (!IS_ERR(f)) {
- if (f->f_op->poll) {
+ if (file_can_poll(f)) {
serial2002_tty_read_poll_wait(f, timeout);
if (kernel_read(f, &ch, 1, &pos) == 1)

drivers/staging/ipx/af_ipx.c

View file
diff --git a/drivers/staging/ipx/af_ipx.c b/drivers/staging/ipx/af_ipx.c
index 5703dd1..208b5c1 100644
--- a/drivers/staging/ipx/af_ipx.c
+++ b/drivers/staging/ipx/af_ipx.c
@@ -1965,7 +1965,7 @@ static const struct proto_ops ipx_dgram_ops = {
.socketpair = sock_no_socketpair,
.accept = sock_no_accept,
.getname = ipx_getname,
- .poll = datagram_poll,
+ .poll_mask = datagram_poll_mask,
.ioctl = ipx_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = ipx_compat_ioctl,

drivers/vfio/virqfd.c

View file
diff --git a/drivers/vfio/virqfd.c b/drivers/vfio/virqfd.c
index 085700f..2a1be85 100644
--- a/drivers/vfio/virqfd.c
+++ b/drivers/vfio/virqfd.c
@@ -166,7 +166,7 @@ int vfio_virqfd_enable(void *opaque,
init_waitqueue_func_entry(&virqfd->wait, virqfd_wakeup);
init_poll_funcptr(&virqfd->pt, virqfd_ptable_queue_proc);
- events = irqfd.file->f_op->poll(irqfd.file, &virqfd->pt);
+ events = vfs_poll(irqfd.file, &virqfd->pt);
/*
* Check if there was an event already pending on the eventfd

drivers/vhost/vhost.c

View file
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index f0be5f3..895eaa2 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -208,7 +208,7 @@ int vhost_poll_start(struct vhost_poll *poll, struct file *file)
if (poll->wqh)
return 0;
- mask = file->f_op->poll(file, &poll->table);
+ mask = vfs_poll(file, &poll->table);
if (mask)
vhost_poll_wakeup(&poll->wait, 0, 0, poll_to_key(mask));
if (mask & EPOLLERR) {

fs/aio.c

View file
diff --git a/fs/aio.c b/fs/aio.c
index 49f5351..b850e92 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -5,6 +5,7 @@
* Implements an efficient asynchronous io interface.
*
* Copyright 2000, 2001, 2002 Red Hat, Inc. All Rights Reserved.
+ * Copyright 2018 Christoph Hellwig.
*
* See ../COPYING for licensing terms.
*/
@@ -46,6 +47,8 @@
#include "internal.h"
+#define KIOCB_KEY 0
+
#define AIO_RING_MAGIC 0xa10a10a1
#define AIO_RING_COMPAT_FEATURES 1
#define AIO_RING_INCOMPAT_FEATURES 0
@@ -156,21 +159,29 @@ struct kioctx {
unsigned id;
};
-/*
- * We use ki_cancel == KIOCB_CANCELLED to indicate that a kiocb has been either
- * cancelled or completed (this makes a certain amount of sense because
- * successful cancellation - io_cancel() - does deliver the completion to
- * userspace).
- *
- * And since most things don't implement kiocb cancellation and we'd really like
- * kiocb completion to be lockless when possible, we use ki_cancel to
- * synchronize cancellation and completion - we only set it to KIOCB_CANCELLED
- * with xchg() or cmpxchg(), see batch_complete_aio() and kiocb_cancel().
- */
-#define KIOCB_CANCELLED ((void *) (~0ULL))
+struct fsync_iocb {
+ struct work_struct work;
+ struct file *file;
+ bool datasync;
+};
+
+struct poll_iocb {
+ struct file *file;
+ __poll_t events;
+ struct wait_queue_head *head;
+
+ union {
+ struct wait_queue_entry wait;
+ struct work_struct work;
+ };
+};
struct aio_kiocb {
- struct kiocb common;
+ union {
+ struct kiocb rw;
+ struct fsync_iocb fsync;
+ struct poll_iocb poll;
+ };
struct kioctx *ki_ctx;
kiocb_cancel_fn *ki_cancel;
@@ -264,9 +275,6 @@ static int __init aio_setup(void)
kiocb_cachep = KMEM_CACHE(aio_kiocb, SLAB_HWCACHE_ALIGN|SLAB_PANIC);
kioctx_cachep = KMEM_CACHE(kioctx,SLAB_HWCACHE_ALIGN|SLAB_PANIC);
-
- pr_debug("sizeof(struct page) = %zu\n", sizeof(struct page));
-
return 0;
}
__initcall(aio_setup);
@@ -552,42 +560,20 @@ static int aio_setup_ring(struct kioctx *ctx, unsigned int nr_events)
void kiocb_set_cancel_fn(struct kiocb *iocb, kiocb_cancel_fn *cancel)
{
- struct aio_kiocb *req = container_of(iocb, struct aio_kiocb, common);
+ struct aio_kiocb *req = container_of(iocb, struct aio_kiocb, rw);
struct kioctx *ctx = req->ki_ctx;
unsigned long flags;
- spin_lock_irqsave(&ctx->ctx_lock, flags);
-
- if (!req->ki_list.next)
- list_add(&req->ki_list, &ctx->active_reqs);
+ if (WARN_ON_ONCE(!list_empty(&req->ki_list)))
+ return;
+ spin_lock_irqsave(&ctx->ctx_lock, flags);
+ list_add_tail(&req->ki_list, &ctx->active_reqs);
req->ki_cancel = cancel;
-
spin_unlock_irqrestore(&ctx->ctx_lock, flags);
}
EXPORT_SYMBOL(kiocb_set_cancel_fn);
-static int kiocb_cancel(struct aio_kiocb *kiocb)
-{
- kiocb_cancel_fn *old, *cancel;
-
- /*
- * Don't want to set kiocb->ki_cancel = KIOCB_CANCELLED unless it
- * actually has a cancel function, hence the cmpxchg()
- */
-
- cancel = READ_ONCE(kiocb->ki_cancel);
- do {
- if (!cancel || cancel == KIOCB_CANCELLED)
- return -EINVAL;
-
- old = cancel;
- cancel = cmpxchg(&kiocb->ki_cancel, old, KIOCB_CANCELLED);
- } while (cancel != old);
-
- return cancel(&kiocb->common);
-}
-
/*
* free_ioctx() should be RCU delayed to synchronize against the RCU
* protected lookup_ioctx() and also needs process context to call
@@ -634,7 +620,7 @@ static void free_ioctx_users(struct percpu_ref *ref)
while (!list_empty(&ctx->active_reqs)) {
req = list_first_entry(&ctx->active_reqs,
struct aio_kiocb, ki_list);
- kiocb_cancel(req);
+ req->ki_cancel(&req->rw);
list_del_init(&req->ki_list);
}
@@ -1041,7 +1027,7 @@ static inline struct aio_kiocb *aio_get_req(struct kioctx *ctx)
goto out_put;
percpu_ref_get(&ctx->reqs);
-
+ INIT_LIST_HEAD(&req->ki_list);
req->ki_ctx = ctx;
return req;
out_put:
@@ -1049,15 +1035,6 @@ out_put:
return NULL;
}
-static void kiocb_free(struct aio_kiocb *req)
-{
- if (req->common.ki_filp)
- fput(req->common.ki_filp);
- if (req->ki_eventfd != NULL)
- eventfd_ctx_put(req->ki_eventfd);
- kmem_cache_free(kiocb_cachep, req);
-}
-
static struct kioctx *lookup_ioctx(unsigned long ctx_id)
{
struct aio_ring __user *ring = (void __user *)ctx_id;
@@ -1088,44 +1065,14 @@ out:
/* aio_complete
* Called when the io request on the given iocb is complete.
*/
-static void aio_complete(struct kiocb *kiocb, long res, long res2)
+static void aio_complete(struct aio_kiocb *iocb, long res, long res2)
{
- struct aio_kiocb *iocb = container_of(kiocb, struct aio_kiocb, common);
struct kioctx *ctx = iocb->ki_ctx;
struct aio_ring *ring;
struct io_event *ev_page, *event;
unsigned tail, pos, head;
unsigned long flags;
- if (kiocb->ki_flags & IOCB_WRITE) {
- struct file *file = kiocb->ki_filp;
-
- /*
- * Tell lockdep we inherited freeze protection from submission
- * thread.
- */
- if (S_ISREG(file_inode(file)->i_mode))
- __sb_writers_acquired(file_inode(file)->i_sb, SB_FREEZE_WRITE);
- file_end_write(file);
- }
-
- /*
- * Special case handling for sync iocbs:
- * - events go directly into the iocb for fast handling
- * - the sync task with the iocb in its stack holds the single iocb
- * ref, no other paths have a way to get another ref
- * - the sync task helpfully left a reference to itself in the iocb
- */
- BUG_ON(is_sync_kiocb(kiocb));
-
- if (iocb->ki_list.next) {
- unsigned long flags;
-
- spin_lock_irqsave(&ctx->ctx_lock, flags);
- list_del(&iocb->ki_list);
- spin_unlock_irqrestore(&ctx->ctx_lock, flags);
- }
-
/*
* Add a completion event to the ring buffer. Must be done holding

This diff is incomplete. Download the complete patch.

fs/eventfd.c

View file

This diff is incomplete. Download the complete patch.

fs/eventpoll.c

View file

This diff is incomplete. Download the complete patch.

fs/pipe.c

View file

This diff is incomplete. Download the complete patch.

fs/select.c

View file

This diff is incomplete. Download the complete patch.

fs/timerfd.c

View file

This diff is incomplete. Download the complete patch.

include/crypto/if_alg.h

View file

This diff is incomplete. Download the complete patch.

include/linux/aio.h

View file

This diff is incomplete. Download the complete patch.

include/linux/compat.h

View file

This diff is incomplete. Download the complete patch.

include/linux/fs.h

View file

This diff is incomplete. Download the complete patch.

include/linux/net.h

View file

This diff is incomplete. Download the complete patch.

include/linux/poll.h

View file

This diff is incomplete. Download the complete patch.

include/linux/skbuff.h

View file

This diff is incomplete. Download the complete patch.

include/linux/syscalls.h

View file

This diff is incomplete. Download the complete patch.

include/net/bluetooth/bluetooth.h

View file

This diff is incomplete. Download the complete patch.

include/net/busy_poll.h

View file

This diff is incomplete. Download the complete patch.

include/net/iucv/af_iucv.h

View file

This diff is incomplete. Download the complete patch.

include/net/sctp/sctp.h

View file

This diff is incomplete. Download the complete patch.

include/net/sock.h

View file

This diff is incomplete. Download the complete patch.

include/net/tcp.h

View file

This diff is incomplete. Download the complete patch.

include/net/udp.h

View file

This diff is incomplete. Download the complete patch.

include/uapi/asm-generic/unistd.h

View file

This diff is incomplete. Download the complete patch.

include/uapi/linux/aio_abi.h

View file

This diff is incomplete. Download the complete patch.

include/uapi/linux/types.h

View file

This diff is incomplete. Download the complete patch.

kernel/sys_ni.c

View file

This diff is incomplete. Download the complete patch.

mm/memcontrol.c

View file

This diff is incomplete. Download the complete patch.

net/9p/trans_fd.c

View file

This diff is incomplete. Download the complete patch.

net/appletalk/ddp.c

View file

This diff is incomplete. Download the complete patch.

net/atm/common.c

View file

This diff is incomplete. Download the complete patch.

net/atm/common.h

View file

This diff is incomplete. Download the complete patch.

net/atm/pvc.c

View file

This diff is incomplete. Download the complete patch.

net/atm/svc.c

View file

This diff is incomplete. Download the complete patch.

net/ax25/af_ax25.c

View file

This diff is incomplete. Download the complete patch.

net/bluetooth/af_bluetooth.c

View file

This diff is incomplete. Download the complete patch.

net/bluetooth/bnep/sock.c

View file

This diff is incomplete. Download the complete patch.

net/bluetooth/cmtp/sock.c

View file

This diff is incomplete. Download the complete patch.

net/bluetooth/hci_sock.c

View file

This diff is incomplete. Download the complete patch.

net/bluetooth/hidp/sock.c

View file

This diff is incomplete. Download the complete patch.

net/bluetooth/l2cap_sock.c

View file

This diff is incomplete. Download the complete patch.

net/bluetooth/rfcomm/sock.c

View file

This diff is incomplete. Download the complete patch.

net/bluetooth/sco.c

View file

This diff is incomplete. Download the complete patch.

net/caif/caif_socket.c

View file

This diff is incomplete. Download the complete patch.

net/can/bcm.c

View file

This diff is incomplete. Download the complete patch.

net/can/raw.c

View file

This diff is incomplete. Download the complete patch.

net/core/datagram.c

View file

This diff is incomplete. Download the complete patch.

net/core/sock.c

View file

This diff is incomplete. Download the complete patch.

net/dccp/dccp.h

View file

This diff is incomplete. Download the complete patch.

net/dccp/ipv4.c

View file

This diff is incomplete. Download the complete patch.

net/dccp/ipv6.c

View file

This diff is incomplete. Download the complete patch.

net/dccp/proto.c

View file

This diff is incomplete. Download the complete patch.

net/decnet/af_decnet.c

View file

This diff is incomplete. Download the complete patch.

net/ieee802154/socket.c

View file

This diff is incomplete. Download the complete patch.

net/ipv4/af_inet.c

View file

This diff is incomplete. Download the complete patch.

net/ipv4/tcp.c

View file

This diff is incomplete. Download the complete patch.

net/ipv4/udp.c

View file

This diff is incomplete. Download the complete patch.

net/ipv6/af_inet6.c

View file

This diff is incomplete. Download the complete patch.

net/ipv6/raw.c

View file

This diff is incomplete. Download the complete patch.

net/iucv/af_iucv.c

View file

This diff is incomplete. Download the complete patch.

net/kcm/kcmsock.c

View file

This diff is incomplete. Download the complete patch.

net/key/af_key.c

View file

This diff is incomplete. Download the complete patch.

net/l2tp/l2tp_ip.c

View file

This diff is incomplete. Download the complete patch.

net/l2tp/l2tp_ip6.c

View file

This diff is incomplete. Download the complete patch.

net/l2tp/l2tp_ppp.c

View file

This diff is incomplete. Download the complete patch.

net/llc/af_llc.c

View file

This diff is incomplete. Download the complete patch.

net/netlink/af_netlink.c

View file

This diff is incomplete. Download the complete patch.

net/netrom/af_netrom.c

View file

This diff is incomplete. Download the complete patch.

net/nfc/llcp_sock.c

View file

This diff is incomplete. Download the complete patch.

net/nfc/rawsock.c

View file

This diff is incomplete. Download the complete patch.

net/packet/af_packet.c

View file

This diff is incomplete. Download the complete patch.

net/phonet/socket.c

View file

This diff is incomplete. Download the complete patch.

net/qrtr/qrtr.c

View file

This diff is incomplete. Download the complete patch.

net/rose/af_rose.c

View file

This diff is incomplete. Download the complete patch.

net/rxrpc/af_rxrpc.c

View file

This diff is incomplete. Download the complete patch.

net/sctp/ipv6.c

View file

This diff is incomplete. Download the complete patch.

net/sctp/protocol.c

View file

This diff is incomplete. Download the complete patch.

net/sctp/socket.c

View file

This diff is incomplete. Download the complete patch.

net/socket.c

View file

This diff is incomplete. Download the complete patch.

net/tipc/socket.c

View file

This diff is incomplete. Download the complete patch.

net/unix/af_unix.c

View file

This diff is incomplete. Download the complete patch.

net/vmw_vsock/af_vsock.c

View file

This diff is incomplete. Download the complete patch.

net/x25/af_x25.c

View file

This diff is incomplete. Download the complete patch.

virt/kvm/eventfd.c

View file

This diff is incomplete. Download the complete patch.