scsi: EH rework prep patches, part 1
Subsystems (13)
Hannes Reinecke
maintainerv3 cover scsi: EH rework prep patches, part 1
Hi all,
here's the first batch of patches for my EH rework. It modifies the host reset callback for SCSI drivers such that the final conversion to have 'struct Scsi_host' as argument becomes possible.
As usual, comments and reviews are welcome.
Changes to v2:
- Include reviews from John Garry
- move mpi3mr, zfcp, sym53c8xx_2, and qla1280 patches to the next patchset
Changes to the initial version:
- Include reviews from Christoph
- Fixup build robot issues
Hannes Reinecke (20):
csiostor: use fc_block_rport()
fc_fcp: use fc_block_rport()
mptfc: simplify mpt_fc_block_error_handler()
mptfusion: correct definitions for mptscsih_dev_reset()
mptfc: open-code mptfc_block_error_handler() for bus reset
qedf: use fc rport as argument for qedf_initiate_tmf()
bnx2fc: Do not rely on a scsi command for lun or target reset
ibmvfc: open-code reset loop for target reset
ibmvfc: use fc_block_rport()
fnic: use dedicated device reset command
fnic: use fc_block_rport() correctly
aic7xxx: make BUILD_SCSIID() a function
aic79xx: make BUILD_SCSIID() a function
aic7xxx: do not reference scsi command when resetting device
aic79xx: do not reference scsi command when resetting device
snic: reserve tag for TMF
snic: use dedicated device reset command
snic: Use scsi_host_busy_iter() to traverse commands
ips: Do not try to abort command from host reset
megaraid: pass in NULL scb for host reset
drivers/message/fusion/mptfc.c | 94 +++++++--- drivers/message/fusion/mptscsih.c | 55 +++++- drivers/message/fusion/mptscsih.h | 1 + drivers/scsi/aic7xxx/aic79xx_osm.c | 32 ++-- drivers/scsi/aic7xxx/aic7xxx_osm.c | 127 ++++++++------ drivers/scsi/bnx2fc/bnx2fc.h | 1 + drivers/scsi/bnx2fc/bnx2fc_hwi.c | 14 +- drivers/scsi/bnx2fc/bnx2fc_io.c | 94 +++++----- drivers/scsi/csiostor/csio_scsi.c | 2 +- drivers/scsi/fnic/fnic_main.c | 9 + drivers/scsi/fnic/fnic_scsi.c | 139 +++++---------- drivers/scsi/ibmvscsi/ibmvfc.c | 48 ++--- drivers/scsi/ips.c | 18 -- drivers/scsi/libfc/fc_fcp.c | 2 +- drivers/scsi/megaraid.c | 42 ++--- drivers/scsi/qedf/qedf.h | 5 +- drivers/scsi/qedf/qedf_io.c | 75 +++----- drivers/scsi/qedf/qedf_main.c | 19 +- drivers/scsi/snic/snic.h | 2 +- drivers/scsi/snic/snic_main.c | 8 + drivers/scsi/snic/snic_scsi.c | 271 ++++++++++++++--------------- 21 files changed, 535 insertions(+), 523 deletions(-)
Signature · 1 line
2.29.2
Hannes Reinecke
maintainerPATCH v3 1/20 csiostor: use fc_block_rport()
Use fc_block_rport() instead of fc_block_scsi_eh() as the SCSI command will be removed as argument for SCSI EH functions.
--- drivers/scsi/csiostor/csio_scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/csiostor/csio_scsi.c +1 -1
@@ -2088,7 +2088,7 @@ csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd) }/* Lnode is ready, now wait on rport node readiness */ - ret =fc_block_scsi_eh (cmnd); + ret =fc_block_rport (rn->rport);if (ret)return ret;
Signature · 1 line
2.29.2
Hannes Reinecke
maintainerPATCH v3 2/20 fc_fcp: 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/libfc/fc_fcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/libfc/fc_fcp.c +1 -1
@@ -2157,7 +2157,7 @@ int fc_eh_device_reset(struct scsi_cmnd *sc_cmd)int rc =FAILED ;int rval; - rval =fc_block_scsi_eh (sc_cmd); + rval =fc_block_rport (rport);if (rval)return rval;
Signature · 1 line
2.29.2
Hannes Reinecke
maintainerPATCH v3 3/20 mptfc: simplify mpt_fc_block_error_handler()
In reply to Hannes ReineckeInstead of passing the a function we can as well return a status and call the function directly afterwards.
--- drivers/message/fusion/mptfc.c | 83 ++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 29 deletions(-)
drivers/message/fusion/mptfc.c +54 -29
@@ -183,73 +183,98 @@ 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_block_error_handler (struct fc_rport *rport) {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)); +struct Scsi_Host *shost =rport_to_shost (rport);unsigned long flags;int ready; -MPT_ADAPTER *ioc; +MPT_ADAPTER *ioc;int loops =40 ;/* seconds */ - hd =shost_priv (SCpnt->device->host); + hd =shost_priv (shost); 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" , +"mptfc_block_error_handler.%d: %s, port status is " +"%x, active flag %d, deferring recovery.\n" , ioc->name, ioc->sh->host_no, - SCpnt->device->id, SCpnt->device->lun, - ready, ioc->active, caller)); +dev_name (&rport->dev), ready, ioc->active));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 ) { +if (ready ==DID_NO_CONNECT || 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, +"mpt_block_error_handler.%d: %s, failing recovery, " +"port state %x, active %d.\n" , ioc->name, ioc->sh->host_no, - SCpnt->device->id, SCpnt->device->lun, ready, - ioc->active, SCpnt->device->hostdata)); +dev_name (&rport->dev), ready, ioc->active));return FAILED ; } -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); +return SUCCESS ; }static int mptfc_abort (struct scsi_cmnd *SCpnt) { -return -mptfc_block_error_handler (SCpnt, mptscsih_abort, __func__); +struct Scsi_Host *shost = SCpnt->device->host; +struct fc_rport *rport =starget_to_rport (scsi_target (SCpnt->device)); +MPT_SCSI_HOST __maybe_unused *hd =shost_priv (shost); +int rtn; + + rtn =mptfc_block_error_handler (rport); +if (rtn ==SUCCESS ) { +dfcprintk (hd->ioc,printk (MYIOC_s_DEBUG_FMT +"%s.%d: %d:%llu, executing recovery.\n" , __func__, + hd->ioc->name, shost->host_no, + SCpnt->device->id, SCpnt->device->lun)); + rtn =mptscsih_abort (SCpnt); + } +return rtn; }static int mptfc_dev_reset (struct scsi_cmnd *SCpnt) { -return -mptfc_block_error_handler (SCpnt, mptscsih_dev_reset, __func__); +struct Scsi_Host *shost = SCpnt->device->host; +struct fc_rport *rport =starget_to_rport (scsi_target (SCpnt->device)); +MPT_SCSI_HOST __maybe_unused *hd =shost_priv (shost); +int rtn; + + rtn =mptfc_block_error_handler (rport); +if (rtn ==SUCCESS ) { +dfcprintk (hd->ioc,printk (MYIOC_s_DEBUG_FMT +"%s.%d: %d:%llu, executing recovery.\n" , __func__, + hd->ioc->name, shost->host_no, + SCpnt->device->id, SCpnt->device->lun)); + rtn =mptscsih_dev_reset (SCpnt); + } +return rtn; }static int mptfc_bus_reset (struct scsi_cmnd *SCpnt) { -return -mptfc_block_error_handler (SCpnt, mptscsih_bus_reset, __func__); +struct Scsi_Host *shost = SCpnt->device->host; +struct fc_rport *rport =starget_to_rport (scsi_target (SCpnt->device)); +MPT_SCSI_HOST __maybe_unused *hd =shost_priv (shost); +int rtn; + + rtn =mptfc_block_error_handler (rport); +if (rtn ==SUCCESS ) { +dfcprintk (hd->ioc,printk (MYIOC_s_DEBUG_FMT +"%s.%d: %d:%llu, executing recovery.\n" , __func__, + hd->ioc->name, shost->host_no, + SCpnt->device->id, SCpnt->device->lun)); + rtn =mptscsih_bus_reset (SCpnt); + } +return rtn; } static void
Signature · 1 line
2.29.2
Hannes Reinecke
maintainerPATCH v3 4/20 mptfusion: correct definitions for mptscsih_dev_reset()
In reply to Hannes ReineckeFrom: 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 ){
@@ -3257,6 +3309,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
Re: [PATCH 04/20] mptfusion: correct definitions for mptscsih_dev_reset()
This patch appears to change the EH activity from issuing a target reset to a LUN reset only
(since it does not add an entry in the host templates for .eh_target_reset_handler to invoke
the new mptscsih_target_reset() function, nor does any other patch in the series).
Is this going to work properly, and without escalating to a host reset which might not have happened before?
-Ewan
Quoted 111 lines · Hannes Reinecke
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 formptscsih_dev_reset(), and renames the original function tomptscsih_target_reset().Signed-off-by Hannes Reinecke <[email protected]>Reviewed-by Christoph Hellwig <[email protected]>Reviewed-by Johannes Thumshirn <[email protected]>--- 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 ){@@ -3257,6 +3309,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
-1@@ -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[]); --2.29.2
Hannes Reinecke
maintainerRe: [PATCH 04/20] mptfusion: correct definitions for mptscsih_dev_reset()
Quoted 10 lines · Ewan Milne
This patch appears to change the EH activity from issuing a target reset to a LUN reset only
(since it does not add an entry in the host templates for .eh_target_reset_handler to invoke
the newmptscsih_target_reset()function, nor does any other patch in the series).Is this going to work properly, and without escalating to a host reset which might not have happened before?
You are correct, the drivers need to be changed to refer to target_reset now. Will be fixing it with the next version.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
Hannes Reinecke
maintainerPATCH v3 5/20 mptfc: open-code mptfc_block_error_handler() for bus reset
In reply to Hannes ReineckeWhen calling bus_reset we have potentially several ports to be reset, so this patch open-codes the existing mptfc_block_error_handler() to wait for all ports attached to this bus.
--- drivers/message/fusion/mptfc.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/message/fusion/mptfc.c +14 -3
@@ -262,12 +262,23 @@ static int mptfc_bus_reset(struct scsi_cmnd *SCpnt) {struct Scsi_Host *shost = SCpnt->device->host; -struct fc_rport *rport =starget_to_rport (scsi_target (SCpnt->device));MPT_SCSI_HOST __maybe_unused *hd =shost_priv (shost); +int channel = SCpnt->device->channel; +struct mptfc_rport_info *ri;int rtn; - rtn =mptfc_block_error_handler (rport); -if (rtn ==SUCCESS ) { +list_for_each_entry (ri, &hd->ioc->fc_rports, list) { +if (ri->flags &MPT_RPORT_INFO_FLAGS_REGISTERED ) { +VirtTarget *vtarget = ri->starget->hostdata; + +if (!vtarget || vtarget->channel != channel) +continue ; + rtn =fc_block_rport (ri->rport); +if (rtn !=0 ) +break ; + } + } +if (rtn ==0 ) { dfcprintk (hd->ioc, printk(MYIOC_s_DEBUG_FMT "%s.%d: %d:%llu, executing recovery.\n", __func__, hd->ioc->name, shost->host_no,
Signature · 1 line
2.29.2
Re: [PATCH 05/20] mptfc: open-code mptfc_block_error_handler() for bus reset
This change removes the debug log messages that mptfc_block_error_handler() would have generated, and also doesn't do the same thing, at all, for each rport due to the differences in the logic between fc_block_rport() and fc_remote_port_chkready()
and waiting for ioc->active == 0.
Perhaps this is desirable and intentional, if so, could you explain this in the commit message?
-Ewan
Quoted 46 lines · Hannes Reinecke
When calling
bus_resetwe have potentially several ports to be reset, so this patch open-codes the existingmptfc_block_error_handler()to wait for all ports attached to this bus.Signed-off-by Hannes Reinecke <[email protected]>Reviewed-by Christoph Hellwig <[email protected]>Reviewed-by Johannes Thumshirn <[email protected]>--- drivers/message/fusion/mptfc.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)drivers/message/fusion/mptfc.c +14
-4@@ -262,12 +262,23 @@ static int mptfc_bus_reset(struct scsi_cmnd *SCpnt) {struct Scsi_Host *shost = SCpnt->device->host; -struct fc_rport *rport =starget_to_rport (scsi_target (SCpnt->device));MPT_SCSI_HOST __maybe_unused *hd =shost_priv (shost); +int channel = SCpnt->device->channel; +struct mptfc_rport_info *ri;int rtn; - rtn =mptfc_block_error_handler (rport); -if (rtn ==SUCCESS ) { +list_for_each_entry (ri, &hd->ioc->fc_rports, list) { +if (ri->flags &MPT_RPORT_INFO_FLAGS_REGISTERED ) { +VirtTarget *vtarget = ri->starget->hostdata; + +if (!vtarget || vtarget->channel != channel) +continue ; + rtn =fc_block_rport (ri->rport); +if (rtn !=0 ) +break ; + } + } +if (rtn ==0 ) { dfcprintk (hd->ioc, printk(MYIOC_s_DEBUG_FMT "%s.%d: %d:%llu, executing recovery.\n", __func__, hd->ioc->name, shost->host_no, --2.29.2
Hannes Reinecke
maintainerRe: [PATCH 05/20] mptfc: open-code mptfc_block_error_handler() for bus reset
Quoted 6 lines · Ewan Milne
This change removes the debug log messages that
mptfc_block_error_handler()would have generated, and also doesn't do the same thing, at all, for each rport due to the differences in the logic betweenfc_block_rport()andfc_remote_port_chkready()
and waiting forioc->active== 0.
Yes, I'll be adding back the checks for ioc->active.
Quoted 3 lines
Perhaps this is desirable and intentional, if so, could you explain this in the commit message?
Removing the debug calls was intentional; if needs be they can be activated via scsi_logging_level.
I'll be updating the commit message.
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman
Hannes Reinecke
maintainerPATCH v3 6/20 qedf: use fc rport as argument for qedf_initiate_tmf()
In reply to Hannes ReineckeWhen sending a TMF we're only concerned with the rport and the LUN ID, so use struct fc_rport as argument for qedf_initiate_tmf().
--- drivers/scsi/qedf/qedf.h | 5 ++- drivers/scsi/qedf/qedf_io.c | 75 ++++++++++------------------------- drivers/scsi/qedf/qedf_main.c | 19 ++++----- 3 files changed, 33 insertions(+), 66 deletions(-)
drivers/scsi/qedf/qedf.h +3 -2
@@ -112,6 +112,7 @@ struct qedf_ioreq {#define QEDF_CMD_ERR_SCSI_DONE 0x5u8 io_req_flags;uint8_t tm_flags; +u64 tm_lun;struct qedf_rport *fcport;#define QEDF_CMD_ST_INACTIVE 0#define QEDFC_CMD_ST_IO_ACTIVE 1
@@ -497,7 +498,7 @@ extern void qedf_process_warning_compl(struct qedf_ctx *qedf, struct fcoe_cqe *cqe, struct qedf_ioreq *io_req);extern void qedf_process_error_detect (struct qedf_ctx *qedf,struct fcoe_cqe *cqe,struct qedf_ioreq *io_req); -extern void qedf_flush_active_ios (struct qedf_rport *fcport,int lun); +extern void qedf_flush_active_ios (struct qedf_rport *fcport,u64 lun);extern void qedf_release_cmd (struct kref *ref);extern int qedf_initiate_abts (struct qedf_ioreq *io_req,bool return_scsi_cmd_on_abts);
@@ -522,7 +523,7 @@ extern int qedf_initiate_cleanup(struct qedf_ioreq *io_req, bool return_scsi_cmd_on_abts);extern void qedf_process_cleanup_compl (struct qedf_ctx *qedf,struct fcoe_cqe *cqe,struct qedf_ioreq *io_req); -extern int qedf_initiate_tmf (struct scsi_cmnd *sc_cmd,u8 tm_flags); +extern int qedf_initiate_tmf (struct fc_rport *rport,u64 lun,u8 tm_flags);extern void qedf_process_tmf_compl (struct qedf_ctx *qedf,struct fcoe_cqe *cqe,struct qedf_ioreq *io_req);extern void qedf_process_cqe (struct qedf_ctx *qedf,struct fcoe_cqe *cqe);
drivers/scsi/qedf/qedf_io.c +20 -55
173 lines not on this page · raw message
drivers/scsi/qedf/qedf_main.c +10 -9
@@ -773,7 +773,7 @@ static int qedf_eh_abort(struct scsi_cmnd *sc_cmd) goto drop_rdata_kref; } - rc =fc_block_scsi_eh (sc_cmd); + rc =fc_block_rport (rport);if (rc) goto drop_rdata_kref;
@@ -857,18 +857,19 @@ static int qedf_eh_abort(struct scsi_cmnd *sc_cmd)static int qedf_eh_target_reset (struct scsi_cmnd *sc_cmd) { -QEDF_ERR (NULL ,"%d:0:%d:%lld: TARGET RESET Issued..." , - sc_cmd->device->host->host_no, sc_cmd->device->id, - sc_cmd->device->lun); -return qedf_initiate_tmf (sc_cmd,FCP_TMF_TGT_RESET ); +struct scsi_target *starget =scsi_target (sc_cmd->device); +struct fc_rport *rport =starget_to_rport (starget); + +QEDF_ERR (NULL ,"TARGET RESET Issued..." ); +return qedf_initiate_tmf (rport,0 ,FCP_TMF_TGT_RESET ); }static int qedf_eh_device_reset (struct scsi_cmnd *sc_cmd) { -QEDF_ERR (NULL ,"%d:0:%d:%lld: LUN RESET Issued... " , - sc_cmd->device->host->host_no, sc_cmd->device->id, - sc_cmd->device->lun); -return qedf_initiate_tmf (sc_cmd,FCP_TMF_LUN_RESET ); +struct fc_rport *rport =starget_to_rport (scsi_target (sc_cmd->device)); + +QEDF_ERR (NULL ,"LUN RESET Issued...\n" ); +return qedf_initiate_tmf (rport, sc_cmd->device->lun,FCP_TMF_LUN_RESET ); }bool qedf_wait_for_upload (struct qedf_ctx *qedf)
Signature · 1 line
2.29.2
Re: [PATCH 06/20] qedf: use fc rport as argument for qedf_initiate_tmf()
The patch changes the data type of the 'lun' argument to qedf_flush_active_ios() to a u64, but the remaining code still uses a wildcard of -1, perhaps this needs a
#define or enum of a value that is unsigned also?
Removing the call to fc_remote_port_chkready() in qedf_initiate_tmf() will result
in different semantics for whether the TMF will be issued.
Changing the debug logging in qedf_eh_target_reset() and qedf_eh_device_reset() might make identifying the target more difficult, although qedf_initiate_tmf() will
also log a message, the rport->scsi_target_id is not the same value as the sdev->id.
-Ewan
Quoted 279 lines · Hannes Reinecke
When sending a TMF we're only concerned with the rport and the LUN ID, so use struct
fc_rportas argument forqedf_initiate_tmf().Signed-off-by Hannes Reinecke <[email protected]>Reviewed-by Christoph Hellwig <[email protected]>Reviewed-by Johannes Thumshirn <[email protected]>Cc Saurav Kashyap <[email protected]>--- drivers/scsi/qedf/qedf.h | 5 ++- drivers/scsi/qedf/qedf_io.c | 75 ++++++++++------------------------- drivers/scsi/qedf/qedf_main.c | 19 ++++----- 3 files changed, 33 insertions(+), 66 deletions(-)drivers/scsi/qedf/qedf.h +3
-2@@ -112,6 +112,7 @@ struct qedf_ioreq {#define QEDF_CMD_ERR_SCSI_DONE 0x5u8 io_req_flags;uint8_t tm_flags; +u64 tm_lun;struct qedf_rport *fcport;#define QEDF_CMD_ST_INACTIVE 0#define QEDFC_CMD_ST_IO_ACTIVE 1@@ -497,7 +498,7 @@ extern void qedf_process_warning_compl(struct qedf_ctx *qedf, struct fcoe_cqe *cqe, struct qedf_ioreq *io_req);extern void qedf_process_error_detect (struct qedf_ctx *qedf,struct fcoe_cqe *cqe,struct qedf_ioreq *io_req); -extern void qedf_flush_active_ios (struct qedf_rport *fcport,int lun); +extern void qedf_flush_active_ios (struct qedf_rport *fcport,u64 lun);extern void qedf_release_cmd (struct kref *ref);extern int qedf_initiate_abts (struct qedf_ioreq *io_req,bool return_scsi_cmd_on_abts);@@ -522,7 +523,7 @@ extern int qedf_initiate_cleanup(struct qedf_ioreq *io_req, bool return_scsi_cmd_on_abts);extern void qedf_process_cleanup_compl (struct qedf_ctx *qedf,struct fcoe_cqe *cqe,struct qedf_ioreq *io_req); -extern int qedf_initiate_tmf (struct scsi_cmnd *sc_cmd,u8 tm_flags); +extern int qedf_initiate_tmf (struct fc_rport *rport,u64 lun,u8 tm_flags);extern void qedf_process_tmf_compl (struct qedf_ctx *qedf,struct fcoe_cqe *cqe,struct qedf_ioreq *io_req);extern void qedf_process_cqe (struct qedf_ctx *qedf,struct fcoe_cqe *cqe);drivers/scsi/qedf/qedf_io.c +20
-55@@ -546,7 +546,7 @@ static int qedf_build_bd_list_from_sg(struct qedf_ioreq *io_req) }static void qedf_build_fcp_cmnd (struct qedf_ioreq *io_req, -struct fcp_cmnd *fcp_cmnd) +struct fcp_cmnd *fcp_cmnd) {struct scsi_cmnd *sc_cmd = io_req->sc_cmd;@@ -554,8 +554,12 @@ static void qedf_build_fcp_cmnd(struct qedf_ioreq *io_req,memset (fcp_cmnd,0 ,FCP_CMND_LEN );/* 8 bytes: SCSI LUN info */ -int_to_scsilun (sc_cmd->device->lun, - (struct scsi_lun *)&fcp_cmnd->fc_lun); +if (io_req->cmd_type ==QEDF_TASK_MGMT_CMD ) +int_to_scsilun (io_req->tm_lun, + (struct scsi_lun *)&fcp_cmnd->fc_lun); +else +int_to_scsilun (sc_cmd->device->lun, + (struct scsi_lun *)&fcp_cmnd->fc_lun);/* 4 bytes: flag info */ fcp_cmnd->fc_pri_ta =0 ;@@ -1096,7 +1100,7 @@ static void qedf_parse_fcp_rsp(struct qedf_ioreq *io_req, }/* The sense buffer can be NULL for TMF commands */ -if (sc_cmd->sense_buffer) { +if (sc_cmd && sc_cmd->sense_buffer) {memset (sc_cmd->sense_buffer,0 ,SCSI_SENSE_BUFFERSIZE );if (fcp_sns_len) memcpy(sc_cmd->sense_buffer, sense_data,@@ -1581,7 +1585,7 @@ static void qedf_flush_els_req(struct qedf_ctx *qedf,/* A value of -1 for lun is a wild card that means flush all * active SCSI I/Os for the target. */ -void qedf_flush_active_ios (struct qedf_rport *fcport,int lun) +void qedf_flush_active_ios (struct qedf_rport *fcport,u64 lun) {struct qedf_ioreq *io_req;struct qedf_ctx *qedf;@@ -1769,10 +1773,6 @@ void qedf_flush_active_ios(struct qedf_rport *fcport, int lun)kref_put (&io_req->refcount, qedf_release_cmd);continue ; } -if (lun >-1 ) { -if (io_req->lun != lun) -continue ; - }/* * Use kref_get_unless_zero in the unlikely case the command @@ -2282,7 +2282,7 @@ void qedf_process_cleanup_compl(struct qedf_ctx *qedf, struct fcoe_cqe *cqe,complete (&io_req->cleanup_done); } -static int qedf_execute_tmf (struct qedf_rport *fcport,struct scsi_cmnd *sc_cmd, +static int qedf_execute_tmf (struct qedf_rport *fcport,u64 tm_lun,uint8_t tm_flags) {struct qedf_ioreq *io_req;@@ -2292,17 +2292,10 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd,int rc =0 ;uint16_t xid;int tmo =0 ; -int lun =0 ;unsigned long flags;struct fcoe_wqe *sqe;u16 sqe_idx; -if (!sc_cmd) { -QEDF_ERR (&qedf->dbg_ctx,"sc_cmd is NULL\n" ); -return FAILED ; - } - - lun = (int )sc_cmd->device->lun;if (!test_bit (QEDF_RPORT_SESSION_READY , &fcport->flags)) {QEDF_ERR (&(qedf->dbg_ctx),"fcport not offloaded\n" ); rc =FAILED ;@@ -2322,7 +2315,7 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd, qedf->target_resets++;/* Initialize rest of io_req fields */ - io_req->sc_cmd = sc_cmd; + io_req->sc_cmd =NULL ; io_req->fcport = fcport; io_req->cmd_type =QEDF_TASK_MGMT_CMD ;@@ -2336,6 +2329,7 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd,/* Default is to return a SCSI command when an error occurs */ io_req->return_scsi_cmd_on_abts = false; + io_req->tm_lun = tm_lun;/* Obtain exchange id */ xid = io_req->xid;@@ -2390,7 +2384,7 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd,if (tm_flags ==FCP_TMF_LUN_RESET ) -qedf_flush_active_ios (fcport, lun); +qedf_flush_active_ios (fcport, tm_lun);else qedf_flush_active_ios (fcport,-1 );@@ -2405,23 +2399,18 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd,return rc; } -int qedf_initiate_tmf (struct scsi_cmnd *sc_cmd,u8 tm_flags) +int qedf_initiate_tmf (struct fc_rport *rport,u64 lun,u8 tm_flags) { -struct fc_rport *rport =starget_to_rport (scsi_target (sc_cmd->device));struct fc_rport_libfc_priv *rp = rport->dd_data;struct qedf_rport *fcport = (struct qedf_rport *)&rp[1 ]; -struct qedf_ctx *qedf; -struct fc_lport *lport =shost_priv (sc_cmd->device->host); +struct qedf_ctx *qedf = fcport->qedf; +struct fc_lport *lport = rp->local_port;int rc =SUCCESS ; -int rval; -struct qedf_ioreq *io_req =NULL ; -int ref_cnt =0 ;struct fc_rport_priv *rdata = fcport->rdata;QEDF_ERR (NULL , -"tm_flags 0x%x sc_cmd %p op = 0x%02x target_id = 0x%x lun=%d\n" , - tm_flags, sc_cmd, sc_cmd->cmd_len ? sc_cmd->cmnd[0 ] :0xff , - rport->scsi_target_id, (int )sc_cmd->device->lun); +"tm_flags 0x%x target_id = 0x%x lun=%llu\n" , + tm_flags, rport->scsi_target_id, lun);if (!rdata || !kref_get_unless_zero (&rdata->kref)) {QEDF_ERR (NULL ,"stale rport\n" );@@ -2432,33 +2421,10 @@ int qedf_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags) (tm_flags ==FCP_TMF_TGT_RESET ) ?"TARGET RESET" : "LUN RESET"); -if (qedf_priv (sc_cmd)->io_req) { - io_req =qedf_priv (sc_cmd)->io_req; - ref_cnt =kref_read (&io_req->refcount); -QEDF_ERR (NULL , -"orig io_req = %p xid = 0x%x ref_cnt = %d.\n" , - io_req, io_req->xid, ref_cnt); - } - - rval =fc_remote_port_chkready (rport); -if (rval) { -QEDF_ERR (NULL ,"device_reset rport not ready\n" ); - rc =FAILED ; - goto tmf_err; - } - - rc =fc_block_scsi_eh (sc_cmd); + rc =fc_block_rport (rport);if (rc) goto tmf_err; -if (!fcport) { -QEDF_ERR (NULL ,"device_reset: rport is NULL\n" ); - rc =FAILED ; - goto tmf_err; - } - - qedf = fcport->qedf; -if (!qedf) {QEDF_ERR (NULL ,"qedf is NULL.\n" ); rc =FAILED ;@@ -2495,7 +2461,7 @@ int qedf_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags) goto tmf_err; } - rc =qedf_execute_tmf (fcport, sc_cmd, tm_flags); + rc =qedf_execute_tmf (fcport, lun, tm_flags); tmf_err:kref_put (&rdata->kref, fc_rport_destroy);@@ -2512,7 +2478,6 @@ void qedf_process_tmf_compl(struct qedf_ctx *qedf, struct fcoe_cqe *cqe, fcp_rsp = &cqe->cqe_info.rsp_info;qedf_parse_fcp_rsp (io_req, fcp_rsp); - io_req->sc_cmd =NULL ;complete (&io_req->tm_done); }drivers/scsi/qedf/qedf_main.c +10
-10@@ -773,7 +773,7 @@ static int qedf_eh_abort(struct scsi_cmnd *sc_cmd) goto drop_rdata_kref; } - rc =fc_block_scsi_eh (sc_cmd); + rc =fc_block_rport (rport);if (rc) goto drop_rdata_kref;@@ -857,18 +857,19 @@ static int qedf_eh_abort(struct scsi_cmnd *sc_cmd)static int qedf_eh_target_reset (struct scsi_cmnd *sc_cmd) { -QEDF_ERR (NULL ,"%d:0:%d:%lld: TARGET RESET Issued..." , - sc_cmd->device->host->host_no, sc_cmd->device->id, - sc_cmd->device->lun); -return qedf_initiate_tmf (sc_cmd,FCP_TMF_TGT_RESET ); +struct scsi_target *starget =scsi_target (sc_cmd->device); +struct fc_rport *rport =starget_to_rport (starget); + +QEDF_ERR (NULL ,"TARGET RESET Issued..." ); +return qedf_initiate_tmf (rport,0 ,FCP_TMF_TGT_RESET ); }static int qedf_eh_device_reset (struct scsi_cmnd *sc_cmd) { -QEDF_ERR (NULL ,"%d:0:%d:%lld: LUN RESET Issued... " , - sc_cmd->device->host->host_no, sc_cmd->device->id, - sc_cmd->device->lun); -return qedf_initiate_tmf (sc_cmd,FCP_TMF_LUN_RESET ); +struct fc_rport *rport =starget_to_rport (scsi_target (sc_cmd->device)); + +QEDF_ERR (NULL ,"LUN RESET Issued...\n" ); +return qedf_initiate_tmf (rport, sc_cmd->device->lun,FCP_TMF_LUN_RESET ); }bool qedf_wait_for_upload (struct qedf_ctx *qedf) --2.29.2
Hannes Reinecke
maintainerRe: [PATCH 06/20] qedf: use fc rport as argument for qedf_initiate_tmf()
Quoted 5 lines · Ewan Milne
The patch changes the data type of the 'lun' argument to
qedf_flush_active_ios()to a u64, but the remaining code still uses a wildcard of -1, perhaps this needs a
#define or enum of a value that is unsigned also?
Ah, no, I went slightly overboard there. That needs to be changed back to be an 'int'.
Quoted 4 lines
Removing the call to
fc_remote_port_chkready()inqedf_initiate_tmf()will result
in different semantics for whether the TMF will be issued.
Really? 'fc_remote_port_chkready()' just evaluates the port state; this is also done by fc_block_rport().
So dropping the first shouldn't make a difference.
Quoted 6 lines
Changing the debug logging in
qedf_eh_target_reset()andqedf_eh_device_reset()might make identifying the target more difficult, althoughqedf_initiate_tmf()will
also log a message, therport->scsi_target_idis not the same value as thesdev->id.
Sigh. Yes, the error logging is suboptimal.
Will be updating it.
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman
Re: [PATCH 06/20] qedf: use fc rport as argument for qedf_initiate_tmf()
Well, fc_remote_port_chkready() has in the _ONLINE and _MARGINAL case:
if (rport->roles & FC_PORT_ROLE_FCP_TARGET)
result = 0;
else if (rport->flags & FC_RPORT_DEVLOSS_PENDING)
result = DID_IMM_RETRY << 16;
else
result = DID_NO_CONNECT << 16;
break;which fc_block_rport() does not have. Admittedly, I would have thought that the rport would be blocked while devloss was pending but there is code in fc_timeout_deleted_rport() that indicates otherwise, maybe this only happens if there is a role change.
-Ewan
Quoted 37 lines · Hannes Reinecke
Quoted 5 lines · Ewan Milne
The patch changes the data type of the 'lun' argument to
qedf_flush_active_ios()to a u64, but the remaining code still uses a wildcard of -1, perhaps this needs a
#define or enum of a value that is unsigned also?Ah, no, I went slightly overboard there. That needs to be changed back to be an 'int'.
Quoted 4 lines
Removing the call to
fc_remote_port_chkready()inqedf_initiate_tmf()will result
in different semantics for whether the TMF will be issued.Really? '
fc_remote_port_chkready()' just evaluates the port state; this is also done byfc_block_rport().
So dropping the first shouldn't make a difference.Quoted 6 lines
Changing the debug logging in
qedf_eh_target_reset()andqedf_eh_device_reset()might make identifying the target more difficult, althoughqedf_initiate_tmf()will
also log a message, therport->scsi_target_idis not the same value as thesdev->id.Sigh. Yes, the error logging is suboptimal.
Will be updating it.Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
[email protected] +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman
Hannes Reinecke
maintainerRe: [PATCH 06/20] qedf: use fc rport as argument for qedf_initiate_tmf()
Quoted 10 lines · Ewan Milne
Well,
fc_remote_port_chkready()has in the_ONLINEand_MARGINALcase:if (rport->roles & FC_PORT_ROLE_FCP_TARGET) result = 0; else if (rport->flags & FC_RPORT_DEVLOSS_PENDING) result = DID_IMM_RETRY << 16; else result = DID_NO_CONNECT << 16; break;
Quoted 5 lines
which
fc_block_rport()does not have. Admittedly, I would have thought that the rport would be blocked while devloss was pending but there is code infc_timeout_deleted_rport()that indicates otherwise, maybe this only happens if there is a role change.
Sort of. But the code in qedf only deals with FCP target ports, so we'll always take the first branch and the entire code is pointless. Am I wrong?
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman
Hannes Reinecke
maintainerPATCH v3 7/20 bnx2fc: Do not rely on a scsi command for lun or target reset
In reply to Hannes ReineckeWhen a LUN or target reset is issued we should not rely on a scsi command to be present; we'll have to reset the entire device or target anyway.
--- drivers/scsi/bnx2fc/bnx2fc.h | 1 + drivers/scsi/bnx2fc/bnx2fc_hwi.c | 14 +++-- drivers/scsi/bnx2fc/bnx2fc_io.c | 94 ++++++++++++++++---------------- 3 files changed, 57 insertions(+), 52 deletions(-)
drivers/scsi/bnx2fc/bnx2fc.h +1 -0
@@ -384,6 +384,7 @@ struct bnx2fc_rport { };struct bnx2fc_mp_req { +u64 tm_lun;u8 tm_flags;u32 req_len;
drivers/scsi/bnx2fc/bnx2fc_hwi.c +9 -5
@@ -1709,7 +1709,8 @@ void bnx2fc_init_task(struct bnx2fc_cmd *io_req,struct fcoe_cached_sge_ctx *cached_sge;struct fcoe_ext_mul_sges_ctx *sgl;int dev_type = tgt->dev_type; -u64 *fcp_cmnd; +struct fcp_cmnd *fcp_cmnd; +u64 *raw_fcp_cmnd;u64 tmp_fcp_cmnd[4 ];u32 context_id;int cnt, i;
@@ -1778,16 +1779,19 @@ void bnx2fc_init_task(struct bnx2fc_cmd *io_req, task->txwr_rxrd.union_ctx.tx_seq.ctx.seq_cnt =1 ;/* Fill FCP_CMND IU */ - fcp_cmnd = (u64 *) + fcp_cmnd = (struct fcp_cmnd *)&tmp_fcp_cmnd; +bnx2fc_build_fcp_cmnd (io_req, fcp_cmnd); +int_to_scsilun (sc_cmd->device->lun, &fcp_cmnd->fc_lun); +memcpy (fcp_cmnd->fc_cdb, sc_cmd->cmnd, sc_cmd->cmd_len); + raw_fcp_cmnd = (u64 *) task->txwr_rxrd.union_ctx.fcp_cmd.opaque; -bnx2fc_build_fcp_cmnd (io_req, (struct fcp_cmnd *)&tmp_fcp_cmnd);/* swap fcp_cmnd */ cnt =sizeof (struct fcp_cmnd ) /sizeof (u64);for (i =0 ; i < cnt; i++) { - *fcp_cmnd =cpu_to_be64 (tmp_fcp_cmnd[i]); - fcp_cmnd++; + *raw_fcp_cmnd =cpu_to_be64 (tmp_fcp_cmnd[i]); + raw_fcp_cmnd++; }/* Rx Write Tx Read */
drivers/scsi/bnx2fc/bnx2fc_io.c +47 -47
192 lines not on this page · raw message
Signature · 1 line
2.29.2
Hannes Reinecke
maintainerPATCH v3 8/20 ibmvfc: open-code reset loop for target reset
In reply to Hannes ReineckeFrom: Hannes Reinecke <[email protected]>
For target reset we need a device to send the target reset to, so open-code the loop in target reset to send the target reset TMF to the correct device.
--- drivers/scsi/ibmvscsi/ibmvfc.c | 42 +++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 19 deletions(-)
drivers/scsi/ibmvscsi/ibmvfc.c +23 -19
@@ -2925,18 +2925,6 @@ static void ibmvfc_dev_cancel_all_noreset(struct scsi_device *sdev, void *data) *rc |=ibmvfc_cancel_all (sdev,IBMVFC_TMF_SUPPRESS_ABTS ); } -/** -* ibmvfc_dev_cancel_all_reset - Device iterated cancel all function -* @sdev: scsi device struct -* @data: return code -* -**/ -static void ibmvfc_dev_cancel_all_reset (struct scsi_device *sdev,void *data) -{ -unsigned long *rc = data; - *rc |=ibmvfc_cancel_all (sdev,IBMVFC_TMF_TGT_RESET ); -} -/** * ibmvfc_eh_target_reset_handler - Reset the target * @cmd: scsi command struct
@@ -2946,22 +2934,38 @@ static void ibmvfc_dev_cancel_all_reset(struct scsi_device *sdev, void *data)**/ static int ibmvfc_eh_target_reset_handler (struct scsi_cmnd *cmd) { -struct scsi_device *sdev = cmd->device; -struct ibmvfc_host *vhost =shost_priv (sdev->host); -struct scsi_target *starget =scsi_target (sdev); +struct scsi_target *starget =scsi_target (cmd->device); +struct fc_rport *rport =starget_to_rport (starget); +struct Scsi_Host *shost =rport_to_shost (rport); +struct ibmvfc_host *vhost =shost_priv (shost);int block_rc;int reset_rc =0 ;int rc =FAILED ;unsigned long cancel_rc =0 ; +bool tgt_reset = false;ENTER ; - block_rc =fc_block_scsi_eh (cmd); + block_rc =fc_block_rport (rport);ibmvfc_wait_while_resetting (vhost);if (block_rc !=FAST_IO_FAIL ) { -starget_for_each_device (starget, &cancel_rc, ibmvfc_dev_cancel_all_reset); - reset_rc =ibmvfc_reset_device (sdev,IBMVFC_TARGET_RESET ,"target" ); +struct scsi_device *sdev; + +shost_for_each_device (sdev, shost) { +if ((sdev->channel != starget->channel) || + (sdev->id != starget->id)) +continue ; + + cancel_rc |=ibmvfc_cancel_all (sdev, +IBMVFC_TMF_TGT_RESET ); +if (!tgt_reset) { + reset_rc =ibmvfc_reset_device (sdev, +IBMVFC_TARGET_RESET ,"target" ); + tgt_reset = true; + } + } }else -starget_for_each_device (starget, &cancel_rc, ibmvfc_dev_cancel_all_noreset); +starget_for_each_device (starget, &cancel_rc, + ibmvfc_dev_cancel_all_noreset);if (!cancel_rc && !reset_rc) rc =ibmvfc_wait_for_ops (vhost, starget, ibmvfc_match_target);
Signature · 1 line
2.29.2
Re: [PATCH 08/20] ibmvfc: open-code reset loop for target reset
This patch looks like it will call ibmvfc_reset_device() w/IBMVFC_TARGET_RESET before it has called ibmvfc_cancel_all() on all the devices, the existing code callsibmvfc_reset_device() w/IBMVFC_TARGET_RESET after the iterator.
Since you have the starget, why change to use shost_for_each_device() and check thesdev->channel and sdev->id ? That's what starget_for_each_device() does.
-Ewan
Quoted 87 lines · Hannes Reinecke
From: Hannes Reinecke <[email protected]>
For target reset we need a device to send the target reset to, so open-code the loop in target reset to send the target reset TMF to the correct device.
Signed-off-by Hannes Reinecke <[email protected]>Reviewed-by Christoph Hellwig <[email protected]>Reviewed-by Johannes Thumshirn <[email protected]>Cc Tyrel Datwyler <[email protected]>--- drivers/scsi/ibmvscsi/ibmvfc.c | 42 +++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 19 deletions(-)drivers/scsi/ibmvscsi/ibmvfc.c +23
-20@@ -2925,18 +2925,6 @@ static void ibmvfc_dev_cancel_all_noreset(struct scsi_device *sdev, void *data) *rc |=ibmvfc_cancel_all (sdev,IBMVFC_TMF_SUPPRESS_ABTS ); } -/** -* ibmvfc_dev_cancel_all_reset - Device iterated cancel all function -* @sdev: scsi device struct -* @data: return code -* -**/ -static void ibmvfc_dev_cancel_all_reset (struct scsi_device *sdev,void *data) -{ -unsigned long *rc = data; - *rc |=ibmvfc_cancel_all (sdev,IBMVFC_TMF_TGT_RESET ); -} -/** * ibmvfc_eh_target_reset_handler - Reset the target * @cmd: scsi command struct @@ -2946,22 +2934,38 @@ static void ibmvfc_dev_cancel_all_reset(struct scsi_device *sdev, void *data)**/ static int ibmvfc_eh_target_reset_handler (struct scsi_cmnd *cmd) { -struct scsi_device *sdev = cmd->device; -struct ibmvfc_host *vhost =shost_priv (sdev->host); -struct scsi_target *starget =scsi_target (sdev); +struct scsi_target *starget =scsi_target (cmd->device); +struct fc_rport *rport =starget_to_rport (starget); +struct Scsi_Host *shost =rport_to_shost (rport); +struct ibmvfc_host *vhost =shost_priv (shost);int block_rc;int reset_rc =0 ;int rc =FAILED ;unsigned long cancel_rc =0 ; +bool tgt_reset = false;ENTER ; - block_rc =fc_block_scsi_eh (cmd); + block_rc =fc_block_rport (rport);ibmvfc_wait_while_resetting (vhost);if (block_rc !=FAST_IO_FAIL ) { -starget_for_each_device (starget, &cancel_rc, ibmvfc_dev_cancel_all_reset); - reset_rc =ibmvfc_reset_device (sdev,IBMVFC_TARGET_RESET ,"target" ); +struct scsi_device *sdev; + +shost_for_each_device (sdev, shost) { +if ((sdev->channel != starget->channel) || + (sdev->id != starget->id)) +continue ; + + cancel_rc |=ibmvfc_cancel_all (sdev, +IBMVFC_TMF_TGT_RESET ); +if (!tgt_reset) { + reset_rc =ibmvfc_reset_device (sdev, +IBMVFC_TARGET_RESET ,"target" ); + tgt_reset = true; + } + } }else -starget_for_each_device (starget, &cancel_rc, ibmvfc_dev_cancel_all_noreset); +starget_for_each_device (starget, &cancel_rc, + ibmvfc_dev_cancel_all_noreset);if (!cancel_rc && !reset_rc) rc =ibmvfc_wait_for_ops (vhost, starget, ibmvfc_match_target); --2.29.2
Hannes Reinecke
maintainerRe: [PATCH 08/20] ibmvfc: open-code reset loop for target reset
Quoted 94 lines · Ewan Milne
This patch looks like it will call
ibmvfc_reset_device()w/IBMVFC_TARGET_RESET before it has calledibmvfc_cancel_all()on all the devices, the existing code callsibmvfc_reset_device()w/IBMVFC_TARGET_RESET after the iterator.Since you have the starget, why change to use
shost_for_each_device()and check thesdev->channelandsdev->id? That's whatstarget_for_each_device()does.-Ewan
Quoted 82 lines · Hannes Reinecke
From: Hannes Reinecke <[email protected]>
For target reset we need a device to send the target reset to, so open-code the loop in target reset to send the target reset TMF to the correct device.
Signed-off-by Hannes Reinecke <[email protected]>Reviewed-by Christoph Hellwig <[email protected]>Reviewed-by Johannes Thumshirn <[email protected]>Cc Tyrel Datwyler <[email protected]>--- drivers/scsi/ibmvscsi/ibmvfc.c | 42 +++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 19 deletions(-)drivers/scsi/ibmvscsi/ibmvfc.c +23
-19@@ -2925,18 +2925,6 @@ static void ibmvfc_dev_cancel_all_noreset(struct scsi_device *sdev, void *data) *rc |=ibmvfc_cancel_all (sdev,IBMVFC_TMF_SUPPRESS_ABTS ); } -/** -* ibmvfc_dev_cancel_all_reset - Device iterated cancel all function -* @sdev: scsi device struct -* @data: return code -* -**/ -static void ibmvfc_dev_cancel_all_reset (struct scsi_device *sdev,void *data) -{ -unsigned long *rc = data; - *rc |=ibmvfc_cancel_all (sdev,IBMVFC_TMF_TGT_RESET ); -} -/** * ibmvfc_eh_target_reset_handler - Reset the target * @cmd: scsi command struct @@ -2946,22 +2934,38 @@ static void ibmvfc_dev_cancel_all_reset(struct scsi_device *sdev, void *data)**/ static int ibmvfc_eh_target_reset_handler (struct scsi_cmnd *cmd) { -struct scsi_device *sdev = cmd->device; -struct ibmvfc_host *vhost =shost_priv (sdev->host); -struct scsi_target *starget =scsi_target (sdev); +struct scsi_target *starget =scsi_target (cmd->device); +struct fc_rport *rport =starget_to_rport (starget); +struct Scsi_Host *shost =rport_to_shost (rport); +struct ibmvfc_host *vhost =shost_priv (shost);int block_rc;int reset_rc =0 ;int rc =FAILED ;unsigned long cancel_rc =0 ; +bool tgt_reset = false;ENTER ; - block_rc =fc_block_scsi_eh (cmd); + block_rc =fc_block_rport (rport);ibmvfc_wait_while_resetting (vhost);if (block_rc !=FAST_IO_FAIL ) { -starget_for_each_device (starget, &cancel_rc, ibmvfc_dev_cancel_all_reset); - reset_rc =ibmvfc_reset_device (sdev,IBMVFC_TARGET_RESET ,"target" ); +struct scsi_device *sdev; + +shost_for_each_device (sdev, shost) { +if ((sdev->channel != starget->channel) || + (sdev->id != starget->id)) +continue ; + + cancel_rc |=ibmvfc_cancel_all (sdev, +IBMVFC_TMF_TGT_RESET ); +if (!tgt_reset) { + reset_rc =ibmvfc_reset_device (sdev, +IBMVFC_TARGET_RESET ,"target" ); + tgt_reset = true; + } + } }else -starget_for_each_device (starget, &cancel_rc, ibmvfc_dev_cancel_all_noreset); +starget_for_each_device (starget, &cancel_rc, + ibmvfc_dev_cancel_all_noreset);
Quoted 6 lines
Quoted 5 lines
drivers/scsi/ibmvscsi/ibmvfc.c +0
-1if (!cancel_rc && !reset_rc) rc =ibmvfc_wait_for_ops (vhost, starget, ibmvfc_match_target); --2.29.2
You are right; the call to ibmvfc_reset_device() needs to be moved out of the loop.
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman
Hannes Reinecke
maintainerPATCH v3 9/20 ibmvfc: use fc_block_rport()
In reply to Hannes ReineckeUse fc_block_rport() instead of fc_block_scsi_eh() as the latter will be deprecated.
--- drivers/scsi/ibmvscsi/ibmvfc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/scsi/ibmvscsi/ibmvfc.c +4 -2
@@ -2857,12 +2857,13 @@ static int ibmvfc_abort_task_set(struct scsi_device *sdev)static int ibmvfc_eh_abort_handler (struct scsi_cmnd *cmd) {struct scsi_device *sdev = cmd->device; +struct fc_rport *rport =starget_to_rport (scsi_target (sdev));struct ibmvfc_host *vhost =shost_priv (sdev->host);int cancel_rc, block_rc;int rc =FAILED ;ENTER ; - block_rc =fc_block_scsi_eh (cmd); + block_rc =fc_block_rport (rport);ibmvfc_wait_while_resetting (vhost);if (block_rc !=FAST_IO_FAIL ) { cancel_rc =ibmvfc_cancel_all (sdev,IBMVFC_TMF_ABORT_TASK_SET );
@@ -2890,12 +2891,13 @@ static int ibmvfc_eh_abort_handler(struct scsi_cmnd *cmd)static int ibmvfc_eh_device_reset_handler (struct scsi_cmnd *cmd) {struct scsi_device *sdev = cmd->device; +struct fc_rport *rport =starget_to_rport (scsi_target (sdev));struct ibmvfc_host *vhost =shost_priv (sdev->host);int cancel_rc, block_rc, reset_rc =0 ;int rc =FAILED ;ENTER ; - block_rc =fc_block_scsi_eh (cmd); + block_rc =fc_block_rport (rport);ibmvfc_wait_while_resetting (vhost);if (block_rc !=FAST_IO_FAIL ) { cancel_rc =ibmvfc_cancel_all (sdev,IBMVFC_TMF_LUN_RESET );
Signature · 1 line
2.29.2
Hannes Reinecke
maintainerPATCH v3 10/20 fnic: use dedicated device reset command
In reply to Hannes ReineckeUse a dedicated command to send a device reset instead of relying on using the command which triggered the device failure.
--- drivers/scsi/fnic/fnic_main.c | 9 +++ drivers/scsi/fnic/fnic_scsi.c | 132 ++++++++++------------------------ 2 files changed, 46 insertions(+), 95 deletions(-)
drivers/scsi/fnic/fnic_main.c +9 -0
@@ -831,6 +831,15 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto err_out_free_rq_buf; } +/* +* Hack alert: +* Reduce can_queue by one after calling scsi_add_host() +* to reserve the topmost command for TMF. +* Should be replaced by using a reserved command once +* support for that gets merged. +*/ + lp->host->can_queue--; +/* Start local port initiatialization */ lp->link_up =0 ;
drivers/scsi/fnic/fnic_scsi.c +37 -95
257 lines not on this page · raw message
Signature · 1 line
2.29.2
Hannes Reinecke
maintainerPATCH v3 11/20 fnic: use fc_block_rport() correctly
In reply to Hannes ReineckeUse fc_block_rport() instead of fc_block_scsi_eh() and evaluate the return value to avoid issuing TMF commands when the port is still blocked.
--- drivers/scsi/fnic/fnic_scsi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/scsi/fnic/fnic_scsi.c +4 -3
@@ -1733,9 +1733,6 @@ int fnic_abort_cmd(struct scsi_cmnd *sc)unsigned long abt_issued_time;DECLARE_COMPLETION_ONSTACK (tm_done); -/* Wait for rport to unblock */ -fc_block_scsi_eh (sc); -/* Get local-port, check ready and link up */ lp =shost_priv (sc->device->host);
@@ -1745,6 +1742,10 @@ int fnic_abort_cmd(struct scsi_cmnd *sc) term_stats = &fnic->fnic_stats.term_stats; rport =starget_to_rport (scsi_target (sc->device)); + ret =fc_block_rport (rport); +if (ret) +return ret; + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "Abort Cmd called FCID 0x%x, LUN 0x%llx TAG %x flags %x\n",
Signature · 1 line
2.29.2
Hannes Reinecke
maintainerPATCH v3 12/20 aic7xxx: make BUILD_SCSIID() a function
In reply to Hannes ReineckeConvert BUILD_SCSIID() into a function and add a scsi_device argument.
--- drivers/scsi/aic7xxx/aic7xxx_osm.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
drivers/scsi/aic7xxx/aic7xxx_osm.c +13 -6
@@ -798,11 +798,18 @@ struct scsi_host_template aic7xxx_driver_template = {/**************************** Tasklet Handler *********************************/ -/******************************** Macros **************************************/ -#define BUILD_SCSIID (ahc, cmd) \ - ((((cmd)->device->id << TID_SHIFT) & TID) \ - | (((cmd)->device->channel == 0) ? (ahc)->our_id : (ahc)->our_id_b) \ - | (((cmd)->device->channel == 0) ? 0 : TWIN_CHNLB)) + +static inline unsigned int ahc_build_scsiid (struct ahc_softc *ahc, +struct scsi_device *sdev) +{ +unsigned int scsiid = (sdev->id <<TID_SHIFT ) &TID ; + +if (sdev->channel ==0 ) + scsiid |= ahc->our_id; +else + scsiid |= ahc->our_id_b |TWIN_CHNLB ; +return scsiid; +}/******************************** Bus DMA *************************************/ int
@@ -1457,7 +1464,7 @@ ahc_linux_run_command(struct ahc_softc *ahc, struct ahc_linux_device *dev,* Fill out basics of the HSCB. */ hscb->control =0 ; - hscb->scsiid =BUILD_SCSIID (ahc, cmd); + hscb->scsiid =ahc_build_scsiid (ahc, cmd->device); hscb->lun = cmd->device->lun; mask =SCB_GET_TARGET_MASK (ahc, scb); tinfo = ahc_fetch_transinfo(ahc, SCB_GET_CHANNEL(ahc, scb),
Signature · 1 line
2.29.2
Re: [PATCH 12/20] aic7xxx: make BUILD_SCSIID() a function
Looks good:
Hannes Reinecke
maintainerPATCH v3 13/20 aic79xx: make BUILD_SCSIID() a function
In reply to Hannes ReineckeConvert BUILD_SCSIID() into a function and add a scsi_device argument.
--- drivers/scsi/aic7xxx/aic79xx_osm.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/scsi/aic7xxx/aic79xx_osm.c +7 -4
@@ -541,8 +541,11 @@ ahd_linux_unmap_scb(struct ahd_softc *ahd, struct scb *scb) }/******************************** Macros **************************************/ -#define BUILD_SCSIID (ahd, cmd) \ - (((scmd_id(cmd) << TID_SHIFT) & TID) | (ahd)->our_id) +static inline unsigned int ahd_build_scsiid (struct ahd_softc *ahd, +struct scsi_device *sdev) +{ +return ((sdev_id (sdev) <<TID_SHIFT ) &TID ) | (ahd)->our_id; +}/* * Return a string describing the driver.
@@ -818,7 +821,7 @@ ahd_linux_dev_reset(struct scsi_cmnd *cmd)ahd_set_sense_residual (reset_scb,0 ); reset_scb->platform_data->xfer_len =0 ; reset_scb->hscb->control =0 ; - reset_scb->hscb->scsiid =BUILD_SCSIID (ahd,cmd); + reset_scb->hscb->scsiid =ahd_build_scsiid (ahd, cmd->device); reset_scb->hscb->lun = cmd->device->lun; reset_scb->hscb->cdb_len =0 ; reset_scb->hscb->task_management =SIU_TASKMGMT_LUN_RESET ;
@@ -1577,7 +1580,7 @@ ahd_linux_run_command(struct ahd_softc *ahd, struct ahd_linux_device *dev,* Fill out basics of the HSCB. */ hscb->control =0 ; - hscb->scsiid =BUILD_SCSIID (ahd, cmd); + hscb->scsiid =ahd_build_scsiid (ahd, cmd->device); hscb->lun = cmd->device->lun; scb->hscb->task_management =0 ; mask =SCB_GET_TARGET_MASK (ahd, scb);
Signature · 1 line
2.29.2
Re: [PATCH 13/20] aic79xx: make BUILD_SCSIID() a function
Looks good:
Hannes Reinecke
maintainerPATCH v3 14/20 aic7xxx: do not reference scsi command when resetting device
In reply to Hannes ReineckeWhen sending a device reset we should not take a reference to the scsi command.
--- drivers/scsi/aic7xxx/aic7xxx_osm.c | 108 +++++++++++++++-------------- 1 file changed, 57 insertions(+), 51 deletions(-)
drivers/scsi/aic7xxx/aic7xxx_osm.c +57 -51
@@ -366,7 +366,8 @@ static void ahc_linux_queue_cmd_complete(struct ahc_softc *ahc, struct scsi_cmnd *cmd);static void ahc_linux_freeze_simq (struct ahc_softc *ahc);static void ahc_linux_release_simq (struct ahc_softc *ahc); -static int ahc_linux_queue_recovery_cmd (struct scsi_cmnd *cmd,scb_flag flag); +static int ahc_linux_queue_recovery_cmd (struct scsi_device *sdev, +struct scsi_cmnd *cmd);static void ahc_linux_initialize_scsi_bus (struct ahc_softc *ahc);static u_int ahc_linux_user_tagdepth (struct ahc_softc *ahc,struct ahc_devinfo *devinfo);
@@ -728,7 +729,7 @@ ahc_linux_abort(struct scsi_cmnd *cmd) {int error; - error =ahc_linux_queue_recovery_cmd (cmd,SCB_ABORT ); + error =ahc_linux_queue_recovery_cmd (cmd->device, cmd);if (error !=SUCCESS )printk ("aic7xxx_abort returns 0x%x\n" , error);return (error);
@@ -742,7 +743,7 @@ ahc_linux_dev_reset(struct scsi_cmnd *cmd) {int error; - error =ahc_linux_queue_recovery_cmd (cmd,SCB_DEVICE_RESET ); + error =ahc_linux_queue_recovery_cmd (cmd->device,NULL );if (error !=SUCCESS )printk ("aic7xxx_dev_reset returns 0x%x\n" , error);return (error);
@@ -2036,11 +2037,12 @@ ahc_linux_release_simq(struct ahc_softc *ahc) }static int -ahc_linux_queue_recovery_cmd (struct scsi_cmnd *cmd,scb_flag flag) +ahc_linux_queue_recovery_cmd (struct scsi_device *sdev, +struct scsi_cmnd *cmd) {struct ahc_softc *ahc;struct ahc_linux_device *dev; -struct scb *pending_scb; +struct scb *pending_scb =NULL , *scb;u_int saved_scbptr;u_int active_scb_index;u_int last_phase;
@@ -2053,18 +2055,19 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)int disconnected;unsigned long flags; - pending_scb =NULL ; paused = FALSE; wait = FALSE; - ahc = *(struct ahc_softc **)cmd->device->host->hostdata; + ahc = *(struct ahc_softc **)sdev->host->hostdata; -scmd_printk (KERN_INFO , cmd,"Attempting to queue a%s message\n" , - flag ==SCB_ABORT ?"n ABORT" :" TARGET RESET" ); +sdev_printk (KERN_INFO , sdev,"Attempting to queue a%s message\n" , + cmd ?"n ABORT" :" TARGET RESET" ); -printk ("CDB:" ); -for (cdb_byte =0 ; cdb_byte < cmd->cmd_len; cdb_byte++) -printk (" 0x%x" , cmd->cmnd[cdb_byte]); -printk ("\n" ); +if (cmd) { +printk ("CDB:" ); +for (cdb_byte =0 ; cdb_byte < cmd->cmd_len; cdb_byte++) +printk (" 0x%x" , cmd->cmnd[cdb_byte]); +printk ("\n" ); + }ahc_lock (ahc, &flags);
@@ -2075,7 +2078,7 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)* at all, and the system wanted us to just abort the * command, return success. */ - dev =scsi_transport_device_data (cmd->device); + dev =scsi_transport_device_data (sdev);if (dev ==NULL ) {/*
@@ -2083,13 +2086,12 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)* so we must not still own the command. */ printk ("%s:%d:%d:%d: Is not an active device\n" , -ahc_name (ahc), cmd->device->channel, cmd->device->id, - (u8 )cmd->device->lun); +ahc_name (ahc), sdev->channel, sdev->id, (u8 )sdev->lun); retval =SUCCESS ; goto no_cmd; } -if ((dev->flags & (AHC_DEV_Q_BASIC |AHC_DEV_Q_TAGGED )) ==0 +if (cmd && (dev->flags & (AHC_DEV_Q_BASIC |AHC_DEV_Q_TAGGED )) ==0 && ahc_search_untagged_queues(ahc, cmd, cmd->device->id, cmd->device->channel + 'A', (u8)cmd->device->lun,
@@ -2104,25 +2106,28 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)/* * See if we can find a matching cmd in the pending list. */ - LIST_FOREACH(pending_scb, &ahc->pending_scbs, pending_links) { -if (pending_scb->io_ctx == cmd) -break ; - } - -if (pending_scb ==NULL && flag ==SCB_DEVICE_RESET ) { - +if (cmd) { + LIST_FOREACH(scb, &ahc->pending_scbs, pending_links) { +if (scb->io_ctx == cmd) { + pending_scb = scb; +break ; + } + } + }else {/* Any SCB for this device will do for a target reset */ - LIST_FOREACH(pending_scb, &ahc->pending_scbs, pending_links) { -if (ahc_match_scb (ahc, pending_scb,scmd_id (cmd), -scmd_channel (cmd) +'A' , + LIST_FOREACH(scb, &ahc->pending_scbs, pending_links) { +if (ahc_match_scb (ahc, scb, sdev->id, + sdev->channel +'A' ,CAM_LUN_WILDCARD , -SCB_LIST_NULL ,ROLE_INITIATOR )) +SCB_LIST_NULL ,ROLE_INITIATOR )) { + pending_scb = scb;break ; + } } }if (pending_scb ==NULL ) { -scmd_printk (KERN_INFO , cmd,"Command not found\n" ); +sdev_printk (KERN_INFO , sdev,"Command not found\n" ); goto no_cmd; }
@@ -2153,22 +2158,22 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)ahc_dump_card_state (ahc); disconnected = TRUE; -if (flag ==SCB_ABORT ) { -if (ahc_search_qinfifo (ahc, cmd->device->id, - cmd->device->channel +'A' , - cmd->device->lun, +if (cmd) { +if (ahc_search_qinfifo (ahc, sdev->id, + sdev->channel +'A' , + sdev->lun, pending_scb->hscb->tag,ROLE_INITIATOR ,CAM_REQ_ABORTED ,SEARCH_COMPLETE ) >0 ) {printk ("%s:%d:%d:%d: Cmd aborted from QINFIFO\n" , -ahc_name (ahc), cmd->device->channel, - cmd->device->id, (u8 )cmd->device->lun); +ahc_name (ahc), sdev->channel, + sdev->id, (u8 )sdev->lun); retval =SUCCESS ; goto done; } - }else if (ahc_search_qinfifo (ahc, cmd->device->id, - cmd->device->channel +'A' , - cmd->device->lun, + }else if (ahc_search_qinfifo (ahc, sdev->id, + sdev->channel +'A' , + sdev->lun, pending_scb->hscb->tag,ROLE_INITIATOR ,/*status*/ 0 ,SEARCH_COUNT ) >0 ) {
@@ -2181,7 +2186,7 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag) bus_scb =ahc_lookup_scb (ahc,ahc_inb (ahc,SCB_TAG ));if (bus_scb == pending_scb) disconnected = FALSE; -else if (flag !=SCB_ABORT +else if (!cmd &&ahc_inb (ahc,SAVED_SCSIID ) == pending_scb->hscb->scsiid &&ahc_inb (ahc,SAVED_LUN ) ==SCB_GET_LUN (pending_scb)) disconnected = FALSE;
@@ -2201,18 +2206,18 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag) saved_scsiid =ahc_inb (ahc,SAVED_SCSIID );if (last_phase !=P_BUSFREE && (pending_scb->hscb->tag == active_scb_index - || (flag ==SCB_DEVICE_RESET - &&SCSIID_TARGET (ahc, saved_scsiid) ==scmd_id (cmd)))) { + || (!cmd &&SCSIID_TARGET (ahc, saved_scsiid) == sdev->id))) {/* * We're active on the bus, so assert ATN * and hope that the target responds. */ pending_scb =ahc_lookup_scb (ahc, active_scb_index); - pending_scb->flags |=SCB_RECOVERY_SCB |flag; + pending_scb->flags |=SCB_RECOVERY_SCB ; + pending_scb->flags |= cmd ?SCB_ABORT :SCB_DEVICE_RESET ;ahc_outb (ahc,MSG_OUT ,HOST_MSG );ahc_outb (ahc,SCSISIGO , last_phase|ATNO ); -scmd_printk (KERN_INFO , cmd,"Device is active, asserting ATN\n" ); +sdev_printk (KERN_INFO , sdev,"Device is active, asserting ATN\n" ); wait = TRUE; }else if (disconnected) {
@@ -2233,7 +2238,8 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)* an unsolicited reselection occurred. */ pending_scb->hscb->control |=MK_MESSAGE |DISCONNECTED ; - pending_scb->flags |=SCB_RECOVERY_SCB |flag; + pending_scb->flags |=SCB_RECOVERY_SCB ; + pending_scb->flags |= cmd ?SCB_ABORT :SCB_DEVICE_RESET ;/* * Remove any cached copy of this SCB in the
@@ -2242,9 +2248,9 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)* same element in the SCB, SCB_NEXT, for * both the qinfifo and the disconnected list. */ -ahc_search_disc_list (ahc, cmd->device->id, - cmd->device->channel +'A' , - cmd->device->lun, pending_scb->hscb->tag, +ahc_search_disc_list (ahc, sdev->id, + sdev->channel +'A' , + sdev->lun, pending_scb->hscb->tag,/*stop_on_first*/ TRUE,/*remove*/ TRUE,/*save_state*/ FALSE);
@@ -2267,9 +2273,9 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)* so we are the next SCB for this target * to run. */ -ahc_search_qinfifo (ahc, cmd->device->id, - cmd->device->channel +'A' , - cmd->device->lun,SCB_LIST_NULL , +ahc_search_qinfifo (ahc, sdev->id, + sdev->channel +'A' , + (u8 )sdev->lun,SCB_LIST_NULL ,ROLE_INITIATOR ,CAM_REQUEUE_REQ ,SEARCH_COMPLETE );ahc_qinfifo_requeue_tail (ahc, pending_scb);
@@ -2278,7 +2284,7 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)printk ("Device is disconnected, re-queuing SCB\n" ); wait = TRUE; }else { -scmd_printk (KERN_INFO , cmd,"Unable to deliver message\n" ); +sdev_printk (KERN_INFO , sdev,"Unable to deliver message\n" ); retval =FAILED ; goto done; }
Signature · 1 line
2.29.2
Hannes Reinecke
maintainerPATCH v3 15/20 aic79xx: do not reference scsi command when resetting device
In reply to Hannes ReineckeWhen sending a device reset we should not take a reference to the scsi command.
--- drivers/scsi/aic7xxx/aic79xx_osm.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/scsi/aic7xxx/aic79xx_osm.c +15 -6
@@ -536,8 +536,10 @@ ahd_linux_unmap_scb(struct ahd_softc *ahd, struct scb *scb)struct scsi_cmnd *cmd; cmd = scb->io_ctx; -ahd_sync_sglist (ahd, scb,BUS_DMASYNC_POSTWRITE ); -scsi_dma_unmap (cmd); +if (cmd) { +ahd_sync_sglist (ahd, scb,BUS_DMASYNC_POSTWRITE ); +scsi_dma_unmap (cmd); + } }/******************************** Macros **************************************/
@@ -814,7 +816,7 @@ ahd_linux_dev_reset(struct scsi_cmnd *cmd) tinfo =ahd_fetch_transinfo (ahd,'A' , ahd->our_id, cmd->device->id, &tstate); - reset_scb->io_ctx = cmd; + reset_scb->io_ctx =NULL ; reset_scb->platform_data->dev = dev; reset_scb->sg_count =0 ;ahd_set_residual (reset_scb,0 );
@@ -1769,9 +1771,16 @@ ahd_done(struct ahd_softc *ahd, struct scb *scb) dev = scb->platform_data->dev; dev->active--; dev->openings++; -if ((cmd->result & (CAM_DEV_QFRZN <<16 )) !=0 ) { - cmd->result &= ~(CAM_DEV_QFRZN <<16 ); - dev->qfrozen--; +if (cmd) { +if ((cmd->result & (CAM_DEV_QFRZN <<16 )) !=0 ) { + cmd->result &= ~(CAM_DEV_QFRZN <<16 ); + dev->qfrozen--; + } + }else if (scb->flags &SCB_DEVICE_RESET ) { +if (ahd->platform_data->eh_done) +complete (ahd->platform_data->eh_done); +ahd_free_scb (ahd, scb); +return ; }ahd_linux_unmap_scb (ahd, scb);
Signature · 1 line
2.29.2
Hannes Reinecke
maintainerPATCH v3 16/20 snic: reserve tag for TMF
In reply to Hannes ReineckeRather than re-using the failed command the snic driver should reserve one command for TMFs.
--- drivers/scsi/snic/snic.h | 2 +- drivers/scsi/snic/snic_main.c | 8 +++++++ drivers/scsi/snic/snic_scsi.c | 44 +++++++++++++++++------------------ 3 files changed, 31 insertions(+), 23 deletions(-)
drivers/scsi/snic/snic.h +1 -1
@@ -380,7 +380,7 @@ int snic_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);int snic_abort_cmd (struct scsi_cmnd *);int snic_device_reset (struct scsi_cmnd *);int snic_host_reset (struct scsi_cmnd *); -int snic_reset (struct Scsi_Host *,struct scsi_cmnd *); +int snic_reset (struct Scsi_Host *);void snic_shutdown_scsi_cleanup (struct snic *);
drivers/scsi/snic/snic_main.c +8 -0
@@ -663,6 +663,14 @@ snic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto err_get_conf; } +/* +* Hack alert: reduce can_queue by one after scsi_add_host() +* had been called. +* This essentially reserves the topmost request for TMF. +* Should be replaced by reserved command +* once support is being added. +*/ + shost->can_queue--;snic_set_state (snic,SNIC_ONLINE ); ret =snic_disc_start (snic);
drivers/scsi/snic/snic_scsi.c +22 -22
96 lines not on this page · raw message
Signature · 1 line
2.29.2
Re: [PATCH 16/20] snic: reserve tag for TMF
Quoted 30 lines · Hannes Reinecke
Rather than re-using the failed command the snic driver should reserve one command for TMFs.
Signed-off-by Hannes Reinecke <[email protected]>Reviewed-by Christoph Hellwig <[email protected]>Reviewed-by Johannes Thumshirn <[email protected]>--- drivers/scsi/snic/snic.h | 2 +- drivers/scsi/snic/snic_main.c | 8 +++++++ drivers/scsi/snic/snic_scsi.c | 44 +++++++++++++++++------------------ 3 files changed, 31 insertions(+), 23 deletions(-)drivers/scsi/snic/snic.h +1
-1@@ -380,7 +380,7 @@ int snic_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);int snic_abort_cmd (struct scsi_cmnd *);int snic_device_reset (struct scsi_cmnd *);int snic_host_reset (struct scsi_cmnd *); -int snic_reset (struct Scsi_Host *,struct scsi_cmnd *); +int snic_reset (struct Scsi_Host *);void snic_shutdown_scsi_cleanup (struct snic *);drivers/scsi/snic/snic_main.c +0
-0
drivers/scsi/snic/snic_main.c snic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 665
Quoted 3 lines
drivers/scsi/snic/snic_main.c +0
-0@@ -663,6 +663,14 @@ snic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto err_get_conf; }
Hi Hannes,
drivers/scsi/snic/snic_main.c snic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 668
Quoted 3 lines
drivers/scsi/snic/snic_main.c +3
-0+/* +* Hack alert: reduce can_queue by one after scsi_add_host() +* had been called.
I am not sure how this helps as I did not think that reducing shost->can_queue after scsi_add_host() had any effect. Maybe pre- 6eb045e092ef it did.
As an alternative interim solution, maybe you could just allocate a regular single scsi request for this TMF at init time.
drivers/scsi/snic/snic_main.c snic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 675
Quoted 7 lines
drivers/scsi/snic/snic_main.c +5
-0+* This essentially reserves the topmost request for TMF. +* Should be replaced by reserved command +* once support is being added. +*/ + shost->can_queue--;snic_set_state (snic,SNIC_ONLINE );
Thanks,
John
Hannes Reinecke
maintainerPATCH v3 17/20 snic: use dedicated device reset command
In reply to Hannes ReineckeUse a dedicated command to send a device reset instead of relying on using the command which triggered the device failure.
--- drivers/scsi/snic/snic_scsi.c | 52 ++++++++++++++++------------------- 1 file changed, 24 insertions(+), 28 deletions(-)
drivers/scsi/snic/snic_scsi.c +24 -28
@@ -2128,57 +2128,53 @@ snic_unlink_and_release_req(struct snic *snic, struct scsi_cmnd *sc, int flag)int snic_device_reset (struct scsi_cmnd *sc) { -struct Scsi_Host *shost = sc->device->host; +struct scsi_device *sdev = sc->device; +struct Scsi_Host *shost = sdev->host;struct snic *snic =shost_priv (shost);struct snic_req_info *rqi =NULL ; -int tag =snic_cmd_tag (sc);int start_time = jiffies;int ret =FAILED ;int dr_supp =0 ; -SNIC_SCSI_DBG (shost,"dev_reset:sc %p :0x%x :req = %p :tag = %d\n" , - sc, sc->cmnd[0 ],scsi_cmd_to_rq (sc), -snic_cmd_tag (sc)); - dr_supp =snic_dev_reset_supported (sc->device); +SNIC_SCSI_DBG (shost,"dev_reset\n" ); + dr_supp =snic_dev_reset_supported (sdev);if (!dr_supp) {/* device reset op is not supported */ SNIC_HOST_INFO (shost,"LUN Reset Op not supported.\n" ); -snic_unlink_and_release_req (snic, sc,SNIC_DEV_RST_NOTSUP ); - goto dev_rst_end; }if (unlikely (snic_get_state (snic) !=SNIC_ONLINE )) { -snic_unlink_and_release_req (snic, sc,0 );SNIC_HOST_ERR (shost,"Devrst: Parent Devs are not online.\n" ); goto dev_rst_end; } -/* There is no tag when lun reset is issue through ioctl. */ -if (unlikely (tag <=SNIC_NO_TAG )) { -SNIC_HOST_INFO (snic->shost, -"Devrst: LUN Reset Recvd thru IOCTL.\n" ); - - rqi =snic_req_init (snic,0 ); -if (!rqi) - goto dev_rst_end; - -memset (scsi_cmd_priv (sc),0 , -sizeof (struct snic_internal_io_state )); -CMD_SP (sc) = (char *)rqi; -CMD_FLAGS (sc) =SNIC_NO_FLAGS ; + rqi =snic_req_init (snic,0 ); +if (!rqi) + goto dev_rst_end; -/* Add special tag for dr coming from user spc */ - rqi->tm_tag =SNIC_TAG_IOCTL_DEV_RST ; - rqi->sc = sc; +/* The last tag is reserved for TMF */ + sc =scsi_host_find_tag (snic->shost, snic->max_tag_id -1 ); +if (!sc ||CMD_SP (sc)) { +SNIC_HOST_ERR (snic->shost, +"Devrst: TMF busy\n" ); + goto dev_rst_end; } +memset (scsi_cmd_priv (sc),0 , +sizeof (struct snic_internal_io_state )); +CMD_SP (sc) = (char *)rqi; +CMD_FLAGS (sc) =SNIC_NO_FLAGS ; + +/* Add special tag for dr coming from user spc */ + rqi->tm_tag =SNIC_TAG_IOCTL_DEV_RST ; + rqi->sc = sc; ret =snic_send_dr_and_wait (snic, sc);if (ret) {SNIC_HOST_ERR (snic->shost,"Devrst: IO w/ Tag %x Failed w/ err = %d\n" , - tag, ret); +snic_cmd_tag (sc), ret);snic_unlink_and_release_req (snic, sc,0 );
@@ -2188,7 +2184,7 @@ snic_device_reset(struct scsi_cmnd *sc) ret =snic_dr_finish (snic, sc); dev_rst_end: -SNIC_TRC (snic->shost->host_no, tag, (ulong ) sc, +SNIC_TRC (snic->shost->host_no,snic_cmd_tag (sc), (ulong ) sc,jiffies_to_msecs (jiffies - start_time),0 ,SNIC_TRC_CMD (sc),SNIC_TRC_CMD_STATE_FLAGS (sc));
@@ -2333,7 +2329,7 @@ snic_reset(struct Scsi_Host *shost)/* The topmost command is reserved for TMF */ sc =scsi_host_find_tag (shost, snic->max_tag_id -1 ); -if (!sc) { +if (!sc ||CMD_SP (sc)) {SNIC_HOST_ERR (shost,"reset:Host Reset Failed to allocate sc.\n" );spin_lock_irqsave (&snic->snic_lock, flags);
Signature · 1 line
2.29.2
Hannes Reinecke
maintainerPATCH v3 18/20 snic: Use scsi_host_busy_iter() to traverse commands
In reply to Hannes ReineckeUse scsi_host_busy_iter() to traverse commands instead of hand-crafted routines walking the command list.
--- drivers/scsi/snic/snic_scsi.c | 177 ++++++++++++++++------------------ 1 file changed, 84 insertions(+), 93 deletions(-)
drivers/scsi/snic/snic_scsi.c +84 -93
@@ -77,7 +77,7 @@ static const char * const snic_io_status_str[] = { [SNIC_STAT_FATAL_ERROR] = "SNIC_STAT_FATAL_ERROR", }; -static void snic_scsi_cleanup (struct snic *,int ); +static void snic_scsi_cleanup (struct snic *);const char *snic_state_to_str (unsigned int state)
@@ -977,7 +977,7 @@ snic_hba_reset_scsi_cleanup(struct snic *snic, struct scsi_cmnd *sc)long act_ios =0 , act_fwreqs =0 ;SNIC_SCSI_DBG (snic->shost,"HBA Reset scsi cleanup.\n" ); -snic_scsi_cleanup (snic,snic_cmd_tag (sc)); +snic_scsi_cleanup (snic);/* Update stats on pending IOs */ act_ios =atomic64_read (&st->io.active);
@@ -2421,53 +2421,36 @@ snic_cmpl_pending_tmreq(struct snic *snic, struct scsi_cmnd *sc)complete (rqi->abts_done); } -/* -* snic_scsi_cleanup: Walks through tag map and releases the reqs -*/ -static void -snic_scsi_cleanup (struct snic *snic,int ex_tag) +static bool +snic_scsi_cleanup_iter (struct scsi_cmnd *sc,void *data,bool reserved) { +struct snic *snic = data;struct snic_req_info *rqi =NULL ; -struct scsi_cmnd *sc =NULL ;spinlock_t *io_lock =NULL ;unsigned long flags; -int tag; +int tag =scsi_cmd_to_rq (sc)->tag;u64 st_time =0 ;SNIC_SCSI_DBG (snic->shost,"sc_clean: scsi cleanup.\n" ); -for (tag =0 ; tag < snic->max_tag_id; tag++) { -/* Skip ex_tag */ -if (tag == ex_tag) -continue ; - - io_lock =snic_io_lock_tag (snic, tag); -spin_lock_irqsave (io_lock, flags); - sc =scsi_host_find_tag (snic->shost, tag); -if (!sc) { -spin_unlock_irqrestore (io_lock, flags); - -continue ; - } - -if (unlikely (snic_tmreq_pending (sc))) { -/* -* When FW Completes reset w/o sending completions -* for outstanding ios. -*/ -snic_cmpl_pending_tmreq (snic, sc); -spin_unlock_irqrestore (io_lock, flags); - -continue ; - } + io_lock =snic_io_lock_tag (snic, tag); +spin_lock_irqsave (io_lock, flags); - rqi = (struct snic_req_info *)CMD_SP (sc); -if (!rqi) { -spin_unlock_irqrestore (io_lock, flags); +if (unlikely (snic_tmreq_pending (sc))) { +/* +* When FW Completes reset w/o sending completions +* for outstanding ios. +*/ +snic_cmpl_pending_tmreq (snic, sc); +spin_unlock_irqrestore (io_lock, flags); - goto cleanup; - } +return true; + } + rqi = (struct snic_req_info *)CMD_SP (sc); +if (!rqi) +spin_unlock_irqrestore (io_lock, flags); +else {SNIC_SCSI_DBG (snic->shost,"sc_clean: sc %p, rqi %p, tag %d flags 0x%llx\n" , sc, rqi, tag,CMD_FLAGS (sc));
@@ -2482,24 +2465,34 @@ snic_scsi_cleanup(struct snic *snic, int ex_tag) rqi, CMD_FLAGS(sc));snic_release_req_buf (snic, rqi, sc); + } + sc->result =DID_TRANSPORT_DISRUPTED <<16 ; +SNIC_HOST_INFO (snic->shost, +"sc_clean: DID_TRANSPORT_DISRUPTED for sc %p, Tag %d flags 0x%llx rqi %p duration %u msecs\n" , + sc, tag,CMD_FLAGS (sc), rqi, +jiffies_to_msecs (jiffies - st_time)); -cleanup: - sc->result =DID_TRANSPORT_DISRUPTED <<16 ; -SNIC_HOST_INFO (snic->shost, -"sc_clean: DID_TRANSPORT_DISRUPTED for sc %p, Tag %d flags 0x%llx rqi %p duration %u msecs\n" , - sc,scsi_cmd_to_rq (sc)->tag,CMD_FLAGS (sc), rqi, -jiffies_to_msecs (jiffies - st_time)); +/* Update IO stats */ +snic_stats_update_io_cmpl (&snic->s_stats); -/* Update IO stats */ -snic_stats_update_io_cmpl (&snic->s_stats); +SNIC_TRC (snic->shost->host_no, tag, (ulong ) sc, +jiffies_to_msecs (jiffies - st_time),0 , +SNIC_TRC_CMD (sc), +SNIC_TRC_CMD_STATE_FLAGS (sc)); -SNIC_TRC (snic->shost->host_no, tag, (ulong ) sc, -jiffies_to_msecs (jiffies - st_time),0 , -SNIC_TRC_CMD (sc), -SNIC_TRC_CMD_STATE_FLAGS (sc)); +scsi_done (sc); +return true; +} -scsi_done (sc); - } +/* +* snic_scsi_cleanup: Walks through tag map and releases the reqs +*/ +static void +snic_scsi_cleanup (struct snic *snic) +{ +SNIC_SCSI_DBG (snic->shost,"sc_clean: scsi cleanup\n" ); + +scsi_host_busy_iter (snic->shost, snic_scsi_cleanup_iter, snic); }/* end of snic_scsi_cleanup */ void
@@ -2507,7 +2500,7 @@ snic_shutdown_scsi_cleanup(struct snic *snic) {SNIC_HOST_INFO (snic->shost,"Shutdown time SCSI Cleanup.\n" ); -snic_scsi_cleanup (snic,SCSI_NO_TAG ); +snic_scsi_cleanup (snic); }/* end of snic_shutdown_scsi_cleanup */ /*
@@ -2521,7 +2514,7 @@ snic_internal_abort_io(struct snic *snic, struct scsi_cmnd *sc, int tmf)spinlock_t *io_lock =NULL ;unsigned long flags;u32 sv_state =0 ; -int ret =0 ; +int ret =FAILED ; io_lock =snic_io_lock_hash (snic, sc);spin_lock_irqsave (io_lock, flags);
@@ -2596,6 +2589,35 @@ snic_internal_abort_io(struct snic *snic, struct scsi_cmnd *sc, int tmf)return ret; }/* end of snic_internal_abort_io */ +struct snic_tgt_scsi_abort_io_data { +struct snic *snic; +struct snic_tgt *tgt; +int tmf; +int abt_cnt; +}; + +static bool snic_tgt_scsi_abort_io_iter (struct scsi_cmnd *sc,void *data, +bool reserved) +{ +struct snic_tgt_scsi_abort_io_data *iter_data = data; +struct snic *snic = iter_data->snic; +struct snic_tgt *sc_tgt; +int ret; + + sc_tgt =starget_to_tgt (scsi_target (sc->device)); +if (sc_tgt != iter_data->tgt) +return true; + + ret =snic_internal_abort_io (snic, sc, iter_data->tmf); +if (ret ==SUCCESS ) + iter_data->abt_cnt++; +else +SNIC_HOST_ERR (snic->shost, +"tgt_abt_io: Tag %x, Failed w err = %d\n" , +scsi_cmd_to_rq (sc)->tag, ret); +return true; +} +/* * snic_tgt_scsi_abort_io : called by snic_tgt_del */
@@ -2603,11 +2625,9 @@ int snic_tgt_scsi_abort_io(struct snic_tgt *tgt) {struct snic *snic =NULL ; -struct scsi_cmnd *sc =NULL ; -struct snic_tgt *sc_tgt =NULL ; -spinlock_t *io_lock =NULL ; -unsigned long flags; -int ret =0 , tag, abt_cnt =0 , tmf =0 ; +struct snic_tgt_scsi_abort_io_data data = { + .abt_cnt =0 , + };if (!tgt)return -1 ;
@@ -2615,44 +2635,15 @@ snic_tgt_scsi_abort_io(struct snic_tgt *tgt) snic =shost_priv (snic_tgt_to_shost (tgt));SNIC_SCSI_DBG (snic->shost,"tgt_abt_io: Cleaning Pending IOs.\n" ); + data.snic = snic;if (tgt->tdata.typ ==SNIC_TGT_DAS ) - tmf =SNIC_ITMF_ABTS_TASK ; + data.tmf =SNIC_ITMF_ABTS_TASK ;else - tmf =SNIC_ITMF_ABTS_TASK_TERM ; - -for (tag =0 ; tag < snic->max_tag_id; tag++) { - io_lock =snic_io_lock_tag (snic, tag); - -spin_lock_irqsave (io_lock, flags); - sc =scsi_host_find_tag (snic->shost, tag); -if (!sc) { -spin_unlock_irqrestore (io_lock, flags); - -continue ; - } + data.tmf =SNIC_ITMF_ABTS_TASK_TERM ; - sc_tgt =starget_to_tgt (scsi_target (sc->device)); -if (sc_tgt != tgt) { -spin_unlock_irqrestore (io_lock, flags); - -continue ; - } -spin_unlock_irqrestore (io_lock, flags); - - ret =snic_internal_abort_io (snic, sc, tmf); -if (ret <0 ) { -SNIC_HOST_ERR (snic->shost, -"tgt_abt_io: Tag %x, Failed w err = %d\n" , - tag, ret); - -continue ; - } - -if (ret ==SUCCESS ) - abt_cnt++; - } +scsi_host_busy_iter (snic->shost, snic_tgt_scsi_abort_io_iter, &data); -SNIC_SCSI_DBG (snic->shost,"tgt_abt_io: abt_cnt = %d\n" , abt_cnt); +SNIC_SCSI_DBG (snic->shost,"tgt_abt_io: abt_cnt = %d\n" , data.abt_cnt);return 0 ; }/* end of snic_tgt_scsi_abort_io */
Signature · 1 line
2.29.2
Hannes Reinecke
maintainerPATCH v3 19/20 ips: Do not try to abort command from host reset
In reply to Hannes ReineckeThe code for aborting an outstanding command is a copy of the functionality from command abort. As we already have called this function once we reach host reset there's no point in trying to do so again.
--- drivers/scsi/ips.c | 18 ------------------ 1 file changed, 18 deletions(-)
drivers/scsi/ips.c +0 -18
@@ -835,7 +835,6 @@ static int __ips_eh_reset(struct scsi_cmnd *SC)int i;ips_ha_t *ha;ips_scb_t *scb; -ips_copp_wait_item_t *item;METHOD_TRACE ("ips_eh_reset" ,1 );
@@ -860,23 +859,6 @@ static int __ips_eh_reset(struct scsi_cmnd *SC)if (!ha->active)return (FAILED ); -/* See if the command is on the copp queue */ - item = ha->copp_waitlist.head; -while ((item) && (item->scsi_cmd !=SC )) - item = item->next; - -if (item) { -/* Found it */ -ips_removeq_copp (&ha->copp_waitlist, item); -return (SUCCESS ); - } - -/* See if the command is on the wait queue */ -if (ips_removeq_wait (&ha->scb_waitlist,SC )) { -/* command not sent yet */ -return (SUCCESS ); - } -/* An explanation for the casual observer: */ /* Part of the function of a RAID controller is automatic error */ /* detection and recovery. As such, the only problem that physically */
Signature · 1 line
2.29.2
Hannes Reinecke
maintainerPATCH v3 20/20 megaraid: pass in NULL scb for host reset
In reply to Hannes ReineckeWhen calling a host reset we shouldn't rely on the command triggering the reset, so allow megaraid_abort_and_reset() to be called with a NULL scb.
And drop the pointless 'bus_reset' and 'target_reset' handlers, which just call the same function as host_reset.
--- drivers/scsi/megaraid.c | 42 ++++++++++++++++------------------------- 1 file changed, 16 insertions(+), 26 deletions(-)
drivers/scsi/megaraid.c +16 -26
@@ -1897,7 +1897,7 @@ megaraid_reset(struct scsi_cmnd *cmd)spin_lock_irq (&adapter->lock); - rval =megaraid_abort_and_reset (adapter, cmd,SCB_RESET ); + rval =megaraid_abort_and_reset (adapter,NULL ,SCB_RESET );/* * This is required here to complete any completed requests
@@ -1936,7 +1936,7 @@ megaraid_abort_and_reset(adapter_t *adapter, struct scsi_cmnd *cmd, int aor) scb =list_entry (pos, scb_t, list); -if (scb->cmd == cmd) {/* Found command */ +if (!cmd || scb->cmd == cmd) {/* Found command */ scb->state |= aor;
@@ -1955,31 +1955,23 @@ megaraid_abort_and_reset(adapter_t *adapter, struct scsi_cmnd *cmd, int aor)return FAILED ; } -else { - -/* -* Not yet issued! Remove from the pending -* list -*/ -dev_warn (&adapter->dev->dev, -"%s-[%x], driver owner\n" , - (aor==SCB_ABORT ) ?"ABORTING" :"RESET" , - scb->idx); - -mega_free_scb (adapter, scb); - -if ( aor ==SCB_ABORT ) { - cmd->result = (DID_ABORT <<16 ); - } -else { - cmd->result = (DID_RESET <<16 ); - } +/* +* Not yet issued! Remove from the pending +* list +*/ +dev_warn (&adapter->dev->dev, +"%s-[%x], driver owner\n" , + (cmd) ?"ABORTING" :"RESET" , + scb->idx); +mega_free_scb (adapter, scb); +if (cmd) { + cmd->result = (DID_ABORT <<16 );list_add_tail (SCSI_LIST (cmd), - &adapter->completed_list); - -return SUCCESS ; + &adapter->completed_list); } + +return SUCCESS ; } }
@@ -4113,8 +4105,6 @@ static struct scsi_host_template megaraid_template = { .sg_tablesize = MAX_SGLIST, .cmd_per_lun = DEF_CMD_PER_LUN, .eh_abort_handler = megaraid_abort, - .eh_device_reset_handler = megaraid_reset, - .eh_bus_reset_handler = megaraid_reset, .eh_host_reset_handler = megaraid_reset, .no_write_same = 1, .cmd_size = sizeof(struct megaraid_cmd_priv),
Signature · 1 line
2.29.2