* scsi: fix target reset handling
@ 2008-03-01 0:25 michaelc
2008-03-01 0:25 ` [PATCH 1/5] scsi_error: add target reset handler michaelc
` (2 more replies)
0 siblings, 3 replies; 24+ messages in thread
From: michaelc @ 2008-03-01 0:25 UTC (permalink / raw)
To: linux-scsi, Eric.Moore, james.smart, andrew.vasquez,
christof.schmitt, mp3, rmk, matthew
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.
^ permalink raw reply [flat|nested] 24+ messages in thread* [PATCH 1/5] scsi_error: add target reset handler 2008-03-01 0:25 scsi: fix target reset handling michaelc @ 2008-03-01 0:25 ` michaelc 2008-03-01 0:25 ` [PATCH 2/5] qla4xxx: Add target reset functionality michaelc 2008-03-01 0:27 ` scsi: fix target reset handling Mike Christie 2008-03-03 17:06 ` Moore, Eric 2 siblings, 1 reply; 24+ messages in thread From: michaelc @ 2008-03-01 0:25 UTC (permalink / raw) To: linux-scsi, Eric.Moore, james.smart, andrew.vasquez, christof.schmitt, mp3, rmk, matthew Cc: Mike Christie From: Mike Christie <michaelc@cs.wisc.edu> 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. Signed-off-by: Mike Christie <michaelc@cs.wisc.edu> --- 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(-) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 045a086..1221d2c 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -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) diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h index 25071d5..37a7614 100644 --- a/include/scsi/scsi_eh.h +++ b/include/scsi/scsi_eh.h @@ -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 4 extern int scsi_reset_provider(struct scsi_device *, int); diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 530ff4c..4913286 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -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 *); -- 1.5.4.1 ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 2/5] qla4xxx: Add target reset functionality 2008-03-01 0:25 ` [PATCH 1/5] scsi_error: add target reset handler michaelc @ 2008-03-01 0:25 ` michaelc 2008-03-01 0:25 ` [PATCH 3/5] Convert qla2xxx, mpt, arm, sym, a100u2w, qla1280 to target reset handler michaelc 0 siblings, 1 reply; 24+ messages in thread From: michaelc @ 2008-03-01 0:25 UTC (permalink / raw) To: linux-scsi, Eric.Moore, james.smart, andrew.vasquez, christof.schmitt, mp3, rmk, matthew Cc: Mike Christie From: Mike Christie <michaelc@cs.wisc.edu> This patch adds target reset functionalty. Signed-off-by: Mike Christie <michaelc@cs.wisc.edu> Acked-by: David Somayajulu <david.somayajulu@qlogic.com> --- 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(-) diff --git a/drivers/scsi/qla4xxx/ql4_fw.h b/drivers/scsi/qla4xxx/ql4_fw.h index fe415ec..ed8ee66 100644 --- a/drivers/scsi/qla4xxx/ql4_fw.h +++ b/drivers/scsi/qla4xxx/ql4_fw.h @@ -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 diff --git a/drivers/scsi/qla4xxx/ql4_glbl.h b/drivers/scsi/qla4xxx/ql4_glbl.h index a3608e0..b403a17 100644 --- a/drivers/scsi/qla4xxx/ql4_glbl.h +++ b/drivers/scsi/qla4xxx/ql4_glbl.h @@ -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); diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c index 35cd73c..c577d79 100644 --- a/drivers/scsi/qla4xxx/ql4_mbx.c +++ b/drivers/scsi/qla4xxx/ql4_mbx.c @@ -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) diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index c3c59d7..8c31fe5 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c @@ -71,6 +71,7 @@ static void qla4xxx_recovery_timedout(struct iscsi_cls_session *session); static int qla4xxx_queuecommand(struct scsi_cmnd *cmd, void (*done) (struct scsi_cmnd *)); static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd); +static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd); static int qla4xxx_eh_host_reset(struct scsi_cmnd *cmd); static int qla4xxx_slave_alloc(struct scsi_device *device); static int qla4xxx_slave_configure(struct scsi_device *device); @@ -83,6 +84,7 @@ static struct scsi_host_template qla4xxx_driver_template = { .queuecommand = qla4xxx_queuecommand, .eh_device_reset_handler = qla4xxx_eh_device_reset, + .eh_target_reset_handler = qla4xxx_eh_target_reset, .eh_host_reset_handler = qla4xxx_eh_host_reset, .slave_configure = qla4xxx_slave_configure, @@ -1478,7 +1480,7 @@ static int qla4xxx_wait_for_hba_online(struct scsi_qla_host *ha) } /** - * qla4xxx_eh_wait_for_active_target_commands - wait for active cmds to finish. + * qla4xxx_eh_wait_for_commands - wait for active cmds to finish. * @ha: pointer to to HBA * @t: target id * @l: lun id @@ -1486,20 +1488,22 @@ static int qla4xxx_wait_for_hba_online(struct scsi_qla_host *ha) * This function waits for all outstanding commands to a lun to complete. It * returns 0 if all pending commands are returned and 1 otherwise. **/ -static int qla4xxx_eh_wait_for_active_target_commands(struct scsi_qla_host *ha, - int t, int l) +static int qla4xxx_eh_wait_for_commands(struct scsi_qla_host *ha, + struct scsi_target *stgt, + struct scsi_device *sdev) { int cnt; int status = 0; struct scsi_cmnd *cmd; /* - * Waiting for all commands for the designated target in the active - * array + * Waiting for all commands for the designated target or dev + * in the active array */ for (cnt = 0; cnt < ha->host->can_queue; cnt++) { cmd = scsi_host_find_tag(ha->host, cnt); - if (cmd && cmd->device->id == t && cmd->device->lun == l) { + if (cmd && stgt == scsi_target(cmd->device) && + (!sdev || sdev == cmd->device)) { if (!qla4xxx_eh_wait_on_command(ha, cmd)) { status++; break; @@ -1547,19 +1551,12 @@ static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd) /* Send marker. */ ha->marker_needed = 1; - /* - * If we are coming down the EH path, wait for all commands to complete - * for the device. - */ - if (cmd->device->host->shost_state == SHOST_RECOVERY) { - if (qla4xxx_eh_wait_for_active_target_commands(ha, - cmd->device->id, - cmd->device->lun)){ - dev_info(&ha->pdev->dev, - "DEVICE RESET FAILED - waiting for " - "commands.\n"); - goto eh_dev_reset_done; - } + if (qla4xxx_eh_wait_for_commands(ha, scsi_target(cmd->device), + cmd->device)) { + dev_info(&ha->pdev->dev, + "DEVICE RESET FAILED - waiting for " + "commands.\n"); + goto eh_dev_reset_done; } dev_info(&ha->pdev->dev, @@ -1575,6 +1572,53 @@ eh_dev_reset_done: } /** + * qla4xxx_eh_target_reset - callback for target reset. + * @cmd: Pointer to Linux's SCSI command structure + * + * This routine is called by the Linux OS to reset the target. + **/ +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; + int stat; + + if (!ddb_entry) + return FAILED; + + starget_printk(KERN_INFO, scsi_target(cmd->device), + "WARM TARGET RESET ISSUED.\n"); + + DEBUG2(printk(KERN_INFO + "scsi%ld: TARGET_DEVICE_RESET cmd=%p jiffies = 0x%lx, " + "to=%x,dpc_flags=%lx, status=%x allowed=%d\n", + ha->host_no, cmd, jiffies, cmd->timeout_per_command / HZ, + ha->dpc_flags, cmd->result, cmd->allowed)); + + stat = qla4xxx_reset_target(ha, ddb_entry); + if (stat != QLA_SUCCESS) { + starget_printk(KERN_INFO, scsi_target(cmd->device), + "WARM TARGET RESET FAILED.\n"); + return FAILED; + } + + /* Send marker. */ + ha->marker_needed = 1; + + if (qla4xxx_eh_wait_for_commands(ha, scsi_target(cmd->device), + NULL)) { + starget_printk(KERN_INFO, scsi_target(cmd->device), + "WARM TARGET DEVICE RESET FAILED - " + "waiting for commands.\n"); + return FAILED; + } + + starget_printk(KERN_INFO, scsi_target(cmd->device), + "WARM TARGET RESET SUCCEEDED.\n"); + return SUCCESS; +} + +/** * qla4xxx_eh_host_reset - kernel callback * @cmd: Pointer to Linux's SCSI command structure * -- 1.5.4.1 ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 3/5] Convert qla2xxx, mpt, arm, sym, a100u2w, qla1280 to target reset handler 2008-03-01 0:25 ` [PATCH 2/5] qla4xxx: Add target reset functionality michaelc @ 2008-03-01 0:25 ` michaelc 2008-03-01 0:25 ` [PATCH 4/5] lpfc: convert lpfc to use " michaelc 2008-03-05 5:08 ` [PATCH 3/5] Convert qla2xxx, mpt, arm, sym, a100u2w, qla1280 to " Andrew Vasquez 0 siblings, 2 replies; 24+ messages in thread From: michaelc @ 2008-03-01 0:25 UTC (permalink / raw) To: linux-scsi, Eric.Moore, james.smart, andrew.vasquez, christof.schmitt, mp3, rmk, matthew Cc: Mike Christie From: Mike Christie <michaelc@cs.wisc.edu> 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 <michaelc@cs.wisc.edu> --- 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(-) diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c index 3cdd4e9..53ed72b 100644 --- a/drivers/message/fusion/mptfc.c +++ b/drivers/message/fusion/mptfc.c @@ -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 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c index f77b329..55563a2 100644 --- a/drivers/message/fusion/mptsas.c +++ b/drivers/message/fusion/mptsas.c @@ -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, diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c index af1de0c..bc19593 100644 --- a/drivers/message/fusion/mptscsih.c +++ b/drivers/message/fusion/mptscsih.c @@ -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); diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h index d289e97..881efa7 100644 --- a/drivers/message/fusion/mptscsih.h +++ b/drivers/message/fusion/mptscsih.h @@ -115,7 +115,7 @@ extern int mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd extern void mptscsih_slave_destroy(struct scsi_device *device); extern int mptscsih_slave_configure(struct scsi_device *device); extern int mptscsih_abort(struct scsi_cmnd * SCpnt); -extern int mptscsih_dev_reset(struct scsi_cmnd * SCpnt); +extern int mptscsih_target_reset(struct scsi_cmnd * SCpnt); extern int mptscsih_bus_reset(struct scsi_cmnd * SCpnt); extern int mptscsih_host_reset(struct scsi_cmnd *SCpnt); extern int mptscsih_bios_param(struct scsi_device * sdev, struct block_device *bdev, sector_t capacity, int geom[]); diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c index 25bcfcf..0e96a69 100644 --- a/drivers/message/fusion/mptspi.c +++ b/drivers/message/fusion/mptspi.c @@ -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, diff --git a/drivers/scsi/a100u2w.c b/drivers/scsi/a100u2w.c index f608d4a..82ae198 100644 --- a/drivers/scsi/a100u2w.c +++ b/drivers/scsi/a100u2w.c @@ -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, diff --git a/drivers/scsi/arm/arxescsi.c b/drivers/scsi/arm/arxescsi.c index 2836fe2..d0315b9 100644 --- a/drivers/scsi/arm/arxescsi.c +++ b/drivers/scsi/arm/arxescsi.c @@ -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, diff --git a/drivers/scsi/arm/cumana_2.c b/drivers/scsi/arm/cumana_2.c index 68a6412..6322fe5 100644 --- a/drivers/scsi/arm/cumana_2.c +++ b/drivers/scsi/arm/cumana_2.c @@ -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, diff --git a/drivers/scsi/arm/eesox.c b/drivers/scsi/arm/eesox.c index bb2477b..f6f4a27 100644 --- a/drivers/scsi/arm/eesox.c +++ b/drivers/scsi/arm/eesox.c @@ -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, diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c index a715632..a9e666d 100644 --- a/drivers/scsi/arm/fas216.c +++ b/drivers/scsi/arm/fas216.c @@ -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); diff --git a/drivers/scsi/arm/fas216.h b/drivers/scsi/arm/fas216.h index b65f4cf..7675d3b 100644 --- a/drivers/scsi/arm/fas216.h +++ b/drivers/scsi/arm/fas216.h @@ -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 diff --git a/drivers/scsi/arm/powertec.c b/drivers/scsi/arm/powertec.c index d9a546d..4577c74 100644 --- a/drivers/scsi/arm/powertec.c +++ b/drivers/scsi/arm/powertec.c @@ -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, diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c index 68c0d09..d61d70a 100644 --- a/drivers/scsi/qla1280.c +++ b/drivers/scsi/qla1280.c @@ -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, diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 3c1b433..41e8d3e 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -102,10 +102,10 @@ static int qla2x00_queuecommand(struct scsi_cmnd *cmd, static int qla24xx_queuecommand(struct scsi_cmnd *cmd, void (*fn)(struct scsi_cmnd *)); static int qla2xxx_eh_abort(struct scsi_cmnd *); -static int qla2xxx_eh_device_reset(struct scsi_cmnd *); +static int qla2xxx_eh_target_reset(struct scsi_cmnd *); static int qla2xxx_eh_bus_reset(struct scsi_cmnd *); static int qla2xxx_eh_host_reset(struct scsi_cmnd *); -static int qla2x00_device_reset(scsi_qla_host_t *, fc_port_t *); +static int qla2x00_target_reset(scsi_qla_host_t *, fc_port_t *); static int qla2x00_change_queue_depth(struct scsi_device *, int); static int qla2x00_change_queue_type(struct scsi_device *, int); @@ -116,7 +116,7 @@ static struct scsi_host_template qla2x00_driver_template = { .queuecommand = qla2x00_queuecommand, .eh_abort_handler = qla2xxx_eh_abort, - .eh_device_reset_handler = qla2xxx_eh_device_reset, + .eh_target_reset_handler = qla2xxx_eh_target_reset, .eh_bus_reset_handler = qla2xxx_eh_bus_reset, .eh_host_reset_handler = qla2xxx_eh_host_reset, @@ -147,7 +147,7 @@ struct scsi_host_template qla24xx_driver_template = { .queuecommand = qla24xx_queuecommand, .eh_abort_handler = qla2xxx_eh_abort, - .eh_device_reset_handler = qla2xxx_eh_device_reset, + .eh_target_reset_handler = qla2xxx_eh_target_reset, .eh_bus_reset_handler = qla2xxx_eh_bus_reset, .eh_host_reset_handler = qla2xxx_eh_host_reset, @@ -771,10 +771,10 @@ qla2x00_eh_wait_for_pending_target_commands(scsi_qla_host_t *ha, unsigned int t) /************************************************************************** -* qla2xxx_eh_device_reset +* qla2xxx_eh_target_reset * * Description: -* The device reset function will reset the target and abort any +* The target reset function will reset the target and abort any * executing commands. * * NOTE: The use of SP is undefined within this context. Do *NOT* @@ -790,31 +790,30 @@ qla2x00_eh_wait_for_pending_target_commands(scsi_qla_host_t *ha, unsigned int t) * **************************************************************************/ static int -qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) +qla2xxx_eh_target_reset(struct scsi_cmnd *cmd) { scsi_qla_host_t *ha = shost_priv(cmd->device->host); fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; int ret = FAILED; - unsigned int id, lun; + unsigned int id; unsigned long serial; qla2x00_block_error_handler(cmd); id = cmd->device->id; - lun = cmd->device->lun; serial = cmd->serial_number; if (!fcport) return ret; qla_printk(KERN_INFO, ha, - "scsi(%ld:%d:%d): DEVICE RESET ISSUED.\n", ha->host_no, id, lun); + "scsi(%ld:%d): TARGET RESET ISSUED.\n", ha->host_no, id); if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS) - goto eh_dev_reset_done; + goto eh_tgt_reset_done; if (qla2x00_wait_for_loop_ready(ha) == QLA_SUCCESS) { - if (qla2x00_device_reset(ha, fcport) == 0) + if (qla2x00_target_reset(ha, fcport) == 0) ret = SUCCESS; #if defined(LOGOUT_AFTER_DEVICE_RESET) @@ -831,12 +830,12 @@ qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) } if (ret == FAILED) { - DEBUG3(printk("%s(%ld): device reset failed\n", + DEBUG3(printk("%s(%ld): target reset failed\n", __func__, ha->host_no)); - qla_printk(KERN_INFO, ha, "%s: device reset failed\n", + qla_printk(KERN_INFO, ha, "%s: target reset failed\n", __func__); - goto eh_dev_reset_done; + goto eh_tgt_reset_done; } /* Flush outstanding commands. */ @@ -849,9 +848,10 @@ qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) "%s: failed while waiting for commands\n", __func__); } else qla_printk(KERN_INFO, ha, - "scsi(%ld:%d:%d): DEVICE RESET SUCCEEDED.\n", ha->host_no, - id, lun); - eh_dev_reset_done: + "scsi(%ld:%d): TARGET RESET SUCCEEDED.\n", ha->host_no, + id); + + eh_tgt_reset_done: return ret; } @@ -1080,7 +1080,7 @@ qla2x00_loop_reset(scsi_qla_host_t *ha) if (fcport->port_type != FCT_TARGET) continue; - ret = qla2x00_device_reset(ha, fcport); + ret = qla2x00_target_reset(ha, fcport); if (ret != QLA_SUCCESS) { DEBUG2_3(printk("%s(%ld): bus_reset failed: " "target_reset=%d d_id=%x.\n", __func__, @@ -1096,7 +1096,7 @@ qla2x00_loop_reset(scsi_qla_host_t *ha) } /* - * qla2x00_device_reset + * qla2x00_target_reset * Issue bus device reset message to the target. * * Input: @@ -1109,7 +1109,7 @@ qla2x00_loop_reset(scsi_qla_host_t *ha) * Kernel context. */ static int -qla2x00_device_reset(scsi_qla_host_t *ha, fc_port_t *reset_fcport) +qla2x00_target_reset(scsi_qla_host_t *ha, fc_port_t *reset_fcport) { /* Abort Target command will clear Reservation */ return ha->isp_ops->abort_target(reset_fcport); diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index d39107b..6cd61c1 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -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, -- 1.5.4.1 ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 4/5] lpfc: convert lpfc to use target reset handler. 2008-03-01 0:25 ` [PATCH 3/5] Convert qla2xxx, mpt, arm, sym, a100u2w, qla1280 to target reset handler michaelc @ 2008-03-01 0:25 ` michaelc 2008-03-01 0:25 ` [PATCH 5/5] zfcp: convert zfcp to use target reset and device " michaelc 2008-04-21 20:43 ` [PATCH 4/5] lpfc: convert lpfc to use target " James Smart 2008-03-05 5:08 ` [PATCH 3/5] Convert qla2xxx, mpt, arm, sym, a100u2w, qla1280 to " Andrew Vasquez 1 sibling, 2 replies; 24+ messages in thread From: michaelc @ 2008-03-01 0:25 UTC (permalink / raw) To: linux-scsi, Eric.Moore, james.smart, andrew.vasquez, christof.schmitt, mp3, rmk, matthew Cc: Mike Christie From: Mike Christie <michaelc@cs.wisc.edu> 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. Signed-off-by: Mike Christie <michaelc@cs.wisc.edu> --- drivers/scsi/lpfc/lpfc_scsi.c | 85 ++++++++++++++--------------------------- 1 files changed, 29 insertions(+), 56 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index 70255c1..e881ffb 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -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, -- 1.5.4.1 ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 5/5] zfcp: convert zfcp to use target reset and device reset handler 2008-03-01 0:25 ` [PATCH 4/5] lpfc: convert lpfc to use " michaelc @ 2008-03-01 0:25 ` michaelc 2008-03-01 13:34 ` Christof Schmitt 2008-03-01 13:36 ` [PATCH] " Christof Schmitt 2008-04-21 20:43 ` [PATCH 4/5] lpfc: convert lpfc to use target " James Smart 1 sibling, 2 replies; 24+ messages in thread From: michaelc @ 2008-03-01 0:25 UTC (permalink / raw) To: linux-scsi, Eric.Moore, james.smart, andrew.vasquez, christof.schmitt, mp3, rmk, matthew Cc: Mike Christie From: Mike Christie <michaelc@cs.wisc.edu> 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). Signed-off-by: Mike Christie <michaelc@cs.wisc.edu> --- drivers/s390/scsi/zfcp_scsi.c | 67 +++++++++++++++++++++++++---------------- 1 files changed, 41 insertions(+), 26 deletions(-) diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c index b9daf5c..13dceec 100644 --- a/drivers/s390/scsi/zfcp_scsi.c +++ b/drivers/s390/scsi/zfcp_scsi.c @@ -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); -- 1.5.4.1 ^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [PATCH 5/5] zfcp: convert zfcp to use target reset and device reset handler 2008-03-01 0:25 ` [PATCH 5/5] zfcp: convert zfcp to use target reset and device " michaelc @ 2008-03-01 13:34 ` Christof Schmitt 2008-03-01 13:36 ` [PATCH] " Christof Schmitt 1 sibling, 0 replies; 24+ messages in thread From: Christof Schmitt @ 2008-03-01 13:34 UTC (permalink / raw) To: michaelc Cc: linux-scsi, Eric.Moore, james.smart, andrew.vasquez, mp3, rmk, matthew On Fri, Feb 29, 2008 at 06:25:23PM -0600, michaelc@cs.wisc.edu wrote: > From: Mike Christie <michaelc@cs.wisc.edu> > > 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). > Signed-off-by: Mike Christie <michaelc@cs.wisc.edu> 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 ^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH] zfcp: convert zfcp to use target reset and device reset handler 2008-03-01 0:25 ` [PATCH 5/5] zfcp: convert zfcp to use target reset and device " michaelc 2008-03-01 13:34 ` Christof Schmitt @ 2008-03-01 13:36 ` Christof Schmitt 2008-03-02 9:09 ` Mike Christie 2008-03-03 9:39 ` Heiko Carstens 1 sibling, 2 replies; 24+ messages in thread From: Christof Schmitt @ 2008-03-01 13:36 UTC (permalink / raw) To: michaelc Cc: linux-scsi, Eric.Moore, james.smart, andrew.vasquez, mp3, rmk, matthew [based on proposal from Mike Christie <michaelc@cs.wisc.edu>, 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. Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com> --- drivers/s390/scsi/zfcp_def.h | 1 drivers/s390/scsi/zfcp_scsi.c | 62 ++++++++++++------------------------------ 2 files changed, 19 insertions(+), 44 deletions(-) --- a/drivers/s390/scsi/zfcp_scsi.c 2008-03-01 14:30:02.000000000 +0100 +++ b/drivers/s390/scsi/zfcp_scsi.c 2008-03-01 14:30:45.000000000 +0100 @@ -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(st return 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 --- a/drivers/s390/scsi/zfcp_def.h 2008-03-01 14:30:02.000000000 +0100 +++ b/drivers/s390/scsi/zfcp_def.h 2008-03-01 14:30:45.000000000 +0100 @@ -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 ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH] zfcp: convert zfcp to use target reset and device reset handler 2008-03-01 13:36 ` [PATCH] " Christof Schmitt @ 2008-03-02 9:09 ` Mike Christie 2008-03-03 9:39 ` Heiko Carstens 1 sibling, 0 replies; 24+ messages in thread From: Mike Christie @ 2008-03-02 9:09 UTC (permalink / raw) To: Christof Schmitt Cc: linux-scsi, Eric.Moore, james.smart, andrew.vasquez, mp3, rmk, matthew Christof Schmitt wrote: > [based on proposal from Mike Christie <michaelc@cs.wisc.edu>, 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. > > Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com> Thanks for the review and testing. Your patch looks better than mine. Reviewed-by Mike Christie <michaelc@cs.wisc.edu> ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH] zfcp: convert zfcp to use target reset and device reset handler 2008-03-01 13:36 ` [PATCH] " Christof Schmitt 2008-03-02 9:09 ` Mike Christie @ 2008-03-03 9:39 ` Heiko Carstens 2008-03-03 10:12 ` Christof Schmitt 1 sibling, 1 reply; 24+ messages in thread From: Heiko Carstens @ 2008-03-03 9:39 UTC (permalink / raw) To: Christof Schmitt Cc: michaelc, linux-scsi, Eric.Moore, james.smart, andrew.vasquez, mp3, rmk, matthew > if (!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. ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH] zfcp: convert zfcp to use target reset and device reset handler 2008-03-03 9:39 ` Heiko Carstens @ 2008-03-03 10:12 ` Christof Schmitt 2008-03-03 10:19 ` Christof Schmitt 0 siblings, 1 reply; 24+ messages in thread From: Christof Schmitt @ 2008-03-03 10:12 UTC (permalink / raw) To: Heiko Carstens Cc: michaelc, linux-scsi, Eric.Moore, james.smart, andrew.vasquez, mp3, rmk, matthew On Mon, Mar 03, 2008 at 10:39:24AM +0100, Heiko Carstens wrote: > > if (!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. Agree, WARN_ON is enough for these cases. I will followup with the changed patch. -- Christof Schmitt ^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH] zfcp: convert zfcp to use target reset and device reset handler 2008-03-03 10:12 ` Christof Schmitt @ 2008-03-03 10:19 ` Christof Schmitt 2008-03-03 10:40 ` Russell King 0 siblings, 1 reply; 24+ messages in thread From: Christof Schmitt @ 2008-03-03 10:19 UTC (permalink / raw) To: Heiko Carstens Cc: michaelc, linux-scsi, Eric.Moore, james.smart, andrew.vasquez, mp3, rmk, matthew [based on proposal from Mike Christie <michaelc@cs.wisc.edu>, 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. Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com> --- drivers/s390/scsi/zfcp_def.h | 1 drivers/s390/scsi/zfcp_scsi.c | 62 ++++++++++++------------------------------ 2 files changed, 19 insertions(+), 44 deletions(-) --- a/drivers/s390/scsi/zfcp_scsi.c 2008-03-01 14:30:02.000000000 +0100 +++ b/drivers/s390/scsi/zfcp_scsi.c 2008-03-03 11:15:21.000000000 +0100 @@ -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(st return 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 --- a/drivers/s390/scsi/zfcp_def.h 2008-03-01 14:30:02.000000000 +0100 +++ b/drivers/s390/scsi/zfcp_def.h 2008-03-01 14:30:45.000000000 +0100 @@ -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 ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH] zfcp: convert zfcp to use target reset and device reset handler 2008-03-03 10:19 ` Christof Schmitt @ 2008-03-03 10:40 ` Russell King 2008-03-03 11:18 ` Christof Schmitt 2008-03-03 11:19 ` Christof Schmitt 0 siblings, 2 replies; 24+ messages in thread From: Russell King @ 2008-03-03 10:40 UTC (permalink / raw) To: Christof Schmitt Cc: Heiko Carstens, michaelc, linux-scsi, Eric.Moore, james.smart, andrew.vasquez, mp3, matthew On Mon, Mar 03, 2008 at 11:19:46AM +0100, Christof Schmitt wrote: > +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? -- Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH] zfcp: convert zfcp to use target reset and device reset handler 2008-03-03 10:40 ` Russell King @ 2008-03-03 11:18 ` Christof Schmitt 2008-03-03 11:19 ` Christof Schmitt 1 sibling, 0 replies; 24+ messages in thread From: Christof Schmitt @ 2008-03-03 11:18 UTC (permalink / raw) To: Russell King Cc: Heiko Carstens, michaelc, linux-scsi, Eric.Moore, james.smart, andrew.vasquez, mp3, matthew On Mon, Mar 03, 2008 at 10:40:10AM +0000, Russell King wrote: > On Mon, Mar 03, 2008 at 11:19:46AM +0100, Christof Schmitt wrote: > > +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 ^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH] zfcp: convert zfcp to use target reset and device reset handler 2008-03-03 10:40 ` Russell King 2008-03-03 11:18 ` Christof Schmitt @ 2008-03-03 11:19 ` Christof Schmitt 1 sibling, 0 replies; 24+ messages in thread From: Christof Schmitt @ 2008-03-03 11:19 UTC (permalink / raw) To: Russell King Cc: Heiko Carstens, michaelc, linux-scsi, Eric.Moore, james.smart, andrew.vasquez, mp3, matthew [based on proposal from Mike Christie <michaelc@cs.wisc.edu>, 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. Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com> --- drivers/s390/scsi/zfcp_def.h | 1 drivers/s390/scsi/zfcp_scsi.c | 64 +++++++++++++----------------------------- 2 files changed, 20 insertions(+), 45 deletions(-) --- a/drivers/s390/scsi/zfcp_scsi.c 2008-03-03 12:16:04.000000000 +0100 +++ b/drivers/s390/scsi/zfcp_scsi.c 2008-03-03 12:16:06.000000000 +0100 @@ -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(st return 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 --- a/drivers/s390/scsi/zfcp_def.h 2008-03-03 12:16:04.000000000 +0100 +++ b/drivers/s390/scsi/zfcp_def.h 2008-03-03 12:16:06.000000000 +0100 @@ -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 ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 4/5] lpfc: convert lpfc to use target reset handler. 2008-03-01 0:25 ` [PATCH 4/5] lpfc: convert lpfc to use " michaelc 2008-03-01 0:25 ` [PATCH 5/5] zfcp: convert zfcp to use target reset and device " michaelc @ 2008-04-21 20:43 ` James Smart 1 sibling, 0 replies; 24+ messages in thread From: James Smart @ 2008-04-21 20:43 UTC (permalink / raw) To: michaelc Cc: linux-scsi, Eric.Moore, andrew.vasquez, christof.schmitt, mp3, rmk, matthew fyi: this patch has been superceeded by : http://marc.info/?l=linux-scsi&m=120880973719266&w=2 -- james s michaelc@cs.wisc.edu wrote: > From: Mike Christie <michaelc@cs.wisc.edu> > > 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. > Signed-off-by: Mike Christie <michaelc@cs.wisc.edu> > --- > drivers/scsi/lpfc/lpfc_scsi.c | 85 ++++++++++++++--------------------------- > 1 files changed, 29 insertions(+), 56 deletions(-) > > diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c > index 70255c1..e881ffb 100644 > --- a/drivers/scsi/lpfc/lpfc_scsi.c > +++ b/drivers/scsi/lpfc/lpfc_scsi.c > @@ -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, ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH 3/5] Convert qla2xxx, mpt, arm, sym, a100u2w, qla1280 to target reset handler 2008-03-01 0:25 ` [PATCH 3/5] Convert qla2xxx, mpt, arm, sym, a100u2w, qla1280 to target reset handler michaelc 2008-03-01 0:25 ` [PATCH 4/5] lpfc: convert lpfc to use " michaelc @ 2008-03-05 5:08 ` Andrew Vasquez 2008-03-05 17:11 ` Mike Christie 1 sibling, 1 reply; 24+ messages in thread From: Andrew Vasquez @ 2008-03-05 5:08 UTC (permalink / raw) To: michaelc Cc: linux-scsi, Eric.Moore, james.smart, christof.schmitt, mp3, rmk, matthew On Fri, 29 Feb 2008, michaelc@cs.wisc.edu wrote: > From: Mike Christie <michaelc@cs.wisc.edu> > > 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 <michaelc@cs.wisc.edu> > --- > 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 --- diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index 3843eaa..f7919d3 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -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, diff --git a/drivers/scsi/qla2xxx/qla_fw.h b/drivers/scsi/qla2xxx/qla_fw.h index 38adc0f..c6a5e49 100644 --- a/drivers/scsi/qla2xxx/qla_fw.h +++ b/drivers/scsi/qla2xxx/qla_fw.h @@ -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 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h index f25aa63..f213364 100644 --- a/drivers/scsi/qla2xxx/qla_gbl.h +++ b/drivers/scsi/qla2xxx/qla_gbl.h @@ -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); diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c index b25c15a..c1af56d 100644 --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c @@ -784,35 +784,20 @@ qla2x00_abort_command(scsi_qla_host_t *ha, srb_t *sp) return rval; } -/* - * qla2x00_abort_target - * Issue abort target mailbox command. - * - * Input: - * ha = adapter block pointer. - * - * Returns: - * qla2x00 local function return status code. - * - * Context: - * Kernel context. - */ int -qla2x00_abort_target(fc_port_t *fcport) +qla2x00_abort_target(struct fc_port *fcport, unsigned int l) { - int rval; + int rval, rval2; mbx_cmd_t mc; mbx_cmd_t *mcp = &mc; scsi_qla_host_t *ha; - if (fcport == NULL) - return 0; - DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->ha->host_no)); + l = l; ha = fcport->ha; mcp->mb[0] = MBC_ABORT_TARGET; - mcp->out_mb = MBX_2|MBX_1|MBX_0; + mcp->out_mb = MBX_9|MBX_2|MBX_1|MBX_0; if (HAS_EXTENDED_IDS(ha)) { mcp->mb[1] = fcport->loop_id; mcp->mb[10] = 0; @@ -821,22 +806,66 @@ qla2x00_abort_target(fc_port_t *fcport) mcp->mb[1] = fcport->loop_id << 8; } mcp->mb[2] = ha->loop_reset_delay; + mcp->mb[9] = ha->vp_idx; mcp->in_mb = MBX_0; mcp->tov = 30; mcp->flags = 0; rval = qla2x00_mailbox_command(ha, mcp); + if (rval != QLA_SUCCESS) { + DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, + ha->host_no, rval)); + } + + /* Issue marker IOCB. */ + rval2 = qla2x00_marker(ha, fcport->loop_id, 0, MK_SYNC_ID); + if (rval2 != QLA_SUCCESS) { + DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB " + "(%x).\n", __func__, ha->host_no, rval2)); + } else { + DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); + } + + return rval; +} + +int +qla2x00_lun_reset(struct fc_port *fcport, unsigned int l) +{ + int rval, rval2; + mbx_cmd_t mc; + mbx_cmd_t *mcp = &mc; + scsi_qla_host_t *ha; + + DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->ha->host_no)); - /* Issue marker command. */ - ha->marker_needed = 1; + ha = fcport->ha; + mcp->mb[0] = MBC_LUN_RESET; + mcp->out_mb = MBX_9|MBX_3|MBX_2|MBX_1|MBX_0; + if (HAS_EXTENDED_IDS(ha)) + mcp->mb[1] = fcport->loop_id; + else + mcp->mb[1] = fcport->loop_id << 8; + mcp->mb[2] = l; + mcp->mb[3] = 0; + mcp->mb[9] = ha->vp_idx; + mcp->in_mb = MBX_0; + mcp->tov = 30; + mcp->flags = 0; + rval = qla2x00_mailbox_command(ha, mcp); if (rval != QLA_SUCCESS) { - DEBUG2_3_11(printk("qla2x00_abort_target(%ld): failed=%x.\n", + DEBUG2_3_11(printk("%s(%ld): failed=%x.\n", __func__, ha->host_no, rval)); + } + + /* Issue marker IOCB. */ + rval2 = qla2x00_marker(ha, fcport->loop_id, l, MK_SYNC_ID_LUN); + if (rval2 != QLA_SUCCESS) { + DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB " + "(%x).\n", __func__, ha->host_no, rval2)); } else { - /*EMPTY*/ - DEBUG11(printk("qla2x00_abort_target(%ld): done.\n", - ha->host_no)); + DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); } return rval; @@ -2186,17 +2215,15 @@ struct tsk_mgmt_cmd { } p; }; -int -qla24xx_abort_target(fc_port_t *fcport) +static int +__qla24xx_issue_tmf(char *name, uint32_t type, struct fc_port *fcport, + unsigned int l) { - int rval; + int rval, rval2; struct tsk_mgmt_cmd *tsk; dma_addr_t tsk_dma; scsi_qla_host_t *ha, *pha; - if (fcport == NULL) - return 0; - DEBUG11(printk("%s(%ld): entered.\n", __func__, fcport->ha->host_no)); ha = fcport->ha; @@ -2213,47 +2240,61 @@ qla24xx_abort_target(fc_port_t *fcport) tsk->p.tsk.entry_count = 1; tsk->p.tsk.nport_handle = cpu_to_le16(fcport->loop_id); tsk->p.tsk.timeout = cpu_to_le16(ha->r_a_tov / 10 * 2); - tsk->p.tsk.control_flags = __constant_cpu_to_le32(TCF_TARGET_RESET); + tsk->p.tsk.control_flags = cpu_to_le32(type); tsk->p.tsk.port_id[0] = fcport->d_id.b.al_pa; tsk->p.tsk.port_id[1] = fcport->d_id.b.area; tsk->p.tsk.port_id[2] = fcport->d_id.b.domain; tsk->p.tsk.vp_index = fcport->vp_idx; + if (type == TCF_LUN_RESET) { + int_to_scsilun(l, &tsk->p.tsk.lun); + host_to_fcp_swap((uint8_t *)&tsk->p.tsk.lun, + sizeof(tsk->p.tsk.lun)); + } rval = qla2x00_issue_iocb(ha, tsk, tsk_dma, 0); if (rval != QLA_SUCCESS) { - DEBUG2_3_11(printk("%s(%ld): failed to issue Target Reset IOCB " - "(%x).\n", __func__, ha->host_no, rval)); - goto atarget_done; + DEBUG2_3_11(printk("%s(%ld): failed to issue %s Reset IOCB " + "(%x).\n", __func__, ha->host_no, name, rval)); } else if (tsk->p.sts.entry_status != 0) { DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " "-- error status (%x).\n", __func__, ha->host_no, tsk->p.sts.entry_status)); rval = QLA_FUNCTION_FAILED; - goto atarget_done; } else if (tsk->p.sts.comp_status != __constant_cpu_to_le16(CS_COMPLETE)) { DEBUG2_3_11(printk("%s(%ld): failed to complete IOCB " "-- completion status (%x).\n", __func__, ha->host_no, le16_to_cpu(tsk->p.sts.comp_status))); rval = QLA_FUNCTION_FAILED; - goto atarget_done; } /* Issue marker IOCB. */ - rval = qla2x00_marker(ha, fcport->loop_id, 0, MK_SYNC_ID); - if (rval != QLA_SUCCESS) { + rval2 = qla2x00_marker(ha, fcport->loop_id, l, + type == TCF_LUN_RESET ? MK_SYNC_ID_LUN: MK_SYNC_ID); + if (rval2 != QLA_SUCCESS) { DEBUG2_3_11(printk("%s(%ld): failed to issue Marker IOCB " - "(%x).\n", __func__, ha->host_no, rval)); + "(%x).\n", __func__, ha->host_no, rval2)); } else { DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); } -atarget_done: dma_pool_free(pha->s_dma_pool, tsk, tsk_dma); return rval; } +int +qla24xx_abort_target(struct fc_port *fcport, unsigned int l) +{ + return __qla24xx_issue_tmf("Target", TCF_TARGET_RESET, fcport, l); +} + +int +qla24xx_lun_reset(struct fc_port *fcport, unsigned int l) +{ + return __qla24xx_issue_tmf("Lun", TCF_LUN_RESET, fcport, l); +} + #if 0 int diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index ba7d2ca..5cddc50 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -100,6 +100,7 @@ static int qla24xx_queuecommand(struct scsi_cmnd *cmd, void (*fn)(struct scsi_cmnd *)); static int qla2xxx_eh_abort(struct scsi_cmnd *); static int qla2xxx_eh_device_reset(struct scsi_cmnd *); +static int qla2xxx_eh_target_reset(struct scsi_cmnd *); static int qla2xxx_eh_bus_reset(struct scsi_cmnd *); static int qla2xxx_eh_host_reset(struct scsi_cmnd *); @@ -113,6 +114,7 @@ static struct scsi_host_template qla2x00_driver_template = { .eh_abort_handler = qla2xxx_eh_abort, .eh_device_reset_handler = qla2xxx_eh_device_reset, + .eh_target_reset_handler = qla2xxx_eh_target_reset, .eh_bus_reset_handler = qla2xxx_eh_bus_reset, .eh_host_reset_handler = qla2xxx_eh_host_reset, @@ -144,6 +146,7 @@ struct scsi_host_template qla24xx_driver_template = { .eh_abort_handler = qla2xxx_eh_abort, .eh_device_reset_handler = qla2xxx_eh_device_reset, + .eh_target_reset_handler = qla2xxx_eh_target_reset, .eh_bus_reset_handler = qla2xxx_eh_bus_reset, .eh_host_reset_handler = qla2xxx_eh_host_reset, @@ -566,8 +569,6 @@ qla2x00_wait_for_hba_online(scsi_qla_host_t *ha) else return_status = QLA_FUNCTION_FAILED; - DEBUG2(printk("%s return_status=%d\n",__func__,return_status)); - return (return_status); } @@ -714,181 +715,122 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd) return ret; } -/************************************************************************** -* qla2x00_eh_wait_for_pending_target_commands -* -* Description: -* Waits for all the commands to come back from the specified target. -* -* Input: -* ha - pointer to scsi_qla_host structure. -* t - target -* Returns: -* Either SUCCESS or FAILED. -* -* Note: -**************************************************************************/ +enum nexus_wait_type { + WAIT_HOST = 0, + WAIT_TARGET, + WAIT_LUN, +}; + static int -qla2x00_eh_wait_for_pending_target_commands(scsi_qla_host_t *ha, unsigned int t) +qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *ha, unsigned int t, + unsigned int l, enum nexus_wait_type type) { - int cnt; - int status; - srb_t *sp; - struct scsi_cmnd *cmd; + int cnt, match, status; + srb_t *sp; unsigned long flags; scsi_qla_host_t *pha = to_qla_parent(ha); - status = 0; - - /* - * Waiting for all commands for the designated target in the active - * array - */ - for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) { - spin_lock_irqsave(&pha->hardware_lock, flags); + status = QLA_SUCCESS; + spin_lock_irqsave(&pha->hardware_lock, flags); + for (cnt = 1; status == QLA_SUCCESS && cnt < MAX_OUTSTANDING_COMMANDS; + cnt++) { sp = pha->outstanding_cmds[cnt]; - if (sp) { - cmd = sp->cmd; - spin_unlock_irqrestore(&pha->hardware_lock, flags); - if (cmd->device->id == t && - ha->vp_idx == sp->ha->vp_idx) { - if (!qla2x00_eh_wait_on_command(ha, cmd)) { - status = 1; - break; - } - } - } else { - spin_unlock_irqrestore(&pha->hardware_lock, flags); + if (!sp) + continue; + if (ha->vp_idx != sp->ha->vp_idx) + continue; + match = 0; + switch (type) { + case WAIT_HOST: + match = 1; + break; + case WAIT_TARGET: + match = sp->cmd->device->id == t; + break; + case WAIT_LUN: + match = (sp->cmd->device->id == t && + sp->cmd->device->lun == l); + break; } + if (!match) + continue; + + spin_unlock_irqrestore(&pha->hardware_lock, flags); + status = qla2x00_eh_wait_on_command(ha, sp->cmd); + spin_lock_irqsave(&pha->hardware_lock, flags); } - return (status); + spin_unlock_irqrestore(&pha->hardware_lock, flags); + + return status; } +static char *reset_errors[] = { + "HBA not online", + "HBA not ready", + "Task management failed", + "Waiting for command completions", +}; -/************************************************************************** -* qla2xxx_eh_device_reset -* -* Description: -* The device reset function will reset the target and abort any -* executing commands. -* -* NOTE: The use of SP is undefined within this context. Do *NOT* -* attempt to use this value, even if you determine it is -* non-null. -* -* Input: -* cmd = Linux SCSI command packet of the command that cause the -* bus device reset. -* -* Returns: -* SUCCESS/FAILURE (defined as macro in scsi.h). -* -**************************************************************************/ static int -qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) +__qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type, + struct scsi_cmnd *cmd, int (*do_reset)(struct fc_port *, unsigned int)) { scsi_qla_host_t *ha = shost_priv(cmd->device->host); fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; - int ret = FAILED; - unsigned int id, lun; - unsigned long serial; + int err; qla2x00_block_error_handler(cmd); - id = cmd->device->id; - lun = cmd->device->lun; - serial = cmd->serial_number; - if (!fcport) - return ret; + return FAILED; - qla_printk(KERN_INFO, ha, - "scsi(%ld:%d:%d): DEVICE RESET ISSUED.\n", ha->host_no, id, lun); + qla_printk(KERN_INFO, ha, "scsi(%ld:%d:%d): %s RESET ISSUED.\n", + ha->host_no, cmd->device->id, cmd->device->lun, name); + err = 0; if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS) - goto eh_dev_reset_done; - - if (qla2x00_wait_for_loop_ready(ha) == QLA_SUCCESS) { - if (ha->isp_ops->abort_target(fcport) == 0) - ret = SUCCESS; - } else { - DEBUG2(printk(KERN_INFO - "%s failed: loop not ready\n",__func__)); - } - - if (ret == FAILED) { - DEBUG3(printk("%s(%ld): device reset failed\n", - __func__, ha->host_no)); - qla_printk(KERN_INFO, ha, "%s: device reset failed\n", - __func__); + goto eh_reset_failed; + err = 1; + if (qla2x00_wait_for_loop_ready(ha) != QLA_SUCCESS) + goto eh_reset_failed; + err = 2; + if (do_reset(fcport, cmd->device->lun) != QLA_SUCCESS) + goto eh_reset_failed; + err = 3; + if (qla2x00_eh_wait_for_pending_commands(ha, cmd->device->id, + cmd->device->lun, type) != QLA_SUCCESS) + goto eh_reset_failed; + + qla_printk(KERN_INFO, ha, "scsi(%ld:%d:%d): %s RESET SUCCEEDED.\n", + ha->host_no, cmd->device->id, cmd->device->lun, name); + + return SUCCESS; + + eh_reset_failed: + qla_printk(KERN_INFO, ha, "scsi(%ld:%d:%d): %s RESET FAILED: %s.\n", + ha->host_no, cmd->device->id, cmd->device->lun, name, + reset_errors[err]); + return FAILED; +} - goto eh_dev_reset_done; - } +static int +qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) +{ + scsi_qla_host_t *ha = shost_priv(cmd->device->host); - /* Flush outstanding commands. */ - if (qla2x00_eh_wait_for_pending_target_commands(ha, id)) - ret = FAILED; - if (ret == FAILED) { - DEBUG3(printk("%s(%ld): failed while waiting for commands\n", - __func__, ha->host_no)); - qla_printk(KERN_INFO, ha, - "%s: failed while waiting for commands\n", __func__); - } else - qla_printk(KERN_INFO, ha, - "scsi(%ld:%d:%d): DEVICE RESET SUCCEEDED.\n", ha->host_no, - id, lun); - eh_dev_reset_done: - return ret; + return __qla2xxx_eh_generic_reset("DEVICE", WAIT_LUN, cmd, + ha->isp_ops->lun_reset); } -/************************************************************************** -* qla2x00_eh_wait_for_pending_commands -* -* Description: -* Waits for all the commands to come back from the specified host. -* -* Input: -* ha - pointer to scsi_qla_host structure. -* -* Returns: -* 1 : SUCCESS -* 0 : FAILED -* -* Note: -**************************************************************************/ static int -qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *ha) +qla2xxx_eh_target_reset(struct scsi_cmnd *cmd) { - int cnt; - int status; - srb_t *sp; - struct scsi_cmnd *cmd; - unsigned long flags; - - status = 1; + scsi_qla_host_t *ha = shost_priv(cmd->device->host); - /* - * Waiting for all commands for the designated target in the active - * array - */ - for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) { - spin_lock_irqsave(&ha->hardware_lock, flags); - sp = ha->outstanding_cmds[cnt]; - if (sp) { - cmd = sp->cmd; - spin_unlock_irqrestore(&ha->hardware_lock, flags); - status = qla2x00_eh_wait_on_command(ha, cmd); - if (status == 0) - break; - } - else { - spin_unlock_irqrestore(&ha->hardware_lock, flags); - } - } - return (status); + return __qla2xxx_eh_generic_reset("TARGET", WAIT_TARGET, cmd, + ha->isp_ops->target_reset); } - /************************************************************************** * qla2xxx_eh_bus_reset * @@ -939,7 +881,8 @@ qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd) goto eh_bus_reset_done; /* Flush outstanding commands. */ - if (!qla2x00_eh_wait_for_pending_commands(pha)) + if (qla2x00_eh_wait_for_pending_commands(pha, 0, 0, WAIT_HOST) != + QLA_SUCCESS) ret = FAILED; eh_bus_reset_done: @@ -1010,7 +953,8 @@ qla2xxx_eh_host_reset(struct scsi_cmnd *cmd) clear_bit(ABORT_ISP_ACTIVE, &pha->dpc_flags); /* Waiting for our command in done_queue to be returned to OS.*/ - if (qla2x00_eh_wait_for_pending_commands(pha)) + if (qla2x00_eh_wait_for_pending_commands(pha, 0, 0, WAIT_HOST) == + QLA_SUCCESS) ret = SUCCESS; if (ha->parent) @@ -1066,7 +1010,7 @@ qla2x00_loop_reset(scsi_qla_host_t *ha) if (fcport->port_type != FCT_TARGET) continue; - ret = ha->isp_ops->abort_target(fcport); + ret = ha->isp_ops->target_reset(fcport, 0); if (ret != QLA_SUCCESS) { DEBUG2_3(printk("%s(%ld): bus_reset failed: " "target_reset=%d d_id=%x.\n", __func__, @@ -1258,7 +1202,8 @@ static struct isp_operations qla2100_isp_ops = { .enable_intrs = qla2x00_enable_intrs, .disable_intrs = qla2x00_disable_intrs, .abort_command = qla2x00_abort_command, - .abort_target = qla2x00_abort_target, + .target_reset = qla2x00_abort_target, + .lun_reset = qla2x00_lun_reset, .fabric_login = qla2x00_login_fabric, .fabric_logout = qla2x00_fabric_logout, .calc_req_entries = qla2x00_calc_iocbs_32, @@ -1291,7 +1236,8 @@ static struct isp_operations qla2300_isp_ops = { .enable_intrs = qla2x00_enable_intrs, .disable_intrs = qla2x00_disable_intrs, .abort_command = qla2x00_abort_command, - .abort_target = qla2x00_abort_target, + .target_reset = qla2x00_abort_target, + .lun_reset = qla2x00_lun_reset, .fabric_login = qla2x00_login_fabric, .fabric_logout = qla2x00_fabric_logout, .calc_req_entries = qla2x00_calc_iocbs_32, @@ -1324,7 +1270,8 @@ static struct isp_operations qla24xx_isp_ops = { .enable_intrs = qla24xx_enable_intrs, .disable_intrs = qla24xx_disable_intrs, .abort_command = qla24xx_abort_command, - .abort_target = qla24xx_abort_target, + .target_reset = qla24xx_abort_target, + .lun_reset = qla24xx_lun_reset, .fabric_login = qla24xx_login_fabric, .fabric_logout = qla24xx_fabric_logout, .calc_req_entries = NULL, @@ -1357,7 +1304,8 @@ static struct isp_operations qla25xx_isp_ops = { .enable_intrs = qla24xx_enable_intrs, .disable_intrs = qla24xx_disable_intrs, .abort_command = qla24xx_abort_command, - .abort_target = qla24xx_abort_target, + .target_reset = qla24xx_abort_target, + .lun_reset = qla24xx_lun_reset, .fabric_login = qla24xx_login_fabric, .fabric_logout = qla24xx_fabric_logout, .calc_req_entries = NULL, ^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [PATCH 3/5] Convert qla2xxx, mpt, arm, sym, a100u2w, qla1280 to target reset handler 2008-03-05 5:08 ` [PATCH 3/5] Convert qla2xxx, mpt, arm, sym, a100u2w, qla1280 to " Andrew Vasquez @ 2008-03-05 17:11 ` Mike Christie 0 siblings, 0 replies; 24+ messages in thread From: Mike Christie @ 2008-03-05 17:11 UTC (permalink / raw) To: Andrew Vasquez Cc: linux-scsi, Eric.Moore, james.smart, christof.schmitt, mp3, rmk, matthew Andrew Vasquez wrote: > On Fri, 29 Feb 2008, michaelc@cs.wisc.edu wrote: > >> From: Mike Christie <michaelc@cs.wisc.edu> >> >> 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 <michaelc@cs.wisc.edu> >> --- >> 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, That sounds good. > 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. ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: scsi: fix target reset handling 2008-03-01 0:25 scsi: fix target reset handling michaelc 2008-03-01 0:25 ` [PATCH 1/5] scsi_error: add target reset handler michaelc @ 2008-03-01 0:27 ` Mike Christie 2008-03-03 17:06 ` Moore, Eric 2 siblings, 0 replies; 24+ messages in thread From: Mike Christie @ 2008-03-01 0:27 UTC (permalink / raw) To: linux-scsi, Eric.Moore, james.smart, andrew.vasquez, christof.schmitt, mp3, rmk, matthew Oh yeah, the patches were made over scsi-rc-fixes, but can be applied over scsi-misc or 2.6.25-rc3. michaelc@cs.wisc.edu 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. > ^ permalink raw reply [flat|nested] 24+ messages in thread
* RE: scsi: fix target reset handling 2008-03-01 0:25 scsi: fix target reset handling michaelc 2008-03-01 0:25 ` [PATCH 1/5] scsi_error: add target reset handler michaelc 2008-03-01 0:27 ` scsi: fix target reset handling Mike Christie @ 2008-03-03 17:06 ` Moore, Eric 2008-03-04 15:21 ` Mike Christie 2 siblings, 1 reply; 24+ messages in thread From: Moore, Eric @ 2008-03-03 17:06 UTC (permalink / raw) To: michaelc, linux-scsi, james.smart, andrew.vasquez, christof.schmitt, mp3, rmk On Friday, February 29, 2008 5:25 PM, Mike Christie 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. > > 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 ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: scsi: fix target reset handling 2008-03-03 17:06 ` Moore, Eric @ 2008-03-04 15:21 ` Mike Christie 2008-03-04 17:34 ` Moore, Eric 0 siblings, 1 reply; 24+ messages in thread From: Mike Christie @ 2008-03-04 15:21 UTC (permalink / raw) To: Moore, Eric Cc: linux-scsi, james.smart, andrew.vasquez, christof.schmitt, mp3, rmk, matthew Moore, Eric wrote: > On Friday, February 29, 2008 5:25 PM, Mike Christie 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. >> >> > > 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? > 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. ^ permalink raw reply [flat|nested] 24+ messages in thread
* RE: scsi: fix target reset handling 2008-03-04 15:21 ` Mike Christie @ 2008-03-04 17:34 ` Moore, Eric 2008-03-04 17:40 ` Hagan, Steve 0 siblings, 1 reply; 24+ messages in thread From: Moore, Eric @ 2008-03-04 17:34 UTC (permalink / raw) To: Mike Christie Cc: linux-scsi, james.smart, andrew.vasquez, christof.schmitt, mp3, rmk, matthew, Hagan, Steve, Rivera, Peter, Prakash, Sathya On Tuesday, March 04, 2008 8:21 AM, Mike Christie wrote: > > 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? > > > > 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, > > How about I add the LU reset support in a separate patch, so > git revert > will be kinder to me? > Seperate patch, no problem. > 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 ^ permalink raw reply [flat|nested] 24+ messages in thread
* RE: scsi: fix target reset handling 2008-03-04 17:34 ` Moore, Eric @ 2008-03-04 17:40 ` Hagan, Steve 2008-03-04 18:00 ` James Bottomley 0 siblings, 1 reply; 24+ messages in thread From: Hagan, Steve @ 2008-03-04 17:40 UTC (permalink / raw) To: Moore, Eric, Mike Christie Cc: linux-scsi, james.smart, andrew.vasquez, christof.schmitt, mp3, rmk, matthew, Rivera, Peter, Prakash, Sathya 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: linux-scsi@vger.kernel.org; james.smart@emulex.com; andrew.vasquez@qlogic.com; christof.schmitt@de.ibm.com; mp3@de.ibm.com; rmk@arm.linux.org.uk; matthew@wil.cx; Hagan, Steve; Rivera, Peter; Prakash, Sathya Subject: RE: scsi: fix target reset handling On Tuesday, March 04, 2008 8:21 AM, Mike Christie wrote: > > 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? > > > > 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, > > How about I add the LU reset support in a separate patch, so git > revert will be kinder to me? > Seperate patch, no problem. > 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 ^ permalink raw reply [flat|nested] 24+ messages in thread
* RE: scsi: fix target reset handling 2008-03-04 17:40 ` Hagan, Steve @ 2008-03-04 18:00 ` James Bottomley 0 siblings, 0 replies; 24+ messages in thread From: James Bottomley @ 2008-03-04 18:00 UTC (permalink / raw) To: Hagan, Steve Cc: Moore, Eric, Mike Christie, linux-scsi, james.smart, andrew.vasquez, christof.schmitt, mp3, rmk, matthew, Rivera, Peter, Prakash, Sathya On Tue, 2008-03-04 at 10:40 -0700, Hagan, Steve wrote: > 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. > 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. > 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 ^ permalink raw reply [flat|nested] 24+ messages in thread
end of thread, other threads:[~2008-04-21 20:44 UTC | newest] Thread overview: 24+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-03-01 0:25 scsi: fix target reset handling michaelc 2008-03-01 0:25 ` [PATCH 1/5] scsi_error: add target reset handler michaelc 2008-03-01 0:25 ` [PATCH 2/5] qla4xxx: Add target reset functionality michaelc 2008-03-01 0:25 ` [PATCH 3/5] Convert qla2xxx, mpt, arm, sym, a100u2w, qla1280 to target reset handler michaelc 2008-03-01 0:25 ` [PATCH 4/5] lpfc: convert lpfc to use " michaelc 2008-03-01 0:25 ` [PATCH 5/5] zfcp: convert zfcp to use target reset and device " michaelc 2008-03-01 13:34 ` Christof Schmitt 2008-03-01 13:36 ` [PATCH] " Christof Schmitt 2008-03-02 9:09 ` Mike Christie 2008-03-03 9:39 ` Heiko Carstens 2008-03-03 10:12 ` Christof Schmitt 2008-03-03 10:19 ` Christof Schmitt 2008-03-03 10:40 ` Russell King 2008-03-03 11:18 ` Christof Schmitt 2008-03-03 11:19 ` Christof Schmitt 2008-04-21 20:43 ` [PATCH 4/5] lpfc: convert lpfc to use target " James Smart 2008-03-05 5:08 ` [PATCH 3/5] Convert qla2xxx, mpt, arm, sym, a100u2w, qla1280 to " Andrew Vasquez 2008-03-05 17:11 ` Mike Christie 2008-03-01 0:27 ` scsi: fix target reset handling Mike Christie 2008-03-03 17:06 ` Moore, Eric 2008-03-04 15:21 ` Mike Christie 2008-03-04 17:34 ` Moore, Eric 2008-03-04 17:40 ` Hagan, Steve 2008-03-04 18:00 ` James Bottomley
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).