diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-18 18:59:18 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-18 18:59:18 -0500 |
commit | 4ba3069fea9f0771dad3f4906b305ab50d5a1b30 (patch) | |
tree | 3f75f2c0a320a6f38538c5e63f46ef79b0b3f1d1 /drivers | |
parent | 507a03c1cba0e32309223d23d19a1bfc0916c140 (diff) | |
parent | 895f3022523361e9b383cf48f51feb1f7d5e7e53 (diff) |
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending
* 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: (26 commits)
target: Set additional sense length field in sense data
target: Remove legacy device status check from transport_execute_tasks
target: Remove __transport_execute_tasks() for each processing context
target: Remove extra se_device->execute_task_lock access in fast path
target: Drop se_device TCQ queue_depth usage from I/O path
target: Fix possible NULL pointer with __transport_execute_tasks
target: Remove TFO->check_release_cmd() fabric API caller
tcm_fc: Convert ft_send_work to use target_submit_cmd
target: Add target_submit_cmd() for process context fabric submission
target: Make target_put_sess_cmd use target_release_cmd_kref
target: Set response format in INQUIRY response
target: tcm_mod_builder: small fixups
Documentation/target: Fix tcm_mod_builder.py build breakage
target: remove overagressive ____cacheline_aligned annoations
tcm_loop: bump max_sectors
target/configs: remove trailing newline from udev_path and alias
iscsi-target: fix chap identifier simple_strtoul usage
target: remove useless casts
target: simplify target_check_cdb_and_preempt
target: Move core_scsi3_check_cdb_abort_and_preempt
...
Diffstat (limited to 'drivers')
42 files changed, 529 insertions, 478 deletions
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 8599545cdf9e..ac44af165b27 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c | |||
@@ -27,8 +27,7 @@ | |||
27 | #include <scsi/scsi_device.h> | 27 | #include <scsi/scsi_device.h> |
28 | #include <scsi/iscsi_proto.h> | 28 | #include <scsi/iscsi_proto.h> |
29 | #include <target/target_core_base.h> | 29 | #include <target/target_core_base.h> |
30 | #include <target/target_core_tmr.h> | 30 | #include <target/target_core_fabric.h> |
31 | #include <target/target_core_transport.h> | ||
32 | 31 | ||
33 | #include "iscsi_target_core.h" | 32 | #include "iscsi_target_core.h" |
34 | #include "iscsi_target_parameters.h" | 33 | #include "iscsi_target_parameters.h" |
@@ -284,8 +283,8 @@ static struct iscsi_np *iscsit_get_np( | |||
284 | sock_in6 = (struct sockaddr_in6 *)sockaddr; | 283 | sock_in6 = (struct sockaddr_in6 *)sockaddr; |
285 | sock_in6_e = (struct sockaddr_in6 *)&np->np_sockaddr; | 284 | sock_in6_e = (struct sockaddr_in6 *)&np->np_sockaddr; |
286 | 285 | ||
287 | if (!memcmp((void *)&sock_in6->sin6_addr.in6_u, | 286 | if (!memcmp(&sock_in6->sin6_addr.in6_u, |
288 | (void *)&sock_in6_e->sin6_addr.in6_u, | 287 | &sock_in6_e->sin6_addr.in6_u, |
289 | sizeof(struct in6_addr))) | 288 | sizeof(struct in6_addr))) |
290 | ip_match = 1; | 289 | ip_match = 1; |
291 | 290 | ||
@@ -1225,7 +1224,7 @@ static void iscsit_do_crypto_hash_buf( | |||
1225 | 1224 | ||
1226 | crypto_hash_init(hash); | 1225 | crypto_hash_init(hash); |
1227 | 1226 | ||
1228 | sg_init_one(&sg, (u8 *)buf, payload_length); | 1227 | sg_init_one(&sg, buf, payload_length); |
1229 | crypto_hash_update(hash, &sg, payload_length); | 1228 | crypto_hash_update(hash, &sg, payload_length); |
1230 | 1229 | ||
1231 | if (padding) { | 1230 | if (padding) { |
@@ -1603,7 +1602,7 @@ static int iscsit_handle_nop_out( | |||
1603 | /* | 1602 | /* |
1604 | * Attach ping data to struct iscsi_cmd->buf_ptr. | 1603 | * Attach ping data to struct iscsi_cmd->buf_ptr. |
1605 | */ | 1604 | */ |
1606 | cmd->buf_ptr = (void *)ping_data; | 1605 | cmd->buf_ptr = ping_data; |
1607 | cmd->buf_ptr_size = payload_length; | 1606 | cmd->buf_ptr_size = payload_length; |
1608 | 1607 | ||
1609 | pr_debug("Got %u bytes of NOPOUT ping" | 1608 | pr_debug("Got %u bytes of NOPOUT ping" |
@@ -3197,7 +3196,7 @@ static int iscsit_build_sendtargets_response(struct iscsi_cmd *cmd) | |||
3197 | end_of_buf = 1; | 3196 | end_of_buf = 1; |
3198 | goto eob; | 3197 | goto eob; |
3199 | } | 3198 | } |
3200 | memcpy((void *)payload + payload_len, buf, len); | 3199 | memcpy(payload + payload_len, buf, len); |
3201 | payload_len += len; | 3200 | payload_len += len; |
3202 | 3201 | ||
3203 | spin_lock(&tiqn->tiqn_tpg_lock); | 3202 | spin_lock(&tiqn->tiqn_tpg_lock); |
@@ -3229,7 +3228,7 @@ static int iscsit_build_sendtargets_response(struct iscsi_cmd *cmd) | |||
3229 | end_of_buf = 1; | 3228 | end_of_buf = 1; |
3230 | goto eob; | 3229 | goto eob; |
3231 | } | 3230 | } |
3232 | memcpy((void *)payload + payload_len, buf, len); | 3231 | memcpy(payload + payload_len, buf, len); |
3233 | payload_len += len; | 3232 | payload_len += len; |
3234 | } | 3233 | } |
3235 | spin_unlock(&tpg->tpg_np_lock); | 3234 | spin_unlock(&tpg->tpg_np_lock); |
@@ -3486,7 +3485,7 @@ int iscsi_target_tx_thread(void *arg) | |||
3486 | struct iscsi_conn *conn; | 3485 | struct iscsi_conn *conn; |
3487 | struct iscsi_queue_req *qr = NULL; | 3486 | struct iscsi_queue_req *qr = NULL; |
3488 | struct se_cmd *se_cmd; | 3487 | struct se_cmd *se_cmd; |
3489 | struct iscsi_thread_set *ts = (struct iscsi_thread_set *)arg; | 3488 | struct iscsi_thread_set *ts = arg; |
3490 | /* | 3489 | /* |
3491 | * Allow ourselves to be interrupted by SIGINT so that a | 3490 | * Allow ourselves to be interrupted by SIGINT so that a |
3492 | * connection recovery / failure event can be triggered externally. | 3491 | * connection recovery / failure event can be triggered externally. |
@@ -3775,7 +3774,7 @@ int iscsi_target_rx_thread(void *arg) | |||
3775 | u8 buffer[ISCSI_HDR_LEN], opcode; | 3774 | u8 buffer[ISCSI_HDR_LEN], opcode; |
3776 | u32 checksum = 0, digest = 0; | 3775 | u32 checksum = 0, digest = 0; |
3777 | struct iscsi_conn *conn = NULL; | 3776 | struct iscsi_conn *conn = NULL; |
3778 | struct iscsi_thread_set *ts = (struct iscsi_thread_set *)arg; | 3777 | struct iscsi_thread_set *ts = arg; |
3779 | struct kvec iov; | 3778 | struct kvec iov; |
3780 | /* | 3779 | /* |
3781 | * Allow ourselves to be interrupted by SIGINT so that a | 3780 | * Allow ourselves to be interrupted by SIGINT so that a |
diff --git a/drivers/target/iscsi/iscsi_target_auth.c b/drivers/target/iscsi/iscsi_target_auth.c index 1cd6ce373b83..db0cf7c8adde 100644 --- a/drivers/target/iscsi/iscsi_target_auth.c +++ b/drivers/target/iscsi/iscsi_target_auth.c | |||
@@ -82,7 +82,7 @@ static void chap_gen_challenge( | |||
82 | unsigned int *c_len) | 82 | unsigned int *c_len) |
83 | { | 83 | { |
84 | unsigned char challenge_asciihex[CHAP_CHALLENGE_LENGTH * 2 + 1]; | 84 | unsigned char challenge_asciihex[CHAP_CHALLENGE_LENGTH * 2 + 1]; |
85 | struct iscsi_chap *chap = (struct iscsi_chap *) conn->auth_protocol; | 85 | struct iscsi_chap *chap = conn->auth_protocol; |
86 | 86 | ||
87 | memset(challenge_asciihex, 0, CHAP_CHALLENGE_LENGTH * 2 + 1); | 87 | memset(challenge_asciihex, 0, CHAP_CHALLENGE_LENGTH * 2 + 1); |
88 | 88 | ||
@@ -120,7 +120,7 @@ static struct iscsi_chap *chap_server_open( | |||
120 | if (!conn->auth_protocol) | 120 | if (!conn->auth_protocol) |
121 | return NULL; | 121 | return NULL; |
122 | 122 | ||
123 | chap = (struct iscsi_chap *) conn->auth_protocol; | 123 | chap = conn->auth_protocol; |
124 | /* | 124 | /* |
125 | * We only support MD5 MDA presently. | 125 | * We only support MD5 MDA presently. |
126 | */ | 126 | */ |
@@ -165,14 +165,15 @@ static int chap_server_compute_md5( | |||
165 | unsigned int *nr_out_len) | 165 | unsigned int *nr_out_len) |
166 | { | 166 | { |
167 | char *endptr; | 167 | char *endptr; |
168 | unsigned char id, digest[MD5_SIGNATURE_SIZE]; | 168 | unsigned long id; |
169 | unsigned char digest[MD5_SIGNATURE_SIZE]; | ||
169 | unsigned char type, response[MD5_SIGNATURE_SIZE * 2 + 2]; | 170 | unsigned char type, response[MD5_SIGNATURE_SIZE * 2 + 2]; |
170 | unsigned char identifier[10], *challenge = NULL; | 171 | unsigned char identifier[10], *challenge = NULL; |
171 | unsigned char *challenge_binhex = NULL; | 172 | unsigned char *challenge_binhex = NULL; |
172 | unsigned char client_digest[MD5_SIGNATURE_SIZE]; | 173 | unsigned char client_digest[MD5_SIGNATURE_SIZE]; |
173 | unsigned char server_digest[MD5_SIGNATURE_SIZE]; | 174 | unsigned char server_digest[MD5_SIGNATURE_SIZE]; |
174 | unsigned char chap_n[MAX_CHAP_N_SIZE], chap_r[MAX_RESPONSE_LENGTH]; | 175 | unsigned char chap_n[MAX_CHAP_N_SIZE], chap_r[MAX_RESPONSE_LENGTH]; |
175 | struct iscsi_chap *chap = (struct iscsi_chap *) conn->auth_protocol; | 176 | struct iscsi_chap *chap = conn->auth_protocol; |
176 | struct crypto_hash *tfm; | 177 | struct crypto_hash *tfm; |
177 | struct hash_desc desc; | 178 | struct hash_desc desc; |
178 | struct scatterlist sg; | 179 | struct scatterlist sg; |
@@ -246,7 +247,7 @@ static int chap_server_compute_md5( | |||
246 | goto out; | 247 | goto out; |
247 | } | 248 | } |
248 | 249 | ||
249 | sg_init_one(&sg, (void *)&chap->id, 1); | 250 | sg_init_one(&sg, &chap->id, 1); |
250 | ret = crypto_hash_update(&desc, &sg, 1); | 251 | ret = crypto_hash_update(&desc, &sg, 1); |
251 | if (ret < 0) { | 252 | if (ret < 0) { |
252 | pr_err("crypto_hash_update() failed for id\n"); | 253 | pr_err("crypto_hash_update() failed for id\n"); |
@@ -254,7 +255,7 @@ static int chap_server_compute_md5( | |||
254 | goto out; | 255 | goto out; |
255 | } | 256 | } |
256 | 257 | ||
257 | sg_init_one(&sg, (void *)&auth->password, strlen(auth->password)); | 258 | sg_init_one(&sg, &auth->password, strlen(auth->password)); |
258 | ret = crypto_hash_update(&desc, &sg, strlen(auth->password)); | 259 | ret = crypto_hash_update(&desc, &sg, strlen(auth->password)); |
259 | if (ret < 0) { | 260 | if (ret < 0) { |
260 | pr_err("crypto_hash_update() failed for password\n"); | 261 | pr_err("crypto_hash_update() failed for password\n"); |
@@ -262,7 +263,7 @@ static int chap_server_compute_md5( | |||
262 | goto out; | 263 | goto out; |
263 | } | 264 | } |
264 | 265 | ||
265 | sg_init_one(&sg, (void *)chap->challenge, CHAP_CHALLENGE_LENGTH); | 266 | sg_init_one(&sg, chap->challenge, CHAP_CHALLENGE_LENGTH); |
266 | ret = crypto_hash_update(&desc, &sg, CHAP_CHALLENGE_LENGTH); | 267 | ret = crypto_hash_update(&desc, &sg, CHAP_CHALLENGE_LENGTH); |
267 | if (ret < 0) { | 268 | if (ret < 0) { |
268 | pr_err("crypto_hash_update() failed for challenge\n"); | 269 | pr_err("crypto_hash_update() failed for challenge\n"); |
@@ -305,14 +306,17 @@ static int chap_server_compute_md5( | |||
305 | } | 306 | } |
306 | 307 | ||
307 | if (type == HEX) | 308 | if (type == HEX) |
308 | id = (unsigned char)simple_strtoul((char *)&identifier[2], | 309 | id = simple_strtoul(&identifier[2], &endptr, 0); |
309 | &endptr, 0); | ||
310 | else | 310 | else |
311 | id = (unsigned char)simple_strtoul(identifier, &endptr, 0); | 311 | id = simple_strtoul(identifier, &endptr, 0); |
312 | if (id > 255) { | ||
313 | pr_err("chap identifier: %lu greater than 255\n", id); | ||
314 | goto out; | ||
315 | } | ||
312 | /* | 316 | /* |
313 | * RFC 1994 says Identifier is no more than octet (8 bits). | 317 | * RFC 1994 says Identifier is no more than octet (8 bits). |
314 | */ | 318 | */ |
315 | pr_debug("[server] Got CHAP_I=%d\n", id); | 319 | pr_debug("[server] Got CHAP_I=%lu\n", id); |
316 | /* | 320 | /* |
317 | * Get CHAP_C. | 321 | * Get CHAP_C. |
318 | */ | 322 | */ |
@@ -351,7 +355,7 @@ static int chap_server_compute_md5( | |||
351 | goto out; | 355 | goto out; |
352 | } | 356 | } |
353 | 357 | ||
354 | sg_init_one(&sg, (void *)&id, 1); | 358 | sg_init_one(&sg, &id, 1); |
355 | ret = crypto_hash_update(&desc, &sg, 1); | 359 | ret = crypto_hash_update(&desc, &sg, 1); |
356 | if (ret < 0) { | 360 | if (ret < 0) { |
357 | pr_err("crypto_hash_update() failed for id\n"); | 361 | pr_err("crypto_hash_update() failed for id\n"); |
@@ -359,7 +363,7 @@ static int chap_server_compute_md5( | |||
359 | goto out; | 363 | goto out; |
360 | } | 364 | } |
361 | 365 | ||
362 | sg_init_one(&sg, (void *)auth->password_mutual, | 366 | sg_init_one(&sg, auth->password_mutual, |
363 | strlen(auth->password_mutual)); | 367 | strlen(auth->password_mutual)); |
364 | ret = crypto_hash_update(&desc, &sg, strlen(auth->password_mutual)); | 368 | ret = crypto_hash_update(&desc, &sg, strlen(auth->password_mutual)); |
365 | if (ret < 0) { | 369 | if (ret < 0) { |
@@ -371,7 +375,7 @@ static int chap_server_compute_md5( | |||
371 | /* | 375 | /* |
372 | * Convert received challenge to binary hex. | 376 | * Convert received challenge to binary hex. |
373 | */ | 377 | */ |
374 | sg_init_one(&sg, (void *)challenge_binhex, challenge_len); | 378 | sg_init_one(&sg, challenge_binhex, challenge_len); |
375 | ret = crypto_hash_update(&desc, &sg, challenge_len); | 379 | ret = crypto_hash_update(&desc, &sg, challenge_len); |
376 | if (ret < 0) { | 380 | if (ret < 0) { |
377 | pr_err("crypto_hash_update() failed for ma challenge\n"); | 381 | pr_err("crypto_hash_update() failed for ma challenge\n"); |
@@ -414,7 +418,7 @@ static int chap_got_response( | |||
414 | char *nr_out_ptr, | 418 | char *nr_out_ptr, |
415 | unsigned int *nr_out_len) | 419 | unsigned int *nr_out_len) |
416 | { | 420 | { |
417 | struct iscsi_chap *chap = (struct iscsi_chap *) conn->auth_protocol; | 421 | struct iscsi_chap *chap = conn->auth_protocol; |
418 | 422 | ||
419 | switch (chap->digest_type) { | 423 | switch (chap->digest_type) { |
420 | case CHAP_DIGEST_MD5: | 424 | case CHAP_DIGEST_MD5: |
@@ -437,7 +441,7 @@ u32 chap_main_loop( | |||
437 | int *in_len, | 441 | int *in_len, |
438 | int *out_len) | 442 | int *out_len) |
439 | { | 443 | { |
440 | struct iscsi_chap *chap = (struct iscsi_chap *) conn->auth_protocol; | 444 | struct iscsi_chap *chap = conn->auth_protocol; |
441 | 445 | ||
442 | if (!chap) { | 446 | if (!chap) { |
443 | chap = chap_server_open(conn, auth, in_text, out_text, out_len); | 447 | chap = chap_server_open(conn, auth, in_text, out_text, out_len); |
diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c index db327845e46b..3468caab47a2 100644 --- a/drivers/target/iscsi/iscsi_target_configfs.c +++ b/drivers/target/iscsi/iscsi_target_configfs.c | |||
@@ -22,12 +22,8 @@ | |||
22 | #include <linux/configfs.h> | 22 | #include <linux/configfs.h> |
23 | #include <linux/export.h> | 23 | #include <linux/export.h> |
24 | #include <target/target_core_base.h> | 24 | #include <target/target_core_base.h> |
25 | #include <target/target_core_transport.h> | 25 | #include <target/target_core_fabric.h> |
26 | #include <target/target_core_fabric_ops.h> | ||
27 | #include <target/target_core_fabric_configfs.h> | 26 | #include <target/target_core_fabric_configfs.h> |
28 | #include <target/target_core_fabric_lib.h> | ||
29 | #include <target/target_core_device.h> | ||
30 | #include <target/target_core_tpg.h> | ||
31 | #include <target/target_core_configfs.h> | 27 | #include <target/target_core_configfs.h> |
32 | #include <target/configfs_macros.h> | 28 | #include <target/configfs_macros.h> |
33 | 29 | ||
@@ -56,8 +52,7 @@ struct iscsi_portal_group *lio_get_tpg_from_tpg_item( | |||
56 | { | 52 | { |
57 | struct se_portal_group *se_tpg = container_of(to_config_group(item), | 53 | struct se_portal_group *se_tpg = container_of(to_config_group(item), |
58 | struct se_portal_group, tpg_group); | 54 | struct se_portal_group, tpg_group); |
59 | struct iscsi_portal_group *tpg = | 55 | struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr; |
60 | (struct iscsi_portal_group *)se_tpg->se_tpg_fabric_ptr; | ||
61 | int ret; | 56 | int ret; |
62 | 57 | ||
63 | if (!tpg) { | 58 | if (!tpg) { |
@@ -1225,7 +1220,7 @@ struct se_portal_group *lio_target_tiqn_addtpg( | |||
1225 | 1220 | ||
1226 | ret = core_tpg_register( | 1221 | ret = core_tpg_register( |
1227 | &lio_target_fabric_configfs->tf_ops, | 1222 | &lio_target_fabric_configfs->tf_ops, |
1228 | wwn, &tpg->tpg_se_tpg, (void *)tpg, | 1223 | wwn, &tpg->tpg_se_tpg, tpg, |
1229 | TRANSPORT_TPG_TYPE_NORMAL); | 1224 | TRANSPORT_TPG_TYPE_NORMAL); |
1230 | if (ret < 0) | 1225 | if (ret < 0) |
1231 | return NULL; | 1226 | return NULL; |
diff --git a/drivers/target/iscsi/iscsi_target_device.c b/drivers/target/iscsi/iscsi_target_device.c index a19fa5eea88e..f63ea35bc4ae 100644 --- a/drivers/target/iscsi/iscsi_target_device.c +++ b/drivers/target/iscsi/iscsi_target_device.c | |||
@@ -21,8 +21,7 @@ | |||
21 | 21 | ||
22 | #include <scsi/scsi_device.h> | 22 | #include <scsi/scsi_device.h> |
23 | #include <target/target_core_base.h> | 23 | #include <target/target_core_base.h> |
24 | #include <target/target_core_device.h> | 24 | #include <target/target_core_fabric.h> |
25 | #include <target/target_core_transport.h> | ||
26 | 25 | ||
27 | #include "iscsi_target_core.h" | 26 | #include "iscsi_target_core.h" |
28 | #include "iscsi_target_device.h" | 27 | #include "iscsi_target_device.h" |
diff --git a/drivers/target/iscsi/iscsi_target_erl0.c b/drivers/target/iscsi/iscsi_target_erl0.c index b7ffc3cd40cc..478451167b62 100644 --- a/drivers/target/iscsi/iscsi_target_erl0.c +++ b/drivers/target/iscsi/iscsi_target_erl0.c | |||
@@ -21,7 +21,7 @@ | |||
21 | 21 | ||
22 | #include <scsi/iscsi_proto.h> | 22 | #include <scsi/iscsi_proto.h> |
23 | #include <target/target_core_base.h> | 23 | #include <target/target_core_base.h> |
24 | #include <target/target_core_transport.h> | 24 | #include <target/target_core_fabric.h> |
25 | 25 | ||
26 | #include "iscsi_target_core.h" | 26 | #include "iscsi_target_core.h" |
27 | #include "iscsi_target_seq_pdu_list.h" | 27 | #include "iscsi_target_seq_pdu_list.h" |
diff --git a/drivers/target/iscsi/iscsi_target_erl1.c b/drivers/target/iscsi/iscsi_target_erl1.c index 101b1beb3bca..255c0d67e898 100644 --- a/drivers/target/iscsi/iscsi_target_erl1.c +++ b/drivers/target/iscsi/iscsi_target_erl1.c | |||
@@ -21,7 +21,7 @@ | |||
21 | #include <linux/list.h> | 21 | #include <linux/list.h> |
22 | #include <scsi/iscsi_proto.h> | 22 | #include <scsi/iscsi_proto.h> |
23 | #include <target/target_core_base.h> | 23 | #include <target/target_core_base.h> |
24 | #include <target/target_core_transport.h> | 24 | #include <target/target_core_fabric.h> |
25 | 25 | ||
26 | #include "iscsi_target_core.h" | 26 | #include "iscsi_target_core.h" |
27 | #include "iscsi_target_seq_pdu_list.h" | 27 | #include "iscsi_target_seq_pdu_list.h" |
diff --git a/drivers/target/iscsi/iscsi_target_erl2.c b/drivers/target/iscsi/iscsi_target_erl2.c index 0b8404c30125..1af1f21af21f 100644 --- a/drivers/target/iscsi/iscsi_target_erl2.c +++ b/drivers/target/iscsi/iscsi_target_erl2.c | |||
@@ -21,7 +21,7 @@ | |||
21 | 21 | ||
22 | #include <scsi/iscsi_proto.h> | 22 | #include <scsi/iscsi_proto.h> |
23 | #include <target/target_core_base.h> | 23 | #include <target/target_core_base.h> |
24 | #include <target/target_core_transport.h> | 24 | #include <target/target_core_fabric.h> |
25 | 25 | ||
26 | #include "iscsi_target_core.h" | 26 | #include "iscsi_target_core.h" |
27 | #include "iscsi_target_datain_values.h" | 27 | #include "iscsi_target_datain_values.h" |
diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c index d734bdec24f9..373b0cc6abd8 100644 --- a/drivers/target/iscsi/iscsi_target_login.c +++ b/drivers/target/iscsi/iscsi_target_login.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #include <linux/crypto.h> | 23 | #include <linux/crypto.h> |
24 | #include <scsi/iscsi_proto.h> | 24 | #include <scsi/iscsi_proto.h> |
25 | #include <target/target_core_base.h> | 25 | #include <target/target_core_base.h> |
26 | #include <target/target_core_transport.h> | 26 | #include <target/target_core_fabric.h> |
27 | 27 | ||
28 | #include "iscsi_target_core.h" | 28 | #include "iscsi_target_core.h" |
29 | #include "iscsi_target_tq.h" | 29 | #include "iscsi_target_tq.h" |
@@ -143,7 +143,7 @@ int iscsi_check_for_session_reinstatement(struct iscsi_conn *conn) | |||
143 | list_for_each_entry_safe(se_sess, se_sess_tmp, &se_tpg->tpg_sess_list, | 143 | list_for_each_entry_safe(se_sess, se_sess_tmp, &se_tpg->tpg_sess_list, |
144 | sess_list) { | 144 | sess_list) { |
145 | 145 | ||
146 | sess_p = (struct iscsi_session *)se_sess->fabric_sess_ptr; | 146 | sess_p = se_sess->fabric_sess_ptr; |
147 | spin_lock(&sess_p->conn_lock); | 147 | spin_lock(&sess_p->conn_lock); |
148 | if (atomic_read(&sess_p->session_fall_back_to_erl0) || | 148 | if (atomic_read(&sess_p->session_fall_back_to_erl0) || |
149 | atomic_read(&sess_p->session_logout) || | 149 | atomic_read(&sess_p->session_logout) || |
@@ -151,9 +151,9 @@ int iscsi_check_for_session_reinstatement(struct iscsi_conn *conn) | |||
151 | spin_unlock(&sess_p->conn_lock); | 151 | spin_unlock(&sess_p->conn_lock); |
152 | continue; | 152 | continue; |
153 | } | 153 | } |
154 | if (!memcmp((void *)sess_p->isid, (void *)conn->sess->isid, 6) && | 154 | if (!memcmp(sess_p->isid, conn->sess->isid, 6) && |
155 | (!strcmp((void *)sess_p->sess_ops->InitiatorName, | 155 | (!strcmp(sess_p->sess_ops->InitiatorName, |
156 | (void *)initiatorname_param->value) && | 156 | initiatorname_param->value) && |
157 | (sess_p->sess_ops->SessionType == sessiontype))) { | 157 | (sess_p->sess_ops->SessionType == sessiontype))) { |
158 | atomic_set(&sess_p->session_reinstatement, 1); | 158 | atomic_set(&sess_p->session_reinstatement, 1); |
159 | spin_unlock(&sess_p->conn_lock); | 159 | spin_unlock(&sess_p->conn_lock); |
@@ -229,7 +229,7 @@ static int iscsi_login_zero_tsih_s1( | |||
229 | 229 | ||
230 | iscsi_login_set_conn_values(sess, conn, pdu->cid); | 230 | iscsi_login_set_conn_values(sess, conn, pdu->cid); |
231 | sess->init_task_tag = pdu->itt; | 231 | sess->init_task_tag = pdu->itt; |
232 | memcpy((void *)&sess->isid, (void *)pdu->isid, 6); | 232 | memcpy(&sess->isid, pdu->isid, 6); |
233 | sess->exp_cmd_sn = pdu->cmdsn; | 233 | sess->exp_cmd_sn = pdu->cmdsn; |
234 | INIT_LIST_HEAD(&sess->sess_conn_list); | 234 | INIT_LIST_HEAD(&sess->sess_conn_list); |
235 | INIT_LIST_HEAD(&sess->sess_ooo_cmdsn_list); | 235 | INIT_LIST_HEAD(&sess->sess_ooo_cmdsn_list); |
@@ -440,8 +440,7 @@ static int iscsi_login_non_zero_tsih_s2( | |||
440 | atomic_read(&sess_p->session_logout) || | 440 | atomic_read(&sess_p->session_logout) || |
441 | (sess_p->time2retain_timer_flags & ISCSI_TF_EXPIRED)) | 441 | (sess_p->time2retain_timer_flags & ISCSI_TF_EXPIRED)) |
442 | continue; | 442 | continue; |
443 | if (!memcmp((const void *)sess_p->isid, | 443 | if (!memcmp(sess_p->isid, pdu->isid, 6) && |
444 | (const void *)pdu->isid, 6) && | ||
445 | (sess_p->tsih == pdu->tsih)) { | 444 | (sess_p->tsih == pdu->tsih)) { |
446 | iscsit_inc_session_usage_count(sess_p); | 445 | iscsit_inc_session_usage_count(sess_p); |
447 | iscsit_stop_time2retain_timer(sess_p); | 446 | iscsit_stop_time2retain_timer(sess_p); |
@@ -654,7 +653,7 @@ static int iscsi_post_login_handler( | |||
654 | 653 | ||
655 | spin_lock_bh(&se_tpg->session_lock); | 654 | spin_lock_bh(&se_tpg->session_lock); |
656 | __transport_register_session(&sess->tpg->tpg_se_tpg, | 655 | __transport_register_session(&sess->tpg->tpg_se_tpg, |
657 | se_sess->se_node_acl, se_sess, (void *)sess); | 656 | se_sess->se_node_acl, se_sess, sess); |
658 | pr_debug("Moving to TARG_SESS_STATE_LOGGED_IN.\n"); | 657 | pr_debug("Moving to TARG_SESS_STATE_LOGGED_IN.\n"); |
659 | sess->session_state = TARG_SESS_STATE_LOGGED_IN; | 658 | sess->session_state = TARG_SESS_STATE_LOGGED_IN; |
660 | 659 | ||
@@ -811,7 +810,7 @@ int iscsi_target_setup_login_socket( | |||
811 | * Setup the np->np_sockaddr from the passed sockaddr setup | 810 | * Setup the np->np_sockaddr from the passed sockaddr setup |
812 | * in iscsi_target_configfs.c code.. | 811 | * in iscsi_target_configfs.c code.. |
813 | */ | 812 | */ |
814 | memcpy((void *)&np->np_sockaddr, (void *)sockaddr, | 813 | memcpy(&np->np_sockaddr, sockaddr, |
815 | sizeof(struct __kernel_sockaddr_storage)); | 814 | sizeof(struct __kernel_sockaddr_storage)); |
816 | 815 | ||
817 | if (sockaddr->ss_family == AF_INET6) | 816 | if (sockaddr->ss_family == AF_INET6) |
@@ -821,6 +820,7 @@ int iscsi_target_setup_login_socket( | |||
821 | /* | 820 | /* |
822 | * Set SO_REUSEADDR, and disable Nagel Algorithm with TCP_NODELAY. | 821 | * Set SO_REUSEADDR, and disable Nagel Algorithm with TCP_NODELAY. |
823 | */ | 822 | */ |
823 | /* FIXME: Someone please explain why this is endian-safe */ | ||
824 | opt = 1; | 824 | opt = 1; |
825 | if (np->np_network_transport == ISCSI_TCP) { | 825 | if (np->np_network_transport == ISCSI_TCP) { |
826 | ret = kernel_setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, | 826 | ret = kernel_setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, |
@@ -832,6 +832,7 @@ int iscsi_target_setup_login_socket( | |||
832 | } | 832 | } |
833 | } | 833 | } |
834 | 834 | ||
835 | /* FIXME: Someone please explain why this is endian-safe */ | ||
835 | ret = kernel_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, | 836 | ret = kernel_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, |
836 | (char *)&opt, sizeof(opt)); | 837 | (char *)&opt, sizeof(opt)); |
837 | if (ret < 0) { | 838 | if (ret < 0) { |
@@ -1206,7 +1207,7 @@ out: | |||
1206 | 1207 | ||
1207 | int iscsi_target_login_thread(void *arg) | 1208 | int iscsi_target_login_thread(void *arg) |
1208 | { | 1209 | { |
1209 | struct iscsi_np *np = (struct iscsi_np *)arg; | 1210 | struct iscsi_np *np = arg; |
1210 | int ret; | 1211 | int ret; |
1211 | 1212 | ||
1212 | allow_signal(SIGINT); | 1213 | allow_signal(SIGINT); |
diff --git a/drivers/target/iscsi/iscsi_target_nego.c b/drivers/target/iscsi/iscsi_target_nego.c index 98936cb7c294..e89fa7457254 100644 --- a/drivers/target/iscsi/iscsi_target_nego.c +++ b/drivers/target/iscsi/iscsi_target_nego.c | |||
@@ -21,7 +21,7 @@ | |||
21 | #include <linux/ctype.h> | 21 | #include <linux/ctype.h> |
22 | #include <scsi/iscsi_proto.h> | 22 | #include <scsi/iscsi_proto.h> |
23 | #include <target/target_core_base.h> | 23 | #include <target/target_core_base.h> |
24 | #include <target/target_core_tpg.h> | 24 | #include <target/target_core_fabric.h> |
25 | 25 | ||
26 | #include "iscsi_target_core.h" | 26 | #include "iscsi_target_core.h" |
27 | #include "iscsi_target_parameters.h" | 27 | #include "iscsi_target_parameters.h" |
@@ -732,7 +732,7 @@ static void iscsi_initiatorname_tolower( | |||
732 | u32 iqn_size = strlen(param_buf), i; | 732 | u32 iqn_size = strlen(param_buf), i; |
733 | 733 | ||
734 | for (i = 0; i < iqn_size; i++) { | 734 | for (i = 0; i < iqn_size; i++) { |
735 | c = (char *)¶m_buf[i]; | 735 | c = ¶m_buf[i]; |
736 | if (!isupper(*c)) | 736 | if (!isupper(*c)) |
737 | continue; | 737 | continue; |
738 | 738 | ||
diff --git a/drivers/target/iscsi/iscsi_target_nodeattrib.c b/drivers/target/iscsi/iscsi_target_nodeattrib.c index aeafbe0cd7d1..b3c699c4fe8c 100644 --- a/drivers/target/iscsi/iscsi_target_nodeattrib.c +++ b/drivers/target/iscsi/iscsi_target_nodeattrib.c | |||
@@ -19,7 +19,6 @@ | |||
19 | ******************************************************************************/ | 19 | ******************************************************************************/ |
20 | 20 | ||
21 | #include <target/target_core_base.h> | 21 | #include <target/target_core_base.h> |
22 | #include <target/target_core_transport.h> | ||
23 | 22 | ||
24 | #include "iscsi_target_core.h" | 23 | #include "iscsi_target_core.h" |
25 | #include "iscsi_target_device.h" | 24 | #include "iscsi_target_device.h" |
@@ -135,7 +134,7 @@ extern int iscsit_na_nopin_timeout( | |||
135 | spin_lock_bh(&se_nacl->nacl_sess_lock); | 134 | spin_lock_bh(&se_nacl->nacl_sess_lock); |
136 | se_sess = se_nacl->nacl_sess; | 135 | se_sess = se_nacl->nacl_sess; |
137 | if (se_sess) { | 136 | if (se_sess) { |
138 | sess = (struct iscsi_session *)se_sess->fabric_sess_ptr; | 137 | sess = se_sess->fabric_sess_ptr; |
139 | 138 | ||
140 | spin_lock(&sess->conn_lock); | 139 | spin_lock(&sess->conn_lock); |
141 | list_for_each_entry(conn, &sess->sess_conn_list, | 140 | list_for_each_entry(conn, &sess->sess_conn_list, |
diff --git a/drivers/target/iscsi/iscsi_target_stat.c b/drivers/target/iscsi/iscsi_target_stat.c index f1db83077e0a..421d6947dc64 100644 --- a/drivers/target/iscsi/iscsi_target_stat.c +++ b/drivers/target/iscsi/iscsi_target_stat.c | |||
@@ -23,7 +23,6 @@ | |||
23 | #include <linux/export.h> | 23 | #include <linux/export.h> |
24 | #include <scsi/iscsi_proto.h> | 24 | #include <scsi/iscsi_proto.h> |
25 | #include <target/target_core_base.h> | 25 | #include <target/target_core_base.h> |
26 | #include <target/target_core_transport.h> | ||
27 | #include <target/configfs_macros.h> | 26 | #include <target/configfs_macros.h> |
28 | 27 | ||
29 | #include "iscsi_target_core.h" | 28 | #include "iscsi_target_core.h" |
@@ -746,7 +745,7 @@ static ssize_t iscsi_stat_sess_show_attr_node( | |||
746 | spin_lock_bh(&se_nacl->nacl_sess_lock); | 745 | spin_lock_bh(&se_nacl->nacl_sess_lock); |
747 | se_sess = se_nacl->nacl_sess; | 746 | se_sess = se_nacl->nacl_sess; |
748 | if (se_sess) { | 747 | if (se_sess) { |
749 | sess = (struct iscsi_session *)se_sess->fabric_sess_ptr; | 748 | sess = se_sess->fabric_sess_ptr; |
750 | if (sess) | 749 | if (sess) |
751 | ret = snprintf(page, PAGE_SIZE, "%u\n", | 750 | ret = snprintf(page, PAGE_SIZE, "%u\n", |
752 | sess->sess_ops->SessionType ? 0 : ISCSI_NODE_INDEX); | 751 | sess->sess_ops->SessionType ? 0 : ISCSI_NODE_INDEX); |
@@ -770,7 +769,7 @@ static ssize_t iscsi_stat_sess_show_attr_indx( | |||
770 | spin_lock_bh(&se_nacl->nacl_sess_lock); | 769 | spin_lock_bh(&se_nacl->nacl_sess_lock); |
771 | se_sess = se_nacl->nacl_sess; | 770 | se_sess = se_nacl->nacl_sess; |
772 | if (se_sess) { | 771 | if (se_sess) { |
773 | sess = (struct iscsi_session *)se_sess->fabric_sess_ptr; | 772 | sess = se_sess->fabric_sess_ptr; |
774 | if (sess) | 773 | if (sess) |
775 | ret = snprintf(page, PAGE_SIZE, "%u\n", | 774 | ret = snprintf(page, PAGE_SIZE, "%u\n", |
776 | sess->session_index); | 775 | sess->session_index); |
@@ -794,7 +793,7 @@ static ssize_t iscsi_stat_sess_show_attr_cmd_pdus( | |||
794 | spin_lock_bh(&se_nacl->nacl_sess_lock); | 793 | spin_lock_bh(&se_nacl->nacl_sess_lock); |
795 | se_sess = se_nacl->nacl_sess; | 794 | se_sess = se_nacl->nacl_sess; |
796 | if (se_sess) { | 795 | if (se_sess) { |
797 | sess = (struct iscsi_session *)se_sess->fabric_sess_ptr; | 796 | sess = se_sess->fabric_sess_ptr; |
798 | if (sess) | 797 | if (sess) |
799 | ret = snprintf(page, PAGE_SIZE, "%u\n", sess->cmd_pdus); | 798 | ret = snprintf(page, PAGE_SIZE, "%u\n", sess->cmd_pdus); |
800 | } | 799 | } |
@@ -817,7 +816,7 @@ static ssize_t iscsi_stat_sess_show_attr_rsp_pdus( | |||
817 | spin_lock_bh(&se_nacl->nacl_sess_lock); | 816 | spin_lock_bh(&se_nacl->nacl_sess_lock); |
818 | se_sess = se_nacl->nacl_sess; | 817 | se_sess = se_nacl->nacl_sess; |
819 | if (se_sess) { | 818 | if (se_sess) { |
820 | sess = (struct iscsi_session *)se_sess->fabric_sess_ptr; | 819 | sess = se_sess->fabric_sess_ptr; |
821 | if (sess) | 820 | if (sess) |
822 | ret = snprintf(page, PAGE_SIZE, "%u\n", sess->rsp_pdus); | 821 | ret = snprintf(page, PAGE_SIZE, "%u\n", sess->rsp_pdus); |
823 | } | 822 | } |
@@ -840,7 +839,7 @@ static ssize_t iscsi_stat_sess_show_attr_txdata_octs( | |||
840 | spin_lock_bh(&se_nacl->nacl_sess_lock); | 839 | spin_lock_bh(&se_nacl->nacl_sess_lock); |
841 | se_sess = se_nacl->nacl_sess; | 840 | se_sess = se_nacl->nacl_sess; |
842 | if (se_sess) { | 841 | if (se_sess) { |
843 | sess = (struct iscsi_session *)se_sess->fabric_sess_ptr; | 842 | sess = se_sess->fabric_sess_ptr; |
844 | if (sess) | 843 | if (sess) |
845 | ret = snprintf(page, PAGE_SIZE, "%llu\n", | 844 | ret = snprintf(page, PAGE_SIZE, "%llu\n", |
846 | (unsigned long long)sess->tx_data_octets); | 845 | (unsigned long long)sess->tx_data_octets); |
@@ -864,7 +863,7 @@ static ssize_t iscsi_stat_sess_show_attr_rxdata_octs( | |||
864 | spin_lock_bh(&se_nacl->nacl_sess_lock); | 863 | spin_lock_bh(&se_nacl->nacl_sess_lock); |
865 | se_sess = se_nacl->nacl_sess; | 864 | se_sess = se_nacl->nacl_sess; |
866 | if (se_sess) { | 865 | if (se_sess) { |
867 | sess = (struct iscsi_session *)se_sess->fabric_sess_ptr; | 866 | sess = se_sess->fabric_sess_ptr; |
868 | if (sess) | 867 | if (sess) |
869 | ret = snprintf(page, PAGE_SIZE, "%llu\n", | 868 | ret = snprintf(page, PAGE_SIZE, "%llu\n", |
870 | (unsigned long long)sess->rx_data_octets); | 869 | (unsigned long long)sess->rx_data_octets); |
@@ -888,7 +887,7 @@ static ssize_t iscsi_stat_sess_show_attr_conn_digest_errors( | |||
888 | spin_lock_bh(&se_nacl->nacl_sess_lock); | 887 | spin_lock_bh(&se_nacl->nacl_sess_lock); |
889 | se_sess = se_nacl->nacl_sess; | 888 | se_sess = se_nacl->nacl_sess; |
890 | if (se_sess) { | 889 | if (se_sess) { |
891 | sess = (struct iscsi_session *)se_sess->fabric_sess_ptr; | 890 | sess = se_sess->fabric_sess_ptr; |
892 | if (sess) | 891 | if (sess) |
893 | ret = snprintf(page, PAGE_SIZE, "%u\n", | 892 | ret = snprintf(page, PAGE_SIZE, "%u\n", |
894 | sess->conn_digest_errors); | 893 | sess->conn_digest_errors); |
@@ -912,7 +911,7 @@ static ssize_t iscsi_stat_sess_show_attr_conn_timeout_errors( | |||
912 | spin_lock_bh(&se_nacl->nacl_sess_lock); | 911 | spin_lock_bh(&se_nacl->nacl_sess_lock); |
913 | se_sess = se_nacl->nacl_sess; | 912 | se_sess = se_nacl->nacl_sess; |
914 | if (se_sess) { | 913 | if (se_sess) { |
915 | sess = (struct iscsi_session *)se_sess->fabric_sess_ptr; | 914 | sess = se_sess->fabric_sess_ptr; |
916 | if (sess) | 915 | if (sess) |
917 | ret = snprintf(page, PAGE_SIZE, "%u\n", | 916 | ret = snprintf(page, PAGE_SIZE, "%u\n", |
918 | sess->conn_timeout_errors); | 917 | sess->conn_timeout_errors); |
diff --git a/drivers/target/iscsi/iscsi_target_tmr.c b/drivers/target/iscsi/iscsi_target_tmr.c index 490207eacde9..255ed35da815 100644 --- a/drivers/target/iscsi/iscsi_target_tmr.c +++ b/drivers/target/iscsi/iscsi_target_tmr.c | |||
@@ -21,7 +21,7 @@ | |||
21 | #include <asm/unaligned.h> | 21 | #include <asm/unaligned.h> |
22 | #include <scsi/iscsi_proto.h> | 22 | #include <scsi/iscsi_proto.h> |
23 | #include <target/target_core_base.h> | 23 | #include <target/target_core_base.h> |
24 | #include <target/target_core_transport.h> | 24 | #include <target/target_core_fabric.h> |
25 | 25 | ||
26 | #include "iscsi_target_core.h" | 26 | #include "iscsi_target_core.h" |
27 | #include "iscsi_target_seq_pdu_list.h" | 27 | #include "iscsi_target_seq_pdu_list.h" |
diff --git a/drivers/target/iscsi/iscsi_target_tpg.c b/drivers/target/iscsi/iscsi_target_tpg.c index d4cf2cd25c44..879d8d0fa3fe 100644 --- a/drivers/target/iscsi/iscsi_target_tpg.c +++ b/drivers/target/iscsi/iscsi_target_tpg.c | |||
@@ -19,10 +19,8 @@ | |||
19 | ******************************************************************************/ | 19 | ******************************************************************************/ |
20 | 20 | ||
21 | #include <target/target_core_base.h> | 21 | #include <target/target_core_base.h> |
22 | #include <target/target_core_transport.h> | 22 | #include <target/target_core_fabric.h> |
23 | #include <target/target_core_fabric_ops.h> | ||
24 | #include <target/target_core_configfs.h> | 23 | #include <target/target_core_configfs.h> |
25 | #include <target/target_core_tpg.h> | ||
26 | 24 | ||
27 | #include "iscsi_target_core.h" | 25 | #include "iscsi_target_core.h" |
28 | #include "iscsi_target_erl0.h" | 26 | #include "iscsi_target_erl0.h" |
@@ -72,7 +70,7 @@ int iscsit_load_discovery_tpg(void) | |||
72 | 70 | ||
73 | ret = core_tpg_register( | 71 | ret = core_tpg_register( |
74 | &lio_target_fabric_configfs->tf_ops, | 72 | &lio_target_fabric_configfs->tf_ops, |
75 | NULL, &tpg->tpg_se_tpg, (void *)tpg, | 73 | NULL, &tpg->tpg_se_tpg, tpg, |
76 | TRANSPORT_TPG_TYPE_DISCOVERY); | 74 | TRANSPORT_TPG_TYPE_DISCOVERY); |
77 | if (ret < 0) { | 75 | if (ret < 0) { |
78 | kfree(tpg); | 76 | kfree(tpg); |
diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c index 02348f727bd4..a05ca1c4f01c 100644 --- a/drivers/target/iscsi/iscsi_target_util.c +++ b/drivers/target/iscsi/iscsi_target_util.c | |||
@@ -22,9 +22,7 @@ | |||
22 | #include <scsi/scsi_tcq.h> | 22 | #include <scsi/scsi_tcq.h> |
23 | #include <scsi/iscsi_proto.h> | 23 | #include <scsi/iscsi_proto.h> |
24 | #include <target/target_core_base.h> | 24 | #include <target/target_core_base.h> |
25 | #include <target/target_core_transport.h> | 25 | #include <target/target_core_fabric.h> |
26 | #include <target/target_core_tmr.h> | ||
27 | #include <target/target_core_fabric_ops.h> | ||
28 | #include <target/target_core_configfs.h> | 26 | #include <target/target_core_configfs.h> |
29 | 27 | ||
30 | #include "iscsi_target_core.h" | 28 | #include "iscsi_target_core.h" |
@@ -289,7 +287,7 @@ struct iscsi_cmd *iscsit_allocate_se_cmd_for_tmr( | |||
289 | } | 287 | } |
290 | 288 | ||
291 | se_cmd->se_tmr_req = core_tmr_alloc_req(se_cmd, | 289 | se_cmd->se_tmr_req = core_tmr_alloc_req(se_cmd, |
292 | (void *)cmd->tmr_req, tcm_function, | 290 | cmd->tmr_req, tcm_function, |
293 | GFP_KERNEL); | 291 | GFP_KERNEL); |
294 | if (!se_cmd->se_tmr_req) | 292 | if (!se_cmd->se_tmr_req) |
295 | goto out; | 293 | goto out; |
@@ -1066,7 +1064,7 @@ static void iscsit_handle_nopin_response_timeout(unsigned long data) | |||
1066 | if (tiqn) { | 1064 | if (tiqn) { |
1067 | spin_lock_bh(&tiqn->sess_err_stats.lock); | 1065 | spin_lock_bh(&tiqn->sess_err_stats.lock); |
1068 | strcpy(tiqn->sess_err_stats.last_sess_fail_rem_name, | 1066 | strcpy(tiqn->sess_err_stats.last_sess_fail_rem_name, |
1069 | (void *)conn->sess->sess_ops->InitiatorName); | 1067 | conn->sess->sess_ops->InitiatorName); |
1070 | tiqn->sess_err_stats.last_sess_failure_type = | 1068 | tiqn->sess_err_stats.last_sess_failure_type = |
1071 | ISCSI_SESS_ERR_CXN_TIMEOUT; | 1069 | ISCSI_SESS_ERR_CXN_TIMEOUT; |
1072 | tiqn->sess_err_stats.cxn_timeout_errors++; | 1070 | tiqn->sess_err_stats.cxn_timeout_errors++; |
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index 81d5832fbbd5..c47ff7f59e57 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c | |||
@@ -33,14 +33,9 @@ | |||
33 | #include <scsi/scsi_cmnd.h> | 33 | #include <scsi/scsi_cmnd.h> |
34 | 34 | ||
35 | #include <target/target_core_base.h> | 35 | #include <target/target_core_base.h> |
36 | #include <target/target_core_transport.h> | 36 | #include <target/target_core_fabric.h> |
37 | #include <target/target_core_fabric_ops.h> | ||
38 | #include <target/target_core_fabric_configfs.h> | 37 | #include <target/target_core_fabric_configfs.h> |
39 | #include <target/target_core_fabric_lib.h> | ||
40 | #include <target/target_core_configfs.h> | 38 | #include <target/target_core_configfs.h> |
41 | #include <target/target_core_device.h> | ||
42 | #include <target/target_core_tpg.h> | ||
43 | #include <target/target_core_tmr.h> | ||
44 | 39 | ||
45 | #include "tcm_loop.h" | 40 | #include "tcm_loop.h" |
46 | 41 | ||
@@ -421,11 +416,11 @@ static struct scsi_host_template tcm_loop_driver_template = { | |||
421 | .queuecommand = tcm_loop_queuecommand, | 416 | .queuecommand = tcm_loop_queuecommand, |
422 | .change_queue_depth = tcm_loop_change_queue_depth, | 417 | .change_queue_depth = tcm_loop_change_queue_depth, |
423 | .eh_device_reset_handler = tcm_loop_device_reset, | 418 | .eh_device_reset_handler = tcm_loop_device_reset, |
424 | .can_queue = TL_SCSI_CAN_QUEUE, | 419 | .can_queue = 1024, |
425 | .this_id = -1, | 420 | .this_id = -1, |
426 | .sg_tablesize = TL_SCSI_SG_TABLESIZE, | 421 | .sg_tablesize = 256, |
427 | .cmd_per_lun = TL_SCSI_CMD_PER_LUN, | 422 | .cmd_per_lun = 1024, |
428 | .max_sectors = TL_SCSI_MAX_SECTORS, | 423 | .max_sectors = 0xFFFF, |
429 | .use_clustering = DISABLE_CLUSTERING, | 424 | .use_clustering = DISABLE_CLUSTERING, |
430 | .slave_alloc = tcm_loop_slave_alloc, | 425 | .slave_alloc = tcm_loop_slave_alloc, |
431 | .slave_configure = tcm_loop_slave_configure, | 426 | .slave_configure = tcm_loop_slave_configure, |
@@ -564,8 +559,7 @@ static char *tcm_loop_get_fabric_name(void) | |||
564 | 559 | ||
565 | static u8 tcm_loop_get_fabric_proto_ident(struct se_portal_group *se_tpg) | 560 | static u8 tcm_loop_get_fabric_proto_ident(struct se_portal_group *se_tpg) |
566 | { | 561 | { |
567 | struct tcm_loop_tpg *tl_tpg = | 562 | struct tcm_loop_tpg *tl_tpg = se_tpg->se_tpg_fabric_ptr; |
568 | (struct tcm_loop_tpg *)se_tpg->se_tpg_fabric_ptr; | ||
569 | struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; | 563 | struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; |
570 | /* | 564 | /* |
571 | * tl_proto_id is set at tcm_loop_configfs.c:tcm_loop_make_scsi_hba() | 565 | * tl_proto_id is set at tcm_loop_configfs.c:tcm_loop_make_scsi_hba() |
@@ -592,8 +586,7 @@ static u8 tcm_loop_get_fabric_proto_ident(struct se_portal_group *se_tpg) | |||
592 | 586 | ||
593 | static char *tcm_loop_get_endpoint_wwn(struct se_portal_group *se_tpg) | 587 | static char *tcm_loop_get_endpoint_wwn(struct se_portal_group *se_tpg) |
594 | { | 588 | { |
595 | struct tcm_loop_tpg *tl_tpg = | 589 | struct tcm_loop_tpg *tl_tpg = se_tpg->se_tpg_fabric_ptr; |
596 | (struct tcm_loop_tpg *)se_tpg->se_tpg_fabric_ptr; | ||
597 | /* | 590 | /* |
598 | * Return the passed NAA identifier for the SAS Target Port | 591 | * Return the passed NAA identifier for the SAS Target Port |
599 | */ | 592 | */ |
@@ -602,8 +595,7 @@ static char *tcm_loop_get_endpoint_wwn(struct se_portal_group *se_tpg) | |||
602 | 595 | ||
603 | static u16 tcm_loop_get_tag(struct se_portal_group *se_tpg) | 596 | static u16 tcm_loop_get_tag(struct se_portal_group *se_tpg) |
604 | { | 597 | { |
605 | struct tcm_loop_tpg *tl_tpg = | 598 | struct tcm_loop_tpg *tl_tpg = se_tpg->se_tpg_fabric_ptr; |
606 | (struct tcm_loop_tpg *)se_tpg->se_tpg_fabric_ptr; | ||
607 | /* | 599 | /* |
608 | * This Tag is used when forming SCSI Name identifier in EVPD=1 0x83 | 600 | * This Tag is used when forming SCSI Name identifier in EVPD=1 0x83 |
609 | * to represent the SCSI Target Port. | 601 | * to represent the SCSI Target Port. |
@@ -623,8 +615,7 @@ static u32 tcm_loop_get_pr_transport_id( | |||
623 | int *format_code, | 615 | int *format_code, |
624 | unsigned char *buf) | 616 | unsigned char *buf) |
625 | { | 617 | { |
626 | struct tcm_loop_tpg *tl_tpg = | 618 | struct tcm_loop_tpg *tl_tpg = se_tpg->se_tpg_fabric_ptr; |
627 | (struct tcm_loop_tpg *)se_tpg->se_tpg_fabric_ptr; | ||
628 | struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; | 619 | struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; |
629 | 620 | ||
630 | switch (tl_hba->tl_proto_id) { | 621 | switch (tl_hba->tl_proto_id) { |
@@ -653,8 +644,7 @@ static u32 tcm_loop_get_pr_transport_id_len( | |||
653 | struct t10_pr_registration *pr_reg, | 644 | struct t10_pr_registration *pr_reg, |
654 | int *format_code) | 645 | int *format_code) |
655 | { | 646 | { |
656 | struct tcm_loop_tpg *tl_tpg = | 647 | struct tcm_loop_tpg *tl_tpg = se_tpg->se_tpg_fabric_ptr; |
657 | (struct tcm_loop_tpg *)se_tpg->se_tpg_fabric_ptr; | ||
658 | struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; | 648 | struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; |
659 | 649 | ||
660 | switch (tl_hba->tl_proto_id) { | 650 | switch (tl_hba->tl_proto_id) { |
@@ -687,8 +677,7 @@ static char *tcm_loop_parse_pr_out_transport_id( | |||
687 | u32 *out_tid_len, | 677 | u32 *out_tid_len, |
688 | char **port_nexus_ptr) | 678 | char **port_nexus_ptr) |
689 | { | 679 | { |
690 | struct tcm_loop_tpg *tl_tpg = | 680 | struct tcm_loop_tpg *tl_tpg = se_tpg->se_tpg_fabric_ptr; |
691 | (struct tcm_loop_tpg *)se_tpg->se_tpg_fabric_ptr; | ||
692 | struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; | 681 | struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; |
693 | 682 | ||
694 | switch (tl_hba->tl_proto_id) { | 683 | switch (tl_hba->tl_proto_id) { |
diff --git a/drivers/target/loopback/tcm_loop.h b/drivers/target/loopback/tcm_loop.h index 6b76c7a22bb0..15a036441471 100644 --- a/drivers/target/loopback/tcm_loop.h +++ b/drivers/target/loopback/tcm_loop.h | |||
@@ -1,16 +1,7 @@ | |||
1 | #define TCM_LOOP_VERSION "v2.1-rc1" | 1 | #define TCM_LOOP_VERSION "v2.1-rc1" |
2 | #define TL_WWN_ADDR_LEN 256 | 2 | #define TL_WWN_ADDR_LEN 256 |
3 | #define TL_TPGS_PER_HBA 32 | 3 | #define TL_TPGS_PER_HBA 32 |
4 | /* | 4 | |
5 | * Defaults for struct scsi_host_template tcm_loop_driver_template | ||
6 | * | ||
7 | * We use large can_queue and cmd_per_lun here and let TCM enforce | ||
8 | * the underlying se_device_t->queue_depth. | ||
9 | */ | ||
10 | #define TL_SCSI_CAN_QUEUE 1024 | ||
11 | #define TL_SCSI_CMD_PER_LUN 1024 | ||
12 | #define TL_SCSI_MAX_SECTORS 1024 | ||
13 | #define TL_SCSI_SG_TABLESIZE 256 | ||
14 | /* | 5 | /* |
15 | * Used in tcm_loop_driver_probe() for struct Scsi_Host->max_cmd_len | 6 | * Used in tcm_loop_driver_probe() for struct Scsi_Host->max_cmd_len |
16 | */ | 7 | */ |
diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c index 1dcbef499d6a..1b1edd14f4bf 100644 --- a/drivers/target/target_core_alua.c +++ b/drivers/target/target_core_alua.c | |||
@@ -32,13 +32,12 @@ | |||
32 | #include <scsi/scsi_cmnd.h> | 32 | #include <scsi/scsi_cmnd.h> |
33 | 33 | ||
34 | #include <target/target_core_base.h> | 34 | #include <target/target_core_base.h> |
35 | #include <target/target_core_device.h> | 35 | #include <target/target_core_backend.h> |
36 | #include <target/target_core_transport.h> | 36 | #include <target/target_core_fabric.h> |
37 | #include <target/target_core_fabric_ops.h> | ||
38 | #include <target/target_core_configfs.h> | 37 | #include <target/target_core_configfs.h> |
39 | 38 | ||
39 | #include "target_core_internal.h" | ||
40 | #include "target_core_alua.h" | 40 | #include "target_core_alua.h" |
41 | #include "target_core_hba.h" | ||
42 | #include "target_core_ua.h" | 41 | #include "target_core_ua.h" |
43 | 42 | ||
44 | static int core_alua_check_transition(int state, int *primary); | 43 | static int core_alua_check_transition(int state, int *primary); |
diff --git a/drivers/target/target_core_cdb.c b/drivers/target/target_core_cdb.c index 831468b3163d..2f2235edefff 100644 --- a/drivers/target/target_core_cdb.c +++ b/drivers/target/target_core_cdb.c | |||
@@ -29,10 +29,11 @@ | |||
29 | #include <scsi/scsi.h> | 29 | #include <scsi/scsi.h> |
30 | 30 | ||
31 | #include <target/target_core_base.h> | 31 | #include <target/target_core_base.h> |
32 | #include <target/target_core_transport.h> | 32 | #include <target/target_core_backend.h> |
33 | #include <target/target_core_fabric_ops.h> | 33 | #include <target/target_core_fabric.h> |
34 | |||
35 | #include "target_core_internal.h" | ||
34 | #include "target_core_ua.h" | 36 | #include "target_core_ua.h" |
35 | #include "target_core_cdb.h" | ||
36 | 37 | ||
37 | static void | 38 | static void |
38 | target_fill_alua_data(struct se_port *port, unsigned char *buf) | 39 | target_fill_alua_data(struct se_port *port, unsigned char *buf) |
@@ -94,6 +95,18 @@ target_emulate_inquiry_std(struct se_cmd *cmd) | |||
94 | buf[2] = dev->transport->get_device_rev(dev); | 95 | buf[2] = dev->transport->get_device_rev(dev); |
95 | 96 | ||
96 | /* | 97 | /* |
98 | * NORMACA and HISUP = 0, RESPONSE DATA FORMAT = 2 | ||
99 | * | ||
100 | * SPC4 says: | ||
101 | * A RESPONSE DATA FORMAT field set to 2h indicates that the | ||
102 | * standard INQUIRY data is in the format defined in this | ||
103 | * standard. Response data format values less than 2h are | ||
104 | * obsolete. Response data format values greater than 2h are | ||
105 | * reserved. | ||
106 | */ | ||
107 | buf[3] = 2; | ||
108 | |||
109 | /* | ||
97 | * Enable SCCS and TPGS fields for Emulated ALUA | 110 | * Enable SCCS and TPGS fields for Emulated ALUA |
98 | */ | 111 | */ |
99 | if (dev->se_sub_dev->t10_alua.alua_type == SPC3_ALUA_EMULATED) | 112 | if (dev->se_sub_dev->t10_alua.alua_type == SPC3_ALUA_EMULATED) |
@@ -115,11 +128,9 @@ target_emulate_inquiry_std(struct se_cmd *cmd) | |||
115 | goto out; | 128 | goto out; |
116 | } | 129 | } |
117 | 130 | ||
118 | snprintf((unsigned char *)&buf[8], 8, "LIO-ORG"); | 131 | snprintf(&buf[8], 8, "LIO-ORG"); |
119 | snprintf((unsigned char *)&buf[16], 16, "%s", | 132 | snprintf(&buf[16], 16, "%s", dev->se_sub_dev->t10_wwn.model); |
120 | &dev->se_sub_dev->t10_wwn.model[0]); | 133 | snprintf(&buf[32], 4, "%s", dev->se_sub_dev->t10_wwn.revision); |
121 | snprintf((unsigned char *)&buf[32], 4, "%s", | ||
122 | &dev->se_sub_dev->t10_wwn.revision[0]); | ||
123 | buf[4] = 31; /* Set additional length to 31 */ | 134 | buf[4] = 31; /* Set additional length to 31 */ |
124 | 135 | ||
125 | out: | 136 | out: |
@@ -138,8 +149,7 @@ target_emulate_evpd_80(struct se_cmd *cmd, unsigned char *buf) | |||
138 | SDF_EMULATED_VPD_UNIT_SERIAL) { | 149 | SDF_EMULATED_VPD_UNIT_SERIAL) { |
139 | u32 unit_serial_len; | 150 | u32 unit_serial_len; |
140 | 151 | ||
141 | unit_serial_len = | 152 | unit_serial_len = strlen(dev->se_sub_dev->t10_wwn.unit_serial); |
142 | strlen(&dev->se_sub_dev->t10_wwn.unit_serial[0]); | ||
143 | unit_serial_len++; /* For NULL Terminator */ | 153 | unit_serial_len++; /* For NULL Terminator */ |
144 | 154 | ||
145 | if (((len + 4) + unit_serial_len) > cmd->data_length) { | 155 | if (((len + 4) + unit_serial_len) > cmd->data_length) { |
@@ -148,8 +158,8 @@ target_emulate_evpd_80(struct se_cmd *cmd, unsigned char *buf) | |||
148 | buf[3] = (len & 0xff); | 158 | buf[3] = (len & 0xff); |
149 | return 0; | 159 | return 0; |
150 | } | 160 | } |
151 | len += sprintf((unsigned char *)&buf[4], "%s", | 161 | len += sprintf(&buf[4], "%s", |
152 | &dev->se_sub_dev->t10_wwn.unit_serial[0]); | 162 | dev->se_sub_dev->t10_wwn.unit_serial); |
153 | len++; /* Extra Byte for NULL Terminator */ | 163 | len++; /* Extra Byte for NULL Terminator */ |
154 | buf[3] = len; | 164 | buf[3] = len; |
155 | } | 165 | } |
@@ -279,14 +289,13 @@ check_t10_vend_desc: | |||
279 | len += (prod_len + unit_serial_len); | 289 | len += (prod_len + unit_serial_len); |
280 | goto check_port; | 290 | goto check_port; |
281 | } | 291 | } |
282 | id_len += sprintf((unsigned char *)&buf[off+12], | 292 | id_len += sprintf(&buf[off+12], "%s:%s", prod, |
283 | "%s:%s", prod, | ||
284 | &dev->se_sub_dev->t10_wwn.unit_serial[0]); | 293 | &dev->se_sub_dev->t10_wwn.unit_serial[0]); |
285 | } | 294 | } |
286 | buf[off] = 0x2; /* ASCII */ | 295 | buf[off] = 0x2; /* ASCII */ |
287 | buf[off+1] = 0x1; /* T10 Vendor ID */ | 296 | buf[off+1] = 0x1; /* T10 Vendor ID */ |
288 | buf[off+2] = 0x0; | 297 | buf[off+2] = 0x0; |
289 | memcpy((unsigned char *)&buf[off+4], "LIO-ORG", 8); | 298 | memcpy(&buf[off+4], "LIO-ORG", 8); |
290 | /* Extra Byte for NULL Terminator */ | 299 | /* Extra Byte for NULL Terminator */ |
291 | id_len++; | 300 | id_len++; |
292 | /* Identifier Length */ | 301 | /* Identifier Length */ |
diff --git a/drivers/target/target_core_cdb.h b/drivers/target/target_core_cdb.h deleted file mode 100644 index ad6b1e393001..000000000000 --- a/drivers/target/target_core_cdb.h +++ /dev/null | |||
@@ -1,14 +0,0 @@ | |||
1 | #ifndef TARGET_CORE_CDB_H | ||
2 | #define TARGET_CORE_CDB_H | ||
3 | |||
4 | int target_emulate_inquiry(struct se_task *task); | ||
5 | int target_emulate_readcapacity(struct se_task *task); | ||
6 | int target_emulate_readcapacity_16(struct se_task *task); | ||
7 | int target_emulate_modesense(struct se_task *task); | ||
8 | int target_emulate_request_sense(struct se_task *task); | ||
9 | int target_emulate_unmap(struct se_task *task); | ||
10 | int target_emulate_write_same(struct se_task *task); | ||
11 | int target_emulate_synchronize_cache(struct se_task *task); | ||
12 | int target_emulate_noop(struct se_task *task); | ||
13 | |||
14 | #endif /* TARGET_CORE_CDB_H */ | ||
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index 93d4f6a1b798..0955bb8979fb 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c | |||
@@ -39,18 +39,16 @@ | |||
39 | #include <linux/spinlock.h> | 39 | #include <linux/spinlock.h> |
40 | 40 | ||
41 | #include <target/target_core_base.h> | 41 | #include <target/target_core_base.h> |
42 | #include <target/target_core_device.h> | 42 | #include <target/target_core_backend.h> |
43 | #include <target/target_core_transport.h> | 43 | #include <target/target_core_fabric.h> |
44 | #include <target/target_core_fabric_ops.h> | ||
45 | #include <target/target_core_fabric_configfs.h> | 44 | #include <target/target_core_fabric_configfs.h> |
46 | #include <target/target_core_configfs.h> | 45 | #include <target/target_core_configfs.h> |
47 | #include <target/configfs_macros.h> | 46 | #include <target/configfs_macros.h> |
48 | 47 | ||
48 | #include "target_core_internal.h" | ||
49 | #include "target_core_alua.h" | 49 | #include "target_core_alua.h" |
50 | #include "target_core_hba.h" | ||
51 | #include "target_core_pr.h" | 50 | #include "target_core_pr.h" |
52 | #include "target_core_rd.h" | 51 | #include "target_core_rd.h" |
53 | #include "target_core_stat.h" | ||
54 | 52 | ||
55 | extern struct t10_alua_lu_gp *default_lu_gp; | 53 | extern struct t10_alua_lu_gp *default_lu_gp; |
56 | 54 | ||
@@ -1452,7 +1450,7 @@ static ssize_t target_core_dev_pr_store_attr_res_aptpl_metadata( | |||
1452 | return -ENOMEM; | 1450 | return -ENOMEM; |
1453 | 1451 | ||
1454 | orig = opts; | 1452 | orig = opts; |
1455 | while ((ptr = strsep(&opts, ",")) != NULL) { | 1453 | while ((ptr = strsep(&opts, ",\n")) != NULL) { |
1456 | if (!*ptr) | 1454 | if (!*ptr) |
1457 | continue; | 1455 | continue; |
1458 | 1456 | ||
@@ -1631,7 +1629,7 @@ static struct config_item_type target_core_dev_pr_cit = { | |||
1631 | 1629 | ||
1632 | static ssize_t target_core_show_dev_info(void *p, char *page) | 1630 | static ssize_t target_core_show_dev_info(void *p, char *page) |
1633 | { | 1631 | { |
1634 | struct se_subsystem_dev *se_dev = (struct se_subsystem_dev *)p; | 1632 | struct se_subsystem_dev *se_dev = p; |
1635 | struct se_hba *hba = se_dev->se_dev_hba; | 1633 | struct se_hba *hba = se_dev->se_dev_hba; |
1636 | struct se_subsystem_api *t = hba->transport; | 1634 | struct se_subsystem_api *t = hba->transport; |
1637 | int bl = 0; | 1635 | int bl = 0; |
@@ -1659,7 +1657,7 @@ static ssize_t target_core_store_dev_control( | |||
1659 | const char *page, | 1657 | const char *page, |
1660 | size_t count) | 1658 | size_t count) |
1661 | { | 1659 | { |
1662 | struct se_subsystem_dev *se_dev = (struct se_subsystem_dev *)p; | 1660 | struct se_subsystem_dev *se_dev = p; |
1663 | struct se_hba *hba = se_dev->se_dev_hba; | 1661 | struct se_hba *hba = se_dev->se_dev_hba; |
1664 | struct se_subsystem_api *t = hba->transport; | 1662 | struct se_subsystem_api *t = hba->transport; |
1665 | 1663 | ||
@@ -1682,7 +1680,7 @@ static struct target_core_configfs_attribute target_core_attr_dev_control = { | |||
1682 | 1680 | ||
1683 | static ssize_t target_core_show_dev_alias(void *p, char *page) | 1681 | static ssize_t target_core_show_dev_alias(void *p, char *page) |
1684 | { | 1682 | { |
1685 | struct se_subsystem_dev *se_dev = (struct se_subsystem_dev *)p; | 1683 | struct se_subsystem_dev *se_dev = p; |
1686 | 1684 | ||
1687 | if (!(se_dev->su_dev_flags & SDF_USING_ALIAS)) | 1685 | if (!(se_dev->su_dev_flags & SDF_USING_ALIAS)) |
1688 | return 0; | 1686 | return 0; |
@@ -1695,7 +1693,7 @@ static ssize_t target_core_store_dev_alias( | |||
1695 | const char *page, | 1693 | const char *page, |
1696 | size_t count) | 1694 | size_t count) |
1697 | { | 1695 | { |
1698 | struct se_subsystem_dev *se_dev = (struct se_subsystem_dev *)p; | 1696 | struct se_subsystem_dev *se_dev = p; |
1699 | struct se_hba *hba = se_dev->se_dev_hba; | 1697 | struct se_hba *hba = se_dev->se_dev_hba; |
1700 | ssize_t read_bytes; | 1698 | ssize_t read_bytes; |
1701 | 1699 | ||
@@ -1710,6 +1708,9 @@ static ssize_t target_core_store_dev_alias( | |||
1710 | read_bytes = snprintf(&se_dev->se_dev_alias[0], SE_DEV_ALIAS_LEN, | 1708 | read_bytes = snprintf(&se_dev->se_dev_alias[0], SE_DEV_ALIAS_LEN, |
1711 | "%s", page); | 1709 | "%s", page); |
1712 | 1710 | ||
1711 | if (se_dev->se_dev_alias[read_bytes - 1] == '\n') | ||
1712 | se_dev->se_dev_alias[read_bytes - 1] = '\0'; | ||
1713 | |||
1713 | pr_debug("Target_Core_ConfigFS: %s/%s set alias: %s\n", | 1714 | pr_debug("Target_Core_ConfigFS: %s/%s set alias: %s\n", |
1714 | config_item_name(&hba->hba_group.cg_item), | 1715 | config_item_name(&hba->hba_group.cg_item), |
1715 | config_item_name(&se_dev->se_dev_group.cg_item), | 1716 | config_item_name(&se_dev->se_dev_group.cg_item), |
@@ -1728,7 +1729,7 @@ static struct target_core_configfs_attribute target_core_attr_dev_alias = { | |||
1728 | 1729 | ||
1729 | static ssize_t target_core_show_dev_udev_path(void *p, char *page) | 1730 | static ssize_t target_core_show_dev_udev_path(void *p, char *page) |
1730 | { | 1731 | { |
1731 | struct se_subsystem_dev *se_dev = (struct se_subsystem_dev *)p; | 1732 | struct se_subsystem_dev *se_dev = p; |
1732 | 1733 | ||
1733 | if (!(se_dev->su_dev_flags & SDF_USING_UDEV_PATH)) | 1734 | if (!(se_dev->su_dev_flags & SDF_USING_UDEV_PATH)) |
1734 | return 0; | 1735 | return 0; |
@@ -1741,7 +1742,7 @@ static ssize_t target_core_store_dev_udev_path( | |||
1741 | const char *page, | 1742 | const char *page, |
1742 | size_t count) | 1743 | size_t count) |
1743 | { | 1744 | { |
1744 | struct se_subsystem_dev *se_dev = (struct se_subsystem_dev *)p; | 1745 | struct se_subsystem_dev *se_dev = p; |
1745 | struct se_hba *hba = se_dev->se_dev_hba; | 1746 | struct se_hba *hba = se_dev->se_dev_hba; |
1746 | ssize_t read_bytes; | 1747 | ssize_t read_bytes; |
1747 | 1748 | ||
@@ -1756,6 +1757,9 @@ static ssize_t target_core_store_dev_udev_path( | |||
1756 | read_bytes = snprintf(&se_dev->se_dev_udev_path[0], SE_UDEV_PATH_LEN, | 1757 | read_bytes = snprintf(&se_dev->se_dev_udev_path[0], SE_UDEV_PATH_LEN, |
1757 | "%s", page); | 1758 | "%s", page); |
1758 | 1759 | ||
1760 | if (se_dev->se_dev_udev_path[read_bytes - 1] == '\n') | ||
1761 | se_dev->se_dev_udev_path[read_bytes - 1] = '\0'; | ||
1762 | |||
1759 | pr_debug("Target_Core_ConfigFS: %s/%s set udev_path: %s\n", | 1763 | pr_debug("Target_Core_ConfigFS: %s/%s set udev_path: %s\n", |
1760 | config_item_name(&hba->hba_group.cg_item), | 1764 | config_item_name(&hba->hba_group.cg_item), |
1761 | config_item_name(&se_dev->se_dev_group.cg_item), | 1765 | config_item_name(&se_dev->se_dev_group.cg_item), |
@@ -1777,7 +1781,7 @@ static ssize_t target_core_store_dev_enable( | |||
1777 | const char *page, | 1781 | const char *page, |
1778 | size_t count) | 1782 | size_t count) |
1779 | { | 1783 | { |
1780 | struct se_subsystem_dev *se_dev = (struct se_subsystem_dev *)p; | 1784 | struct se_subsystem_dev *se_dev = p; |
1781 | struct se_device *dev; | 1785 | struct se_device *dev; |
1782 | struct se_hba *hba = se_dev->se_dev_hba; | 1786 | struct se_hba *hba = se_dev->se_dev_hba; |
1783 | struct se_subsystem_api *t = hba->transport; | 1787 | struct se_subsystem_api *t = hba->transport; |
@@ -1822,7 +1826,7 @@ static struct target_core_configfs_attribute target_core_attr_dev_enable = { | |||
1822 | static ssize_t target_core_show_alua_lu_gp(void *p, char *page) | 1826 | static ssize_t target_core_show_alua_lu_gp(void *p, char *page) |
1823 | { | 1827 | { |
1824 | struct se_device *dev; | 1828 | struct se_device *dev; |
1825 | struct se_subsystem_dev *su_dev = (struct se_subsystem_dev *)p; | 1829 | struct se_subsystem_dev *su_dev = p; |
1826 | struct config_item *lu_ci; | 1830 | struct config_item *lu_ci; |
1827 | struct t10_alua_lu_gp *lu_gp; | 1831 | struct t10_alua_lu_gp *lu_gp; |
1828 | struct t10_alua_lu_gp_member *lu_gp_mem; | 1832 | struct t10_alua_lu_gp_member *lu_gp_mem; |
@@ -1860,7 +1864,7 @@ static ssize_t target_core_store_alua_lu_gp( | |||
1860 | size_t count) | 1864 | size_t count) |
1861 | { | 1865 | { |
1862 | struct se_device *dev; | 1866 | struct se_device *dev; |
1863 | struct se_subsystem_dev *su_dev = (struct se_subsystem_dev *)p; | 1867 | struct se_subsystem_dev *su_dev = p; |
1864 | struct se_hba *hba = su_dev->se_dev_hba; | 1868 | struct se_hba *hba = su_dev->se_dev_hba; |
1865 | struct t10_alua_lu_gp *lu_gp = NULL, *lu_gp_new = NULL; | 1869 | struct t10_alua_lu_gp *lu_gp = NULL, *lu_gp_new = NULL; |
1866 | struct t10_alua_lu_gp_member *lu_gp_mem; | 1870 | struct t10_alua_lu_gp_member *lu_gp_mem; |
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index 9b8639425472..0c5992f0d946 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c | |||
@@ -42,13 +42,11 @@ | |||
42 | #include <scsi/scsi_device.h> | 42 | #include <scsi/scsi_device.h> |
43 | 43 | ||
44 | #include <target/target_core_base.h> | 44 | #include <target/target_core_base.h> |
45 | #include <target/target_core_device.h> | 45 | #include <target/target_core_backend.h> |
46 | #include <target/target_core_tpg.h> | 46 | #include <target/target_core_fabric.h> |
47 | #include <target/target_core_transport.h> | ||
48 | #include <target/target_core_fabric_ops.h> | ||
49 | 47 | ||
48 | #include "target_core_internal.h" | ||
50 | #include "target_core_alua.h" | 49 | #include "target_core_alua.h" |
51 | #include "target_core_hba.h" | ||
52 | #include "target_core_pr.h" | 50 | #include "target_core_pr.h" |
53 | #include "target_core_ua.h" | 51 | #include "target_core_ua.h" |
54 | 52 | ||
@@ -1134,8 +1132,6 @@ int se_dev_set_emulate_rest_reord(struct se_device *dev, int flag) | |||
1134 | */ | 1132 | */ |
1135 | int se_dev_set_queue_depth(struct se_device *dev, u32 queue_depth) | 1133 | int se_dev_set_queue_depth(struct se_device *dev, u32 queue_depth) |
1136 | { | 1134 | { |
1137 | u32 orig_queue_depth = dev->queue_depth; | ||
1138 | |||
1139 | if (atomic_read(&dev->dev_export_obj.obj_access_count)) { | 1135 | if (atomic_read(&dev->dev_export_obj.obj_access_count)) { |
1140 | pr_err("dev[%p]: Unable to change SE Device TCQ while" | 1136 | pr_err("dev[%p]: Unable to change SE Device TCQ while" |
1141 | " dev_export_obj: %d count exists\n", dev, | 1137 | " dev_export_obj: %d count exists\n", dev, |
@@ -1169,11 +1165,6 @@ int se_dev_set_queue_depth(struct se_device *dev, u32 queue_depth) | |||
1169 | } | 1165 | } |
1170 | 1166 | ||
1171 | dev->se_sub_dev->se_dev_attrib.queue_depth = dev->queue_depth = queue_depth; | 1167 | dev->se_sub_dev->se_dev_attrib.queue_depth = dev->queue_depth = queue_depth; |
1172 | if (queue_depth > orig_queue_depth) | ||
1173 | atomic_add(queue_depth - orig_queue_depth, &dev->depth_left); | ||
1174 | else if (queue_depth < orig_queue_depth) | ||
1175 | atomic_sub(orig_queue_depth - queue_depth, &dev->depth_left); | ||
1176 | |||
1177 | pr_debug("dev[%p]: SE Device TCQ Depth changed to: %u\n", | 1168 | pr_debug("dev[%p]: SE Device TCQ Depth changed to: %u\n", |
1178 | dev, queue_depth); | 1169 | dev, queue_depth); |
1179 | return 0; | 1170 | return 0; |
diff --git a/drivers/target/target_core_fabric_configfs.c b/drivers/target/target_core_fabric_configfs.c index 09b6f8729f91..4f77cce22646 100644 --- a/drivers/target/target_core_fabric_configfs.c +++ b/drivers/target/target_core_fabric_configfs.c | |||
@@ -36,18 +36,14 @@ | |||
36 | #include <linux/configfs.h> | 36 | #include <linux/configfs.h> |
37 | 37 | ||
38 | #include <target/target_core_base.h> | 38 | #include <target/target_core_base.h> |
39 | #include <target/target_core_device.h> | 39 | #include <target/target_core_fabric.h> |
40 | #include <target/target_core_tpg.h> | ||
41 | #include <target/target_core_transport.h> | ||
42 | #include <target/target_core_fabric_ops.h> | ||
43 | #include <target/target_core_fabric_configfs.h> | 40 | #include <target/target_core_fabric_configfs.h> |
44 | #include <target/target_core_configfs.h> | 41 | #include <target/target_core_configfs.h> |
45 | #include <target/configfs_macros.h> | 42 | #include <target/configfs_macros.h> |
46 | 43 | ||
44 | #include "target_core_internal.h" | ||
47 | #include "target_core_alua.h" | 45 | #include "target_core_alua.h" |
48 | #include "target_core_hba.h" | ||
49 | #include "target_core_pr.h" | 46 | #include "target_core_pr.h" |
50 | #include "target_core_stat.h" | ||
51 | 47 | ||
52 | #define TF_CIT_SETUP(_name, _item_ops, _group_ops, _attrs) \ | 48 | #define TF_CIT_SETUP(_name, _item_ops, _group_ops, _attrs) \ |
53 | static void target_fabric_setup_##_name##_cit(struct target_fabric_configfs *tf) \ | 49 | static void target_fabric_setup_##_name##_cit(struct target_fabric_configfs *tf) \ |
diff --git a/drivers/target/target_core_fabric_lib.c b/drivers/target/target_core_fabric_lib.c index ec4249be617e..283a36e464e6 100644 --- a/drivers/target/target_core_fabric_lib.c +++ b/drivers/target/target_core_fabric_lib.c | |||
@@ -34,13 +34,10 @@ | |||
34 | #include <scsi/scsi_cmnd.h> | 34 | #include <scsi/scsi_cmnd.h> |
35 | 35 | ||
36 | #include <target/target_core_base.h> | 36 | #include <target/target_core_base.h> |
37 | #include <target/target_core_device.h> | 37 | #include <target/target_core_fabric.h> |
38 | #include <target/target_core_transport.h> | ||
39 | #include <target/target_core_fabric_lib.h> | ||
40 | #include <target/target_core_fabric_ops.h> | ||
41 | #include <target/target_core_configfs.h> | 38 | #include <target/target_core_configfs.h> |
42 | 39 | ||
43 | #include "target_core_hba.h" | 40 | #include "target_core_internal.h" |
44 | #include "target_core_pr.h" | 41 | #include "target_core_pr.h" |
45 | 42 | ||
46 | /* | 43 | /* |
@@ -402,7 +399,7 @@ char *iscsi_parse_pr_out_transport_id( | |||
402 | add_len = ((buf[2] >> 8) & 0xff); | 399 | add_len = ((buf[2] >> 8) & 0xff); |
403 | add_len |= (buf[3] & 0xff); | 400 | add_len |= (buf[3] & 0xff); |
404 | 401 | ||
405 | tid_len = strlen((char *)&buf[4]); | 402 | tid_len = strlen(&buf[4]); |
406 | tid_len += 4; /* Add four bytes for iSCSI Transport ID header */ | 403 | tid_len += 4; /* Add four bytes for iSCSI Transport ID header */ |
407 | tid_len += 1; /* Add one byte for NULL terminator */ | 404 | tid_len += 1; /* Add one byte for NULL terminator */ |
408 | padding = ((-tid_len) & 3); | 405 | padding = ((-tid_len) & 3); |
@@ -423,11 +420,11 @@ char *iscsi_parse_pr_out_transport_id( | |||
423 | * format. | 420 | * format. |
424 | */ | 421 | */ |
425 | if (format_code == 0x40) { | 422 | if (format_code == 0x40) { |
426 | p = strstr((char *)&buf[4], ",i,0x"); | 423 | p = strstr(&buf[4], ",i,0x"); |
427 | if (!p) { | 424 | if (!p) { |
428 | pr_err("Unable to locate \",i,0x\" seperator" | 425 | pr_err("Unable to locate \",i,0x\" seperator" |
429 | " for Initiator port identifier: %s\n", | 426 | " for Initiator port identifier: %s\n", |
430 | (char *)&buf[4]); | 427 | &buf[4]); |
431 | return NULL; | 428 | return NULL; |
432 | } | 429 | } |
433 | *p = '\0'; /* Terminate iSCSI Name */ | 430 | *p = '\0'; /* Terminate iSCSI Name */ |
diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c index b4864fba4ef0..7ed58e2df791 100644 --- a/drivers/target/target_core_file.c +++ b/drivers/target/target_core_file.c | |||
@@ -37,8 +37,7 @@ | |||
37 | #include <scsi/scsi_host.h> | 37 | #include <scsi/scsi_host.h> |
38 | 38 | ||
39 | #include <target/target_core_base.h> | 39 | #include <target/target_core_base.h> |
40 | #include <target/target_core_device.h> | 40 | #include <target/target_core_backend.h> |
41 | #include <target/target_core_transport.h> | ||
42 | 41 | ||
43 | #include "target_core_file.h" | 42 | #include "target_core_file.h" |
44 | 43 | ||
@@ -86,7 +85,7 @@ static void fd_detach_hba(struct se_hba *hba) | |||
86 | static void *fd_allocate_virtdevice(struct se_hba *hba, const char *name) | 85 | static void *fd_allocate_virtdevice(struct se_hba *hba, const char *name) |
87 | { | 86 | { |
88 | struct fd_dev *fd_dev; | 87 | struct fd_dev *fd_dev; |
89 | struct fd_host *fd_host = (struct fd_host *) hba->hba_ptr; | 88 | struct fd_host *fd_host = hba->hba_ptr; |
90 | 89 | ||
91 | fd_dev = kzalloc(sizeof(struct fd_dev), GFP_KERNEL); | 90 | fd_dev = kzalloc(sizeof(struct fd_dev), GFP_KERNEL); |
92 | if (!fd_dev) { | 91 | if (!fd_dev) { |
@@ -114,8 +113,8 @@ static struct se_device *fd_create_virtdevice( | |||
114 | struct se_device *dev; | 113 | struct se_device *dev; |
115 | struct se_dev_limits dev_limits; | 114 | struct se_dev_limits dev_limits; |
116 | struct queue_limits *limits; | 115 | struct queue_limits *limits; |
117 | struct fd_dev *fd_dev = (struct fd_dev *) p; | 116 | struct fd_dev *fd_dev = p; |
118 | struct fd_host *fd_host = (struct fd_host *) hba->hba_ptr; | 117 | struct fd_host *fd_host = hba->hba_ptr; |
119 | mm_segment_t old_fs; | 118 | mm_segment_t old_fs; |
120 | struct file *file; | 119 | struct file *file; |
121 | struct inode *inode = NULL; | 120 | struct inode *inode = NULL; |
@@ -240,7 +239,7 @@ fail: | |||
240 | */ | 239 | */ |
241 | static void fd_free_device(void *p) | 240 | static void fd_free_device(void *p) |
242 | { | 241 | { |
243 | struct fd_dev *fd_dev = (struct fd_dev *) p; | 242 | struct fd_dev *fd_dev = p; |
244 | 243 | ||
245 | if (fd_dev->fd_file) { | 244 | if (fd_dev->fd_file) { |
246 | filp_close(fd_dev->fd_file, NULL); | 245 | filp_close(fd_dev->fd_file, NULL); |
@@ -498,7 +497,7 @@ static ssize_t fd_set_configfs_dev_params( | |||
498 | 497 | ||
499 | orig = opts; | 498 | orig = opts; |
500 | 499 | ||
501 | while ((ptr = strsep(&opts, ",")) != NULL) { | 500 | while ((ptr = strsep(&opts, ",\n")) != NULL) { |
502 | if (!*ptr) | 501 | if (!*ptr) |
503 | continue; | 502 | continue; |
504 | 503 | ||
@@ -559,7 +558,7 @@ out: | |||
559 | 558 | ||
560 | static ssize_t fd_check_configfs_dev_params(struct se_hba *hba, struct se_subsystem_dev *se_dev) | 559 | static ssize_t fd_check_configfs_dev_params(struct se_hba *hba, struct se_subsystem_dev *se_dev) |
561 | { | 560 | { |
562 | struct fd_dev *fd_dev = (struct fd_dev *) se_dev->se_dev_su_ptr; | 561 | struct fd_dev *fd_dev = se_dev->se_dev_su_ptr; |
563 | 562 | ||
564 | if (!(fd_dev->fbd_flags & FBDF_HAS_PATH)) { | 563 | if (!(fd_dev->fbd_flags & FBDF_HAS_PATH)) { |
565 | pr_err("Missing fd_dev_name=\n"); | 564 | pr_err("Missing fd_dev_name=\n"); |
diff --git a/drivers/target/target_core_hba.c b/drivers/target/target_core_hba.c index c68019d6c406..3dd1bd4b6f71 100644 --- a/drivers/target/target_core_hba.c +++ b/drivers/target/target_core_hba.c | |||
@@ -37,11 +37,10 @@ | |||
37 | #include <net/tcp.h> | 37 | #include <net/tcp.h> |
38 | 38 | ||
39 | #include <target/target_core_base.h> | 39 | #include <target/target_core_base.h> |
40 | #include <target/target_core_device.h> | 40 | #include <target/target_core_backend.h> |
41 | #include <target/target_core_tpg.h> | 41 | #include <target/target_core_fabric.h> |
42 | #include <target/target_core_transport.h> | ||
43 | 42 | ||
44 | #include "target_core_hba.h" | 43 | #include "target_core_internal.h" |
45 | 44 | ||
46 | static LIST_HEAD(subsystem_list); | 45 | static LIST_HEAD(subsystem_list); |
47 | static DEFINE_MUTEX(subsystem_mutex); | 46 | static DEFINE_MUTEX(subsystem_mutex); |
diff --git a/drivers/target/target_core_hba.h b/drivers/target/target_core_hba.h deleted file mode 100644 index bb0fea5f730c..000000000000 --- a/drivers/target/target_core_hba.h +++ /dev/null | |||
@@ -1,7 +0,0 @@ | |||
1 | #ifndef TARGET_CORE_HBA_H | ||
2 | #define TARGET_CORE_HBA_H | ||
3 | |||
4 | extern struct se_hba *core_alloc_hba(const char *, u32, u32); | ||
5 | extern int core_delete_hba(struct se_hba *); | ||
6 | |||
7 | #endif /* TARGET_CORE_HBA_H */ | ||
diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c index 4aa992204438..cc8e6b58ef20 100644 --- a/drivers/target/target_core_iblock.c +++ b/drivers/target/target_core_iblock.c | |||
@@ -42,8 +42,7 @@ | |||
42 | #include <scsi/scsi_host.h> | 42 | #include <scsi/scsi_host.h> |
43 | 43 | ||
44 | #include <target/target_core_base.h> | 44 | #include <target/target_core_base.h> |
45 | #include <target/target_core_device.h> | 45 | #include <target/target_core_backend.h> |
46 | #include <target/target_core_transport.h> | ||
47 | 46 | ||
48 | #include "target_core_iblock.h" | 47 | #include "target_core_iblock.h" |
49 | 48 | ||
@@ -391,7 +390,7 @@ static ssize_t iblock_set_configfs_dev_params(struct se_hba *hba, | |||
391 | 390 | ||
392 | orig = opts; | 391 | orig = opts; |
393 | 392 | ||
394 | while ((ptr = strsep(&opts, ",")) != NULL) { | 393 | while ((ptr = strsep(&opts, ",\n")) != NULL) { |
395 | if (!*ptr) | 394 | if (!*ptr) |
396 | continue; | 395 | continue; |
397 | 396 | ||
@@ -465,7 +464,7 @@ static ssize_t iblock_show_configfs_dev_params( | |||
465 | if (bd) { | 464 | if (bd) { |
466 | bl += sprintf(b + bl, "Major: %d Minor: %d %s\n", | 465 | bl += sprintf(b + bl, "Major: %d Minor: %d %s\n", |
467 | MAJOR(bd->bd_dev), MINOR(bd->bd_dev), (!bd->bd_contains) ? | 466 | MAJOR(bd->bd_dev), MINOR(bd->bd_dev), (!bd->bd_contains) ? |
468 | "" : (bd->bd_holder == (struct iblock_dev *)ibd) ? | 467 | "" : (bd->bd_holder == ibd) ? |
469 | "CLAIMED: IBLOCK" : "CLAIMED: OS"); | 468 | "CLAIMED: IBLOCK" : "CLAIMED: OS"); |
470 | } else { | 469 | } else { |
471 | bl += sprintf(b + bl, "Major: 0 Minor: 0\n"); | 470 | bl += sprintf(b + bl, "Major: 0 Minor: 0\n"); |
diff --git a/drivers/target/target_core_internal.h b/drivers/target/target_core_internal.h new file mode 100644 index 000000000000..26f135e94f6e --- /dev/null +++ b/drivers/target/target_core_internal.h | |||
@@ -0,0 +1,123 @@ | |||
1 | #ifndef TARGET_CORE_INTERNAL_H | ||
2 | #define TARGET_CORE_INTERNAL_H | ||
3 | |||
4 | /* target_core_alua.c */ | ||
5 | extern struct t10_alua_lu_gp *default_lu_gp; | ||
6 | |||
7 | /* target_core_cdb.c */ | ||
8 | int target_emulate_inquiry(struct se_task *task); | ||
9 | int target_emulate_readcapacity(struct se_task *task); | ||
10 | int target_emulate_readcapacity_16(struct se_task *task); | ||
11 | int target_emulate_modesense(struct se_task *task); | ||
12 | int target_emulate_request_sense(struct se_task *task); | ||
13 | int target_emulate_unmap(struct se_task *task); | ||
14 | int target_emulate_write_same(struct se_task *task); | ||
15 | int target_emulate_synchronize_cache(struct se_task *task); | ||
16 | int target_emulate_noop(struct se_task *task); | ||
17 | |||
18 | /* target_core_device.c */ | ||
19 | struct se_dev_entry *core_get_se_deve_from_rtpi(struct se_node_acl *, u16); | ||
20 | int core_free_device_list_for_node(struct se_node_acl *, | ||
21 | struct se_portal_group *); | ||
22 | void core_dec_lacl_count(struct se_node_acl *, struct se_cmd *); | ||
23 | void core_update_device_list_access(u32, u32, struct se_node_acl *); | ||
24 | int core_update_device_list_for_node(struct se_lun *, struct se_lun_acl *, | ||
25 | u32, u32, struct se_node_acl *, struct se_portal_group *, int); | ||
26 | void core_clear_lun_from_tpg(struct se_lun *, struct se_portal_group *); | ||
27 | int core_dev_export(struct se_device *, struct se_portal_group *, | ||
28 | struct se_lun *); | ||
29 | void core_dev_unexport(struct se_device *, struct se_portal_group *, | ||
30 | struct se_lun *); | ||
31 | int target_report_luns(struct se_task *); | ||
32 | void se_release_device_for_hba(struct se_device *); | ||
33 | void se_release_vpd_for_dev(struct se_device *); | ||
34 | int se_free_virtual_device(struct se_device *, struct se_hba *); | ||
35 | int se_dev_check_online(struct se_device *); | ||
36 | int se_dev_check_shutdown(struct se_device *); | ||
37 | void se_dev_set_default_attribs(struct se_device *, struct se_dev_limits *); | ||
38 | int se_dev_set_task_timeout(struct se_device *, u32); | ||
39 | int se_dev_set_max_unmap_lba_count(struct se_device *, u32); | ||
40 | int se_dev_set_max_unmap_block_desc_count(struct se_device *, u32); | ||
41 | int se_dev_set_unmap_granularity(struct se_device *, u32); | ||
42 | int se_dev_set_unmap_granularity_alignment(struct se_device *, u32); | ||
43 | int se_dev_set_emulate_dpo(struct se_device *, int); | ||
44 | int se_dev_set_emulate_fua_write(struct se_device *, int); | ||
45 | int se_dev_set_emulate_fua_read(struct se_device *, int); | ||
46 | int se_dev_set_emulate_write_cache(struct se_device *, int); | ||
47 | int se_dev_set_emulate_ua_intlck_ctrl(struct se_device *, int); | ||
48 | int se_dev_set_emulate_tas(struct se_device *, int); | ||
49 | int se_dev_set_emulate_tpu(struct se_device *, int); | ||
50 | int se_dev_set_emulate_tpws(struct se_device *, int); | ||
51 | int se_dev_set_enforce_pr_isids(struct se_device *, int); | ||
52 | int se_dev_set_is_nonrot(struct se_device *, int); | ||
53 | int se_dev_set_emulate_rest_reord(struct se_device *dev, int); | ||
54 | int se_dev_set_queue_depth(struct se_device *, u32); | ||
55 | int se_dev_set_max_sectors(struct se_device *, u32); | ||
56 | int se_dev_set_optimal_sectors(struct se_device *, u32); | ||
57 | int se_dev_set_block_size(struct se_device *, u32); | ||
58 | struct se_lun *core_dev_add_lun(struct se_portal_group *, struct se_hba *, | ||
59 | struct se_device *, u32); | ||
60 | int core_dev_del_lun(struct se_portal_group *, u32); | ||
61 | struct se_lun *core_get_lun_from_tpg(struct se_portal_group *, u32); | ||
62 | struct se_lun_acl *core_dev_init_initiator_node_lun_acl(struct se_portal_group *, | ||
63 | u32, char *, int *); | ||
64 | int core_dev_add_initiator_node_lun_acl(struct se_portal_group *, | ||
65 | struct se_lun_acl *, u32, u32); | ||
66 | int core_dev_del_initiator_node_lun_acl(struct se_portal_group *, | ||
67 | struct se_lun *, struct se_lun_acl *); | ||
68 | void core_dev_free_initiator_node_lun_acl(struct se_portal_group *, | ||
69 | struct se_lun_acl *lacl); | ||
70 | int core_dev_setup_virtual_lun0(void); | ||
71 | void core_dev_release_virtual_lun0(void); | ||
72 | |||
73 | /* target_core_hba.c */ | ||
74 | struct se_hba *core_alloc_hba(const char *, u32, u32); | ||
75 | int core_delete_hba(struct se_hba *); | ||
76 | |||
77 | /* target_core_tmr.c */ | ||
78 | int core_tmr_lun_reset(struct se_device *, struct se_tmr_req *, | ||
79 | struct list_head *, struct se_cmd *); | ||
80 | |||
81 | /* target_core_tpg.c */ | ||
82 | extern struct se_device *g_lun0_dev; | ||
83 | |||
84 | struct se_node_acl *__core_tpg_get_initiator_node_acl(struct se_portal_group *tpg, | ||
85 | const char *); | ||
86 | struct se_node_acl *core_tpg_get_initiator_node_acl(struct se_portal_group *tpg, | ||
87 | unsigned char *); | ||
88 | void core_tpg_add_node_to_devs(struct se_node_acl *, struct se_portal_group *); | ||
89 | void core_tpg_wait_for_nacl_pr_ref(struct se_node_acl *); | ||
90 | struct se_lun *core_tpg_pre_addlun(struct se_portal_group *, u32); | ||
91 | int core_tpg_post_addlun(struct se_portal_group *, struct se_lun *, | ||
92 | u32, void *); | ||
93 | struct se_lun *core_tpg_pre_dellun(struct se_portal_group *, u32, int *); | ||
94 | int core_tpg_post_dellun(struct se_portal_group *, struct se_lun *); | ||
95 | |||
96 | /* target_core_transport.c */ | ||
97 | extern struct kmem_cache *se_tmr_req_cache; | ||
98 | |||
99 | int init_se_kmem_caches(void); | ||
100 | void release_se_kmem_caches(void); | ||
101 | u32 scsi_get_new_index(scsi_index_t); | ||
102 | void transport_subsystem_check_init(void); | ||
103 | void transport_cmd_finish_abort(struct se_cmd *, int); | ||
104 | void __transport_remove_task_from_execute_queue(struct se_task *, | ||
105 | struct se_device *); | ||
106 | unsigned char *transport_dump_cmd_direction(struct se_cmd *); | ||
107 | void transport_dump_dev_state(struct se_device *, char *, int *); | ||
108 | void transport_dump_dev_info(struct se_device *, struct se_lun *, | ||
109 | unsigned long long, char *, int *); | ||
110 | void transport_dump_vpd_proto_id(struct t10_vpd *, unsigned char *, int); | ||
111 | int transport_dump_vpd_assoc(struct t10_vpd *, unsigned char *, int); | ||
112 | int transport_dump_vpd_ident_type(struct t10_vpd *, unsigned char *, int); | ||
113 | int transport_dump_vpd_ident(struct t10_vpd *, unsigned char *, int); | ||
114 | bool target_stop_task(struct se_task *task, unsigned long *flags); | ||
115 | int transport_clear_lun_from_sessions(struct se_lun *); | ||
116 | void transport_send_task_abort(struct se_cmd *); | ||
117 | |||
118 | /* target_core_stat.c */ | ||
119 | void target_stat_setup_dev_default_groups(struct se_subsystem_dev *); | ||
120 | void target_stat_setup_port_default_groups(struct se_lun *); | ||
121 | void target_stat_setup_mappedlun_default_groups(struct se_lun_acl *); | ||
122 | |||
123 | #endif /* TARGET_CORE_INTERNAL_H */ | ||
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c index 95dee7074aeb..429ad7291664 100644 --- a/drivers/target/target_core_pr.c +++ b/drivers/target/target_core_pr.c | |||
@@ -33,14 +33,11 @@ | |||
33 | #include <asm/unaligned.h> | 33 | #include <asm/unaligned.h> |
34 | 34 | ||
35 | #include <target/target_core_base.h> | 35 | #include <target/target_core_base.h> |
36 | #include <target/target_core_device.h> | 36 | #include <target/target_core_backend.h> |
37 | #include <target/target_core_tmr.h> | 37 | #include <target/target_core_fabric.h> |
38 | #include <target/target_core_tpg.h> | ||
39 | #include <target/target_core_transport.h> | ||
40 | #include <target/target_core_fabric_ops.h> | ||
41 | #include <target/target_core_configfs.h> | 38 | #include <target/target_core_configfs.h> |
42 | 39 | ||
43 | #include "target_core_hba.h" | 40 | #include "target_core_internal.h" |
44 | #include "target_core_pr.h" | 41 | #include "target_core_pr.h" |
45 | #include "target_core_ua.h" | 42 | #include "target_core_ua.h" |
46 | 43 | ||
@@ -2984,21 +2981,6 @@ static void core_scsi3_release_preempt_and_abort( | |||
2984 | } | 2981 | } |
2985 | } | 2982 | } |
2986 | 2983 | ||
2987 | int core_scsi3_check_cdb_abort_and_preempt( | ||
2988 | struct list_head *preempt_and_abort_list, | ||
2989 | struct se_cmd *cmd) | ||
2990 | { | ||
2991 | struct t10_pr_registration *pr_reg, *pr_reg_tmp; | ||
2992 | |||
2993 | list_for_each_entry_safe(pr_reg, pr_reg_tmp, preempt_and_abort_list, | ||
2994 | pr_reg_abort_list) { | ||
2995 | if (pr_reg->pr_res_key == cmd->pr_res_key) | ||
2996 | return 0; | ||
2997 | } | ||
2998 | |||
2999 | return 1; | ||
3000 | } | ||
3001 | |||
3002 | static int core_scsi3_pro_preempt( | 2984 | static int core_scsi3_pro_preempt( |
3003 | struct se_cmd *cmd, | 2985 | struct se_cmd *cmd, |
3004 | int type, | 2986 | int type, |
diff --git a/drivers/target/target_core_pr.h b/drivers/target/target_core_pr.h index b97f6940dd05..7a233feb7e99 100644 --- a/drivers/target/target_core_pr.h +++ b/drivers/target/target_core_pr.h | |||
@@ -60,8 +60,6 @@ extern void core_scsi3_free_pr_reg_from_nacl(struct se_device *, | |||
60 | struct se_node_acl *); | 60 | struct se_node_acl *); |
61 | extern void core_scsi3_free_all_registrations(struct se_device *); | 61 | extern void core_scsi3_free_all_registrations(struct se_device *); |
62 | extern unsigned char *core_scsi3_pr_dump_type(int); | 62 | extern unsigned char *core_scsi3_pr_dump_type(int); |
63 | extern int core_scsi3_check_cdb_abort_and_preempt(struct list_head *, | ||
64 | struct se_cmd *); | ||
65 | 63 | ||
66 | extern int target_scsi3_emulate_pr_in(struct se_task *task); | 64 | extern int target_scsi3_emulate_pr_in(struct se_task *task); |
67 | extern int target_scsi3_emulate_pr_out(struct se_task *task); | 65 | extern int target_scsi3_emulate_pr_out(struct se_task *task); |
diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c index 8b15e56b0384..d35467d42e12 100644 --- a/drivers/target/target_core_pscsi.c +++ b/drivers/target/target_core_pscsi.c | |||
@@ -44,8 +44,7 @@ | |||
44 | #include <scsi/scsi_tcq.h> | 44 | #include <scsi/scsi_tcq.h> |
45 | 45 | ||
46 | #include <target/target_core_base.h> | 46 | #include <target/target_core_base.h> |
47 | #include <target/target_core_device.h> | 47 | #include <target/target_core_backend.h> |
48 | #include <target/target_core_transport.h> | ||
49 | 48 | ||
50 | #include "target_core_pscsi.h" | 49 | #include "target_core_pscsi.h" |
51 | 50 | ||
@@ -105,7 +104,7 @@ static void pscsi_detach_hba(struct se_hba *hba) | |||
105 | 104 | ||
106 | static int pscsi_pmode_enable_hba(struct se_hba *hba, unsigned long mode_flag) | 105 | static int pscsi_pmode_enable_hba(struct se_hba *hba, unsigned long mode_flag) |
107 | { | 106 | { |
108 | struct pscsi_hba_virt *phv = (struct pscsi_hba_virt *)hba->hba_ptr; | 107 | struct pscsi_hba_virt *phv = hba->hba_ptr; |
109 | struct Scsi_Host *sh = phv->phv_lld_host; | 108 | struct Scsi_Host *sh = phv->phv_lld_host; |
110 | /* | 109 | /* |
111 | * Release the struct Scsi_Host | 110 | * Release the struct Scsi_Host |
@@ -351,7 +350,6 @@ static struct se_device *pscsi_add_device_to_list( | |||
351 | * scsi_device_put() and the pdv->pdv_sd cleared. | 350 | * scsi_device_put() and the pdv->pdv_sd cleared. |
352 | */ | 351 | */ |
353 | pdv->pdv_sd = sd; | 352 | pdv->pdv_sd = sd; |
354 | |||
355 | dev = transport_add_device_to_core_hba(hba, &pscsi_template, | 353 | dev = transport_add_device_to_core_hba(hba, &pscsi_template, |
356 | se_dev, dev_flags, pdv, | 354 | se_dev, dev_flags, pdv, |
357 | &dev_limits, NULL, NULL); | 355 | &dev_limits, NULL, NULL); |
@@ -406,7 +404,7 @@ static struct se_device *pscsi_create_type_disk( | |||
406 | __releases(sh->host_lock) | 404 | __releases(sh->host_lock) |
407 | { | 405 | { |
408 | struct se_device *dev; | 406 | struct se_device *dev; |
409 | struct pscsi_hba_virt *phv = (struct pscsi_hba_virt *)pdv->pdv_se_hba->hba_ptr; | 407 | struct pscsi_hba_virt *phv = pdv->pdv_se_hba->hba_ptr; |
410 | struct Scsi_Host *sh = sd->host; | 408 | struct Scsi_Host *sh = sd->host; |
411 | struct block_device *bd; | 409 | struct block_device *bd; |
412 | u32 dev_flags = 0; | 410 | u32 dev_flags = 0; |
@@ -454,7 +452,7 @@ static struct se_device *pscsi_create_type_rom( | |||
454 | __releases(sh->host_lock) | 452 | __releases(sh->host_lock) |
455 | { | 453 | { |
456 | struct se_device *dev; | 454 | struct se_device *dev; |
457 | struct pscsi_hba_virt *phv = (struct pscsi_hba_virt *)pdv->pdv_se_hba->hba_ptr; | 455 | struct pscsi_hba_virt *phv = pdv->pdv_se_hba->hba_ptr; |
458 | struct Scsi_Host *sh = sd->host; | 456 | struct Scsi_Host *sh = sd->host; |
459 | u32 dev_flags = 0; | 457 | u32 dev_flags = 0; |
460 | 458 | ||
@@ -489,7 +487,7 @@ static struct se_device *pscsi_create_type_other( | |||
489 | __releases(sh->host_lock) | 487 | __releases(sh->host_lock) |
490 | { | 488 | { |
491 | struct se_device *dev; | 489 | struct se_device *dev; |
492 | struct pscsi_hba_virt *phv = (struct pscsi_hba_virt *)pdv->pdv_se_hba->hba_ptr; | 490 | struct pscsi_hba_virt *phv = pdv->pdv_se_hba->hba_ptr; |
493 | struct Scsi_Host *sh = sd->host; | 491 | struct Scsi_Host *sh = sd->host; |
494 | u32 dev_flags = 0; | 492 | u32 dev_flags = 0; |
495 | 493 | ||
@@ -510,10 +508,10 @@ static struct se_device *pscsi_create_virtdevice( | |||
510 | struct se_subsystem_dev *se_dev, | 508 | struct se_subsystem_dev *se_dev, |
511 | void *p) | 509 | void *p) |
512 | { | 510 | { |
513 | struct pscsi_dev_virt *pdv = (struct pscsi_dev_virt *)p; | 511 | struct pscsi_dev_virt *pdv = p; |
514 | struct se_device *dev; | 512 | struct se_device *dev; |
515 | struct scsi_device *sd; | 513 | struct scsi_device *sd; |
516 | struct pscsi_hba_virt *phv = (struct pscsi_hba_virt *)hba->hba_ptr; | 514 | struct pscsi_hba_virt *phv = hba->hba_ptr; |
517 | struct Scsi_Host *sh = phv->phv_lld_host; | 515 | struct Scsi_Host *sh = phv->phv_lld_host; |
518 | int legacy_mode_enable = 0; | 516 | int legacy_mode_enable = 0; |
519 | 517 | ||
@@ -818,7 +816,7 @@ static ssize_t pscsi_set_configfs_dev_params(struct se_hba *hba, | |||
818 | 816 | ||
819 | orig = opts; | 817 | orig = opts; |
820 | 818 | ||
821 | while ((ptr = strsep(&opts, ",")) != NULL) { | 819 | while ((ptr = strsep(&opts, ",\n")) != NULL) { |
822 | if (!*ptr) | 820 | if (!*ptr) |
823 | continue; | 821 | continue; |
824 | 822 | ||
@@ -1144,7 +1142,7 @@ static unsigned char *pscsi_get_sense_buffer(struct se_task *task) | |||
1144 | { | 1142 | { |
1145 | struct pscsi_plugin_task *pt = PSCSI_TASK(task); | 1143 | struct pscsi_plugin_task *pt = PSCSI_TASK(task); |
1146 | 1144 | ||
1147 | return (unsigned char *)&pt->pscsi_sense[0]; | 1145 | return pt->pscsi_sense; |
1148 | } | 1146 | } |
1149 | 1147 | ||
1150 | /* pscsi_get_device_rev(): | 1148 | /* pscsi_get_device_rev(): |
diff --git a/drivers/target/target_core_rd.c b/drivers/target/target_core_rd.c index 02e51faa2f4e..8b68f7b82631 100644 --- a/drivers/target/target_core_rd.c +++ b/drivers/target/target_core_rd.c | |||
@@ -37,9 +37,7 @@ | |||
37 | #include <scsi/scsi_host.h> | 37 | #include <scsi/scsi_host.h> |
38 | 38 | ||
39 | #include <target/target_core_base.h> | 39 | #include <target/target_core_base.h> |
40 | #include <target/target_core_device.h> | 40 | #include <target/target_core_backend.h> |
41 | #include <target/target_core_transport.h> | ||
42 | #include <target/target_core_fabric_ops.h> | ||
43 | 41 | ||
44 | #include "target_core_rd.h" | 42 | #include "target_core_rd.h" |
45 | 43 | ||
@@ -474,7 +472,7 @@ static ssize_t rd_set_configfs_dev_params( | |||
474 | 472 | ||
475 | orig = opts; | 473 | orig = opts; |
476 | 474 | ||
477 | while ((ptr = strsep(&opts, ",")) != NULL) { | 475 | while ((ptr = strsep(&opts, ",\n")) != NULL) { |
478 | if (!*ptr) | 476 | if (!*ptr) |
479 | continue; | 477 | continue; |
480 | 478 | ||
diff --git a/drivers/target/target_core_stat.c b/drivers/target/target_core_stat.c index 874152aed94a..f8c2d2cc3431 100644 --- a/drivers/target/target_core_stat.c +++ b/drivers/target/target_core_stat.c | |||
@@ -43,12 +43,12 @@ | |||
43 | #include <scsi/scsi_host.h> | 43 | #include <scsi/scsi_host.h> |
44 | 44 | ||
45 | #include <target/target_core_base.h> | 45 | #include <target/target_core_base.h> |
46 | #include <target/target_core_transport.h> | 46 | #include <target/target_core_backend.h> |
47 | #include <target/target_core_fabric_ops.h> | 47 | #include <target/target_core_fabric.h> |
48 | #include <target/target_core_configfs.h> | 48 | #include <target/target_core_configfs.h> |
49 | #include <target/configfs_macros.h> | 49 | #include <target/configfs_macros.h> |
50 | 50 | ||
51 | #include "target_core_hba.h" | 51 | #include "target_core_internal.h" |
52 | 52 | ||
53 | #ifndef INITIAL_JIFFIES | 53 | #ifndef INITIAL_JIFFIES |
54 | #define INITIAL_JIFFIES ((unsigned long)(unsigned int) (-300*HZ)) | 54 | #define INITIAL_JIFFIES ((unsigned long)(unsigned int) (-300*HZ)) |
@@ -1755,8 +1755,7 @@ static ssize_t target_stat_scsi_att_intr_port_show_attr_port_ident( | |||
1755 | /* scsiAttIntrPortName+scsiAttIntrPortIdentifier */ | 1755 | /* scsiAttIntrPortName+scsiAttIntrPortIdentifier */ |
1756 | memset(buf, 0, 64); | 1756 | memset(buf, 0, 64); |
1757 | if (tpg->se_tpg_tfo->sess_get_initiator_sid != NULL) | 1757 | if (tpg->se_tpg_tfo->sess_get_initiator_sid != NULL) |
1758 | tpg->se_tpg_tfo->sess_get_initiator_sid(se_sess, | 1758 | tpg->se_tpg_tfo->sess_get_initiator_sid(se_sess, buf, 64); |
1759 | (unsigned char *)&buf[0], 64); | ||
1760 | 1759 | ||
1761 | ret = snprintf(page, PAGE_SIZE, "%s+i+%s\n", nacl->initiatorname, buf); | 1760 | ret = snprintf(page, PAGE_SIZE, "%s+i+%s\n", nacl->initiatorname, buf); |
1762 | spin_unlock_irq(&nacl->nacl_sess_lock); | 1761 | spin_unlock_irq(&nacl->nacl_sess_lock); |
diff --git a/drivers/target/target_core_stat.h b/drivers/target/target_core_stat.h deleted file mode 100644 index 86c252f9ea47..000000000000 --- a/drivers/target/target_core_stat.h +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | #ifndef TARGET_CORE_STAT_H | ||
2 | #define TARGET_CORE_STAT_H | ||
3 | |||
4 | extern void target_stat_setup_dev_default_groups(struct se_subsystem_dev *); | ||
5 | extern void target_stat_setup_port_default_groups(struct se_lun *); | ||
6 | extern void target_stat_setup_mappedlun_default_groups(struct se_lun_acl *); | ||
7 | |||
8 | #endif /*** TARGET_CORE_STAT_H ***/ | ||
diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c index 684522805a1f..dcb0618c9388 100644 --- a/drivers/target/target_core_tmr.c +++ b/drivers/target/target_core_tmr.c | |||
@@ -32,12 +32,11 @@ | |||
32 | #include <scsi/scsi_cmnd.h> | 32 | #include <scsi/scsi_cmnd.h> |
33 | 33 | ||
34 | #include <target/target_core_base.h> | 34 | #include <target/target_core_base.h> |
35 | #include <target/target_core_device.h> | 35 | #include <target/target_core_backend.h> |
36 | #include <target/target_core_tmr.h> | 36 | #include <target/target_core_fabric.h> |
37 | #include <target/target_core_transport.h> | ||
38 | #include <target/target_core_fabric_ops.h> | ||
39 | #include <target/target_core_configfs.h> | 37 | #include <target/target_core_configfs.h> |
40 | 38 | ||
39 | #include "target_core_internal.h" | ||
41 | #include "target_core_alua.h" | 40 | #include "target_core_alua.h" |
42 | #include "target_core_pr.h" | 41 | #include "target_core_pr.h" |
43 | 42 | ||
@@ -101,6 +100,21 @@ static void core_tmr_handle_tas_abort( | |||
101 | transport_cmd_finish_abort(cmd, 0); | 100 | transport_cmd_finish_abort(cmd, 0); |
102 | } | 101 | } |
103 | 102 | ||
103 | static int target_check_cdb_and_preempt(struct list_head *list, | ||
104 | struct se_cmd *cmd) | ||
105 | { | ||
106 | struct t10_pr_registration *reg; | ||
107 | |||
108 | if (!list) | ||
109 | return 0; | ||
110 | list_for_each_entry(reg, list, pr_reg_abort_list) { | ||
111 | if (reg->pr_res_key == cmd->pr_res_key) | ||
112 | return 0; | ||
113 | } | ||
114 | |||
115 | return 1; | ||
116 | } | ||
117 | |||
104 | static void core_tmr_drain_tmr_list( | 118 | static void core_tmr_drain_tmr_list( |
105 | struct se_device *dev, | 119 | struct se_device *dev, |
106 | struct se_tmr_req *tmr, | 120 | struct se_tmr_req *tmr, |
@@ -132,9 +146,7 @@ static void core_tmr_drain_tmr_list( | |||
132 | * parameter (eg: for PROUT PREEMPT_AND_ABORT service action | 146 | * parameter (eg: for PROUT PREEMPT_AND_ABORT service action |
133 | * skip non regisration key matching TMRs. | 147 | * skip non regisration key matching TMRs. |
134 | */ | 148 | */ |
135 | if (preempt_and_abort_list && | 149 | if (target_check_cdb_and_preempt(preempt_and_abort_list, cmd)) |
136 | (core_scsi3_check_cdb_abort_and_preempt( | ||
137 | preempt_and_abort_list, cmd) != 0)) | ||
138 | continue; | 150 | continue; |
139 | 151 | ||
140 | spin_lock(&cmd->t_state_lock); | 152 | spin_lock(&cmd->t_state_lock); |
@@ -211,9 +223,7 @@ static void core_tmr_drain_task_list( | |||
211 | * For PREEMPT_AND_ABORT usage, only process commands | 223 | * For PREEMPT_AND_ABORT usage, only process commands |
212 | * with a matching reservation key. | 224 | * with a matching reservation key. |
213 | */ | 225 | */ |
214 | if (preempt_and_abort_list && | 226 | if (target_check_cdb_and_preempt(preempt_and_abort_list, cmd)) |
215 | (core_scsi3_check_cdb_abort_and_preempt( | ||
216 | preempt_and_abort_list, cmd) != 0)) | ||
217 | continue; | 227 | continue; |
218 | /* | 228 | /* |
219 | * Not aborting PROUT PREEMPT_AND_ABORT CDB.. | 229 | * Not aborting PROUT PREEMPT_AND_ABORT CDB.. |
@@ -222,7 +232,7 @@ static void core_tmr_drain_task_list( | |||
222 | continue; | 232 | continue; |
223 | 233 | ||
224 | list_move_tail(&task->t_state_list, &drain_task_list); | 234 | list_move_tail(&task->t_state_list, &drain_task_list); |
225 | atomic_set(&task->task_state_active, 0); | 235 | task->t_state_active = false; |
226 | /* | 236 | /* |
227 | * Remove from task execute list before processing drain_task_list | 237 | * Remove from task execute list before processing drain_task_list |
228 | */ | 238 | */ |
@@ -321,9 +331,7 @@ static void core_tmr_drain_cmd_list( | |||
321 | * For PREEMPT_AND_ABORT usage, only process commands | 331 | * For PREEMPT_AND_ABORT usage, only process commands |
322 | * with a matching reservation key. | 332 | * with a matching reservation key. |
323 | */ | 333 | */ |
324 | if (preempt_and_abort_list && | 334 | if (target_check_cdb_and_preempt(preempt_and_abort_list, cmd)) |
325 | (core_scsi3_check_cdb_abort_and_preempt( | ||
326 | preempt_and_abort_list, cmd) != 0)) | ||
327 | continue; | 335 | continue; |
328 | /* | 336 | /* |
329 | * Not aborting PROUT PREEMPT_AND_ABORT CDB.. | 337 | * Not aborting PROUT PREEMPT_AND_ABORT CDB.. |
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c index 8ddd133025b9..b7668029bb31 100644 --- a/drivers/target/target_core_tpg.c +++ b/drivers/target/target_core_tpg.c | |||
@@ -39,13 +39,10 @@ | |||
39 | #include <scsi/scsi_cmnd.h> | 39 | #include <scsi/scsi_cmnd.h> |
40 | 40 | ||
41 | #include <target/target_core_base.h> | 41 | #include <target/target_core_base.h> |
42 | #include <target/target_core_device.h> | 42 | #include <target/target_core_backend.h> |
43 | #include <target/target_core_tpg.h> | 43 | #include <target/target_core_fabric.h> |
44 | #include <target/target_core_transport.h> | ||
45 | #include <target/target_core_fabric_ops.h> | ||
46 | 44 | ||
47 | #include "target_core_hba.h" | 45 | #include "target_core_internal.h" |
48 | #include "target_core_stat.h" | ||
49 | 46 | ||
50 | extern struct se_device *g_lun0_dev; | 47 | extern struct se_device *g_lun0_dev; |
51 | 48 | ||
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 0257658e2e3e..d3ddd1361949 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c | |||
@@ -45,16 +45,12 @@ | |||
45 | #include <scsi/scsi_tcq.h> | 45 | #include <scsi/scsi_tcq.h> |
46 | 46 | ||
47 | #include <target/target_core_base.h> | 47 | #include <target/target_core_base.h> |
48 | #include <target/target_core_device.h> | 48 | #include <target/target_core_backend.h> |
49 | #include <target/target_core_tmr.h> | 49 | #include <target/target_core_fabric.h> |
50 | #include <target/target_core_tpg.h> | ||
51 | #include <target/target_core_transport.h> | ||
52 | #include <target/target_core_fabric_ops.h> | ||
53 | #include <target/target_core_configfs.h> | 50 | #include <target/target_core_configfs.h> |
54 | 51 | ||
52 | #include "target_core_internal.h" | ||
55 | #include "target_core_alua.h" | 53 | #include "target_core_alua.h" |
56 | #include "target_core_cdb.h" | ||
57 | #include "target_core_hba.h" | ||
58 | #include "target_core_pr.h" | 54 | #include "target_core_pr.h" |
59 | #include "target_core_ua.h" | 55 | #include "target_core_ua.h" |
60 | 56 | ||
@@ -72,7 +68,7 @@ struct kmem_cache *t10_alua_tg_pt_gp_mem_cache; | |||
72 | 68 | ||
73 | static int transport_generic_write_pending(struct se_cmd *); | 69 | static int transport_generic_write_pending(struct se_cmd *); |
74 | static int transport_processing_thread(void *param); | 70 | static int transport_processing_thread(void *param); |
75 | static int __transport_execute_tasks(struct se_device *dev); | 71 | static int __transport_execute_tasks(struct se_device *dev, struct se_cmd *); |
76 | static void transport_complete_task_attr(struct se_cmd *cmd); | 72 | static void transport_complete_task_attr(struct se_cmd *cmd); |
77 | static void transport_handle_queue_full(struct se_cmd *cmd, | 73 | static void transport_handle_queue_full(struct se_cmd *cmd, |
78 | struct se_device *dev); | 74 | struct se_device *dev); |
@@ -212,14 +208,13 @@ u32 scsi_get_new_index(scsi_index_t type) | |||
212 | return new_index; | 208 | return new_index; |
213 | } | 209 | } |
214 | 210 | ||
215 | void transport_init_queue_obj(struct se_queue_obj *qobj) | 211 | static void transport_init_queue_obj(struct se_queue_obj *qobj) |
216 | { | 212 | { |
217 | atomic_set(&qobj->queue_cnt, 0); | 213 | atomic_set(&qobj->queue_cnt, 0); |
218 | INIT_LIST_HEAD(&qobj->qobj_list); | 214 | INIT_LIST_HEAD(&qobj->qobj_list); |
219 | init_waitqueue_head(&qobj->thread_wq); | 215 | init_waitqueue_head(&qobj->thread_wq); |
220 | spin_lock_init(&qobj->cmd_queue_lock); | 216 | spin_lock_init(&qobj->cmd_queue_lock); |
221 | } | 217 | } |
222 | EXPORT_SYMBOL(transport_init_queue_obj); | ||
223 | 218 | ||
224 | void transport_subsystem_check_init(void) | 219 | void transport_subsystem_check_init(void) |
225 | { | 220 | { |
@@ -426,18 +421,18 @@ static void transport_all_task_dev_remove_state(struct se_cmd *cmd) | |||
426 | if (task->task_flags & TF_ACTIVE) | 421 | if (task->task_flags & TF_ACTIVE) |
427 | continue; | 422 | continue; |
428 | 423 | ||
429 | if (!atomic_read(&task->task_state_active)) | ||
430 | continue; | ||
431 | |||
432 | spin_lock_irqsave(&dev->execute_task_lock, flags); | 424 | spin_lock_irqsave(&dev->execute_task_lock, flags); |
433 | list_del(&task->t_state_list); | 425 | if (task->t_state_active) { |
434 | pr_debug("Removed ITT: 0x%08x dev: %p task[%p]\n", | 426 | pr_debug("Removed ITT: 0x%08x dev: %p task[%p]\n", |
435 | cmd->se_tfo->get_task_tag(cmd), dev, task); | 427 | cmd->se_tfo->get_task_tag(cmd), dev, task); |
436 | spin_unlock_irqrestore(&dev->execute_task_lock, flags); | ||
437 | 428 | ||
438 | atomic_set(&task->task_state_active, 0); | 429 | list_del(&task->t_state_list); |
439 | atomic_dec(&cmd->t_task_cdbs_ex_left); | 430 | atomic_dec(&cmd->t_task_cdbs_ex_left); |
431 | task->t_state_active = false; | ||
432 | } | ||
433 | spin_unlock_irqrestore(&dev->execute_task_lock, flags); | ||
440 | } | 434 | } |
435 | |||
441 | } | 436 | } |
442 | 437 | ||
443 | /* transport_cmd_check_stop(): | 438 | /* transport_cmd_check_stop(): |
@@ -696,12 +691,6 @@ void transport_complete_task(struct se_task *task, int success) | |||
696 | struct se_cmd *cmd = task->task_se_cmd; | 691 | struct se_cmd *cmd = task->task_se_cmd; |
697 | struct se_device *dev = cmd->se_dev; | 692 | struct se_device *dev = cmd->se_dev; |
698 | unsigned long flags; | 693 | unsigned long flags; |
699 | #if 0 | ||
700 | pr_debug("task: %p CDB: 0x%02x obj_ptr: %p\n", task, | ||
701 | cmd->t_task_cdb[0], dev); | ||
702 | #endif | ||
703 | if (dev) | ||
704 | atomic_inc(&dev->depth_left); | ||
705 | 694 | ||
706 | spin_lock_irqsave(&cmd->t_state_lock, flags); | 695 | spin_lock_irqsave(&cmd->t_state_lock, flags); |
707 | task->task_flags &= ~TF_ACTIVE; | 696 | task->task_flags &= ~TF_ACTIVE; |
@@ -714,7 +703,7 @@ void transport_complete_task(struct se_task *task, int success) | |||
714 | if (dev && dev->transport->transport_complete) { | 703 | if (dev && dev->transport->transport_complete) { |
715 | if (dev->transport->transport_complete(task) != 0) { | 704 | if (dev->transport->transport_complete(task) != 0) { |
716 | cmd->se_cmd_flags |= SCF_TRANSPORT_TASK_SENSE; | 705 | cmd->se_cmd_flags |= SCF_TRANSPORT_TASK_SENSE; |
717 | task->task_sense = 1; | 706 | task->task_flags |= TF_HAS_SENSE; |
718 | success = 1; | 707 | success = 1; |
719 | } | 708 | } |
720 | } | 709 | } |
@@ -743,13 +732,7 @@ void transport_complete_task(struct se_task *task, int success) | |||
743 | } | 732 | } |
744 | 733 | ||
745 | if (cmd->t_tasks_failed) { | 734 | if (cmd->t_tasks_failed) { |
746 | if (!task->task_error_status) { | 735 | cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
747 | task->task_error_status = | ||
748 | TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; | ||
749 | cmd->scsi_sense_reason = | ||
750 | TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; | ||
751 | } | ||
752 | |||
753 | INIT_WORK(&cmd->work, target_complete_failure_work); | 736 | INIT_WORK(&cmd->work, target_complete_failure_work); |
754 | } else { | 737 | } else { |
755 | atomic_set(&cmd->t_transport_complete, 1); | 738 | atomic_set(&cmd->t_transport_complete, 1); |
@@ -824,7 +807,7 @@ static void __transport_add_task_to_execute_queue( | |||
824 | head_of_queue = transport_add_task_check_sam_attr(task, task_prev, dev); | 807 | head_of_queue = transport_add_task_check_sam_attr(task, task_prev, dev); |
825 | atomic_inc(&dev->execute_tasks); | 808 | atomic_inc(&dev->execute_tasks); |
826 | 809 | ||
827 | if (atomic_read(&task->task_state_active)) | 810 | if (task->t_state_active) |
828 | return; | 811 | return; |
829 | /* | 812 | /* |
830 | * Determine if this task needs to go to HEAD_OF_QUEUE for the | 813 | * Determine if this task needs to go to HEAD_OF_QUEUE for the |
@@ -838,7 +821,7 @@ static void __transport_add_task_to_execute_queue( | |||
838 | else | 821 | else |
839 | list_add_tail(&task->t_state_list, &dev->state_task_list); | 822 | list_add_tail(&task->t_state_list, &dev->state_task_list); |
840 | 823 | ||
841 | atomic_set(&task->task_state_active, 1); | 824 | task->t_state_active = true; |
842 | 825 | ||
843 | pr_debug("Added ITT: 0x%08x task[%p] to dev: %p\n", | 826 | pr_debug("Added ITT: 0x%08x task[%p] to dev: %p\n", |
844 | task->task_se_cmd->se_tfo->get_task_tag(task->task_se_cmd), | 827 | task->task_se_cmd->se_tfo->get_task_tag(task->task_se_cmd), |
@@ -853,29 +836,26 @@ static void transport_add_tasks_to_state_queue(struct se_cmd *cmd) | |||
853 | 836 | ||
854 | spin_lock_irqsave(&cmd->t_state_lock, flags); | 837 | spin_lock_irqsave(&cmd->t_state_lock, flags); |
855 | list_for_each_entry(task, &cmd->t_task_list, t_list) { | 838 | list_for_each_entry(task, &cmd->t_task_list, t_list) { |
856 | if (atomic_read(&task->task_state_active)) | ||
857 | continue; | ||
858 | |||
859 | spin_lock(&dev->execute_task_lock); | 839 | spin_lock(&dev->execute_task_lock); |
860 | list_add_tail(&task->t_state_list, &dev->state_task_list); | 840 | if (!task->t_state_active) { |
861 | atomic_set(&task->task_state_active, 1); | 841 | list_add_tail(&task->t_state_list, |
862 | 842 | &dev->state_task_list); | |
863 | pr_debug("Added ITT: 0x%08x task[%p] to dev: %p\n", | 843 | task->t_state_active = true; |
864 | task->task_se_cmd->se_tfo->get_task_tag( | 844 | |
865 | task->task_se_cmd), task, dev); | 845 | pr_debug("Added ITT: 0x%08x task[%p] to dev: %p\n", |
866 | 846 | task->task_se_cmd->se_tfo->get_task_tag( | |
847 | task->task_se_cmd), task, dev); | ||
848 | } | ||
867 | spin_unlock(&dev->execute_task_lock); | 849 | spin_unlock(&dev->execute_task_lock); |
868 | } | 850 | } |
869 | spin_unlock_irqrestore(&cmd->t_state_lock, flags); | 851 | spin_unlock_irqrestore(&cmd->t_state_lock, flags); |
870 | } | 852 | } |
871 | 853 | ||
872 | static void transport_add_tasks_from_cmd(struct se_cmd *cmd) | 854 | static void __transport_add_tasks_from_cmd(struct se_cmd *cmd) |
873 | { | 855 | { |
874 | struct se_device *dev = cmd->se_dev; | 856 | struct se_device *dev = cmd->se_dev; |
875 | struct se_task *task, *task_prev = NULL; | 857 | struct se_task *task, *task_prev = NULL; |
876 | unsigned long flags; | ||
877 | 858 | ||
878 | spin_lock_irqsave(&dev->execute_task_lock, flags); | ||
879 | list_for_each_entry(task, &cmd->t_task_list, t_list) { | 859 | list_for_each_entry(task, &cmd->t_task_list, t_list) { |
880 | if (!list_empty(&task->t_execute_list)) | 860 | if (!list_empty(&task->t_execute_list)) |
881 | continue; | 861 | continue; |
@@ -886,6 +866,15 @@ static void transport_add_tasks_from_cmd(struct se_cmd *cmd) | |||
886 | __transport_add_task_to_execute_queue(task, task_prev, dev); | 866 | __transport_add_task_to_execute_queue(task, task_prev, dev); |
887 | task_prev = task; | 867 | task_prev = task; |
888 | } | 868 | } |
869 | } | ||
870 | |||
871 | static void transport_add_tasks_from_cmd(struct se_cmd *cmd) | ||
872 | { | ||
873 | unsigned long flags; | ||
874 | struct se_device *dev = cmd->se_dev; | ||
875 | |||
876 | spin_lock_irqsave(&dev->execute_task_lock, flags); | ||
877 | __transport_add_tasks_from_cmd(cmd); | ||
889 | spin_unlock_irqrestore(&dev->execute_task_lock, flags); | 878 | spin_unlock_irqrestore(&dev->execute_task_lock, flags); |
890 | } | 879 | } |
891 | 880 | ||
@@ -896,7 +885,7 @@ void __transport_remove_task_from_execute_queue(struct se_task *task, | |||
896 | atomic_dec(&dev->execute_tasks); | 885 | atomic_dec(&dev->execute_tasks); |
897 | } | 886 | } |
898 | 887 | ||
899 | void transport_remove_task_from_execute_queue( | 888 | static void transport_remove_task_from_execute_queue( |
900 | struct se_task *task, | 889 | struct se_task *task, |
901 | struct se_device *dev) | 890 | struct se_device *dev) |
902 | { | 891 | { |
@@ -983,9 +972,8 @@ void transport_dump_dev_state( | |||
983 | break; | 972 | break; |
984 | } | 973 | } |
985 | 974 | ||
986 | *bl += sprintf(b + *bl, " Execute/Left/Max Queue Depth: %d/%d/%d", | 975 | *bl += sprintf(b + *bl, " Execute/Max Queue Depth: %d/%d", |
987 | atomic_read(&dev->execute_tasks), atomic_read(&dev->depth_left), | 976 | atomic_read(&dev->execute_tasks), dev->queue_depth); |
988 | dev->queue_depth); | ||
989 | *bl += sprintf(b + *bl, " SectorSize: %u MaxSectors: %u\n", | 977 | *bl += sprintf(b + *bl, " SectorSize: %u MaxSectors: %u\n", |
990 | dev->se_sub_dev->se_dev_attrib.block_size, dev->se_sub_dev->se_dev_attrib.max_sectors); | 978 | dev->se_sub_dev->se_dev_attrib.block_size, dev->se_sub_dev->se_dev_attrib.max_sectors); |
991 | *bl += sprintf(b + *bl, " "); | 979 | *bl += sprintf(b + *bl, " "); |
@@ -1340,9 +1328,6 @@ struct se_device *transport_add_device_to_core_hba( | |||
1340 | spin_lock_init(&dev->se_port_lock); | 1328 | spin_lock_init(&dev->se_port_lock); |
1341 | spin_lock_init(&dev->se_tmr_lock); | 1329 | spin_lock_init(&dev->se_tmr_lock); |
1342 | spin_lock_init(&dev->qf_cmd_lock); | 1330 | spin_lock_init(&dev->qf_cmd_lock); |
1343 | |||
1344 | dev->queue_depth = dev_limits->queue_depth; | ||
1345 | atomic_set(&dev->depth_left, dev->queue_depth); | ||
1346 | atomic_set(&dev->dev_ordered_id, 0); | 1331 | atomic_set(&dev->dev_ordered_id, 0); |
1347 | 1332 | ||
1348 | se_dev_set_default_attribs(dev, dev_limits); | 1333 | se_dev_set_default_attribs(dev, dev_limits); |
@@ -1654,6 +1639,80 @@ int transport_handle_cdb_direct( | |||
1654 | } | 1639 | } |
1655 | EXPORT_SYMBOL(transport_handle_cdb_direct); | 1640 | EXPORT_SYMBOL(transport_handle_cdb_direct); |
1656 | 1641 | ||
1642 | /** | ||
1643 | * target_submit_cmd - lookup unpacked lun and submit uninitialized se_cmd | ||
1644 | * | ||
1645 | * @se_cmd: command descriptor to submit | ||
1646 | * @se_sess: associated se_sess for endpoint | ||
1647 | * @cdb: pointer to SCSI CDB | ||
1648 | * @sense: pointer to SCSI sense buffer | ||
1649 | * @unpacked_lun: unpacked LUN to reference for struct se_lun | ||
1650 | * @data_length: fabric expected data transfer length | ||
1651 | * @task_addr: SAM task attribute | ||
1652 | * @data_dir: DMA data direction | ||
1653 | * @flags: flags for command submission from target_sc_flags_tables | ||
1654 | * | ||
1655 | * This may only be called from process context, and also currently | ||
1656 | * assumes internal allocation of fabric payload buffer by target-core. | ||
1657 | **/ | ||
1658 | int target_submit_cmd(struct se_cmd *se_cmd, struct se_session *se_sess, | ||
1659 | unsigned char *cdb, unsigned char *sense, u32 unpacked_lun, | ||
1660 | u32 data_length, int task_attr, int data_dir, int flags) | ||
1661 | { | ||
1662 | struct se_portal_group *se_tpg; | ||
1663 | int rc; | ||
1664 | |||
1665 | se_tpg = se_sess->se_tpg; | ||
1666 | BUG_ON(!se_tpg); | ||
1667 | BUG_ON(se_cmd->se_tfo || se_cmd->se_sess); | ||
1668 | BUG_ON(in_interrupt()); | ||
1669 | /* | ||
1670 | * Initialize se_cmd for target operation. From this point | ||
1671 | * exceptions are handled by sending exception status via | ||
1672 | * target_core_fabric_ops->queue_status() callback | ||
1673 | */ | ||
1674 | transport_init_se_cmd(se_cmd, se_tpg->se_tpg_tfo, se_sess, | ||
1675 | data_length, data_dir, task_attr, sense); | ||
1676 | /* | ||
1677 | * Obtain struct se_cmd->cmd_kref reference and add new cmd to | ||
1678 | * se_sess->sess_cmd_list. A second kref_get here is necessary | ||
1679 | * for fabrics using TARGET_SCF_ACK_KREF that expect a second | ||
1680 | * kref_put() to happen during fabric packet acknowledgement. | ||
1681 | */ | ||
1682 | target_get_sess_cmd(se_sess, se_cmd, (flags & TARGET_SCF_ACK_KREF)); | ||
1683 | /* | ||
1684 | * Signal bidirectional data payloads to target-core | ||
1685 | */ | ||
1686 | if (flags & TARGET_SCF_BIDI_OP) | ||
1687 | se_cmd->se_cmd_flags |= SCF_BIDI; | ||
1688 | /* | ||
1689 | * Locate se_lun pointer and attach it to struct se_cmd | ||
1690 | */ | ||
1691 | if (transport_lookup_cmd_lun(se_cmd, unpacked_lun) < 0) | ||
1692 | goto out_check_cond; | ||
1693 | /* | ||
1694 | * Sanitize CDBs via transport_generic_cmd_sequencer() and | ||
1695 | * allocate the necessary tasks to complete the received CDB+data | ||
1696 | */ | ||
1697 | rc = transport_generic_allocate_tasks(se_cmd, cdb); | ||
1698 | if (rc != 0) | ||
1699 | goto out_check_cond; | ||
1700 | /* | ||
1701 | * Dispatch se_cmd descriptor to se_lun->lun_se_dev backend | ||
1702 | * for immediate execution of READs, otherwise wait for | ||
1703 | * transport_generic_handle_data() to be called for WRITEs | ||
1704 | * when fabric has filled the incoming buffer. | ||
1705 | */ | ||
1706 | transport_handle_cdb_direct(se_cmd); | ||
1707 | return 0; | ||
1708 | |||
1709 | out_check_cond: | ||
1710 | transport_send_check_condition_and_sense(se_cmd, | ||
1711 | se_cmd->scsi_sense_reason, 0); | ||
1712 | return 0; | ||
1713 | } | ||
1714 | EXPORT_SYMBOL(target_submit_cmd); | ||
1715 | |||
1657 | /* | 1716 | /* |
1658 | * Used by fabric module frontends defining a TFO->new_cmd_map() caller | 1717 | * Used by fabric module frontends defining a TFO->new_cmd_map() caller |
1659 | * to queue up a newly setup se_cmd w/ TRANSPORT_NEW_CMD_MAP in order to | 1718 | * to queue up a newly setup se_cmd w/ TRANSPORT_NEW_CMD_MAP in order to |
@@ -1920,18 +1979,6 @@ static void transport_set_supported_SAM_opcode(struct se_cmd *se_cmd) | |||
1920 | spin_unlock_irqrestore(&se_cmd->t_state_lock, flags); | 1979 | spin_unlock_irqrestore(&se_cmd->t_state_lock, flags); |
1921 | } | 1980 | } |
1922 | 1981 | ||
1923 | static inline int transport_tcq_window_closed(struct se_device *dev) | ||
1924 | { | ||
1925 | if (dev->dev_tcq_window_closed++ < | ||
1926 | PYX_TRANSPORT_WINDOW_CLOSED_THRESHOLD) { | ||
1927 | msleep(PYX_TRANSPORT_WINDOW_CLOSED_WAIT_SHORT); | ||
1928 | } else | ||
1929 | msleep(PYX_TRANSPORT_WINDOW_CLOSED_WAIT_LONG); | ||
1930 | |||
1931 | wake_up_interruptible(&dev->dev_queue_obj.thread_wq); | ||
1932 | return 0; | ||
1933 | } | ||
1934 | |||
1935 | /* | 1982 | /* |
1936 | * Called from Fabric Module context from transport_execute_tasks() | 1983 | * Called from Fabric Module context from transport_execute_tasks() |
1937 | * | 1984 | * |
@@ -2014,13 +2061,7 @@ static inline int transport_execute_task_attr(struct se_cmd *cmd) | |||
2014 | static int transport_execute_tasks(struct se_cmd *cmd) | 2061 | static int transport_execute_tasks(struct se_cmd *cmd) |
2015 | { | 2062 | { |
2016 | int add_tasks; | 2063 | int add_tasks; |
2017 | 2064 | struct se_device *se_dev = cmd->se_dev; | |
2018 | if (se_dev_check_online(cmd->se_dev) != 0) { | ||
2019 | cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; | ||
2020 | transport_generic_request_failure(cmd); | ||
2021 | return 0; | ||
2022 | } | ||
2023 | |||
2024 | /* | 2065 | /* |
2025 | * Call transport_cmd_check_stop() to see if a fabric exception | 2066 | * Call transport_cmd_check_stop() to see if a fabric exception |
2026 | * has occurred that prevents execution. | 2067 | * has occurred that prevents execution. |
@@ -2034,19 +2075,16 @@ static int transport_execute_tasks(struct se_cmd *cmd) | |||
2034 | if (!add_tasks) | 2075 | if (!add_tasks) |
2035 | goto execute_tasks; | 2076 | goto execute_tasks; |
2036 | /* | 2077 | /* |
2037 | * This calls transport_add_tasks_from_cmd() to handle | 2078 | * __transport_execute_tasks() -> __transport_add_tasks_from_cmd() |
2038 | * HEAD_OF_QUEUE ordering for SAM Task Attribute emulation | 2079 | * adds associated se_tasks while holding dev->execute_task_lock |
2039 | * (if enabled) in __transport_add_task_to_execute_queue() and | 2080 | * before I/O dispath to avoid a double spinlock access. |
2040 | * transport_add_task_check_sam_attr(). | ||
2041 | */ | 2081 | */ |
2042 | transport_add_tasks_from_cmd(cmd); | 2082 | __transport_execute_tasks(se_dev, cmd); |
2083 | return 0; | ||
2043 | } | 2084 | } |
2044 | /* | 2085 | |
2045 | * Kick the execution queue for the cmd associated struct se_device | ||
2046 | * storage object. | ||
2047 | */ | ||
2048 | execute_tasks: | 2086 | execute_tasks: |
2049 | __transport_execute_tasks(cmd->se_dev); | 2087 | __transport_execute_tasks(se_dev, NULL); |
2050 | return 0; | 2088 | return 0; |
2051 | } | 2089 | } |
2052 | 2090 | ||
@@ -2056,24 +2094,18 @@ execute_tasks: | |||
2056 | * | 2094 | * |
2057 | * Called from transport_processing_thread() | 2095 | * Called from transport_processing_thread() |
2058 | */ | 2096 | */ |
2059 | static int __transport_execute_tasks(struct se_device *dev) | 2097 | static int __transport_execute_tasks(struct se_device *dev, struct se_cmd *new_cmd) |
2060 | { | 2098 | { |
2061 | int error; | 2099 | int error; |
2062 | struct se_cmd *cmd = NULL; | 2100 | struct se_cmd *cmd = NULL; |
2063 | struct se_task *task = NULL; | 2101 | struct se_task *task = NULL; |
2064 | unsigned long flags; | 2102 | unsigned long flags; |
2065 | 2103 | ||
2066 | /* | ||
2067 | * Check if there is enough room in the device and HBA queue to send | ||
2068 | * struct se_tasks to the selected transport. | ||
2069 | */ | ||
2070 | check_depth: | 2104 | check_depth: |
2071 | if (!atomic_read(&dev->depth_left)) | ||
2072 | return transport_tcq_window_closed(dev); | ||
2073 | |||
2074 | dev->dev_tcq_window_closed = 0; | ||
2075 | |||
2076 | spin_lock_irq(&dev->execute_task_lock); | 2105 | spin_lock_irq(&dev->execute_task_lock); |
2106 | if (new_cmd != NULL) | ||
2107 | __transport_add_tasks_from_cmd(new_cmd); | ||
2108 | |||
2077 | if (list_empty(&dev->execute_task_list)) { | 2109 | if (list_empty(&dev->execute_task_list)) { |
2078 | spin_unlock_irq(&dev->execute_task_lock); | 2110 | spin_unlock_irq(&dev->execute_task_lock); |
2079 | return 0; | 2111 | return 0; |
@@ -2083,10 +2115,7 @@ check_depth: | |||
2083 | __transport_remove_task_from_execute_queue(task, dev); | 2115 | __transport_remove_task_from_execute_queue(task, dev); |
2084 | spin_unlock_irq(&dev->execute_task_lock); | 2116 | spin_unlock_irq(&dev->execute_task_lock); |
2085 | 2117 | ||
2086 | atomic_dec(&dev->depth_left); | ||
2087 | |||
2088 | cmd = task->task_se_cmd; | 2118 | cmd = task->task_se_cmd; |
2089 | |||
2090 | spin_lock_irqsave(&cmd->t_state_lock, flags); | 2119 | spin_lock_irqsave(&cmd->t_state_lock, flags); |
2091 | task->task_flags |= (TF_ACTIVE | TF_SENT); | 2120 | task->task_flags |= (TF_ACTIVE | TF_SENT); |
2092 | atomic_inc(&cmd->t_task_cdbs_sent); | 2121 | atomic_inc(&cmd->t_task_cdbs_sent); |
@@ -2107,10 +2136,10 @@ check_depth: | |||
2107 | spin_unlock_irqrestore(&cmd->t_state_lock, flags); | 2136 | spin_unlock_irqrestore(&cmd->t_state_lock, flags); |
2108 | atomic_set(&cmd->t_transport_sent, 0); | 2137 | atomic_set(&cmd->t_transport_sent, 0); |
2109 | transport_stop_tasks_for_cmd(cmd); | 2138 | transport_stop_tasks_for_cmd(cmd); |
2110 | atomic_inc(&dev->depth_left); | ||
2111 | transport_generic_request_failure(cmd); | 2139 | transport_generic_request_failure(cmd); |
2112 | } | 2140 | } |
2113 | 2141 | ||
2142 | new_cmd = NULL; | ||
2114 | goto check_depth; | 2143 | goto check_depth; |
2115 | 2144 | ||
2116 | return 0; | 2145 | return 0; |
@@ -2351,7 +2380,7 @@ static int transport_get_sense_data(struct se_cmd *cmd) | |||
2351 | 2380 | ||
2352 | list_for_each_entry_safe(task, task_tmp, | 2381 | list_for_each_entry_safe(task, task_tmp, |
2353 | &cmd->t_task_list, t_list) { | 2382 | &cmd->t_task_list, t_list) { |
2354 | if (!task->task_sense) | 2383 | if (!(task->task_flags & TF_HAS_SENSE)) |
2355 | continue; | 2384 | continue; |
2356 | 2385 | ||
2357 | if (!dev->transport->get_sense_buffer) { | 2386 | if (!dev->transport->get_sense_buffer) { |
@@ -3346,6 +3375,32 @@ static inline void transport_free_pages(struct se_cmd *cmd) | |||
3346 | } | 3375 | } |
3347 | 3376 | ||
3348 | /** | 3377 | /** |
3378 | * transport_release_cmd - free a command | ||
3379 | * @cmd: command to free | ||
3380 | * | ||
3381 | * This routine unconditionally frees a command, and reference counting | ||
3382 | * or list removal must be done in the caller. | ||
3383 | */ | ||
3384 | static void transport_release_cmd(struct se_cmd *cmd) | ||
3385 | { | ||
3386 | BUG_ON(!cmd->se_tfo); | ||
3387 | |||
3388 | if (cmd->se_tmr_req) | ||
3389 | core_tmr_release_req(cmd->se_tmr_req); | ||
3390 | if (cmd->t_task_cdb != cmd->__t_task_cdb) | ||
3391 | kfree(cmd->t_task_cdb); | ||
3392 | /* | ||
3393 | * If this cmd has been setup with target_get_sess_cmd(), drop | ||
3394 | * the kref and call ->release_cmd() in kref callback. | ||
3395 | */ | ||
3396 | if (cmd->check_release != 0) { | ||
3397 | target_put_sess_cmd(cmd->se_sess, cmd); | ||
3398 | return; | ||
3399 | } | ||
3400 | cmd->se_tfo->release_cmd(cmd); | ||
3401 | } | ||
3402 | |||
3403 | /** | ||
3349 | * transport_put_cmd - release a reference to a command | 3404 | * transport_put_cmd - release a reference to a command |
3350 | * @cmd: command to release | 3405 | * @cmd: command to release |
3351 | * | 3406 | * |
@@ -3870,33 +3925,6 @@ queue_full: | |||
3870 | return 0; | 3925 | return 0; |
3871 | } | 3926 | } |
3872 | 3927 | ||
3873 | /** | ||
3874 | * transport_release_cmd - free a command | ||
3875 | * @cmd: command to free | ||
3876 | * | ||
3877 | * This routine unconditionally frees a command, and reference counting | ||
3878 | * or list removal must be done in the caller. | ||
3879 | */ | ||
3880 | void transport_release_cmd(struct se_cmd *cmd) | ||
3881 | { | ||
3882 | BUG_ON(!cmd->se_tfo); | ||
3883 | |||
3884 | if (cmd->se_tmr_req) | ||
3885 | core_tmr_release_req(cmd->se_tmr_req); | ||
3886 | if (cmd->t_task_cdb != cmd->__t_task_cdb) | ||
3887 | kfree(cmd->t_task_cdb); | ||
3888 | /* | ||
3889 | * Check if target_wait_for_sess_cmds() is expecting to | ||
3890 | * release se_cmd directly here.. | ||
3891 | */ | ||
3892 | if (cmd->check_release != 0 && cmd->se_tfo->check_release_cmd) | ||
3893 | if (cmd->se_tfo->check_release_cmd(cmd) != 0) | ||
3894 | return; | ||
3895 | |||
3896 | cmd->se_tfo->release_cmd(cmd); | ||
3897 | } | ||
3898 | EXPORT_SYMBOL(transport_release_cmd); | ||
3899 | |||
3900 | void transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks) | 3928 | void transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks) |
3901 | { | 3929 | { |
3902 | if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD)) { | 3930 | if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD)) { |
@@ -3923,11 +3951,22 @@ EXPORT_SYMBOL(transport_generic_free_cmd); | |||
3923 | /* target_get_sess_cmd - Add command to active ->sess_cmd_list | 3951 | /* target_get_sess_cmd - Add command to active ->sess_cmd_list |
3924 | * @se_sess: session to reference | 3952 | * @se_sess: session to reference |
3925 | * @se_cmd: command descriptor to add | 3953 | * @se_cmd: command descriptor to add |
3954 | * @ack_kref: Signal that fabric will perform an ack target_put_sess_cmd() | ||
3926 | */ | 3955 | */ |
3927 | void target_get_sess_cmd(struct se_session *se_sess, struct se_cmd *se_cmd) | 3956 | void target_get_sess_cmd(struct se_session *se_sess, struct se_cmd *se_cmd, |
3957 | bool ack_kref) | ||
3928 | { | 3958 | { |
3929 | unsigned long flags; | 3959 | unsigned long flags; |
3930 | 3960 | ||
3961 | kref_init(&se_cmd->cmd_kref); | ||
3962 | /* | ||
3963 | * Add a second kref if the fabric caller is expecting to handle | ||
3964 | * fabric acknowledgement that requires two target_put_sess_cmd() | ||
3965 | * invocations before se_cmd descriptor release. | ||
3966 | */ | ||
3967 | if (ack_kref == true) | ||
3968 | kref_get(&se_cmd->cmd_kref); | ||
3969 | |||
3931 | spin_lock_irqsave(&se_sess->sess_cmd_lock, flags); | 3970 | spin_lock_irqsave(&se_sess->sess_cmd_lock, flags); |
3932 | list_add_tail(&se_cmd->se_cmd_list, &se_sess->sess_cmd_list); | 3971 | list_add_tail(&se_cmd->se_cmd_list, &se_sess->sess_cmd_list); |
3933 | se_cmd->check_release = 1; | 3972 | se_cmd->check_release = 1; |
@@ -3935,30 +3974,36 @@ void target_get_sess_cmd(struct se_session *se_sess, struct se_cmd *se_cmd) | |||
3935 | } | 3974 | } |
3936 | EXPORT_SYMBOL(target_get_sess_cmd); | 3975 | EXPORT_SYMBOL(target_get_sess_cmd); |
3937 | 3976 | ||
3938 | /* target_put_sess_cmd - Check for active I/O shutdown or list delete | 3977 | static void target_release_cmd_kref(struct kref *kref) |
3939 | * @se_sess: session to reference | ||
3940 | * @se_cmd: command descriptor to drop | ||
3941 | */ | ||
3942 | int target_put_sess_cmd(struct se_session *se_sess, struct se_cmd *se_cmd) | ||
3943 | { | 3978 | { |
3979 | struct se_cmd *se_cmd = container_of(kref, struct se_cmd, cmd_kref); | ||
3980 | struct se_session *se_sess = se_cmd->se_sess; | ||
3944 | unsigned long flags; | 3981 | unsigned long flags; |
3945 | 3982 | ||
3946 | spin_lock_irqsave(&se_sess->sess_cmd_lock, flags); | 3983 | spin_lock_irqsave(&se_sess->sess_cmd_lock, flags); |
3947 | if (list_empty(&se_cmd->se_cmd_list)) { | 3984 | if (list_empty(&se_cmd->se_cmd_list)) { |
3948 | spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags); | 3985 | spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags); |
3949 | WARN_ON(1); | 3986 | WARN_ON(1); |
3950 | return 0; | 3987 | return; |
3951 | } | 3988 | } |
3952 | |||
3953 | if (se_sess->sess_tearing_down && se_cmd->cmd_wait_set) { | 3989 | if (se_sess->sess_tearing_down && se_cmd->cmd_wait_set) { |
3954 | spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags); | 3990 | spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags); |
3955 | complete(&se_cmd->cmd_wait_comp); | 3991 | complete(&se_cmd->cmd_wait_comp); |
3956 | return 1; | 3992 | return; |
3957 | } | 3993 | } |
3958 | list_del(&se_cmd->se_cmd_list); | 3994 | list_del(&se_cmd->se_cmd_list); |
3959 | spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags); | 3995 | spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags); |
3960 | 3996 | ||
3961 | return 0; | 3997 | se_cmd->se_tfo->release_cmd(se_cmd); |
3998 | } | ||
3999 | |||
4000 | /* target_put_sess_cmd - Check for active I/O shutdown via kref_put | ||
4001 | * @se_sess: session to reference | ||
4002 | * @se_cmd: command descriptor to drop | ||
4003 | */ | ||
4004 | int target_put_sess_cmd(struct se_session *se_sess, struct se_cmd *se_cmd) | ||
4005 | { | ||
4006 | return kref_put(&se_cmd->cmd_kref, target_release_cmd_kref); | ||
3962 | } | 4007 | } |
3963 | EXPORT_SYMBOL(target_put_sess_cmd); | 4008 | EXPORT_SYMBOL(target_put_sess_cmd); |
3964 | 4009 | ||
@@ -4174,7 +4219,7 @@ check_cond: | |||
4174 | 4219 | ||
4175 | static int transport_clear_lun_thread(void *p) | 4220 | static int transport_clear_lun_thread(void *p) |
4176 | { | 4221 | { |
4177 | struct se_lun *lun = (struct se_lun *)p; | 4222 | struct se_lun *lun = p; |
4178 | 4223 | ||
4179 | __transport_clear_lun_from_sessions(lun); | 4224 | __transport_clear_lun_from_sessions(lun); |
4180 | complete(&lun->lun_shutdown_comp); | 4225 | complete(&lun->lun_shutdown_comp); |
@@ -4353,6 +4398,7 @@ int transport_send_check_condition_and_sense( | |||
4353 | case TCM_NON_EXISTENT_LUN: | 4398 | case TCM_NON_EXISTENT_LUN: |
4354 | /* CURRENT ERROR */ | 4399 | /* CURRENT ERROR */ |
4355 | buffer[offset] = 0x70; | 4400 | buffer[offset] = 0x70; |
4401 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | ||
4356 | /* ILLEGAL REQUEST */ | 4402 | /* ILLEGAL REQUEST */ |
4357 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; | 4403 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; |
4358 | /* LOGICAL UNIT NOT SUPPORTED */ | 4404 | /* LOGICAL UNIT NOT SUPPORTED */ |
@@ -4362,6 +4408,7 @@ int transport_send_check_condition_and_sense( | |||
4362 | case TCM_SECTOR_COUNT_TOO_MANY: | 4408 | case TCM_SECTOR_COUNT_TOO_MANY: |
4363 | /* CURRENT ERROR */ | 4409 | /* CURRENT ERROR */ |
4364 | buffer[offset] = 0x70; | 4410 | buffer[offset] = 0x70; |
4411 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | ||
4365 | /* ILLEGAL REQUEST */ | 4412 | /* ILLEGAL REQUEST */ |
4366 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; | 4413 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; |
4367 | /* INVALID COMMAND OPERATION CODE */ | 4414 | /* INVALID COMMAND OPERATION CODE */ |
@@ -4370,6 +4417,7 @@ int transport_send_check_condition_and_sense( | |||
4370 | case TCM_UNKNOWN_MODE_PAGE: | 4417 | case TCM_UNKNOWN_MODE_PAGE: |
4371 | /* CURRENT ERROR */ | 4418 | /* CURRENT ERROR */ |
4372 | buffer[offset] = 0x70; | 4419 | buffer[offset] = 0x70; |
4420 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | ||
4373 | /* ILLEGAL REQUEST */ | 4421 | /* ILLEGAL REQUEST */ |
4374 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; | 4422 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; |
4375 | /* INVALID FIELD IN CDB */ | 4423 | /* INVALID FIELD IN CDB */ |
@@ -4378,6 +4426,7 @@ int transport_send_check_condition_and_sense( | |||
4378 | case TCM_CHECK_CONDITION_ABORT_CMD: | 4426 | case TCM_CHECK_CONDITION_ABORT_CMD: |
4379 | /* CURRENT ERROR */ | 4427 | /* CURRENT ERROR */ |
4380 | buffer[offset] = 0x70; | 4428 | buffer[offset] = 0x70; |
4429 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | ||
4381 | /* ABORTED COMMAND */ | 4430 | /* ABORTED COMMAND */ |
4382 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; | 4431 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; |
4383 | /* BUS DEVICE RESET FUNCTION OCCURRED */ | 4432 | /* BUS DEVICE RESET FUNCTION OCCURRED */ |
@@ -4387,6 +4436,7 @@ int transport_send_check_condition_and_sense( | |||
4387 | case TCM_INCORRECT_AMOUNT_OF_DATA: | 4436 | case TCM_INCORRECT_AMOUNT_OF_DATA: |
4388 | /* CURRENT ERROR */ | 4437 | /* CURRENT ERROR */ |
4389 | buffer[offset] = 0x70; | 4438 | buffer[offset] = 0x70; |
4439 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | ||
4390 | /* ABORTED COMMAND */ | 4440 | /* ABORTED COMMAND */ |
4391 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; | 4441 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; |
4392 | /* WRITE ERROR */ | 4442 | /* WRITE ERROR */ |
@@ -4397,6 +4447,7 @@ int transport_send_check_condition_and_sense( | |||
4397 | case TCM_INVALID_CDB_FIELD: | 4447 | case TCM_INVALID_CDB_FIELD: |
4398 | /* CURRENT ERROR */ | 4448 | /* CURRENT ERROR */ |
4399 | buffer[offset] = 0x70; | 4449 | buffer[offset] = 0x70; |
4450 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | ||
4400 | /* ABORTED COMMAND */ | 4451 | /* ABORTED COMMAND */ |
4401 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; | 4452 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; |
4402 | /* INVALID FIELD IN CDB */ | 4453 | /* INVALID FIELD IN CDB */ |
@@ -4405,6 +4456,7 @@ int transport_send_check_condition_and_sense( | |||
4405 | case TCM_INVALID_PARAMETER_LIST: | 4456 | case TCM_INVALID_PARAMETER_LIST: |
4406 | /* CURRENT ERROR */ | 4457 | /* CURRENT ERROR */ |
4407 | buffer[offset] = 0x70; | 4458 | buffer[offset] = 0x70; |
4459 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | ||
4408 | /* ABORTED COMMAND */ | 4460 | /* ABORTED COMMAND */ |
4409 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; | 4461 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; |
4410 | /* INVALID FIELD IN PARAMETER LIST */ | 4462 | /* INVALID FIELD IN PARAMETER LIST */ |
@@ -4413,6 +4465,7 @@ int transport_send_check_condition_and_sense( | |||
4413 | case TCM_UNEXPECTED_UNSOLICITED_DATA: | 4465 | case TCM_UNEXPECTED_UNSOLICITED_DATA: |
4414 | /* CURRENT ERROR */ | 4466 | /* CURRENT ERROR */ |
4415 | buffer[offset] = 0x70; | 4467 | buffer[offset] = 0x70; |
4468 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | ||
4416 | /* ABORTED COMMAND */ | 4469 | /* ABORTED COMMAND */ |
4417 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; | 4470 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; |
4418 | /* WRITE ERROR */ | 4471 | /* WRITE ERROR */ |
@@ -4423,6 +4476,7 @@ int transport_send_check_condition_and_sense( | |||
4423 | case TCM_SERVICE_CRC_ERROR: | 4476 | case TCM_SERVICE_CRC_ERROR: |
4424 | /* CURRENT ERROR */ | 4477 | /* CURRENT ERROR */ |
4425 | buffer[offset] = 0x70; | 4478 | buffer[offset] = 0x70; |
4479 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | ||
4426 | /* ABORTED COMMAND */ | 4480 | /* ABORTED COMMAND */ |
4427 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; | 4481 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; |
4428 | /* PROTOCOL SERVICE CRC ERROR */ | 4482 | /* PROTOCOL SERVICE CRC ERROR */ |
@@ -4433,6 +4487,7 @@ int transport_send_check_condition_and_sense( | |||
4433 | case TCM_SNACK_REJECTED: | 4487 | case TCM_SNACK_REJECTED: |
4434 | /* CURRENT ERROR */ | 4488 | /* CURRENT ERROR */ |
4435 | buffer[offset] = 0x70; | 4489 | buffer[offset] = 0x70; |
4490 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | ||
4436 | /* ABORTED COMMAND */ | 4491 | /* ABORTED COMMAND */ |
4437 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; | 4492 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; |
4438 | /* READ ERROR */ | 4493 | /* READ ERROR */ |
@@ -4443,6 +4498,7 @@ int transport_send_check_condition_and_sense( | |||
4443 | case TCM_WRITE_PROTECTED: | 4498 | case TCM_WRITE_PROTECTED: |
4444 | /* CURRENT ERROR */ | 4499 | /* CURRENT ERROR */ |
4445 | buffer[offset] = 0x70; | 4500 | buffer[offset] = 0x70; |
4501 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | ||
4446 | /* DATA PROTECT */ | 4502 | /* DATA PROTECT */ |
4447 | buffer[offset+SPC_SENSE_KEY_OFFSET] = DATA_PROTECT; | 4503 | buffer[offset+SPC_SENSE_KEY_OFFSET] = DATA_PROTECT; |
4448 | /* WRITE PROTECTED */ | 4504 | /* WRITE PROTECTED */ |
@@ -4451,6 +4507,7 @@ int transport_send_check_condition_and_sense( | |||
4451 | case TCM_CHECK_CONDITION_UNIT_ATTENTION: | 4507 | case TCM_CHECK_CONDITION_UNIT_ATTENTION: |
4452 | /* CURRENT ERROR */ | 4508 | /* CURRENT ERROR */ |
4453 | buffer[offset] = 0x70; | 4509 | buffer[offset] = 0x70; |
4510 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | ||
4454 | /* UNIT ATTENTION */ | 4511 | /* UNIT ATTENTION */ |
4455 | buffer[offset+SPC_SENSE_KEY_OFFSET] = UNIT_ATTENTION; | 4512 | buffer[offset+SPC_SENSE_KEY_OFFSET] = UNIT_ATTENTION; |
4456 | core_scsi3_ua_for_check_condition(cmd, &asc, &ascq); | 4513 | core_scsi3_ua_for_check_condition(cmd, &asc, &ascq); |
@@ -4460,6 +4517,7 @@ int transport_send_check_condition_and_sense( | |||
4460 | case TCM_CHECK_CONDITION_NOT_READY: | 4517 | case TCM_CHECK_CONDITION_NOT_READY: |
4461 | /* CURRENT ERROR */ | 4518 | /* CURRENT ERROR */ |
4462 | buffer[offset] = 0x70; | 4519 | buffer[offset] = 0x70; |
4520 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | ||
4463 | /* Not Ready */ | 4521 | /* Not Ready */ |
4464 | buffer[offset+SPC_SENSE_KEY_OFFSET] = NOT_READY; | 4522 | buffer[offset+SPC_SENSE_KEY_OFFSET] = NOT_READY; |
4465 | transport_get_sense_codes(cmd, &asc, &ascq); | 4523 | transport_get_sense_codes(cmd, &asc, &ascq); |
@@ -4470,6 +4528,7 @@ int transport_send_check_condition_and_sense( | |||
4470 | default: | 4528 | default: |
4471 | /* CURRENT ERROR */ | 4529 | /* CURRENT ERROR */ |
4472 | buffer[offset] = 0x70; | 4530 | buffer[offset] = 0x70; |
4531 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | ||
4473 | /* ILLEGAL REQUEST */ | 4532 | /* ILLEGAL REQUEST */ |
4474 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; | 4533 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; |
4475 | /* LOGICAL UNIT COMMUNICATION FAILURE */ | 4534 | /* LOGICAL UNIT COMMUNICATION FAILURE */ |
@@ -4545,11 +4604,7 @@ void transport_send_task_abort(struct se_cmd *cmd) | |||
4545 | cmd->se_tfo->queue_status(cmd); | 4604 | cmd->se_tfo->queue_status(cmd); |
4546 | } | 4605 | } |
4547 | 4606 | ||
4548 | /* transport_generic_do_tmr(): | 4607 | static int transport_generic_do_tmr(struct se_cmd *cmd) |
4549 | * | ||
4550 | * | ||
4551 | */ | ||
4552 | int transport_generic_do_tmr(struct se_cmd *cmd) | ||
4553 | { | 4608 | { |
4554 | struct se_device *dev = cmd->se_dev; | 4609 | struct se_device *dev = cmd->se_dev; |
4555 | struct se_tmr_req *tmr = cmd->se_tmr_req; | 4610 | struct se_tmr_req *tmr = cmd->se_tmr_req; |
@@ -4597,7 +4652,7 @@ static int transport_processing_thread(void *param) | |||
4597 | { | 4652 | { |
4598 | int ret; | 4653 | int ret; |
4599 | struct se_cmd *cmd; | 4654 | struct se_cmd *cmd; |
4600 | struct se_device *dev = (struct se_device *) param; | 4655 | struct se_device *dev = param; |
4601 | 4656 | ||
4602 | while (!kthread_should_stop()) { | 4657 | while (!kthread_should_stop()) { |
4603 | ret = wait_event_interruptible(dev->dev_queue_obj.thread_wq, | 4658 | ret = wait_event_interruptible(dev->dev_queue_obj.thread_wq, |
@@ -4607,8 +4662,6 @@ static int transport_processing_thread(void *param) | |||
4607 | goto out; | 4662 | goto out; |
4608 | 4663 | ||
4609 | get_cmd: | 4664 | get_cmd: |
4610 | __transport_execute_tasks(dev); | ||
4611 | |||
4612 | cmd = transport_get_cmd_from_queue(&dev->dev_queue_obj); | 4665 | cmd = transport_get_cmd_from_queue(&dev->dev_queue_obj); |
4613 | if (!cmd) | 4666 | if (!cmd) |
4614 | continue; | 4667 | continue; |
diff --git a/drivers/target/target_core_ua.c b/drivers/target/target_core_ua.c index 50a480db7a66..3e12f6bcfa10 100644 --- a/drivers/target/target_core_ua.c +++ b/drivers/target/target_core_ua.c | |||
@@ -30,13 +30,11 @@ | |||
30 | #include <scsi/scsi_cmnd.h> | 30 | #include <scsi/scsi_cmnd.h> |
31 | 31 | ||
32 | #include <target/target_core_base.h> | 32 | #include <target/target_core_base.h> |
33 | #include <target/target_core_device.h> | 33 | #include <target/target_core_fabric.h> |
34 | #include <target/target_core_transport.h> | ||
35 | #include <target/target_core_fabric_ops.h> | ||
36 | #include <target/target_core_configfs.h> | 34 | #include <target/target_core_configfs.h> |
37 | 35 | ||
36 | #include "target_core_internal.h" | ||
38 | #include "target_core_alua.h" | 37 | #include "target_core_alua.h" |
39 | #include "target_core_hba.h" | ||
40 | #include "target_core_pr.h" | 38 | #include "target_core_pr.h" |
41 | #include "target_core_ua.h" | 39 | #include "target_core_ua.h" |
42 | 40 | ||
diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c index 71fc9cea5dc9..addc18f727ea 100644 --- a/drivers/target/tcm_fc/tfc_cmd.c +++ b/drivers/target/tcm_fc/tfc_cmd.c | |||
@@ -39,12 +39,8 @@ | |||
39 | #include <scsi/fc_encode.h> | 39 | #include <scsi/fc_encode.h> |
40 | 40 | ||
41 | #include <target/target_core_base.h> | 41 | #include <target/target_core_base.h> |
42 | #include <target/target_core_transport.h> | 42 | #include <target/target_core_fabric.h> |
43 | #include <target/target_core_fabric_ops.h> | ||
44 | #include <target/target_core_device.h> | ||
45 | #include <target/target_core_tpg.h> | ||
46 | #include <target/target_core_configfs.h> | 43 | #include <target/target_core_configfs.h> |
47 | #include <target/target_core_tmr.h> | ||
48 | #include <target/configfs_macros.h> | 44 | #include <target/configfs_macros.h> |
49 | 45 | ||
50 | #include "tcm_fc.h" | 46 | #include "tcm_fc.h" |
@@ -367,6 +363,11 @@ static void ft_send_tm(struct ft_cmd *cmd) | |||
367 | struct ft_sess *sess; | 363 | struct ft_sess *sess; |
368 | u8 tm_func; | 364 | u8 tm_func; |
369 | 365 | ||
366 | transport_init_se_cmd(&cmd->se_cmd, &ft_configfs->tf_ops, | ||
367 | cmd->sess->se_sess, 0, DMA_NONE, 0, | ||
368 | &cmd->ft_sense_buffer[0]); | ||
369 | target_get_sess_cmd(cmd->sess->se_sess, &cmd->se_cmd, false); | ||
370 | |||
370 | fcp = fc_frame_payload_get(cmd->req_frame, sizeof(*fcp)); | 371 | fcp = fc_frame_payload_get(cmd->req_frame, sizeof(*fcp)); |
371 | 372 | ||
372 | switch (fcp->fc_tm_flags) { | 373 | switch (fcp->fc_tm_flags) { |
@@ -420,7 +421,6 @@ static void ft_send_tm(struct ft_cmd *cmd) | |||
420 | sess = cmd->sess; | 421 | sess = cmd->sess; |
421 | transport_send_check_condition_and_sense(&cmd->se_cmd, | 422 | transport_send_check_condition_and_sense(&cmd->se_cmd, |
422 | cmd->se_cmd.scsi_sense_reason, 0); | 423 | cmd->se_cmd.scsi_sense_reason, 0); |
423 | transport_generic_free_cmd(&cmd->se_cmd, 0); | ||
424 | ft_sess_put(sess); | 424 | ft_sess_put(sess); |
425 | return; | 425 | return; |
426 | } | 426 | } |
@@ -536,7 +536,6 @@ static void ft_send_work(struct work_struct *work) | |||
536 | { | 536 | { |
537 | struct ft_cmd *cmd = container_of(work, struct ft_cmd, work); | 537 | struct ft_cmd *cmd = container_of(work, struct ft_cmd, work); |
538 | struct fc_frame_header *fh = fc_frame_header_get(cmd->req_frame); | 538 | struct fc_frame_header *fh = fc_frame_header_get(cmd->req_frame); |
539 | struct se_cmd *se_cmd; | ||
540 | struct fcp_cmnd *fcp; | 539 | struct fcp_cmnd *fcp; |
541 | int data_dir = 0; | 540 | int data_dir = 0; |
542 | u32 data_len; | 541 | u32 data_len; |
@@ -591,15 +590,6 @@ static void ft_send_work(struct work_struct *work) | |||
591 | data_len = ntohl(fcp->fc_dl); | 590 | data_len = ntohl(fcp->fc_dl); |
592 | cmd->cdb = fcp->fc_cdb; | 591 | cmd->cdb = fcp->fc_cdb; |
593 | } | 592 | } |
594 | |||
595 | se_cmd = &cmd->se_cmd; | ||
596 | /* | ||
597 | * Initialize struct se_cmd descriptor from target_core_mod | ||
598 | * infrastructure | ||
599 | */ | ||
600 | transport_init_se_cmd(se_cmd, &ft_configfs->tf_ops, cmd->sess->se_sess, | ||
601 | data_len, data_dir, task_attr, | ||
602 | &cmd->ft_sense_buffer[0]); | ||
603 | /* | 593 | /* |
604 | * Check for FCP task management flags | 594 | * Check for FCP task management flags |
605 | */ | 595 | */ |
@@ -607,39 +597,20 @@ static void ft_send_work(struct work_struct *work) | |||
607 | ft_send_tm(cmd); | 597 | ft_send_tm(cmd); |
608 | return; | 598 | return; |
609 | } | 599 | } |
610 | |||
611 | fc_seq_exch(cmd->seq)->lp->tt.seq_set_resp(cmd->seq, ft_recv_seq, cmd); | 600 | fc_seq_exch(cmd->seq)->lp->tt.seq_set_resp(cmd->seq, ft_recv_seq, cmd); |
612 | |||
613 | cmd->lun = scsilun_to_int((struct scsi_lun *)fcp->fc_lun); | 601 | cmd->lun = scsilun_to_int((struct scsi_lun *)fcp->fc_lun); |
614 | ret = transport_lookup_cmd_lun(&cmd->se_cmd, cmd->lun); | 602 | /* |
603 | * Use a single se_cmd->cmd_kref as we expect to release se_cmd | ||
604 | * directly from ft_check_stop_free callback in response path. | ||
605 | */ | ||
606 | ret = target_submit_cmd(&cmd->se_cmd, cmd->sess->se_sess, cmd->cdb, | ||
607 | &cmd->ft_sense_buffer[0], cmd->lun, data_len, | ||
608 | task_attr, data_dir, 0); | ||
609 | pr_debug("r_ctl %x alloc target_submit_cmd %d\n", fh->fh_r_ctl, ret); | ||
615 | if (ret < 0) { | 610 | if (ret < 0) { |
616 | ft_dump_cmd(cmd, __func__); | 611 | ft_dump_cmd(cmd, __func__); |
617 | transport_send_check_condition_and_sense(&cmd->se_cmd, | ||
618 | cmd->se_cmd.scsi_sense_reason, 0); | ||
619 | return; | ||
620 | } | ||
621 | |||
622 | ret = transport_generic_allocate_tasks(se_cmd, cmd->cdb); | ||
623 | |||
624 | pr_debug("r_ctl %x alloc task ret %d\n", fh->fh_r_ctl, ret); | ||
625 | ft_dump_cmd(cmd, __func__); | ||
626 | |||
627 | if (ret == -ENOMEM) { | ||
628 | transport_send_check_condition_and_sense(se_cmd, | ||
629 | TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE, 0); | ||
630 | transport_generic_free_cmd(se_cmd, 0); | ||
631 | return; | ||
632 | } | ||
633 | if (ret == -EINVAL) { | ||
634 | if (se_cmd->se_cmd_flags & SCF_SCSI_RESERVATION_CONFLICT) | ||
635 | ft_queue_status(se_cmd); | ||
636 | else | ||
637 | transport_send_check_condition_and_sense(se_cmd, | ||
638 | se_cmd->scsi_sense_reason, 0); | ||
639 | transport_generic_free_cmd(se_cmd, 0); | ||
640 | return; | 612 | return; |
641 | } | 613 | } |
642 | transport_handle_cdb_direct(se_cmd); | ||
643 | return; | 614 | return; |
644 | 615 | ||
645 | err: | 616 | err: |
diff --git a/drivers/target/tcm_fc/tfc_conf.c b/drivers/target/tcm_fc/tfc_conf.c index 9402b7387cac..73852fbc857b 100644 --- a/drivers/target/tcm_fc/tfc_conf.c +++ b/drivers/target/tcm_fc/tfc_conf.c | |||
@@ -41,12 +41,8 @@ | |||
41 | #include <scsi/libfc.h> | 41 | #include <scsi/libfc.h> |
42 | 42 | ||
43 | #include <target/target_core_base.h> | 43 | #include <target/target_core_base.h> |
44 | #include <target/target_core_transport.h> | 44 | #include <target/target_core_fabric.h> |
45 | #include <target/target_core_fabric_ops.h> | ||
46 | #include <target/target_core_fabric_configfs.h> | 45 | #include <target/target_core_fabric_configfs.h> |
47 | #include <target/target_core_fabric_lib.h> | ||
48 | #include <target/target_core_device.h> | ||
49 | #include <target/target_core_tpg.h> | ||
50 | #include <target/target_core_configfs.h> | 46 | #include <target/target_core_configfs.h> |
51 | #include <target/configfs_macros.h> | 47 | #include <target/configfs_macros.h> |
52 | 48 | ||
diff --git a/drivers/target/tcm_fc/tfc_io.c b/drivers/target/tcm_fc/tfc_io.c index 1369b1cb103d..d8cabc21036d 100644 --- a/drivers/target/tcm_fc/tfc_io.c +++ b/drivers/target/tcm_fc/tfc_io.c | |||
@@ -48,10 +48,7 @@ | |||
48 | #include <scsi/fc_encode.h> | 48 | #include <scsi/fc_encode.h> |
49 | 49 | ||
50 | #include <target/target_core_base.h> | 50 | #include <target/target_core_base.h> |
51 | #include <target/target_core_transport.h> | 51 | #include <target/target_core_fabric.h> |
52 | #include <target/target_core_fabric_ops.h> | ||
53 | #include <target/target_core_device.h> | ||
54 | #include <target/target_core_tpg.h> | ||
55 | #include <target/target_core_configfs.h> | 52 | #include <target/target_core_configfs.h> |
56 | #include <target/configfs_macros.h> | 53 | #include <target/configfs_macros.h> |
57 | 54 | ||
diff --git a/drivers/target/tcm_fc/tfc_sess.c b/drivers/target/tcm_fc/tfc_sess.c index 326921385aff..4c0507cf808c 100644 --- a/drivers/target/tcm_fc/tfc_sess.c +++ b/drivers/target/tcm_fc/tfc_sess.c | |||
@@ -40,10 +40,7 @@ | |||
40 | #include <scsi/libfc.h> | 40 | #include <scsi/libfc.h> |
41 | 41 | ||
42 | #include <target/target_core_base.h> | 42 | #include <target/target_core_base.h> |
43 | #include <target/target_core_transport.h> | 43 | #include <target/target_core_fabric.h> |
44 | #include <target/target_core_fabric_ops.h> | ||
45 | #include <target/target_core_device.h> | ||
46 | #include <target/target_core_tpg.h> | ||
47 | #include <target/target_core_configfs.h> | 44 | #include <target/target_core_configfs.h> |
48 | #include <target/configfs_macros.h> | 45 | #include <target/configfs_macros.h> |
49 | 46 | ||