aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAndy Grover <agrover@redhat.com>2012-04-03 18:51:25 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2012-04-14 20:40:38 -0400
commit4334e49bcae6f4602eb5c52158b8fb89d8941d99 (patch)
tree33c0ba79b0d172e21aac919675d1a49bbbef8935 /drivers
parentebf1d95ca297a06fe760177b614646dcec06abef (diff)
target/iscsi: Fold _decide_list_to_build into _build_pdu_and_seq_lists
Rename iscsit_build_pdu_and_seq_list to iscsit_do_build_pdu_and_seq_lists Rename iscsit_do_build_list to iscsit_build_pdu_and_seq_lists Move code from iscsit_decide_list_to_build into _seq_pdu_list.c, seems a better fit. Also update some comments in pdu/seq code for correctness and whitespace. Signed-off-by: Andy Grover <agrover@redhat.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/target/iscsi/iscsi_target.c2
-rw-r--r--drivers/target/iscsi/iscsi_target_seq_pdu_list.c58
-rw-r--r--drivers/target/iscsi/iscsi_target_seq_pdu_list.h2
-rw-r--r--drivers/target/iscsi/iscsi_target_util.c45
-rw-r--r--drivers/target/iscsi/iscsi_target_util.h1
5 files changed, 50 insertions, 58 deletions
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index a29a1bb279d5..e9cc08774732 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -1060,7 +1060,7 @@ done:
1060 */ 1060 */
1061 send_check_condition = 1; 1061 send_check_condition = 1;
1062 } else { 1062 } else {
1063 if (iscsit_decide_list_to_build(cmd, payload_length) < 0) 1063 if (iscsit_build_pdu_and_seq_lists(cmd, payload_length) < 0)
1064 return iscsit_add_reject_from_cmd( 1064 return iscsit_add_reject_from_cmd(
1065 ISCSI_REASON_BOOKMARK_NO_RESOURCES, 1065 ISCSI_REASON_BOOKMARK_NO_RESOURCES,
1066 1, 1, buf, cmd); 1066 1, 1, buf, cmd);
diff --git a/drivers/target/iscsi/iscsi_target_seq_pdu_list.c b/drivers/target/iscsi/iscsi_target_seq_pdu_list.c
index d98276581a19..7d0effad9396 100644
--- a/drivers/target/iscsi/iscsi_target_seq_pdu_list.c
+++ b/drivers/target/iscsi/iscsi_target_seq_pdu_list.c
@@ -24,6 +24,7 @@
24 24
25#include "iscsi_target_core.h" 25#include "iscsi_target_core.h"
26#include "iscsi_target_util.h" 26#include "iscsi_target_util.h"
27#include "iscsi_target_tpg.h"
27#include "iscsi_target_seq_pdu_list.h" 28#include "iscsi_target_seq_pdu_list.h"
28 29
29#define OFFLOAD_BUF_SIZE 32768 30#define OFFLOAD_BUF_SIZE 32768
@@ -287,10 +288,10 @@ static void iscsit_determine_counts_for_list(
287 288
288 289
289/* 290/*
290 * Builds PDU and/or Sequence list, called while DataSequenceInOrder=No 291 * Builds PDU and/or Sequence list, called while DataSequenceInOrder=No
291 * and DataPDUInOrder=No. 292 * or DataPDUInOrder=No.
292 */ 293 */
293static int iscsit_build_pdu_and_seq_list( 294static int iscsit_do_build_pdu_and_seq_lists(
294 struct iscsi_cmd *cmd, 295 struct iscsi_cmd *cmd,
295 struct iscsi_build_list *bl) 296 struct iscsi_build_list *bl)
296{ 297{
@@ -493,19 +494,56 @@ static int iscsit_build_pdu_and_seq_list(
493 return 0; 494 return 0;
494} 495}
495 496
496/* 497int iscsit_build_pdu_and_seq_lists(
497 * Only called while DataSequenceInOrder=No or DataPDUInOrder=No.
498 */
499int iscsit_do_build_list(
500 struct iscsi_cmd *cmd, 498 struct iscsi_cmd *cmd,
501 struct iscsi_build_list *bl) 499 u32 immediate_data_length)
502{ 500{
501 struct iscsi_build_list bl;
503 u32 pdu_count = 0, seq_count = 1; 502 u32 pdu_count = 0, seq_count = 1;
504 struct iscsi_conn *conn = cmd->conn; 503 struct iscsi_conn *conn = cmd->conn;
505 struct iscsi_pdu *pdu = NULL; 504 struct iscsi_pdu *pdu = NULL;
506 struct iscsi_seq *seq = NULL; 505 struct iscsi_seq *seq = NULL;
507 506
508 iscsit_determine_counts_for_list(cmd, bl, &seq_count, &pdu_count); 507 struct iscsi_session *sess = conn->sess;
508 struct iscsi_node_attrib *na;
509
510 /*
511 * Do nothing if no OOO shenanigans
512 */
513 if (sess->sess_ops->DataSequenceInOrder &&
514 sess->sess_ops->DataPDUInOrder)
515 return 0;
516
517 if (cmd->data_direction == DMA_NONE)
518 return 0;
519
520 na = iscsit_tpg_get_node_attrib(sess);
521 memset(&bl, 0, sizeof(struct iscsi_build_list));
522
523 if (cmd->data_direction == DMA_FROM_DEVICE) {
524 bl.data_direction = ISCSI_PDU_READ;
525 bl.type = PDULIST_NORMAL;
526 if (na->random_datain_pdu_offsets)
527 bl.randomize |= RANDOM_DATAIN_PDU_OFFSETS;
528 if (na->random_datain_seq_offsets)
529 bl.randomize |= RANDOM_DATAIN_SEQ_OFFSETS;
530 } else {
531 bl.data_direction = ISCSI_PDU_WRITE;
532 bl.immediate_data_length = immediate_data_length;
533 if (na->random_r2t_offsets)
534 bl.randomize |= RANDOM_R2T_OFFSETS;
535
536 if (!cmd->immediate_data && !cmd->unsolicited_data)
537 bl.type = PDULIST_NORMAL;
538 else if (cmd->immediate_data && !cmd->unsolicited_data)
539 bl.type = PDULIST_IMMEDIATE;
540 else if (!cmd->immediate_data && cmd->unsolicited_data)
541 bl.type = PDULIST_UNSOLICITED;
542 else if (cmd->immediate_data && cmd->unsolicited_data)
543 bl.type = PDULIST_IMMEDIATE_AND_UNSOLICITED;
544 }
545
546 iscsit_determine_counts_for_list(cmd, &bl, &seq_count, &pdu_count);
509 547
510 if (!conn->sess->sess_ops->DataSequenceInOrder) { 548 if (!conn->sess->sess_ops->DataSequenceInOrder) {
511 seq = kzalloc(seq_count * sizeof(struct iscsi_seq), GFP_ATOMIC); 549 seq = kzalloc(seq_count * sizeof(struct iscsi_seq), GFP_ATOMIC);
@@ -528,7 +566,7 @@ int iscsit_do_build_list(
528 cmd->pdu_count = pdu_count; 566 cmd->pdu_count = pdu_count;
529 } 567 }
530 568
531 return iscsit_build_pdu_and_seq_list(cmd, bl); 569 return iscsit_do_build_pdu_and_seq_lists(cmd, &bl);
532} 570}
533 571
534struct iscsi_pdu *iscsit_get_pdu_holder( 572struct iscsi_pdu *iscsit_get_pdu_holder(
diff --git a/drivers/target/iscsi/iscsi_target_seq_pdu_list.h b/drivers/target/iscsi/iscsi_target_seq_pdu_list.h
index 0d52a10e3069..d5b153751a8d 100644
--- a/drivers/target/iscsi/iscsi_target_seq_pdu_list.h
+++ b/drivers/target/iscsi/iscsi_target_seq_pdu_list.h
@@ -78,7 +78,7 @@ struct iscsi_seq {
78 u32 xfer_len; 78 u32 xfer_len;
79} ____cacheline_aligned; 79} ____cacheline_aligned;
80 80
81extern int iscsit_do_build_list(struct iscsi_cmd *, struct iscsi_build_list *); 81extern int iscsit_build_pdu_and_seq_lists(struct iscsi_cmd *, u32);
82extern struct iscsi_pdu *iscsit_get_pdu_holder(struct iscsi_cmd *, u32, u32); 82extern struct iscsi_pdu *iscsit_get_pdu_holder(struct iscsi_cmd *, u32, u32);
83extern struct iscsi_pdu *iscsit_get_pdu_holder_for_seq(struct iscsi_cmd *, struct iscsi_seq *); 83extern struct iscsi_pdu *iscsit_get_pdu_holder_for_seq(struct iscsi_cmd *, struct iscsi_seq *);
84extern struct iscsi_seq *iscsit_get_seq_holder(struct iscsi_cmd *, u32, u32); 84extern struct iscsi_seq *iscsit_get_seq_holder(struct iscsi_cmd *, u32, u32);
diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c
index 1f5a456f26b4..9cd9f30c0237 100644
--- a/drivers/target/iscsi/iscsi_target_util.c
+++ b/drivers/target/iscsi/iscsi_target_util.c
@@ -176,51 +176,6 @@ struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *conn, gfp_t gfp_mask)
176 return cmd; 176 return cmd;
177} 177}
178 178
179int iscsit_decide_list_to_build(
180 struct iscsi_cmd *cmd,
181 u32 immediate_data_length)
182{
183 struct iscsi_build_list bl;
184 struct iscsi_conn *conn = cmd->conn;
185 struct iscsi_session *sess = conn->sess;
186 struct iscsi_node_attrib *na;
187
188 if (sess->sess_ops->DataSequenceInOrder &&
189 sess->sess_ops->DataPDUInOrder)
190 return 0;
191
192 if (cmd->data_direction == DMA_NONE)
193 return 0;
194
195 na = iscsit_tpg_get_node_attrib(sess);
196 memset(&bl, 0, sizeof(struct iscsi_build_list));
197
198 if (cmd->data_direction == DMA_FROM_DEVICE) {
199 bl.data_direction = ISCSI_PDU_READ;
200 bl.type = PDULIST_NORMAL;
201 if (na->random_datain_pdu_offsets)
202 bl.randomize |= RANDOM_DATAIN_PDU_OFFSETS;
203 if (na->random_datain_seq_offsets)
204 bl.randomize |= RANDOM_DATAIN_SEQ_OFFSETS;
205 } else {
206 bl.data_direction = ISCSI_PDU_WRITE;
207 bl.immediate_data_length = immediate_data_length;
208 if (na->random_r2t_offsets)
209 bl.randomize |= RANDOM_R2T_OFFSETS;
210
211 if (!cmd->immediate_data && !cmd->unsolicited_data)
212 bl.type = PDULIST_NORMAL;
213 else if (cmd->immediate_data && !cmd->unsolicited_data)
214 bl.type = PDULIST_IMMEDIATE;
215 else if (!cmd->immediate_data && cmd->unsolicited_data)
216 bl.type = PDULIST_UNSOLICITED;
217 else if (cmd->immediate_data && cmd->unsolicited_data)
218 bl.type = PDULIST_IMMEDIATE_AND_UNSOLICITED;
219 }
220
221 return iscsit_do_build_list(cmd, &bl);
222}
223
224struct iscsi_seq *iscsit_get_seq_holder_for_datain( 179struct iscsi_seq *iscsit_get_seq_holder_for_datain(
225 struct iscsi_cmd *cmd, 180 struct iscsi_cmd *cmd,
226 u32 seq_send_order) 181 u32 seq_send_order)
diff --git a/drivers/target/iscsi/iscsi_target_util.h b/drivers/target/iscsi/iscsi_target_util.h
index df8dbddc6e78..e1c729b8a1c5 100644
--- a/drivers/target/iscsi/iscsi_target_util.h
+++ b/drivers/target/iscsi/iscsi_target_util.h
@@ -9,7 +9,6 @@ extern struct iscsi_r2t *iscsit_get_r2t_from_list(struct iscsi_cmd *);
9extern void iscsit_free_r2t(struct iscsi_r2t *, struct iscsi_cmd *); 9extern void iscsit_free_r2t(struct iscsi_r2t *, struct iscsi_cmd *);
10extern void iscsit_free_r2ts_from_list(struct iscsi_cmd *); 10extern void iscsit_free_r2ts_from_list(struct iscsi_cmd *);
11extern struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *, gfp_t); 11extern struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *, gfp_t);
12extern int iscsit_decide_list_to_build(struct iscsi_cmd *, u32);
13extern struct iscsi_seq *iscsit_get_seq_holder_for_datain(struct iscsi_cmd *, u32); 12extern struct iscsi_seq *iscsit_get_seq_holder_for_datain(struct iscsi_cmd *, u32);
14extern struct iscsi_seq *iscsit_get_seq_holder_for_r2t(struct iscsi_cmd *); 13extern struct iscsi_seq *iscsit_get_seq_holder_for_r2t(struct iscsi_cmd *);
15extern struct iscsi_r2t *iscsit_get_holder_for_r2tsn(struct iscsi_cmd *, u32); 14extern struct iscsi_r2t *iscsit_get_holder_for_r2tsn(struct iscsi_cmd *, u32);