[PATCH 2/2] Create tx pdu by explicit scsi cmd type (rd,wr,bidir)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Alexander Nezhinsky <nezhinsky@xxxxxxxxx>

Differentiating between various possible cases for tx pdus
(r2t, data-in and scsi_response) has been made using a set of
predicates, some of which are relevant only for a specific cmd types.
Although possibly correct when all counters and flags used
are up-to-date, this may be dangerous and hard to debug.
Explicit check of cmd type allows discriminating only between
the choices feasible for each cmd type.
---
 usr/iscsi/iscsid.c |   25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c
index e1180fb..fc9938d 100644
--- a/usr/iscsi/iscsid.c
+++ b/usr/iscsi/iscsid.c
@@ -1785,14 +1785,27 @@ static int iscsi_task_rx_start(struct iscsi_connection *conn)
 
 static int iscsi_scsi_cmd_tx_start(struct iscsi_task *task)
 {
+	enum data_direction data_dir = scsi_get_data_dir(&task->scmd);
 	int err = 0;
 
-	if (task->r2t_count)
-		err = iscsi_r2t_build(task);
-	else if (task->offset < scsi_get_in_transfer_len(&task->scmd))
-		err = iscsi_data_rsp_build(task);
-	else
-		err = iscsi_cmd_rsp_build(task);
+	if (data_dir == DATA_READ) {
+		if (task->offset < scsi_get_in_transfer_len(&task->scmd))
+			err = iscsi_data_rsp_build(task);
+		else
+			err = iscsi_cmd_rsp_build(task);
+	} else if (data_dir == DATA_WRITE) {
+		if (task->r2t_count)
+			err = iscsi_r2t_build(task);
+		else
+			err = iscsi_cmd_rsp_build(task);
+	} else if (data_dir == DATA_BIDIRECTIONAL) {
+		if (task->r2t_count)
+			err = iscsi_r2t_build(task);
+		else if (task->offset < scsi_get_in_transfer_len(&task->scmd))
+			err = iscsi_data_rsp_build(task);
+		else
+			err = iscsi_cmd_rsp_build(task);
+	}
 
 	return err;
 }
-- 
1.7.9.6

--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux