On 06/13/2014 02:26 AM, Douglas Gilbert wrote:
This is a re-presentation of a patch to the sg driver whose v3 was sent in November 2013: http://www.spinics.net/lists/linux-scsi/msg69957.html It addresses a problem reported by Vaughan Cao concerning the correctness of the O_EXCL logic in the sg driver. POSIX doesn't defined O_EXCL semantics on devices but "allow only one open file descriptor at a time per sg device" is a rough definition. The sg driver's semantics have been to wait on an open() when O_NONBLOCK is not given and there are O_EXCL headwinds. Nasty things can happen during that wait such as the device being detached (removed). So multiple locks are reworked in this patch making it large and hard to break down into digestible bits. This patch is against Linus's current git repository which doesn't include any sg patches sent in the last few weeks. Hence this patch touches as little as possible that it doesn't need to and strips out most SCSI_LOG_TIMEOUT() changes in v3 because Hannes said he was going to rework all that stuff. The sg3_utils package has several test programs written to test this patch. See examples/sg_tst_excl*.cpp . Not all the locks and flags in sg have been re-worked in this patch, notably sg_request::done . That can wait for a follow-up patch if this one meets with approval. ChangeLog v4: - based on the current kernel tree: pre 3.16-rc1 - strip out clean-ups in v3 that others are better placed to do (e.g. debug/logging) - simplify open_wait_event() logic and add comment ChangeLog v3 and earlier: see link in the first paragraph. Could anyone confirm whether v3 of this patch has found its way into any distro and/or been tested or used more widely? Signed-off-by: Douglas Gilbert <dgilbert@xxxxxxxxxxxx>
We've tested a similar version here. Reviewed-by: Hannes Reinecke <hare@xxxxxxx> Cheers, Hannes -- Dr. Hannes Reinecke zSeries & Storage hare@xxxxxxx +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg) -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html