From ee2b9c3a9dc7014e378779bad639dbf2f0f89721 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Sat, 19 Jul 2014 04:08:30 +0000 Subject: [PATCH] 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 git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5684 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_targ.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index a490321d7..d1b5cd079 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -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