From ed0ed73f08a79c846cb3173ebe0b159ab1e837f1 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 8 Mar 2019 03:01:27 +0000 Subject: [PATCH] scst: Remove scst_mgmt_cmd.scst_get_called This patch does not change any functionality. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8016 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/scst.h | 1 - scst/src/scst_lib.c | 11 ++++++----- scst/src/scst_targ.c | 5 ++++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/scst/include/scst.h b/scst/include/scst.h index 0bc6d71de..a3f608932 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -2627,7 +2627,6 @@ struct scst_mgmt_cmd { unsigned int needs_unblocking:1; unsigned int lun_set:1; /* set, if lun field is valid */ unsigned int cmd_sn_set:1; /* set, if cmd_sn field is valid */ - unsigned int scst_get_called:1; /* set, if scst_get() was called */ /* Set if dev handler's task_mgmt_fn_received was called */ unsigned int task_mgmt_fn_received_called:1; unsigned int mcmd_dropped:1; /* set if mcmd was dropped */ diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 0220c4c42..877b4e893 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -7338,11 +7338,10 @@ static void scst_destroy_cmd(struct scst_cmd *cmd) scst_sess_put(cmd->sess); - /* - * At this point tgt_dev can be dead, but the pointer remains non-NULL - */ - if (likely(cmd->tgt_dev != NULL)) + if (likely(cmd->cpu_cmd_counter)) { scst_put(cmd->cpu_cmd_counter); + cmd->cpu_cmd_counter = NULL; + } EXTRACHECKS_BUG_ON(cmd->pre_alloced && cmd->internal); @@ -7582,8 +7581,10 @@ void scst_free_mgmt_cmd(struct scst_mgmt_cmd *mcmd) scst_sess_put(mcmd->sess); - if ((mcmd->mcmd_tgt_dev != NULL) || mcmd->scst_get_called) + if (mcmd->cpu_cmd_counter) { scst_put(mcmd->cpu_cmd_counter); + mcmd->cpu_cmd_counter = NULL; + } mempool_free(mcmd, scst_mgmt_mempool); diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index 741d82a98..e883a09e5 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -5023,9 +5023,11 @@ static int scst_translate_lun(struct scst_cmd *cmd) scst_event_queue_lun_not_found(cmd); } scst_put(cmd->cpu_cmd_counter); + cmd->cpu_cmd_counter = NULL; } } else { scst_put(cmd->cpu_cmd_counter); + cmd->cpu_cmd_counter = NULL; TRACE_MGMT_DBG("%s", "FLAG SUSPENDED set, skipping"); res = 1; } @@ -5831,6 +5833,7 @@ static int scst_get_mgmt(struct scst_mgmt_cmd *mcmd) if (unlikely(test_bit(SCST_FLAG_SUSPENDED, &scst_flags) && !test_bit(SCST_FLAG_SUSPENDING, &scst_flags))) { scst_put(mcmd->cpu_cmd_counter); + mcmd->cpu_cmd_counter = NULL; TRACE_MGMT_DBG("%s", "FLAG SUSPENDED set, skipping"); res = 1; goto out; @@ -5870,6 +5873,7 @@ static int scst_mgmt_translate_lun(struct scst_mgmt_cmd *mcmd) res = 0; } else { scst_put(mcmd->cpu_cmd_counter); + mcmd->cpu_cmd_counter = NULL; res = -1; } @@ -6718,7 +6722,6 @@ static int scst_mgmt_cmd_init(struct scst_mgmt_cmd *mcmd) rc = scst_get_mgmt(mcmd); if (rc == 0) { mcmd->state = SCST_MCMD_STATE_EXEC; - mcmd->scst_get_called = 1; } else { EXTRACHECKS_BUG_ON(rc < 0); res = rc;