scsi: EH rework prep patches, part 2
Subsystems (11)
cover scsi: EH rework prep patches, part 2
Hi all,
here's the second 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_target' resp 'struct scsi_device' as argument for the EH callbacks becomes possible.
As usual, comments and reviews are welcome.
Hannes Reinecke (11):
pmcraid: Select device in pmcraid_eh_bus_reset_handler()
sym53c8xx_2: rework reset handling
libiscsi: use cls_session as argument for target and session reset
scsi_transport_iscsi: use session as argument for
iscsi_block_scsi_eh()
pmcraid: select first available device for target reset
bfa: Do not use scsi command to signal TMF status
aha152x: look for stuck command when resetting device
a1000u2w: do not rely on the command for inia100_device_reset()
xen-scsifront: add scsi device as argument to scsifront_do_request()
fas216: Rework device reset to not rely on SCSI command pointer
csiostor: use separate TMF command
drivers/scsi/a100u2w.c | 43 +++-------- drivers/scsi/aha152x.c | 26 ++++--- drivers/scsi/arm/fas216.c | 39 +++++----- drivers/scsi/be2iscsi/be_main.c | 10 ++- drivers/scsi/bfa/bfad_im.c | 112 +++++++++++++++------------- drivers/scsi/bfa/bfad_im.h | 2 + drivers/scsi/csiostor/csio_hw.h | 2 + drivers/scsi/csiostor/csio_init.c | 2 +- drivers/scsi/csiostor/csio_scsi.c | 48 +++++++----- drivers/scsi/libiscsi.c | 21 +++--- drivers/scsi/pmcraid.c | 60 ++++++++++++--- drivers/scsi/qla4xxx/ql4_os.c | 34 +++++---- drivers/scsi/scsi_transport_iscsi.c | 6 +- drivers/scsi/sym53c8xx_2/sym_glue.c | 82 +++++++++++++------- drivers/scsi/xen-scsifront.c | 31 +++++--- include/scsi/libiscsi.h | 2 +- include/scsi/scsi_transport_iscsi.h | 2 +- 17 files changed, 310 insertions(+), 212 deletions(-)
Signature · 1 line
2.29.2
PATCH 1/11 pmcraid: Select device in pmcraid_eh_bus_reset_handler()
The reset code requires a device to be selected, but we shouldn't rely on the command to provide a device for us. So select the first device on the bus when sending down a bus reset.
--- drivers/scsi/pmcraid.c | 46 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-)
drivers/scsi/pmcraid.c +38 -8
@@ -2691,7 +2691,7 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)* SUCCESS / FAILED */ static int pmcraid_reset_device ( -struct scsi_cmnd *scsi_cmd, +struct scsi_device *scsi_dev,unsigned long timeout,u8 modifier) {
@@ -2703,11 +2703,11 @@ static int pmcraid_reset_device(u32 ioasc; pinstance = - (struct pmcraid_instance *)scsi_cmd->device->host->hostdata; - res = scsi_cmd->device->hostdata; + (struct pmcraid_instance *)scsi_dev->host->hostdata; + res = scsi_dev->hostdata;if (!res) { -sdev_printk (KERN_ERR , scsi_cmd->device, +sdev_printk (KERN_ERR , scsi_dev,"reset_device: NULL resource pointer\n" );return FAILED ; }
@@ -3018,16 +3018,46 @@ static int pmcraid_eh_device_reset_handler(struct scsi_cmnd *scmd) {scmd_printk (KERN_INFO , scmd,"resetting device due to an I/O command timeout.\n" ); -return pmcraid_reset_device (scmd, +return pmcraid_reset_device (scmd->device,PMCRAID_INTERNAL_TIMEOUT ,RESET_DEVICE_LUN ); }static int pmcraid_eh_bus_reset_handler (struct scsi_cmnd *scmd) { -scmd_printk (KERN_INFO , scmd, +struct Scsi_Host *host = scmd->device->host; +struct pmcraid_instance *pinstance = + (struct pmcraid_instance *)host->hostdata; +struct pmcraid_resource_entry *res =NULL ; +struct pmcraid_resource_entry *temp; +struct scsi_device *sdev =NULL ; +unsigned long lock_flags; + +/* +* The reset device code insists on us passing down +* a device, so grab the first device on the bus. +*/ +spin_lock_irqsave (&pinstance->resource_lock, lock_flags); +list_for_each_entry (temp, &pinstance->used_res_q, queue) { +if (scmd->device->channel ==PMCRAID_VSET_BUS_ID && +RES_IS_VSET (temp->cfg_entry)) { + res = temp; +break ; + }else if (scmd->device->channel ==PMCRAID_PHYS_BUS_ID && +RES_IS_GSCSI (temp->cfg_entry)) { + res = temp; +break ; + } + } +if (res) + sdev = res->scsi_dev; +spin_unlock_irqrestore (&pinstance->resource_lock, lock_flags); +if (!sdev) +return FAILED ; + +sdev_printk (KERN_INFO , sdev,"Doing bus reset due to an I/O command timeout.\n" ); -return pmcraid_reset_device (scmd, +return pmcraid_reset_device (sdev,PMCRAID_RESET_BUS_TIMEOUT ,RESET_DEVICE_BUS ); }
@@ -3036,7 +3066,7 @@ static int pmcraid_eh_target_reset_handler(struct scsi_cmnd *scmd) {scmd_printk (KERN_INFO , scmd,"Doing target reset due to an I/O command timeout.\n" ); -return pmcraid_reset_device (scmd, +return pmcraid_reset_device (scmd->device,PMCRAID_INTERNAL_TIMEOUT ,RESET_DEVICE_TARGET ); }
Signature · 1 line
2.29.2
Re: [PATCH 01/11] pmcraid: Select device in pmcraid_eh_bus_reset_handler()
Looks good:
Re: [PATCH 01/11] pmcraid: Select device in pmcraid_eh_bus_reset_handler()
In reply to Hannes ReineckeQuoted 1 line · Hannes Reinecke
The reset code requires a device to be selected, but we shouldn't
^^^^^^^^^^^^
Quoted 2 lines
rely on the command to provide a device for us. So select the first device on the bus when sending down a bus reset.
Why is it that we shouldn't rely on the SCSI EH to provide a device? I think this should be explained in the commit message.
Thanks,
Bart.
Re: [PATCH 01/11] pmcraid: Select device in pmcraid_eh_bus_reset_handler()
Quoted 7 lines · Bart Van Assche
Quoted 1 line · Hannes Reinecke
The reset code requires a device to be selected, but we shouldn't
^^^^^^^^^^^^
Quoted 2 lines
rely on the command to provide a device for us. So select the first device on the bus when sending down a bus reset.
Why is it that we shouldn't rely on the SCSI EH to provide a device? I think this should be explained in the commit message.
Scope.
We should rely on the _device_, we should rely on the _bus_.
Cheers,
Hannes
Signature · 4 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: Felix Imendörffer
PATCH 2/11 sym53c8xx_2: rework reset handling
In reply to Hannes ReineckeSplit off the combined abort and device reset handling into distinct functions.
And the current device reset handler really is a target reset, so rename it.
--- drivers/scsi/sym53c8xx_2/sym_glue.c | 82 +++++++++++++++++++---------- 1 file changed, 55 insertions(+), 27 deletions(-)
drivers/scsi/sym53c8xx_2/sym_glue.c +55 -27
@@ -564,7 +564,10 @@ static void sym53c8xx_timer(struct timer_list *t)* Generic method for our eh processing. * The 'op' argument tells what we have to do. */ -static int sym_eh_handler (int op,char *opname,struct scsi_cmnd *cmd) +/* +* Error handlers called from the eh thread (one thread per HBA). +*/ +static int sym53c8xx_eh_abort_handler (struct scsi_cmnd *cmd) {struct sym_ucmd *ucmd =SYM_UCMD_PTR (cmd);struct Scsi_Host *shost = cmd->device->host;
@@ -576,7 +579,7 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd)int sts =-1 ;struct completion eh_done; -scmd_printk (KERN_WARNING , cmd,"%s operation started\n" , opname); +scmd_printk (KERN_WARNING , cmd,"ABORT operation started\n" );/* * Escalate to host reset if the PCI bus went down
@@ -594,19 +597,7 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd) } } -/* Try to proceed the operation we have been asked for */ - sts =-1 ; -switch (op) { -case SYM_EH_ABORT : - sts =sym_abort_scsiio (np, cmd,1 ); -break ; -case SYM_EH_DEVICE_RESET : - sts =sym_reset_scsi_target (np, cmd->device->id); -break ; -default : -break ; - } - + sts =sym_abort_scsiio (np, cmd,1 );/* On error, restore everything and cross fingers :) */ if (sts) cmd_queued =0 ;
@@ -623,23 +614,60 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd)spin_unlock_irq (shost->host_lock); } -dev_warn (&cmd->device->sdev_gendev,"%s operation %s.\n" , opname, +dev_warn (&cmd->device->sdev_gendev,"ABORT operation %s.\n" , sts==0 ?"complete" :sts==-2 ?"timed-out" :"failed" );return sts ?SCSI_FAILED :SCSI_SUCCESS ; } - -/* -* Error handlers called from the eh thread (one thread per HBA). -*/ -static int sym53c8xx_eh_abort_handler (struct scsi_cmnd *cmd) +static int sym53c8xx_eh_target_reset_handler (struct scsi_cmnd *cmd) { -return sym_eh_handler (SYM_EH_ABORT ,"ABORT" , cmd); -} +struct scsi_target *starget =scsi_target (cmd->device); +struct Scsi_Host *shost =dev_to_shost (starget->dev.parent); +struct sym_data *sym_data =shost_priv (shost); +struct pci_dev *pdev = sym_data->pdev; +struct sym_hcb *np = sym_data->ncb; +SYM_QUEHEAD *qp; +int sts; +struct completion eh_done; -static int sym53c8xx_eh_device_reset_handler (struct scsi_cmnd *cmd) -{ -return sym_eh_handler (SYM_EH_DEVICE_RESET ,"DEVICE RESET" , cmd); +starget_printk (KERN_WARNING , starget, +"TARGET RESET operation started\n" ); + +/* +* Escalate to host reset if the PCI bus went down +*/ +if (pci_channel_offline (pdev)) +return SCSI_FAILED ; + +spin_lock_irq (shost->host_lock); + sts =sym_reset_scsi_target (np, starget->id); +if (!sts) { + FOR_EACH_QUEUED_ELEMENT(&np->busy_ccbq, qp) { + struct sym_ccb *cp = sym_que_entry(qp, struct sym_ccb, + link_ccbq); +struct scsi_cmnd *cmd = cp->cmd; +struct sym_ucmd *ucmd; + +if (!cmd || cmd->device->channel != starget->channel || + cmd->device->id != starget->id) +continue ; + + ucmd =SYM_UCMD_PTR (cmd); +init_completion (&eh_done); + ucmd->eh_done = &eh_done; +spin_unlock_irq (shost->host_lock); +if (!wait_for_completion_timeout (&eh_done,5 *HZ )) { + ucmd->eh_done =NULL ; + sts =-2 ; + } +spin_lock_irq (shost->host_lock); + } + } +spin_unlock_irq (shost->host_lock); + +starget_printk (KERN_WARNING , starget,"TARGET RESET operation %s.\n" , + sts==0 ?"complete" :sts==-2 ?"timed-out" :"failed" ); +return SCSI_SUCCESS ; }static int sym53c8xx_eh_bus_reset_handler (struct scsi_cmnd *cmd)
@@ -1660,7 +1688,7 @@ static struct scsi_host_template sym2_template = { .slave_configure = sym53c8xx_slave_configure, .slave_destroy = sym53c8xx_slave_destroy, .eh_abort_handler = sym53c8xx_eh_abort_handler, - .eh_device_reset_handler = sym53c8xx_eh_device_reset_handler, + .eh_target_reset_handler = sym53c8xx_eh_target_reset_handler, .eh_bus_reset_handler = sym53c8xx_eh_bus_reset_handler, .eh_host_reset_handler = sym53c8xx_eh_host_reset_handler, .this_id = 7,
Signature · 1 line
2.29.2
Re: [PATCH 02/11] sym53c8xx_2: rework reset handling
Looks good:
PATCH 3/11 libiscsi: use cls_session as argument for target and session reset
In reply to Hannes Reineckeiscsi_eh_target_reset() and iscsi_eh_session_reset() only depend on the cls_session, so use that as an argument.
--- drivers/scsi/be2iscsi/be_main.c | 10 +++++++++- drivers/scsi/libiscsi.c | 21 +++++++++------------ include/scsi/libiscsi.h | 2 +- 3 files changed, 19 insertions(+), 14 deletions(-)
drivers/scsi/be2iscsi/be_main.c +9 -1
@@ -370,6 +370,14 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)return rc; } +static int beiscsi_eh_session_reset (struct scsi_cmnd *sc) +{ +struct iscsi_cls_session *cls_session; + + cls_session =starget_to_session (scsi_target (sc->device)); +return iscsi_eh_session_reset (cls_session); +} +/*------------------- PCI Driver operations and data ----------------- */ static const struct pci_device_id beiscsi_pci_id_table[] = { {PCI_DEVICE (BE_VENDOR_ID ,BE_DEVICE_ID1 ) },
@@ -393,7 +401,7 @@ static struct scsi_host_template beiscsi_sht = { .eh_timed_out = iscsi_eh_cmd_timed_out, .eh_abort_handler = beiscsi_eh_abort, .eh_device_reset_handler = beiscsi_eh_device_reset, - .eh_target_reset_handler = iscsi_eh_session_reset, + .eh_target_reset_handler = beiscsi_eh_session_reset, .shost_groups = beiscsi_groups, .sg_tablesize = BEISCSI_SGLIST_ELEMENTS, .can_queue = BE2_IO_DEPTH,
drivers/scsi/libiscsi.c +9 -12
@@ -2494,13 +2494,11 @@ EXPORT_SYMBOL_GPL(iscsi_session_recovery_timedout);* This function will wait for a relogin, session termination from * userspace, or a recovery/replacement timeout. */ -int iscsi_eh_session_reset (struct scsi_cmnd *sc) +int iscsi_eh_session_reset (struct iscsi_cls_session *cls_session) { -struct iscsi_cls_session *cls_session;struct iscsi_session *session;struct iscsi_conn *conn; - cls_session =starget_to_session (scsi_target (sc->device)); session = cls_session->dd_data;mutex_lock (&session->eh_mutex);
@@ -2547,7 +2545,7 @@ int iscsi_eh_session_reset(struct scsi_cmnd *sc) }EXPORT_SYMBOL_GPL (iscsi_eh_session_reset); -static void iscsi_prep_tgt_reset_pdu (struct scsi_cmnd *sc,struct iscsi_tm *hdr) +static void iscsi_prep_tgt_reset_pdu (struct iscsi_tm *hdr) {memset (hdr,0 ,sizeof (*hdr)); hdr->opcode =ISCSI_OP_SCSI_TMFUNC |ISCSI_OP_IMMEDIATE ;
@@ -2562,19 +2560,16 @@ static void iscsi_prep_tgt_reset_pdu(struct scsi_cmnd *sc, struct iscsi_tm *hdr)* * This will attempt to send a warm target reset. */ -static int iscsi_eh_target_reset (struct scsi_cmnd *sc) +static int iscsi_eh_target_reset (struct iscsi_cls_session *cls_session) { -struct iscsi_cls_session *cls_session;struct iscsi_session *session;struct iscsi_conn *conn;struct iscsi_tm *hdr;int rc =FAILED ; - cls_session =starget_to_session (scsi_target (sc->device)); session = cls_session->dd_data; -ISCSI_DBG_EH (session,"tgt Reset [sc %p tgt %s]\n" , sc, - session->targetname); +ISCSI_DBG_EH (session,"tgt Reset [tgt %s]\n" , session->targetname);mutex_lock (&session->eh_mutex);spin_lock_bh (&session->frwd_lock);
@@ -2592,7 +2587,7 @@ static int iscsi_eh_target_reset(struct scsi_cmnd *sc) session->tmf_state =TMF_QUEUED ; hdr = &session->tmhdr; -iscsi_prep_tgt_reset_pdu (sc, hdr); +iscsi_prep_tgt_reset_pdu (hdr);if (iscsi_exec_task_mgmt_fn (conn, hdr, session->age, session->tgt_reset_timeout)) {
@@ -2644,11 +2639,13 @@ static int iscsi_eh_target_reset(struct scsi_cmnd *sc)*/ int iscsi_eh_recover_target (struct scsi_cmnd *sc) { +struct iscsi_cls_session *cls_session;int rc; - rc =iscsi_eh_target_reset (sc); + cls_session =starget_to_session (scsi_target (sc->device)); + rc =iscsi_eh_target_reset (cls_session);if (rc ==FAILED ) - rc =iscsi_eh_session_reset (sc); + rc =iscsi_eh_session_reset (cls_session);return rc; }EXPORT_SYMBOL_GPL (iscsi_eh_recover_target);
include/scsi/libiscsi.h +1 -1
@@ -391,7 +391,7 @@ struct iscsi_host {*/ extern int iscsi_eh_abort (struct scsi_cmnd *sc);extern int iscsi_eh_recover_target (struct scsi_cmnd *sc); -extern int iscsi_eh_session_reset (struct scsi_cmnd *sc); +extern int iscsi_eh_session_reset (struct iscsi_cls_session *cls_session);extern int iscsi_eh_device_reset (struct scsi_cmnd *sc);extern int iscsi_queuecommand (struct Scsi_Host *host,struct scsi_cmnd *sc);extern enum blk_eh_timer_return iscsi_eh_cmd_timed_out (struct scsi_cmnd *sc);
Signature · 1 line
2.29.2
Re: [PATCH 03/11] libiscsi: use cls_session as argument for target and session reset
Looks good:
PATCH 4/11 scsi_transport_iscsi: use session as argument for iscsi_block_scsi_eh()
In reply to Hannes ReineckeWe should be passing in the session directly instead of deriving it from the scsi command.
--- drivers/scsi/qla4xxx/ql4_os.c | 34 ++++++++++++++++++----------- drivers/scsi/scsi_transport_iscsi.c | 6 ++--- include/scsi/scsi_transport_iscsi.h | 2 +- 3 files changed, 24 insertions(+), 18 deletions(-)
drivers/scsi/qla4xxx/ql4_os.c +21 -13
@@ -9262,15 +9262,18 @@ static int qla4xxx_eh_abort(struct scsi_cmnd *cmd)**/ static int qla4xxx_eh_device_reset (struct scsi_cmnd *cmd) { -struct scsi_qla_host *ha =to_qla_host (cmd->device->host); -struct ddb_entry *ddb_entry = cmd->device->hostdata; +struct scsi_device *sdev = cmd->device; +struct scsi_qla_host *ha =to_qla_host (sdev->host); +struct iscsi_cls_session *session; +struct ddb_entry *ddb_entry = sdev->hostdata;int ret =FAILED , stat;int rval;if (!ddb_entry)return ret; - ret =iscsi_block_scsi_eh (cmd); + session =starget_to_session (scsi_target (sdev)); + ret =iscsi_block_scsi_eh (session);if (ret)return ret; ret =FAILED ;
@@ -9331,19 +9334,25 @@ static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd)**/ static int qla4xxx_eh_target_reset (struct scsi_cmnd *cmd) { -struct scsi_qla_host *ha =to_qla_host (cmd->device->host); -struct ddb_entry *ddb_entry = cmd->device->hostdata; +struct scsi_target *starget =scsi_target (cmd->device); +struct iscsi_cls_session *cls_session =starget_to_session (starget); +struct iscsi_session *sess; +struct scsi_qla_host *ha; +struct ddb_entry *ddb_entry;int stat, ret;int rval; + sess = cls_session->dd_data; + ddb_entry = sess->dd_data;if (!ddb_entry)return FAILED ; + ha = ddb_entry->ha; - ret =iscsi_block_scsi_eh (cmd); + ret =iscsi_block_scsi_eh (cls_session);if (ret)return ret; -starget_printk (KERN_INFO ,scsi_target (cmd->device), +starget_printk (KERN_INFO , starget,"WARM TARGET RESET ISSUED.\n" ); DEBUG2(printk(KERN_INFO
@@ -9360,14 +9369,13 @@ static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd) stat =qla4xxx_reset_target (ha, ddb_entry);if (stat !=QLA_SUCCESS ) { -starget_printk (KERN_INFO ,scsi_target (cmd->device), +starget_printk (KERN_INFO , starget,"WARM TARGET RESET FAILED.\n" );return FAILED ; } -if (qla4xxx_eh_wait_for_commands (ha,scsi_target (cmd->device), -NULL )) { -starget_printk (KERN_INFO ,scsi_target (cmd->device), +if (qla4xxx_eh_wait_for_commands (ha, starget,NULL )) { +starget_printk (KERN_INFO , starget,"WARM TARGET DEVICE RESET FAILED - " "waiting for commands.\n" );return FAILED ;
@@ -9376,13 +9384,13 @@ static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd)/* Send marker. */ if (qla4xxx_send_marker_iocb (ha, ddb_entry, cmd->device->lun,MM_TGT_WARM_RESET ) !=QLA_SUCCESS ) { -starget_printk (KERN_INFO ,scsi_target (cmd->device), +starget_printk (KERN_INFO , starget,"WARM TARGET DEVICE RESET FAILED - " "marker iocb failed.\n" );return FAILED ; } -starget_printk (KERN_INFO ,scsi_target (cmd->device), +starget_printk (KERN_INFO , starget,"WARM TARGET RESET SUCCEEDED.\n" );return SUCCESS ; }
drivers/scsi/scsi_transport_iscsi.c +2 -4
@@ -1821,17 +1821,15 @@ static void iscsi_scan_session(struct work_struct *work)/** * iscsi_block_scsi_eh - block scsi eh until session state has transistioned -* @cmd: scsi cmd passed to scsi eh handler +* @session: iscsi session derived from scsi eh handler argument * * If the session is down this function will wait for the recovery * timer to fire or for the session to be logged back in. If the * recovery timer fires then FAST_IO_FAIL is returned. The caller * should pass this error value to the scsi eh. */ -int iscsi_block_scsi_eh (struct scsi_cmnd *cmd) +int iscsi_block_scsi_eh (struct iscsi_cls_session *session) { -struct iscsi_cls_session *session = -starget_to_session (scsi_target (cmd->device));unsigned long flags;int ret =0 ;
include/scsi/scsi_transport_iscsi.h +1 -1
@@ -456,7 +456,7 @@ extern struct iscsi_endpoint *iscsi_create_endpoint(int dd_size);extern void iscsi_destroy_endpoint (struct iscsi_endpoint *ep);extern struct iscsi_endpoint *iscsi_lookup_endpoint (u64 handle);extern void iscsi_put_endpoint (struct iscsi_endpoint *ep); -extern int iscsi_block_scsi_eh (struct scsi_cmnd *cmd); +extern int iscsi_block_scsi_eh (struct iscsi_cls_session *session); extern struct iscsi_iface *iscsi_create_iface(struct Scsi_Host *shost, struct iscsi_transport *t, uint32_t iface_type,
Signature · 1 line
2.29.2
Re: [PATCH 04/11] scsi_transport_iscsi: use session as argument for iscsi_block_scsi_eh()
Looks good:
PATCH 5/11 pmcraid: select first available device for target reset
In reply to Hannes ReineckeAs we're moving away from using a scsi command as argument for eh_XX callbacks we should be selecting the first available device for sending a target reset to.
--- drivers/scsi/pmcraid.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/scsi/pmcraid.c +14 -2
@@ -3064,9 +3064,21 @@ static int pmcraid_eh_bus_reset_handler(struct scsi_cmnd *scmd)static int pmcraid_eh_target_reset_handler (struct scsi_cmnd *scmd) { -scmd_printk (KERN_INFO , scmd, +struct Scsi_Host *shost = scmd->device->host; +struct scsi_device *scsi_dev =NULL , *tmp; + +shost_for_each_device (tmp, shost) { +if ((tmp->channel == scmd->device->channel) && + (tmp->id == scmd->device->id)) { + scsi_dev = tmp; +break ; + } + } +if (!scsi_dev) +return FAILED ; +sdev_printk (KERN_INFO , scsi_dev,"Doing target reset due to an I/O command timeout.\n" ); -return pmcraid_reset_device (scmd->device, +return pmcraid_reset_device (scsi_dev,PMCRAID_INTERNAL_TIMEOUT ,RESET_DEVICE_TARGET ); }
Signature · 1 line
2.29.2
Re: [PATCH 05/11] pmcraid: select first available device for target reset
Looks good:
Re: [PATCH 05/11] pmcraid: select first available device for target reset
In reply to Hannes ReineckeQuoted 2 lines · Hannes Reinecke
As we're moving away from using a scsi command as argument for
eh_XXcallbacks we should be selecting the first available device
^^^^^^^^^
Quoted 1 line
for sending a target reset to.
Please explain in the commit message why selecting the first available
device is the right approach.
Thanks,
Bart.
Re: [PATCH 05/11] pmcraid: select first available device for target reset
Quoted 8 lines · Bart Van Assche
Quoted 2 lines · Hannes Reinecke
As we're moving away from using a scsi command as argument for
eh_XXcallbacks we should be selecting the first available device^^^^^^^^^
Quoted 1 line
for sending a target reset to.
Please explain in the commit message why selecting the first available
device is the right approach.
That's due to the firmware interface of the pmcraid HBA.
All commands require a LUN number to be specified, so we need to select the first available drive on the bus to get a valid LUN.
It _might_ be that LUN 0 _could_ be sufficient here, but that would be change in behaviour and hard to validate. So this patch mimics the original behaviour to always fill in a valid LUN.
Cheers,
Hannes
Signature · 4 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: Felix Imendörffer
PATCH 6/11 bfa: Do not use scsi command to signal TMF status
In reply to Hannes ReineckeThe bfa driver hijacks the scsi command to signal the TMF status, which will no longer work if the TMF handler will be converted. So rework TMF handling to not use a scsi command but rather add new TMF fields to the per-device structure.
--- drivers/scsi/bfa/bfad_im.c | 112 ++++++++++++++++++++----------------- drivers/scsi/bfa/bfad_im.h | 2 + 2 files changed, 63 insertions(+), 51 deletions(-)
drivers/scsi/bfa/bfad_im.c +61 -51
@@ -147,13 +147,13 @@ void bfa_cb_tskim_done(void *bfad, struct bfad_tskim_s *dtsk, enum bfi_tskim_status tsk_status) { -struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dtsk; +struct bfad_itnim_data_s *itnim_data = + (struct bfad_itnim_data_s *)dtsk;wait_queue_head_t *wq; -bfad_priv (cmnd)->status |= tsk_status <<1 ; -set_bit (IO_DONE_BIT , &bfad_priv (cmnd)->status); - wq =bfad_priv (cmnd)->wq; -bfad_priv (cmnd)->wq =NULL ; + itnim_data->tmf_status |= tsk_status <<1 ; +set_bit (IO_DONE_BIT , &itnim_data->tmf_status); + wq = itnim_data->tmf_wq;if (wq)wake_up (wq);
@@ -238,15 +238,16 @@ bfad_im_abort_handler(struct scsi_cmnd *cmnd) }static bfa_status_t -bfad_im_target_reset_send (struct bfad_s *bfad,struct scsi_cmnd *cmnd, -struct bfad_itnim_s *itnim) +bfad_im_target_reset_send (struct bfad_s *bfad, +struct bfad_itnim_data_s *itnim_data) { +struct bfad_itnim_s *itnim = itnim_data->itnim;struct bfa_tskim_s *tskim;struct bfa_itnim_s *bfa_itnim;bfa_status_t rc =BFA_STATUS_OK ;struct scsi_lun scsilun; - tskim =bfa_tskim_alloc (&bfad->bfa, (struct bfad_tskim_s *) cmnd); + tskim =bfa_tskim_alloc (&bfad->bfa, (struct bfad_tskim_s *) itnim_data);if (!tskim) {BFA_LOG (KERN_ERR , bfad, bfa_log_level,"target reset, fail to allocate tskim\n" );
@@ -254,12 +255,6 @@ bfad_im_target_reset_send(struct bfad_s *bfad, struct scsi_cmnd *cmnd, goto out; } -/* -* Set host_scribble to NULL to avoid aborting a task command if -* happens. -*/ - cmnd->host_scribble =NULL ; -bfad_priv (cmnd)->status =0 ; bfa_itnim =bfa_fcs_itnim_get_halitn (&itnim->fcs_itnim);/* * bfa_itnim can be NULL if the port gets disconnected and the bfa
@@ -290,10 +285,11 @@ bfad_im_target_reset_send(struct bfad_s *bfad, struct scsi_cmnd *cmnd,static int bfad_im_reset_lun_handler (struct scsi_cmnd *cmnd) { -struct Scsi_Host *shost = cmnd->device->host; +struct scsi_device *sdev = cmnd->device; +struct Scsi_Host *shost = sdev->host;struct bfad_im_port_s *im_port = (struct bfad_im_port_s *) shost->hostdata[0 ]; -struct bfad_itnim_data_s *itnim_data = cmnd->device->hostdata; +struct bfad_itnim_data_s *itnim_data = sdev->hostdata;struct bfad_s *bfad = im_port->bfad;struct bfa_tskim_s *tskim;struct bfad_itnim_s *itnim;
@@ -305,14 +301,20 @@ bfad_im_reset_lun_handler(struct scsi_cmnd *cmnd)struct scsi_lun scsilun;spin_lock_irqsave (&bfad->bfad_lock, flags); +if (itnim_data->tmf_wq) { +BFA_LOG (KERN_ERR , bfad, bfa_log_level, +"LUN reset, TMF already active" ); +spin_unlock_irqrestore (&bfad->bfad_lock, flags); + rc =FAILED ; + goto out; + } itnim = itnim_data->itnim;if (!itnim) {spin_unlock_irqrestore (&bfad->bfad_lock, flags); rc =FAILED ; goto out; } - - tskim =bfa_tskim_alloc (&bfad->bfa, (struct bfad_tskim_s *) cmnd); + tskim =bfa_tskim_alloc (&bfad->bfa, (struct bfad_tskim_s *) itnim_data);if (!tskim) {BFA_LOG (KERN_ERR , bfad, bfa_log_level,"LUN reset, fail to allocate tskim" );
@@ -321,13 +323,8 @@ bfad_im_reset_lun_handler(struct scsi_cmnd *cmnd) goto out; } -/* -* Set host_scribble to NULL to avoid aborting a task command -* if happens. -*/ - cmnd->host_scribble =NULL ; -bfad_priv (cmnd)->wq = &wq; -bfad_priv (cmnd)->status =0 ; + itnim_data->tmf_wq = &wq; + itnim_data->tmf_status =0 ; bfa_itnim =bfa_fcs_itnim_get_halitn (&itnim->fcs_itnim);/* * bfa_itnim can be NULL if the port gets disconnected and the bfa
@@ -342,14 +339,15 @@ bfad_im_reset_lun_handler(struct scsi_cmnd *cmnd) rc =FAILED ; goto out; } -int_to_scsilun (cmnd->device->lun, &scsilun); +int_to_scsilun (sdev->lun, &scsilun);bfa_tskim_start (tskim, bfa_itnim, scsilun,FCP_TM_LUN_RESET ,BFAD_LUN_RESET_TMO );spin_unlock_irqrestore (&bfad->bfad_lock, flags); -wait_event (wq,test_bit (IO_DONE_BIT , &bfad_priv (cmnd)->status)); +wait_event (wq,test_bit (IO_DONE_BIT , &itnim_data->tmf_status)); - task_status =bfad_priv (cmnd)->status >>1 ; + itnim_data->tmf_wq =NULL ; + task_status = itnim_data->tmf_status >>1 ;if (task_status !=BFI_TSKIM_STS_OK ) {BFA_LOG (KERN_ERR , bfad, bfa_log_level,"LUN reset failure, status: %d\n" , task_status);
@@ -368,35 +366,47 @@ bfad_im_reset_target_handler(struct scsi_cmnd *cmnd) {struct Scsi_Host *shost = cmnd->device->host;struct scsi_target *starget =scsi_target (cmnd->device); +struct fc_rport *rport =starget_to_rport (starget);struct bfad_im_port_s *im_port = (struct bfad_im_port_s *) shost->hostdata[0 ]; -struct bfad_s *bfad = im_port->bfad; -struct bfad_itnim_s *itnim; -unsigned long flags; -u32 rc, rtn =FAILED ; +struct bfad_s *bfad = im_port->bfad; +struct bfad_itnim_data_s *itnim_data; +struct bfad_itnim_s *itnim; +unsigned long flags; +u32 rc, rtn =FAILED ;DECLARE_WAIT_QUEUE_HEAD_ONSTACK (wq);enum bfi_tskim_status task_status;spin_lock_irqsave (&bfad->bfad_lock, flags); - itnim =bfad_get_itnim (im_port, starget->id); -if (itnim) { -bfad_priv (cmnd)->wq = &wq; - rc =bfad_im_target_reset_send (bfad, cmnd, itnim); -if (rc ==BFA_STATUS_OK ) { -/* wait target reset to complete */ -spin_unlock_irqrestore (&bfad->bfad_lock, flags); -wait_event (wq,test_bit (IO_DONE_BIT , - &bfad_priv (cmnd)->status)); -spin_lock_irqsave (&bfad->bfad_lock, flags); - - task_status =bfad_priv (cmnd)->status >>1 ; -if (task_status !=BFI_TSKIM_STS_OK ) -BFA_LOG (KERN_ERR , bfad, bfa_log_level, -"target reset failure," -" status: %d\n" , task_status); -else - rtn =SUCCESS ; - } +if (!rport->dd_data) { +spin_unlock_irqrestore (&bfad->bfad_lock, flags); +return rtn; + } + itnim_data = rport->dd_data; +if (itnim_data->tmf_wq) { +BFA_LOG (KERN_ERR , bfad, bfa_log_level, +"target reset failed, TMF already active" ); +spin_unlock_irqrestore (&bfad->bfad_lock, flags); +return rtn; + } + itnim = itnim_data->itnim; + itnim_data->tmf_wq = &wq; + itnim_data->tmf_status =0 ; + rc =bfad_im_target_reset_send (bfad, itnim_data); +if (rc ==BFA_STATUS_OK ) { +/* wait target reset to complete */ +spin_unlock_irqrestore (&bfad->bfad_lock, flags); +wait_event (wq,test_bit (IO_DONE_BIT , + &itnim_data->tmf_status)); +spin_lock_irqsave (&bfad->bfad_lock, flags); + + task_status = itnim_data->tmf_status >>1 ; +if (task_status !=BFI_TSKIM_STS_OK ) +BFA_LOG (KERN_ERR , bfad, bfa_log_level, +"target reset failure," +" status: %d\n" , task_status); +else + rtn =SUCCESS ; }spin_unlock_irqrestore (&bfad->bfad_lock, flags);
drivers/scsi/bfa/bfad_im.h +2 -0
@@ -61,6 +61,8 @@ static inline struct bfad_cmd_priv *bfad_priv(struct scsi_cmnd *cmd)struct bfad_itnim_data_s {struct bfad_itnim_s *itnim; +wait_queue_head_t *tmf_wq; +unsigned long tmf_status; };struct bfad_im_port_s {
Signature · 1 line
2.29.2
Re: [PATCH 06/11] bfa: Do not use scsi command to signal TMF status
Quoted 4 lines · Hannes Reinecke
The bfa driver hijacks the scsi command to signal the TMF status, which will no longer work if the TMF handler will be converted. So rework TMF handling to not use a scsi command but rather add new TMF fields to the per-device structure.
This looks ok, but also a little sketchy. Given how unmaintained the bfa driver is, maybe it is time just drop it?
Re: [PATCH 06/11] bfa: Do not use scsi command to signal TMF status
Quoted 8 lines · Christoph Hellwig
Quoted 4 lines · Hannes Reinecke
The bfa driver hijacks the scsi command to signal the TMF status, which will no longer work if the TMF handler will be converted. So rework TMF handling to not use a scsi command but rather add new TMF fields to the per-device structure.
This looks ok, but also a little sketchy. Given how unmaintained the bfa driver is, maybe it is time just drop it?
Hmm. Opens up interesting possibilities.
While I still have a couple of them, I can't say that I'm actively using them. (Quite the contrary, actually.)
And these are FCoE cards to boot, so one actually needs an FCoE switch to get them to work. And those have gone out of fashion lately, so the driver indeed is bordering on being obsolete.
But not quite, so I'm not sure.
We could ask Broadcom, though; nominally it's their driver after all...
Cheers,
Hannes
Signature · 4 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: Felix Imendörffer
PATCH 7/11 aha152x: look for stuck command when resetting device
In reply to Hannes ReineckeFrom: Hannes Reinecke <[email protected]>
The LLDD needs a command to send the reset with, so look at the list of outstanding commands to get one.
--- drivers/scsi/aha152x.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-)
drivers/scsi/aha152x.c +15 -11
@@ -1070,24 +1070,28 @@ static int aha152x_abort(struct scsi_cmnd *SCpnt)*/ static int aha152x_device_reset (struct scsi_cmnd * SCpnt) { -struct Scsi_Host *shpnt = SCpnt->device->host; +struct scsi_device *sdev = SCpnt->device; +struct Scsi_Host *shpnt = sdev->host;DECLARE_COMPLETION (done);int ret, issued, disconnected; -unsigned char old_cmd_len = SCpnt->cmd_len; +unsigned char old_cmd_len;unsigned long flags;unsigned long timeleft; -if (CURRENT_SC ==SCpnt) { -scmd_printk (KERN_ERR , SCpnt,"cannot reset current device\n" ); -return FAILED ; - } -DO_LOCK (flags); - issued =remove_SC (&ISSUE_SC , SCpnt) ==NULL ; - disconnected = issued &&remove_SC (&DISCONNECTED_SC , SCpnt); +/* Look for the stuck command */ + SCpnt =remove_lun_SC (&ISSUE_SC , sdev->id, sdev->lun); +if (SCpnt) + issued =1 ; +else + SCpnt =remove_lun_SC (&DISCONNECTED_SC , sdev->id, sdev->lun); +if (!issued && SCpnt) + disconnected =1 ;DO_UNLOCK (flags); - - SCpnt->cmd_len =0 ; +if (!SCpnt) +return FAILED ; + old_cmd_len = SCpnt->cmd_len; + SCpnt->cmd_len =0 ;aha152x_internal_queue (SCpnt, &done, resetting);
Signature · 1 line
2.29.2
PATCH 8/11 a1000u2w: do not rely on the command for inia100_device_reset()
In reply to Hannes ReineckeUse the scsi device as argument to orc_device_reset() instead of relying on the passed in scsi command.
--- drivers/scsi/a100u2w.c | 43 +++++++++++------------------------------- 1 file changed, 11 insertions(+), 32 deletions(-)
drivers/scsi/a100u2w.c +11 -32
@@ -592,39 +592,20 @@ static int orc_reset_scsi_bus(struct orc_host * host)* commands for target w/o soft reset */ -static int orc_device_reset (struct orc_host * host,struct scsi_cmnd *cmd,unsigned int target) +static int orc_device_reset (struct orc_host * host,struct scsi_device *sdev) {/* I need Host Control Block Information */ struct orc_scb *scb;struct orc_extended_scb *escb; -struct orc_scb *host_scb; -u8 i;unsigned long flags;spin_lock_irqsave (&(host->allocation_lock), flags); scb = (struct orc_scb *)NULL ; escb = (struct orc_extended_scb *)NULL ; -/* setup scatter list address with one buffer */ - host_scb = host->scb_virt; -/* FIXME: is this safe if we then fail to issue the reset or race a completion ? */ init_alloc_map (host); -/* Find the scb corresponding to the command */ -for (i =0 ; i <ORC_MAXQUEUE ; i++) { - escb = host_scb->escb; -if (host_scb->status && escb->srb == cmd) -break ; - host_scb++; - } - -if (i ==ORC_MAXQUEUE ) { -printk (KERN_ERR "Unable to Reset - No SCB Found\n" ); -spin_unlock_irqrestore (&(host->allocation_lock), flags); -return FAILED ; - } -/* Allocate a new SCB for the reset command to the firmware */ if ((scb =__orc_alloc_scb (host)) ==NULL ) {/* Can't happen.. */
@@ -635,7 +616,7 @@ static int orc_device_reset(struct orc_host * host, struct scsi_cmnd *cmd, unsig/* Reset device is handled by the firmware, we fill in an SCB and fire it at the controller, it does the rest */ scb->opcode =ORC_BUSDEVRST ; - scb->target = target; + scb->target = sdev->id; scb->hastat =0 ; scb->tastat =0 ; scb->status =0x0 ;
@@ -645,8 +626,8 @@ static int orc_device_reset(struct orc_host * host, struct scsi_cmnd *cmd, unsig scb->xferlen =cpu_to_le32 (0 ); scb->sg_len =cpu_to_le32 (0 ); + escb = scb->escb; escb->srb =NULL ; - escb->srb = cmd;orc_exec_scb (host, scb);/* Start execute SCB */ spin_unlock_irqrestore (&host->allocation_lock, flags);return SUCCESS ;
@@ -971,7 +952,7 @@ static int inia100_device_reset(struct scsi_cmnd * cmd) {/* I need Host Control Block Information */ struct orc_host *host; host = (struct orc_host *) cmd->device->host->hostdata; -return orc_device_reset (host, cmd,scmd_id (cmd)); +return orc_device_reset (host, cmd->device); }
@@ -991,11 +972,7 @@ static void inia100_scb_handler(struct orc_host *host, struct orc_scb *scb)struct orc_extended_scb *escb; escb = scb->escb; -if ((cmd = (struct scsi_cmnd *) escb->srb) ==NULL ) { -printk (KERN_ERR "inia100_scb_handler: SRB pointer is empty\n" ); -orc_release_scb (host, scb);/* Release SCB for current channel */ -return ; - } + cmd = (struct scsi_cmnd *)escb->srb; escb->srb =NULL ;switch (scb->hastat) {
@@ -1033,13 +1010,15 @@ static void inia100_scb_handler(struct orc_host *host, struct orc_scb *scb)break ; } -if (scb->tastat ==2 ) {/* Check condition */ +if (cmd && scb->tastat ==2 ) {/* Check condition */ memcpy ((unsigned char *) &cmd->sense_buffer[0 ], (unsigned char *) &escb->sglist[0 ],SENSE_SIZE ); } - cmd->result = scb->tastat | (scb->hastat <<16 ); -scsi_dma_unmap (cmd); -scsi_done (cmd);/* Notify system DONE */ +if (cmd) { + cmd->result = scb->tastat | (scb->hastat <<16 ); +scsi_dma_unmap (cmd); +scsi_done (cmd);/* Notify system DONE */ + }orc_release_scb (host, scb);/* Release SCB for current channel */ }
Signature · 1 line
2.29.2
PATCH 9/11 xen-scsifront: add scsi device as argument to scsifront_do_request()
In reply to Hannes ReineckeAdd scsi device as argument to scsifront_do_request() so that it will be possible to call it with a NULL command pointer.
--- drivers/scsi/xen-scsifront.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-)
drivers/scsi/xen-scsifront.c +20 -11
@@ -175,7 +175,8 @@ static void scsifront_put_rqid(struct vscsifrnt_info *info, uint32_t id)scsifront_wake_up (info); } -static int scsifront_do_request (struct vscsifrnt_info *info, +static int scsifront_do_request (struct scsi_device *sdev, +struct vscsifrnt_info *info,struct vscsifrnt_shadow *shadow) {struct vscsiif_front_ring *ring = &(info->ring);
@@ -202,17 +203,25 @@ static int scsifront_do_request(struct vscsifrnt_info *info, ring_req->ref_rqid = shadow->ref_rqid; ring_req->nr_segments = shadow->nr_segments; - ring_req->id = sc->device->id; - ring_req->lun = sc->device->lun; - ring_req->channel = sc->device->channel; - ring_req->cmd_len = sc->cmd_len; + ring_req->id = sdev->id; + ring_req->lun = sdev->lun; + ring_req->channel = sdev->channel; -BUG_ON (sc->cmd_len >VSCSIIF_MAX_COMMAND_SIZE ); +if (sc) { + ring_req->cmd_len = sc->cmd_len; -memcpy (ring_req->cmnd, sc->cmnd, sc->cmd_len); +BUG_ON (sc->cmd_len >VSCSIIF_MAX_COMMAND_SIZE ); - ring_req->sc_data_direction = (uint8_t )sc->sc_data_direction; - ring_req->timeout_per_command =scsi_cmd_to_rq (sc)->timeout /HZ ; +memcpy (ring_req->cmnd, sc->cmnd, sc->cmd_len); + + ring_req->sc_data_direction = (uint8_t )sc->sc_data_direction; + ring_req->timeout_per_command = +scsi_cmd_to_rq (sc)->timeout /HZ ; + }else { + ring_req->cmd_len =VSCSIIF_MAX_COMMAND_SIZE ; +memset (ring_req->cmnd,0 ,VSCSIIF_MAX_COMMAND_SIZE ); + ring_req->sc_data_direction =DMA_NONE ; + }for (i =0 ; i < (shadow->nr_segments & ~VSCSIIF_SG_GRANT ); i++) ring_req->seg[i] = shadow->seg[i];
@@ -561,7 +570,7 @@ static int scsifront_queuecommand(struct Scsi_Host *shost,return 0 ; } -if (scsifront_do_request (info, shadow)) { +if (scsifront_do_request (sc->device, info, shadow)) {scsifront_gnttab_done (info, shadow); goto busy; }
@@ -606,7 +615,7 @@ static int scsifront_action_handler(struct scsi_cmnd *sc, uint8_t act)if (scsifront_enter (info)) goto fail; -if (!scsifront_do_request (info, shadow)) +if (!scsifront_do_request (sc->device, info, shadow))break ;scsifront_return (info);
Signature · 1 line
2.29.2
Re: [PATCH 09/11] xen-scsifront: add scsi device as argument to scsifront_do_request()
Quoted 2 lines · Hannes Reinecke
Add scsi device as argument to
scsifront_do_request()so that it will be possible to call it with a NULL command pointer.
Looks good:
PATCH 10/11 fas216: Rework device reset to not rely on SCSI command pointer
In reply to Hannes ReineckeThe device reset code should not rely on the SCSI command pointer; it will be going away with the device reset handler rework.
--- drivers/scsi/arm/fas216.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-)
drivers/scsi/arm/fas216.c +19 -20
@@ -1985,7 +1985,6 @@ static void fas216_devicereset_done(FAS216_Info *info, struct scsi_cmnd *SCpnt, {fas216_log (info,LOG_ERROR ,"fas216 device reset complete" ); - info->rstSCpnt =NULL ; info->rst_dev_status =1 ;wake_up (&info->eh_wait); }
@@ -2143,12 +2142,12 @@ static void fas216_done(FAS216_Info *info, unsigned int result)fas216_checkmagic (info); -if (!info->SCpnt) +if (!info->SCpnt && info->rst_dev_status) goto no_command; SCpnt = info->SCpnt; info->SCpnt =NULL ; - info->scsi.phase =PHASE_IDLE ; + info->scsi.phase =PHASE_IDLE ;if (info->scsi.aborting) {fas216_log (info,0 ,"uncaught abort - returning DID_ABORT" );
@@ -2160,7 +2159,7 @@ static void fas216_done(FAS216_Info *info, unsigned int result)* Sanity check the completion - if we have zero bytes left * to transfer, we should not have a valid pointer. */ -if (info->scsi.SCp.ptr && info->scsi.SCp.this_residual ==0 ) { +if (SCpnt && info->scsi.SCp.ptr && info->scsi.SCp.this_residual ==0 ) {scmd_printk (KERN_INFO , SCpnt,"zero bytes left to transfer, but buffer pointer still valid: ptr=%p len=%08x\n" , info->scsi.SCp.ptr, info->scsi.SCp.this_residual);
@@ -2173,12 +2172,18 @@ static void fas216_done(FAS216_Info *info, unsigned int result)* the sense information, fas216_kick will re-assert the busy * status. */ - info->device[SCpnt->device->id].parity_check =0 ; -clear_bit (SCpnt->device->id *8 + - (u8)(SCpnt->device->lun &0x7 ), info->busyluns); - - fn = (void (*)(FAS216_Info *,struct scsi_cmnd *,unsigned int ))SCpnt->host_scribble; -fn (info, SCpnt, result); +if (SCpnt) { + info->device[SCpnt->device->id].parity_check =0 ; +clear_bit (SCpnt->device->id *8 + + (u8)(SCpnt->device->lun &0x7 ), info->busyluns); + } +if (!info->rst_dev_status) { + info->rst_dev_status =1 ; +wake_up (&info->eh_wait); + }else { + fn = (void (*)(FAS216_Info *,struct scsi_cmnd *,unsigned int ))SCpnt->host_scribble; +fn (info, SCpnt, result); + }if (info->scsi.irq) {spin_lock_irqsave (&info->host_lock, flags);
@@ -2478,9 +2483,10 @@ int fas216_eh_abort(struct scsi_cmnd *SCpnt)*/ int fas216_eh_device_reset (struct scsi_cmnd *SCpnt) { -FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata; +struct scsi_device *sdev = SCpnt->device; +FAS216_Info *info = (FAS216_Info *)sdev->host->hostdata;unsigned long flags; -int i, res =FAILED , target = SCpnt->device->id; +int i, res =FAILED , target = sdev->id;fas216_log (info,LOG_ERROR ,"device reset for target %d" , target);
@@ -2494,7 +2500,7 @@ int fas216_eh_device_reset(struct scsi_cmnd *SCpnt)* and we need a bus reset. */ if (info->SCpnt && !info->scsi.disconnectable && - info->SCpnt->device->id == SCpnt->device->id) + info->SCpnt->device->id == sdev->id)break ;/*
@@ -2512,14 +2518,7 @@ int fas216_eh_device_reset(struct scsi_cmnd *SCpnt)for (i =0 ; i <8 ; i++)clear_bit (target *8 + i, info->busyluns); -/* -* Hijack this SCSI command structure to send -* a bus device reset message to this device. -*/ - SCpnt->host_scribble = (void *)fas216_devicereset_done; - info->rst_dev_status =0 ; - info->rstSCpnt = SCpnt;if (info->scsi.phase ==PHASE_IDLE )fas216_kick (info);
Signature · 1 line
2.29.2
Re: [PATCH 10/11] fas216: Rework device reset to not rely on SCSI command pointer
Eww, the function pointer abuse in this drive is rather gross.
But the changes looks ok to me:
PATCH 11/11 csiostor: use separate TMF command
In reply to Hannes ReineckeSet one command aside as a TMF command, and use this command to send the TMF. This avoids having to rely on the passed-in scsi command when resetting the device.
--- drivers/scsi/csiostor/csio_hw.h | 2 ++ drivers/scsi/csiostor/csio_init.c | 2 +- drivers/scsi/csiostor/csio_scsi.c | 48 +++++++++++++++++++------------ 3 files changed, 33 insertions(+), 19 deletions(-)
drivers/scsi/csiostor/csio_hw.h +2 -0
@@ -68,6 +68,8 @@#define CSIO_MAX_LUN 0xFFFF#define CSIO_MAX_QUEUE 2048 +#define CSIO_TMF_TAG (CSIO_MAX_QUEUE - 1) +#define CSIO_MAX_CMD_PER_LUN 32#define CSIO_MAX_DDP_BUF_SIZE (1024 * 1024)#define CSIO_MAX_SECTOR_SIZE 128
drivers/scsi/csiostor/csio_init.c +1 -1
@@ -621,7 +621,7 @@ csio_shost_init(struct csio_hw *hw, struct device *dev,/* Link common lnode to this lnode */ ln->dev_num = (shost->host_no <<16 ); - shost->can_queue =CSIO_MAX_QUEUE ; + shost->can_queue =CSIO_MAX_QUEUE -1 ; shost->this_id =-1 ; shost->unique_id = shost->host_no; shost->max_cmd_len =16 ;/* Max CDB length supported */
drivers/scsi/csiostor/csio_scsi.c +30 -18
129 lines not on this page · raw message
Signature · 1 line
2.29.2
Re: [PATCH 11/11] csiostor: use separate TMF command
Looks good: