aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target/iscsi/iscsi_target_datain_values.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/target/iscsi/iscsi_target_datain_values.c')
-rw-r--r--drivers/target/iscsi/iscsi_target_datain_values.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/drivers/target/iscsi/iscsi_target_datain_values.c b/drivers/target/iscsi/iscsi_target_datain_values.c
index 8c0495129513..848fee768948 100644
--- a/drivers/target/iscsi/iscsi_target_datain_values.c
+++ b/drivers/target/iscsi/iscsi_target_datain_values.c
@@ -37,7 +37,7 @@ struct iscsi_datain_req *iscsit_allocate_datain_req(void)
37 " struct iscsi_datain_req\n"); 37 " struct iscsi_datain_req\n");
38 return NULL; 38 return NULL;
39 } 39 }
40 INIT_LIST_HEAD(&dr->dr_list); 40 INIT_LIST_HEAD(&dr->cmd_datain_node);
41 41
42 return dr; 42 return dr;
43} 43}
@@ -45,14 +45,14 @@ struct iscsi_datain_req *iscsit_allocate_datain_req(void)
45void iscsit_attach_datain_req(struct iscsi_cmd *cmd, struct iscsi_datain_req *dr) 45void iscsit_attach_datain_req(struct iscsi_cmd *cmd, struct iscsi_datain_req *dr)
46{ 46{
47 spin_lock(&cmd->datain_lock); 47 spin_lock(&cmd->datain_lock);
48 list_add_tail(&dr->dr_list, &cmd->datain_list); 48 list_add_tail(&dr->cmd_datain_node, &cmd->datain_list);
49 spin_unlock(&cmd->datain_lock); 49 spin_unlock(&cmd->datain_lock);
50} 50}
51 51
52void iscsit_free_datain_req(struct iscsi_cmd *cmd, struct iscsi_datain_req *dr) 52void iscsit_free_datain_req(struct iscsi_cmd *cmd, struct iscsi_datain_req *dr)
53{ 53{
54 spin_lock(&cmd->datain_lock); 54 spin_lock(&cmd->datain_lock);
55 list_del(&dr->dr_list); 55 list_del(&dr->cmd_datain_node);
56 spin_unlock(&cmd->datain_lock); 56 spin_unlock(&cmd->datain_lock);
57 57
58 kmem_cache_free(lio_dr_cache, dr); 58 kmem_cache_free(lio_dr_cache, dr);
@@ -63,8 +63,8 @@ void iscsit_free_all_datain_reqs(struct iscsi_cmd *cmd)
63 struct iscsi_datain_req *dr, *dr_tmp; 63 struct iscsi_datain_req *dr, *dr_tmp;
64 64
65 spin_lock(&cmd->datain_lock); 65 spin_lock(&cmd->datain_lock);
66 list_for_each_entry_safe(dr, dr_tmp, &cmd->datain_list, dr_list) { 66 list_for_each_entry_safe(dr, dr_tmp, &cmd->datain_list, cmd_datain_node) {
67 list_del(&dr->dr_list); 67 list_del(&dr->cmd_datain_node);
68 kmem_cache_free(lio_dr_cache, dr); 68 kmem_cache_free(lio_dr_cache, dr);
69 } 69 }
70 spin_unlock(&cmd->datain_lock); 70 spin_unlock(&cmd->datain_lock);
@@ -72,17 +72,14 @@ void iscsit_free_all_datain_reqs(struct iscsi_cmd *cmd)
72 72
73struct iscsi_datain_req *iscsit_get_datain_req(struct iscsi_cmd *cmd) 73struct iscsi_datain_req *iscsit_get_datain_req(struct iscsi_cmd *cmd)
74{ 74{
75 struct iscsi_datain_req *dr;
76
77 if (list_empty(&cmd->datain_list)) { 75 if (list_empty(&cmd->datain_list)) {
78 pr_err("cmd->datain_list is empty for ITT:" 76 pr_err("cmd->datain_list is empty for ITT:"
79 " 0x%08x\n", cmd->init_task_tag); 77 " 0x%08x\n", cmd->init_task_tag);
80 return NULL; 78 return NULL;
81 } 79 }
82 list_for_each_entry(dr, &cmd->datain_list, dr_list)
83 break;
84 80
85 return dr; 81 return list_first_entry(&cmd->datain_list, struct iscsi_datain_req,
82 cmd_datain_node);
86} 83}
87 84
88/* 85/*
@@ -113,7 +110,7 @@ static struct iscsi_datain_req *iscsit_set_datain_values_yes_and_yes(
113 read_data_done = (!dr->recovery) ? 110 read_data_done = (!dr->recovery) ?
114 cmd->read_data_done : dr->read_data_done; 111 cmd->read_data_done : dr->read_data_done;
115 112
116 read_data_left = (cmd->data_length - read_data_done); 113 read_data_left = (cmd->se_cmd.data_length - read_data_done);
117 if (!read_data_left) { 114 if (!read_data_left) {
118 pr_err("ITT: 0x%08x read_data_left is zero!\n", 115 pr_err("ITT: 0x%08x read_data_left is zero!\n",
119 cmd->init_task_tag); 116 cmd->init_task_tag);
@@ -212,7 +209,7 @@ static struct iscsi_datain_req *iscsit_set_datain_values_no_and_yes(
212 seq_send_order = (!dr->recovery) ? 209 seq_send_order = (!dr->recovery) ?
213 cmd->seq_send_order : dr->seq_send_order; 210 cmd->seq_send_order : dr->seq_send_order;
214 211
215 read_data_left = (cmd->data_length - read_data_done); 212 read_data_left = (cmd->se_cmd.data_length - read_data_done);
216 if (!read_data_left) { 213 if (!read_data_left) {
217 pr_err("ITT: 0x%08x read_data_left is zero!\n", 214 pr_err("ITT: 0x%08x read_data_left is zero!\n",
218 cmd->init_task_tag); 215 cmd->init_task_tag);
@@ -231,8 +228,8 @@ static struct iscsi_datain_req *iscsit_set_datain_values_no_and_yes(
231 offset = (seq->offset + seq->next_burst_len); 228 offset = (seq->offset + seq->next_burst_len);
232 229
233 if ((offset + conn->conn_ops->MaxRecvDataSegmentLength) >= 230 if ((offset + conn->conn_ops->MaxRecvDataSegmentLength) >=
234 cmd->data_length) { 231 cmd->se_cmd.data_length) {
235 datain->length = (cmd->data_length - offset); 232 datain->length = (cmd->se_cmd.data_length - offset);
236 datain->offset = offset; 233 datain->offset = offset;
237 234
238 datain->flags |= ISCSI_FLAG_CMD_FINAL; 235 datain->flags |= ISCSI_FLAG_CMD_FINAL;
@@ -264,7 +261,7 @@ static struct iscsi_datain_req *iscsit_set_datain_values_no_and_yes(
264 } 261 }
265 } 262 }
266 263
267 if ((read_data_done + datain->length) == cmd->data_length) 264 if ((read_data_done + datain->length) == cmd->se_cmd.data_length)
268 datain->flags |= ISCSI_FLAG_DATA_STATUS; 265 datain->flags |= ISCSI_FLAG_DATA_STATUS;
269 266
270 datain->data_sn = (!dr->recovery) ? cmd->data_sn++ : dr->data_sn++; 267 datain->data_sn = (!dr->recovery) ? cmd->data_sn++ : dr->data_sn++;
@@ -333,7 +330,7 @@ static struct iscsi_datain_req *iscsit_set_datain_values_yes_and_no(
333 read_data_done = (!dr->recovery) ? 330 read_data_done = (!dr->recovery) ?
334 cmd->read_data_done : dr->read_data_done; 331 cmd->read_data_done : dr->read_data_done;
335 332
336 read_data_left = (cmd->data_length - read_data_done); 333 read_data_left = (cmd->se_cmd.data_length - read_data_done);
337 if (!read_data_left) { 334 if (!read_data_left) {
338 pr_err("ITT: 0x%08x read_data_left is zero!\n", 335 pr_err("ITT: 0x%08x read_data_left is zero!\n",
339 cmd->init_task_tag); 336 cmd->init_task_tag);
@@ -344,7 +341,7 @@ static struct iscsi_datain_req *iscsit_set_datain_values_yes_and_no(
344 if (!pdu) 341 if (!pdu)
345 return dr; 342 return dr;
346 343
347 if ((read_data_done + pdu->length) == cmd->data_length) { 344 if ((read_data_done + pdu->length) == cmd->se_cmd.data_length) {
348 pdu->flags |= (ISCSI_FLAG_CMD_FINAL | ISCSI_FLAG_DATA_STATUS); 345 pdu->flags |= (ISCSI_FLAG_CMD_FINAL | ISCSI_FLAG_DATA_STATUS);
349 if (conn->sess->sess_ops->ErrorRecoveryLevel > 0) 346 if (conn->sess->sess_ops->ErrorRecoveryLevel > 0)
350 pdu->flags |= ISCSI_FLAG_DATA_ACK; 347 pdu->flags |= ISCSI_FLAG_DATA_ACK;
@@ -433,7 +430,7 @@ static struct iscsi_datain_req *iscsit_set_datain_values_no_and_no(
433 seq_send_order = (!dr->recovery) ? 430 seq_send_order = (!dr->recovery) ?
434 cmd->seq_send_order : dr->seq_send_order; 431 cmd->seq_send_order : dr->seq_send_order;
435 432
436 read_data_left = (cmd->data_length - read_data_done); 433 read_data_left = (cmd->se_cmd.data_length - read_data_done);
437 if (!read_data_left) { 434 if (!read_data_left) {
438 pr_err("ITT: 0x%08x read_data_left is zero!\n", 435 pr_err("ITT: 0x%08x read_data_left is zero!\n",
439 cmd->init_task_tag); 436 cmd->init_task_tag);
@@ -463,7 +460,7 @@ static struct iscsi_datain_req *iscsit_set_datain_values_no_and_no(
463 } else 460 } else
464 seq->next_burst_len += pdu->length; 461 seq->next_burst_len += pdu->length;
465 462
466 if ((read_data_done + pdu->length) == cmd->data_length) 463 if ((read_data_done + pdu->length) == cmd->se_cmd.data_length)
467 pdu->flags |= ISCSI_FLAG_DATA_STATUS; 464 pdu->flags |= ISCSI_FLAG_DATA_STATUS;
468 465
469 pdu->data_sn = (!dr->recovery) ? cmd->data_sn++ : dr->data_sn++; 466 pdu->data_sn = (!dr->recovery) ? cmd->data_sn++ : dr->data_sn++;