Re: [PATCHv3 3/6] sg: protect accesses to 'reserved' page array

2017-02-03 Thread James Bottomley
On Fri, 2017-02-03 at 19:06 +0100, Johannes Thumshirn wrote: > > On 02/03/2017 05:19 PM, Christoph Hellwig wrote: > > On Fri, Feb 03, 2017 at 02:38:35PM +0100, Hannes Reinecke wrote: > > > On 02/03/2017 02:31 PM, Christoph Hellwig wrote: > > > > > - if (sg_res_in_use(sfp)) { > > > > >

Re: [PATCHv3 3/6] sg: protect accesses to 'reserved' page array

2017-02-03 Thread Johannes Thumshirn
On 02/03/2017 05:19 PM, Christoph Hellwig wrote: On Fri, Feb 03, 2017 at 02:38:35PM +0100, Hannes Reinecke wrote: On 02/03/2017 02:31 PM, Christoph Hellwig wrote: - if (sg_res_in_use(sfp)) { + mutex_lock(&sfp->f_mutex); + if (sfp->res_in_use) { +

Re: [PATCHv3 3/6] sg: protect accesses to 'reserved' page array

2017-02-03 Thread Christoph Hellwig
On Fri, Feb 03, 2017 at 02:38:35PM +0100, Hannes Reinecke wrote: > On 02/03/2017 02:31 PM, Christoph Hellwig wrote: > >> - if (sg_res_in_use(sfp)) { > >> + mutex_lock(&sfp->f_mutex); > >> + if (sfp->res_in_use) { > >> + mutex_unlock(&sfp->f_mutex); > >>

Re: [PATCHv3 3/6] sg: protect accesses to 'reserved' page array

2017-02-03 Thread Hannes Reinecke
On 02/03/2017 02:31 PM, Christoph Hellwig wrote: >> -if (sg_res_in_use(sfp)) { >> +mutex_lock(&sfp->f_mutex); >> +if (sfp->res_in_use) { >> +mutex_unlock(&sfp->f_mutex); >> sg_remove_request(sfp, srp); >>

Re: [PATCHv3 3/6] sg: protect accesses to 'reserved' page array

2017-02-03 Thread Christoph Hellwig
> - if (sg_res_in_use(sfp)) { > + mutex_lock(&sfp->f_mutex); > + if (sfp->res_in_use) { > + mutex_unlock(&sfp->f_mutex); > sg_remove_request(sfp, srp); > return -EBUSY; /* reserve buffer already bei

[PATCHv3 3/6] sg: protect accesses to 'reserved' page array

2017-02-03 Thread Hannes Reinecke
The 'reserved' page array is used as a short-cut for mapping data, saving us to allocate pages per request. However, the 'reserved' array is only capable of holding one request, so this patch introduces a mutex for protect 'sg_fd' against concurrent accesses. Signed-off-by: Hannes Reinecke Review