diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 653a7fcec..b4565c268 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -4756,8 +4756,6 @@ static void scst_ws_write_cmd_finished(struct scst_cmd *cmd) cmd->sg = NULL; cmd->sg_cnt = 0; - EXTRACHECKS_BUG_ON(!cmd->completed); - mutex_lock(&wsp->ws_mutex); wsp->ws_cur_in_flight--; @@ -4782,13 +4780,13 @@ static void scst_ws_write_cmd_finished(struct scst_cmd *cmd) } if (wsp->ws_left_to_send == 0) - goto out_check_finished; + goto out_check_finish; blocks = min_t(int, wsp->ws_left_to_send, wsp->ws_max_each); rc = scst_ws_push_single_write(wsp, wsp->ws_cur_lba, blocks); if (rc != 0) - goto out_check_finished; + goto out_check_finish; wake_up(&ws_cmd->cmd_threads->cmd_list_waitQ); @@ -4799,7 +4797,7 @@ out: TRACE_EXIT(); return; -out_check_finished: +out_check_finish: if (wsp->ws_cur_in_flight > 0) goto out_unlock; @@ -8540,9 +8538,9 @@ char *scst_get_next_token_str(char **input_str) } EXPORT_SYMBOL_GPL(scst_get_next_token_str); -static bool scst_parse_unmap_descriptors(struct scst_cmd *cmd) +static int scst_parse_unmap_descriptors(struct scst_cmd *cmd) { - int res = false; + int res = 0; ssize_t length = 0; uint8_t *address; int i, cnt, offset, descriptor_len, total_len; @@ -8620,7 +8618,7 @@ out_abn_put: out_abn: scst_set_cmd_abnormal_done_state(cmd); - res = true; + res = -1; goto out; } @@ -8635,9 +8633,9 @@ static void scst_free_unmap_descriptors(struct scst_cmd *cmd) return; } -bool scst_parse_descriptors(struct scst_cmd *cmd) +int scst_parse_descriptors(struct scst_cmd *cmd) { - bool res; + int res; TRACE_ENTRY(); diff --git a/scst/src/scst_priv.h b/scst/src/scst_priv.h index d29d14bdb..af18bbd4d 100644 --- a/scst/src/scst_priv.h +++ b/scst/src/scst_priv.h @@ -686,6 +686,7 @@ static inline void scst_destroy_cmd(struct scst_cmd *cmd) static inline void __scst_cmd_get(struct scst_cmd *cmd) { atomic_inc(&cmd->cmd_ref); + smp_mb__after_atomic_inc(); TRACE_DBG("Incrementing cmd %p ref (new value %d)", cmd, atomic_read(&cmd->cmd_ref)); } @@ -698,11 +699,11 @@ static inline void __scst_cmd_put(struct scst_cmd *cmd) scst_free_cmd(cmd); } -extern void scst_throttle_cmd(struct scst_cmd *cmd); -extern void scst_unthrottle_cmd(struct scst_cmd *cmd); +void scst_throttle_cmd(struct scst_cmd *cmd); +void scst_unthrottle_cmd(struct scst_cmd *cmd); int scst_do_internal_parsing(struct scst_cmd *cmd); -bool scst_parse_descriptors(struct scst_cmd *cmd); +int scst_parse_descriptors(struct scst_cmd *cmd); #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) void scst_vfs_unlink_and_put(struct nameidata *nd); diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index f0630b30f..82aeefae6 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -1179,7 +1179,11 @@ void scst_restart_cmd(struct scst_cmd *cmd, int status, switch (status) { case SCST_PREPROCESS_STATUS_SUCCESS: - if (cmd->data_direction & SCST_DATA_WRITE) + if (unlikely(cmd->tgt_dev == NULL)) { + cmd->state = SCST_CMD_STATE_PRE_XMIT_RESP; + pref_context = SCST_CONTEXT_THREAD; + break; + } else if (cmd->data_direction & SCST_DATA_WRITE) cmd->state = SCST_CMD_STATE_RDY_TO_XFER; else cmd->state = SCST_CMD_STATE_TGT_PRE_EXEC; @@ -1575,8 +1579,8 @@ static int scst_tgt_pre_exec(struct scst_cmd *cmd) out_descr: if (unlikely(cmd->op_flags & SCST_DESCRIPTORS_BASED)) { - bool r = scst_parse_descriptors(cmd); - if (unlikely(r)) + int r = scst_parse_descriptors(cmd); + if (unlikely(r != 0)) goto out; }