Commit 210588c0344e7daf1351aa3c68b0cd9141ab80dc
Committed by
Greg Kroah-Hartman
1 parent
7e920411dd
Exists in
smarct4x-processor-sdk-linux-03.00.00.04
and in
2 other branches
scsi: Add intermediate STARGET_REMOVE state to scsi_target_state
commit f05795d3d771f30a7bdc3a138bf714b06d42aa95 upstream. Add intermediate STARGET_REMOVE state to scsi_target_state to avoid running into the BUG_ON() in scsi_target_reap(). The STARGET_REMOVE state is only valid in the path from scsi_remove_target() to scsi_target_destroy() indicating this target is going to be removed. This re-fixes the problem introduced in commits bc3f02a795d3 ("[SCSI] scsi_remove_target: fix softlockup regression on hot remove") and 40998193560d ("scsi: restart list search after unlock in scsi_remove_target") in a more comprehensive way. [mkp: Included James' fix for scsi_target_destroy()] Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de> Fixes: 40998193560dab6c3ce8d25f4fa58a23e252ef38 Reported-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Tested-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Reviewed-by: Ewan D. Milne <emilne@redhat.com> Reviewed-by: Hannes Reinecke <hare@suse.com> Reviewed-by: James Bottomley <jejb@linux.vnet.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Showing 3 changed files with 4 additions and 0 deletions Side-by-side Diff
drivers/scsi/scsi_scan.c
drivers/scsi/scsi_sysfs.c
... | ... | @@ -1199,11 +1199,13 @@ |
1199 | 1199 | spin_lock_irqsave(shost->host_lock, flags); |
1200 | 1200 | list_for_each_entry(starget, &shost->__targets, siblings) { |
1201 | 1201 | if (starget->state == STARGET_DEL || |
1202 | + starget->state == STARGET_REMOVE || | |
1202 | 1203 | starget == last_target) |
1203 | 1204 | continue; |
1204 | 1205 | if (starget->dev.parent == dev || &starget->dev == dev) { |
1205 | 1206 | kref_get(&starget->reap_ref); |
1206 | 1207 | last_target = starget; |
1208 | + starget->state = STARGET_REMOVE; | |
1207 | 1209 | spin_unlock_irqrestore(shost->host_lock, flags); |
1208 | 1210 | __scsi_remove_target(starget); |
1209 | 1211 | scsi_target_reap(starget); |