diff options
author | Mike Christie <michaelc@cs.wisc.edu> | 2008-05-21 16:54:09 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-07-12 09:22:19 -0400 |
commit | 9c19a7d0387124a508d2cdb38ebf8cd484631ad0 (patch) | |
tree | 3c7022cd03fee32e1eb290396fe780049f095449 /drivers/scsi/libiscsi.c | |
parent | 2747fdb25726caa1a89229f43d99ca50af72576a (diff) |
[SCSI] libiscsi: rename iscsi_cmd_task to iscsi_task
This is the second part of the iscsi task merging, and
all it does it rename iscsi_cmd_task to iscsi_task and
mtask/ctask to just task.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi/libiscsi.c')
-rw-r--r-- | drivers/scsi/libiscsi.c | 514 |
1 files changed, 258 insertions, 256 deletions
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index ef92b1b0f16e..92ee6d94aaf9 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c | |||
@@ -88,61 +88,61 @@ iscsi_update_cmdsn(struct iscsi_session *session, struct iscsi_nopin *hdr) | |||
88 | } | 88 | } |
89 | EXPORT_SYMBOL_GPL(iscsi_update_cmdsn); | 89 | EXPORT_SYMBOL_GPL(iscsi_update_cmdsn); |
90 | 90 | ||
91 | void iscsi_prep_unsolicit_data_pdu(struct iscsi_cmd_task *ctask, | 91 | void iscsi_prep_unsolicit_data_pdu(struct iscsi_task *task, |
92 | struct iscsi_data *hdr) | 92 | struct iscsi_data *hdr) |
93 | { | 93 | { |
94 | struct iscsi_conn *conn = ctask->conn; | 94 | struct iscsi_conn *conn = task->conn; |
95 | 95 | ||
96 | memset(hdr, 0, sizeof(struct iscsi_data)); | 96 | memset(hdr, 0, sizeof(struct iscsi_data)); |
97 | hdr->ttt = cpu_to_be32(ISCSI_RESERVED_TAG); | 97 | hdr->ttt = cpu_to_be32(ISCSI_RESERVED_TAG); |
98 | hdr->datasn = cpu_to_be32(ctask->unsol_datasn); | 98 | hdr->datasn = cpu_to_be32(task->unsol_datasn); |
99 | ctask->unsol_datasn++; | 99 | task->unsol_datasn++; |
100 | hdr->opcode = ISCSI_OP_SCSI_DATA_OUT; | 100 | hdr->opcode = ISCSI_OP_SCSI_DATA_OUT; |
101 | memcpy(hdr->lun, ctask->hdr->lun, sizeof(hdr->lun)); | 101 | memcpy(hdr->lun, task->hdr->lun, sizeof(hdr->lun)); |
102 | 102 | ||
103 | hdr->itt = ctask->hdr->itt; | 103 | hdr->itt = task->hdr->itt; |
104 | hdr->exp_statsn = cpu_to_be32(conn->exp_statsn); | 104 | hdr->exp_statsn = cpu_to_be32(conn->exp_statsn); |
105 | hdr->offset = cpu_to_be32(ctask->unsol_offset); | 105 | hdr->offset = cpu_to_be32(task->unsol_offset); |
106 | 106 | ||
107 | if (ctask->unsol_count > conn->max_xmit_dlength) { | 107 | if (task->unsol_count > conn->max_xmit_dlength) { |
108 | hton24(hdr->dlength, conn->max_xmit_dlength); | 108 | hton24(hdr->dlength, conn->max_xmit_dlength); |
109 | ctask->data_count = conn->max_xmit_dlength; | 109 | task->data_count = conn->max_xmit_dlength; |
110 | ctask->unsol_offset += ctask->data_count; | 110 | task->unsol_offset += task->data_count; |
111 | hdr->flags = 0; | 111 | hdr->flags = 0; |
112 | } else { | 112 | } else { |
113 | hton24(hdr->dlength, ctask->unsol_count); | 113 | hton24(hdr->dlength, task->unsol_count); |
114 | ctask->data_count = ctask->unsol_count; | 114 | task->data_count = task->unsol_count; |
115 | hdr->flags = ISCSI_FLAG_CMD_FINAL; | 115 | hdr->flags = ISCSI_FLAG_CMD_FINAL; |
116 | } | 116 | } |
117 | } | 117 | } |
118 | EXPORT_SYMBOL_GPL(iscsi_prep_unsolicit_data_pdu); | 118 | EXPORT_SYMBOL_GPL(iscsi_prep_unsolicit_data_pdu); |
119 | 119 | ||
120 | static int iscsi_add_hdr(struct iscsi_cmd_task *ctask, unsigned len) | 120 | static int iscsi_add_hdr(struct iscsi_task *task, unsigned len) |
121 | { | 121 | { |
122 | unsigned exp_len = ctask->hdr_len + len; | 122 | unsigned exp_len = task->hdr_len + len; |
123 | 123 | ||
124 | if (exp_len > ctask->hdr_max) { | 124 | if (exp_len > task->hdr_max) { |
125 | WARN_ON(1); | 125 | WARN_ON(1); |
126 | return -EINVAL; | 126 | return -EINVAL; |
127 | } | 127 | } |
128 | 128 | ||
129 | WARN_ON(len & (ISCSI_PAD_LEN - 1)); /* caller must pad the AHS */ | 129 | WARN_ON(len & (ISCSI_PAD_LEN - 1)); /* caller must pad the AHS */ |
130 | ctask->hdr_len = exp_len; | 130 | task->hdr_len = exp_len; |
131 | return 0; | 131 | return 0; |
132 | } | 132 | } |
133 | 133 | ||
134 | /* | 134 | /* |
135 | * make an extended cdb AHS | 135 | * make an extended cdb AHS |
136 | */ | 136 | */ |
137 | static int iscsi_prep_ecdb_ahs(struct iscsi_cmd_task *ctask) | 137 | static int iscsi_prep_ecdb_ahs(struct iscsi_task *task) |
138 | { | 138 | { |
139 | struct scsi_cmnd *cmd = ctask->sc; | 139 | struct scsi_cmnd *cmd = task->sc; |
140 | unsigned rlen, pad_len; | 140 | unsigned rlen, pad_len; |
141 | unsigned short ahslength; | 141 | unsigned short ahslength; |
142 | struct iscsi_ecdb_ahdr *ecdb_ahdr; | 142 | struct iscsi_ecdb_ahdr *ecdb_ahdr; |
143 | int rc; | 143 | int rc; |
144 | 144 | ||
145 | ecdb_ahdr = iscsi_next_hdr(ctask); | 145 | ecdb_ahdr = iscsi_next_hdr(task); |
146 | rlen = cmd->cmd_len - ISCSI_CDB_SIZE; | 146 | rlen = cmd->cmd_len - ISCSI_CDB_SIZE; |
147 | 147 | ||
148 | BUG_ON(rlen > sizeof(ecdb_ahdr->ecdb)); | 148 | BUG_ON(rlen > sizeof(ecdb_ahdr->ecdb)); |
@@ -150,7 +150,7 @@ static int iscsi_prep_ecdb_ahs(struct iscsi_cmd_task *ctask) | |||
150 | 150 | ||
151 | pad_len = iscsi_padding(rlen); | 151 | pad_len = iscsi_padding(rlen); |
152 | 152 | ||
153 | rc = iscsi_add_hdr(ctask, sizeof(ecdb_ahdr->ahslength) + | 153 | rc = iscsi_add_hdr(task, sizeof(ecdb_ahdr->ahslength) + |
154 | sizeof(ecdb_ahdr->ahstype) + ahslength + pad_len); | 154 | sizeof(ecdb_ahdr->ahstype) + ahslength + pad_len); |
155 | if (rc) | 155 | if (rc) |
156 | return rc; | 156 | return rc; |
@@ -165,19 +165,19 @@ static int iscsi_prep_ecdb_ahs(struct iscsi_cmd_task *ctask) | |||
165 | 165 | ||
166 | debug_scsi("iscsi_prep_ecdb_ahs: varlen_cdb_len %d " | 166 | debug_scsi("iscsi_prep_ecdb_ahs: varlen_cdb_len %d " |
167 | "rlen %d pad_len %d ahs_length %d iscsi_headers_size %u\n", | 167 | "rlen %d pad_len %d ahs_length %d iscsi_headers_size %u\n", |
168 | cmd->cmd_len, rlen, pad_len, ahslength, ctask->hdr_len); | 168 | cmd->cmd_len, rlen, pad_len, ahslength, task->hdr_len); |
169 | 169 | ||
170 | return 0; | 170 | return 0; |
171 | } | 171 | } |
172 | 172 | ||
173 | static int iscsi_prep_bidi_ahs(struct iscsi_cmd_task *ctask) | 173 | static int iscsi_prep_bidi_ahs(struct iscsi_task *task) |
174 | { | 174 | { |
175 | struct scsi_cmnd *sc = ctask->sc; | 175 | struct scsi_cmnd *sc = task->sc; |
176 | struct iscsi_rlength_ahdr *rlen_ahdr; | 176 | struct iscsi_rlength_ahdr *rlen_ahdr; |
177 | int rc; | 177 | int rc; |
178 | 178 | ||
179 | rlen_ahdr = iscsi_next_hdr(ctask); | 179 | rlen_ahdr = iscsi_next_hdr(task); |
180 | rc = iscsi_add_hdr(ctask, sizeof(*rlen_ahdr)); | 180 | rc = iscsi_add_hdr(task, sizeof(*rlen_ahdr)); |
181 | if (rc) | 181 | if (rc) |
182 | return rc; | 182 | return rc; |
183 | 183 | ||
@@ -197,28 +197,28 @@ static int iscsi_prep_bidi_ahs(struct iscsi_cmd_task *ctask) | |||
197 | 197 | ||
198 | /** | 198 | /** |
199 | * iscsi_prep_scsi_cmd_pdu - prep iscsi scsi cmd pdu | 199 | * iscsi_prep_scsi_cmd_pdu - prep iscsi scsi cmd pdu |
200 | * @ctask: iscsi task | 200 | * @task: iscsi task |
201 | * | 201 | * |
202 | * Prep basic iSCSI PDU fields for a scsi cmd pdu. The LLD should set | 202 | * Prep basic iSCSI PDU fields for a scsi cmd pdu. The LLD should set |
203 | * fields like dlength or final based on how much data it sends | 203 | * fields like dlength or final based on how much data it sends |
204 | */ | 204 | */ |
205 | static int iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask) | 205 | static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task) |
206 | { | 206 | { |
207 | struct iscsi_conn *conn = ctask->conn; | 207 | struct iscsi_conn *conn = task->conn; |
208 | struct iscsi_session *session = conn->session; | 208 | struct iscsi_session *session = conn->session; |
209 | struct iscsi_cmd *hdr = ctask->hdr; | 209 | struct iscsi_cmd *hdr = task->hdr; |
210 | struct scsi_cmnd *sc = ctask->sc; | 210 | struct scsi_cmnd *sc = task->sc; |
211 | unsigned hdrlength, cmd_len; | 211 | unsigned hdrlength, cmd_len; |
212 | int rc; | 212 | int rc; |
213 | 213 | ||
214 | ctask->hdr_len = 0; | 214 | task->hdr_len = 0; |
215 | rc = iscsi_add_hdr(ctask, sizeof(*hdr)); | 215 | rc = iscsi_add_hdr(task, sizeof(*hdr)); |
216 | if (rc) | 216 | if (rc) |
217 | return rc; | 217 | return rc; |
218 | hdr->opcode = ISCSI_OP_SCSI_CMD; | 218 | hdr->opcode = ISCSI_OP_SCSI_CMD; |
219 | hdr->flags = ISCSI_ATTR_SIMPLE; | 219 | hdr->flags = ISCSI_ATTR_SIMPLE; |
220 | int_to_scsilun(sc->device->lun, (struct scsi_lun *)hdr->lun); | 220 | int_to_scsilun(sc->device->lun, (struct scsi_lun *)hdr->lun); |
221 | hdr->itt = build_itt(ctask->itt, session->age); | 221 | hdr->itt = build_itt(task->itt, session->age); |
222 | hdr->cmdsn = cpu_to_be32(session->cmdsn); | 222 | hdr->cmdsn = cpu_to_be32(session->cmdsn); |
223 | session->cmdsn++; | 223 | session->cmdsn++; |
224 | hdr->exp_statsn = cpu_to_be32(conn->exp_statsn); | 224 | hdr->exp_statsn = cpu_to_be32(conn->exp_statsn); |
@@ -226,17 +226,17 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask) | |||
226 | if (cmd_len < ISCSI_CDB_SIZE) | 226 | if (cmd_len < ISCSI_CDB_SIZE) |
227 | memset(&hdr->cdb[cmd_len], 0, ISCSI_CDB_SIZE - cmd_len); | 227 | memset(&hdr->cdb[cmd_len], 0, ISCSI_CDB_SIZE - cmd_len); |
228 | else if (cmd_len > ISCSI_CDB_SIZE) { | 228 | else if (cmd_len > ISCSI_CDB_SIZE) { |
229 | rc = iscsi_prep_ecdb_ahs(ctask); | 229 | rc = iscsi_prep_ecdb_ahs(task); |
230 | if (rc) | 230 | if (rc) |
231 | return rc; | 231 | return rc; |
232 | cmd_len = ISCSI_CDB_SIZE; | 232 | cmd_len = ISCSI_CDB_SIZE; |
233 | } | 233 | } |
234 | memcpy(hdr->cdb, sc->cmnd, cmd_len); | 234 | memcpy(hdr->cdb, sc->cmnd, cmd_len); |
235 | 235 | ||
236 | ctask->imm_count = 0; | 236 | task->imm_count = 0; |
237 | if (scsi_bidi_cmnd(sc)) { | 237 | if (scsi_bidi_cmnd(sc)) { |
238 | hdr->flags |= ISCSI_FLAG_CMD_READ; | 238 | hdr->flags |= ISCSI_FLAG_CMD_READ; |
239 | rc = iscsi_prep_bidi_ahs(ctask); | 239 | rc = iscsi_prep_bidi_ahs(task); |
240 | if (rc) | 240 | if (rc) |
241 | return rc; | 241 | return rc; |
242 | } | 242 | } |
@@ -258,28 +258,28 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask) | |||
258 | * | 258 | * |
259 | * pad_count bytes to be sent as zero-padding | 259 | * pad_count bytes to be sent as zero-padding |
260 | */ | 260 | */ |
261 | ctask->unsol_count = 0; | 261 | task->unsol_count = 0; |
262 | ctask->unsol_offset = 0; | 262 | task->unsol_offset = 0; |
263 | ctask->unsol_datasn = 0; | 263 | task->unsol_datasn = 0; |
264 | 264 | ||
265 | if (session->imm_data_en) { | 265 | if (session->imm_data_en) { |
266 | if (out_len >= session->first_burst) | 266 | if (out_len >= session->first_burst) |
267 | ctask->imm_count = min(session->first_burst, | 267 | task->imm_count = min(session->first_burst, |
268 | conn->max_xmit_dlength); | 268 | conn->max_xmit_dlength); |
269 | else | 269 | else |
270 | ctask->imm_count = min(out_len, | 270 | task->imm_count = min(out_len, |
271 | conn->max_xmit_dlength); | 271 | conn->max_xmit_dlength); |
272 | hton24(hdr->dlength, ctask->imm_count); | 272 | hton24(hdr->dlength, task->imm_count); |
273 | } else | 273 | } else |
274 | zero_data(hdr->dlength); | 274 | zero_data(hdr->dlength); |
275 | 275 | ||
276 | if (!session->initial_r2t_en) { | 276 | if (!session->initial_r2t_en) { |
277 | ctask->unsol_count = min(session->first_burst, out_len) | 277 | task->unsol_count = min(session->first_burst, out_len) |
278 | - ctask->imm_count; | 278 | - task->imm_count; |
279 | ctask->unsol_offset = ctask->imm_count; | 279 | task->unsol_offset = task->imm_count; |
280 | } | 280 | } |
281 | 281 | ||
282 | if (!ctask->unsol_count) | 282 | if (!task->unsol_count) |
283 | /* No unsolicit Data-Out's */ | 283 | /* No unsolicit Data-Out's */ |
284 | hdr->flags |= ISCSI_FLAG_CMD_FINAL; | 284 | hdr->flags |= ISCSI_FLAG_CMD_FINAL; |
285 | } else { | 285 | } else { |
@@ -292,7 +292,7 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask) | |||
292 | } | 292 | } |
293 | 293 | ||
294 | /* calculate size of additional header segments (AHSs) */ | 294 | /* calculate size of additional header segments (AHSs) */ |
295 | hdrlength = ctask->hdr_len - sizeof(*hdr); | 295 | hdrlength = task->hdr_len - sizeof(*hdr); |
296 | 296 | ||
297 | WARN_ON(hdrlength & (ISCSI_PAD_LEN-1)); | 297 | WARN_ON(hdrlength & (ISCSI_PAD_LEN-1)); |
298 | hdrlength /= ISCSI_PAD_LEN; | 298 | hdrlength /= ISCSI_PAD_LEN; |
@@ -301,17 +301,17 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask) | |||
301 | hdr->hlength = hdrlength & 0xFF; | 301 | hdr->hlength = hdrlength & 0xFF; |
302 | 302 | ||
303 | if (conn->session->tt->init_task && | 303 | if (conn->session->tt->init_task && |
304 | conn->session->tt->init_task(ctask)) | 304 | conn->session->tt->init_task(task)) |
305 | return -EIO; | 305 | return -EIO; |
306 | 306 | ||
307 | ctask->state = ISCSI_TASK_RUNNING; | 307 | task->state = ISCSI_TASK_RUNNING; |
308 | list_move_tail(&ctask->running, &conn->run_list); | 308 | list_move_tail(&task->running, &conn->run_list); |
309 | 309 | ||
310 | conn->scsicmd_pdus_cnt++; | 310 | conn->scsicmd_pdus_cnt++; |
311 | debug_scsi("iscsi prep [%s cid %d sc %p cdb 0x%x itt 0x%x len %d " | 311 | debug_scsi("iscsi prep [%s cid %d sc %p cdb 0x%x itt 0x%x len %d " |
312 | "bidi_len %d cmdsn %d win %d]\n", scsi_bidi_cmnd(sc) ? | 312 | "bidi_len %d cmdsn %d win %d]\n", scsi_bidi_cmnd(sc) ? |
313 | "bidirectional" : sc->sc_data_direction == DMA_TO_DEVICE ? | 313 | "bidirectional" : sc->sc_data_direction == DMA_TO_DEVICE ? |
314 | "write" : "read", conn->id, sc, sc->cmnd[0], ctask->itt, | 314 | "write" : "read", conn->id, sc, sc->cmnd[0], task->itt, |
315 | scsi_bufflen(sc), | 315 | scsi_bufflen(sc), |
316 | scsi_bidi_cmnd(sc) ? scsi_in(sc)->length : 0, | 316 | scsi_bidi_cmnd(sc) ? scsi_in(sc)->length : 0, |
317 | session->cmdsn, session->max_cmdsn - session->exp_cmdsn + 1); | 317 | session->cmdsn, session->max_cmdsn - session->exp_cmdsn + 1); |
@@ -320,37 +320,37 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task *ctask) | |||
320 | 320 | ||
321 | /** | 321 | /** |
322 | * iscsi_complete_command - finish a task | 322 | * iscsi_complete_command - finish a task |
323 | * @ctask: iscsi cmd task | 323 | * @task: iscsi cmd task |
324 | * | 324 | * |
325 | * Must be called with session lock. | 325 | * Must be called with session lock. |
326 | * This function returns the scsi command to scsi-ml or cleans | 326 | * This function returns the scsi command to scsi-ml or cleans |
327 | * up mgmt tasks then returns the task to the pool. | 327 | * up mgmt tasks then returns the task to the pool. |
328 | */ | 328 | */ |
329 | static void iscsi_complete_command(struct iscsi_cmd_task *ctask) | 329 | static void iscsi_complete_command(struct iscsi_task *task) |
330 | { | 330 | { |
331 | struct iscsi_conn *conn = ctask->conn; | 331 | struct iscsi_conn *conn = task->conn; |
332 | struct iscsi_session *session = conn->session; | 332 | struct iscsi_session *session = conn->session; |
333 | struct scsi_cmnd *sc = ctask->sc; | 333 | struct scsi_cmnd *sc = task->sc; |
334 | 334 | ||
335 | list_del_init(&ctask->running); | 335 | list_del_init(&task->running); |
336 | ctask->state = ISCSI_TASK_COMPLETED; | 336 | task->state = ISCSI_TASK_COMPLETED; |
337 | ctask->sc = NULL; | 337 | task->sc = NULL; |
338 | 338 | ||
339 | if (conn->ctask == ctask) | 339 | if (conn->task == task) |
340 | conn->ctask = NULL; | 340 | conn->task = NULL; |
341 | /* | 341 | /* |
342 | * login ctask is preallocated so do not free | 342 | * login task is preallocated so do not free |
343 | */ | 343 | */ |
344 | if (conn->login_ctask == ctask) | 344 | if (conn->login_task == task) |
345 | return; | 345 | return; |
346 | 346 | ||
347 | __kfifo_put(session->cmdpool.queue, (void*)&ctask, sizeof(void*)); | 347 | __kfifo_put(session->cmdpool.queue, (void*)&task, sizeof(void*)); |
348 | 348 | ||
349 | if (conn->ping_ctask == ctask) | 349 | if (conn->ping_task == task) |
350 | conn->ping_ctask = NULL; | 350 | conn->ping_task = NULL; |
351 | 351 | ||
352 | if (sc) { | 352 | if (sc) { |
353 | ctask->sc = NULL; | 353 | task->sc = NULL; |
354 | /* SCSI eh reuses commands to verify us */ | 354 | /* SCSI eh reuses commands to verify us */ |
355 | sc->SCp.ptr = NULL; | 355 | sc->SCp.ptr = NULL; |
356 | /* | 356 | /* |
@@ -362,47 +362,47 @@ static void iscsi_complete_command(struct iscsi_cmd_task *ctask) | |||
362 | } | 362 | } |
363 | } | 363 | } |
364 | 364 | ||
365 | static void __iscsi_get_ctask(struct iscsi_cmd_task *ctask) | 365 | static void __iscsi_get_task(struct iscsi_task *task) |
366 | { | 366 | { |
367 | atomic_inc(&ctask->refcount); | 367 | atomic_inc(&task->refcount); |
368 | } | 368 | } |
369 | 369 | ||
370 | static void __iscsi_put_ctask(struct iscsi_cmd_task *ctask) | 370 | static void __iscsi_put_task(struct iscsi_task *task) |
371 | { | 371 | { |
372 | if (atomic_dec_and_test(&ctask->refcount)) | 372 | if (atomic_dec_and_test(&task->refcount)) |
373 | iscsi_complete_command(ctask); | 373 | iscsi_complete_command(task); |
374 | } | 374 | } |
375 | 375 | ||
376 | void iscsi_put_ctask(struct iscsi_cmd_task *ctask) | 376 | void iscsi_put_task(struct iscsi_task *task) |
377 | { | 377 | { |
378 | struct iscsi_session *session = ctask->conn->session; | 378 | struct iscsi_session *session = task->conn->session; |
379 | 379 | ||
380 | spin_lock_bh(&session->lock); | 380 | spin_lock_bh(&session->lock); |
381 | __iscsi_put_ctask(ctask); | 381 | __iscsi_put_task(task); |
382 | spin_unlock_bh(&session->lock); | 382 | spin_unlock_bh(&session->lock); |
383 | } | 383 | } |
384 | EXPORT_SYMBOL_GPL(iscsi_put_ctask); | 384 | EXPORT_SYMBOL_GPL(iscsi_put_task); |
385 | 385 | ||
386 | /* | 386 | /* |
387 | * session lock must be held | 387 | * session lock must be held |
388 | */ | 388 | */ |
389 | static void fail_command(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask, | 389 | static void fail_command(struct iscsi_conn *conn, struct iscsi_task *task, |
390 | int err) | 390 | int err) |
391 | { | 391 | { |
392 | struct scsi_cmnd *sc; | 392 | struct scsi_cmnd *sc; |
393 | 393 | ||
394 | sc = ctask->sc; | 394 | sc = task->sc; |
395 | if (!sc) | 395 | if (!sc) |
396 | return; | 396 | return; |
397 | 397 | ||
398 | if (ctask->state == ISCSI_TASK_PENDING) | 398 | if (task->state == ISCSI_TASK_PENDING) |
399 | /* | 399 | /* |
400 | * cmd never made it to the xmit thread, so we should not count | 400 | * cmd never made it to the xmit thread, so we should not count |
401 | * the cmd in the sequencing | 401 | * the cmd in the sequencing |
402 | */ | 402 | */ |
403 | conn->session->queued_cmdsn--; | 403 | conn->session->queued_cmdsn--; |
404 | else | 404 | else |
405 | conn->session->tt->cleanup_task(conn, ctask); | 405 | conn->session->tt->cleanup_task(conn, task); |
406 | 406 | ||
407 | sc->result = err; | 407 | sc->result = err; |
408 | 408 | ||
@@ -413,17 +413,17 @@ static void fail_command(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask, | |||
413 | scsi_in(sc)->resid = scsi_in(sc)->length; | 413 | scsi_in(sc)->resid = scsi_in(sc)->length; |
414 | } | 414 | } |
415 | 415 | ||
416 | if (conn->ctask == ctask) | 416 | if (conn->task == task) |
417 | conn->ctask = NULL; | 417 | conn->task = NULL; |
418 | /* release ref from queuecommand */ | 418 | /* release ref from queuecommand */ |
419 | __iscsi_put_ctask(ctask); | 419 | __iscsi_put_task(task); |
420 | } | 420 | } |
421 | 421 | ||
422 | static int iscsi_prep_mgmt_task(struct iscsi_conn *conn, | 422 | static int iscsi_prep_mgmt_task(struct iscsi_conn *conn, |
423 | struct iscsi_cmd_task *ctask) | 423 | struct iscsi_task *task) |
424 | { | 424 | { |
425 | struct iscsi_session *session = conn->session; | 425 | struct iscsi_session *session = conn->session; |
426 | struct iscsi_hdr *hdr = (struct iscsi_hdr *)ctask->hdr; | 426 | struct iscsi_hdr *hdr = (struct iscsi_hdr *)task->hdr; |
427 | struct iscsi_nopout *nop = (struct iscsi_nopout *)hdr; | 427 | struct iscsi_nopout *nop = (struct iscsi_nopout *)hdr; |
428 | 428 | ||
429 | if (conn->session->state == ISCSI_STATE_LOGGING_OUT) | 429 | if (conn->session->state == ISCSI_STATE_LOGGING_OUT) |
@@ -437,7 +437,7 @@ static int iscsi_prep_mgmt_task(struct iscsi_conn *conn, | |||
437 | */ | 437 | */ |
438 | nop->cmdsn = cpu_to_be32(session->cmdsn); | 438 | nop->cmdsn = cpu_to_be32(session->cmdsn); |
439 | if (hdr->itt != RESERVED_ITT) { | 439 | if (hdr->itt != RESERVED_ITT) { |
440 | hdr->itt = build_itt(ctask->itt, session->age); | 440 | hdr->itt = build_itt(task->itt, session->age); |
441 | /* | 441 | /* |
442 | * TODO: We always use immediate, so we never hit this. | 442 | * TODO: We always use immediate, so we never hit this. |
443 | * If we start to send tmfs or nops as non-immediate then | 443 | * If we start to send tmfs or nops as non-immediate then |
@@ -451,24 +451,24 @@ static int iscsi_prep_mgmt_task(struct iscsi_conn *conn, | |||
451 | } | 451 | } |
452 | 452 | ||
453 | if (session->tt->init_task) | 453 | if (session->tt->init_task) |
454 | session->tt->init_task(ctask); | 454 | session->tt->init_task(task); |
455 | 455 | ||
456 | if ((hdr->opcode & ISCSI_OPCODE_MASK) == ISCSI_OP_LOGOUT) | 456 | if ((hdr->opcode & ISCSI_OPCODE_MASK) == ISCSI_OP_LOGOUT) |
457 | session->state = ISCSI_STATE_LOGGING_OUT; | 457 | session->state = ISCSI_STATE_LOGGING_OUT; |
458 | 458 | ||
459 | list_move_tail(&ctask->running, &conn->mgmt_run_list); | 459 | list_move_tail(&task->running, &conn->mgmt_run_list); |
460 | debug_scsi("mgmtpdu [op 0x%x hdr->itt 0x%x datalen %d]\n", | 460 | debug_scsi("mgmtpdu [op 0x%x hdr->itt 0x%x datalen %d]\n", |
461 | hdr->opcode & ISCSI_OPCODE_MASK, hdr->itt, | 461 | hdr->opcode & ISCSI_OPCODE_MASK, hdr->itt, |
462 | ctask->data_count); | 462 | task->data_count); |
463 | return 0; | 463 | return 0; |
464 | } | 464 | } |
465 | 465 | ||
466 | static struct iscsi_cmd_task * | 466 | static struct iscsi_task * |
467 | __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, | 467 | __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, |
468 | char *data, uint32_t data_size) | 468 | char *data, uint32_t data_size) |
469 | { | 469 | { |
470 | struct iscsi_session *session = conn->session; | 470 | struct iscsi_session *session = conn->session; |
471 | struct iscsi_cmd_task *ctask; | 471 | struct iscsi_task *task; |
472 | 472 | ||
473 | if (session->state == ISCSI_STATE_TERMINATE) | 473 | if (session->state == ISCSI_STATE_TERMINATE) |
474 | return NULL; | 474 | return NULL; |
@@ -481,18 +481,18 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, | |||
481 | * Same task can be used. Same ITT must be used. | 481 | * Same task can be used. Same ITT must be used. |
482 | * Note that login_task is preallocated at conn_create(). | 482 | * Note that login_task is preallocated at conn_create(). |
483 | */ | 483 | */ |
484 | ctask = conn->login_ctask; | 484 | task = conn->login_task; |
485 | else { | 485 | else { |
486 | BUG_ON(conn->c_stage == ISCSI_CONN_INITIAL_STAGE); | 486 | BUG_ON(conn->c_stage == ISCSI_CONN_INITIAL_STAGE); |
487 | BUG_ON(conn->c_stage == ISCSI_CONN_STOPPED); | 487 | BUG_ON(conn->c_stage == ISCSI_CONN_STOPPED); |
488 | 488 | ||
489 | if (!__kfifo_get(session->cmdpool.queue, | 489 | if (!__kfifo_get(session->cmdpool.queue, |
490 | (void*)&ctask, sizeof(void*))) | 490 | (void*)&task, sizeof(void*))) |
491 | return NULL; | 491 | return NULL; |
492 | 492 | ||
493 | if ((hdr->opcode == (ISCSI_OP_NOOP_OUT | ISCSI_OP_IMMEDIATE)) && | 493 | if ((hdr->opcode == (ISCSI_OP_NOOP_OUT | ISCSI_OP_IMMEDIATE)) && |
494 | hdr->ttt == RESERVED_ITT) { | 494 | hdr->ttt == RESERVED_ITT) { |
495 | conn->ping_ctask = ctask; | 495 | conn->ping_task = task; |
496 | conn->last_ping = jiffies; | 496 | conn->last_ping = jiffies; |
497 | } | 497 | } |
498 | } | 498 | } |
@@ -501,33 +501,33 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, | |||
501 | * released by the lld when it has transmitted the task for | 501 | * released by the lld when it has transmitted the task for |
502 | * pdus we do not expect a response for. | 502 | * pdus we do not expect a response for. |
503 | */ | 503 | */ |
504 | atomic_set(&ctask->refcount, 1); | 504 | atomic_set(&task->refcount, 1); |
505 | ctask->conn = conn; | 505 | task->conn = conn; |
506 | ctask->sc = NULL; | 506 | task->sc = NULL; |
507 | 507 | ||
508 | if (data_size) { | 508 | if (data_size) { |
509 | memcpy(ctask->data, data, data_size); | 509 | memcpy(task->data, data, data_size); |
510 | ctask->data_count = data_size; | 510 | task->data_count = data_size; |
511 | } else | 511 | } else |
512 | ctask->data_count = 0; | 512 | task->data_count = 0; |
513 | 513 | ||
514 | memcpy(ctask->hdr, hdr, sizeof(struct iscsi_hdr)); | 514 | memcpy(task->hdr, hdr, sizeof(struct iscsi_hdr)); |
515 | INIT_LIST_HEAD(&ctask->running); | 515 | INIT_LIST_HEAD(&task->running); |
516 | list_add_tail(&ctask->running, &conn->mgmtqueue); | 516 | list_add_tail(&task->running, &conn->mgmtqueue); |
517 | 517 | ||
518 | if (session->tt->caps & CAP_DATA_PATH_OFFLOAD) { | 518 | if (session->tt->caps & CAP_DATA_PATH_OFFLOAD) { |
519 | if (iscsi_prep_mgmt_task(conn, ctask)) { | 519 | if (iscsi_prep_mgmt_task(conn, task)) { |
520 | __iscsi_put_ctask(ctask); | 520 | __iscsi_put_task(task); |
521 | return NULL; | 521 | return NULL; |
522 | } | 522 | } |
523 | 523 | ||
524 | if (session->tt->xmit_task(ctask)) | 524 | if (session->tt->xmit_task(task)) |
525 | ctask = NULL; | 525 | task = NULL; |
526 | 526 | ||
527 | } else | 527 | } else |
528 | scsi_queue_work(conn->session->host, &conn->xmitwork); | 528 | scsi_queue_work(conn->session->host, &conn->xmitwork); |
529 | 529 | ||
530 | return ctask; | 530 | return task; |
531 | } | 531 | } |
532 | 532 | ||
533 | int iscsi_conn_send_pdu(struct iscsi_cls_conn *cls_conn, struct iscsi_hdr *hdr, | 533 | int iscsi_conn_send_pdu(struct iscsi_cls_conn *cls_conn, struct iscsi_hdr *hdr, |
@@ -549,20 +549,20 @@ EXPORT_SYMBOL_GPL(iscsi_conn_send_pdu); | |||
549 | * iscsi_cmd_rsp - SCSI Command Response processing | 549 | * iscsi_cmd_rsp - SCSI Command Response processing |
550 | * @conn: iscsi connection | 550 | * @conn: iscsi connection |
551 | * @hdr: iscsi header | 551 | * @hdr: iscsi header |
552 | * @ctask: scsi command task | 552 | * @task: scsi command task |
553 | * @data: cmd data buffer | 553 | * @data: cmd data buffer |
554 | * @datalen: len of buffer | 554 | * @datalen: len of buffer |
555 | * | 555 | * |
556 | * iscsi_cmd_rsp sets up the scsi_cmnd fields based on the PDU and | 556 | * iscsi_cmd_rsp sets up the scsi_cmnd fields based on the PDU and |
557 | * then completes the command and ctask. | 557 | * then completes the command and task. |
558 | **/ | 558 | **/ |
559 | static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr, | 559 | static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr, |
560 | struct iscsi_cmd_task *ctask, char *data, | 560 | struct iscsi_task *task, char *data, |
561 | int datalen) | 561 | int datalen) |
562 | { | 562 | { |
563 | struct iscsi_cmd_rsp *rhdr = (struct iscsi_cmd_rsp *)hdr; | 563 | struct iscsi_cmd_rsp *rhdr = (struct iscsi_cmd_rsp *)hdr; |
564 | struct iscsi_session *session = conn->session; | 564 | struct iscsi_session *session = conn->session; |
565 | struct scsi_cmnd *sc = ctask->sc; | 565 | struct scsi_cmnd *sc = task->sc; |
566 | 566 | ||
567 | iscsi_update_cmdsn(session, (struct iscsi_nopin*)rhdr); | 567 | iscsi_update_cmdsn(session, (struct iscsi_nopin*)rhdr); |
568 | conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1; | 568 | conn->exp_statsn = be32_to_cpu(rhdr->statsn) + 1; |
@@ -622,10 +622,10 @@ invalid_datalen: | |||
622 | } | 622 | } |
623 | out: | 623 | out: |
624 | debug_scsi("done [sc %lx res %d itt 0x%x]\n", | 624 | debug_scsi("done [sc %lx res %d itt 0x%x]\n", |
625 | (long)sc, sc->result, ctask->itt); | 625 | (long)sc, sc->result, task->itt); |
626 | conn->scsirsp_pdus_cnt++; | 626 | conn->scsirsp_pdus_cnt++; |
627 | 627 | ||
628 | __iscsi_put_ctask(ctask); | 628 | __iscsi_put_task(task); |
629 | } | 629 | } |
630 | 630 | ||
631 | static void iscsi_tmf_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr) | 631 | static void iscsi_tmf_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr) |
@@ -650,9 +650,9 @@ static void iscsi_tmf_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr) | |||
650 | static void iscsi_send_nopout(struct iscsi_conn *conn, struct iscsi_nopin *rhdr) | 650 | static void iscsi_send_nopout(struct iscsi_conn *conn, struct iscsi_nopin *rhdr) |
651 | { | 651 | { |
652 | struct iscsi_nopout hdr; | 652 | struct iscsi_nopout hdr; |
653 | struct iscsi_cmd_task *ctask; | 653 | struct iscsi_task *task; |
654 | 654 | ||
655 | if (!rhdr && conn->ping_ctask) | 655 | if (!rhdr && conn->ping_task) |
656 | return; | 656 | return; |
657 | 657 | ||
658 | memset(&hdr, 0, sizeof(struct iscsi_nopout)); | 658 | memset(&hdr, 0, sizeof(struct iscsi_nopout)); |
@@ -666,8 +666,8 @@ static void iscsi_send_nopout(struct iscsi_conn *conn, struct iscsi_nopin *rhdr) | |||
666 | } else | 666 | } else |
667 | hdr.ttt = RESERVED_ITT; | 667 | hdr.ttt = RESERVED_ITT; |
668 | 668 | ||
669 | ctask = __iscsi_conn_send_pdu(conn, (struct iscsi_hdr *)&hdr, NULL, 0); | 669 | task = __iscsi_conn_send_pdu(conn, (struct iscsi_hdr *)&hdr, NULL, 0); |
670 | if (!ctask) | 670 | if (!task) |
671 | iscsi_conn_printk(KERN_ERR, conn, "Could not send nopout\n"); | 671 | iscsi_conn_printk(KERN_ERR, conn, "Could not send nopout\n"); |
672 | } | 672 | } |
673 | 673 | ||
@@ -712,7 +712,7 @@ static int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, | |||
712 | { | 712 | { |
713 | struct iscsi_session *session = conn->session; | 713 | struct iscsi_session *session = conn->session; |
714 | int opcode = hdr->opcode & ISCSI_OPCODE_MASK, rc = 0; | 714 | int opcode = hdr->opcode & ISCSI_OPCODE_MASK, rc = 0; |
715 | struct iscsi_cmd_task *ctask; | 715 | struct iscsi_task *task; |
716 | uint32_t itt; | 716 | uint32_t itt; |
717 | 717 | ||
718 | conn->last_recv = jiffies; | 718 | conn->last_recv = jiffies; |
@@ -758,27 +758,27 @@ static int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, | |||
758 | goto out; | 758 | goto out; |
759 | } | 759 | } |
760 | 760 | ||
761 | ctask = session->cmds[itt]; | 761 | task = session->cmds[itt]; |
762 | switch(opcode) { | 762 | switch(opcode) { |
763 | case ISCSI_OP_SCSI_CMD_RSP: | 763 | case ISCSI_OP_SCSI_CMD_RSP: |
764 | if (!ctask->sc) { | 764 | if (!task->sc) { |
765 | rc = ISCSI_ERR_NO_SCSI_CMD; | 765 | rc = ISCSI_ERR_NO_SCSI_CMD; |
766 | break; | 766 | break; |
767 | } | 767 | } |
768 | BUG_ON((void*)ctask != ctask->sc->SCp.ptr); | 768 | BUG_ON((void*)task != task->sc->SCp.ptr); |
769 | iscsi_scsi_cmd_rsp(conn, hdr, ctask, data, datalen); | 769 | iscsi_scsi_cmd_rsp(conn, hdr, task, data, datalen); |
770 | break; | 770 | break; |
771 | case ISCSI_OP_SCSI_DATA_IN: | 771 | case ISCSI_OP_SCSI_DATA_IN: |
772 | if (!ctask->sc) { | 772 | if (!task->sc) { |
773 | rc = ISCSI_ERR_NO_SCSI_CMD; | 773 | rc = ISCSI_ERR_NO_SCSI_CMD; |
774 | break; | 774 | break; |
775 | } | 775 | } |
776 | BUG_ON((void*)ctask != ctask->sc->SCp.ptr); | 776 | BUG_ON((void*)task != task->sc->SCp.ptr); |
777 | if (hdr->flags & ISCSI_FLAG_DATA_STATUS) { | 777 | if (hdr->flags & ISCSI_FLAG_DATA_STATUS) { |
778 | conn->scsirsp_pdus_cnt++; | 778 | conn->scsirsp_pdus_cnt++; |
779 | iscsi_update_cmdsn(session, | 779 | iscsi_update_cmdsn(session, |
780 | (struct iscsi_nopin*) hdr); | 780 | (struct iscsi_nopin*) hdr); |
781 | __iscsi_put_ctask(ctask); | 781 | __iscsi_put_task(task); |
782 | } | 782 | } |
783 | break; | 783 | break; |
784 | case ISCSI_OP_R2T: | 784 | case ISCSI_OP_R2T: |
@@ -808,7 +808,7 @@ static int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, | |||
808 | } | 808 | } |
809 | 809 | ||
810 | iscsi_tmf_rsp(conn, hdr); | 810 | iscsi_tmf_rsp(conn, hdr); |
811 | __iscsi_put_ctask(ctask); | 811 | __iscsi_put_task(task); |
812 | break; | 812 | break; |
813 | case ISCSI_OP_NOOP_IN: | 813 | case ISCSI_OP_NOOP_IN: |
814 | iscsi_update_cmdsn(session, (struct iscsi_nopin*)hdr); | 814 | iscsi_update_cmdsn(session, (struct iscsi_nopin*)hdr); |
@@ -818,13 +818,15 @@ static int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, | |||
818 | } | 818 | } |
819 | conn->exp_statsn = be32_to_cpu(hdr->statsn) + 1; | 819 | conn->exp_statsn = be32_to_cpu(hdr->statsn) + 1; |
820 | 820 | ||
821 | if (conn->ping_ctask != ctask) | 821 | if (conn->ping_task != task) |
822 | /* | 822 | /* |
823 | * If this is not in response to one of our | 823 | * If this is not in response to one of our |
824 | * nops then it must be from userspace. | 824 | * nops then it must be from userspace. |
825 | */ | 825 | */ |
826 | goto recv_pdu; | 826 | goto recv_pdu; |
827 | __iscsi_put_ctask(ctask); | 827 | |
828 | mod_timer(&conn->transport_timer, jiffies + conn->recv_timeout); | ||
829 | __iscsi_put_task(task); | ||
828 | break; | 830 | break; |
829 | default: | 831 | default: |
830 | rc = ISCSI_ERR_BAD_OPCODE; | 832 | rc = ISCSI_ERR_BAD_OPCODE; |
@@ -836,7 +838,7 @@ out: | |||
836 | recv_pdu: | 838 | recv_pdu: |
837 | if (iscsi_recv_pdu(conn->cls_conn, hdr, data, datalen)) | 839 | if (iscsi_recv_pdu(conn->cls_conn, hdr, data, datalen)) |
838 | rc = ISCSI_ERR_CONN_FAILED; | 840 | rc = ISCSI_ERR_CONN_FAILED; |
839 | __iscsi_put_ctask(ctask); | 841 | __iscsi_put_task(task); |
840 | return rc; | 842 | return rc; |
841 | } | 843 | } |
842 | 844 | ||
@@ -855,7 +857,7 @@ EXPORT_SYMBOL_GPL(iscsi_complete_pdu); | |||
855 | int iscsi_verify_itt(struct iscsi_conn *conn, itt_t itt) | 857 | int iscsi_verify_itt(struct iscsi_conn *conn, itt_t itt) |
856 | { | 858 | { |
857 | struct iscsi_session *session = conn->session; | 859 | struct iscsi_session *session = conn->session; |
858 | struct iscsi_cmd_task *ctask; | 860 | struct iscsi_task *task; |
859 | uint32_t i; | 861 | uint32_t i; |
860 | 862 | ||
861 | if (itt == RESERVED_ITT) | 863 | if (itt == RESERVED_ITT) |
@@ -878,11 +880,11 @@ int iscsi_verify_itt(struct iscsi_conn *conn, itt_t itt) | |||
878 | return ISCSI_ERR_BAD_ITT; | 880 | return ISCSI_ERR_BAD_ITT; |
879 | } | 881 | } |
880 | 882 | ||
881 | ctask = session->cmds[i]; | 883 | task = session->cmds[i]; |
882 | if (ctask->sc && ctask->sc->SCp.phase != session->age) { | 884 | if (task->sc && task->sc->SCp.phase != session->age) { |
883 | iscsi_conn_printk(KERN_ERR, conn, | 885 | iscsi_conn_printk(KERN_ERR, conn, |
884 | "iscsi: ctask's session age %d, " | 886 | "iscsi: task's session age %d, " |
885 | "expected %d\n", ctask->sc->SCp.phase, | 887 | "expected %d\n", task->sc->SCp.phase, |
886 | session->age); | 888 | session->age); |
887 | return ISCSI_ERR_SESSION_FAILED; | 889 | return ISCSI_ERR_SESSION_FAILED; |
888 | } | 890 | } |
@@ -890,11 +892,11 @@ int iscsi_verify_itt(struct iscsi_conn *conn, itt_t itt) | |||
890 | } | 892 | } |
891 | EXPORT_SYMBOL_GPL(iscsi_verify_itt); | 893 | EXPORT_SYMBOL_GPL(iscsi_verify_itt); |
892 | 894 | ||
893 | struct iscsi_cmd_task * | 895 | struct iscsi_task * |
894 | iscsi_itt_to_ctask(struct iscsi_conn *conn, itt_t itt) | 896 | iscsi_itt_to_ctask(struct iscsi_conn *conn, itt_t itt) |
895 | { | 897 | { |
896 | struct iscsi_session *session = conn->session; | 898 | struct iscsi_session *session = conn->session; |
897 | struct iscsi_cmd_task *ctask; | 899 | struct iscsi_task *task; |
898 | uint32_t i; | 900 | uint32_t i; |
899 | 901 | ||
900 | if (iscsi_verify_itt(conn, itt)) | 902 | if (iscsi_verify_itt(conn, itt)) |
@@ -907,14 +909,14 @@ iscsi_itt_to_ctask(struct iscsi_conn *conn, itt_t itt) | |||
907 | if (i >= session->cmds_max) | 909 | if (i >= session->cmds_max) |
908 | return NULL; | 910 | return NULL; |
909 | 911 | ||
910 | ctask = session->cmds[i]; | 912 | task = session->cmds[i]; |
911 | if (!ctask->sc) | 913 | if (!task->sc) |
912 | return NULL; | 914 | return NULL; |
913 | 915 | ||
914 | if (ctask->sc->SCp.phase != session->age) | 916 | if (task->sc->SCp.phase != session->age) |
915 | return NULL; | 917 | return NULL; |
916 | 918 | ||
917 | return ctask; | 919 | return task; |
918 | } | 920 | } |
919 | EXPORT_SYMBOL_GPL(iscsi_itt_to_ctask); | 921 | EXPORT_SYMBOL_GPL(iscsi_itt_to_ctask); |
920 | 922 | ||
@@ -955,38 +957,38 @@ static int iscsi_check_cmdsn_window_closed(struct iscsi_conn *conn) | |||
955 | return 0; | 957 | return 0; |
956 | } | 958 | } |
957 | 959 | ||
958 | static int iscsi_xmit_ctask(struct iscsi_conn *conn) | 960 | static int iscsi_xmit_task(struct iscsi_conn *conn) |
959 | { | 961 | { |
960 | struct iscsi_cmd_task *ctask = conn->ctask; | 962 | struct iscsi_task *task = conn->task; |
961 | int rc; | 963 | int rc; |
962 | 964 | ||
963 | __iscsi_get_ctask(ctask); | 965 | __iscsi_get_task(task); |
964 | spin_unlock_bh(&conn->session->lock); | 966 | spin_unlock_bh(&conn->session->lock); |
965 | rc = conn->session->tt->xmit_task(ctask); | 967 | rc = conn->session->tt->xmit_task(task); |
966 | spin_lock_bh(&conn->session->lock); | 968 | spin_lock_bh(&conn->session->lock); |
967 | __iscsi_put_ctask(ctask); | 969 | __iscsi_put_task(task); |
968 | if (!rc) | 970 | if (!rc) |
969 | /* done with this ctask */ | 971 | /* done with this task */ |
970 | conn->ctask = NULL; | 972 | conn->task = NULL; |
971 | return rc; | 973 | return rc; |
972 | } | 974 | } |
973 | 975 | ||
974 | /** | 976 | /** |
975 | * iscsi_requeue_ctask - requeue ctask to run from session workqueue | 977 | * iscsi_requeue_task - requeue task to run from session workqueue |
976 | * @ctask: ctask to requeue | 978 | * @task: task to requeue |
977 | * | 979 | * |
978 | * LLDs that need to run a ctask from the session workqueue should call | 980 | * LLDs that need to run a task from the session workqueue should call |
979 | * this. The session lock must be held. This should only be called | 981 | * this. The session lock must be held. This should only be called |
980 | * by software drivers. | 982 | * by software drivers. |
981 | */ | 983 | */ |
982 | void iscsi_requeue_ctask(struct iscsi_cmd_task *ctask) | 984 | void iscsi_requeue_task(struct iscsi_task *task) |
983 | { | 985 | { |
984 | struct iscsi_conn *conn = ctask->conn; | 986 | struct iscsi_conn *conn = task->conn; |
985 | 987 | ||
986 | list_move_tail(&ctask->running, &conn->requeue); | 988 | list_move_tail(&task->running, &conn->requeue); |
987 | scsi_queue_work(conn->session->host, &conn->xmitwork); | 989 | scsi_queue_work(conn->session->host, &conn->xmitwork); |
988 | } | 990 | } |
989 | EXPORT_SYMBOL_GPL(iscsi_requeue_ctask); | 991 | EXPORT_SYMBOL_GPL(iscsi_requeue_task); |
990 | 992 | ||
991 | /** | 993 | /** |
992 | * iscsi_data_xmit - xmit any command into the scheduled connection | 994 | * iscsi_data_xmit - xmit any command into the scheduled connection |
@@ -1008,8 +1010,8 @@ static int iscsi_data_xmit(struct iscsi_conn *conn) | |||
1008 | return -ENODATA; | 1010 | return -ENODATA; |
1009 | } | 1011 | } |
1010 | 1012 | ||
1011 | if (conn->ctask) { | 1013 | if (conn->task) { |
1012 | rc = iscsi_xmit_ctask(conn); | 1014 | rc = iscsi_xmit_task(conn); |
1013 | if (rc) | 1015 | if (rc) |
1014 | goto again; | 1016 | goto again; |
1015 | } | 1017 | } |
@@ -1021,14 +1023,14 @@ static int iscsi_data_xmit(struct iscsi_conn *conn) | |||
1021 | */ | 1023 | */ |
1022 | check_mgmt: | 1024 | check_mgmt: |
1023 | while (!list_empty(&conn->mgmtqueue)) { | 1025 | while (!list_empty(&conn->mgmtqueue)) { |
1024 | conn->ctask = list_entry(conn->mgmtqueue.next, | 1026 | conn->task = list_entry(conn->mgmtqueue.next, |
1025 | struct iscsi_cmd_task, running); | 1027 | struct iscsi_task, running); |
1026 | if (iscsi_prep_mgmt_task(conn, conn->ctask)) { | 1028 | if (iscsi_prep_mgmt_task(conn, conn->task)) { |
1027 | __iscsi_put_ctask(conn->ctask); | 1029 | __iscsi_put_task(conn->task); |
1028 | conn->ctask = NULL; | 1030 | conn->task = NULL; |
1029 | continue; | 1031 | continue; |
1030 | } | 1032 | } |
1031 | rc = iscsi_xmit_ctask(conn); | 1033 | rc = iscsi_xmit_task(conn); |
1032 | if (rc) | 1034 | if (rc) |
1033 | goto again; | 1035 | goto again; |
1034 | } | 1036 | } |
@@ -1038,21 +1040,21 @@ check_mgmt: | |||
1038 | if (conn->tmf_state == TMF_QUEUED) | 1040 | if (conn->tmf_state == TMF_QUEUED) |
1039 | break; | 1041 | break; |
1040 | 1042 | ||
1041 | conn->ctask = list_entry(conn->xmitqueue.next, | 1043 | conn->task = list_entry(conn->xmitqueue.next, |
1042 | struct iscsi_cmd_task, running); | 1044 | struct iscsi_task, running); |
1043 | if (conn->session->state == ISCSI_STATE_LOGGING_OUT) { | 1045 | if (conn->session->state == ISCSI_STATE_LOGGING_OUT) { |
1044 | fail_command(conn, conn->ctask, DID_IMM_RETRY << 16); | 1046 | fail_command(conn, conn->task, DID_IMM_RETRY << 16); |
1045 | continue; | 1047 | continue; |
1046 | } | 1048 | } |
1047 | if (iscsi_prep_scsi_cmd_pdu(conn->ctask)) { | 1049 | if (iscsi_prep_scsi_cmd_pdu(conn->task)) { |
1048 | fail_command(conn, conn->ctask, DID_ABORT << 16); | 1050 | fail_command(conn, conn->task, DID_ABORT << 16); |
1049 | continue; | 1051 | continue; |
1050 | } | 1052 | } |
1051 | rc = iscsi_xmit_ctask(conn); | 1053 | rc = iscsi_xmit_task(conn); |
1052 | if (rc) | 1054 | if (rc) |
1053 | goto again; | 1055 | goto again; |
1054 | /* | 1056 | /* |
1055 | * we could continuously get new ctask requests so | 1057 | * we could continuously get new task requests so |
1056 | * we need to check the mgmt queue for nops that need to | 1058 | * we need to check the mgmt queue for nops that need to |
1057 | * be sent to aviod starvation | 1059 | * be sent to aviod starvation |
1058 | */ | 1060 | */ |
@@ -1070,11 +1072,11 @@ check_mgmt: | |||
1070 | if (conn->session->state == ISCSI_STATE_LOGGING_OUT) | 1072 | if (conn->session->state == ISCSI_STATE_LOGGING_OUT) |
1071 | break; | 1073 | break; |
1072 | 1074 | ||
1073 | conn->ctask = list_entry(conn->requeue.next, | 1075 | conn->task = list_entry(conn->requeue.next, |
1074 | struct iscsi_cmd_task, running); | 1076 | struct iscsi_task, running); |
1075 | conn->ctask->state = ISCSI_TASK_RUNNING; | 1077 | conn->task->state = ISCSI_TASK_RUNNING; |
1076 | list_move_tail(conn->requeue.next, &conn->run_list); | 1078 | list_move_tail(conn->requeue.next, &conn->run_list); |
1077 | rc = iscsi_xmit_ctask(conn); | 1079 | rc = iscsi_xmit_task(conn); |
1078 | if (rc) | 1080 | if (rc) |
1079 | goto again; | 1081 | goto again; |
1080 | if (!list_empty(&conn->mgmtqueue)) | 1082 | if (!list_empty(&conn->mgmtqueue)) |
@@ -1123,7 +1125,7 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)) | |||
1123 | int reason = 0; | 1125 | int reason = 0; |
1124 | struct iscsi_session *session; | 1126 | struct iscsi_session *session; |
1125 | struct iscsi_conn *conn; | 1127 | struct iscsi_conn *conn; |
1126 | struct iscsi_cmd_task *ctask = NULL; | 1128 | struct iscsi_task *task = NULL; |
1127 | 1129 | ||
1128 | sc->scsi_done = done; | 1130 | sc->scsi_done = done; |
1129 | sc->result = 0; | 1131 | sc->result = 0; |
@@ -1191,31 +1193,31 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)) | |||
1191 | goto reject; | 1193 | goto reject; |
1192 | } | 1194 | } |
1193 | 1195 | ||
1194 | if (!__kfifo_get(session->cmdpool.queue, (void*)&ctask, | 1196 | if (!__kfifo_get(session->cmdpool.queue, (void*)&task, |
1195 | sizeof(void*))) { | 1197 | sizeof(void*))) { |
1196 | reason = FAILURE_OOM; | 1198 | reason = FAILURE_OOM; |
1197 | goto reject; | 1199 | goto reject; |
1198 | } | 1200 | } |
1199 | sc->SCp.phase = session->age; | 1201 | sc->SCp.phase = session->age; |
1200 | sc->SCp.ptr = (char *)ctask; | 1202 | sc->SCp.ptr = (char *)task; |
1201 | 1203 | ||
1202 | atomic_set(&ctask->refcount, 1); | 1204 | atomic_set(&task->refcount, 1); |
1203 | ctask->state = ISCSI_TASK_PENDING; | 1205 | task->state = ISCSI_TASK_PENDING; |
1204 | ctask->conn = conn; | 1206 | task->conn = conn; |
1205 | ctask->sc = sc; | 1207 | task->sc = sc; |
1206 | INIT_LIST_HEAD(&ctask->running); | 1208 | INIT_LIST_HEAD(&task->running); |
1207 | list_add_tail(&ctask->running, &conn->xmitqueue); | 1209 | list_add_tail(&task->running, &conn->xmitqueue); |
1208 | 1210 | ||
1209 | if (session->tt->caps & CAP_DATA_PATH_OFFLOAD) { | 1211 | if (session->tt->caps & CAP_DATA_PATH_OFFLOAD) { |
1210 | if (iscsi_prep_scsi_cmd_pdu(ctask)) { | 1212 | if (iscsi_prep_scsi_cmd_pdu(task)) { |
1211 | sc->result = DID_ABORT << 16; | 1213 | sc->result = DID_ABORT << 16; |
1212 | sc->scsi_done = NULL; | 1214 | sc->scsi_done = NULL; |
1213 | iscsi_complete_command(ctask); | 1215 | iscsi_complete_command(task); |
1214 | goto fault; | 1216 | goto fault; |
1215 | } | 1217 | } |
1216 | if (session->tt->xmit_task(ctask)) { | 1218 | if (session->tt->xmit_task(task)) { |
1217 | sc->scsi_done = NULL; | 1219 | sc->scsi_done = NULL; |
1218 | iscsi_complete_command(ctask); | 1220 | iscsi_complete_command(task); |
1219 | reason = FAILURE_SESSION_NOT_READY; | 1221 | reason = FAILURE_SESSION_NOT_READY; |
1220 | goto reject; | 1222 | goto reject; |
1221 | } | 1223 | } |
@@ -1336,16 +1338,16 @@ static void iscsi_tmf_timedout(unsigned long data) | |||
1336 | spin_unlock(&session->lock); | 1338 | spin_unlock(&session->lock); |
1337 | } | 1339 | } |
1338 | 1340 | ||
1339 | static int iscsi_exec_ctask_mgmt_fn(struct iscsi_conn *conn, | 1341 | static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn, |
1340 | struct iscsi_tm *hdr, int age, | 1342 | struct iscsi_tm *hdr, int age, |
1341 | int timeout) | 1343 | int timeout) |
1342 | { | 1344 | { |
1343 | struct iscsi_session *session = conn->session; | 1345 | struct iscsi_session *session = conn->session; |
1344 | struct iscsi_cmd_task *ctask; | 1346 | struct iscsi_task *task; |
1345 | 1347 | ||
1346 | ctask = __iscsi_conn_send_pdu(conn, (struct iscsi_hdr *)hdr, | 1348 | task = __iscsi_conn_send_pdu(conn, (struct iscsi_hdr *)hdr, |
1347 | NULL, 0); | 1349 | NULL, 0); |
1348 | if (!ctask) { | 1350 | if (!task) { |
1349 | spin_unlock_bh(&session->lock); | 1351 | spin_unlock_bh(&session->lock); |
1350 | iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); | 1352 | iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); |
1351 | spin_lock_bh(&session->lock); | 1353 | spin_lock_bh(&session->lock); |
@@ -1379,7 +1381,7 @@ static int iscsi_exec_ctask_mgmt_fn(struct iscsi_conn *conn, | |||
1379 | 1381 | ||
1380 | mutex_lock(&session->eh_mutex); | 1382 | mutex_lock(&session->eh_mutex); |
1381 | spin_lock_bh(&session->lock); | 1383 | spin_lock_bh(&session->lock); |
1382 | /* if the session drops it will clean up the ctask */ | 1384 | /* if the session drops it will clean up the task */ |
1383 | if (age != session->age || | 1385 | if (age != session->age || |
1384 | session->state != ISCSI_STATE_LOGGED_IN) | 1386 | session->state != ISCSI_STATE_LOGGED_IN) |
1385 | return -ENOTCONN; | 1387 | return -ENOTCONN; |
@@ -1393,34 +1395,34 @@ static int iscsi_exec_ctask_mgmt_fn(struct iscsi_conn *conn, | |||
1393 | static void fail_all_commands(struct iscsi_conn *conn, unsigned lun, | 1395 | static void fail_all_commands(struct iscsi_conn *conn, unsigned lun, |
1394 | int error) | 1396 | int error) |
1395 | { | 1397 | { |
1396 | struct iscsi_cmd_task *ctask, *tmp; | 1398 | struct iscsi_task *task, *tmp; |
1397 | 1399 | ||
1398 | if (conn->ctask && (conn->ctask->sc->device->lun == lun || lun == -1)) | 1400 | if (conn->task && (conn->task->sc->device->lun == lun || lun == -1)) |
1399 | conn->ctask = NULL; | 1401 | conn->task = NULL; |
1400 | 1402 | ||
1401 | /* flush pending */ | 1403 | /* flush pending */ |
1402 | list_for_each_entry_safe(ctask, tmp, &conn->xmitqueue, running) { | 1404 | list_for_each_entry_safe(task, tmp, &conn->xmitqueue, running) { |
1403 | if (lun == ctask->sc->device->lun || lun == -1) { | 1405 | if (lun == task->sc->device->lun || lun == -1) { |
1404 | debug_scsi("failing pending sc %p itt 0x%x\n", | 1406 | debug_scsi("failing pending sc %p itt 0x%x\n", |
1405 | ctask->sc, ctask->itt); | 1407 | task->sc, task->itt); |
1406 | fail_command(conn, ctask, error << 16); | 1408 | fail_command(conn, task, error << 16); |
1407 | } | 1409 | } |
1408 | } | 1410 | } |
1409 | 1411 | ||
1410 | list_for_each_entry_safe(ctask, tmp, &conn->requeue, running) { | 1412 | list_for_each_entry_safe(task, tmp, &conn->requeue, running) { |
1411 | if (lun == ctask->sc->device->lun || lun == -1) { | 1413 | if (lun == task->sc->device->lun || lun == -1) { |
1412 | debug_scsi("failing requeued sc %p itt 0x%x\n", | 1414 | debug_scsi("failing requeued sc %p itt 0x%x\n", |
1413 | ctask->sc, ctask->itt); | 1415 | task->sc, task->itt); |
1414 | fail_command(conn, ctask, error << 16); | 1416 | fail_command(conn, task, error << 16); |
1415 | } | 1417 | } |
1416 | } | 1418 | } |
1417 | 1419 | ||
1418 | /* fail all other running */ | 1420 | /* fail all other running */ |
1419 | list_for_each_entry_safe(ctask, tmp, &conn->run_list, running) { | 1421 | list_for_each_entry_safe(task, tmp, &conn->run_list, running) { |
1420 | if (lun == ctask->sc->device->lun || lun == -1) { | 1422 | if (lun == task->sc->device->lun || lun == -1) { |
1421 | debug_scsi("failing in progress sc %p itt 0x%x\n", | 1423 | debug_scsi("failing in progress sc %p itt 0x%x\n", |
1422 | ctask->sc, ctask->itt); | 1424 | task->sc, task->itt); |
1423 | fail_command(conn, ctask, DID_BUS_BUSY << 16); | 1425 | fail_command(conn, task, DID_BUS_BUSY << 16); |
1424 | } | 1426 | } |
1425 | } | 1427 | } |
1426 | } | 1428 | } |
@@ -1486,7 +1488,7 @@ static enum scsi_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *scmd) | |||
1486 | jiffies)) | 1488 | jiffies)) |
1487 | rc = EH_RESET_TIMER; | 1489 | rc = EH_RESET_TIMER; |
1488 | /* if in the middle of checking the transport then give us more time */ | 1490 | /* if in the middle of checking the transport then give us more time */ |
1489 | if (conn->ping_ctask) | 1491 | if (conn->ping_task) |
1490 | rc = EH_RESET_TIMER; | 1492 | rc = EH_RESET_TIMER; |
1491 | done: | 1493 | done: |
1492 | spin_unlock(&session->lock); | 1494 | spin_unlock(&session->lock); |
@@ -1510,7 +1512,7 @@ static void iscsi_check_transport_timeouts(unsigned long data) | |||
1510 | 1512 | ||
1511 | recv_timeout *= HZ; | 1513 | recv_timeout *= HZ; |
1512 | last_recv = conn->last_recv; | 1514 | last_recv = conn->last_recv; |
1513 | if (conn->ping_ctask && | 1515 | if (conn->ping_task && |
1514 | time_before_eq(conn->last_ping + (conn->ping_timeout * HZ), | 1516 | time_before_eq(conn->last_ping + (conn->ping_timeout * HZ), |
1515 | jiffies)) { | 1517 | jiffies)) { |
1516 | iscsi_conn_printk(KERN_ERR, conn, "ping timeout of %d secs " | 1518 | iscsi_conn_printk(KERN_ERR, conn, "ping timeout of %d secs " |
@@ -1536,16 +1538,16 @@ done: | |||
1536 | spin_unlock(&session->lock); | 1538 | spin_unlock(&session->lock); |
1537 | } | 1539 | } |
1538 | 1540 | ||
1539 | static void iscsi_prep_abort_ctask_pdu(struct iscsi_cmd_task *ctask, | 1541 | static void iscsi_prep_abort_task_pdu(struct iscsi_task *task, |
1540 | struct iscsi_tm *hdr) | 1542 | struct iscsi_tm *hdr) |
1541 | { | 1543 | { |
1542 | memset(hdr, 0, sizeof(*hdr)); | 1544 | memset(hdr, 0, sizeof(*hdr)); |
1543 | hdr->opcode = ISCSI_OP_SCSI_TMFUNC | ISCSI_OP_IMMEDIATE; | 1545 | hdr->opcode = ISCSI_OP_SCSI_TMFUNC | ISCSI_OP_IMMEDIATE; |
1544 | hdr->flags = ISCSI_TM_FUNC_ABORT_TASK & ISCSI_FLAG_TM_FUNC_MASK; | 1546 | hdr->flags = ISCSI_TM_FUNC_ABORT_TASK & ISCSI_FLAG_TM_FUNC_MASK; |
1545 | hdr->flags |= ISCSI_FLAG_CMD_FINAL; | 1547 | hdr->flags |= ISCSI_FLAG_CMD_FINAL; |
1546 | memcpy(hdr->lun, ctask->hdr->lun, sizeof(hdr->lun)); | 1548 | memcpy(hdr->lun, task->hdr->lun, sizeof(hdr->lun)); |
1547 | hdr->rtt = ctask->hdr->itt; | 1549 | hdr->rtt = task->hdr->itt; |
1548 | hdr->refcmdsn = ctask->hdr->cmdsn; | 1550 | hdr->refcmdsn = task->hdr->cmdsn; |
1549 | } | 1551 | } |
1550 | 1552 | ||
1551 | int iscsi_eh_abort(struct scsi_cmnd *sc) | 1553 | int iscsi_eh_abort(struct scsi_cmnd *sc) |
@@ -1553,7 +1555,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) | |||
1553 | struct iscsi_cls_session *cls_session; | 1555 | struct iscsi_cls_session *cls_session; |
1554 | struct iscsi_session *session; | 1556 | struct iscsi_session *session; |
1555 | struct iscsi_conn *conn; | 1557 | struct iscsi_conn *conn; |
1556 | struct iscsi_cmd_task *ctask; | 1558 | struct iscsi_task *task; |
1557 | struct iscsi_tm *hdr; | 1559 | struct iscsi_tm *hdr; |
1558 | int rc, age; | 1560 | int rc, age; |
1559 | 1561 | ||
@@ -1588,17 +1590,17 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) | |||
1588 | conn->eh_abort_cnt++; | 1590 | conn->eh_abort_cnt++; |
1589 | age = session->age; | 1591 | age = session->age; |
1590 | 1592 | ||
1591 | ctask = (struct iscsi_cmd_task *)sc->SCp.ptr; | 1593 | task = (struct iscsi_task *)sc->SCp.ptr; |
1592 | debug_scsi("aborting [sc %p itt 0x%x]\n", sc, ctask->itt); | 1594 | debug_scsi("aborting [sc %p itt 0x%x]\n", sc, task->itt); |
1593 | 1595 | ||
1594 | /* ctask completed before time out */ | 1596 | /* task completed before time out */ |
1595 | if (!ctask->sc) { | 1597 | if (!task->sc) { |
1596 | debug_scsi("sc completed while abort in progress\n"); | 1598 | debug_scsi("sc completed while abort in progress\n"); |
1597 | goto success; | 1599 | goto success; |
1598 | } | 1600 | } |
1599 | 1601 | ||
1600 | if (ctask->state == ISCSI_TASK_PENDING) { | 1602 | if (task->state == ISCSI_TASK_PENDING) { |
1601 | fail_command(conn, ctask, DID_ABORT << 16); | 1603 | fail_command(conn, task, DID_ABORT << 16); |
1602 | goto success; | 1604 | goto success; |
1603 | } | 1605 | } |
1604 | 1606 | ||
@@ -1608,9 +1610,9 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) | |||
1608 | conn->tmf_state = TMF_QUEUED; | 1610 | conn->tmf_state = TMF_QUEUED; |
1609 | 1611 | ||
1610 | hdr = &conn->tmhdr; | 1612 | hdr = &conn->tmhdr; |
1611 | iscsi_prep_abort_ctask_pdu(ctask, hdr); | 1613 | iscsi_prep_abort_task_pdu(task, hdr); |
1612 | 1614 | ||
1613 | if (iscsi_exec_ctask_mgmt_fn(conn, hdr, age, session->abort_timeout)) { | 1615 | if (iscsi_exec_task_mgmt_fn(conn, hdr, age, session->abort_timeout)) { |
1614 | rc = FAILED; | 1616 | rc = FAILED; |
1615 | goto failed; | 1617 | goto failed; |
1616 | } | 1618 | } |
@@ -1620,11 +1622,11 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) | |||
1620 | spin_unlock_bh(&session->lock); | 1622 | spin_unlock_bh(&session->lock); |
1621 | iscsi_suspend_tx(conn); | 1623 | iscsi_suspend_tx(conn); |
1622 | /* | 1624 | /* |
1623 | * clean up ctask if aborted. grab the recv lock as a writer | 1625 | * clean up task if aborted. grab the recv lock as a writer |
1624 | */ | 1626 | */ |
1625 | write_lock_bh(conn->recv_lock); | 1627 | write_lock_bh(conn->recv_lock); |
1626 | spin_lock(&session->lock); | 1628 | spin_lock(&session->lock); |
1627 | fail_command(conn, ctask, DID_ABORT << 16); | 1629 | fail_command(conn, task, DID_ABORT << 16); |
1628 | conn->tmf_state = TMF_INITIAL; | 1630 | conn->tmf_state = TMF_INITIAL; |
1629 | spin_unlock(&session->lock); | 1631 | spin_unlock(&session->lock); |
1630 | write_unlock_bh(conn->recv_lock); | 1632 | write_unlock_bh(conn->recv_lock); |
@@ -1637,7 +1639,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) | |||
1637 | case TMF_NOT_FOUND: | 1639 | case TMF_NOT_FOUND: |
1638 | if (!sc->SCp.ptr) { | 1640 | if (!sc->SCp.ptr) { |
1639 | conn->tmf_state = TMF_INITIAL; | 1641 | conn->tmf_state = TMF_INITIAL; |
1640 | /* ctask completed before tmf abort response */ | 1642 | /* task completed before tmf abort response */ |
1641 | debug_scsi("sc completed while abort in progress\n"); | 1643 | debug_scsi("sc completed while abort in progress\n"); |
1642 | goto success; | 1644 | goto success; |
1643 | } | 1645 | } |
@@ -1650,7 +1652,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc) | |||
1650 | success: | 1652 | success: |
1651 | spin_unlock_bh(&session->lock); | 1653 | spin_unlock_bh(&session->lock); |
1652 | success_unlocked: | 1654 | success_unlocked: |
1653 | debug_scsi("abort success [sc %lx itt 0x%x]\n", (long)sc, ctask->itt); | 1655 | debug_scsi("abort success [sc %lx itt 0x%x]\n", (long)sc, task->itt); |
1654 | mutex_unlock(&session->eh_mutex); | 1656 | mutex_unlock(&session->eh_mutex); |
1655 | return SUCCESS; | 1657 | return SUCCESS; |
1656 | 1658 | ||
@@ -1658,7 +1660,7 @@ failed: | |||
1658 | spin_unlock_bh(&session->lock); | 1660 | spin_unlock_bh(&session->lock); |
1659 | failed_unlocked: | 1661 | failed_unlocked: |
1660 | debug_scsi("abort failed [sc %p itt 0x%x]\n", sc, | 1662 | debug_scsi("abort failed [sc %p itt 0x%x]\n", sc, |
1661 | ctask ? ctask->itt : 0); | 1663 | task ? task->itt : 0); |
1662 | mutex_unlock(&session->eh_mutex); | 1664 | mutex_unlock(&session->eh_mutex); |
1663 | return FAILED; | 1665 | return FAILED; |
1664 | } | 1666 | } |
@@ -1705,7 +1707,7 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc) | |||
1705 | hdr = &conn->tmhdr; | 1707 | hdr = &conn->tmhdr; |
1706 | iscsi_prep_lun_reset_pdu(sc, hdr); | 1708 | iscsi_prep_lun_reset_pdu(sc, hdr); |
1707 | 1709 | ||
1708 | if (iscsi_exec_ctask_mgmt_fn(conn, hdr, session->age, | 1710 | if (iscsi_exec_task_mgmt_fn(conn, hdr, session->age, |
1709 | session->lu_reset_timeout)) { | 1711 | session->lu_reset_timeout)) { |
1710 | rc = FAILED; | 1712 | rc = FAILED; |
1711 | goto unlock; | 1713 | goto unlock; |
@@ -1886,7 +1888,7 @@ EXPORT_SYMBOL_GPL(iscsi_host_free); | |||
1886 | * @iscsit: iscsi transport template | 1888 | * @iscsit: iscsi transport template |
1887 | * @shost: scsi host | 1889 | * @shost: scsi host |
1888 | * @cmds_max: session can queue | 1890 | * @cmds_max: session can queue |
1889 | * @cmd_ctask_size: LLD ctask private data size | 1891 | * @cmd_task_size: LLD task private data size |
1890 | * @initial_cmdsn: initial CmdSN | 1892 | * @initial_cmdsn: initial CmdSN |
1891 | * | 1893 | * |
1892 | * This can be used by software iscsi_transports that allocate | 1894 | * This can be used by software iscsi_transports that allocate |
@@ -1894,7 +1896,7 @@ EXPORT_SYMBOL_GPL(iscsi_host_free); | |||
1894 | */ | 1896 | */ |
1895 | struct iscsi_cls_session * | 1897 | struct iscsi_cls_session * |
1896 | iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost, | 1898 | iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost, |
1897 | uint16_t scsi_cmds_max, int cmd_ctask_size, | 1899 | uint16_t scsi_cmds_max, int cmd_task_size, |
1898 | uint32_t initial_cmdsn) | 1900 | uint32_t initial_cmdsn) |
1899 | { | 1901 | { |
1900 | struct iscsi_session *session; | 1902 | struct iscsi_session *session; |
@@ -1902,7 +1904,7 @@ iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost, | |||
1902 | int cmd_i, cmds_max; | 1904 | int cmd_i, cmds_max; |
1903 | 1905 | ||
1904 | /* | 1906 | /* |
1905 | * The iscsi layer needs some ctasks for nop handling and tmfs. | 1907 | * The iscsi layer needs some tasks for nop handling and tmfs. |
1906 | */ | 1908 | */ |
1907 | if (scsi_cmds_max < 1) | 1909 | if (scsi_cmds_max < 1) |
1908 | scsi_cmds_max = ISCSI_MGMT_CMDS_MAX; | 1910 | scsi_cmds_max = ISCSI_MGMT_CMDS_MAX; |
@@ -1939,17 +1941,17 @@ iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost, | |||
1939 | /* initialize SCSI PDU commands pool */ | 1941 | /* initialize SCSI PDU commands pool */ |
1940 | if (iscsi_pool_init(&session->cmdpool, session->cmds_max, | 1942 | if (iscsi_pool_init(&session->cmdpool, session->cmds_max, |
1941 | (void***)&session->cmds, | 1943 | (void***)&session->cmds, |
1942 | cmd_ctask_size + sizeof(struct iscsi_cmd_task))) | 1944 | cmd_task_size + sizeof(struct iscsi_task))) |
1943 | goto cmdpool_alloc_fail; | 1945 | goto cmdpool_alloc_fail; |
1944 | 1946 | ||
1945 | /* pre-format cmds pool with ITT */ | 1947 | /* pre-format cmds pool with ITT */ |
1946 | for (cmd_i = 0; cmd_i < session->cmds_max; cmd_i++) { | 1948 | for (cmd_i = 0; cmd_i < session->cmds_max; cmd_i++) { |
1947 | struct iscsi_cmd_task *ctask = session->cmds[cmd_i]; | 1949 | struct iscsi_task *task = session->cmds[cmd_i]; |
1948 | 1950 | ||
1949 | if (cmd_ctask_size) | 1951 | if (cmd_task_size) |
1950 | ctask->dd_data = &ctask[1]; | 1952 | task->dd_data = &task[1]; |
1951 | ctask->itt = cmd_i; | 1953 | task->itt = cmd_i; |
1952 | INIT_LIST_HEAD(&ctask->running); | 1954 | INIT_LIST_HEAD(&task->running); |
1953 | } | 1955 | } |
1954 | 1956 | ||
1955 | if (!try_module_get(iscsit->owner)) | 1957 | if (!try_module_get(iscsit->owner)) |
@@ -2035,30 +2037,30 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size, | |||
2035 | INIT_LIST_HEAD(&conn->requeue); | 2037 | INIT_LIST_HEAD(&conn->requeue); |
2036 | INIT_WORK(&conn->xmitwork, iscsi_xmitworker); | 2038 | INIT_WORK(&conn->xmitwork, iscsi_xmitworker); |
2037 | 2039 | ||
2038 | /* allocate login_ctask used for the login/text sequences */ | 2040 | /* allocate login_task used for the login/text sequences */ |
2039 | spin_lock_bh(&session->lock); | 2041 | spin_lock_bh(&session->lock); |
2040 | if (!__kfifo_get(session->cmdpool.queue, | 2042 | if (!__kfifo_get(session->cmdpool.queue, |
2041 | (void*)&conn->login_ctask, | 2043 | (void*)&conn->login_task, |
2042 | sizeof(void*))) { | 2044 | sizeof(void*))) { |
2043 | spin_unlock_bh(&session->lock); | 2045 | spin_unlock_bh(&session->lock); |
2044 | goto login_ctask_alloc_fail; | 2046 | goto login_task_alloc_fail; |
2045 | } | 2047 | } |
2046 | spin_unlock_bh(&session->lock); | 2048 | spin_unlock_bh(&session->lock); |
2047 | 2049 | ||
2048 | data = kmalloc(ISCSI_DEF_MAX_RECV_SEG_LEN, GFP_KERNEL); | 2050 | data = kmalloc(ISCSI_DEF_MAX_RECV_SEG_LEN, GFP_KERNEL); |
2049 | if (!data) | 2051 | if (!data) |
2050 | goto login_ctask_data_alloc_fail; | 2052 | goto login_task_data_alloc_fail; |
2051 | conn->login_ctask->data = conn->data = data; | 2053 | conn->login_task->data = conn->data = data; |
2052 | 2054 | ||
2053 | init_timer(&conn->tmf_timer); | 2055 | init_timer(&conn->tmf_timer); |
2054 | init_waitqueue_head(&conn->ehwait); | 2056 | init_waitqueue_head(&conn->ehwait); |
2055 | 2057 | ||
2056 | return cls_conn; | 2058 | return cls_conn; |
2057 | 2059 | ||
2058 | login_ctask_data_alloc_fail: | 2060 | login_task_data_alloc_fail: |
2059 | __kfifo_put(session->cmdpool.queue, (void*)&conn->login_ctask, | 2061 | __kfifo_put(session->cmdpool.queue, (void*)&conn->login_task, |
2060 | sizeof(void*)); | 2062 | sizeof(void*)); |
2061 | login_ctask_alloc_fail: | 2063 | login_task_alloc_fail: |
2062 | iscsi_destroy_conn(cls_conn); | 2064 | iscsi_destroy_conn(cls_conn); |
2063 | return NULL; | 2065 | return NULL; |
2064 | } | 2066 | } |
@@ -2118,7 +2120,7 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn) | |||
2118 | spin_lock_bh(&session->lock); | 2120 | spin_lock_bh(&session->lock); |
2119 | kfree(conn->data); | 2121 | kfree(conn->data); |
2120 | kfree(conn->persistent_address); | 2122 | kfree(conn->persistent_address); |
2121 | __kfifo_put(session->cmdpool.queue, (void*)&conn->login_ctask, | 2123 | __kfifo_put(session->cmdpool.queue, (void*)&conn->login_task, |
2122 | sizeof(void*)); | 2124 | sizeof(void*)); |
2123 | if (session->leadconn == conn) | 2125 | if (session->leadconn == conn) |
2124 | session->leadconn = NULL; | 2126 | session->leadconn = NULL; |
@@ -2199,23 +2201,23 @@ EXPORT_SYMBOL_GPL(iscsi_conn_start); | |||
2199 | static void | 2201 | static void |
2200 | flush_control_queues(struct iscsi_session *session, struct iscsi_conn *conn) | 2202 | flush_control_queues(struct iscsi_session *session, struct iscsi_conn *conn) |
2201 | { | 2203 | { |
2202 | struct iscsi_cmd_task *ctask, *tmp; | 2204 | struct iscsi_task *task, *tmp; |
2203 | 2205 | ||
2204 | /* handle pending */ | 2206 | /* handle pending */ |
2205 | list_for_each_entry_safe(ctask, tmp, &conn->mgmtqueue, running) { | 2207 | list_for_each_entry_safe(task, tmp, &conn->mgmtqueue, running) { |
2206 | debug_scsi("flushing pending mgmt ctask itt 0x%x\n", ctask->itt); | 2208 | debug_scsi("flushing pending mgmt task itt 0x%x\n", task->itt); |
2207 | /* release ref from prep ctask */ | 2209 | /* release ref from prep task */ |
2208 | __iscsi_put_ctask(ctask); | 2210 | __iscsi_put_task(task); |
2209 | } | 2211 | } |
2210 | 2212 | ||
2211 | /* handle running */ | 2213 | /* handle running */ |
2212 | list_for_each_entry_safe(ctask, tmp, &conn->mgmt_run_list, running) { | 2214 | list_for_each_entry_safe(task, tmp, &conn->mgmt_run_list, running) { |
2213 | debug_scsi("flushing running mgmt ctask itt 0x%x\n", ctask->itt); | 2215 | debug_scsi("flushing running mgmt task itt 0x%x\n", task->itt); |
2214 | /* release ref from prep ctask */ | 2216 | /* release ref from prep task */ |
2215 | __iscsi_put_ctask(ctask); | 2217 | __iscsi_put_task(task); |
2216 | } | 2218 | } |
2217 | 2219 | ||
2218 | conn->ctask = NULL; | 2220 | conn->task = NULL; |
2219 | } | 2221 | } |
2220 | 2222 | ||
2221 | static void iscsi_start_session_recovery(struct iscsi_session *session, | 2223 | static void iscsi_start_session_recovery(struct iscsi_session *session, |
@@ -2246,7 +2248,7 @@ static void iscsi_start_session_recovery(struct iscsi_session *session, | |||
2246 | 2248 | ||
2247 | /* | 2249 | /* |
2248 | * When this is called for the in_login state, we only want to clean | 2250 | * When this is called for the in_login state, we only want to clean |
2249 | * up the login ctask and connection. We do not need to block and set | 2251 | * up the login task and connection. We do not need to block and set |
2250 | * the recovery state again | 2252 | * the recovery state again |
2251 | */ | 2253 | */ |
2252 | if (flag == STOP_CONN_TERM) | 2254 | if (flag == STOP_CONN_TERM) |