Commit 3386f4bd authored by James Smart's avatar James Smart Committed by Martin K. Petersen

scsi: lpfc: Fix crash during driver unload with running nvme traffic

When the driver is unloading, the nvme transport could be in the process
of submitting new requests, will send abort requests to terminate
associations, or may make LS-related requests.  The driver's abort and
request entry points currently is ignorant of the unloading state and is
starting the requests even though the infrastructure to complete them
continues to teardown.

Change the entry points for new requests to check whether unloading and
if so, reject the requests. Abort routines check unloading, and if so,
noop the request. An abort is noop'd as the teardown paths are already
aborting/terminating the io outstanding at the time the teardown
initiated.
Signed-off-by: default avatarDick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: default avatarJames Smart <james.smart@broadcom.com>
Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent add9d6be
...@@ -420,6 +420,9 @@ lpfc_nvme_ls_req(struct nvme_fc_local_port *pnvme_lport, ...@@ -420,6 +420,9 @@ lpfc_nvme_ls_req(struct nvme_fc_local_port *pnvme_lport,
lport = (struct lpfc_nvme_lport *)pnvme_lport->private; lport = (struct lpfc_nvme_lport *)pnvme_lport->private;
vport = lport->vport; vport = lport->vport;
if (vport->load_flag & FC_UNLOADING)
return -ENODEV;
if (vport->load_flag & FC_UNLOADING) if (vport->load_flag & FC_UNLOADING)
return -ENODEV; return -ENODEV;
...@@ -538,6 +541,9 @@ lpfc_nvme_ls_abort(struct nvme_fc_local_port *pnvme_lport, ...@@ -538,6 +541,9 @@ lpfc_nvme_ls_abort(struct nvme_fc_local_port *pnvme_lport,
vport = lport->vport; vport = lport->vport;
phba = vport->phba; phba = vport->phba;
if (vport->load_flag & FC_UNLOADING)
return;
ndlp = lpfc_findnode_did(vport, pnvme_rport->port_id); ndlp = lpfc_findnode_did(vport, pnvme_rport->port_id);
if (!ndlp) { if (!ndlp) {
lpfc_printf_vlog(vport, KERN_ERR, LOG_NVME_ABTS, lpfc_printf_vlog(vport, KERN_ERR, LOG_NVME_ABTS,
...@@ -1273,6 +1279,11 @@ lpfc_nvme_fcp_io_submit(struct nvme_fc_local_port *pnvme_lport, ...@@ -1273,6 +1279,11 @@ lpfc_nvme_fcp_io_submit(struct nvme_fc_local_port *pnvme_lport,
goto out_fail; goto out_fail;
} }
if (vport->load_flag & FC_UNLOADING) {
ret = -ENODEV;
goto out_fail;
}
/* Validate pointers. */ /* Validate pointers. */
if (!pnvme_lport || !pnvme_rport || !freqpriv) { if (!pnvme_lport || !pnvme_rport || !freqpriv) {
lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_IOERR | LOG_NODE, lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_IOERR | LOG_NODE,
...@@ -1500,6 +1511,9 @@ lpfc_nvme_fcp_abort(struct nvme_fc_local_port *pnvme_lport, ...@@ -1500,6 +1511,9 @@ lpfc_nvme_fcp_abort(struct nvme_fc_local_port *pnvme_lport,
vport = lport->vport; vport = lport->vport;
phba = vport->phba; phba = vport->phba;
if (vport->load_flag & FC_UNLOADING)
return;
/* Announce entry to new IO submit field. */ /* Announce entry to new IO submit field. */
lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_ABTS, lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_ABTS,
"6002 Abort Request to rport DID x%06x " "6002 Abort Request to rport DID x%06x "
......
...@@ -632,6 +632,9 @@ lpfc_nvmet_xmt_ls_rsp(struct nvmet_fc_target_port *tgtport, ...@@ -632,6 +632,9 @@ lpfc_nvmet_xmt_ls_rsp(struct nvmet_fc_target_port *tgtport,
struct ulp_bde64 bpl; struct ulp_bde64 bpl;
int rc; int rc;
if (phba->pport->load_flag & FC_UNLOADING)
return -ENODEV;
if (phba->pport->load_flag & FC_UNLOADING) if (phba->pport->load_flag & FC_UNLOADING)
return -ENODEV; return -ENODEV;
...@@ -721,6 +724,11 @@ lpfc_nvmet_xmt_fcp_op(struct nvmet_fc_target_port *tgtport, ...@@ -721,6 +724,11 @@ lpfc_nvmet_xmt_fcp_op(struct nvmet_fc_target_port *tgtport,
goto aerr; goto aerr;
} }
if (phba->pport->load_flag & FC_UNLOADING) {
rc = -ENODEV;
goto aerr;
}
#ifdef CONFIG_SCSI_LPFC_DEBUG_FS #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
if (ctxp->ts_cmd_nvme) { if (ctxp->ts_cmd_nvme) {
if (rsp->op == NVMET_FCOP_RSP) if (rsp->op == NVMET_FCOP_RSP)
...@@ -820,6 +828,9 @@ lpfc_nvmet_xmt_fcp_abort(struct nvmet_fc_target_port *tgtport, ...@@ -820,6 +828,9 @@ lpfc_nvmet_xmt_fcp_abort(struct nvmet_fc_target_port *tgtport,
struct lpfc_hba *phba = ctxp->phba; struct lpfc_hba *phba = ctxp->phba;
unsigned long flags; unsigned long flags;
if (phba->pport->load_flag & FC_UNLOADING)
return;
if (phba->pport->load_flag & FC_UNLOADING) if (phba->pport->load_flag & FC_UNLOADING)
return; return;
......
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