Re: [dm-devel] [PATCH 1/3] dm: a basic support for using the select or poll function

2017-05-12 Thread Mikulas Patocka
On Thu, 11 May 2017, Martin Wilck wrote: > On Thu, 2017-05-11 at 09:21 -0400, Mike Snitzer wrote: > > On Thu, May 11 2017 at  5:43am -0400, > > Martin Wilck wrote: > > > > > On Thu, 2017-05-11 at 11:39 +0200, Martin Wilck wrote: > > > > On Tue, 2017-05-09 at 12:10 -0700, Andy

Re: [dm-devel] [PATCH 1/3] dm: a basic support for using the select or poll function

2017-05-12 Thread Martin Wilck
On Thu, 2017-05-11 at 14:46 -0700, Andy Grover wrote: > > a) Application notes initial event_nrs for all relevant devices > while (1) >  b) Application calls ARM_POLL >  c) Application gets updated event_nrs from LIST_DEVICES and > handles >  d) Application calls poll() > > If events

Re: [dm-devel] [PATCH 1/3] dm: a basic support for using the select or poll function

2017-05-11 Thread Alasdair G Kergon
On Thu, May 11, 2017 at 09:30:43PM +0200, Martin Wilck wrote: > I see - but I don't see yet how the ioctl approach (or the > close()/open() based one, for that matter) would avoid this race. > 1) application processes event N > 2) event N+1 arrives in the kernel > 3) user space issues ioctl or

Re: [dm-devel] [PATCH 1/3] dm: a basic support for using the select or poll function

2017-05-11 Thread Andy Grover
On 05/11/2017 12:30 PM, Martin Wilck wrote: I see - but I don't see yet how the ioctl approach (or the close()/open() based one, for that matter) would avoid this race. 1) application processes event N 2) event N+1 arrives in the kernel 3) user space issues ioctl or close()/open()

Re: [dm-devel] [PATCH 1/3] dm: a basic support for using the select or poll function

2017-05-11 Thread Alasdair G Kergon
On Thu, May 11, 2017 at 10:45:27PM +0200, Martin Wilck wrote: > Except that it can cause userspace to miss events, as I tried to point > out in my reply to Mike. It should never miss new events. Because the calls are separate, occasionally it might trigger when it didn't need to, but userspace

Re: [dm-devel] [PATCH 1/3] dm: a basic support for using the select or poll function

2017-05-11 Thread Martin Wilck
On Thu, 2017-05-11 at 21:21 +0100, Alasdair G Kergon wrote: > On Thu, May 11, 2017 at 09:49:14PM +0200, Martin Wilck wrote: > > Here is an idea: the best way to avoid the race mentioned by Mike > > might > > be to set priv->global_event_nr to the highest event nr reported by > > the > >

Re: [dm-devel] [PATCH 1/3] dm: a basic support for using the select or poll function

2017-05-11 Thread Alasdair G Kergon
On Thu, May 11, 2017 at 09:49:14PM +0200, Martin Wilck wrote: > Here is an idea: the best way to avoid the race mentioned by Mike might > be to set priv->global_event_nr to the highest event nr reported by the > DM_LIST_DEVICES ioctl when this ioctl returns. DM_LIST_DEVICES would > then represent

Re: [dm-devel] [PATCH 1/3] dm: a basic support for using the select or poll function

2017-05-11 Thread Martin Wilck
On Thu, 2017-05-11 at 11:10 -0700, Andy Grover wrote: > > I think getting one readiness notification for multiple events should > be ok. > > But, the semantics of poll(2) are level-triggered, meaning if a fd > is  > ready then it will stay ready through multiple invocations of poll()  > until

Re: [dm-devel] [PATCH 1/3] dm: a basic support for using the select or poll function

2017-05-11 Thread Martin Wilck
On Thu, 2017-05-11 at 09:21 -0400, Mike Snitzer wrote: > On Thu, May 11 2017 at  5:43am -0400, > Martin Wilck wrote: > > > On Thu, 2017-05-11 at 11:39 +0200, Martin Wilck wrote: > > > On Tue, 2017-05-09 at 12:10 -0700, Andy Grover wrote: > > > > From: Mikulas Patocka

Re: [dm-devel] [PATCH 1/3] dm: a basic support for using the select or poll function

2017-05-11 Thread Andy Grover
On 05/11/2017 06:21 AM, Mike Snitzer wrote: On Thu, May 11 2017 at 5:43am -0400, Martin Wilck wrote: On Thu, 2017-05-11 at 11:39 +0200, Martin Wilck wrote: On Tue, 2017-05-09 at 12:10 -0700, Andy Grover wrote: From: Mikulas Patocka This is the very

Re: [dm-devel] [PATCH 1/3] dm: a basic support for using the select or poll function

2017-05-11 Thread Mike Snitzer
On Thu, May 11 2017 at 5:43am -0400, Martin Wilck wrote: > On Thu, 2017-05-11 at 11:39 +0200, Martin Wilck wrote: > > On Tue, 2017-05-09 at 12:10 -0700, Andy Grover wrote: > > > From: Mikulas Patocka > > >   > > > This is the very simple patch for polling

Re: [dm-devel] [PATCH 1/3] dm: a basic support for using the select or poll function

2017-05-11 Thread Martin Wilck
On Thu, 2017-05-11 at 11:39 +0200, Martin Wilck wrote: > On Tue, 2017-05-09 at 12:10 -0700, Andy Grover wrote: > > From: Mikulas Patocka > >   > > This is the very simple patch for polling on the > > /dev/mapper/control > > device. The select or poll function waits until any

Re: [dm-devel] [PATCH 1/3] dm: a basic support for using the select or poll function

2017-05-11 Thread Martin Wilck
On Tue, 2017-05-09 at 12:10 -0700, Andy Grover wrote: > From: Mikulas Patocka >  > This is the very simple patch for polling on the /dev/mapper/control > device. The select or poll function waits until any event happens on > any > dm device since opening the