Message ID | 20191206011118.46909-1-yanaijie@huawei.com (mailing list archive) |
---|---|
State | Mainlined |
Commit | f70267f379b5e5e11bdc5d72a56bf17e5feed01f |
Headers | show |
Series | [v3] scsi: libsas: stop discovering if oob mode is disconnected | expand |
Jason, > The discovering of sas port is driven by workqueue in libsas. When > libsas is processing port events or phy events in workqueue, new > events may rise up and change the state of some structures such as > asd_sas_phy. Applied to 5.5/scsi-fixes, thanks!
diff --git a/drivers/scsi/libsas/sas_discover.c b/drivers/scsi/libsas/sas_discover.c index f47b4b281b14..d7302c2052f9 100644 --- a/drivers/scsi/libsas/sas_discover.c +++ b/drivers/scsi/libsas/sas_discover.c @@ -81,12 +81,21 @@ static int sas_get_port_device(struct asd_sas_port *port) else dev->dev_type = SAS_SATA_DEV; dev->tproto = SAS_PROTOCOL_SATA; - } else { + } else if (port->oob_mode == SAS_OOB_MODE) { struct sas_identify_frame *id = (struct sas_identify_frame *) dev->frame_rcvd; dev->dev_type = id->dev_type; dev->iproto = id->initiator_bits; dev->tproto = id->target_bits; + } else { + /* If the oob mode is OOB_NOT_CONNECTED, the port is + * disconnected due to race with PHY down. We cannot + * continue to discover this port + */ + sas_put_device(dev); + pr_warn("Port %016llx is disconnected when discovering\n", + SAS_ADDR(port->attached_sas_addr)); + return -ENODEV; } sas_init_dev(dev);