lpfc: fixes for SCSI EH rework
Subsystems (2)
cover lpfc: fixes for SCSI EH rework
Hi all,
with the SCSI EH rework the scsi_cmnd argument for the SCSI EH callbacks is going away, so we need to fixup the drivers to work without it.
This patchset modifies the lpfc driver to not rely on a specific command for the EH callbacks.
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 | 138 +++++----------------------------- 1 file changed, 20 insertions(+), 118 deletions(-)
Signature · 1 line
2.29.2
PATCH 1/5 lpfc: kill lpfc_bus_reset_handler
lpfc_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
@@ -6367,95 +6367,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.
@@ -7035,7 +6946,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,
@@ -7060,7 +6970,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
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
@@ -6925,12 +6925,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) {
@@ -6943,10 +6937,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 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 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/scsi/lpfc/lpfc_scsi.c +6 -4
@@ -6187,6 +6187,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;
@@ -6196,7 +6197,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",
@@ -6204,7 +6205,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;
@@ -6261,6 +6262,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;
@@ -6273,7 +6275,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",
@@ -6281,7 +6283,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 4/5 lpfc: use rport as argument for lpfc_send_taskmgmt()
In reply to Hannes ReineckeInstead 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
@@ -5980,7 +5980,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
@@ -5993,7 +5993,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) {
@@ -6006,7 +6006,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;
@@ -6016,7 +6016,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,
@@ -6225,7 +6225,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 ;
@@ -6311,7 +6311,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 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
@@ -6082,7 +6082,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.
@@ -6092,19 +6092,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.
@@ -6116,7 +6117,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;
@@ -6209,7 +6210,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);
@@ -6287,7 +6288,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 5/5] lpfc: use rport as argument for lpfc_chk_tgt_mapped()
Hi Hannes,
Quoted 14 lines · Hannes Reinecke
We only need the rport structure for
lpfc_chk_tgt_mapped().Signed-off-by Hannes Reinecke <[email protected]>Cc James Smart <[email protected]>--- drivers/scsi/lpfc/lpfc_scsi.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)drivers/scsi/lpfc/lpfc_scsi.c +0
-0
drivers/scsi/lpfc/lpfc_scsi.c lpfc_send_taskmgmt(struct lpfc_vport *vport, struct fc_rport *rport, · line 6098
Quoted 9 lines
drivers/scsi/lpfc/lpfc_scsi.c +2
-2@@ -6092,19 +6092,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 ;
Do we need to initialise this variable ...
drivers/scsi/lpfc/lpfc_scsi.c lpfc_send_taskmgmt(struct lpfc_vport *vport, struct fc_rport *rport, · line 6107
Quoted 10 lines
drivers/scsi/lpfc/lpfc_scsi.c +1
-1unsigned 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;
... as we're assigning it here and don't use it before this line?
Thanks,
Signature · 4 lines
Julian Calaby Email: [email protected] Profile: http://www.google.com/profiles/julian.calaby/
Quoted 18 lines · Hannes Reinecke
Hi all,
with the SCSI EH rework the
scsi_cmndargument for the SCSI EH callbacks is going away, so we need to fixup the drivers to work without it.This patchset modifies the lpfc driver to not rely on a specific command for the EH callbacks.
As usual, comments and reviews are welcome.
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()
Quoted 3 lines
drivers/scsi/lpfc/lpfc_scsi.c | 138 +++++----------------------------- 1 file changed, 20 insertions(+), 118 deletions(-)
I think I've acked all of these in their prior posting
-- james