]> git.baikalelectronics.ru Git - kernel.git/commit
scsi: core: Don't start concurrent async scan on same host
authorMing Lei <ming.lei@redhat.com>
Sat, 10 Oct 2020 03:25:39 +0000 (11:25 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Mon, 26 Oct 2020 20:05:34 +0000 (16:05 -0400)
commitc01feead8262b07693405731bbfb7f33a04168ac
tree55edf7cfc12446727e86994b307d4c4b413f828d
parenta1fe7c755400af92f0070a66f48f00b659aeacac
scsi: core: Don't start concurrent async scan on same host

The current scanning mechanism is supposed to fall back to a synchronous
host scan if an asynchronous scan is in progress. However, this rule isn't
strictly respected, scsi_prep_async_scan() doesn't hold scan_mutex when
checking shost->async_scan. When scsi_scan_host() is called concurrently,
two async scans on same host can be started and a hang in do_scan_async()
is observed.

Fixes this issue by checking & setting shost->async_scan atomically with
shost->scan_mutex.

Link: https://lore.kernel.org/r/20201010032539.426615-1-ming.lei@redhat.com
Cc: Christoph Hellwig <hch@lst.de>
Cc: Ewan D. Milne <emilne@redhat.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Lee Duncan <lduncan@suse.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/scsi_scan.c