Commit d1c26857 authored by Bart Van Assche's avatar Bart Van Assche Committed by Nicholas Bellinger

target/iscsi: Simplify iscsit_free_cmd()

Since .se_tfo is only set if a command has been submitted to
the LIO core, check .se_tfo instead of .iscsi_opcode. Since
__iscsit_free_cmd() only affects SCSI commands but not TMFs,
calling that function for TMFs does not change behavior. This
patch does not change the behavior of iscsit_free_cmd().
Signed-off-by: default avatarBart Van Assche <bart.vanassche@sandisk.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Andy Grover <agrover@redhat.com>
Cc: David Disseldorp <ddiss@suse.de>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent 4412a671
...@@ -734,49 +734,18 @@ void __iscsit_free_cmd(struct iscsi_cmd *cmd, bool check_queues) ...@@ -734,49 +734,18 @@ void __iscsit_free_cmd(struct iscsi_cmd *cmd, bool check_queues)
void iscsit_free_cmd(struct iscsi_cmd *cmd, bool shutdown) void iscsit_free_cmd(struct iscsi_cmd *cmd, bool shutdown)
{ {
struct se_cmd *se_cmd = NULL; struct se_cmd *se_cmd = cmd->se_cmd.se_tfo ? &cmd->se_cmd : NULL;
int rc; int rc;
/* __iscsit_free_cmd(cmd, shutdown);
* Determine if a struct se_cmd is associated with if (se_cmd) {
* this struct iscsi_cmd.
*/
switch (cmd->iscsi_opcode) {
case ISCSI_OP_SCSI_CMD:
/*
* Fallthrough
*/
case ISCSI_OP_SCSI_TMFUNC:
se_cmd = &cmd->se_cmd;
__iscsit_free_cmd(cmd, shutdown);
rc = transport_generic_free_cmd(se_cmd, shutdown); rc = transport_generic_free_cmd(se_cmd, shutdown);
if (!rc && shutdown && se_cmd->se_sess) { if (!rc && shutdown && se_cmd->se_sess) {
__iscsit_free_cmd(cmd, shutdown); __iscsit_free_cmd(cmd, shutdown);
target_put_sess_cmd(se_cmd); target_put_sess_cmd(se_cmd);
} }
break; } else {
case ISCSI_OP_REJECT:
/*
* Handle special case for REJECT when iscsi_add_reject*() has
* overwritten the original iscsi_opcode assignment, and the
* associated cmd->se_cmd needs to be released.
*/
if (cmd->se_cmd.se_tfo != NULL) {
se_cmd = &cmd->se_cmd;
__iscsit_free_cmd(cmd, shutdown);
rc = transport_generic_free_cmd(&cmd->se_cmd, shutdown);
if (!rc && shutdown && se_cmd->se_sess) {
__iscsit_free_cmd(cmd, shutdown);
target_put_sess_cmd(se_cmd);
}
break;
}
/* Fall-through */
default:
__iscsit_free_cmd(cmd, shutdown);
iscsit_release_cmd(cmd); iscsit_release_cmd(cmd);
break;
} }
} }
EXPORT_SYMBOL(iscsit_free_cmd); EXPORT_SYMBOL(iscsit_free_cmd);
......
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