On 10/9/20 8:25 PM, Ming Lei wrote:
Current scsi host scan mechanism supposes to fallback into sync host scan if async scan is in-progress. However, this rule isn't strictly respected, because scsi_prep_async_scan() doesn't hold scan_mutex when checking shost->async_scan. When scsi_scan_host() is called concurrently, two async scan on same host may be started, and hang in do_scan_async() is observed. Fixes this issue by checking & setting shost->async_scan atomically with shost->scan_mutex.
Did you perhaps mean "by serializing shost->async_scan accesses with shost->scan_mutex"? It is not clear to me why the shost->async_scan assignment is protected with the host lock. Can spin_lock_irqsave(shost->host_lock, flags) and spin_unlock_irqrestore(shost->host_lock, flags) be left out from this function? Anyway: Reviewed-by: Bart Van Assche <bvanassche@xxxxxxx>