Re: [PATCH 2/4] sg: protect access to to 'reserved' page array
On 02/03/2017 11:24 AM, Christoph Hellwig wrote: > On Fri, Feb 03, 2017 at 09:54:49AM +0100, Hannes Reinecke wrote: >> 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 we need to protect it against concurrent accesses. > > Can you please explain how you protect the access here a bit more, > as mentioned before the set_bit for exclusion trick is always > suspicious, so the changelog needs to have a justification for it. > The 'reserved' array provides for a fast/reliable mechanism for mapping data of a request. However, it only has enough room to hold one request at a time. Plus we can change the size of the buffer during runtime via an ioctl. So we need to mark the array as 'in use' atomically, and keep that marker as long as the request using it is active. While I surely can introduce a variable 'in_use' and protect accesses to it via mutex or somesuch, I found this to be a bit pointless given that it's actually just one bit which needs to be checked. Which is what I did. But okay, I'll update the description. Cheers, Hannes -- Dr. Hannes ReineckeTeamlead Storage & Networking h...@suse.de +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
Re: [PATCH 2/4] sg: protect access to to 'reserved' page array
On Fri, Feb 03, 2017 at 09:54:49AM +0100, Hannes Reinecke wrote: > 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 we need to protect it against concurrent accesses. Can you please explain how you protect the access here a bit more, as mentioned before the set_bit for exclusion trick is always suspicious, so the changelog needs to have a justification for it.
Re: [PATCH 2/4] sg: protect access to to 'reserved' page array
On 02/03/2017 09:54 AM, Hannes Reinecke wrote: 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 we need to protect it against concurrent accesses. Cc: sta...@vger.kernel.org Reported-by: Dmitry VyukovLink: http://www.spinics.net/lists/linux-scsi/msg104326.html Signed-off-by: Hannes Reinecke Tested-by: Johannes Thumshirn --- Reviewed-by: Johannes Thumshirn -- Johannes Thumshirn Storage jthumsh...@suse.de+49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850