mptfusion: Fixes for SCSI EH rework
Subsystems (2)
cover mptfusion: 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 mptfusion driver to not rely on a specific command for the SCSI EH callbacks.
As usual, comments and reviews are welcome.
Hannes Reinecke (3):
mptfusion: correct definitions for mptscsih_dev_reset()
mptfc: use fc_block_rport() instead of open-coding it
mptfc: iterate over all rports during bus reset
drivers/message/fusion/mptfc.c | 96 +++++++++++++++---------------- drivers/message/fusion/mptscsih.c | 55 +++++++++++++++++- drivers/message/fusion/mptscsih.h | 1 + 3 files changed, 100 insertions(+), 52 deletions(-)
Signature · 1 line
2.29.2
PATCH 1/3 mptfusion: correct definitions for mptscsih_dev_reset()
From: Hannes Reinecke <[email protected]>
mptscsih_dev_reset() is _not_ a device reset, but rather a target reset. Nevertheless it's being used for either purpose. This patch adds a correct implementation for mptscsih_dev_reset(), and renames the original function to mptscsih_target_reset().
--- drivers/message/fusion/mptscsih.c | 55 ++++++++++++++++++++++++++++++- drivers/message/fusion/mptscsih.h | 1 + 2 files changed, 55 insertions(+), 1 deletion(-)
drivers/message/fusion/mptscsih.c +54 -1
@@ -1794,7 +1794,7 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ /** -* mptscsih_dev_reset - Perform a SCSI TARGET_RESET! new_eh variant +* mptscsih_dev_reset - Perform a SCSI LOGICAL_UNIT_RESET! * @SCpnt: Pointer to scsi_cmnd structure, IO which reset is due to * * (linux scsi_host_template.eh_dev_reset_handler routine)
@@ -1809,6 +1809,58 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt)VirtDevice *vdevice;MPT_ADAPTER *ioc; +/* If we can't locate our host adapter structure, return FAILED status. +*/ +if ((hd =shost_priv (SCpnt->device->host)) ==NULL ){ + printk(KERN_ERR MYNAM ": lun reset: " + "Can't locate host! (sc=%p)\n", SCpnt); +return FAILED ; + } + + ioc = hd->ioc; +printk (MYIOC_s_INFO_FMT"attempting lun reset! (sc=%p)\n" , + ioc->name, SCpnt); +scsi_print_command (SCpnt); + + vdevice = SCpnt->device->hostdata; +if (!vdevice || !vdevice->vtarget) { + retval =0 ; + goto out; + } + + retval =mptscsih_IssueTaskMgmt (hd, +MPI_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET , + vdevice->vtarget->channel, + vdevice->vtarget->id, vdevice->lun,0 , +mptscsih_get_tm_timeout (ioc)); + + out: +printk (MYIOC_s_INFO_FMT"lun reset: %s (sc=%p)\n" , + ioc->name, ((retval ==0 ) ?"SUCCESS" :"FAILED" ), SCpnt); + +if (retval ==0 ) +return SUCCESS ; +else +return FAILED ; +} + +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ +/** +* mptscsih_target_reset - Perform a SCSI TARGET_RESET! +* @SCpnt: Pointer to scsi_cmnd structure, IO which reset is due to +* +* (linux scsi_host_template.eh_target_reset_handler routine) +* +* Returns SUCCESS or FAILED. +**/ +int +mptscsih_target_reset (struct scsi_cmnd * SCpnt) +{ +MPT_SCSI_HOST *hd; +int retval; +VirtDevice *vdevice; +MPT_ADAPTER *ioc; +/* If we can't locate our host adapter structure, return FAILED status. */ if ((hd =shost_priv (SCpnt->device->host)) ==NULL ){
@@ -3249,6 +3301,7 @@ EXPORT_SYMBOL(mptscsih_slave_destroy);EXPORT_SYMBOL (mptscsih_slave_configure);EXPORT_SYMBOL (mptscsih_abort);EXPORT_SYMBOL (mptscsih_dev_reset); +EXPORT_SYMBOL (mptscsih_target_reset);EXPORT_SYMBOL (mptscsih_bus_reset);EXPORT_SYMBOL (mptscsih_host_reset);EXPORT_SYMBOL (mptscsih_bios_param);
drivers/message/fusion/mptscsih.h +1 -0
@@ -120,6 +120,7 @@ extern void mptscsih_slave_destroy(struct scsi_device *device);extern int mptscsih_slave_configure (struct scsi_device *device);extern int mptscsih_abort (struct scsi_cmnd * SCpnt);extern int mptscsih_dev_reset (struct scsi_cmnd * SCpnt); +extern int mptscsih_target_reset (struct scsi_cmnd * SCpnt);extern int mptscsih_bus_reset (struct scsi_cmnd * SCpnt);extern int mptscsih_host_reset (struct scsi_cmnd *SCpnt);extern int mptscsih_bios_param (struct scsi_device * sdev,struct block_device *bdev,sector_t capacity,int geom[]);
Signature · 1 line
2.29.2
PATCH 2/3 mptfc: use fc_block_rport() instead of open-coding it
In reply to Hannes Reineckemptfc_block_error_handler() is just an open-coded version of fc_block_rport().
--- drivers/message/fusion/mptfc.c | 92 +++++++++++++++------------------- 1 file changed, 41 insertions(+), 51 deletions(-)
drivers/message/fusion/mptfc.c +41 -51
@@ -183,73 +183,63 @@ static struct fc_function_template mptfc_transport_functions = { };static int -mptfc_block_error_handler (struct scsi_cmnd *SCpnt, -int (*func)(struct scsi_cmnd *SCpnt), -const char *caller) +mptfc_abort (struct scsi_cmnd *SCpnt) { -MPT_SCSI_HOST *hd;struct scsi_device *sdev = SCpnt->device;struct Scsi_Host *shost = sdev->host;struct fc_rport *rport =starget_to_rport (scsi_target (sdev)); -unsigned long flags; -int ready; -MPT_ADAPTER *ioc; -int loops =40 ;/* seconds */ +MPT_SCSI_HOST *hd =shost_priv (shost); +MPT_ADAPTER *ioc = hd->ioc; +int rval; - hd =shost_priv (SCpnt->device->host); - ioc = hd->ioc; -spin_lock_irqsave (shost->host_lock, flags); -while ((ready =fc_remote_port_chkready (rport) >>16 ) ==DID_IMM_RETRY - || (loops >0 && ioc->active ==0 )) { -spin_unlock_irqrestore (shost->host_lock, flags); -dfcprintk (ioc,printk (MYIOC_s_DEBUG_FMT -"mptfc_block_error_handler.%d: %d:%llu, port status is " -"%x, active flag %d, deferring %s recovery.\n" , - ioc->name, ioc->sh->host_no, - SCpnt->device->id, SCpnt->device->lun, - ready, ioc->active, caller)); -msleep (1000 ); -spin_lock_irqsave (shost->host_lock, flags); - loops --; - } -spin_unlock_irqrestore (shost->host_lock, flags); - -if (ready ==DID_NO_CONNECT || !SCpnt->device->hostdata - || ioc->active ==0 ) { -dfcprintk (ioc,printk (MYIOC_s_DEBUG_FMT -"%s.%d: %d:%llu, failing recovery, " -"port state %x, active %d, vdevice %p.\n" , caller, - ioc->name, ioc->sh->host_no, - SCpnt->device->id, SCpnt->device->lun, ready, - ioc->active, SCpnt->device->hostdata)); -return FAILED ; - } + rval =fc_block_rport (rport); +if (rval) +return rval;dfcprintk (ioc,printk (MYIOC_s_DEBUG_FMT -"%s.%d: %d:%llu, executing recovery.\n" , caller, - ioc->name, ioc->sh->host_no, - SCpnt->device->id, SCpnt->device->lun)); -return (*func)(SCpnt); -} - -static int -mptfc_abort (struct scsi_cmnd *SCpnt) -{ -return -mptfc_block_error_handler (SCpnt, mptscsih_abort, __func__); +"%s.%d: %d:%llu, executing recovery.\n" , + ioc->name, __func__, ioc->sh->host_no, + sdev->id, sdev->lun)); +return mptscsih_abort (SCpnt); }static int mptfc_dev_reset (struct scsi_cmnd *SCpnt) { -return -mptfc_block_error_handler (SCpnt, mptscsih_dev_reset, __func__); +struct scsi_device *sdev = SCpnt->device; +struct Scsi_Host *shost = sdev->host; +struct fc_rport *rport =starget_to_rport (scsi_target (sdev)); +MPT_SCSI_HOST *hd =shost_priv (shost); +MPT_ADAPTER *ioc = hd->ioc; +int rval; + + rval =fc_block_rport (rport); +if (rval) +return rval; +dfcprintk (ioc,printk (MYIOC_s_DEBUG_FMT +"%s.%d: %d:%llu, executing recovery.\n" , + ioc->name, __func__, ioc->sh->host_no, + sdev->id, sdev->lun)); +return mptscsih_dev_reset (SCpnt); }static int mptfc_bus_reset (struct scsi_cmnd *SCpnt) { -return -mptfc_block_error_handler (SCpnt, mptscsih_bus_reset, __func__); +struct scsi_device *sdev = SCpnt->device; +struct Scsi_Host *shost = sdev->host; +struct fc_rport *rport =starget_to_rport (scsi_target (sdev)); +MPT_SCSI_HOST *hd =shost_priv (shost); +MPT_ADAPTER *ioc = hd->ioc; +int rval; + + rval =fc_block_rport (rport); +if (rval) +return rval; +dfcprintk (ioc,printk (MYIOC_s_DEBUG_FMT +"%s.%d: %d:%llu, executing recovery.\n" , + ioc->name, __func__, ioc->sh->host_no, + sdev->id, sdev->lun)); +return mptscsih_bus_reset (SCpnt); } static void
Signature · 1 line
2.29.2
PATCH 3/3 mptfc: iterate over all rports during bus reset
In reply to Hannes ReineckeWhen issuing a bus reset we need to call fc_block_rport() on all ports, otherwise we might be executing the bus reset call prematurely.
--- drivers/message/fusion/mptfc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/message/fusion/mptfc.c +8 -4
@@ -227,14 +227,18 @@ mptfc_bus_reset(struct scsi_cmnd *SCpnt) {struct scsi_device *sdev = SCpnt->device;struct Scsi_Host *shost = sdev->host; -struct fc_rport *rport =starget_to_rport (scsi_target (sdev));MPT_SCSI_HOST *hd =shost_priv (shost);MPT_ADAPTER *ioc = hd->ioc; +struct mptfc_rport_info *ri;int rval; - rval =fc_block_rport (rport); -if (rval) -return rval; +list_for_each_entry (ri, &ioc->fc_rports, list) { + rval =fc_block_rport (ri->rport); +if (rval) +return rval; +if (ioc->active ==0 ) +return FAILED ; + } dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT "%s.%d: %d:%llu, executing recovery.\n", ioc->name, __func__, ioc->sh->host_no,
Signature · 1 line
2.29.2