Due to the task management function rework it is safe to wait for a TMF that is not in the "active" state. Hence remove the CMD_T_ACTIVE flag and also the command state tests from the TMR handling code. Signed-off-by: Bart Van Assche <bart.vanassche@xxxxxxxxxxx> Reviewed-by: Andy Grover <agrover@xxxxxxxxxx> Cc: Christoph Hellwig <hch@xxxxxx> Cc: Hannes Reinecke <hare@xxxxxxx> Cc: Sagi Grimberg <sagig@xxxxxxxxxxxx> --- drivers/infiniband/ulp/srpt/ib_srpt.c | 5 ----- drivers/target/target_core_sbc.c | 2 +- drivers/target/target_core_tmr.c | 15 +-------------- drivers/target/target_core_transport.c | 24 +++++------------------- include/target/target_core_base.h | 1 - 5 files changed, 7 insertions(+), 40 deletions(-) diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index 903d9af..8c22b28 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c @@ -1351,11 +1351,6 @@ static int srpt_abort_cmd(struct srpt_send_ioctx *ioctx) break; case SRPT_STATE_NEED_DATA: /* DMA_TO_DEVICE (write) - RDMA read error. */ - - /* XXX(hch): this is a horrible layering violation.. */ - spin_lock_irqsave(&ioctx->cmd.t_state_lock, flags); - ioctx->cmd.transport_state &= ~CMD_T_ACTIVE; - spin_unlock_irqrestore(&ioctx->cmd.t_state_lock, flags); break; case SRPT_STATE_CMD_RSP_SENT: /* diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c index 8e30765..7e2a79d 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c @@ -586,7 +586,7 @@ static sense_reason_t compare_and_write_callback(struct se_cmd *cmd, bool succes spin_lock_irq(&cmd->t_state_lock); cmd->t_state = TRANSPORT_PROCESSING; - cmd->transport_state |= CMD_T_ACTIVE|CMD_T_SENT; + cmd->transport_state |= CMD_T_SENT; spin_unlock_irq(&cmd->t_state_lock); __target_execute_cmd(cmd); diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c index df20630..c7c4414 100644 --- a/drivers/target/target_core_tmr.c +++ b/drivers/target/target_core_tmr.c @@ -186,17 +186,6 @@ static void core_tmr_drain_tmr_list( if (target_check_cdb_and_preempt(preempt_and_abort_list, cmd)) continue; - spin_lock(&cmd->t_state_lock); - if (!(cmd->transport_state & CMD_T_ACTIVE)) { - spin_unlock(&cmd->t_state_lock); - continue; - } - if (cmd->t_state == TRANSPORT_ISTATE_PROCESSING) { - spin_unlock(&cmd->t_state_lock); - continue; - } - spin_unlock(&cmd->t_state_lock); - /* * Don't try to move a command without a zero refount, * it has been completed already as will be removed from @@ -315,10 +304,8 @@ static void core_tmr_drain_state_list( cmd->se_tfo->get_cmd_state(cmd), cmd->t_state, cmd->t_task_cdb[0]); pr_debug("LUN_RESET: ITT[0x%08llx] - pr_res_key: 0x%016Lx" - " -- CMD_T_ACTIVE: %d" - " CMD_T_STOP: %d CMD_T_SENT: %d\n", + " -- CMD_T_STOP: %d CMD_T_SENT: %d\n", cmd->tag, cmd->pr_res_key, - (cmd->transport_state & CMD_T_ACTIVE) != 0, (cmd->transport_state & CMD_T_STOP) != 0, (cmd->transport_state & CMD_T_SENT) != 0); diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index d41225b..7671f68 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -585,7 +585,6 @@ static int transport_cmd_check_stop(struct se_cmd *cmd, bool remove_from_lists, return 1; } - cmd->transport_state &= ~CMD_T_ACTIVE; if (remove_from_lists) { /* * Some fabric modules like tcm_loop can release @@ -712,7 +711,7 @@ void target_complete_cmd(struct se_cmd *cmd, u8 scsi_status) } cmd->t_state = TRANSPORT_COMPLETE; - cmd->transport_state |= (CMD_T_COMPLETE | CMD_T_ACTIVE); + cmd->transport_state |= CMD_T_COMPLETE; spin_unlock_irqrestore(&cmd->t_state_lock, flags); queue_work(target_completion_wq, &cmd->work); @@ -1327,7 +1326,7 @@ int transport_handle_cdb_direct( return -EINVAL; } /* - * Set TRANSPORT_NEW_CMD state and CMD_T_ACTIVE to ensure that + * Set TRANSPORT_NEW_CMD state to ensure that * outstanding descriptors are handled correctly during shutdown via * transport_wait_for_tasks() * @@ -1335,7 +1334,6 @@ int transport_handle_cdb_direct( * this to be called for initial descriptor submission. */ cmd->t_state = TRANSPORT_NEW_CMD; - cmd->transport_state |= CMD_T_ACTIVE; /* * transport_generic_new_cmd() is already handling QUEUE_FULL, @@ -1637,8 +1635,7 @@ void transport_generic_request_failure(struct se_cmd *cmd, pr_debug("-----[ i_state: %d t_state: %d sense_reason: %d\n", cmd->se_tfo->get_cmd_state(cmd), cmd->t_state, sense_reason); - pr_debug("-----[ CMD_T_ACTIVE: %d CMD_T_STOP: %d CMD_T_SENT: %d\n", - (cmd->transport_state & CMD_T_ACTIVE) != 0, + pr_debug("-----[ CMD_T_STOP: %d CMD_T_SENT: %d\n", (cmd->transport_state & CMD_T_STOP) != 0, (cmd->transport_state & CMD_T_SENT) != 0); @@ -1842,7 +1839,7 @@ void target_execute_cmd(struct se_cmd *cmd) spin_lock_irq(&cmd->t_state_lock); cmd->t_state = TRANSPORT_PROCESSING; - cmd->transport_state |= CMD_T_ACTIVE|CMD_T_SENT; + cmd->transport_state |= CMD_T_SENT; spin_unlock_irq(&cmd->t_state_lock); if (target_write_prot_action(cmd)) @@ -2603,11 +2600,6 @@ bool transport_wait_for_tasks(struct se_cmd *cmd) return false; } - if (!(cmd->transport_state & CMD_T_ACTIVE)) { - spin_unlock_irqrestore(&cmd->t_state_lock, flags); - return false; - } - cmd->transport_state |= CMD_T_STOP; pr_debug("wait_for_tasks: Stopping %p ITT: 0x%08llx i_state: %d, t_state: %d, CMD_T_STOP\n", @@ -2618,7 +2610,7 @@ bool transport_wait_for_tasks(struct se_cmd *cmd) wait_for_completion(&cmd->finished); spin_lock_irqsave(&cmd->t_state_lock, flags); - cmd->transport_state &= ~(CMD_T_ACTIVE | CMD_T_STOP); + cmd->transport_state &= ~CMD_T_STOP; pr_debug("wait_for_tasks: Stopped wait_for_completion(&cmd->t_transport_stop_comp) for ITT: 0x%08llx\n", cmd->tag); @@ -2855,12 +2847,6 @@ static void target_tmr_work(struct work_struct *work) int transport_generic_handle_tmr( struct se_cmd *cmd) { - unsigned long flags; - - spin_lock_irqsave(&cmd->t_state_lock, flags); - cmd->transport_state |= CMD_T_ACTIVE; - spin_unlock_irqrestore(&cmd->t_state_lock, flags); - INIT_WORK(&cmd->work, target_tmr_work); queue_work(cmd->se_dev->tmr_wq, &cmd->work); return 0; diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 4727812..2fa13ca 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -483,7 +483,6 @@ struct se_cmd { unsigned int t_task_nolb; unsigned int transport_state; #define CMD_T_ABORTED (1 << 0) -#define CMD_T_ACTIVE (1 << 1) #define CMD_T_COMPLETE (1 << 2) #define CMD_T_SENT (1 << 4) #define CMD_T_STOP (1 << 5) -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html