scst: Clean up scst_process_active_cmd()

Since inside scst_process_active_cmd() cmd->state can only change after
cmd has been added back to the command list it is safe to perform the
cmd->state check without holding the command list lock. Hence move the
perform the cmd->state check without holding the command list lock.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>



git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5684 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2014-07-19 04:08:30 +00:00
parent 726be64769
commit ee2b9c3a9d

View File

@@ -4845,7 +4845,6 @@ void scst_process_active_cmd(struct scst_cmd *cmd, bool atomic)
if (res == SCST_CMD_STATE_RES_CONT_NEXT) {
/* None */
} else if (res == SCST_CMD_STATE_RES_NEED_THREAD) {
spin_lock_irq(&cmd->cmd_threads->cmd_list_lock);
#ifdef CONFIG_SCST_EXTRACHECKS
switch (cmd->state) {
case SCST_CMD_STATE_PARSE:
@@ -4858,22 +4857,18 @@ void scst_process_active_cmd(struct scst_cmd *cmd, bool atomic)
case SCST_CMD_STATE_REAL_EXEC:
case SCST_CMD_STATE_DEV_DONE:
case SCST_CMD_STATE_XMIT_RESP:
#endif
TRACE_DBG("Adding cmd %p to head of active cmd list",
cmd);
list_add(&cmd->cmd_list_entry,
&cmd->cmd_threads->active_cmd_list);
#ifdef CONFIG_SCST_EXTRACHECKS
break;
default:
PRINT_CRIT_ERROR("cmd %p is in invalid state %d)", cmd,
cmd->state);
#if !defined(__CHECKER__)
spin_unlock_irq(&cmd->cmd_threads->cmd_list_lock);
#endif
sBUG();
}
#endif
TRACE_DBG("Adding cmd %p to head of active cmd list", cmd);
spin_lock_irq(&cmd->cmd_threads->cmd_list_lock);
list_add(&cmd->cmd_list_entry,
&cmd->cmd_threads->active_cmd_list);
wake_up(&cmd->cmd_threads->cmd_list_waitQ);
spin_unlock_irq(&cmd->cmd_threads->cmd_list_lock);
} else