On 2/11/20 1:22 PM, Pavel Begunkov wrote: >> @@ -3692,15 +3738,33 @@ static void io_poll_queue_proc(struct file *file, struct wait_queue_head *head, >> struct poll_table_struct *p) >> { >> struct io_poll_table *pt = container_of(p, struct io_poll_table, pt); >> + struct io_kiocb *req = pt->req; >> + struct io_poll_iocb *poll = &req->poll; >> >> - if (unlikely(pt->req->poll.head)) { >> - pt->error = -EINVAL; >> - return; >> + /* >> + * If poll->head is already set, it's because the file being polled >> + * use multiple waitqueues for poll handling (eg one for read, one >> + * for write). Setup a separate io_poll_iocb if this happens. >> + */ >> + if (unlikely(poll->head)) { > > I'll keep looking, but I guess there should be : > > if (req->io) > return -EINVAL; Yes, I've changed it to: if (unlikely(poll->head)) { /* already have a 2nd entry, fail a third attempt */ if (req->io) { pt->error = -EINVAL; return; } poll = kmalloc(sizeof(*poll), GFP_ATOMIC); if (!poll) { pt->error = -ENOMEM; return; } [...] -- Jens Axboe