Skip to content

Commit bf1a28f

Browse files
hreineckemartinkpetersen
authored andcommitted
scsi: scsi_transport_srp: Sanitize scsi_target_block/unblock sequences
The SCSI midlayer does not allow state transitions from SDEV_BLOCK to SDEV_BLOCK so calling scsi_target_block() from __rport_fast_io_fail() is wrong as the port is already blocked. Similarly, we don't need to call scsi_target_unblock() afterwards as the function has already done this. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Bart Van Assche <[email protected]> Reviewed-by: Laurence Oberman <[email protected]> Signed-off-by: Hannes Reinecke <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent d61fa5b commit bf1a28f

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

drivers/scsi/scsi_transport_srp.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,10 @@ static void srp_reconnect_work(struct work_struct *work)
395395
}
396396
}
397397

398+
/*
399+
* scsi_target_block() must have been called before this function is
400+
* called to guarantee that no .queuecommand() calls are in progress.
401+
*/
398402
static void __rport_fail_io_fast(struct srp_rport *rport)
399403
{
400404
struct Scsi_Host *shost = rport_to_shost(rport);
@@ -404,11 +408,7 @@ static void __rport_fail_io_fast(struct srp_rport *rport)
404408

405409
if (srp_rport_set_state(rport, SRP_RPORT_FAIL_FAST))
406410
return;
407-
/*
408-
* Call scsi_target_block() to wait for ongoing shost->queuecommand()
409-
* calls before invoking i->f->terminate_rport_io().
410-
*/
411-
scsi_target_block(rport->dev.parent);
411+
412412
scsi_target_unblock(rport->dev.parent, SDEV_TRANSPORT_OFFLINE);
413413

414414
/* Involve the LLD if possible to terminate all I/O on the rport. */
@@ -570,8 +570,6 @@ int srp_reconnect_rport(struct srp_rport *rport)
570570
* failure timers if these had not yet been started.
571571
*/
572572
__rport_fail_io_fast(rport);
573-
scsi_target_unblock(&shost->shost_gendev,
574-
SDEV_TRANSPORT_OFFLINE);
575573
__srp_start_tl_fail_timers(rport);
576574
} else if (rport->state != SRP_RPORT_BLOCKED) {
577575
scsi_target_unblock(&shost->shost_gendev,

0 commit comments

Comments
 (0)