Commit bf1a28f9 authored by Hannes Reinecke's avatar Hannes Reinecke Committed by Martin K. Petersen

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/20200728134833.42547-1-hare@suse.deReviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
Reviewed-by: default avatarLaurence Oberman <loberman@redhat.com>
Signed-off-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent d61fa5bc
......@@ -395,6 +395,10 @@ static void srp_reconnect_work(struct work_struct *work)
}
}
/*
* scsi_target_block() must have been called before this function is
* called to guarantee that no .queuecommand() calls are in progress.
*/
static void __rport_fail_io_fast(struct srp_rport *rport)
{
struct Scsi_Host *shost = rport_to_shost(rport);
......@@ -404,11 +408,7 @@ static void __rport_fail_io_fast(struct srp_rport *rport)
if (srp_rport_set_state(rport, SRP_RPORT_FAIL_FAST))
return;
/*
* Call scsi_target_block() to wait for ongoing shost->queuecommand()
* calls before invoking i->f->terminate_rport_io().
*/
scsi_target_block(rport->dev.parent);
scsi_target_unblock(rport->dev.parent, SDEV_TRANSPORT_OFFLINE);
/* 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)
* failure timers if these had not yet been started.
*/
__rport_fail_io_fast(rport);
scsi_target_unblock(&shost->shost_gendev,
SDEV_TRANSPORT_OFFLINE);
__srp_start_tl_fail_timers(rport);
} else if (rport->state != SRP_RPORT_BLOCKED) {
scsi_target_unblock(&shost->shost_gendev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment