aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBart Van Assche <bart.vanassche@sandisk.com>2017-05-23 19:48:44 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2017-07-07 02:11:27 -0400
commitd1c26857cdec3e3bdb5cf7179411f6ce8cc0834c (patch)
treec82cb87bd5f15a840095adff694f09fc6637a6c2
parent4412a67131a037fa1d032bcd50270e9d336a775d (diff)
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: Bart 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: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r--drivers/target/iscsi/iscsi_target_util.c39
1 files changed, 4 insertions, 35 deletions
diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c
index 41b9e7cc08b8..1e36f83b5961 100644
--- a/drivers/target/iscsi/iscsi_target_util.c
+++ b/drivers/target/iscsi/iscsi_target_util.c
@@ -734,49 +734,18 @@ void __iscsit_free_cmd(struct iscsi_cmd *cmd, bool check_queues)
734 734
735void iscsit_free_cmd(struct iscsi_cmd *cmd, bool shutdown) 735void iscsit_free_cmd(struct iscsi_cmd *cmd, bool shutdown)
736{ 736{
737 struct se_cmd *se_cmd = NULL; 737 struct se_cmd *se_cmd = cmd->se_cmd.se_tfo ? &cmd->se_cmd : NULL;
738 int rc; 738 int rc;
739 739
740 /* 740 __iscsit_free_cmd(cmd, shutdown);
741 * Determine if a struct se_cmd is associated with 741 if (se_cmd) {
742 * this struct iscsi_cmd.
743 */
744 switch (cmd->iscsi_opcode) {
745 case ISCSI_OP_SCSI_CMD:
746 /*
747 * Fallthrough
748 */
749 case ISCSI_OP_SCSI_TMFUNC:
750 se_cmd = &cmd->se_cmd;
751 __iscsit_free_cmd(cmd, shutdown);
752 rc = transport_generic_free_cmd(se_cmd, shutdown); 742 rc = transport_generic_free_cmd(se_cmd, shutdown);
753 if (!rc && shutdown && se_cmd->se_sess) { 743 if (!rc && shutdown && se_cmd->se_sess) {
754 __iscsit_free_cmd(cmd, shutdown); 744 __iscsit_free_cmd(cmd, shutdown);
755 target_put_sess_cmd(se_cmd); 745 target_put_sess_cmd(se_cmd);
756 } 746 }
757 break; 747 } else {
758 case ISCSI_OP_REJECT:
759 /*
760 * Handle special case for REJECT when iscsi_add_reject*() has
761 * overwritten the original iscsi_opcode assignment, and the
762 * associated cmd->se_cmd needs to be released.
763 */
764 if (cmd->se_cmd.se_tfo != NULL) {
765 se_cmd = &cmd->se_cmd;
766 __iscsit_free_cmd(cmd, shutdown);
767
768 rc = transport_generic_free_cmd(&cmd->se_cmd, shutdown);
769 if (!rc && shutdown && se_cmd->se_sess) {
770 __iscsit_free_cmd(cmd, shutdown);
771 target_put_sess_cmd(se_cmd);
772 }
773 break;
774 }
775 /* Fall-through */
776 default:
777 __iscsit_free_cmd(cmd, shutdown);
778 iscsit_release_cmd(cmd); 748 iscsit_release_cmd(cmd);
779 break;
780 } 749 }
781} 750}
782EXPORT_SYMBOL(iscsit_free_cmd); 751EXPORT_SYMBOL(iscsit_free_cmd);