Re: [RFC] scsi: reduce protection of scan_mutex in scsi_remove_device

2017-04-25 Thread Song Liu
> On Apr 25, 2017, at 3:17 PM, Bart Van Assche > wrote: > > On Tue, 2017-04-25 at 21:17 +, Song Liu wrote: >> I am not sure I fully understand the problem here. If I understand the logic >> correctly, when a device is being removed, it will stay in >>

Re: [RFC] scsi: reduce protection of scan_mutex in scsi_remove_device

2017-04-25 Thread Bart Van Assche
On Tue, 2017-04-25 at 21:17 +, Song Liu wrote: > I am not sure I fully understand the problem here. If I understand the logic > correctly, when a device is being removed, it will stay in > scsi_host->__devices > until fully the remove routine is finished. And LUN scanning in parallel will >

Re: [RFC] scsi: reduce protection of scan_mutex in scsi_remove_device

2017-04-25 Thread Song Liu
> On Apr 25, 2017, at 1:59 PM, Bart Van Assche > wrote: > > On Fri, 2017-04-21 at 22:31 +, Song Liu wrote: >> On Apr 21, 2017, at 2:20 PM, Bart Van Assche >> wrote: >>> On Fri, 2017-04-21 at 14:13 -0700, Song Liu wrote: On the

Re: [RFC] scsi: reduce protection of scan_mutex in scsi_remove_device

2017-04-25 Thread Song Liu
> On Apr 25, 2017, at 10:52 AM, Bart Van Assche > wrote: > > On Tue, 2017-04-25 at 17:42 +, Song Liu wrote: >> I have been studying the code recently. I am wondering whether the following >> would work: >> >> 1. Introduce a new mutex for scsi_device to protect

Re: [RFC] scsi: reduce protection of scan_mutex in scsi_remove_device

2017-04-25 Thread Bart Van Assche
On Fri, 2017-04-21 at 22:31 +, Song Liu wrote: > On Apr 21, 2017, at 2:20 PM, Bart Van Assche > wrote: > > On Fri, 2017-04-21 at 14:13 -0700, Song Liu wrote: > > > On the other hand, some devices do long latency IO during deletion, > > > for example, sd_shutdown()

Re: [RFC] scsi: reduce protection of scan_mutex in scsi_remove_device

2017-04-25 Thread Bart Van Assche
On Tue, 2017-04-25 at 17:42 +, Song Liu wrote: > I have been studying the code recently. I am wondering whether the following > would work: > > 1. Introduce a new mutex for scsi_device to protect most operations in the >list you gathered above; > > 2. For operations like

Re: [RFC] scsi: reduce protection of scan_mutex in scsi_remove_device

2017-04-25 Thread Song Liu
> On Apr 25, 2017, at 10:23 AM, Bart Van Assche > wrote: > > On Fri, 2017-04-21 at 14:13 -0700, Song Liu wrote: >> When a device is deleted through sysfs handle "delete", the code >> locks shost->scan_mutex. If multiple devices are deleted at the >> same time, these

Re: [RFC] scsi: reduce protection of scan_mutex in scsi_remove_device

2017-04-25 Thread Bart Van Assche
On Fri, 2017-04-21 at 14:13 -0700, Song Liu wrote: > When a device is deleted through sysfs handle "delete", the code > locks shost->scan_mutex. If multiple devices are deleted at the > same time, these deletes will be handled in series. > > On the other hand, some devices do long latency IO

Re: [RFC] scsi: reduce protection of scan_mutex in scsi_remove_device

2017-04-24 Thread Christoph Hellwig
On Fri, Apr 21, 2017 at 02:13:02PM -0700, Song Liu wrote: > When a device is deleted through sysfs handle "delete", the code > locks shost->scan_mutex. If multiple devices are deleted at the > same time, these deletes will be handled in series. > > On the other hand, some devices do long latency

Re: [RFC] scsi: reduce protection of scan_mutex in scsi_remove_device

2017-04-21 Thread Song Liu
> On Apr 21, 2017, at 2:20 PM, Bart Van Assche > wrote: > > On Fri, 2017-04-21 at 14:13 -0700, Song Liu wrote: >> On the other hand, some devices do long latency IO during deletion, >> for example, sd_shutdown() may do sync cache and/or start_stop. >> It is not

Re: [RFC] scsi: reduce protection of scan_mutex in scsi_remove_device

2017-04-21 Thread Song Liu
> On Apr 21, 2017, at 2:17 PM, Bart Van Assche > wrote: > > On Fri, 2017-04-21 at 14:13 -0700, Song Liu wrote: >> When a device is deleted through sysfs handle "delete", [ ... ] > > If I try to use that sysfs attribute then I encounter a deadlock (see > also the

Re: [RFC] scsi: reduce protection of scan_mutex in scsi_remove_device

2017-04-21 Thread Bart Van Assche
On Fri, 2017-04-21 at 14:13 -0700, Song Liu wrote: > On the other hand, some devices do long latency IO during deletion, > for example, sd_shutdown() may do sync cache and/or start_stop. > It is not necessary for these commands to run in series. Have you noticed my patch series that makes

Re: [RFC] scsi: reduce protection of scan_mutex in scsi_remove_device

2017-04-21 Thread Bart Van Assche
On Fri, 2017-04-21 at 14:13 -0700, Song Liu wrote: > When a device is deleted through sysfs handle "delete", [ ... ] If I try to use that sysfs attribute then I encounter a deadlock (see also the report below). How is it possible that you have not hit that deadlock in your tests? Bart.

[RFC] scsi: reduce protection of scan_mutex in scsi_remove_device

2017-04-21 Thread Song Liu
When a device is deleted through sysfs handle "delete", the code locks shost->scan_mutex. If multiple devices are deleted at the same time, these deletes will be handled in series. On the other hand, some devices do long latency IO during deletion, for example, sd_shutdown() may do sync cache