scsi: fix target reset handling
Subsystems (10)
PATCH 3/5 Convert qla2xxx, mpt, arm, sym, a100u2w, qla1280 to target reset handler
In reply to [email protected]From: Mike Christie <[email protected]>
This patch converts the drivers that just needed a rename from "deivce" to "target" to use the target reset handler. This includes qla2xxx, mpt, arm/*, sym53c8xx_2, a100u2w and qla1280.
--- drivers/message/fusion/mptfc.c | 8 +++--- drivers/message/fusion/mptsas.c | 8 +++--- drivers/message/fusion/mptscsih.c | 8 +++--- drivers/message/fusion/mptscsih.h | 2 +- drivers/message/fusion/mptspi.c | 2 +- drivers/scsi/a100u2w.c | 12 +++++----- drivers/scsi/arm/arxescsi.c | 2 +- drivers/scsi/arm/cumana_2.c | 2 +- drivers/scsi/arm/eesox.c | 2 +- drivers/scsi/arm/fas216.c | 6 ++-- drivers/scsi/arm/fas216.h | 4 +- drivers/scsi/arm/powertec.c | 2 +- drivers/scsi/qla1280.c | 30 ++++++++++++------------ drivers/scsi/qla2xxx/qla_os.c | 42 +++++++++++++++++----------------- drivers/scsi/sym53c8xx_2/sym_glue.c | 10 ++++---- 15 files changed, 70 insertions(+), 70 deletions(-)
drivers/message/fusion/mptfc.c +4 -4
@@ -102,7 +102,7 @@ static void mptfc_target_destroy(struct scsi_target *starget);static void mptfc_set_rport_loss_tmo (struct fc_rport *rport,uint32_t timeout); static void __devexit mptfc_remove(struct pci_dev *pdev);static int mptfc_abort (struct scsi_cmnd *SCpnt); -static int mptfc_dev_reset (struct scsi_cmnd *SCpnt); +static int mptfc_target_reset (struct scsi_cmnd *SCpnt);static int mptfc_bus_reset (struct scsi_cmnd *SCpnt);static int mptfc_host_reset (struct scsi_cmnd *SCpnt);
@@ -120,7 +120,7 @@ static struct scsi_host_template mptfc_driver_template = { .slave_destroy = mptscsih_slave_destroy, .change_queue_depth = mptscsih_change_queue_depth, .eh_abort_handler = mptfc_abort, - .eh_device_reset_handler = mptfc_dev_reset, + .eh_target_reset_handler = mptfc_target_reset, .eh_bus_reset_handler = mptfc_bus_reset, .eh_host_reset_handler = mptfc_host_reset, .bios_param = mptscsih_bios_param,
@@ -235,10 +235,10 @@ mptfc_abort(struct scsi_cmnd *SCpnt) }static int -mptfc_dev_reset (struct scsi_cmnd *SCpnt) +mptfc_target_reset (struct scsi_cmnd *SCpnt) {return -mptfc_block_error_handler (SCpnt, mptscsih_dev_reset, __FUNCTION__); +mptfc_block_error_handler (SCpnt, mptscsih_target_reset, __FUNCTION__); } static int
drivers/message/fusion/mptsas.c +4 -4
@@ -610,7 +610,7 @@ mptsas_target_reset_queue(MPT_ADAPTER *ioc, }/** -* mptsas_dev_reset_complete +* mptsas_target_reset_complete * * Completion for TARGET_RESET after NOT_RESPONDING_EVENT, * enable work queue to finish off removing device from upper layers.
@@ -620,7 +620,7 @@ mptsas_target_reset_queue(MPT_ADAPTER *ioc,* **/ static void -mptsas_dev_reset_complete (MPT_ADAPTER *ioc) +mptsas_target_reset_complete (MPT_ADAPTER *ioc) {MPT_SCSI_HOST *hd =shost_priv (ioc->sh);struct list_head *head = &hd->target_reset_list;
@@ -711,7 +711,7 @@ mptsas_dev_reset_complete(MPT_ADAPTER *ioc)static int mptsas_taskmgmt_complete (MPT_ADAPTER *ioc,MPT_FRAME_HDR *mf,MPT_FRAME_HDR *mr) { -mptsas_dev_reset_complete (ioc); +mptsas_target_reset_complete (ioc);return mptscsih_taskmgmt_complete (ioc, mf, mr); }
@@ -1022,7 +1022,7 @@ static struct scsi_host_template mptsas_driver_template = { .slave_destroy = mptscsih_slave_destroy, .change_queue_depth = mptscsih_change_queue_depth, .eh_abort_handler = mptscsih_abort, - .eh_device_reset_handler = mptscsih_dev_reset, + .eh_target_reset_handler = mptscsih_target_reset, .eh_bus_reset_handler = mptscsih_bus_reset, .eh_host_reset_handler = mptscsih_host_reset, .bios_param = mptscsih_bios_param,
drivers/message/fusion/mptscsih.c +4 -4
@@ -1870,15 +1870,15 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ /** -* mptscsih_dev_reset - Perform a SCSI TARGET_RESET! new_eh variant +* mptscsih_target_reset - Perform a SCSI TARGET_RESET! new_eh variant * @SCpnt: Pointer to scsi_cmnd structure, IO which reset is due to * -* (linux scsi_host_template.eh_dev_reset_handler routine) +* (linux scsi_host_template.eh_target_reset_handler routine) * * Returns SUCCESS or FAILED. **/ int -mptscsih_dev_reset (struct scsi_cmnd * SCpnt) +mptscsih_target_reset (struct scsi_cmnd * SCpnt) {MPT_SCSI_HOST *hd;int retval;
@@ -3489,7 +3489,7 @@ EXPORT_SYMBOL(mptscsih_qcmd);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
@@ -115,7 +115,7 @@ extern int mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmndextern 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[]);
drivers/message/fusion/mptspi.c +1 -1
@@ -821,7 +821,7 @@ static struct scsi_host_template mptspi_driver_template = { .slave_destroy = mptspi_slave_destroy, .change_queue_depth = mptscsih_change_queue_depth, .eh_abort_handler = mptscsih_abort, - .eh_device_reset_handler = mptscsih_dev_reset, + .eh_target_reset_handler = mptscsih_target_reset, .eh_bus_reset_handler = mptscsih_bus_reset, .eh_host_reset_handler = mptscsih_host_reset, .bios_param = mptscsih_bios_param,
drivers/scsi/a100u2w.c +6 -6
@@ -583,7 +583,7 @@ static int orc_reset_scsi_bus(struct orc_host * host) }/** -* orc_device_reset - device reset handler +* orc_target_reset - target reset handler * @host: host to reset * @cmd: command causing the reset * @target; target device
@@ -592,7 +592,7 @@ 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_target_reset (struct orc_host * host,struct scsi_cmnd *cmd,unsigned int target) {/* I need Host Control Block Information */ struct orc_scb *scb;struct orc_extended_scb *escb;
@@ -955,17 +955,17 @@ static int inia100_bus_reset(struct scsi_cmnd * cmd) }/***************************************************************************** -Function name : inia100_device_reset +Function name : inia100_target_reset Description : Reset the device Input : host - Pointer to host adapter structure Output : None. Return : pSRB - Pointer to SCSI request block. *****************************************************************************/ -static int inia100_device_reset (struct scsi_cmnd * cmd) +static int inia100_target_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_target_reset (host, cmd,scmd_id (cmd)); }
@@ -1065,7 +1065,7 @@ static struct scsi_host_template inia100_template = { .queuecommand = inia100_queue, .eh_abort_handler = inia100_abort, .eh_bus_reset_handler = inia100_bus_reset, - .eh_device_reset_handler = inia100_device_reset, + .eh_target_reset_handler = inia100_target_reset, .can_queue = 1, .this_id = 1, .sg_tablesize = SG_ALL,
drivers/scsi/arm/arxescsi.c +1 -1
@@ -266,7 +266,7 @@ static struct scsi_host_template arxescsi_template = { .queuecommand = fas216_noqueue_command, .eh_host_reset_handler = fas216_eh_host_reset, .eh_bus_reset_handler = fas216_eh_bus_reset, - .eh_device_reset_handler = fas216_eh_device_reset, + .eh_target_reset_handler = fas216_eh_target_reset, .eh_abort_handler = fas216_eh_abort, .can_queue = 0, .this_id = 7,
drivers/scsi/arm/cumana_2.c +1 -1
@@ -386,7 +386,7 @@ static struct scsi_host_template cumanascsi2_template = { .queuecommand = fas216_queue_command, .eh_host_reset_handler = fas216_eh_host_reset, .eh_bus_reset_handler = fas216_eh_bus_reset, - .eh_device_reset_handler = fas216_eh_device_reset, + .eh_target_reset_handler = fas216_eh_target_reset, .eh_abort_handler = fas216_eh_abort, .can_queue = 1, .this_id = 7,
drivers/scsi/arm/eesox.c +1 -1
@@ -504,7 +504,7 @@ static struct scsi_host_template eesox_template = { .queuecommand = fas216_queue_command, .eh_host_reset_handler = fas216_eh_host_reset, .eh_bus_reset_handler = fas216_eh_bus_reset, - .eh_device_reset_handler = fas216_eh_device_reset, + .eh_target_reset_handler = fas216_eh_target_reset, .eh_abort_handler = fas216_eh_abort, .can_queue = 1, .this_id = 7,
drivers/scsi/arm/fas216.c +3 -3
@@ -2460,7 +2460,7 @@ int fas216_eh_abort(struct scsi_cmnd *SCpnt) }/** -* fas216_eh_device_reset - Reset the device associated with this command +* fas216_eh_target_reset - Reset the device associated with this command * @SCpnt: command specifing device to reset * * Reset the device associated with this command.
@@ -2468,7 +2468,7 @@ int fas216_eh_abort(struct scsi_cmnd *SCpnt)* Notes: We won't be re-entered, so we'll only have one device * reset on the go at one time. */ -int fas216_eh_device_reset (struct scsi_cmnd *SCpnt) +int fas216_eh_target_reset (struct scsi_cmnd *SCpnt) {FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata;unsigned long flags;
@@ -3029,7 +3029,7 @@ EXPORT_SYMBOL(fas216_intr);EXPORT_SYMBOL (fas216_remove);EXPORT_SYMBOL (fas216_release);EXPORT_SYMBOL (fas216_eh_abort); -EXPORT_SYMBOL (fas216_eh_device_reset); +EXPORT_SYMBOL (fas216_eh_target_reset);EXPORT_SYMBOL (fas216_eh_bus_reset);EXPORT_SYMBOL (fas216_eh_host_reset);EXPORT_SYMBOL (fas216_print_host);
drivers/scsi/arm/fas216.h +2 -2
@@ -375,12 +375,12 @@ extern int fas216_print_devices(FAS216_Info *info, char *buffer);*/ extern int fas216_eh_abort (struct scsi_cmnd *SCpnt); -/* Function: int fas216_eh_device_reset(struct scsi_cmnd *SCpnt) +/* Function: int fas216_eh_target_reset(struct scsi_cmnd *SCpnt) * Purpose : Reset the device associated with this command * Params : SCpnt - command specifing device to reset * Returns : FAILED if unable to reset */ -extern int fas216_eh_device_reset (struct scsi_cmnd *SCpnt); +extern int fas216_eh_target_reset (struct scsi_cmnd *SCpnt);/* Function: int fas216_eh_bus_reset(struct scsi_cmnd *SCpnt) * Purpose : Reset the complete bus associated with this command
drivers/scsi/arm/powertec.c +1 -1
@@ -297,7 +297,7 @@ static struct scsi_host_template powertecscsi_template = { .queuecommand = fas216_queue_command, .eh_host_reset_handler = fas216_eh_host_reset, .eh_bus_reset_handler = fas216_eh_bus_reset, - .eh_device_reset_handler = fas216_eh_device_reset, + .eh_target_reset_handler = fas216_eh_target_reset, .eh_abort_handler = fas216_eh_abort, .can_queue = 8,
drivers/scsi/qla1280.c +15 -15
@@ -442,7 +442,7 @@ static int qla1280_nvram_config(struct scsi_qla_host *);static int qla1280_mailbox_command (struct scsi_qla_host *,uint8_t ,uint16_t *);static int qla1280_bus_reset (struct scsi_qla_host *,int ); -static int qla1280_device_reset (struct scsi_qla_host *,int ,int ); +static int qla1280_target_reset (struct scsi_qla_host *,int ,int );static int qla1280_abort_device (struct scsi_qla_host *,int ,int ,int );static int qla1280_abort_command (struct scsi_qla_host *,struct srb *,int );static int qla1280_abort_isp (struct scsi_qla_host *);
@@ -756,7 +756,7 @@ qla1280_queuecommand(struct scsi_cmnd *cmd, void (*fn)(struct scsi_cmnd *))enum action {ABORT_COMMAND ,ABORT_DEVICE , -DEVICE_RESET , +TGT_RESET ,BUS_RESET ,ADAPTER_RESET ,FAIL
@@ -919,12 +919,12 @@ qla1280_error_action(struct scsi_cmnd *cmd, enum action action) result =SUCCESS ;break ; -case DEVICE_RESET : +case TGT_RESET :if (qla1280_verbose)printk (KERN_INFO -"scsi(%ld:%d:%d:%d): Queueing device reset " +"scsi(%ld:%d:%d:%d): Queueing target reset " "command.\n" , ha->host_no, bus, target, lun); -if (qla1280_device_reset (ha, bus, target) ==0 ) +if (qla1280_target_reset (ha, bus, target) ==0 ) result =SUCCESS ;break ;
@@ -1018,16 +1018,16 @@ qla1280_eh_abort(struct scsi_cmnd * cmd) }/************************************************************************** -* qla1280_device_reset -* Reset the specified SCSI device +* qla1280_target_reset +* Reset the specified SCSI target **************************************************************************/ static int -qla1280_eh_device_reset (struct scsi_cmnd *cmd) +qla1280_eh_target_reset (struct scsi_cmnd *cmd) {int rc;spin_lock_irq (cmd->device->host->host_lock); - rc =qla1280_error_action (cmd,DEVICE_RESET ); + rc =qla1280_error_action (cmd,TGT_RESET );spin_unlock_irq (cmd->device->host->host_lock);return rc;
@@ -2580,7 +2580,7 @@ qla1280_bus_reset(struct scsi_qla_host *ha, int bus) }/* -* qla1280_device_reset +* qla1280_target_reset * Issue bus device reset message to the target. * * Input:
@@ -2592,12 +2592,12 @@ qla1280_bus_reset(struct scsi_qla_host *ha, int bus)* 0 = success */ static int -qla1280_device_reset (struct scsi_qla_host *ha,int bus,int target) +qla1280_target_reset (struct scsi_qla_host *ha,int bus,int target) {uint16_t mb[MAILBOX_REGISTER_COUNT ];int status; -ENTER ("qla1280_device_reset" ); +ENTER ("qla1280_target_reset" ); mb[0 ] =MBC_ABORT_TARGET ; mb[1 ] = (bus ? (target |BIT_7 ) : target) <<8 ;
@@ -2608,9 +2608,9 @@ qla1280_device_reset(struct scsi_qla_host *ha, int bus, int target)qla1280_marker (ha, bus, target,0 ,MK_SYNC_ID );if (status) -dprintk (2 ,"qla1280_device_reset: **** FAILED ****\n" ); +dprintk (2 ,"qla1280_target_reset: **** FAILED ****\n" ); -LEAVE ("qla1280_device_reset" ); +LEAVE ("qla1280_target_reset" );return status; }
@@ -4195,7 +4195,7 @@ static struct scsi_host_template qla1280_driver_template = { .slave_configure = qla1280_slave_configure, .queuecommand = qla1280_queuecommand, .eh_abort_handler = qla1280_eh_abort, - .eh_device_reset_handler= qla1280_eh_device_reset, + .eh_target_reset_handler= qla1280_eh_target_reset, .eh_bus_reset_handler = qla1280_eh_bus_reset, .eh_host_reset_handler = qla1280_eh_adapter_reset, .bios_param = qla1280_biosparam,
drivers/scsi/qla2xxx/qla_os.c +21 -21
128 lines not on this page · raw message
drivers/scsi/sym53c8xx_2/sym_glue.c +5 -5
@@ -578,7 +578,7 @@ static void sym53c8xx_timer(unsigned long npref)* What the eh thread wants us to perform. */ #define SYM_EH_ABORT 0 -#define SYM_EH_DEVICE_RESET 1 +#define SYM_EH_TARGET_RESET 1#define SYM_EH_BUS_RESET 2#define SYM_EH_HOST_RESET 3
@@ -646,7 +646,7 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd)case SYM_EH_ABORT : sts =sym_abort_scsiio (np, cmd,1 );break ; -case SYM_EH_DEVICE_RESET : +case SYM_EH_TARGET_RESET : sts =sym_reset_scsi_target (np, cmd->device->id);break ;case SYM_EH_BUS_RESET :
@@ -692,9 +692,9 @@ static int sym53c8xx_eh_abort_handler(struct scsi_cmnd *cmd)return sym_eh_handler (SYM_EH_ABORT ,"ABORT" , cmd); } -static int sym53c8xx_eh_device_reset_handler (struct scsi_cmnd *cmd) +static int sym53c8xx_eh_target_reset_handler (struct scsi_cmnd *cmd) { -return sym_eh_handler (SYM_EH_DEVICE_RESET ,"DEVICE RESET" , cmd); +return sym_eh_handler (SYM_EH_TARGET_RESET ,"TARGET RESET" , cmd); }static int sym53c8xx_eh_bus_reset_handler (struct scsi_cmnd *cmd)
@@ -1676,7 +1676,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
1.5.4.1
PATCH 5/5 zfcp: convert zfcp to use target reset and device reset handler
In reply to [email protected]From: Mike Christie <[email protected]>
zfcp uses the device reset handler to try and send a lun reset. If that fails it then does a target reset. This patch has it do a lun reset in the target reset handler like other drivers, then do a target reset in the target reset handler. scsi_error.c will escalate from device reset to target reset for the driver.
This patch is only compile tested since suprisingly I could find a s390 box, but I could not hook storage into the the zfcp adapter (box was remote).
--- drivers/s390/scsi/zfcp_scsi.c | 67 +++++++++++++++++++++++++---------------- 1 files changed, 41 insertions(+), 26 deletions(-)
drivers/s390/scsi/zfcp_scsi.c +41 -26
@@ -31,6 +31,7 @@ static int zfcp_scsi_queuecommand(struct scsi_cmnd *, void (*done) (struct scsi_cmnd *));static int zfcp_scsi_eh_abort_handler (struct scsi_cmnd *);static int zfcp_scsi_eh_device_reset_handler (struct scsi_cmnd *); +static int zfcp_scsi_eh_target_reset_handler (struct scsi_cmnd *);static int zfcp_scsi_eh_host_reset_handler (struct scsi_cmnd *);static int zfcp_task_management_function (struct zfcp_unit *,u8 ,struct scsi_cmnd *);
@@ -51,6 +52,7 @@ struct zfcp_data zfcp_data = { .queuecommand = zfcp_scsi_queuecommand, .eh_abort_handler = zfcp_scsi_eh_abort_handler, .eh_device_reset_handler = zfcp_scsi_eh_device_reset_handler, + .eh_target_reset_handler = zfcp_scsi_eh_target_reset_handler, .eh_host_reset_handler = zfcp_scsi_eh_host_reset_handler, .can_queue = 4096, .this_id = -1,
@@ -457,33 +459,46 @@ zfcp_scsi_eh_device_reset_handler(struct scsi_cmnd *scpnt) unit->fcp_lun, unit->port->wwpn, zfcp_get_busid_by_adapter(unit->port->adapter)); -/* -* If we do not know whether the unit supports 'logical unit reset' -* then try 'logical unit reset' and proceed with 'target reset' -* if 'logical unit reset' fails. -* If the unit is known not to support 'logical unit reset' then -* skip 'logical unit reset' and try 'target reset' immediately. -*/ -if (!atomic_test_mask (ZFCP_STATUS_UNIT_NOTSUPPUNITRESET , - &unit->status)) { - retval =zfcp_task_management_function (unit, -FCP_LOGICAL_UNIT_RESET , - scpnt); -if (retval) { -ZFCP_LOG_DEBUG ("unit reset failed (unit=%p)\n" , unit); -if (retval == -ENOTSUPP ) -atomic_set_mask - (ZFCP_STATUS_UNIT_NOTSUPPUNITRESET , - &unit->status); -/* fall through and try 'target reset' next */ - }else { -ZFCP_LOG_DEBUG ("unit reset succeeded (unit=%p)\n" , - unit); -/* avoid 'target reset' */ - retval =SUCCESS ; - goto out; - } +if (atomic_test_mask (ZFCP_STATUS_UNIT_NOTSUPPUNITRESET , + &unit->status)) { +ZFCP_LOG_DEBUG ("unit reset not supported (unit=%p)\n" , unit); + retval =FAILED ; + goto out; + } + + retval =zfcp_task_management_function (unit, +FCP_LOGICAL_UNIT_RESET , + scpnt); +if (retval) { +ZFCP_LOG_DEBUG ("unit reset failed (unit=%p)\n" , unit); +if (retval == -ENOTSUPP ) +atomic_set_mask (ZFCP_STATUS_UNIT_NOTSUPPUNITRESET , + &unit->status); + retval =FAILED ; + }else { +ZFCP_LOG_DEBUG ("unit reset succeeded (unit=%p)\n" , unit); + retval =SUCCESS ; + } + out: +return retval; +} + +static int +zfcp_scsi_eh_target_reset_handler (struct scsi_cmnd *scpnt) +{ +int retval; +struct zfcp_unit *unit = (struct zfcp_unit *) scpnt->device->hostdata; + +if (!unit) { +ZFCP_LOG_NORMAL ("bug: Tried reset for nonexistent unit\n" ); + retval =SUCCESS ; + goto out; } + +ZFCP_LOG_NORMAL ("resetting target 0x%016Lx on port 0x%016Lx, adapter %s\n" , + unit->fcp_lun, unit->port->wwpn, +zfcp_get_busid_by_adapter (unit->port->adapter)); + retval =zfcp_task_management_function (unit,FCP_TARGET_RESET , scpnt);if (retval) {ZFCP_LOG_DEBUG ("target reset failed (unit=%p)\n" , unit);
Signature · 1 line
1.5.4.1
PATCH 2/5 qla4xxx: Add target reset functionality
In reply to [email protected]From: Mike Christie <[email protected]>
This patch adds target reset functionalty.
--- drivers/scsi/qla4xxx/ql4_fw.h | 1 + drivers/scsi/qla4xxx/ql4_glbl.h | 2 + drivers/scsi/qla4xxx/ql4_mbx.c | 39 ++++++++++++++++++ drivers/scsi/qla4xxx/ql4_os.c | 82 ++++++++++++++++++++++++++++++--------- 4 files changed, 105 insertions(+), 19 deletions(-)
drivers/scsi/qla4xxx/ql4_fw.h +1 -0
@@ -216,6 +216,7 @@ union external_hw_config_reg {#define MBOX_CMD_ABOUT_FW 0x0009#define MBOX_CMD_PING 0x000B#define MBOX_CMD_LUN_RESET 0x0016 +#define MBOX_CMD_TARGET_WARM_RESET 0x0017#define MBOX_CMD_GET_MANAGEMENT_DATA 0x001E#define MBOX_CMD_GET_FW_STATUS 0x001F#define MBOX_CMD_SET_ISNS_SERVICE 0x0021
drivers/scsi/qla4xxx/ql4_glbl.h +2 -0
@@ -27,6 +27,8 @@ int qla4xxx_relogin_device(struct scsi_qla_host * ha, struct ddb_entry * ddb_entry);int qla4xxx_reset_lun (struct scsi_qla_host * ha,struct ddb_entry * ddb_entry,int lun); +int qla4xxx_reset_target (struct scsi_qla_host * ha, +struct ddb_entry * ddb_entry);int qla4xxx_get_flash (struct scsi_qla_host * ha,dma_addr_t dma_addr,uint32_t offset,uint32_t len);int qla4xxx_get_firmware_status (struct scsi_qla_host * ha);
drivers/scsi/qla4xxx/ql4_mbx.c +39 -0
@@ -713,6 +713,45 @@ int qla4xxx_reset_lun(struct scsi_qla_host * ha, struct ddb_entry * ddb_entry,return status; } +/** +* qla4xxx_reset_target - issues target Reset +* @ha: Pointer to host adapter structure. +* @db_entry: Pointer to device database entry +* @un_entry: Pointer to lun entry structure +* +* This routine performs a TARGET RESET on the specified target. +* The caller must ensure that the ddb_entry pointers +* are valid before calling this routine. +**/ +int qla4xxx_reset_target (struct scsi_qla_host *ha, +struct ddb_entry *ddb_entry) +{ +uint32_t mbox_cmd[MBOX_REG_COUNT ]; +uint32_t mbox_sts[MBOX_REG_COUNT ]; +int status =QLA_SUCCESS ; + +DEBUG2 (printk ("scsi%ld:%d: target reset issued\n" , ha->host_no, + ddb_entry->os_target_id)); + +/* +* Send target reset command to ISP, so that the ISP will return all +* outstanding requests with RESET status +*/ +memset (&mbox_cmd,0 ,sizeof (mbox_cmd)); +memset (&mbox_sts,0 ,sizeof (mbox_sts)); + + mbox_cmd[0 ] =MBOX_CMD_TARGET_WARM_RESET ; + mbox_cmd[1 ] = ddb_entry->fw_ddb_index; + mbox_cmd[5 ] =0x01 ;/* Immediate Command Enable */ + +qla4xxx_mailbox_command (ha,MBOX_REG_COUNT ,1 , &mbox_cmd[0 ], + &mbox_sts[0 ]); +if (mbox_sts[0 ] !=MBOX_STS_COMMAND_COMPLETE && + mbox_sts[0 ] !=MBOX_STS_COMMAND_ERROR ) + status =QLA_ERROR ; + +return status; +}int qla4xxx_get_flash (struct scsi_qla_host * ha,dma_addr_t dma_addr,uint32_t offset,uint32_t len)
drivers/scsi/qla4xxx/ql4_os.c +63 -19
127 lines not on this page · raw message
Signature · 1 line
1.5.4.1
PATCH 4/5 lpfc: convert lpfc to use target reset handler.
In reply to [email protected]From: Mike Christie <[email protected]>
lpfc is sending a target reset from the device reset handler, so this patch just has it use the target reset handler.
This patch also has the driver use CTX_TGT instead of CTX_LUN in the target reset handler. It looked like a bug.
One thing I was not sure of was if lpfc_scsi_tgt_reset fails, but the caller ends up calling lpfc_sli_abort_iocb and that aborts all the commands for the context that is requested and those are all cleaned up by the driver/firmware, should we return SUCCESS.
This patch should wait for James Smart. I think he is on vacation, but the driver will work without the patch like it did before, so it is not required that this patch be merged with the rest.
--- drivers/scsi/lpfc/lpfc_scsi.c | 85 ++++++++++++++--------------------------- 1 files changed, 29 insertions(+), 56 deletions(-)
drivers/scsi/lpfc/lpfc_scsi.c +29 -56
@@ -835,13 +835,15 @@ lpfc_tskmgmt_def_cmpl(struct lpfc_hba *phba,static int lpfc_scsi_tgt_reset (struct lpfc_scsi_buf *lpfc_cmd,struct lpfc_vport *vport,unsigned tgt_id,unsigned int lun, -struct lpfc_rport_data *rdata) +struct lpfc_rport_data *rdata,int *iocb_status) {struct lpfc_hba *phba = vport->phba;struct lpfc_iocbq *iocbq;struct lpfc_iocbq *iocbqrsp;int ret; + *iocb_status =0 ; +if (!rdata->pnode)return FAILED ;
@@ -861,13 +863,14 @@ lpfc_scsi_tgt_reset(struct lpfc_scsi_buf *lpfc_cmd, struct lpfc_vport *vport,lpfc_printf_vlog (vport,KERN_INFO ,LOG_FCP ,"0702 Issue Target Reset to TGT %d Data: x%x x%x\n" , tgt_id, rdata->pnode->nlp_rpi, rdata->pnode->nlp_flag); - ret =lpfc_sli_issue_iocb_wait (phba, + *iocb_status =lpfc_sli_issue_iocb_wait (phba, &phba->sli.ring[phba->sli.fcp_ring], iocbq, iocbqrsp, lpfc_cmd->timeout); -if (ret !=IOCB_SUCCESS ) { -if (ret ==IOCB_TIMEDOUT ) +if (*iocb_status !=IOCB_SUCCESS ) { +if (*iocb_status ==IOCB_TIMEDOUT ) iocbq->iocb_cmpl = lpfc_tskmgmt_def_cmpl; lpfc_cmd->status =IOSTAT_DRIVER_REJECT ; + ret =FAILED ; }else { ret =SUCCESS ; lpfc_cmd->result = iocbqrsp->iocb.un.ulpWord[4 ];
@@ -1125,16 +1128,14 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd) }static int -lpfc_device_reset_handler (struct scsi_cmnd *cmnd) +lpfc_target_reset_handler (struct scsi_cmnd *cmnd) {struct Scsi_Host *shost = cmnd->device->host;struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;struct lpfc_hba *phba = vport->phba;struct lpfc_scsi_buf *lpfc_cmd; -struct lpfc_iocbq *iocbq, *iocbqrsp;struct lpfc_rport_data *rdata = cmnd->device->hostdata;struct lpfc_nodelist *pnode = rdata->pnode; -uint32_t cmd_result =0 , cmd_status =0 ;int ret =FAILED ;int iocb_status =IOCB_SUCCESS ;int cnt, loopcnt;
@@ -1156,7 +1157,7 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd)if (!rdata || (loopcnt > ((vport->cfg_devloss_tmo *2 ) +1 ))){lpfc_printf_vlog (vport,KERN_ERR ,LOG_FCP , -"0721 LUN Reset rport " +"0721 Target Reset rport " "failure: cnt x%x rdata x%p\n" , loopcnt, rdata); goto out;
@@ -1174,52 +1175,20 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd) goto out; lpfc_cmd->timeout =60 ; - lpfc_cmd->rdata = rdata; - - ret =lpfc_scsi_prep_task_mgmt_cmd (vport, lpfc_cmd, cmnd->device->lun, -FCP_TARGET_RESET ); -if (!ret) - goto out_free_scsi_buf; - - iocbq = &lpfc_cmd->cur_iocbq; - -/* get a buffer for this IOCB command response */ - iocbqrsp =lpfc_sli_get_iocbq (phba); -if (iocbqrsp ==NULL ) - goto out_free_scsi_buf; - -lpfc_printf_vlog (vport,KERN_INFO ,LOG_FCP , -"0703 Issue target reset to TGT %d LUN %d " -"rpi x%x nlp_flag x%x\n" , cmnd->device->id, - cmnd->device->lun, pnode->nlp_rpi, pnode->nlp_flag); - iocb_status =lpfc_sli_issue_iocb_wait (phba, - &phba->sli.ring[phba->sli.fcp_ring], - iocbq, iocbqrsp, lpfc_cmd->timeout); - -if (iocb_status ==IOCB_TIMEDOUT ) - iocbq->iocb_cmpl = lpfc_tskmgmt_def_cmpl; - -if (iocb_status ==IOCB_SUCCESS ) - ret =SUCCESS ; -else - ret = iocb_status; - - cmd_result = iocbqrsp->iocb.un.ulpWord[4 ]; - cmd_status = iocbqrsp->iocb.ulpStatus; - -lpfc_sli_release_iocbq (phba, iocbqrsp); + ret =lpfc_scsi_tgt_reset (lpfc_cmd, vport, cmnd->device->id, + cmnd->device->lun, rdata, &iocb_status);/* * All outstanding txcmplq I/Os should have been aborted by the device. * Unfortunately, some targets do not abide by this forcing the driver * to double check. */ cnt =lpfc_sli_sum_iocb (vport, cmnd->device->id, cmnd->device->lun, -LPFC_CTX_LUN ); +LPFC_CTX_TGT );if (cnt)lpfc_sli_abort_iocb (vport, &phba->sli.ring[phba->sli.fcp_ring], cmnd->device->id, cmnd->device->lun, -LPFC_CTX_LUN ); +LPFC_CTX_TGT ); loopcnt =0 ;while (cnt) {schedule_timeout_uninterruptible (LPFC_RESET_WAIT *HZ );
@@ -1229,25 +1198,29 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd)break ; cnt =lpfc_sli_sum_iocb (vport, cmnd->device->id, - cmnd->device->lun,LPFC_CTX_LUN ); + cmnd->device->lun,LPFC_CTX_TGT ); } +/* +* if lpfc_scsi_tgt_reset returned FAILED but lpfc_sli_abort_iocb +* got run above and that aborted all the commands and cnt=0, should +* we return SUCCESS because at least the commands were unstuck? +*/ if (cnt) {lpfc_printf_vlog (vport,KERN_ERR ,LOG_FCP , -"0719 device reset I/O flush failure: " +"0719 target reset I/O flush failure: " "cnt x%x\n" , cnt); ret =FAILED ; } -out_free_scsi_buf:if (iocb_status !=IOCB_TIMEDOUT ) {lpfc_release_scsi_buf (phba, lpfc_cmd); }lpfc_printf_vlog (vport,KERN_ERR ,LOG_FCP , -"0713 SCSI layer issued device reset (%d, %d) " +"0713 SCSI layer issued target reset (%d) " "return x%x status x%x result x%x\n" , - cmnd->device->id, cmnd->device->lun, ret, - cmd_status, cmd_result); + cmnd->device->id, ret, + lpfc_cmd->status, lpfc_cmd->result); out:return ret; }
@@ -1263,6 +1236,7 @@ lpfc_bus_reset_handler(struct scsi_cmnd *cmnd)int ret =FAILED , i, err_count =0 ;int cnt, loopcnt;struct lpfc_scsi_buf * lpfc_cmd; +int iocb_status =IOCB_SUCCESS ;lpfc_block_error_handler (cmnd);
@@ -1296,9 +1270,8 @@ lpfc_bus_reset_handler(struct scsi_cmnd *cmnd)if (!match)continue ; - ret =lpfc_scsi_tgt_reset (lpfc_cmd, vport, i, - cmnd->device->lun, - ndlp->rport->dd_data); + ret =lpfc_scsi_tgt_reset (lpfc_cmd, vport, i, cmnd->device->lun, + ndlp->rport->dd_data, &iocb_status);if (ret !=SUCCESS ) { lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP, "0700 Bus Reset on target %d failed\n",
@@ -1308,7 +1281,7 @@ lpfc_bus_reset_handler(struct scsi_cmnd *cmnd) } } -if (ret !=IOCB_TIMEDOUT ) +if (iocb_status !=IOCB_TIMEDOUT )lpfc_release_scsi_buf (phba, lpfc_cmd);if (err_count ==0 )
@@ -1453,7 +1426,7 @@ struct scsi_host_template lpfc_template = { .info = lpfc_info, .queuecommand = lpfc_queuecommand, .eh_abort_handler = lpfc_abort_handler, - .eh_device_reset_handler= lpfc_device_reset_handler, + .eh_target_reset_handler= lpfc_target_reset_handler, .eh_bus_reset_handler = lpfc_bus_reset_handler, .slave_alloc = lpfc_slave_alloc, .slave_configure = lpfc_slave_configure,
@@ -1473,7 +1446,7 @@ struct scsi_host_template lpfc_vport_template = { .info = lpfc_info, .queuecommand = lpfc_queuecommand, .eh_abort_handler = lpfc_abort_handler, - .eh_device_reset_handler= lpfc_device_reset_handler, + .eh_target_reset_handler= lpfc_target_reset_handler, .eh_bus_reset_handler = lpfc_bus_reset_handler, .slave_alloc = lpfc_slave_alloc, .slave_configure = lpfc_slave_configure,
Signature · 1 line
1.5.4.1
This patchset fixes the problem where scsi-ml will call the device reset handler for each logical unit, but some drivers are sending a target reset. Because we do not need to send a target reset multiple times, this patchset creates a new target reset callout which of course is called once per target instead of once per lu. It also cleans up the all the commands sent to the target when SUCCESS is returned.
qla4xxx, qla2xxx and lpfc were test with a hacked up sg_reset. I also sent lots of commands to the target and decreased the cmd timeout to 1 second so the scsi would run (turned off the eh abort callout too).
The arm scsi, mpt fusion, sym53c8xx_2, and a100u2w, and qla1280 drivers were only compile tested, but looked like the only needed a rename of the scsi eh handler.
The zfcp driver is also only compile tested. It was doing a lun reset and possibly target reset, so I split that up to use the device and target reset handlers. scsi-ml will escalate from the device to the target reset for the driver.
PATCH 1/5 scsi_error: add target reset handler
From: Mike Christie <[email protected]>
The problem is that serveral drivers are sending a target reset from the device reset handler, and if we have multiple devices a target reset gets sent for each device when only one would be sufficient. And if we do a target reset it affects all the commands on the target so the device reset handler code only cleaning up one devices's commands makes programming the driver a little more difficult than it should be.
This patch adds a target reset handler, which drivers can use to send a target reset. If successful it cleans up the commands for a devices accessed through that starget.
The next patches will convert drivers to use it.
--- drivers/scsi/scsi_error.c | 122 ++++++++++++++++++++++++++++++++++++++------- include/scsi/scsi_eh.h | 1 + include/scsi/scsi_host.h | 1 + 3 files changed, 106 insertions(+), 18 deletions(-)
drivers/scsi/scsi_error.c +104 -18
@@ -524,6 +524,41 @@ static int scsi_try_bus_reset(struct scsi_cmnd *scmd)return rtn; } +static void __scsi_report_device_reset (struct scsi_device *sdev,void *data) +{ + sdev->was_reset =1 ; + sdev->expecting_cc_ua =1 ; +} + +/** +* scsi_try_target_reset - Ask host to perform a target reset +* @scmd: SCSI cmd used to send a target reset +* +* Notes: +* There is no timeout for this operation. if this operation is +* unreliable for a given host, then the host itself needs to put a +* timer on it, and set the host back to a consistent state prior to +* returning. +*/ +static int scsi_try_target_reset (struct scsi_cmnd *scmd) +{ +unsigned long flags; +int rtn; + +if (!scmd->device->host->hostt->eh_target_reset_handler) +return FAILED ; + + rtn = scmd->device->host->hostt->eh_target_reset_handler (scmd); +if (rtn ==SUCCESS ) { +spin_lock_irqsave (scmd->device->host->host_lock, flags); +__starget_for_each_device (scsi_target (scmd->device),NULL , + __scsi_report_device_reset); +spin_unlock_irqrestore (scmd->device->host->host_lock, flags); + } + +return rtn; +} +/** * scsi_try_bus_device_reset - Ask host to perform a BDR on a dev * @scmd: SCSI cmd used to send BDR
@@ -542,11 +577,8 @@ static int scsi_try_bus_device_reset(struct scsi_cmnd *scmd)return FAILED ; rtn = scmd->device->host->hostt->eh_device_reset_handler (scmd); -if (rtn ==SUCCESS ) { - scmd->device->was_reset =1 ; - scmd->device->expecting_cc_ua =1 ; - } - +if (rtn ==SUCCESS ) +__scsi_report_device_reset (scmd->device,NULL );return rtn; }
@@ -584,8 +616,9 @@ static void scsi_abort_eh_cmnd(struct scsi_cmnd *scmd) {if (__scsi_try_to_abort_cmd (scmd) !=SUCCESS )if (scsi_try_bus_device_reset (scmd) !=SUCCESS ) -if (scsi_try_bus_reset (scmd) !=SUCCESS ) -scsi_try_host_reset (scmd); +if (scsi_try_target_reset (scmd) !=SUCCESS ) +if (scsi_try_bus_reset (scmd) !=SUCCESS ) +scsi_try_host_reset (scmd); }/**
@@ -1060,6 +1093,56 @@ static int scsi_eh_bus_device_reset(struct Scsi_Host *shost, }/** +* scsi_eh_target_reset - send target reset if needed +* @shost: scsi host being recovered. +* @work_q: &list_head for pending commands. +* @done_q: &list_head for processed commands. +* +* Notes: +* Try a target reset. +*/ +static int scsi_eh_target_reset (struct Scsi_Host *shost, +struct list_head *work_q, +struct list_head *done_q) +{ +struct scsi_cmnd *scmd, *tgtr_scmd, *next; +unsigned int id; +int rtn; + +for (id =0 ; id <= shost->max_id; id++) { + tgtr_scmd =NULL ; +list_for_each_entry (scmd, work_q, eh_entry) { +if (id ==scmd_id (scmd)) { + tgtr_scmd = scmd; +break ; + } + } +if (!tgtr_scmd) +continue ; + +SCSI_LOG_ERROR_RECOVERY (3 ,printk ("%s: Sending target reset " +"to target %d\n" , + current->comm, id)); + rtn =scsi_try_target_reset (tgtr_scmd); +if (rtn ==SUCCESS ) { +list_for_each_entry_safe (scmd, next, work_q, eh_entry) { +if (id ==scmd_id (scmd)) +if (!scsi_device_online (scmd->device) || + !scsi_eh_tur (tgtr_scmd)) +scsi_eh_finish_cmd (scmd, + done_q); + } + }else +SCSI_LOG_ERROR_RECOVERY (3 ,printk ("%s: Target reset" +" failed target: " +"%d\n" , + current->comm, id)); + } + +return list_empty (work_q); +} + +/** * scsi_eh_bus_reset - send a bus reset * @shost: &scsi host being recovered. * @work_q: &list_head for pending commands.
@@ -1447,9 +1530,11 @@ void scsi_eh_ready_devs(struct Scsi_Host *shost, {if (!scsi_eh_stu (shost, work_q, done_q))if (!scsi_eh_bus_device_reset (shost, work_q, done_q)) -if (!scsi_eh_bus_reset (shost, work_q, done_q)) -if (!scsi_eh_host_reset (work_q, done_q)) -scsi_eh_offline_sdevs (work_q, done_q); +if (!scsi_eh_target_reset (shost, work_q, done_q)) +if (!scsi_eh_bus_reset (shost, work_q, done_q)) +if (!scsi_eh_host_reset (work_q, done_q)) +scsi_eh_offline_sdevs (work_q, + done_q); }EXPORT_SYMBOL_GPL (scsi_eh_ready_devs);
@@ -1619,10 +1704,8 @@ void scsi_report_bus_reset(struct Scsi_Host *shost, int channel)struct scsi_device *sdev;__shost_for_each_device (sdev, shost) { -if (channel ==sdev_channel (sdev)) { - sdev->was_reset =1 ; - sdev->expecting_cc_ua =1 ; - } +if (channel ==sdev_channel (sdev)) +__scsi_report_device_reset (sdev,NULL ); } }EXPORT_SYMBOL (scsi_report_bus_reset);
@@ -1655,10 +1738,8 @@ void scsi_report_device_reset(struct Scsi_Host *shost, int channel, int target)__shost_for_each_device (sdev, shost) {if (channel ==sdev_channel (sdev) && - target ==sdev_id (sdev)) { - sdev->was_reset =1 ; - sdev->expecting_cc_ua =1 ; - } + target ==sdev_id (sdev)) +__scsi_report_device_reset (sdev,NULL ); } }EXPORT_SYMBOL (scsi_report_device_reset);
@@ -1714,6 +1795,11 @@ scsi_reset_provider(struct scsi_device *dev, int flag)if (rtn ==SUCCESS )break ;/* FALLTHROUGH */ +case SCSI_TRY_RESET_TARGET : + rtn =scsi_try_target_reset (scmd); +if (rtn ==SUCCESS ) +break ; +/* FALLTHROUGH */ case SCSI_TRY_RESET_BUS : rtn =scsi_try_bus_reset (scmd);if (rtn ==SUCCESS )
include/scsi/scsi_eh.h +1 -0
@@ -64,6 +64,7 @@ extern int scsi_get_sense_info_fld(const u8 * sense_buffer, int sb_len,#define SCSI_TRY_RESET_DEVICE 1#define SCSI_TRY_RESET_BUS 2#define SCSI_TRY_RESET_HOST 3 +#define SCSI_TRY_RESET_TARGET 4extern int scsi_reset_provider (struct scsi_device *,int );
include/scsi/scsi_host.h +1 -0
@@ -172,6 +172,7 @@ struct scsi_host_template {*/ int (* eh_abort_handler)(struct scsi_cmnd *);int (* eh_device_reset_handler)(struct scsi_cmnd *); +int (* eh_target_reset_handler)(struct scsi_cmnd *);int (* eh_bus_reset_handler)(struct scsi_cmnd *);int (* eh_host_reset_handler)(struct scsi_cmnd *);
Signature · 1 line
1.5.4.1
Oh yeah, the patches were made over scsi-rc-fixes, but can be applied over scsi-misc or 2.6.25-rc3.
Quoted 20 lines · [email protected] wrote:
This patchset fixes the problem where scsi-ml will call the device reset handler for each logical unit, but some drivers are sending a target reset. Because we do not need to send a target reset multiple times, this patchset creates a new target reset callout which of course is called once per target instead of once per lu. It also cleans up the all the commands sent to the target when SUCCESS is returned.
qla4xxx, qla2xxx and lpfc were test with a hacked up
sg_reset. I also sent lots of commands to the target and decreased the cmd timeout to 1 second so the scsi would run (turned off the eh abort callout too).The arm scsi, mpt fusion,
sym53c8xx_2, and a100u2w, and qla1280 drivers were only compile tested, but looked like the only needed a rename of the scsi eh handler.The zfcp driver is also only compile tested. It was doing a lun reset and possibly target reset, so I split that up to use the device and target reset handlers. scsi-ml will escalate from the device to the target reset for the driver.
Re: [PATCH 5/5] zfcp: convert zfcp to use target reset and device reset handler
In reply to [email protected]Quoted 8 lines · On Fri, Feb 29, 2008 at 06:25:23PM -0600, [email protected] wrote:
From: Mike Christie <[email protected]>
zfcp uses the device reset handler to try and send a lun reset. If that fails it then does a target reset. This patch has it do a lun reset in the target reset handler like other drivers, then do a target reset in the target reset handler.
scsi_error.cwill escalate from device reset to target reset for the driver.
Quoted 4 lines
This patch is only compile tested since suprisingly I could find a s390 box, but I could not hook storage into the the zfcp adapter (box was remote).
Signed-off-by Mike Christie <[email protected]>
Mike,
thank you very much for this work. I will reply to the mail with a adapted version of the patch: When we are implementing the target reset handler in zfcp, we can remove the decision what to do from zfcp and let the midlayer decide what should be reset.
--
Christof Schmitt
PATCH 1/1 zfcp: convert zfcp to use target reset and device reset handler
In reply to [email protected][based on proposal from Mike Christie <[email protected]>, this patch adds some simplifications to the handler functions]
With the new target reset handler callback in the SCSI midlayer, the device reset handler in zfcp can be split in two parts. Now, zfcp does not have to track anymore whether the device supports LUN resets, so remove this flag and let the SCSI midlayer decide what to do.
The device reset handler simply issues a LUN reset and the target reset handler a target reset.
--- drivers/s390/scsi/zfcp_def.h | 1 drivers/s390/scsi/zfcp_scsi.c | 62 ++++++++++++------------------------------ 2 files changed, 19 insertions(+), 44 deletions(-)
drivers/s390/scsi/zfcp_scsi.c +19 -43
@@ -31,6 +31,7 @@ static int zfcp_scsi_queuecommand(struct void (*done) (struct scsi_cmnd *));static int zfcp_scsi_eh_abort_handler (struct scsi_cmnd *);static int zfcp_scsi_eh_device_reset_handler (struct scsi_cmnd *); +static int zfcp_scsi_eh_target_reset_handler (struct scsi_cmnd *);static int zfcp_scsi_eh_host_reset_handler (struct scsi_cmnd *);static int zfcp_task_management_function (struct zfcp_unit *,u8 ,struct scsi_cmnd *);
@@ -51,6 +52,7 @@ struct zfcp_data zfcp_data = { .queuecommand = zfcp_scsi_queuecommand, .eh_abort_handler = zfcp_scsi_eh_abort_handler, .eh_device_reset_handler = zfcp_scsi_eh_device_reset_handler, + .eh_target_reset_handler = zfcp_scsi_eh_target_reset_handler, .eh_host_reset_handler = zfcp_scsi_eh_host_reset_handler, .can_queue = 4096, .this_id = -1,
@@ -442,58 +444,32 @@ static int zfcp_scsi_eh_abort_handler(streturn retval; } -static int -zfcp_scsi_eh_device_reset_handler (struct scsi_cmnd *scpnt) +static int zfcp_scsi_eh_device_reset_handler (struct scsi_cmnd *scpnt) {int retval;struct zfcp_unit *unit = (struct zfcp_unit *) scpnt->device->hostdata;if (!unit) { -ZFCP_LOG_NORMAL ("bug: Tried reset for nonexistent unit\n" ); - retval =SUCCESS ; - goto out; +BUG (); +return SUCCESS ; } -ZFCP_LOG_NORMAL ("resetting unit 0x%016Lx on port 0x%016Lx, adapter %s\n" , - unit->fcp_lun, unit->port->wwpn, -zfcp_get_busid_by_adapter (unit->port->adapter)); + retval =zfcp_task_management_function (unit, +FCP_LOGICAL_UNIT_RESET , + scpnt); +return retval ?FAILED :SUCCESS ; +} -/* -* If we do not know whether the unit supports 'logical unit reset' -* then try 'logical unit reset' and proceed with 'target reset' -* if 'logical unit reset' fails. -* If the unit is known not to support 'logical unit reset' then -* skip 'logical unit reset' and try 'target reset' immediately. -*/ -if (!atomic_test_mask (ZFCP_STATUS_UNIT_NOTSUPPUNITRESET , - &unit->status)) { - retval =zfcp_task_management_function (unit, -FCP_LOGICAL_UNIT_RESET , - scpnt); -if (retval) { -ZFCP_LOG_DEBUG ("unit reset failed (unit=%p)\n" , unit); -if (retval == -ENOTSUPP ) -atomic_set_mask - (ZFCP_STATUS_UNIT_NOTSUPPUNITRESET , - &unit->status); -/* fall through and try 'target reset' next */ - }else { -ZFCP_LOG_DEBUG ("unit reset succeeded (unit=%p)\n" , - unit); -/* avoid 'target reset' */ - retval =SUCCESS ; - goto out; - } +static int zfcp_scsi_eh_target_reset_handler (struct scsi_cmnd *scpnt) +{ +int retval; +struct zfcp_unit *unit = (struct zfcp_unit *) scpnt->device->hostdata; + +if (!unit) { +BUG (); +return SUCCESS ; } retval =zfcp_task_management_function (unit,FCP_TARGET_RESET , scpnt); -if (retval) { -ZFCP_LOG_DEBUG ("target reset failed (unit=%p)\n" , unit); - retval =FAILED ; - }else { -ZFCP_LOG_DEBUG ("target reset succeeded (unit=%p)\n" , unit); - retval =SUCCESS ; - } - out: -return retval; +return retval ?FAILED :SUCCESS ; } static int
drivers/s390/scsi/zfcp_def.h +0 -1
@@ -634,7 +634,6 @@ do { \ ZFCP_STATUS_PORT_NO_SCSI_ID)/* logical unit status */ -#define ZFCP_STATUS_UNIT_NOTSUPPUNITRESET 0x00000001#define ZFCP_STATUS_UNIT_TEMPORARY 0x00000002#define ZFCP_STATUS_UNIT_SHARED 0x00000004#define ZFCP_STATUS_UNIT_READONLY 0x00000008
Re: [PATCH] zfcp: convert zfcp to use target reset and device reset handler
Quoted 8 lines · Christof Schmitt
[based on proposal from Mike Christie <[email protected]>, this patch adds some simplifications to the handler functions]
With the new target reset handler callback in the SCSI midlayer, the device reset handler in zfcp can be split in two parts. Now, zfcp does not have to track anymore whether the device supports LUN resets, so remove this flag and let the SCSI midlayer decide what to do.
Quoted 4 lines
The device reset handler simply issues a LUN reset and the target reset handler a target reset.
Signed-off-by Christof Schmitt <[email protected]>
Thanks for the review and testing. Your patch looks better than mine.
Reviewed-by Mike Christie <[email protected]>
Re: [PATCH] zfcp: convert zfcp to use target reset and device reset handler
In reply to Christof Schmittdrivers/s390/scsi/zfcp_scsi.c static int zfcp_scsi_eh_abort_handler(st · line 469
Quoted 10 lines
drivers/s390/scsi/zfcp_scsi.c +5
-3if (!unit) { -ZFCP_LOG_NORMAL ("bug: Tried reset for nonexistent unit\n" ); - retval =SUCCESS ; - goto out; +BUG (); +return SUCCESS ; +if (!unit) { +BUG (); +return SUCCESS ;
Would you mind turning the BUG()s into WARN_ON(1)s? BUG() may crash the whole system, while WARN_ON() will just emit a warning and continue.
Re: [PATCH] zfcp: convert zfcp to use target reset and device reset handler
Quoted 5 lines · Heiko Carstens
Quoted 5 lines
drivers/s390/scsi/zfcp_scsi.c +1
-3if (!unit) { -ZFCP_LOG_NORMAL ("bug: Tried reset for nonexistent unit\n" ); - retval =SUCCESS ; - goto out; +BUG ();
Quoted 8 lines
drivers/s390/scsi/zfcp_scsi.c static int zfcp_scsi_eh_abort_handler(st · line 469
Quoted 5 lines
drivers/s390/scsi/zfcp_scsi.c +4
-0+return SUCCESS ; +if (!unit) { +BUG (); +return SUCCESS ;Would you mind turning the BUG()s into WARN_ON(1)s?
BUG()may crash the whole system, whileWARN_ON()will just emit a warning and continue.
Agree, WARN_ON is enough for these cases. I will followup with the changed patch.
--
Christof Schmitt
PATCH 1/1 zfcp: convert zfcp to use target reset and device reset handler
[based on proposal from Mike Christie <[email protected]>, this patch adds some simplifications to the handler functions]
With the new target reset handler callback in the SCSI midlayer, the device reset handler in zfcp can be split in two parts. Now, zfcp does not have to track anymore whether the device supports LUN resets, so remove this flag and let the SCSI midlayer decide what to do.
The device reset handler simply issues a LUN reset and the target reset handler a target reset.
--- drivers/s390/scsi/zfcp_def.h | 1 drivers/s390/scsi/zfcp_scsi.c | 62 ++++++++++++------------------------------ 2 files changed, 19 insertions(+), 44 deletions(-)
drivers/s390/scsi/zfcp_scsi.c +19 -43
@@ -31,6 +31,7 @@ static int zfcp_scsi_queuecommand(struct void (*done) (struct scsi_cmnd *));static int zfcp_scsi_eh_abort_handler (struct scsi_cmnd *);static int zfcp_scsi_eh_device_reset_handler (struct scsi_cmnd *); +static int zfcp_scsi_eh_target_reset_handler (struct scsi_cmnd *);static int zfcp_scsi_eh_host_reset_handler (struct scsi_cmnd *);static int zfcp_task_management_function (struct zfcp_unit *,u8 ,struct scsi_cmnd *);
@@ -51,6 +52,7 @@ struct zfcp_data zfcp_data = { .queuecommand = zfcp_scsi_queuecommand, .eh_abort_handler = zfcp_scsi_eh_abort_handler, .eh_device_reset_handler = zfcp_scsi_eh_device_reset_handler, + .eh_target_reset_handler = zfcp_scsi_eh_target_reset_handler, .eh_host_reset_handler = zfcp_scsi_eh_host_reset_handler, .can_queue = 4096, .this_id = -1,
@@ -442,58 +444,32 @@ static int zfcp_scsi_eh_abort_handler(streturn retval; } -static int -zfcp_scsi_eh_device_reset_handler (struct scsi_cmnd *scpnt) +static int zfcp_scsi_eh_device_reset_handler (struct scsi_cmnd *scpnt) {int retval;struct zfcp_unit *unit = (struct zfcp_unit *) scpnt->device->hostdata;if (!unit) { -ZFCP_LOG_NORMAL ("bug: Tried reset for nonexistent unit\n" ); - retval =SUCCESS ; - goto out; +WARN_ON (1 ); +return SUCCESS ; } -ZFCP_LOG_NORMAL ("resetting unit 0x%016Lx on port 0x%016Lx, adapter %s\n" , - unit->fcp_lun, unit->port->wwpn, -zfcp_get_busid_by_adapter (unit->port->adapter)); + retval =zfcp_task_management_function (unit, +FCP_LOGICAL_UNIT_RESET , + scpnt); +return retval ?FAILED :SUCCESS ; +} -/* -* If we do not know whether the unit supports 'logical unit reset' -* then try 'logical unit reset' and proceed with 'target reset' -* if 'logical unit reset' fails. -* If the unit is known not to support 'logical unit reset' then -* skip 'logical unit reset' and try 'target reset' immediately. -*/ -if (!atomic_test_mask (ZFCP_STATUS_UNIT_NOTSUPPUNITRESET , - &unit->status)) { - retval =zfcp_task_management_function (unit, -FCP_LOGICAL_UNIT_RESET , - scpnt); -if (retval) { -ZFCP_LOG_DEBUG ("unit reset failed (unit=%p)\n" , unit); -if (retval == -ENOTSUPP ) -atomic_set_mask - (ZFCP_STATUS_UNIT_NOTSUPPUNITRESET , - &unit->status); -/* fall through and try 'target reset' next */ - }else { -ZFCP_LOG_DEBUG ("unit reset succeeded (unit=%p)\n" , - unit); -/* avoid 'target reset' */ - retval =SUCCESS ; - goto out; - } +static int zfcp_scsi_eh_target_reset_handler (struct scsi_cmnd *scpnt) +{ +int retval; +struct zfcp_unit *unit = (struct zfcp_unit *) scpnt->device->hostdata; + +if (!unit) { +WARN_ON (1 ); +return SUCCESS ; } retval =zfcp_task_management_function (unit,FCP_TARGET_RESET , scpnt); -if (retval) { -ZFCP_LOG_DEBUG ("target reset failed (unit=%p)\n" , unit); - retval =FAILED ; - }else { -ZFCP_LOG_DEBUG ("target reset succeeded (unit=%p)\n" , unit); - retval =SUCCESS ; - } - out: -return retval; +return retval ?FAILED :SUCCESS ; } static int
drivers/s390/scsi/zfcp_def.h +0 -1
@@ -634,7 +634,6 @@ do { \ ZFCP_STATUS_PORT_NO_SCSI_ID)/* logical unit status */ -#define ZFCP_STATUS_UNIT_NOTSUPPUNITRESET 0x00000001#define ZFCP_STATUS_UNIT_TEMPORARY 0x00000002#define ZFCP_STATUS_UNIT_SHARED 0x00000004#define ZFCP_STATUS_UNIT_READONLY 0x00000008
Re: [PATCH] zfcp: convert zfcp to use target reset and device reset handler
drivers/s390/scsi/zfcp_scsi.c static int zfcp_scsi_eh_abort_handler(st · line 465
Quoted 4 lines · Christof Schmitt
drivers/s390/scsi/zfcp_scsi.c +4
-0+static int zfcp_scsi_eh_target_reset_handler (struct scsi_cmnd *scpnt) +{ +int retval; +struct zfcp_unit *unit = (struct zfcp_unit *) scpnt->device->hostdata;
Randomly spotted item. Isn't hostdata of type void *?
void *hostdata; /* available to low-level driver */
in which case, isn't that cast, which is being added, redundant?
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of:
Re: [PATCH] zfcp: convert zfcp to use target reset and device reset handler
Quoted 11 lines · Russell King
drivers/s390/scsi/zfcp_scsi.c static int zfcp_scsi_eh_abort_handler(st · line 465
Quoted 4 lines · Christof Schmitt
drivers/s390/scsi/zfcp_scsi.c +4
-0+static int zfcp_scsi_eh_target_reset_handler (struct scsi_cmnd *scpnt) +{ +int retval; +struct zfcp_unit *unit = (struct zfcp_unit *) scpnt->device->hostdata;Randomly spotted item. Isn't hostdata of type void *?
void *hostdata; /* available to low-level driver */
in which case, isn't that cast, which is being added, redundant?
True. The cast was there before, but only in the device_reset_handler. When touching the code now, we can as well remove it.
--
Christof Schmitt
PATCH 1/1 zfcp: convert zfcp to use target reset and device reset handler
In reply to Russell King[based on proposal from Mike Christie <[email protected]>, this patch adds some simplifications to the handler functions]
With the new target reset handler callback in the SCSI midlayer, the device reset handler in zfcp can be split in two parts. Now, zfcp does not have to track anymore whether the device supports LUN resets, so remove this flag and let the SCSI midlayer decide what to do.
The device reset handler simply issues a LUN reset and the target reset handler a target reset.
--- drivers/s390/scsi/zfcp_def.h | 1 drivers/s390/scsi/zfcp_scsi.c | 64 +++++++++++++----------------------------- 2 files changed, 20 insertions(+), 45 deletions(-)
drivers/s390/scsi/zfcp_scsi.c +20 -44
@@ -31,6 +31,7 @@ static int zfcp_scsi_queuecommand(struct void (*done) (struct scsi_cmnd *));static int zfcp_scsi_eh_abort_handler (struct scsi_cmnd *);static int zfcp_scsi_eh_device_reset_handler (struct scsi_cmnd *); +static int zfcp_scsi_eh_target_reset_handler (struct scsi_cmnd *);static int zfcp_scsi_eh_host_reset_handler (struct scsi_cmnd *);static int zfcp_task_management_function (struct zfcp_unit *,u8 ,struct scsi_cmnd *);
@@ -51,6 +52,7 @@ struct zfcp_data zfcp_data = { .queuecommand = zfcp_scsi_queuecommand, .eh_abort_handler = zfcp_scsi_eh_abort_handler, .eh_device_reset_handler = zfcp_scsi_eh_device_reset_handler, + .eh_target_reset_handler = zfcp_scsi_eh_target_reset_handler, .eh_host_reset_handler = zfcp_scsi_eh_host_reset_handler, .can_queue = 4096, .this_id = -1,
@@ -442,58 +444,32 @@ static int zfcp_scsi_eh_abort_handler(streturn retval; } -static int -zfcp_scsi_eh_device_reset_handler (struct scsi_cmnd *scpnt) +static int zfcp_scsi_eh_device_reset_handler (struct scsi_cmnd *scpnt) {int retval; -struct zfcp_unit *unit = (struct zfcp_unit *) scpnt->device->hostdata; +struct zfcp_unit *unit = scpnt->device->hostdata;if (!unit) { -ZFCP_LOG_NORMAL ("bug: Tried reset for nonexistent unit\n" ); - retval =SUCCESS ; - goto out; +WARN_ON (1 ); +return SUCCESS ; } -ZFCP_LOG_NORMAL ("resetting unit 0x%016Lx on port 0x%016Lx, adapter %s\n" , - unit->fcp_lun, unit->port->wwpn, -zfcp_get_busid_by_adapter (unit->port->adapter)); + retval =zfcp_task_management_function (unit, +FCP_LOGICAL_UNIT_RESET , + scpnt); +return retval ?FAILED :SUCCESS ; +} -/* -* If we do not know whether the unit supports 'logical unit reset' -* then try 'logical unit reset' and proceed with 'target reset' -* if 'logical unit reset' fails. -* If the unit is known not to support 'logical unit reset' then -* skip 'logical unit reset' and try 'target reset' immediately. -*/ -if (!atomic_test_mask (ZFCP_STATUS_UNIT_NOTSUPPUNITRESET , - &unit->status)) { - retval =zfcp_task_management_function (unit, -FCP_LOGICAL_UNIT_RESET , - scpnt); -if (retval) { -ZFCP_LOG_DEBUG ("unit reset failed (unit=%p)\n" , unit); -if (retval == -ENOTSUPP ) -atomic_set_mask - (ZFCP_STATUS_UNIT_NOTSUPPUNITRESET , - &unit->status); -/* fall through and try 'target reset' next */ - }else { -ZFCP_LOG_DEBUG ("unit reset succeeded (unit=%p)\n" , - unit); -/* avoid 'target reset' */ - retval =SUCCESS ; - goto out; - } +static int zfcp_scsi_eh_target_reset_handler (struct scsi_cmnd *scpnt) +{ +int retval; +struct zfcp_unit *unit = scpnt->device->hostdata; + +if (!unit) { +WARN_ON (1 ); +return SUCCESS ; } retval =zfcp_task_management_function (unit,FCP_TARGET_RESET , scpnt); -if (retval) { -ZFCP_LOG_DEBUG ("target reset failed (unit=%p)\n" , unit); - retval =FAILED ; - }else { -ZFCP_LOG_DEBUG ("target reset succeeded (unit=%p)\n" , unit); - retval =SUCCESS ; - } - out: -return retval; +return retval ?FAILED :SUCCESS ; } static int
drivers/s390/scsi/zfcp_def.h +0 -1
@@ -634,7 +634,6 @@ do { \ ZFCP_STATUS_PORT_NO_SCSI_ID)/* logical unit status */ -#define ZFCP_STATUS_UNIT_NOTSUPPUNITRESET 0x00000001#define ZFCP_STATUS_UNIT_TEMPORARY 0x00000002#define ZFCP_STATUS_UNIT_SHARED 0x00000004#define ZFCP_STATUS_UNIT_READONLY 0x00000008
Quoted 12 lines · Mike Christie
This patchset fixes the problem where scsi-ml will call the device reset
handler for each logical unit, but some drivers are sending a target reset. Because we do not need to send a target reset multiple times, this patchset creates a new target reset callout which of course is called once per target instead of once per lu. It also cleans up the all the commands sent to the target when SUCCESS is returned.qla4xxx, qla2xxx and lpfc were test with a hacked up
sg_reset. I also sent lots of commands to the target and decreased the cmd timeout to 1 second so the scsi would run (turned off the eh abort callout too).
Quoted 10 lines
The arm scsi, mpt fusion,
sym53c8xx_2, and a100u2w, and qla1280 drivers were only compile tested, but looked like the only needed a rename of the scsi eh handler.The zfcp driver is also only compile tested. It was doing a lun reset and possibly target reset, so I split that up to use the device and target reset handlers. scsi-ml will escalate from the device to the target reset for the driver.
The fusion firmware supports Logical Unit Reset, so why not fix mptscsih_dev_reset so its passing MPI_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET, and lun number to mptscsih_TMHandler, and create the new function mptscsih_target_reset as you've done?
Eric
Quoted 23 lines · Eric
Quoted 11 lines · Mike Christie
This patchset fixes the problem where scsi-ml will call the device reset handler for each logical unit, but some drivers are sending a target reset. Because we do not need to send a target reset multiple times, this patchset creates a new target reset callout which of course is called once per target instead of once per lu. It also cleans up the all the commands sent to the target when SUCCESS is returned.
qla4xxx, qla2xxx and lpfc were test with a hacked up
sg_reset. I also sent lots of commands to the target and decreased the cmd timeout to 1 second so the scsi would run (turned off the eh abort callout too).Quoted 10 lines
The arm scsi, mpt fusion,
sym53c8xx_2, and a100u2w, and qla1280 drivers were only compile tested, but looked like the only needed a rename of the scsi eh handler.The zfcp driver is also only compile tested. It was doing a lun reset and possibly target reset, so I split that up to use the device and target reset handlers. scsi-ml will escalate from the device to the target reset for the driver.
Quoted 6 lines
The fusion firmware supports Logical Unit Reset, so why not fix
mptscsih_dev_resetso its passingMPI_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET, and lun number tomptscsih_TMHandler, and create the new functionmptscsih_target_resetas you've done?
I did not do this because I was not trying to add new functionality. I was just trying to fix what was there.
How about I add the LU reset support in a separate patch, so git revert will be kinder to me?
There was also some side discussion about side affects of doing a lu reset and if we need to be doing something more than what we do today from the device reset handler, so I did not want to dig into that in this patchset. I am just trying to get target reset done in the proper place on this pass. In later patches I want to tackle TMFs like lu reset, abort task set, etc.
Quoted 11 lines · Mike Christie
Quoted 4 lines
The fusion firmware supports Logical Unit Reset, so why not fix
mptscsih_dev_resetso its passingMPI_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET, and lun number tomptscsih_TMHandler, and create the new function
mptscsih_target_resetasQuoted 2 lines
you've done?
I did not do this because I was not trying to add new functionality. I
was just trying to fix what was there.
No problem, lets go for what you've done already, thanks,
Quoted 5 lines
How about I add the LU reset support in a separate patch, so git revert
will be kinder to me?
Seperate patch, no problem.
Quoted 8 lines
There was also some side discussion about side affects of doing a lu reset and if we need to be doing something more than what we do today from the device reset handler, so I did not want to dig into that in this patchset. I am just trying to get target reset done in the proper
place on this pass. In later patches I want to tackle TMFs like lu reset, abort task set, etc.
I'm pretty sure that windows supports LU Reset callback handlers, instead of target reset. I'm not sure if there are any side effects, for instance non supported devices. I've copied Steve Hagan, perhaps he might have some feedback on that.
Is there any chance for TM callback support in the transport, for instance in SAS, we have phy, link and hard reset. I believe the current support is manually invoked via sysfs.
Eric
Windows (StorPort drivers) supports LUN, target, and bus resets in a hierarchical fashion. If an I/O times out, Storport will issue a LUN reset first. If that fails, it will escalate to a target reset. If that fails, it will escalate to a bus reset.
What does "fail" mean? If the TM request returns with a non-success status, or if there are outstanding I/O's for the scope of the reset remaining after we receive the TM reply, then the reset is considered failed. Our miniport driver will return error status back to Storport and it will escalate to the next level of reset. A bus reset cannot be failed back to Storport. If a bus reset fails (as above) then the only recourse if for the miniport to do a hard reset of the adapter and return all outstanding I/O's with reset status.
Steve H.
-----Original Message-----
From: Moore, Eric
Sent: Tuesday, March 04, 2008 11:35 AM
To: Mike Christie
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Hagan, Steve; Rivera, Peter; Prakash, Sathya
Subject: RE: scsi: fix target reset handling
Quoted 11 lines · Mike Christie
Quoted 4 lines
The fusion firmware supports Logical Unit Reset, so why not fix
mptscsih_dev_resetso its passingMPI_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET, and lun number tomptscsih_TMHandler, and create the new function
mptscsih_target_resetasQuoted 2 lines
you've done?
I did not do this because I was not trying to add new functionality. I
was just trying to fix what was there.
No problem, lets go for what you've done already, thanks,
Quoted 4 lines
How about I add the LU reset support in a separate patch, so git revert will be kinder to me?
Seperate patch, no problem.
Quoted 8 lines
There was also some side discussion about side affects of doing a lu reset and if we need to be doing something more than what we do today from the device reset handler, so I did not want to dig into that in this patchset. I am just trying to get target reset done in the proper
place on this pass. In later patches I want to tackle TMFs like lu reset, abort task set, etc.
I'm pretty sure that windows supports LU Reset callback handlers, instead of target reset. I'm not sure if there are any side effects, for instance non supported devices. I've copied Steve Hagan, perhaps he might have some feedback on that.
Is there any chance for TM callback support in the transport, for instance in SAS, we have phy, link and hard reset. I believe the current support is manually invoked via sysfs.
Eric
James Bottomley
maintainerQuoted 6 lines · Steve
Windows (StorPort drivers) supports LUN, target, and bus resets in a hierarchical fashion. If an I/O times out, Storport will issue a LUN reset first. If that fails, it will escalate to a target reset. If that fails, it will escalate to a bus reset.
What does "fail" mean?
Fail means the driver was unable to perform the action. i.e failure of a LUN reset means we couldn't get the TMF out.
Quoted 4 lines
If the TM request returns with a non-success
status, or if there are outstanding I/O's for the scope of the reset remaining after we receive the TM reply, then the reset is considered failed.
Outstanding I/O is a dubious point. Your driver could have outstanding I/O for the LUN after a LUN reset, but if the device correctly executed it, it will have cleared its queue.
Quoted 5 lines
Our miniport driver will return error status back to Storport
and it will escalate to the next level of reset. A bus reset cannot be failed back to Storport. If a bus reset fails (as above) then the only recourse if for the miniport to do a hard reset of the adapter and return all outstanding I/O's with reset status.
That's pretty much what the default error handler does.
James
Re: [PATCH 3/5] Convert qla2xxx, mpt, arm, sym, a100u2w, qla1280 to target reset handler
In reply to [email protected]Quoted 7 lines · On Fri, 29 Feb 2008, [email protected] wrote:
From: Mike Christie <[email protected]>
This patch converts the drivers that just needed a rename from "deivce" to "target" to use the target reset handler. This includes qla2xxx, mpt, arm/*,
sym53c8xx_2, a100u2w and qla1280.Signed-off-by Mike Christie <[email protected]>
Quoted 15 lines
--- drivers/message/fusion/mptfc.c | 8 +++--- drivers/message/fusion/mptsas.c | 8 +++--- drivers/message/fusion/mptscsih.c | 8 +++--- drivers/message/fusion/mptscsih.h | 2 +- drivers/message/fusion/mptspi.c | 2 +- drivers/scsi/a100u2w.c | 12 +++++----- drivers/scsi/arm/arxescsi.c | 2 +- drivers/scsi/arm/cumana_2.c | 2 +- drivers/scsi/arm/eesox.c | 2 +- drivers/scsi/arm/fas216.c | 6 ++-- drivers/scsi/arm/fas216.h | 4 +- drivers/scsi/arm/powertec.c | 2 +- drivers/scsi/qla1280.c | 30 ++++++++++++------------ drivers/scsi/qla2xxx/qla_os.c | 42 +++++++++++++++++-----------------
Mike,
Thanks for doing this. In looking at the changes needed to support both device and lun resets, there's some significant cleanup and code consolidation which can easily occur. Your qla2xxx changes currently conflict with my a several commits in my 2.6.26 patch-queue. Would you mind if I carry the qla2xxx updates in my tree and push when the infrastructure updates are present in scsi-misc-2.6? As it stands, here's a snapshot of the composite LUN/Target-reset updates for qla2xxx which I have testing locally. The commit should make it to my public tree in the next few days:
git://git.qlogic.com/qla2xxx-upstream.git
Thanks,
AV
---
drivers/scsi/qla2xxx/qla_def.h +2 -1
@@ -2062,7 +2062,8 @@ struct isp_operations {void (*disable_intrs) (struct scsi_qla_host *);int (*abort_command) (struct scsi_qla_host *,srb_t *); -int (*abort_target) (struct fc_port *); +int (*target_reset) (struct fc_port *,unsigned int ); +int (*lun_reset) (struct fc_port *,unsigned int );int (*fabric_login) (struct scsi_qla_host *,uint16_t ,uint8_t ,uint8_t ,uint8_t ,uint16_t *,uint8_t ); int (*fabric_logout) (struct scsi_qla_host *, uint16_t, uint8_t,
drivers/scsi/qla2xxx/qla_fw.h +1 -1
@@ -719,7 +719,7 @@ struct tsk_mgmt_entry {uint16_t timeout;/* Command timeout. */ -uint8_t lun[8 ];/* FCP LUN (BE). */ +struct scsi_lun lun;/* FCP LUN (BE). */ uint32_t control_flags;/* Control Flags. */ #define TCF_NOTMCMD_TO_TARGET BIT_31
drivers/scsi/qla2xxx/qla_gbl.h +6 -2
@@ -153,7 +153,10 @@ extern int qla2x00_abort_command(scsi_qla_host_t *, srb_t *);extern int -qla2x00_abort_target (fc_port_t *); +qla2x00_abort_target (struct fc_port *,unsigned int ); + +extern int +qla2x00_lun_reset (struct fc_port *,unsigned int ); extern int qla2x00_get_adapter_id(scsi_qla_host_t *, uint16_t *, uint8_t *, uint8_t *,
@@ -219,7 +222,8 @@ qla24xx_get_isp_stats(scsi_qla_host_t *, struct link_statistics *, dma_addr_t);extern int qla24xx_abort_command (scsi_qla_host_t *,srb_t *); -extern int qla24xx_abort_target (fc_port_t *); +extern int qla24xx_abort_target (struct fc_port *,unsigned int ); +extern int qla24xx_lun_reset (struct fc_port *,unsigned int );extern int qla2x00_set_serdes_params (scsi_qla_host_t *,uint16_t ,uint16_t ,uint16_t );
drivers/scsi/qla2xxx/qla_mbx.c +82 -41
203 lines not on this page · raw message
drivers/scsi/qla2xxx/qla_os.c +101 -153
357 lines not on this page · raw message
Re: [PATCH 3/5] Convert qla2xxx, mpt, arm, sym, a100u2w, qla1280 to target reset handler
Quoted 25 lines · Andrew Vasquez
Quoted 7 lines · On Fri, 29 Feb 2008, [email protected] wrote:
From: Mike Christie <[email protected]>
This patch converts the drivers that just needed a rename from "deivce" to "target" to use the target reset handler. This includes qla2xxx, mpt, arm/*,
sym53c8xx_2, a100u2w and qla1280.Signed-off-by Mike Christie <[email protected]>Quoted 15 lines
--- drivers/message/fusion/mptfc.c | 8 +++--- drivers/message/fusion/mptsas.c | 8 +++--- drivers/message/fusion/mptscsih.c | 8 +++--- drivers/message/fusion/mptscsih.h | 2 +- drivers/message/fusion/mptspi.c | 2 +- drivers/scsi/a100u2w.c | 12 +++++----- drivers/scsi/arm/arxescsi.c | 2 +- drivers/scsi/arm/cumana_2.c | 2 +- drivers/scsi/arm/eesox.c | 2 +- drivers/scsi/arm/fas216.c | 6 ++-- drivers/scsi/arm/fas216.h | 4 +- drivers/scsi/arm/powertec.c | 2 +- drivers/scsi/qla1280.c | 30 ++++++++++++------------ drivers/scsi/qla2xxx/qla_os.c | 42 +++++++++++++++++-----------------
Quoted 8 lines
Mike,
Thanks for doing this. In looking at the changes needed to support both device and lun resets, there's some significant cleanup and code consolidation which can easily occur. Your qla2xxx changes currently conflict with my a several commits in my 2.6.26 patch-queue. Would you mind if I carry the qla2xxx updates in my tree and push when the infrastructure updates are present in scsi-misc-2.6? As it stands,
That sounds good.
Quoted 6 lines
here's a snapshot of the composite LUN/Target-reset updates for qla2xxx which I have testing locally. The commit should make it to my public tree in the next few days:
git://git.qlogic.com/qla2xxx-upstream.git
Thanks.
Re: [PATCH 4/5] lpfc: convert lpfc to use target reset handler.
In reply to [email protected]fyi: this patch has been superceeded by :
http://marc.info/?l=linux-scsi&m=120880973719266&w=2
-- james s
Quoted 227 lines · [email protected] wrote:
From: Mike Christie <[email protected]>
lpfc is sending a target reset from the device reset handler, so this patch just has it use the target reset handler.
This patch also has the driver use
CTX_TGTinstead ofCTX_LUNin the target reset handler. It looked like a bug.One thing I was not sure of was if
lpfc_scsi_tgt_resetfails, but the caller ends up callinglpfc_sli_abort_iocband that aborts all the commands for the context that is requested and those are all cleaned up by the driver/firmware, should we return SUCCESS.This patch should wait for James Smart. I think he is on vacation, but the driver will work without the patch like it did before, so it is not required that this patch be merged with the rest.
Signed-off-by Mike Christie <[email protected]>--- drivers/scsi/lpfc/lpfc_scsi.c | 85 ++++++++++++++--------------------------- 1 files changed, 29 insertions(+), 56 deletions(-)drivers/scsi/lpfc/lpfc_scsi.c +29
-56@@ -835,13 +835,15 @@ lpfc_tskmgmt_def_cmpl(struct lpfc_hba *phba,static int lpfc_scsi_tgt_reset (struct lpfc_scsi_buf *lpfc_cmd,struct lpfc_vport *vport,unsigned tgt_id,unsigned int lun, -struct lpfc_rport_data *rdata) +struct lpfc_rport_data *rdata,int *iocb_status) {struct lpfc_hba *phba = vport->phba;struct lpfc_iocbq *iocbq;struct lpfc_iocbq *iocbqrsp;int ret; + *iocb_status =0 ; +if (!rdata->pnode)return FAILED ;@@ -861,13 +863,14 @@ lpfc_scsi_tgt_reset(struct lpfc_scsi_buf *lpfc_cmd, struct lpfc_vport *vport,lpfc_printf_vlog (vport,KERN_INFO ,LOG_FCP ,"0702 Issue Target Reset to TGT %d Data: x%x x%x\n" , tgt_id, rdata->pnode->nlp_rpi, rdata->pnode->nlp_flag); - ret =lpfc_sli_issue_iocb_wait (phba, + *iocb_status =lpfc_sli_issue_iocb_wait (phba, &phba->sli.ring[phba->sli.fcp_ring], iocbq, iocbqrsp, lpfc_cmd->timeout); -if (ret !=IOCB_SUCCESS ) { -if (ret ==IOCB_TIMEDOUT ) +if (*iocb_status !=IOCB_SUCCESS ) { +if (*iocb_status ==IOCB_TIMEDOUT ) iocbq->iocb_cmpl = lpfc_tskmgmt_def_cmpl; lpfc_cmd->status =IOSTAT_DRIVER_REJECT ; + ret =FAILED ; }else { ret =SUCCESS ; lpfc_cmd->result = iocbqrsp->iocb.un.ulpWord[4 ];@@ -1125,16 +1128,14 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd) }static int -lpfc_device_reset_handler (struct scsi_cmnd *cmnd) +lpfc_target_reset_handler (struct scsi_cmnd *cmnd) {struct Scsi_Host *shost = cmnd->device->host;struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;struct lpfc_hba *phba = vport->phba;struct lpfc_scsi_buf *lpfc_cmd; -struct lpfc_iocbq *iocbq, *iocbqrsp;struct lpfc_rport_data *rdata = cmnd->device->hostdata;struct lpfc_nodelist *pnode = rdata->pnode; -uint32_t cmd_result =0 , cmd_status =0 ;int ret =FAILED ;int iocb_status =IOCB_SUCCESS ;int cnt, loopcnt;@@ -1156,7 +1157,7 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd)if (!rdata || (loopcnt > ((vport->cfg_devloss_tmo *2 ) +1 ))){lpfc_printf_vlog (vport,KERN_ERR ,LOG_FCP , -"0721 LUN Reset rport " +"0721 Target Reset rport " "failure: cnt x%x rdata x%p\n" , loopcnt, rdata); goto out;@@ -1174,52 +1175,20 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd) goto out; lpfc_cmd->timeout =60 ; - lpfc_cmd->rdata = rdata; - - ret =lpfc_scsi_prep_task_mgmt_cmd (vport, lpfc_cmd, cmnd->device->lun, -FCP_TARGET_RESET ); -if (!ret) - goto out_free_scsi_buf; - - iocbq = &lpfc_cmd->cur_iocbq; - -/* get a buffer for this IOCB command response */ - iocbqrsp =lpfc_sli_get_iocbq (phba); -if (iocbqrsp ==NULL ) - goto out_free_scsi_buf; - -lpfc_printf_vlog (vport,KERN_INFO ,LOG_FCP , -"0703 Issue target reset to TGT %d LUN %d " -"rpi x%x nlp_flag x%x\n" , cmnd->device->id, - cmnd->device->lun, pnode->nlp_rpi, pnode->nlp_flag); - iocb_status =lpfc_sli_issue_iocb_wait (phba, - &phba->sli.ring[phba->sli.fcp_ring], - iocbq, iocbqrsp, lpfc_cmd->timeout); - -if (iocb_status ==IOCB_TIMEDOUT ) - iocbq->iocb_cmpl = lpfc_tskmgmt_def_cmpl; - -if (iocb_status ==IOCB_SUCCESS ) - ret =SUCCESS ; -else - ret = iocb_status; - - cmd_result = iocbqrsp->iocb.un.ulpWord[4 ]; - cmd_status = iocbqrsp->iocb.ulpStatus; - -lpfc_sli_release_iocbq (phba, iocbqrsp); + ret =lpfc_scsi_tgt_reset (lpfc_cmd, vport, cmnd->device->id, + cmnd->device->lun, rdata, &iocb_status);/* * All outstanding txcmplq I/Os should have been aborted by the device. * Unfortunately, some targets do not abide by this forcing the driver * to double check. */ cnt =lpfc_sli_sum_iocb (vport, cmnd->device->id, cmnd->device->lun, -LPFC_CTX_LUN ); +LPFC_CTX_TGT );if (cnt)lpfc_sli_abort_iocb (vport, &phba->sli.ring[phba->sli.fcp_ring], cmnd->device->id, cmnd->device->lun, -LPFC_CTX_LUN ); +LPFC_CTX_TGT ); loopcnt =0 ;while (cnt) {schedule_timeout_uninterruptible (LPFC_RESET_WAIT *HZ );@@ -1229,25 +1198,29 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd)break ; cnt =lpfc_sli_sum_iocb (vport, cmnd->device->id, - cmnd->device->lun,LPFC_CTX_LUN ); + cmnd->device->lun,LPFC_CTX_TGT ); } +/* +* if lpfc_scsi_tgt_reset returned FAILED but lpfc_sli_abort_iocb +* got run above and that aborted all the commands and cnt=0, should +* we return SUCCESS because at least the commands were unstuck? +*/ if (cnt) {lpfc_printf_vlog (vport,KERN_ERR ,LOG_FCP , -"0719 device reset I/O flush failure: " +"0719 target reset I/O flush failure: " "cnt x%x\n" , cnt); ret =FAILED ; } -out_free_scsi_buf:if (iocb_status !=IOCB_TIMEDOUT ) {lpfc_release_scsi_buf (phba, lpfc_cmd); }lpfc_printf_vlog (vport,KERN_ERR ,LOG_FCP , -"0713 SCSI layer issued device reset (%d, %d) " +"0713 SCSI layer issued target reset (%d) " "return x%x status x%x result x%x\n" , - cmnd->device->id, cmnd->device->lun, ret, - cmd_status, cmd_result); + cmnd->device->id, ret, + lpfc_cmd->status, lpfc_cmd->result); out:return ret; }@@ -1263,6 +1236,7 @@ lpfc_bus_reset_handler(struct scsi_cmnd *cmnd)int ret =FAILED , i, err_count =0 ;int cnt, loopcnt;struct lpfc_scsi_buf * lpfc_cmd; +int iocb_status =IOCB_SUCCESS ;lpfc_block_error_handler (cmnd);@@ -1296,9 +1270,8 @@ lpfc_bus_reset_handler(struct scsi_cmnd *cmnd)if (!match)continue ; - ret =lpfc_scsi_tgt_reset (lpfc_cmd, vport, i, - cmnd->device->lun, - ndlp->rport->dd_data); + ret =lpfc_scsi_tgt_reset (lpfc_cmd, vport, i, cmnd->device->lun, + ndlp->rport->dd_data, &iocb_status);if (ret !=SUCCESS ) { lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP, "0700 Bus Reset on target %d failed\n",@@ -1308,7 +1281,7 @@ lpfc_bus_reset_handler(struct scsi_cmnd *cmnd) } } -if (ret !=IOCB_TIMEDOUT ) +if (iocb_status !=IOCB_TIMEDOUT )lpfc_release_scsi_buf (phba, lpfc_cmd);if (err_count ==0 )@@ -1453,7 +1426,7 @@ struct scsi_host_template lpfc_template = { .info = lpfc_info, .queuecommand = lpfc_queuecommand, .eh_abort_handler = lpfc_abort_handler, - .eh_device_reset_handler= lpfc_device_reset_handler, + .eh_target_reset_handler= lpfc_target_reset_handler, .eh_bus_reset_handler = lpfc_bus_reset_handler, .slave_alloc = lpfc_slave_alloc, .slave_configure = lpfc_slave_configure,@@ -1473,7 +1446,7 @@ struct scsi_host_template lpfc_vport_template = { .info = lpfc_info, .queuecommand = lpfc_queuecommand, .eh_abort_handler = lpfc_abort_handler, - .eh_device_reset_handler= lpfc_device_reset_handler, + .eh_target_reset_handler= lpfc_target_reset_handler, .eh_bus_reset_handler = lpfc_bus_reset_handler, .slave_alloc = lpfc_slave_alloc, .slave_configure = lpfc_slave_configure,