]> www.infradead.org Git - users/jedix/linux-maple.git/commit
scsi: Protect SCSI device state changes with a mutex
authorBart Van Assche <bart.vanassche@sandisk.com>
Fri, 2 Jun 2017 21:21:55 +0000 (14:21 -0700)
committerJack Vogel <jack.vogel@oracle.com>
Fri, 16 Feb 2018 23:06:18 +0000 (15:06 -0800)
commit2e5602ab8d7d9ebc330af282571a1baa8a358b35
treeced52fb8371e08c8f699ce6b8553027cf688e903
parentcb6c5020d3255b1d3d9e8ef70b3fb91fb4f2076d
scsi: Protect SCSI device state changes with a mutex

Serializing SCSI device state changes avoids that two state changes can
occur concurrently, e.g. the state changes in scsi_target_block() and
__scsi_remove_device(). This serialization is essential to make patch
"Make __scsi_remove_device go straight from BLOCKED to DEL" work
reliably.

Enable this mechanism for all scsi_target_*block() callers but not for
the scsi_internal_device_unblock() calls from the mpt3sas driver because
that driver can call scsi_internal_device_unblock() from atomic context.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Orabug: 27546768
(cherry picked from commit 0db6ca8a5e1ea585795db3643ec7d50fc8cb1aff)
Signed-off-by: Kyle Fortin <kyle.fortin@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Conflicts:
drivers/scsi/scsi_error.c
drivers/scsi/scsi_lib.c
include/scsi/scsi_device.h

Use kmalloc'd state_mutex_kabi in scsi_device to fit new field
state_mutex in KABI reserved space.
drivers/scsi/scsi_error.c
drivers/scsi/scsi_lib.c
drivers/scsi/scsi_scan.c
drivers/scsi/scsi_sysfs.c
drivers/scsi/scsi_transport_srp.c
drivers/scsi/sd.c
include/scsi/scsi_device.h