Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

target/iscsi: Remove second argument of __iscsit_free_cmd()

Initialize .data_direction to DMA_NONE in iscsit_allocate_cmd()
such that the second argument of __iscsit_free_cmd() can be left
out. Note: this patch causes the first part of __iscsit_free_cmd()
no longer to be skipped for TMFs. That's fine since no data
segments are associated with TMFs.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: 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>

authored by

Bart Van Assche and committed by
Nicholas Bellinger
4412a671 4c1f0e65

+15 -20
+1 -3
drivers/target/iscsi/iscsi_target.c
··· 488 488 489 489 void iscsit_aborted_task(struct iscsi_conn *conn, struct iscsi_cmd *cmd) 490 490 { 491 - bool scsi_cmd = (cmd->iscsi_opcode == ISCSI_OP_SCSI_CMD); 492 - 493 491 spin_lock_bh(&conn->cmd_lock); 494 492 if (!list_empty(&cmd->i_conn_node) && 495 493 !(cmd->se_cmd.transport_state & CMD_T_FABRIC_STOP)) 496 494 list_del_init(&cmd->i_conn_node); 497 495 spin_unlock_bh(&conn->cmd_lock); 498 496 499 - __iscsit_free_cmd(cmd, scsi_cmd, true); 497 + __iscsit_free_cmd(cmd, true); 500 498 } 501 499 EXPORT_SYMBOL(iscsit_aborted_task); 502 500
+13 -16
drivers/target/iscsi/iscsi_target_util.c
··· 167 167 168 168 cmd->se_cmd.map_tag = tag; 169 169 cmd->conn = conn; 170 + cmd->data_direction = DMA_NONE; 170 171 INIT_LIST_HEAD(&cmd->i_conn_node); 171 172 INIT_LIST_HEAD(&cmd->datain_list); 172 173 INIT_LIST_HEAD(&cmd->cmd_r2t_list); ··· 712 711 } 713 712 EXPORT_SYMBOL(iscsit_release_cmd); 714 713 715 - void __iscsit_free_cmd(struct iscsi_cmd *cmd, bool scsi_cmd, 716 - bool check_queues) 714 + void __iscsit_free_cmd(struct iscsi_cmd *cmd, bool check_queues) 717 715 { 718 716 struct iscsi_conn *conn = cmd->conn; 719 717 720 - if (scsi_cmd) { 721 - if (cmd->data_direction == DMA_TO_DEVICE) { 722 - iscsit_stop_dataout_timer(cmd); 723 - iscsit_free_r2ts_from_list(cmd); 724 - } 725 - if (cmd->data_direction == DMA_FROM_DEVICE) 726 - iscsit_free_all_datain_reqs(cmd); 718 + if (cmd->data_direction == DMA_TO_DEVICE) { 719 + iscsit_stop_dataout_timer(cmd); 720 + iscsit_free_r2ts_from_list(cmd); 727 721 } 722 + if (cmd->data_direction == DMA_FROM_DEVICE) 723 + iscsit_free_all_datain_reqs(cmd); 728 724 729 725 if (conn && check_queues) { 730 726 iscsit_remove_cmd_from_immediate_queue(cmd, conn); ··· 736 738 { 737 739 struct se_cmd *se_cmd = NULL; 738 740 int rc; 739 - bool op_scsi = false; 741 + 740 742 /* 741 743 * Determine if a struct se_cmd is associated with 742 744 * this struct iscsi_cmd. 743 745 */ 744 746 switch (cmd->iscsi_opcode) { 745 747 case ISCSI_OP_SCSI_CMD: 746 - op_scsi = true; 747 748 /* 748 749 * Fallthrough 749 750 */ 750 751 case ISCSI_OP_SCSI_TMFUNC: 751 752 se_cmd = &cmd->se_cmd; 752 - __iscsit_free_cmd(cmd, op_scsi, shutdown); 753 + __iscsit_free_cmd(cmd, shutdown); 753 754 rc = transport_generic_free_cmd(se_cmd, shutdown); 754 755 if (!rc && shutdown && se_cmd->se_sess) { 755 - __iscsit_free_cmd(cmd, op_scsi, shutdown); 756 + __iscsit_free_cmd(cmd, shutdown); 756 757 target_put_sess_cmd(se_cmd); 757 758 } 758 759 break; ··· 763 766 */ 764 767 if (cmd->se_cmd.se_tfo != NULL) { 765 768 se_cmd = &cmd->se_cmd; 766 - __iscsit_free_cmd(cmd, true, shutdown); 769 + __iscsit_free_cmd(cmd, shutdown); 767 770 768 771 rc = transport_generic_free_cmd(&cmd->se_cmd, shutdown); 769 772 if (!rc && shutdown && se_cmd->se_sess) { 770 - __iscsit_free_cmd(cmd, true, shutdown); 773 + __iscsit_free_cmd(cmd, shutdown); 771 774 target_put_sess_cmd(se_cmd); 772 775 } 773 776 break; 774 777 } 775 778 /* Fall-through */ 776 779 default: 777 - __iscsit_free_cmd(cmd, false, shutdown); 780 + __iscsit_free_cmd(cmd, shutdown); 778 781 iscsit_release_cmd(cmd); 779 782 break; 780 783 }
+1 -1
drivers/target/iscsi/iscsi_target_util.h
··· 37 37 extern bool iscsit_conn_all_queues_empty(struct iscsi_conn *); 38 38 extern void iscsit_free_queue_reqs_for_conn(struct iscsi_conn *); 39 39 extern void iscsit_release_cmd(struct iscsi_cmd *); 40 - extern void __iscsit_free_cmd(struct iscsi_cmd *, bool, bool); 40 + extern void __iscsit_free_cmd(struct iscsi_cmd *, bool); 41 41 extern void iscsit_free_cmd(struct iscsi_cmd *, bool); 42 42 extern int iscsit_check_session_usage_count(struct iscsi_session *); 43 43 extern void iscsit_dec_session_usage_count(struct iscsi_session *);