[SCSI] sg: use rwsem to solve race during exclusive open
A race condition may happen if two threads are both trying to open the same sg with O_EXCL simultaneously. It's possible that they both find fsds list is empty and get_exclude(sdp) returns 0, then they both call set_exclude() and break out from wait_event_interruptible and resume open. Now use rwsem to protect this process. Exclusive open gets write lock and others get read lock. The lock will be held until file descriptor is closed. This also leads 'exclude' only a status rather than a check mark. Signed-off-by: NVaughan Cao <vaughan.cao@oracle.com> Acked-by: NDouglas Gilbert <dgilbert@interlog.com> Signed-off-by: NJames Bottomley <JBottomley@Parallels.com>
Showing
想要评论请 注册 或 登录