[PATCH 3/4] aio: implement IOCB_CMD_POLL

2018-08-06 Thread Christoph Hellwig
Simple one-shot poll through the io_submit() interface. To poll for a file descriptor the application should submit an iocb of type IOCB_CMD_POLL. It will poll the fd for the events specified in the the first 32 bits of the aio_buf field of the iocb. Unlike poll or epoll without EPOLLONESHOT

[PATCH 3/4] aio: implement IOCB_CMD_POLL

2018-08-06 Thread Christoph Hellwig
Simple one-shot poll through the io_submit() interface. To poll for a file descriptor the application should submit an iocb of type IOCB_CMD_POLL. It will poll the fd for the events specified in the the first 32 bits of the aio_buf field of the iocb. Unlike poll or epoll without EPOLLONESHOT

Re: [PATCH 3/4] aio: implement IOCB_CMD_POLL

2018-08-02 Thread Al Viro
On Thu, Aug 02, 2018 at 06:16:48PM +0200, Christoph Hellwig wrote: > On Thu, Aug 02, 2018 at 05:08:38PM +0100, Al Viro wrote: > > On Thu, Aug 02, 2018 at 06:08:16PM +0200, Christoph Hellwig wrote: > > > On Thu, Aug 02, 2018 at 05:00:32PM +0100, Al Viro wrote: > > > > BTW, what happens if we insert

Re: [PATCH 3/4] aio: implement IOCB_CMD_POLL

2018-08-02 Thread Al Viro
On Thu, Aug 02, 2018 at 06:16:48PM +0200, Christoph Hellwig wrote: > On Thu, Aug 02, 2018 at 05:08:38PM +0100, Al Viro wrote: > > On Thu, Aug 02, 2018 at 06:08:16PM +0200, Christoph Hellwig wrote: > > > On Thu, Aug 02, 2018 at 05:00:32PM +0100, Al Viro wrote: > > > > BTW, what happens if we insert

Re: [PATCH 3/4] aio: implement IOCB_CMD_POLL

2018-08-02 Thread Christoph Hellwig
On Thu, Aug 02, 2018 at 05:08:38PM +0100, Al Viro wrote: > On Thu, Aug 02, 2018 at 06:08:16PM +0200, Christoph Hellwig wrote: > > On Thu, Aug 02, 2018 at 05:00:32PM +0100, Al Viro wrote: > > > BTW, what happens if we insert into one queue and immediately get > > > woken up, even before the damn

Re: [PATCH 3/4] aio: implement IOCB_CMD_POLL

2018-08-02 Thread Christoph Hellwig
On Thu, Aug 02, 2018 at 05:08:38PM +0100, Al Viro wrote: > On Thu, Aug 02, 2018 at 06:08:16PM +0200, Christoph Hellwig wrote: > > On Thu, Aug 02, 2018 at 05:00:32PM +0100, Al Viro wrote: > > > BTW, what happens if we insert into one queue and immediately get > > > woken up, even before the damn

Re: [PATCH 3/4] aio: implement IOCB_CMD_POLL

2018-08-02 Thread Al Viro
On Thu, Aug 02, 2018 at 06:08:16PM +0200, Christoph Hellwig wrote: > On Thu, Aug 02, 2018 at 05:00:32PM +0100, Al Viro wrote: > > BTW, what happens if we insert into one queue and immediately get > > woken up, even before the damn thing gets to the end of ->poll(), > > which proceeds to call

Re: [PATCH 3/4] aio: implement IOCB_CMD_POLL

2018-08-02 Thread Al Viro
On Thu, Aug 02, 2018 at 06:08:16PM +0200, Christoph Hellwig wrote: > On Thu, Aug 02, 2018 at 05:00:32PM +0100, Al Viro wrote: > > BTW, what happens if we insert into one queue and immediately get > > woken up, even before the damn thing gets to the end of ->poll(), > > which proceeds to call

Re: [PATCH 3/4] aio: implement IOCB_CMD_POLL

2018-08-02 Thread Christoph Hellwig
On Thu, Aug 02, 2018 at 05:00:32PM +0100, Al Viro wrote: > BTW, what happens if we insert into one queue and immediately get > woken up, even before the damn thing gets to the end of ->poll(), > which proceeds to call poll_wait() again (on another queue)? > AFAICS, apt.error will be set by the

Re: [PATCH 3/4] aio: implement IOCB_CMD_POLL

2018-08-02 Thread Christoph Hellwig
On Thu, Aug 02, 2018 at 05:00:32PM +0100, Al Viro wrote: > BTW, what happens if we insert into one queue and immediately get > woken up, even before the damn thing gets to the end of ->poll(), > which proceeds to call poll_wait() again (on another queue)? > AFAICS, apt.error will be set by the

Re: [PATCH 3/4] aio: implement IOCB_CMD_POLL

2018-08-02 Thread Al Viro
On Thu, Aug 02, 2018 at 11:22:34AM +0200, Christoph Hellwig wrote: > Yes, I think you are right. I'll see how I could handle that case. > One of the easiest options would be to just support aio poll on > file ops that support keyed wakeups, we'd just need to pass that > information up. BTW, what

Re: [PATCH 3/4] aio: implement IOCB_CMD_POLL

2018-08-02 Thread Al Viro
On Thu, Aug 02, 2018 at 11:22:34AM +0200, Christoph Hellwig wrote: > Yes, I think you are right. I'll see how I could handle that case. > One of the easiest options would be to just support aio poll on > file ops that support keyed wakeups, we'd just need to pass that > information up. BTW, what

Re: [PATCH 3/4] aio: implement IOCB_CMD_POLL

2018-08-02 Thread Christoph Hellwig
On Thu, Aug 02, 2018 at 01:21:22AM +0100, Al Viro wrote: > So what happens if > * we call aio_poll(), add the sucker to queue and see that we need > to wait > * add to ->active_refs just as the wakeup comes active_reqs I guess.. > * wakeup removes from queue and hits

Re: [PATCH 3/4] aio: implement IOCB_CMD_POLL

2018-08-02 Thread Christoph Hellwig
On Thu, Aug 02, 2018 at 01:21:22AM +0100, Al Viro wrote: > So what happens if > * we call aio_poll(), add the sucker to queue and see that we need > to wait > * add to ->active_refs just as the wakeup comes active_reqs I guess.. > * wakeup removes from queue and hits

Re: [PATCH 3/4] aio: implement IOCB_CMD_POLL

2018-08-02 Thread Christoph Hellwig
On Thu, Aug 02, 2018 at 12:54:12AM +0100, Al Viro wrote: > On Mon, Jul 30, 2018 at 09:15:43AM +0200, Christoph Hellwig wrote: > > > + apt.error = -EINVAL; /* same as no support for IOCB_CMD_POLL */ > > > + mask = vfs_poll(req->file, ) & req->events; > > + if (mask || apt.error) { > > +

Re: [PATCH 3/4] aio: implement IOCB_CMD_POLL

2018-08-02 Thread Christoph Hellwig
On Thu, Aug 02, 2018 at 12:54:12AM +0100, Al Viro wrote: > On Mon, Jul 30, 2018 at 09:15:43AM +0200, Christoph Hellwig wrote: > > > + apt.error = -EINVAL; /* same as no support for IOCB_CMD_POLL */ > > > + mask = vfs_poll(req->file, ) & req->events; > > + if (mask || apt.error) { > > +

Re: [PATCH 3/4] aio: implement IOCB_CMD_POLL

2018-08-01 Thread Al Viro
On Mon, Jul 30, 2018 at 09:15:43AM +0200, Christoph Hellwig wrote: > +static void aio_poll_complete_work(struct work_struct *work) > +{ > + struct poll_iocb *req = container_of(work, struct poll_iocb, work); > + struct aio_kiocb *iocb = container_of(req, struct aio_kiocb, poll); > +

Re: [PATCH 3/4] aio: implement IOCB_CMD_POLL

2018-08-01 Thread Al Viro
On Mon, Jul 30, 2018 at 09:15:43AM +0200, Christoph Hellwig wrote: > +static void aio_poll_complete_work(struct work_struct *work) > +{ > + struct poll_iocb *req = container_of(work, struct poll_iocb, work); > + struct aio_kiocb *iocb = container_of(req, struct aio_kiocb, poll); > +

Re: [PATCH 3/4] aio: implement IOCB_CMD_POLL

2018-08-01 Thread Al Viro
On Mon, Jul 30, 2018 at 09:15:43AM +0200, Christoph Hellwig wrote: > + apt.error = -EINVAL; /* same as no support for IOCB_CMD_POLL */ > + mask = vfs_poll(req->file, ) & req->events; > + if (mask || apt.error) { > + bool removed = false; > + > + /* we did not

Re: [PATCH 3/4] aio: implement IOCB_CMD_POLL

2018-08-01 Thread Al Viro
On Mon, Jul 30, 2018 at 09:15:43AM +0200, Christoph Hellwig wrote: > + apt.error = -EINVAL; /* same as no support for IOCB_CMD_POLL */ > + mask = vfs_poll(req->file, ) & req->events; > + if (mask || apt.error) { > + bool removed = false; > + > + /* we did not

[PATCH 3/4] aio: implement IOCB_CMD_POLL

2018-07-30 Thread Christoph Hellwig
Simple one-shot poll through the io_submit() interface. To poll for a file descriptor the application should submit an iocb of type IOCB_CMD_POLL. It will poll the fd for the events specified in the the first 32 bits of the aio_buf field of the iocb. Unlike poll or epoll without EPOLLONESHOT

[PATCH 3/4] aio: implement IOCB_CMD_POLL

2018-07-30 Thread Christoph Hellwig
Simple one-shot poll through the io_submit() interface. To poll for a file descriptor the application should submit an iocb of type IOCB_CMD_POLL. It will poll the fd for the events specified in the the first 32 bits of the aio_buf field of the iocb. Unlike poll or epoll without EPOLLONESHOT

[PATCH 3/4] aio: implement IOCB_CMD_POLL

2018-07-26 Thread Christoph Hellwig
Simple one-shot poll through the io_submit() interface. To poll for a file descriptor the application should submit an iocb of type IOCB_CMD_POLL. It will poll the fd for the events specified in the the first 32 bits of the aio_buf field of the iocb. Unlike poll or epoll without EPOLLONESHOT

[PATCH 3/4] aio: implement IOCB_CMD_POLL

2018-07-26 Thread Christoph Hellwig
Simple one-shot poll through the io_submit() interface. To poll for a file descriptor the application should submit an iocb of type IOCB_CMD_POLL. It will poll the fd for the events specified in the the first 32 bits of the aio_buf field of the iocb. Unlike poll or epoll without EPOLLONESHOT