target/qla2xxx: Simplify the code for handling aborted commands
Subsystems (3)
PATCH 14/17 target/qla2xxx: Simplify the code for handling aborted commands
Since the target core waits anyway until a target driver has finished processing a command, remove similar waiting code from the tcm_qla2xxx driver. With this change applied command abortion works as follows:
* tcm_qla2xxx receives an ABTS and calls target_submit_tmr().
* The target core calls core_tmr_abort_task(). That function sets the CMD_T_ABORTED flag and next calls transport_wait_for_tasks().
* If CMD_T_ACTIVE is still set, __transport_wait_for_tasks() sets CMD_T_STOP and waits for t_transport_stop_comp.
* When tcm_qla2xxx_handle_data_work() gets called, it either invokes transport_generic_request_failure() or target_execute_cmd().
* Both functions start with calling __transport_check_aborted_status() and return 1 if CMD_T_ABORTED was set. Otherwise the command that is being executed is completed and target_complete_cmd() completes t_transport_stop_comp.
* Once transport_wait_for_tasks() returns the target core considers the TMF as finished.
--- drivers/scsi/qla2xxx/tcm_qla2xxx.c | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-)
drivers/scsi/qla2xxx/tcm_qla2xxx.c +5 -21
@@ -414,21 +414,14 @@ static int tcm_qla2xxx_write_pending(struct se_cmd *se_cmd)static int tcm_qla2xxx_write_pending_status (struct se_cmd *se_cmd) {unsigned long flags; -/* -* Check for WRITE_PENDING status to determine if we need to wait for -* CTIO aborts to be posted via hardware in tcm_qla2xxx_handle_data(). -*/ +bool wp; +spin_lock_irqsave (&se_cmd->t_state_lock, flags); -if (se_cmd->t_state =TRANSPORT_WRITE_PENDING || - se_cmd->t_state =TRANSPORT_COMPLETE_QF_WP ) { -spin_unlock_irqrestore (&se_cmd->t_state_lock, flags); -wait_for_completion_timeout (&se_cmd->t_transport_stop_comp, -50 ); -return 0 ; - } + wp = se_cmd->t_state =TRANSPORT_WRITE_PENDING || + se_cmd->t_state =TRANSPORT_COMPLETE_QF_WP ;spin_unlock_irqrestore (&se_cmd->t_state_lock, flags); -return 0 ; +return wp; }static void tcm_qla2xxx_set_default_node_attrs (struct se_node_acl *nacl)
@@ -508,15 +501,6 @@ static void tcm_qla2xxx_handle_data_work(struct work_struct *work) cmd->qpair->tgt_counters.qla_core_ret_ctio++;if (!cmd->write_data_transferred) { -/* -* Check if se_cmd has already been aborted via LUN_RESET, and -* waiting upon completion in tcm_qla2xxx_write_pending_status() -*/ -if (cmd->se_cmd.transport_state &CMD_T_ABORTED ) { -complete (&cmd->se_cmd.t_transport_stop_comp); -return ; - } -switch (cmd->dif_err_code) {case DIF_ERR_GRD : cmd->se_cmd.pi_err --
2.18.0
On Mon, 2018-09-17 at 14:35 -0700, Bart Van Assche wrote:
+AD4 Since the target core waits anyway until a target driver has
+AD4 finished processing a command, remove similar waiting code from
+AD4 the tcm+AF8-qla2xxx driver. With this change applied command abortion
+AD4 works as follows:
+AD4 +ACo tcm+AF8-qla2xxx receives an ABTS and calls target+AF8-submit+AF8-tmr(). +AD4 +ACo The target core calls core+AF8-tmr+AF8-abort+AF8-task(). That function
+AD4 sets the CMD+AF8-T+AF8-ABORTED flag and next calls transport+AF8-wait+AF8-for+AF8-tasks().
+AD4 +ACo If CMD+AF8-T+AF8-ACTIVE is still set, +AF8AXw-transport+AF8-wait+AF8-for+AF8-tasks() sets
+AD4 CMD+AF8-T+AF8-STOP and waits for t+AF8-transport+AF8-stop+AF8-comp.
+AD4 +ACo When tcm+AF8-qla2xxx+AF8-handle+AF8-data+AF8-work() gets called, it either invokes
+AD4 transport+AF8-generic+AF8-request+AF8-failure() or target+AF8-execute+AF8-cmd().
+AD4 +ACo Both functions start with calling +AF8AXw-transport+AF8-check+AF8-aborted+AF8-status()
+AD4 and return 1 if CMD+AF8-T+AF8-ABORTED was set. Otherwise the command that +AD4 is being executed is completed and target+AF8-complete+AF8-cmd() completes +AD4 t+AF8-transport+AF8-stop+AF8-comp.
+AD4 +ACo Once transport+AF8-wait+AF8-for+AF8-tasks() returns the target core considers
+AD4 the TMF as finished.
+AD4
+AD4 Signed-off-by: Bart Van Assche +ADw-bvanassche+AEA-acm.org+AD4
+AD4 Cc: Himanshu Madhani +ADw-himanshu.madhani+AEA-cavium.com+AD4
+AD4 Cc: Quinn Tran +ADw-quinn.tran+AEA-cavium.com+AD4
+AD4 Cc: Nicholas Bellinger +ADw-nab+AEA-linux-iscsi.org+AD4
+AD4 Cc: Mike Christie +ADw-mchristi+AEA-redhat.com+AD4
+AD4 Cc: Christoph Hellwig +ADw-hch+AEA-lst.de+AD4
+AD4 Cc: Hannes Reinecke +ADw-hare+AEA-suse.de+AD4
Hello Himanshu and Quinn,
Can one of you review this patch?
Thanks,
Bart.
Quoted 32 lines · Bart Van Assche
External Email
Quoted 18 lines · Bart Van Assche
Since the target core waits anyway until a target driver has finished processing a command, remove similar waiting code from the
tcm_qla2xxxdriver. With this change applied command abortion works as follows:
*tcm_qla2xxxreceives an ABTS and callstarget_submit_tmr().
* The target core callscore_tmr_abort_task(). That function sets theCMD_T_ABORTEDflag and next callstransport_wait_for_tasks().
* IfCMD_T_ACTIVEis still set,__transport_wait_for_tasks()setsCMD_T_STOPand waits fort_transport_stop_comp.
* Whentcm_qla2xxx_handle_data_work()gets called, it either invokestransport_generic_request_failure()ortarget_execute_cmd().
* Both functions start with calling__transport_check_aborted_status()and return 1 ifCMD_T_ABORTEDwas set. Otherwise the command that is being executed is completed andtarget_complete_cmd()completest_transport_stop_comp.
* Oncetransport_wait_for_tasks()returns the target core considers the TMF as finished.Quoted 7 lines
Signed-off-by Bart Van Assche <[email protected]>Cc Himanshu Madhani <[email protected]>Cc Quinn Tran <[email protected]>Cc Nicholas Bellinger <[email protected]>Cc Mike Christie <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>
Quoted 8 lines
Hello Himanshu and Quinn,
Can one of you review this patch?
Thanks,
Bart.
Apologies for delay. Still reviewing the patch
Thanks,
- Himanshu
Hi Bart,
Apologies for long delay
Quoted 81 lines · Bart Van Assche
External Email
Since the target core waits anyway until a target driver has finished processing a command, remove similar waiting code from the
tcm_qla2xxxdriver. With this change applied command abortion works as follows:
*tcm_qla2xxxreceives an ABTS and callstarget_submit_tmr().
* The target core callscore_tmr_abort_task(). That function sets theCMD_T_ABORTEDflag and next callstransport_wait_for_tasks().
* IfCMD_T_ACTIVEis still set,__transport_wait_for_tasks()setsCMD_T_STOPand waits fort_transport_stop_comp.
* Whentcm_qla2xxx_handle_data_work()gets called, it either invokestransport_generic_request_failure()ortarget_execute_cmd().
* Both functions start with calling__transport_check_aborted_status()and return 1 ifCMD_T_ABORTEDwas set. Otherwise the command that is being executed is completed andtarget_complete_cmd()completest_transport_stop_comp.
* Oncetransport_wait_for_tasks()returns the target core considers the TMF as finished.Signed-off-by Bart Van Assche <[email protected]>Cc Himanshu Madhani <[email protected]>Cc Quinn Tran <[email protected]>Cc Nicholas Bellinger <[email protected]>Cc Mike Christie <[email protected]>Cc Christoph Hellwig <[email protected]>Cc Hannes Reinecke <[email protected]>---
drivers/scsi/qla2xxx/tcm_qla2xxx.c| 26 +++++---------------------1 file changed, 5 insertions(+), 21 deletions(-)drivers/scsi/qla2xxx/tcm_qla2xxx.c +5
-22@@ -414,21 +414,14 @@ static int tcm_qla2xxx_write_pending(struct se_cmd *se_cmd)static int tcm_qla2xxx_write_pending_status (struct se_cmd *se_cmd) {unsigned long flags; -/* -* Check for WRITE_PENDING status to determine if we need to wait for -* CTIO aborts to be posted via hardware in tcm_qla2xxx_handle_data(). -*/ +bool wp; +spin_lock_irqsave (&se_cmd->t_state_lock, flags); -if (se_cmd->t_state ==TRANSPORT_WRITE_PENDING || - se_cmd->t_state ==TRANSPORT_COMPLETE_QF_WP ) { -spin_unlock_irqrestore (&se_cmd->t_state_lock, flags); -wait_for_completion_timeout (&se_cmd->t_transport_stop_comp, -50 ); -return 0 ; - } + wp = se_cmd->t_state ==TRANSPORT_WRITE_PENDING || + se_cmd->t_state ==TRANSPORT_COMPLETE_QF_WP ;spin_unlock_irqrestore (&se_cmd->t_state_lock, flags); -return 0 ; +return wp; }static void tcm_qla2xxx_set_default_node_attrs (struct se_node_acl *nacl)@@ -508,15 +501,6 @@ static void tcm_qla2xxx_handle_data_work(struct work_struct *work) cmd->qpair->tgt_counters.qla_core_ret_ctio++;if (!cmd->write_data_transferred) { -/* -* Check if se_cmd has already been aborted via LUN_RESET, and -* waiting upon completion in tcm_qla2xxx_write_pending_status() -*/ -if (cmd->se_cmd.transport_state &CMD_T_ABORTED ) { -complete (&cmd->se_cmd.t_transport_stop_comp); -return ; - } -switch (cmd->dif_err_code) {case DIF_ERR_GRD : cmd->se_cmd.pi_err = --
Quoted 2 lines
2.18.0
Patch Looks good.
Thanks,
- Himanshu