From 04040543ce9c54fc85a9399c909ba5849719b238 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Fri, 20 Jul 2012 23:41:05 +0000 Subject: [PATCH] Cleanup git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4414 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_lib.c | 23 +++++------------------ scst/src/scst_priv.h | 26 +++++++++++++++++--------- 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 4e954e187..653a7fcec 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -87,7 +87,6 @@ static int sg_copy(struct scatterlist *dst_sg, struct scatterlist *src_sg, #endif static void scst_free_descriptors(struct scst_cmd *cmd); -static void scst_destroy_put_cmd(struct scst_cmd *cmd); struct scst_sdbops; @@ -4494,6 +4493,8 @@ static struct scst_cmd *scst_create_prepare_internal_cmd( if (res->tgt_dev != NULL) res->cpu_cmd_counter = scst_get(); + scst_set_start_time(res); + TRACE(TRACE_SCSI, "New internal cmd %p (op 0x%x)", res, res->cdb[0]); rc = scst_pre_parse(res); @@ -4710,7 +4711,7 @@ out: return res; out_destroy: - scst_destroy_put_cmd(cmd); + scst_destroy_cmd(cmd); out_busy: scst_set_busy(ws_cmd); @@ -5312,20 +5313,6 @@ out_free: goto out; } -static void scst_destroy_put_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)) - scst_put(cmd->cpu_cmd_counter); - - scst_destroy_cmd(cmd); - return; -} - /* No locks supposed to be held */ void scst_free_cmd(struct scst_cmd *cmd) { @@ -5407,7 +5394,7 @@ void scst_free_cmd(struct scst_cmd *cmd) kfree(cmd->cdb); if (likely(destroy)) - scst_destroy_put_cmd(cmd); + scst_destroy_cmd(cmd); TRACE_EXIT(); return; @@ -7961,7 +7948,7 @@ restart: spin_unlock_irq(&order_data->sn_lock); if (test_and_set_bit(SCST_CMD_CAN_BE_DESTROYED, &cmd->cmd_flags)) - scst_destroy_put_cmd(cmd); + scst_destroy_cmd(cmd); scst_inc_expected_sn(order_data, slot); expected_sn = order_data->expected_sn; spin_lock_irq(&order_data->sn_lock); diff --git a/scst/src/scst_priv.h b/scst/src/scst_priv.h index 15ef072c9..d29d14bdb 100644 --- a/scst/src/scst_priv.h +++ b/scst/src/scst_priv.h @@ -352,15 +352,6 @@ struct scst_session *scst_alloc_session(struct scst_tgt *tgt, gfp_t gfp_mask, void scst_free_session(struct scst_session *sess); void scst_free_session_callback(struct scst_session *sess); -struct scst_cmd *scst_alloc_cmd(const uint8_t *cdb, - unsigned int cdb_len, gfp_t gfp_mask); -void scst_free_cmd(struct scst_cmd *cmd); -static inline void scst_destroy_cmd(struct scst_cmd *cmd) -{ - kmem_cache_free(scst_cmd_cachep, cmd); - return; -} - void scst_check_retries(struct scst_tgt *tgt); #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) @@ -675,6 +666,23 @@ static inline void scst_sess_put(struct scst_session *sess) scst_sched_session_free(sess); } +struct scst_cmd *scst_alloc_cmd(const uint8_t *cdb, + unsigned int cdb_len, gfp_t gfp_mask); +void scst_free_cmd(struct scst_cmd *cmd); +static inline 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)) + scst_put(cmd->cpu_cmd_counter); + + kmem_cache_free(scst_cmd_cachep, cmd); + return; +} + static inline void __scst_cmd_get(struct scst_cmd *cmd) { atomic_inc(&cmd->cmd_ref);