lpfc: fixes for EH rework
Subsystems (2)
PATCH 3/5 lpfc: use fc_block_rport()
In reply to Hannes ReineckeUse fc_block_rport() instead of fc_block_scsi_eh() as the SCSI command will be removed as argument for SCSI EH functions.
--- drivers/scsi/lpfc/lpfc_scsi.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/scsi/lpfc/lpfc_scsi.c +8 -5
@@ -5888,6 +5888,7 @@ static int lpfc_abort_handler(struct scsi_cmnd *cmnd) {struct Scsi_Host *shost = cmnd->device->host; +struct fc_rport *rport =starget_to_rport (scsi_target (cmnd->device));struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;struct lpfc_hba *phba = vport->phba;struct lpfc_iocbq *iocb;
@@ -5899,7 +5900,7 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd)unsigned long flags;DECLARE_WAIT_QUEUE_HEAD_ONSTACK (waitq); - status =fc_block_scsi_eh (cmnd); + status =fc_block_rport (rport);if (status !=0 && status !=SUCCESS )return status;
@@ -6348,6 +6349,7 @@ static int lpfc_device_reset_handler(struct scsi_cmnd *cmnd) {struct Scsi_Host *shost = cmnd->device->host; +struct fc_rport *rport =starget_to_rport (scsi_target (cmnd->device));struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;struct lpfc_rport_data *rdata;struct lpfc_nodelist *pnode;
@@ -6357,7 +6359,7 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd)int status;u32 logit =LOG_FCP ; - rdata =lpfc_rport_data_from_scsi_device (cmnd->device); + rdata = rport->dd_data;if (!rdata || !rdata->pnode) { lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, "0798 Device Reset rdata failure: rdata x%px\n",
@@ -6365,7 +6367,7 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd)return FAILED ; } pnode = rdata->pnode; - status =fc_block_scsi_eh (cmnd); + status =fc_block_rport (rport);if (status !=0 && status !=SUCCESS )return status;
@@ -6422,6 +6424,7 @@ static int lpfc_target_reset_handler(struct scsi_cmnd *cmnd) {struct Scsi_Host *shost = cmnd->device->host; +struct fc_rport *rport =starget_to_rport (scsi_target (cmnd->device));struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;struct lpfc_rport_data *rdata;struct lpfc_nodelist *pnode;
@@ -6434,7 +6437,7 @@ lpfc_target_reset_handler(struct scsi_cmnd *cmnd)unsigned long flags;DECLARE_WAIT_QUEUE_HEAD_ONSTACK (waitq); - rdata =lpfc_rport_data_from_scsi_device (cmnd->device); + rdata = rport->dd_data;if (!rdata || !rdata->pnode) { lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, "0799 Target Reset rdata failure: rdata x%px\n",
@@ -6442,7 +6445,7 @@ lpfc_target_reset_handler(struct scsi_cmnd *cmnd)return FAILED ; } pnode = rdata->pnode; - status =fc_block_scsi_eh (cmnd); + status =fc_block_rport (rport);if (status !=0 && status !=SUCCESS )return status;
Signature · 1 line
2.29.2
PATCH 1/5 lpfc: kill lpfc_bus_reset_handler
In reply to Hannes Reineckelpfc_bus_reset_handler is really just a loop calling lpfc_target_reset_handler() over all targets, which is what the error handler will be doing anyway.
--- drivers/scsi/lpfc/lpfc_scsi.c | 91 ----------------------------------- 1 file changed, 91 deletions(-)
drivers/scsi/lpfc/lpfc_scsi.c +0 -91
@@ -6528,95 +6528,6 @@ lpfc_target_reset_handler(struct scsi_cmnd *cmnd)return status; } -/** -* lpfc_bus_reset_handler - scsi_host_template eh_bus_reset_handler entry point -* @cmnd: Pointer to scsi_cmnd data structure. -* -* This routine does target reset to all targets on @cmnd->device->host. -* This emulates Parallel SCSI Bus Reset Semantics. -* -* Return code : -* 0x2003 - Error -* 0x2002 - Success -**/ -static int -lpfc_bus_reset_handler (struct scsi_cmnd *cmnd) -{ -struct Scsi_Host *shost = cmnd->device->host; -struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; -struct lpfc_nodelist *ndlp =NULL ; -struct lpfc_scsi_event_header scsi_event; -int match; -int ret =SUCCESS , status, i; -u32 logit =LOG_FCP ; - - scsi_event.event_type =FC_REG_SCSI_EVENT ; - scsi_event.subcategory =LPFC_EVENT_BUSRESET ; - scsi_event.lun =0 ; -memcpy (scsi_event.wwpn, &vport->fc_portname,sizeof (struct lpfc_name )); -memcpy (scsi_event.wwnn, &vport->fc_nodename,sizeof (struct lpfc_name )); - -fc_host_post_vendor_event (shost,fc_get_event_number (), -sizeof (scsi_event), (char *)&scsi_event,LPFC_NL_VENDOR_ID ); - - status =fc_block_scsi_eh (cmnd); -if (status !=0 && status !=SUCCESS ) -return status; - -/* -* Since the driver manages a single bus device, reset all -* targets known to the driver. Should any target reset -* fail, this routine returns failure to the midlayer. -*/ -for (i =0 ; i <LPFC_MAX_TARGET ; i++) { -/* Search for mapped node by target ID */ - match =0 ; -spin_lock_irq (shost->host_lock); -list_for_each_entry (ndlp, &vport->fc_nodes, nlp_listp) { - -if (vport->phba->cfg_fcp2_no_tgt_reset && - (ndlp->nlp_fcp_info &NLP_FCP_2_DEVICE )) -continue ; -if (ndlp->nlp_state ==NLP_STE_MAPPED_NODE && - ndlp->nlp_sid == i && - ndlp->rport && - ndlp->nlp_type &NLP_FCP_TARGET ) { - match =1 ; -break ; - } - } -spin_unlock_irq (shost->host_lock); -if (!match) -continue ; - - status =lpfc_send_taskmgmt (vport, cmnd, - i,0 ,FCP_TARGET_RESET ); - -if (status !=SUCCESS ) { -lpfc_printf_vlog (vport,KERN_ERR ,LOG_TRACE_EVENT , -"0700 Bus Reset on target %d failed\n" , - i); - ret =FAILED ; - } - } -/* -* We have to clean up i/o as : they may be orphaned by the TMFs -* above; or if any of the TMFs failed, they may be in an -* indeterminate state. -* We will report success if all the i/o aborts successfully. -*/ - - status =lpfc_reset_flush_io_context (vport,0 ,0 ,LPFC_CTX_HOST ); -if (status !=SUCCESS ) - ret =FAILED ; -if (ret ==FAILED ) - logit =LOG_TRACE_EVENT ; - -lpfc_printf_vlog (vport,KERN_ERR , logit, -"0714 SCSI layer issued Bus Reset Data: x%x\n" , ret); -return ret; -} -/** * lpfc_host_reset_handler - scsi_host_template eh_host_reset_handler entry pt * @cmnd: Pointer to scsi_cmnd data structure.
@@ -7203,7 +7114,6 @@ struct scsi_host_template lpfc_template_nvme = { .eh_abort_handler = lpfc_no_handler, .eh_device_reset_handler = lpfc_no_handler, .eh_target_reset_handler = lpfc_no_handler, - .eh_bus_reset_handler = lpfc_no_handler, .eh_host_reset_handler = lpfc_no_handler, .slave_alloc = lpfc_no_slave, .slave_configure = lpfc_no_slave,
@@ -7228,7 +7138,6 @@ struct scsi_host_template lpfc_template = { .eh_abort_handler = lpfc_abort_handler, .eh_device_reset_handler = lpfc_device_reset_handler, .eh_target_reset_handler = lpfc_target_reset_handler, - .eh_bus_reset_handler = lpfc_bus_reset_handler, .eh_host_reset_handler = lpfc_host_reset_handler, .slave_alloc = lpfc_slave_alloc, .slave_configure = lpfc_slave_configure,
Signature · 1 line
2.29.2
cover lpfc: fixes for EH rework
Hi all,
in preparation to the SCSI EH rework here's a bunch of patches to the lpfc driver to make the conversion easier.
As usual, comments and reviews are welcome.
Hannes Reinecke (5):
lpfc: kill lpfc_bus_reset_handler
lpfc: drop lpfc_no_handler()
lpfc: use fc_block_rport()
lpfc: use rport as argument for lpfc_send_taskmgmt()
lpfc: use rport as argument for lpfc_chk_tgt_mapped()
drivers/scsi/lpfc/lpfc_scsi.c | 141 ++++++---------------------------- 1 file changed, 22 insertions(+), 119 deletions(-)
Signature · 1 line
2.29.2
PATCH 4/5 lpfc: use rport as argument for lpfc_send_taskmgmt()
Instead of passing in a scsi device we should be using the rport; we already have the target and lun id as parameters, so there's no need to pass the scsi device, too.
--- drivers/scsi/lpfc/lpfc_scsi.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/scsi/lpfc/lpfc_scsi.c +6 -6
@@ -6142,7 +6142,7 @@ lpfc_check_fcp_rsp(struct lpfc_vport *vport, struct lpfc_io_buf *lpfc_cmd)/** * lpfc_send_taskmgmt - Generic SCSI Task Mgmt Handler * @vport: The virtual port for which this call is being executed. -* @cmnd: Pointer to scsi_cmnd data structure. +* @rport: Pointer to remote port * @tgt_id: Target ID of remote device. * @lun_id: Lun number for the TMF * @task_mgmt_cmd: type of TMF to send
@@ -6155,7 +6155,7 @@ lpfc_check_fcp_rsp(struct lpfc_vport *vport, struct lpfc_io_buf *lpfc_cmd)* 0x2002 - Success. **/ static int -lpfc_send_taskmgmt (struct lpfc_vport *vport,struct scsi_cmnd *cmnd, +lpfc_send_taskmgmt (struct lpfc_vport *vport,struct fc_rport *rport,unsigned int tgt_id,uint64_t lun_id,uint8_t task_mgmt_cmd) {
@@ -6168,7 +6168,7 @@ lpfc_send_taskmgmt(struct lpfc_vport *vport, struct scsi_cmnd *cmnd,int ret;int status; - rdata =lpfc_rport_data_from_scsi_device (cmnd->device); + rdata = rport->dd_data;if (!rdata || !rdata->pnode)return FAILED ; pnode = rdata->pnode;
@@ -6178,7 +6178,7 @@ lpfc_send_taskmgmt(struct lpfc_vport *vport, struct scsi_cmnd *cmnd,return FAILED ; lpfc_cmd->timeout = phba->cfg_task_mgmt_tmo; lpfc_cmd->rdata = rdata; - lpfc_cmd->pCmd = cmnd; + lpfc_cmd->pCmd =NULL ; lpfc_cmd->ndlp = pnode; status = lpfc_scsi_prep_task_mgmt_cmd(vport, lpfc_cmd, lun_id,
@@ -6387,7 +6387,7 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd)fc_host_post_vendor_event (shost,fc_get_event_number (),sizeof (scsi_event), (char *)&scsi_event,LPFC_NL_VENDOR_ID ); - status =lpfc_send_taskmgmt (vport, cmnd, tgt_id, lun_id, + status =lpfc_send_taskmgmt (vport, rport, tgt_id, lun_id,FCP_LUN_RESET );if (status !=SUCCESS ) logit =LOG_TRACE_EVENT ;
@@ -6473,7 +6473,7 @@ lpfc_target_reset_handler(struct scsi_cmnd *cmnd)fc_host_post_vendor_event (shost,fc_get_event_number (),sizeof (scsi_event), (char *)&scsi_event,LPFC_NL_VENDOR_ID ); - status =lpfc_send_taskmgmt (vport, cmnd, tgt_id, lun_id, + status =lpfc_send_taskmgmt (vport, rport, tgt_id, lun_id,FCP_TARGET_RESET );if (status !=SUCCESS ) { logit =LOG_TRACE_EVENT ;
Signature · 1 line
2.29.2
PATCH 2/5 lpfc: drop lpfc_no_handler()
In reply to Hannes ReineckeThe default SCSI EH action for a non-existing EH callback is to return FAILED, so having a callback just returning FAILED is pointless.
--- drivers/scsi/lpfc/lpfc_scsi.c | 10 ---------- 1 file changed, 10 deletions(-)
drivers/scsi/lpfc/lpfc_scsi.c +0 -10
@@ -7093,12 +7093,6 @@ lpfc_no_command(struct Scsi_Host *shost, struct scsi_cmnd *cmnd)return SCSI_MLQUEUE_HOST_BUSY ; } -static int -lpfc_no_handler (struct scsi_cmnd *cmnd) -{ -return FAILED ; -} -static int lpfc_no_slave (struct scsi_device *sdev) {
@@ -7111,10 +7105,6 @@ struct scsi_host_template lpfc_template_nvme = { .proc_name = LPFC_DRIVER_NAME, .info = lpfc_info, .queuecommand = lpfc_no_command, - .eh_abort_handler = lpfc_no_handler, - .eh_device_reset_handler = lpfc_no_handler, - .eh_target_reset_handler = lpfc_no_handler, - .eh_host_reset_handler = lpfc_no_handler, .slave_alloc = lpfc_no_slave, .slave_configure = lpfc_no_slave, .scan_finished = lpfc_scan_finished,
Signature · 1 line
2.29.2
PATCH 5/5 lpfc: use rport as argument for lpfc_chk_tgt_mapped()
In reply to Hannes ReineckeWe only need the rport structure for lpfc_chk_tgt_mapped().
--- drivers/scsi/lpfc/lpfc_scsi.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/scsi/lpfc/lpfc_scsi.c +8 -7
@@ -6244,7 +6244,7 @@ lpfc_send_taskmgmt(struct lpfc_vport *vport, struct fc_rport *rport,/** * lpfc_chk_tgt_mapped - * @vport: The virtual port to check on -* @cmnd: Pointer to scsi_cmnd data structure. +* @rport: Pointer to fc_rport data structure. * * This routine delays until the scsi target (aka rport) for the * command exists (is present and logged in) or we declare it non-existent.
@@ -6254,19 +6254,20 @@ lpfc_send_taskmgmt(struct lpfc_vport *vport, struct fc_rport *rport,* 0x2002 - Success **/ static int -lpfc_chk_tgt_mapped (struct lpfc_vport *vport,struct scsi_cmnd *cmnd) +lpfc_chk_tgt_mapped (struct lpfc_vport *vport,struct fc_rport *rport) {struct lpfc_rport_data *rdata; -struct lpfc_nodelist *pnode; +struct lpfc_nodelist *pnode =NULL ;unsigned long later; - rdata =lpfc_rport_data_from_scsi_device (cmnd->device); + rdata = rport->dd_data;if (!rdata) {lpfc_printf_vlog (vport,KERN_INFO ,LOG_FCP ,"0797 Tgt Map rport failure: rdata x%px\n" , rdata);return FAILED ; } pnode = rdata->pnode; +/* * If target is not in a MAPPED state, delay until * target is rediscovered or devloss timeout expires.
@@ -6278,7 +6279,7 @@ lpfc_chk_tgt_mapped(struct lpfc_vport *vport, struct scsi_cmnd *cmnd)if (pnode->nlp_state ==NLP_STE_MAPPED_NODE )return SUCCESS ;schedule_timeout_uninterruptible (msecs_to_jiffies (500 )); - rdata =lpfc_rport_data_from_scsi_device (cmnd->device); + rdata = rport->dd_data;if (!rdata)return FAILED ; pnode = rdata->pnode;
@@ -6371,7 +6372,7 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd)if (status !=0 && status !=SUCCESS )return status; - status =lpfc_chk_tgt_mapped (vport, cmnd); + status =lpfc_chk_tgt_mapped (vport, rport);if (status ==FAILED ) {lpfc_printf_vlog (vport,KERN_ERR ,LOG_TRACE_EVENT ,"0721 Device Reset rport failure: rdata x%px\n" , rdata);
@@ -6449,7 +6450,7 @@ lpfc_target_reset_handler(struct scsi_cmnd *cmnd)if (status !=0 && status !=SUCCESS )return status; - status =lpfc_chk_tgt_mapped (vport, cmnd); + status =lpfc_chk_tgt_mapped (vport, rport);if (status ==FAILED ) {lpfc_printf_vlog (vport,KERN_ERR ,LOG_TRACE_EVENT ,"0722 Target Reset rport failure: rdata x%px\n" , rdata);
Signature · 1 line
2.29.2
Re: [PATCH 1/5] lpfc: kill lpfc_bus_reset_handler
In reply to Hannes ReineckeQuoted 3 lines · Hannes Reinecke
lpfc_bus_reset_handleris really just a loop callinglpfc_target_reset_handler()over all targets, which is what the error handler will be doing anyway.
Looks good:
Re: [PATCH 3/5] lpfc: use fc_block_rport()
In reply to Hannes ReineckeQuoted 2 lines · Hannes Reinecke
Use
fc_block_rport()instead offc_block_scsi_eh()as the SCSI command will be removed as argument for SCSI EH functions.
Looks good,
Re: [PATCH 4/5] lpfc: use rport as argument for lpfc_send_taskmgmt()
In reply to Hannes ReineckeLooks good,
Re: [PATCH 5/5] lpfc: use rport as argument for lpfc_chk_tgt_mapped()
In reply to Hannes ReineckeLooks good,
Martin K. Petersen
AppliedHannes,
Quoted 2 lines
in preparation to the SCSI EH rework here's a bunch of patches to the lpfc driver to make the conversion easier.
Applied to 5.18/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Martin K. Petersen
AppliedQuoted 5 lines · Hannes Reinecke
in preparation to the SCSI EH rework here's a bunch of patches to the lpfc driver to make the conversion easier.
As usual, comments and reviews are welcome.
Quoted 8 lines
Hannes Reinecke (5):
lpfc: killlpfc_bus_reset_handler
lpfc: droplpfc_no_handler()
lpfc: usefc_block_rport()
lpfc: use rport as argument forlpfc_send_taskmgmt()
lpfc: use rport as argument forlpfc_chk_tgt_mapped()[...]
Applied to 5.18/scsi-queue, thanks!
[1/5] lpfc: kill lpfc_bus_reset_handler
https://git.kernel.org/mkp/scsi/c/bf180cc1a5da [2/5] lpfc: drop lpfc_no_handler() https://git.kernel.org/mkp/scsi/c/45c59287ff01 [3/5] lpfc: use fc_block_rport() https://git.kernel.org/mkp/scsi/c/bb21fc9911ee [4/5] lpfc: use rport as argument for lpfc_send_taskmgmt() https://git.kernel.org/mkp/scsi/c/123a3af35d08 [5/5] lpfc: use rport as argument for lpfc_chk_tgt_mapped() https://git.kernel.org/mkp/scsi/c/e81ce97f5716
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering