Commit 82f1c8a4 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Nicholas Bellinger

target: push session reinstatement out of transport_generic_free_cmd

Push session reinstatement out of transport_generic_free_cmd into the only
caller that actually needs it.  Clean up transport_generic_free_cmd a bit,
and remove the useless comment.  I'd love to add a more useful kerneldoc
comment for it, but as this point I'm still a bit confused in where it
stands in the command release stack.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent e6a2573f
...@@ -3547,7 +3547,7 @@ int iscsi_target_tx_thread(void *arg) ...@@ -3547,7 +3547,7 @@ int iscsi_target_tx_thread(void *arg)
iscsit_release_cmd(cmd); iscsit_release_cmd(cmd);
else else
transport_generic_free_cmd(&cmd->se_cmd, transport_generic_free_cmd(&cmd->se_cmd,
1, 0); 1);
goto get_immediate; goto get_immediate;
case ISTATE_SEND_NOPIN_WANT_RESPONSE: case ISTATE_SEND_NOPIN_WANT_RESPONSE:
spin_unlock_bh(&cmd->istate_lock); spin_unlock_bh(&cmd->istate_lock);
......
...@@ -200,7 +200,7 @@ static void tcm_loop_check_stop_free(struct se_cmd *se_cmd) ...@@ -200,7 +200,7 @@ static void tcm_loop_check_stop_free(struct se_cmd *se_cmd)
* Release the struct se_cmd, which will make a callback to release * Release the struct se_cmd, which will make a callback to release
* struct tcm_loop_cmd * in tcm_loop_deallocate_core_cmd() * struct tcm_loop_cmd * in tcm_loop_deallocate_core_cmd()
*/ */
transport_generic_free_cmd(se_cmd, 0, 0); transport_generic_free_cmd(se_cmd, 0);
} }
static void tcm_loop_release_cmd(struct se_cmd *se_cmd) static void tcm_loop_release_cmd(struct se_cmd *se_cmd)
...@@ -388,7 +388,7 @@ static int tcm_loop_device_reset(struct scsi_cmnd *sc) ...@@ -388,7 +388,7 @@ static int tcm_loop_device_reset(struct scsi_cmnd *sc)
SUCCESS : FAILED; SUCCESS : FAILED;
release: release:
if (se_cmd) if (se_cmd)
transport_generic_free_cmd(se_cmd, 1, 0); transport_generic_free_cmd(se_cmd, 1);
else else
kmem_cache_free(tcm_loop_cmd_cache, tl_cmd); kmem_cache_free(tcm_loop_cmd_cache, tl_cmd);
kfree(tl_tmr); kfree(tl_tmr);
......
...@@ -4331,42 +4331,25 @@ void transport_release_cmd(struct se_cmd *cmd) ...@@ -4331,42 +4331,25 @@ void transport_release_cmd(struct se_cmd *cmd)
} }
EXPORT_SYMBOL(transport_release_cmd); EXPORT_SYMBOL(transport_release_cmd);
/* transport_generic_free_cmd(): bool transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks)
*
* Called from processing frontend to release storage engine resources
*/
void transport_generic_free_cmd(
struct se_cmd *cmd,
int wait_for_tasks,
int session_reinstatement)
{ {
if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD)) if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD))
transport_release_cmd(cmd); transport_release_cmd(cmd);
else { else {
core_dec_lacl_count(cmd->se_sess->se_node_acl, cmd); core_dec_lacl_count(cmd->se_sess->se_node_acl, cmd);
if (cmd->se_lun) { if (cmd->se_lun)
#if 0
pr_debug("cmd: %p ITT: 0x%08x contains"
" cmd->se_lun\n", cmd,
cmd->se_tfo->get_task_tag(cmd));
#endif
transport_lun_remove_cmd(cmd); transport_lun_remove_cmd(cmd);
}
if (wait_for_tasks && cmd->transport_wait_for_tasks) if (wait_for_tasks && cmd->transport_wait_for_tasks)
cmd->transport_wait_for_tasks(cmd, 0, 0); cmd->transport_wait_for_tasks(cmd, 0, 0);
transport_free_dev_tasks(cmd); transport_free_dev_tasks(cmd);
if (!transport_put_cmd(cmd) && session_reinstatement) { return transport_put_cmd(cmd);
unsigned long flags;
spin_lock_irqsave(&cmd->t_state_lock, flags);
transport_all_task_dev_remove_state(cmd);
spin_unlock_irqrestore(&cmd->t_state_lock, flags);
}
} }
return true;
} }
EXPORT_SYMBOL(transport_generic_free_cmd); EXPORT_SYMBOL(transport_generic_free_cmd);
...@@ -4631,7 +4614,13 @@ static void transport_generic_wait_for_tasks( ...@@ -4631,7 +4614,13 @@ static void transport_generic_wait_for_tasks(
if (!remove_cmd) if (!remove_cmd)
return; return;
transport_generic_free_cmd(cmd, 0, session_reinstatement); if (!transport_generic_free_cmd(cmd, 0) && session_reinstatement) {
unsigned long flags;
spin_lock_irqsave(&cmd->t_state_lock, flags);
transport_all_task_dev_remove_state(cmd);
spin_unlock_irqrestore(&cmd->t_state_lock, flags);
}
} }
static int transport_get_sense_codes( static int transport_get_sense_codes(
...@@ -5181,7 +5170,7 @@ static int transport_processing_thread(void *param) ...@@ -5181,7 +5170,7 @@ static int transport_processing_thread(void *param)
transport_put_cmd(cmd); transport_put_cmd(cmd);
break; break;
case TRANSPORT_FREE_CMD_INTR: case TRANSPORT_FREE_CMD_INTR:
transport_generic_free_cmd(cmd, 0, 0); transport_generic_free_cmd(cmd, 0);
break; break;
case TRANSPORT_PROCESS_TMR: case TRANSPORT_PROCESS_TMR:
transport_generic_do_tmr(cmd); transport_generic_do_tmr(cmd);
......
...@@ -114,7 +114,7 @@ void ft_release_cmd(struct se_cmd *se_cmd) ...@@ -114,7 +114,7 @@ void ft_release_cmd(struct se_cmd *se_cmd)
void ft_check_stop_free(struct se_cmd *se_cmd) void ft_check_stop_free(struct se_cmd *se_cmd)
{ {
transport_generic_free_cmd(se_cmd, 0, 0); transport_generic_free_cmd(se_cmd, 0);
} }
/* /*
...@@ -269,7 +269,7 @@ static void ft_recv_seq(struct fc_seq *sp, struct fc_frame *fp, void *arg) ...@@ -269,7 +269,7 @@ static void ft_recv_seq(struct fc_seq *sp, struct fc_frame *fp, void *arg)
/* XXX need to find cmd if queued */ /* XXX need to find cmd if queued */
cmd->se_cmd.t_state = TRANSPORT_REMOVE; cmd->se_cmd.t_state = TRANSPORT_REMOVE;
cmd->seq = NULL; cmd->seq = NULL;
transport_generic_free_cmd(&cmd->se_cmd, 0, 0); transport_generic_free_cmd(&cmd->se_cmd, 0);
return; return;
} }
...@@ -287,7 +287,7 @@ static void ft_recv_seq(struct fc_seq *sp, struct fc_frame *fp, void *arg) ...@@ -287,7 +287,7 @@ static void ft_recv_seq(struct fc_seq *sp, struct fc_frame *fp, void *arg)
__func__, fh->fh_r_ctl); __func__, fh->fh_r_ctl);
ft_invl_hw_context(cmd); ft_invl_hw_context(cmd);
fc_frame_free(fp); fc_frame_free(fp);
transport_generic_free_cmd(&cmd->se_cmd, 0, 0); transport_generic_free_cmd(&cmd->se_cmd, 0);
break; break;
} }
} }
...@@ -420,7 +420,7 @@ static void ft_send_tm(struct ft_cmd *cmd) ...@@ -420,7 +420,7 @@ static void ft_send_tm(struct ft_cmd *cmd)
sess = cmd->sess; sess = cmd->sess;
transport_send_check_condition_and_sense(&cmd->se_cmd, transport_send_check_condition_and_sense(&cmd->se_cmd,
cmd->se_cmd.scsi_sense_reason, 0); cmd->se_cmd.scsi_sense_reason, 0);
transport_generic_free_cmd(&cmd->se_cmd, 0, 0); transport_generic_free_cmd(&cmd->se_cmd, 0);
ft_sess_put(sess); ft_sess_put(sess);
return; return;
} }
...@@ -627,7 +627,7 @@ static void ft_send_work(struct work_struct *work) ...@@ -627,7 +627,7 @@ static void ft_send_work(struct work_struct *work)
if (ret == -ENOMEM) { if (ret == -ENOMEM) {
transport_send_check_condition_and_sense(se_cmd, transport_send_check_condition_and_sense(se_cmd,
TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE, 0); TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE, 0);
transport_generic_free_cmd(se_cmd, 0, 0); transport_generic_free_cmd(se_cmd, 0);
return; return;
} }
if (ret == -EINVAL) { if (ret == -EINVAL) {
...@@ -636,7 +636,7 @@ static void ft_send_work(struct work_struct *work) ...@@ -636,7 +636,7 @@ static void ft_send_work(struct work_struct *work)
else else
transport_send_check_condition_and_sense(se_cmd, transport_send_check_condition_and_sense(se_cmd,
se_cmd->scsi_sense_reason, 0); se_cmd->scsi_sense_reason, 0);
transport_generic_free_cmd(se_cmd, 0, 0); transport_generic_free_cmd(se_cmd, 0);
return; return;
} }
transport_handle_cdb_direct(se_cmd); transport_handle_cdb_direct(se_cmd);
......
...@@ -184,7 +184,7 @@ extern int transport_check_aborted_status(struct se_cmd *, int); ...@@ -184,7 +184,7 @@ extern int transport_check_aborted_status(struct se_cmd *, int);
extern int transport_send_check_condition_and_sense(struct se_cmd *, u8, int); extern int transport_send_check_condition_and_sense(struct se_cmd *, u8, int);
extern void transport_send_task_abort(struct se_cmd *); extern void transport_send_task_abort(struct se_cmd *);
extern void transport_release_cmd(struct se_cmd *); extern void transport_release_cmd(struct se_cmd *);
extern void transport_generic_free_cmd(struct se_cmd *, int, int); extern bool transport_generic_free_cmd(struct se_cmd *, int);
extern void transport_generic_wait_for_cmds(struct se_cmd *, int); extern void transport_generic_wait_for_cmds(struct se_cmd *, int);
extern int transport_init_task_sg(struct se_task *, struct se_mem *, u32); extern int transport_init_task_sg(struct se_task *, struct se_mem *, u32);
extern int transport_map_mem_to_sg(struct se_task *, struct list_head *, extern int transport_map_mem_to_sg(struct se_task *, struct list_head *,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment