From 18c99cc2cf90457dbbfd010ba3655c28f0aaf525 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Mon, 2 Nov 2009 18:43:22 +0000 Subject: [PATCH] Merge of r1300: Fix for the wrong mcmd state assignment if scst_mgmt_translate_lun() returns >0 because of suspending. Found by Gilad / git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/1.0.1.x@1311 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_targ.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index 2688dc34e..adb7192ac 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -4303,8 +4303,6 @@ static int scst_mgmt_cmd_init(struct scst_mgmt_cmd *mcmd) TRACE_ENTRY(); - mcmd->state = SCST_MCMD_STATE_READY; - switch (mcmd->fn) { case SCST_ABORT_TASK: { @@ -4359,6 +4357,7 @@ static int scst_mgmt_cmd_init(struct scst_mgmt_cmd *mcmd) case SCST_NEXUS_LOSS: case SCST_ABORT_ALL_TASKS: case SCST_UNREG_SESS_TM: + mcmd->state = SCST_MCMD_STATE_READY; break; case SCST_ABORT_TASK_SET: @@ -4366,12 +4365,14 @@ static int scst_mgmt_cmd_init(struct scst_mgmt_cmd *mcmd) case SCST_CLEAR_TASK_SET: case SCST_LUN_RESET: rc = scst_mgmt_translate_lun(mcmd); - if (rc < 0) { + if (rc == 0) + mcmd->state = SCST_MCMD_STATE_READY; + else if (rc < 0) { PRINT_ERROR("Corresponding device for LUN %lld not " "found", (long long unsigned int)mcmd->lun); mcmd->status = SCST_MGMT_STATUS_LUN_NOT_EXIST; mcmd->state = SCST_MCMD_STATE_DONE; - } else if (rc != 0) + } else res = rc; break;