diff options
Diffstat (limited to 'drivers/target')
-rw-r--r-- | drivers/target/iscsi/iscsi_target.c | 26 | ||||
-rw-r--r-- | drivers/target/iscsi/iscsi_target_auth.c | 6 | ||||
-rw-r--r-- | drivers/target/iscsi/iscsi_target_core.h | 3 | ||||
-rw-r--r-- | drivers/target/iscsi/iscsi_target_erl1.c | 3 | ||||
-rw-r--r-- | drivers/target/iscsi/iscsi_target_login.c | 13 | ||||
-rw-r--r-- | drivers/target/iscsi/iscsi_target_nego.c | 3 | ||||
-rw-r--r-- | drivers/target/loopback/tcm_loop.c | 41 | ||||
-rw-r--r-- | drivers/target/target_core_alua.c | 27 | ||||
-rw-r--r-- | drivers/target/target_core_cdb.c | 20 | ||||
-rw-r--r-- | drivers/target/target_core_configfs.c | 11 | ||||
-rw-r--r-- | drivers/target/target_core_device.c | 30 | ||||
-rw-r--r-- | drivers/target/target_core_file.c | 20 | ||||
-rw-r--r-- | drivers/target/target_core_iblock.c | 16 | ||||
-rw-r--r-- | drivers/target/target_core_pr.c | 240 | ||||
-rw-r--r-- | drivers/target/target_core_pscsi.c | 28 | ||||
-rw-r--r-- | drivers/target/target_core_rd.c | 258 | ||||
-rw-r--r-- | drivers/target/target_core_tmr.c | 4 | ||||
-rw-r--r-- | drivers/target/target_core_transport.c | 260 | ||||
-rw-r--r-- | drivers/target/tcm_fc/tfc_cmd.c | 2 | ||||
-rw-r--r-- | drivers/target/tcm_fc/tfc_conf.c | 3 |
20 files changed, 419 insertions, 595 deletions
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 0fd96c10271d..8599545cdf9e 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c | |||
@@ -614,13 +614,12 @@ int iscsit_add_reject( | |||
614 | hdr = (struct iscsi_reject *) cmd->pdu; | 614 | hdr = (struct iscsi_reject *) cmd->pdu; |
615 | hdr->reason = reason; | 615 | hdr->reason = reason; |
616 | 616 | ||
617 | cmd->buf_ptr = kzalloc(ISCSI_HDR_LEN, GFP_KERNEL); | 617 | cmd->buf_ptr = kmemdup(buf, ISCSI_HDR_LEN, GFP_KERNEL); |
618 | if (!cmd->buf_ptr) { | 618 | if (!cmd->buf_ptr) { |
619 | pr_err("Unable to allocate memory for cmd->buf_ptr\n"); | 619 | pr_err("Unable to allocate memory for cmd->buf_ptr\n"); |
620 | iscsit_release_cmd(cmd); | 620 | iscsit_release_cmd(cmd); |
621 | return -1; | 621 | return -1; |
622 | } | 622 | } |
623 | memcpy(cmd->buf_ptr, buf, ISCSI_HDR_LEN); | ||
624 | 623 | ||
625 | spin_lock_bh(&conn->cmd_lock); | 624 | spin_lock_bh(&conn->cmd_lock); |
626 | list_add_tail(&cmd->i_list, &conn->conn_cmd_list); | 625 | list_add_tail(&cmd->i_list, &conn->conn_cmd_list); |
@@ -661,13 +660,12 @@ int iscsit_add_reject_from_cmd( | |||
661 | hdr = (struct iscsi_reject *) cmd->pdu; | 660 | hdr = (struct iscsi_reject *) cmd->pdu; |
662 | hdr->reason = reason; | 661 | hdr->reason = reason; |
663 | 662 | ||
664 | cmd->buf_ptr = kzalloc(ISCSI_HDR_LEN, GFP_KERNEL); | 663 | cmd->buf_ptr = kmemdup(buf, ISCSI_HDR_LEN, GFP_KERNEL); |
665 | if (!cmd->buf_ptr) { | 664 | if (!cmd->buf_ptr) { |
666 | pr_err("Unable to allocate memory for cmd->buf_ptr\n"); | 665 | pr_err("Unable to allocate memory for cmd->buf_ptr\n"); |
667 | iscsit_release_cmd(cmd); | 666 | iscsit_release_cmd(cmd); |
668 | return -1; | 667 | return -1; |
669 | } | 668 | } |
670 | memcpy(cmd->buf_ptr, buf, ISCSI_HDR_LEN); | ||
671 | 669 | ||
672 | if (add_to_conn) { | 670 | if (add_to_conn) { |
673 | spin_lock_bh(&conn->cmd_lock); | 671 | spin_lock_bh(&conn->cmd_lock); |
@@ -1017,11 +1015,6 @@ done: | |||
1017 | " non-existent or non-exported iSCSI LUN:" | 1015 | " non-existent or non-exported iSCSI LUN:" |
1018 | " 0x%016Lx\n", get_unaligned_le64(&hdr->lun)); | 1016 | " 0x%016Lx\n", get_unaligned_le64(&hdr->lun)); |
1019 | } | 1017 | } |
1020 | if (ret == PYX_TRANSPORT_OUT_OF_MEMORY_RESOURCES) | ||
1021 | return iscsit_add_reject_from_cmd( | ||
1022 | ISCSI_REASON_BOOKMARK_NO_RESOURCES, | ||
1023 | 1, 1, buf, cmd); | ||
1024 | |||
1025 | send_check_condition = 1; | 1018 | send_check_condition = 1; |
1026 | goto attach_cmd; | 1019 | goto attach_cmd; |
1027 | } | 1020 | } |
@@ -1044,6 +1037,8 @@ done: | |||
1044 | */ | 1037 | */ |
1045 | send_check_condition = 1; | 1038 | send_check_condition = 1; |
1046 | } else { | 1039 | } else { |
1040 | cmd->data_length = cmd->se_cmd.data_length; | ||
1041 | |||
1047 | if (iscsit_decide_list_to_build(cmd, payload_length) < 0) | 1042 | if (iscsit_decide_list_to_build(cmd, payload_length) < 0) |
1048 | return iscsit_add_reject_from_cmd( | 1043 | return iscsit_add_reject_from_cmd( |
1049 | ISCSI_REASON_BOOKMARK_NO_RESOURCES, | 1044 | ISCSI_REASON_BOOKMARK_NO_RESOURCES, |
@@ -1123,7 +1118,7 @@ attach_cmd: | |||
1123 | * the backend memory allocation. | 1118 | * the backend memory allocation. |
1124 | */ | 1119 | */ |
1125 | ret = transport_generic_new_cmd(&cmd->se_cmd); | 1120 | ret = transport_generic_new_cmd(&cmd->se_cmd); |
1126 | if ((ret < 0) || (cmd->se_cmd.se_cmd_flags & SCF_SE_CMD_FAILED)) { | 1121 | if (ret < 0) { |
1127 | immed_ret = IMMEDIATE_DATA_NORMAL_OPERATION; | 1122 | immed_ret = IMMEDIATE_DATA_NORMAL_OPERATION; |
1128 | dump_immediate_data = 1; | 1123 | dump_immediate_data = 1; |
1129 | goto after_immediate_data; | 1124 | goto after_immediate_data; |
@@ -1341,7 +1336,7 @@ static int iscsit_handle_data_out(struct iscsi_conn *conn, unsigned char *buf) | |||
1341 | 1336 | ||
1342 | spin_lock_irqsave(&se_cmd->t_state_lock, flags); | 1337 | spin_lock_irqsave(&se_cmd->t_state_lock, flags); |
1343 | if (!(se_cmd->se_cmd_flags & SCF_SUPPORTED_SAM_OPCODE) || | 1338 | if (!(se_cmd->se_cmd_flags & SCF_SUPPORTED_SAM_OPCODE) || |
1344 | (se_cmd->se_cmd_flags & SCF_SE_CMD_FAILED)) | 1339 | (se_cmd->se_cmd_flags & SCF_SCSI_CDB_EXCEPTION)) |
1345 | dump_unsolicited_data = 1; | 1340 | dump_unsolicited_data = 1; |
1346 | spin_unlock_irqrestore(&se_cmd->t_state_lock, flags); | 1341 | spin_unlock_irqrestore(&se_cmd->t_state_lock, flags); |
1347 | 1342 | ||
@@ -2513,10 +2508,10 @@ static int iscsit_send_data_in( | |||
2513 | if (hdr->flags & ISCSI_FLAG_DATA_STATUS) { | 2508 | if (hdr->flags & ISCSI_FLAG_DATA_STATUS) { |
2514 | if (cmd->se_cmd.se_cmd_flags & SCF_OVERFLOW_BIT) { | 2509 | if (cmd->se_cmd.se_cmd_flags & SCF_OVERFLOW_BIT) { |
2515 | hdr->flags |= ISCSI_FLAG_DATA_OVERFLOW; | 2510 | hdr->flags |= ISCSI_FLAG_DATA_OVERFLOW; |
2516 | hdr->residual_count = cpu_to_be32(cmd->residual_count); | 2511 | hdr->residual_count = cpu_to_be32(cmd->se_cmd.residual_count); |
2517 | } else if (cmd->se_cmd.se_cmd_flags & SCF_UNDERFLOW_BIT) { | 2512 | } else if (cmd->se_cmd.se_cmd_flags & SCF_UNDERFLOW_BIT) { |
2518 | hdr->flags |= ISCSI_FLAG_DATA_UNDERFLOW; | 2513 | hdr->flags |= ISCSI_FLAG_DATA_UNDERFLOW; |
2519 | hdr->residual_count = cpu_to_be32(cmd->residual_count); | 2514 | hdr->residual_count = cpu_to_be32(cmd->se_cmd.residual_count); |
2520 | } | 2515 | } |
2521 | } | 2516 | } |
2522 | hton24(hdr->dlength, datain.length); | 2517 | hton24(hdr->dlength, datain.length); |
@@ -3018,10 +3013,10 @@ static int iscsit_send_status( | |||
3018 | hdr->flags |= ISCSI_FLAG_CMD_FINAL; | 3013 | hdr->flags |= ISCSI_FLAG_CMD_FINAL; |
3019 | if (cmd->se_cmd.se_cmd_flags & SCF_OVERFLOW_BIT) { | 3014 | if (cmd->se_cmd.se_cmd_flags & SCF_OVERFLOW_BIT) { |
3020 | hdr->flags |= ISCSI_FLAG_CMD_OVERFLOW; | 3015 | hdr->flags |= ISCSI_FLAG_CMD_OVERFLOW; |
3021 | hdr->residual_count = cpu_to_be32(cmd->residual_count); | 3016 | hdr->residual_count = cpu_to_be32(cmd->se_cmd.residual_count); |
3022 | } else if (cmd->se_cmd.se_cmd_flags & SCF_UNDERFLOW_BIT) { | 3017 | } else if (cmd->se_cmd.se_cmd_flags & SCF_UNDERFLOW_BIT) { |
3023 | hdr->flags |= ISCSI_FLAG_CMD_UNDERFLOW; | 3018 | hdr->flags |= ISCSI_FLAG_CMD_UNDERFLOW; |
3024 | hdr->residual_count = cpu_to_be32(cmd->residual_count); | 3019 | hdr->residual_count = cpu_to_be32(cmd->se_cmd.residual_count); |
3025 | } | 3020 | } |
3026 | hdr->response = cmd->iscsi_response; | 3021 | hdr->response = cmd->iscsi_response; |
3027 | hdr->cmd_status = cmd->se_cmd.scsi_status; | 3022 | hdr->cmd_status = cmd->se_cmd.scsi_status; |
@@ -3133,6 +3128,7 @@ static int iscsit_send_task_mgt_rsp( | |||
3133 | hdr = (struct iscsi_tm_rsp *) cmd->pdu; | 3128 | hdr = (struct iscsi_tm_rsp *) cmd->pdu; |
3134 | memset(hdr, 0, ISCSI_HDR_LEN); | 3129 | memset(hdr, 0, ISCSI_HDR_LEN); |
3135 | hdr->opcode = ISCSI_OP_SCSI_TMFUNC_RSP; | 3130 | hdr->opcode = ISCSI_OP_SCSI_TMFUNC_RSP; |
3131 | hdr->flags = ISCSI_FLAG_CMD_FINAL; | ||
3136 | hdr->response = iscsit_convert_tcm_tmr_rsp(se_tmr); | 3132 | hdr->response = iscsit_convert_tcm_tmr_rsp(se_tmr); |
3137 | hdr->itt = cpu_to_be32(cmd->init_task_tag); | 3133 | hdr->itt = cpu_to_be32(cmd->init_task_tag); |
3138 | cmd->stat_sn = conn->stat_sn++; | 3134 | cmd->stat_sn = conn->stat_sn++; |
diff --git a/drivers/target/iscsi/iscsi_target_auth.c b/drivers/target/iscsi/iscsi_target_auth.c index beb39469e7f1..1cd6ce373b83 100644 --- a/drivers/target/iscsi/iscsi_target_auth.c +++ b/drivers/target/iscsi/iscsi_target_auth.c | |||
@@ -30,9 +30,11 @@ | |||
30 | 30 | ||
31 | static int chap_string_to_hex(unsigned char *dst, unsigned char *src, int len) | 31 | static int chap_string_to_hex(unsigned char *dst, unsigned char *src, int len) |
32 | { | 32 | { |
33 | int j = DIV_ROUND_UP(len, 2); | 33 | int j = DIV_ROUND_UP(len, 2), rc; |
34 | 34 | ||
35 | hex2bin(dst, src, j); | 35 | rc = hex2bin(dst, src, j); |
36 | if (rc < 0) | ||
37 | pr_debug("CHAP string contains non hex digit symbols\n"); | ||
36 | 38 | ||
37 | dst[j] = '\0'; | 39 | dst[j] = '\0'; |
38 | return j; | 40 | return j; |
diff --git a/drivers/target/iscsi/iscsi_target_core.h b/drivers/target/iscsi/iscsi_target_core.h index 3723d90d5ae5..f1a02dad05a0 100644 --- a/drivers/target/iscsi/iscsi_target_core.h +++ b/drivers/target/iscsi/iscsi_target_core.h | |||
@@ -398,7 +398,6 @@ struct iscsi_cmd { | |||
398 | u32 pdu_send_order; | 398 | u32 pdu_send_order; |
399 | /* Current struct iscsi_pdu in struct iscsi_cmd->pdu_list */ | 399 | /* Current struct iscsi_pdu in struct iscsi_cmd->pdu_list */ |
400 | u32 pdu_start; | 400 | u32 pdu_start; |
401 | u32 residual_count; | ||
402 | /* Next struct iscsi_seq to send in struct iscsi_cmd->seq_list */ | 401 | /* Next struct iscsi_seq to send in struct iscsi_cmd->seq_list */ |
403 | u32 seq_send_order; | 402 | u32 seq_send_order; |
404 | /* Number of struct iscsi_seq in struct iscsi_cmd->seq_list */ | 403 | /* Number of struct iscsi_seq in struct iscsi_cmd->seq_list */ |
@@ -535,7 +534,6 @@ struct iscsi_conn { | |||
535 | atomic_t connection_exit; | 534 | atomic_t connection_exit; |
536 | atomic_t connection_recovery; | 535 | atomic_t connection_recovery; |
537 | atomic_t connection_reinstatement; | 536 | atomic_t connection_reinstatement; |
538 | atomic_t connection_wait; | ||
539 | atomic_t connection_wait_rcfr; | 537 | atomic_t connection_wait_rcfr; |
540 | atomic_t sleep_on_conn_wait_comp; | 538 | atomic_t sleep_on_conn_wait_comp; |
541 | atomic_t transport_failed; | 539 | atomic_t transport_failed; |
@@ -643,7 +641,6 @@ struct iscsi_session { | |||
643 | atomic_t session_reinstatement; | 641 | atomic_t session_reinstatement; |
644 | atomic_t session_stop_active; | 642 | atomic_t session_stop_active; |
645 | atomic_t sleep_on_sess_wait_comp; | 643 | atomic_t sleep_on_sess_wait_comp; |
646 | atomic_t transport_wait_cmds; | ||
647 | /* connection list */ | 644 | /* connection list */ |
648 | struct list_head sess_conn_list; | 645 | struct list_head sess_conn_list; |
649 | struct list_head cr_active_list; | 646 | struct list_head cr_active_list; |
diff --git a/drivers/target/iscsi/iscsi_target_erl1.c b/drivers/target/iscsi/iscsi_target_erl1.c index c4c68da3e500..101b1beb3bca 100644 --- a/drivers/target/iscsi/iscsi_target_erl1.c +++ b/drivers/target/iscsi/iscsi_target_erl1.c | |||
@@ -938,8 +938,7 @@ int iscsit_execute_cmd(struct iscsi_cmd *cmd, int ooo) | |||
938 | * handle the SCF_SCSI_RESERVATION_CONFLICT case here as well. | 938 | * handle the SCF_SCSI_RESERVATION_CONFLICT case here as well. |
939 | */ | 939 | */ |
940 | if (se_cmd->se_cmd_flags & SCF_SCSI_CDB_EXCEPTION) { | 940 | if (se_cmd->se_cmd_flags & SCF_SCSI_CDB_EXCEPTION) { |
941 | if (se_cmd->se_cmd_flags & | 941 | if (se_cmd->scsi_sense_reason == TCM_RESERVATION_CONFLICT) { |
942 | SCF_SCSI_RESERVATION_CONFLICT) { | ||
943 | cmd->i_state = ISTATE_SEND_STATUS; | 942 | cmd->i_state = ISTATE_SEND_STATUS; |
944 | spin_unlock_bh(&cmd->istate_lock); | 943 | spin_unlock_bh(&cmd->istate_lock); |
945 | iscsit_add_cmd_to_response_queue(cmd, cmd->conn, | 944 | iscsit_add_cmd_to_response_queue(cmd, cmd->conn, |
diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c index daad362a93ce..d734bdec24f9 100644 --- a/drivers/target/iscsi/iscsi_target_login.c +++ b/drivers/target/iscsi/iscsi_target_login.c | |||
@@ -224,7 +224,7 @@ static int iscsi_login_zero_tsih_s1( | |||
224 | iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, | 224 | iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, |
225 | ISCSI_LOGIN_STATUS_NO_RESOURCES); | 225 | ISCSI_LOGIN_STATUS_NO_RESOURCES); |
226 | pr_err("Could not allocate memory for session\n"); | 226 | pr_err("Could not allocate memory for session\n"); |
227 | return -1; | 227 | return -ENOMEM; |
228 | } | 228 | } |
229 | 229 | ||
230 | iscsi_login_set_conn_values(sess, conn, pdu->cid); | 230 | iscsi_login_set_conn_values(sess, conn, pdu->cid); |
@@ -250,7 +250,8 @@ static int iscsi_login_zero_tsih_s1( | |||
250 | pr_err("idr_pre_get() for sess_idr failed\n"); | 250 | pr_err("idr_pre_get() for sess_idr failed\n"); |
251 | iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, | 251 | iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, |
252 | ISCSI_LOGIN_STATUS_NO_RESOURCES); | 252 | ISCSI_LOGIN_STATUS_NO_RESOURCES); |
253 | return -1; | 253 | kfree(sess); |
254 | return -ENOMEM; | ||
254 | } | 255 | } |
255 | spin_lock(&sess_idr_lock); | 256 | spin_lock(&sess_idr_lock); |
256 | idr_get_new(&sess_idr, NULL, &sess->session_index); | 257 | idr_get_new(&sess_idr, NULL, &sess->session_index); |
@@ -270,14 +271,16 @@ static int iscsi_login_zero_tsih_s1( | |||
270 | ISCSI_LOGIN_STATUS_NO_RESOURCES); | 271 | ISCSI_LOGIN_STATUS_NO_RESOURCES); |
271 | pr_err("Unable to allocate memory for" | 272 | pr_err("Unable to allocate memory for" |
272 | " struct iscsi_sess_ops.\n"); | 273 | " struct iscsi_sess_ops.\n"); |
273 | return -1; | 274 | kfree(sess); |
275 | return -ENOMEM; | ||
274 | } | 276 | } |
275 | 277 | ||
276 | sess->se_sess = transport_init_session(); | 278 | sess->se_sess = transport_init_session(); |
277 | if (!sess->se_sess) { | 279 | if (IS_ERR(sess->se_sess)) { |
278 | iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, | 280 | iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, |
279 | ISCSI_LOGIN_STATUS_NO_RESOURCES); | 281 | ISCSI_LOGIN_STATUS_NO_RESOURCES); |
280 | return -1; | 282 | kfree(sess); |
283 | return -ENOMEM; | ||
281 | } | 284 | } |
282 | 285 | ||
283 | return 0; | 286 | return 0; |
diff --git a/drivers/target/iscsi/iscsi_target_nego.c b/drivers/target/iscsi/iscsi_target_nego.c index 426cd4bf6a9a..98936cb7c294 100644 --- a/drivers/target/iscsi/iscsi_target_nego.c +++ b/drivers/target/iscsi/iscsi_target_nego.c | |||
@@ -981,14 +981,13 @@ struct iscsi_login *iscsi_target_init_negotiation( | |||
981 | return NULL; | 981 | return NULL; |
982 | } | 982 | } |
983 | 983 | ||
984 | login->req = kzalloc(ISCSI_HDR_LEN, GFP_KERNEL); | 984 | login->req = kmemdup(login_pdu, ISCSI_HDR_LEN, GFP_KERNEL); |
985 | if (!login->req) { | 985 | if (!login->req) { |
986 | pr_err("Unable to allocate memory for Login Request.\n"); | 986 | pr_err("Unable to allocate memory for Login Request.\n"); |
987 | iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, | 987 | iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, |
988 | ISCSI_LOGIN_STATUS_NO_RESOURCES); | 988 | ISCSI_LOGIN_STATUS_NO_RESOURCES); |
989 | goto out; | 989 | goto out; |
990 | } | 990 | } |
991 | memcpy(login->req, login_pdu, ISCSI_HDR_LEN); | ||
992 | 991 | ||
993 | login->req_buf = kzalloc(MAX_KEY_VALUE_PAIRS, GFP_KERNEL); | 992 | login->req_buf = kzalloc(MAX_KEY_VALUE_PAIRS, GFP_KERNEL); |
994 | if (!login->req_buf) { | 993 | if (!login->req_buf) { |
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index 3df1c9b8ae6b..81d5832fbbd5 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c | |||
@@ -113,11 +113,9 @@ static struct se_cmd *tcm_loop_allocate_core_cmd( | |||
113 | scsi_bufflen(sc), sc->sc_data_direction, sam_task_attr, | 113 | scsi_bufflen(sc), sc->sc_data_direction, sam_task_attr, |
114 | &tl_cmd->tl_sense_buf[0]); | 114 | &tl_cmd->tl_sense_buf[0]); |
115 | 115 | ||
116 | /* | ||
117 | * Signal BIDI usage with T_TASK(cmd)->t_tasks_bidi | ||
118 | */ | ||
119 | if (scsi_bidi_cmnd(sc)) | 116 | if (scsi_bidi_cmnd(sc)) |
120 | se_cmd->t_tasks_bidi = 1; | 117 | se_cmd->se_cmd_flags |= SCF_BIDI; |
118 | |||
121 | /* | 119 | /* |
122 | * Locate the struct se_lun pointer and attach it to struct se_cmd | 120 | * Locate the struct se_lun pointer and attach it to struct se_cmd |
123 | */ | 121 | */ |
@@ -148,27 +146,13 @@ static int tcm_loop_new_cmd_map(struct se_cmd *se_cmd) | |||
148 | * Allocate the necessary tasks to complete the received CDB+data | 146 | * Allocate the necessary tasks to complete the received CDB+data |
149 | */ | 147 | */ |
150 | ret = transport_generic_allocate_tasks(se_cmd, sc->cmnd); | 148 | ret = transport_generic_allocate_tasks(se_cmd, sc->cmnd); |
151 | if (ret == -ENOMEM) { | 149 | if (ret != 0) |
152 | /* Out of Resources */ | 150 | return ret; |
153 | return PYX_TRANSPORT_LU_COMM_FAILURE; | ||
154 | } else if (ret == -EINVAL) { | ||
155 | /* | ||
156 | * Handle case for SAM_STAT_RESERVATION_CONFLICT | ||
157 | */ | ||
158 | if (se_cmd->se_cmd_flags & SCF_SCSI_RESERVATION_CONFLICT) | ||
159 | return PYX_TRANSPORT_RESERVATION_CONFLICT; | ||
160 | /* | ||
161 | * Otherwise, return SAM_STAT_CHECK_CONDITION and return | ||
162 | * sense data. | ||
163 | */ | ||
164 | return PYX_TRANSPORT_USE_SENSE_REASON; | ||
165 | } | ||
166 | |||
167 | /* | 151 | /* |
168 | * For BIDI commands, pass in the extra READ buffer | 152 | * For BIDI commands, pass in the extra READ buffer |
169 | * to transport_generic_map_mem_to_cmd() below.. | 153 | * to transport_generic_map_mem_to_cmd() below.. |
170 | */ | 154 | */ |
171 | if (se_cmd->t_tasks_bidi) { | 155 | if (se_cmd->se_cmd_flags & SCF_BIDI) { |
172 | struct scsi_data_buffer *sdb = scsi_in(sc); | 156 | struct scsi_data_buffer *sdb = scsi_in(sc); |
173 | 157 | ||
174 | sgl_bidi = sdb->table.sgl; | 158 | sgl_bidi = sdb->table.sgl; |
@@ -194,12 +178,8 @@ static int tcm_loop_new_cmd_map(struct se_cmd *se_cmd) | |||
194 | } | 178 | } |
195 | 179 | ||
196 | /* Tell the core about our preallocated memory */ | 180 | /* Tell the core about our preallocated memory */ |
197 | ret = transport_generic_map_mem_to_cmd(se_cmd, scsi_sglist(sc), | 181 | return transport_generic_map_mem_to_cmd(se_cmd, scsi_sglist(sc), |
198 | scsi_sg_count(sc), sgl_bidi, sgl_bidi_count); | 182 | scsi_sg_count(sc), sgl_bidi, sgl_bidi_count); |
199 | if (ret < 0) | ||
200 | return PYX_TRANSPORT_LU_COMM_FAILURE; | ||
201 | |||
202 | return 0; | ||
203 | } | 183 | } |
204 | 184 | ||
205 | /* | 185 | /* |
@@ -1360,17 +1340,16 @@ void tcm_loop_drop_scsi_hba( | |||
1360 | { | 1340 | { |
1361 | struct tcm_loop_hba *tl_hba = container_of(wwn, | 1341 | struct tcm_loop_hba *tl_hba = container_of(wwn, |
1362 | struct tcm_loop_hba, tl_hba_wwn); | 1342 | struct tcm_loop_hba, tl_hba_wwn); |
1363 | int host_no = tl_hba->sh->host_no; | 1343 | |
1344 | pr_debug("TCM_Loop_ConfigFS: Deallocating emulated Target" | ||
1345 | " SAS Address: %s at Linux/SCSI Host ID: %d\n", | ||
1346 | tl_hba->tl_wwn_address, tl_hba->sh->host_no); | ||
1364 | /* | 1347 | /* |
1365 | * Call device_unregister() on the original tl_hba->dev. | 1348 | * Call device_unregister() on the original tl_hba->dev. |
1366 | * tcm_loop_fabric_scsi.c:tcm_loop_release_adapter() will | 1349 | * tcm_loop_fabric_scsi.c:tcm_loop_release_adapter() will |
1367 | * release *tl_hba; | 1350 | * release *tl_hba; |
1368 | */ | 1351 | */ |
1369 | device_unregister(&tl_hba->dev); | 1352 | device_unregister(&tl_hba->dev); |
1370 | |||
1371 | pr_debug("TCM_Loop_ConfigFS: Deallocated emulated Target" | ||
1372 | " SAS Address: %s at Linux/SCSI Host ID: %d\n", | ||
1373 | config_item_name(&wwn->wwn_group.cg_item), host_no); | ||
1374 | } | 1353 | } |
1375 | 1354 | ||
1376 | /* Start items for tcm_loop_cit */ | 1355 | /* Start items for tcm_loop_cit */ |
diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c index 88f2ad43ec8b..1dcbef499d6a 100644 --- a/drivers/target/target_core_alua.c +++ b/drivers/target/target_core_alua.c | |||
@@ -191,9 +191,10 @@ int target_emulate_set_target_port_groups(struct se_task *task) | |||
191 | int alua_access_state, primary = 0, rc; | 191 | int alua_access_state, primary = 0, rc; |
192 | u16 tg_pt_id, rtpi; | 192 | u16 tg_pt_id, rtpi; |
193 | 193 | ||
194 | if (!l_port) | 194 | if (!l_port) { |
195 | return PYX_TRANSPORT_LU_COMM_FAILURE; | 195 | cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
196 | 196 | return -EINVAL; | |
197 | } | ||
197 | buf = transport_kmap_first_data_page(cmd); | 198 | buf = transport_kmap_first_data_page(cmd); |
198 | 199 | ||
199 | /* | 200 | /* |
@@ -203,7 +204,8 @@ int target_emulate_set_target_port_groups(struct se_task *task) | |||
203 | l_tg_pt_gp_mem = l_port->sep_alua_tg_pt_gp_mem; | 204 | l_tg_pt_gp_mem = l_port->sep_alua_tg_pt_gp_mem; |
204 | if (!l_tg_pt_gp_mem) { | 205 | if (!l_tg_pt_gp_mem) { |
205 | pr_err("Unable to access l_port->sep_alua_tg_pt_gp_mem\n"); | 206 | pr_err("Unable to access l_port->sep_alua_tg_pt_gp_mem\n"); |
206 | rc = PYX_TRANSPORT_UNKNOWN_SAM_OPCODE; | 207 | cmd->scsi_sense_reason = TCM_UNSUPPORTED_SCSI_OPCODE; |
208 | rc = -EINVAL; | ||
207 | goto out; | 209 | goto out; |
208 | } | 210 | } |
209 | spin_lock(&l_tg_pt_gp_mem->tg_pt_gp_mem_lock); | 211 | spin_lock(&l_tg_pt_gp_mem->tg_pt_gp_mem_lock); |
@@ -211,7 +213,8 @@ int target_emulate_set_target_port_groups(struct se_task *task) | |||
211 | if (!l_tg_pt_gp) { | 213 | if (!l_tg_pt_gp) { |
212 | spin_unlock(&l_tg_pt_gp_mem->tg_pt_gp_mem_lock); | 214 | spin_unlock(&l_tg_pt_gp_mem->tg_pt_gp_mem_lock); |
213 | pr_err("Unable to access *l_tg_pt_gp_mem->tg_pt_gp\n"); | 215 | pr_err("Unable to access *l_tg_pt_gp_mem->tg_pt_gp\n"); |
214 | rc = PYX_TRANSPORT_UNKNOWN_SAM_OPCODE; | 216 | cmd->scsi_sense_reason = TCM_UNSUPPORTED_SCSI_OPCODE; |
217 | rc = -EINVAL; | ||
215 | goto out; | 218 | goto out; |
216 | } | 219 | } |
217 | rc = (l_tg_pt_gp->tg_pt_gp_alua_access_type & TPGS_EXPLICT_ALUA); | 220 | rc = (l_tg_pt_gp->tg_pt_gp_alua_access_type & TPGS_EXPLICT_ALUA); |
@@ -220,7 +223,8 @@ int target_emulate_set_target_port_groups(struct se_task *task) | |||
220 | if (!rc) { | 223 | if (!rc) { |
221 | pr_debug("Unable to process SET_TARGET_PORT_GROUPS" | 224 | pr_debug("Unable to process SET_TARGET_PORT_GROUPS" |
222 | " while TPGS_EXPLICT_ALUA is disabled\n"); | 225 | " while TPGS_EXPLICT_ALUA is disabled\n"); |
223 | rc = PYX_TRANSPORT_UNKNOWN_SAM_OPCODE; | 226 | cmd->scsi_sense_reason = TCM_UNSUPPORTED_SCSI_OPCODE; |
227 | rc = -EINVAL; | ||
224 | goto out; | 228 | goto out; |
225 | } | 229 | } |
226 | 230 | ||
@@ -245,7 +249,8 @@ int target_emulate_set_target_port_groups(struct se_task *task) | |||
245 | * REQUEST, and the additional sense code set to INVALID | 249 | * REQUEST, and the additional sense code set to INVALID |
246 | * FIELD IN PARAMETER LIST. | 250 | * FIELD IN PARAMETER LIST. |
247 | */ | 251 | */ |
248 | rc = PYX_TRANSPORT_INVALID_PARAMETER_LIST; | 252 | cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; |
253 | rc = -EINVAL; | ||
249 | goto out; | 254 | goto out; |
250 | } | 255 | } |
251 | rc = -1; | 256 | rc = -1; |
@@ -298,7 +303,8 @@ int target_emulate_set_target_port_groups(struct se_task *task) | |||
298 | * throw an exception with ASCQ: INVALID_PARAMETER_LIST | 303 | * throw an exception with ASCQ: INVALID_PARAMETER_LIST |
299 | */ | 304 | */ |
300 | if (rc != 0) { | 305 | if (rc != 0) { |
301 | rc = PYX_TRANSPORT_INVALID_PARAMETER_LIST; | 306 | cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; |
307 | rc = -EINVAL; | ||
302 | goto out; | 308 | goto out; |
303 | } | 309 | } |
304 | } else { | 310 | } else { |
@@ -335,7 +341,8 @@ int target_emulate_set_target_port_groups(struct se_task *task) | |||
335 | * INVALID_PARAMETER_LIST | 341 | * INVALID_PARAMETER_LIST |
336 | */ | 342 | */ |
337 | if (rc != 0) { | 343 | if (rc != 0) { |
338 | rc = PYX_TRANSPORT_INVALID_PARAMETER_LIST; | 344 | cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; |
345 | rc = -EINVAL; | ||
339 | goto out; | 346 | goto out; |
340 | } | 347 | } |
341 | } | 348 | } |
@@ -1184,7 +1191,6 @@ void core_alua_free_lu_gp(struct t10_alua_lu_gp *lu_gp) | |||
1184 | * struct t10_alua_lu_gp. | 1191 | * struct t10_alua_lu_gp. |
1185 | */ | 1192 | */ |
1186 | spin_lock(&lu_gps_lock); | 1193 | spin_lock(&lu_gps_lock); |
1187 | atomic_set(&lu_gp->lu_gp_shutdown, 1); | ||
1188 | list_del(&lu_gp->lu_gp_node); | 1194 | list_del(&lu_gp->lu_gp_node); |
1189 | alua_lu_gps_count--; | 1195 | alua_lu_gps_count--; |
1190 | spin_unlock(&lu_gps_lock); | 1196 | spin_unlock(&lu_gps_lock); |
@@ -1438,7 +1444,6 @@ struct t10_alua_tg_pt_gp_member *core_alua_allocate_tg_pt_gp_mem( | |||
1438 | 1444 | ||
1439 | tg_pt_gp_mem->tg_pt = port; | 1445 | tg_pt_gp_mem->tg_pt = port; |
1440 | port->sep_alua_tg_pt_gp_mem = tg_pt_gp_mem; | 1446 | port->sep_alua_tg_pt_gp_mem = tg_pt_gp_mem; |
1441 | atomic_set(&port->sep_tg_pt_gp_active, 1); | ||
1442 | 1447 | ||
1443 | return tg_pt_gp_mem; | 1448 | return tg_pt_gp_mem; |
1444 | } | 1449 | } |
diff --git a/drivers/target/target_core_cdb.c b/drivers/target/target_core_cdb.c index 683ba02b8247..831468b3163d 100644 --- a/drivers/target/target_core_cdb.c +++ b/drivers/target/target_core_cdb.c | |||
@@ -478,7 +478,7 @@ target_emulate_evpd_86(struct se_cmd *cmd, unsigned char *buf) | |||
478 | if (cmd->data_length < 60) | 478 | if (cmd->data_length < 60) |
479 | return 0; | 479 | return 0; |
480 | 480 | ||
481 | buf[2] = 0x3c; | 481 | buf[3] = 0x3c; |
482 | /* Set HEADSUP, ORDSUP, SIMPSUP */ | 482 | /* Set HEADSUP, ORDSUP, SIMPSUP */ |
483 | buf[5] = 0x07; | 483 | buf[5] = 0x07; |
484 | 484 | ||
@@ -703,6 +703,7 @@ int target_emulate_inquiry(struct se_task *task) | |||
703 | if (cmd->data_length < 4) { | 703 | if (cmd->data_length < 4) { |
704 | pr_err("SCSI Inquiry payload length: %u" | 704 | pr_err("SCSI Inquiry payload length: %u" |
705 | " too small for EVPD=1\n", cmd->data_length); | 705 | " too small for EVPD=1\n", cmd->data_length); |
706 | cmd->scsi_sense_reason = TCM_INVALID_CDB_FIELD; | ||
706 | return -EINVAL; | 707 | return -EINVAL; |
707 | } | 708 | } |
708 | 709 | ||
@@ -719,6 +720,7 @@ int target_emulate_inquiry(struct se_task *task) | |||
719 | } | 720 | } |
720 | 721 | ||
721 | pr_err("Unknown VPD Code: 0x%02x\n", cdb[2]); | 722 | pr_err("Unknown VPD Code: 0x%02x\n", cdb[2]); |
723 | cmd->scsi_sense_reason = TCM_UNSUPPORTED_SCSI_OPCODE; | ||
722 | ret = -EINVAL; | 724 | ret = -EINVAL; |
723 | 725 | ||
724 | out_unmap: | 726 | out_unmap: |
@@ -969,7 +971,8 @@ int target_emulate_modesense(struct se_task *task) | |||
969 | default: | 971 | default: |
970 | pr_err("MODE SENSE: unimplemented page/subpage: 0x%02x/0x%02x\n", | 972 | pr_err("MODE SENSE: unimplemented page/subpage: 0x%02x/0x%02x\n", |
971 | cdb[2] & 0x3f, cdb[3]); | 973 | cdb[2] & 0x3f, cdb[3]); |
972 | return PYX_TRANSPORT_UNKNOWN_MODE_PAGE; | 974 | cmd->scsi_sense_reason = TCM_UNKNOWN_MODE_PAGE; |
975 | return -EINVAL; | ||
973 | } | 976 | } |
974 | offset += length; | 977 | offset += length; |
975 | 978 | ||
@@ -1027,7 +1030,8 @@ int target_emulate_request_sense(struct se_task *task) | |||
1027 | if (cdb[1] & 0x01) { | 1030 | if (cdb[1] & 0x01) { |
1028 | pr_err("REQUEST_SENSE description emulation not" | 1031 | pr_err("REQUEST_SENSE description emulation not" |
1029 | " supported\n"); | 1032 | " supported\n"); |
1030 | return PYX_TRANSPORT_INVALID_CDB_FIELD; | 1033 | cmd->scsi_sense_reason = TCM_INVALID_CDB_FIELD; |
1034 | return -ENOSYS; | ||
1031 | } | 1035 | } |
1032 | 1036 | ||
1033 | buf = transport_kmap_first_data_page(cmd); | 1037 | buf = transport_kmap_first_data_page(cmd); |
@@ -1100,7 +1104,8 @@ int target_emulate_unmap(struct se_task *task) | |||
1100 | if (!dev->transport->do_discard) { | 1104 | if (!dev->transport->do_discard) { |
1101 | pr_err("UNMAP emulation not supported for: %s\n", | 1105 | pr_err("UNMAP emulation not supported for: %s\n", |
1102 | dev->transport->name); | 1106 | dev->transport->name); |
1103 | return PYX_TRANSPORT_UNKNOWN_SAM_OPCODE; | 1107 | cmd->scsi_sense_reason = TCM_UNSUPPORTED_SCSI_OPCODE; |
1108 | return -ENOSYS; | ||
1104 | } | 1109 | } |
1105 | 1110 | ||
1106 | /* First UNMAP block descriptor starts at 8 byte offset */ | 1111 | /* First UNMAP block descriptor starts at 8 byte offset */ |
@@ -1157,7 +1162,8 @@ int target_emulate_write_same(struct se_task *task) | |||
1157 | if (!dev->transport->do_discard) { | 1162 | if (!dev->transport->do_discard) { |
1158 | pr_err("WRITE_SAME emulation not supported" | 1163 | pr_err("WRITE_SAME emulation not supported" |
1159 | " for: %s\n", dev->transport->name); | 1164 | " for: %s\n", dev->transport->name); |
1160 | return PYX_TRANSPORT_UNKNOWN_SAM_OPCODE; | 1165 | cmd->scsi_sense_reason = TCM_UNSUPPORTED_SCSI_OPCODE; |
1166 | return -ENOSYS; | ||
1161 | } | 1167 | } |
1162 | 1168 | ||
1163 | if (cmd->t_task_cdb[0] == WRITE_SAME) | 1169 | if (cmd->t_task_cdb[0] == WRITE_SAME) |
@@ -1193,11 +1199,13 @@ int target_emulate_write_same(struct se_task *task) | |||
1193 | int target_emulate_synchronize_cache(struct se_task *task) | 1199 | int target_emulate_synchronize_cache(struct se_task *task) |
1194 | { | 1200 | { |
1195 | struct se_device *dev = task->task_se_cmd->se_dev; | 1201 | struct se_device *dev = task->task_se_cmd->se_dev; |
1202 | struct se_cmd *cmd = task->task_se_cmd; | ||
1196 | 1203 | ||
1197 | if (!dev->transport->do_sync_cache) { | 1204 | if (!dev->transport->do_sync_cache) { |
1198 | pr_err("SYNCHRONIZE_CACHE emulation not supported" | 1205 | pr_err("SYNCHRONIZE_CACHE emulation not supported" |
1199 | " for: %s\n", dev->transport->name); | 1206 | " for: %s\n", dev->transport->name); |
1200 | return PYX_TRANSPORT_UNKNOWN_SAM_OPCODE; | 1207 | cmd->scsi_sense_reason = TCM_UNSUPPORTED_SCSI_OPCODE; |
1208 | return -ENOSYS; | ||
1201 | } | 1209 | } |
1202 | 1210 | ||
1203 | dev->transport->do_sync_cache(task); | 1211 | dev->transport->do_sync_cache(task); |
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index e0c1e8a8dd4e..93d4f6a1b798 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c | |||
@@ -67,9 +67,6 @@ static struct config_group target_core_hbagroup; | |||
67 | static struct config_group alua_group; | 67 | static struct config_group alua_group; |
68 | static struct config_group alua_lu_gps_group; | 68 | static struct config_group alua_lu_gps_group; |
69 | 69 | ||
70 | static DEFINE_SPINLOCK(se_device_lock); | ||
71 | static LIST_HEAD(se_dev_list); | ||
72 | |||
73 | static inline struct se_hba * | 70 | static inline struct se_hba * |
74 | item_to_hba(struct config_item *item) | 71 | item_to_hba(struct config_item *item) |
75 | { | 72 | { |
@@ -2741,7 +2738,6 @@ static struct config_group *target_core_make_subdev( | |||
2741 | " struct se_subsystem_dev\n"); | 2738 | " struct se_subsystem_dev\n"); |
2742 | goto unlock; | 2739 | goto unlock; |
2743 | } | 2740 | } |
2744 | INIT_LIST_HEAD(&se_dev->se_dev_node); | ||
2745 | INIT_LIST_HEAD(&se_dev->t10_wwn.t10_vpd_list); | 2741 | INIT_LIST_HEAD(&se_dev->t10_wwn.t10_vpd_list); |
2746 | spin_lock_init(&se_dev->t10_wwn.t10_vpd_lock); | 2742 | spin_lock_init(&se_dev->t10_wwn.t10_vpd_lock); |
2747 | INIT_LIST_HEAD(&se_dev->t10_pr.registration_list); | 2743 | INIT_LIST_HEAD(&se_dev->t10_pr.registration_list); |
@@ -2777,9 +2773,6 @@ static struct config_group *target_core_make_subdev( | |||
2777 | " from allocate_virtdevice()\n"); | 2773 | " from allocate_virtdevice()\n"); |
2778 | goto out; | 2774 | goto out; |
2779 | } | 2775 | } |
2780 | spin_lock(&se_device_lock); | ||
2781 | list_add_tail(&se_dev->se_dev_node, &se_dev_list); | ||
2782 | spin_unlock(&se_device_lock); | ||
2783 | 2776 | ||
2784 | config_group_init_type_name(&se_dev->se_dev_group, name, | 2777 | config_group_init_type_name(&se_dev->se_dev_group, name, |
2785 | &target_core_dev_cit); | 2778 | &target_core_dev_cit); |
@@ -2874,10 +2867,6 @@ static void target_core_drop_subdev( | |||
2874 | mutex_lock(&hba->hba_access_mutex); | 2867 | mutex_lock(&hba->hba_access_mutex); |
2875 | t = hba->transport; | 2868 | t = hba->transport; |
2876 | 2869 | ||
2877 | spin_lock(&se_device_lock); | ||
2878 | list_del(&se_dev->se_dev_node); | ||
2879 | spin_unlock(&se_device_lock); | ||
2880 | |||
2881 | dev_stat_grp = &se_dev->dev_stat_grps.stat_group; | 2870 | dev_stat_grp = &se_dev->dev_stat_grps.stat_group; |
2882 | for (i = 0; dev_stat_grp->default_groups[i]; i++) { | 2871 | for (i = 0; dev_stat_grp->default_groups[i]; i++) { |
2883 | df_item = &dev_stat_grp->default_groups[i]->cg_item; | 2872 | df_item = &dev_stat_grp->default_groups[i]->cg_item; |
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index ba5edec2c5f8..9b8639425472 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c | |||
@@ -104,7 +104,6 @@ int transport_lookup_cmd_lun(struct se_cmd *se_cmd, u32 unpacked_lun) | |||
104 | se_cmd->se_lun = deve->se_lun; | 104 | se_cmd->se_lun = deve->se_lun; |
105 | se_cmd->pr_res_key = deve->pr_res_key; | 105 | se_cmd->pr_res_key = deve->pr_res_key; |
106 | se_cmd->orig_fe_lun = unpacked_lun; | 106 | se_cmd->orig_fe_lun = unpacked_lun; |
107 | se_cmd->se_orig_obj_ptr = se_cmd->se_lun->lun_se_dev; | ||
108 | se_cmd->se_cmd_flags |= SCF_SE_LUN_CMD; | 107 | se_cmd->se_cmd_flags |= SCF_SE_LUN_CMD; |
109 | } | 108 | } |
110 | spin_unlock_irqrestore(&se_sess->se_node_acl->device_list_lock, flags); | 109 | spin_unlock_irqrestore(&se_sess->se_node_acl->device_list_lock, flags); |
@@ -137,7 +136,6 @@ int transport_lookup_cmd_lun(struct se_cmd *se_cmd, u32 unpacked_lun) | |||
137 | se_lun = &se_sess->se_tpg->tpg_virt_lun0; | 136 | se_lun = &se_sess->se_tpg->tpg_virt_lun0; |
138 | se_cmd->se_lun = &se_sess->se_tpg->tpg_virt_lun0; | 137 | se_cmd->se_lun = &se_sess->se_tpg->tpg_virt_lun0; |
139 | se_cmd->orig_fe_lun = 0; | 138 | se_cmd->orig_fe_lun = 0; |
140 | se_cmd->se_orig_obj_ptr = se_cmd->se_lun->lun_se_dev; | ||
141 | se_cmd->se_cmd_flags |= SCF_SE_LUN_CMD; | 139 | se_cmd->se_cmd_flags |= SCF_SE_LUN_CMD; |
142 | } | 140 | } |
143 | /* | 141 | /* |
@@ -200,7 +198,6 @@ int transport_lookup_tmr_lun(struct se_cmd *se_cmd, u32 unpacked_lun) | |||
200 | se_lun = deve->se_lun; | 198 | se_lun = deve->se_lun; |
201 | se_cmd->pr_res_key = deve->pr_res_key; | 199 | se_cmd->pr_res_key = deve->pr_res_key; |
202 | se_cmd->orig_fe_lun = unpacked_lun; | 200 | se_cmd->orig_fe_lun = unpacked_lun; |
203 | se_cmd->se_orig_obj_ptr = se_cmd->se_dev; | ||
204 | } | 201 | } |
205 | spin_unlock_irqrestore(&se_sess->se_node_acl->device_list_lock, flags); | 202 | spin_unlock_irqrestore(&se_sess->se_node_acl->device_list_lock, flags); |
206 | 203 | ||
@@ -708,7 +705,7 @@ done: | |||
708 | 705 | ||
709 | se_task->task_scsi_status = GOOD; | 706 | se_task->task_scsi_status = GOOD; |
710 | transport_complete_task(se_task, 1); | 707 | transport_complete_task(se_task, 1); |
711 | return PYX_TRANSPORT_SENT_TO_TRANSPORT; | 708 | return 0; |
712 | } | 709 | } |
713 | 710 | ||
714 | /* se_release_device_for_hba(): | 711 | /* se_release_device_for_hba(): |
@@ -957,8 +954,12 @@ int se_dev_set_emulate_dpo(struct se_device *dev, int flag) | |||
957 | return -EINVAL; | 954 | return -EINVAL; |
958 | } | 955 | } |
959 | 956 | ||
960 | pr_err("dpo_emulated not supported\n"); | 957 | if (flag) { |
961 | return -EINVAL; | 958 | pr_err("dpo_emulated not supported\n"); |
959 | return -EINVAL; | ||
960 | } | ||
961 | |||
962 | return 0; | ||
962 | } | 963 | } |
963 | 964 | ||
964 | int se_dev_set_emulate_fua_write(struct se_device *dev, int flag) | 965 | int se_dev_set_emulate_fua_write(struct se_device *dev, int flag) |
@@ -968,7 +969,7 @@ int se_dev_set_emulate_fua_write(struct se_device *dev, int flag) | |||
968 | return -EINVAL; | 969 | return -EINVAL; |
969 | } | 970 | } |
970 | 971 | ||
971 | if (dev->transport->fua_write_emulated == 0) { | 972 | if (flag && dev->transport->fua_write_emulated == 0) { |
972 | pr_err("fua_write_emulated not supported\n"); | 973 | pr_err("fua_write_emulated not supported\n"); |
973 | return -EINVAL; | 974 | return -EINVAL; |
974 | } | 975 | } |
@@ -985,8 +986,12 @@ int se_dev_set_emulate_fua_read(struct se_device *dev, int flag) | |||
985 | return -EINVAL; | 986 | return -EINVAL; |
986 | } | 987 | } |
987 | 988 | ||
988 | pr_err("ua read emulated not supported\n"); | 989 | if (flag) { |
989 | return -EINVAL; | 990 | pr_err("ua read emulated not supported\n"); |
991 | return -EINVAL; | ||
992 | } | ||
993 | |||
994 | return 0; | ||
990 | } | 995 | } |
991 | 996 | ||
992 | int se_dev_set_emulate_write_cache(struct se_device *dev, int flag) | 997 | int se_dev_set_emulate_write_cache(struct se_device *dev, int flag) |
@@ -995,7 +1000,7 @@ int se_dev_set_emulate_write_cache(struct se_device *dev, int flag) | |||
995 | pr_err("Illegal value %d\n", flag); | 1000 | pr_err("Illegal value %d\n", flag); |
996 | return -EINVAL; | 1001 | return -EINVAL; |
997 | } | 1002 | } |
998 | if (dev->transport->write_cache_emulated == 0) { | 1003 | if (flag && dev->transport->write_cache_emulated == 0) { |
999 | pr_err("write_cache_emulated not supported\n"); | 1004 | pr_err("write_cache_emulated not supported\n"); |
1000 | return -EINVAL; | 1005 | return -EINVAL; |
1001 | } | 1006 | } |
@@ -1056,7 +1061,7 @@ int se_dev_set_emulate_tpu(struct se_device *dev, int flag) | |||
1056 | * We expect this value to be non-zero when generic Block Layer | 1061 | * We expect this value to be non-zero when generic Block Layer |
1057 | * Discard supported is detected iblock_create_virtdevice(). | 1062 | * Discard supported is detected iblock_create_virtdevice(). |
1058 | */ | 1063 | */ |
1059 | if (!dev->se_sub_dev->se_dev_attrib.max_unmap_block_desc_count) { | 1064 | if (flag && !dev->se_sub_dev->se_dev_attrib.max_unmap_block_desc_count) { |
1060 | pr_err("Generic Block Discard not supported\n"); | 1065 | pr_err("Generic Block Discard not supported\n"); |
1061 | return -ENOSYS; | 1066 | return -ENOSYS; |
1062 | } | 1067 | } |
@@ -1077,7 +1082,7 @@ int se_dev_set_emulate_tpws(struct se_device *dev, int flag) | |||
1077 | * We expect this value to be non-zero when generic Block Layer | 1082 | * We expect this value to be non-zero when generic Block Layer |
1078 | * Discard supported is detected iblock_create_virtdevice(). | 1083 | * Discard supported is detected iblock_create_virtdevice(). |
1079 | */ | 1084 | */ |
1080 | if (!dev->se_sub_dev->se_dev_attrib.max_unmap_block_desc_count) { | 1085 | if (flag && !dev->se_sub_dev->se_dev_attrib.max_unmap_block_desc_count) { |
1081 | pr_err("Generic Block Discard not supported\n"); | 1086 | pr_err("Generic Block Discard not supported\n"); |
1082 | return -ENOSYS; | 1087 | return -ENOSYS; |
1083 | } | 1088 | } |
@@ -1587,7 +1592,6 @@ int core_dev_setup_virtual_lun0(void) | |||
1587 | ret = -ENOMEM; | 1592 | ret = -ENOMEM; |
1588 | goto out; | 1593 | goto out; |
1589 | } | 1594 | } |
1590 | INIT_LIST_HEAD(&se_dev->se_dev_node); | ||
1591 | INIT_LIST_HEAD(&se_dev->t10_wwn.t10_vpd_list); | 1595 | INIT_LIST_HEAD(&se_dev->t10_wwn.t10_vpd_list); |
1592 | spin_lock_init(&se_dev->t10_wwn.t10_vpd_lock); | 1596 | spin_lock_init(&se_dev->t10_wwn.t10_vpd_lock); |
1593 | INIT_LIST_HEAD(&se_dev->t10_pr.registration_list); | 1597 | INIT_LIST_HEAD(&se_dev->t10_pr.registration_list); |
diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c index 67cd6fe05bfa..b4864fba4ef0 100644 --- a/drivers/target/target_core_file.c +++ b/drivers/target/target_core_file.c | |||
@@ -289,9 +289,9 @@ static int fd_do_readv(struct se_task *task) | |||
289 | return -ENOMEM; | 289 | return -ENOMEM; |
290 | } | 290 | } |
291 | 291 | ||
292 | for (i = 0; i < task->task_sg_nents; i++) { | 292 | for_each_sg(task->task_sg, sg, task->task_sg_nents, i) { |
293 | iov[i].iov_len = sg[i].length; | 293 | iov[i].iov_len = sg->length; |
294 | iov[i].iov_base = sg_virt(&sg[i]); | 294 | iov[i].iov_base = sg_virt(sg); |
295 | } | 295 | } |
296 | 296 | ||
297 | old_fs = get_fs(); | 297 | old_fs = get_fs(); |
@@ -342,9 +342,9 @@ static int fd_do_writev(struct se_task *task) | |||
342 | return -ENOMEM; | 342 | return -ENOMEM; |
343 | } | 343 | } |
344 | 344 | ||
345 | for (i = 0; i < task->task_sg_nents; i++) { | 345 | for_each_sg(task->task_sg, sg, task->task_sg_nents, i) { |
346 | iov[i].iov_len = sg[i].length; | 346 | iov[i].iov_len = sg->length; |
347 | iov[i].iov_base = sg_virt(&sg[i]); | 347 | iov[i].iov_base = sg_virt(sg); |
348 | } | 348 | } |
349 | 349 | ||
350 | old_fs = get_fs(); | 350 | old_fs = get_fs(); |
@@ -438,7 +438,7 @@ static int fd_do_task(struct se_task *task) | |||
438 | if (ret > 0 && | 438 | if (ret > 0 && |
439 | dev->se_sub_dev->se_dev_attrib.emulate_write_cache > 0 && | 439 | dev->se_sub_dev->se_dev_attrib.emulate_write_cache > 0 && |
440 | dev->se_sub_dev->se_dev_attrib.emulate_fua_write > 0 && | 440 | dev->se_sub_dev->se_dev_attrib.emulate_fua_write > 0 && |
441 | cmd->t_tasks_fua) { | 441 | (cmd->se_cmd_flags & SCF_FUA)) { |
442 | /* | 442 | /* |
443 | * We might need to be a bit smarter here | 443 | * We might need to be a bit smarter here |
444 | * and return some sense data to let the initiator | 444 | * and return some sense data to let the initiator |
@@ -449,13 +449,15 @@ static int fd_do_task(struct se_task *task) | |||
449 | 449 | ||
450 | } | 450 | } |
451 | 451 | ||
452 | if (ret < 0) | 452 | if (ret < 0) { |
453 | cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; | ||
453 | return ret; | 454 | return ret; |
455 | } | ||
454 | if (ret) { | 456 | if (ret) { |
455 | task->task_scsi_status = GOOD; | 457 | task->task_scsi_status = GOOD; |
456 | transport_complete_task(task, 1); | 458 | transport_complete_task(task, 1); |
457 | } | 459 | } |
458 | return PYX_TRANSPORT_SENT_TO_TRANSPORT; | 460 | return 0; |
459 | } | 461 | } |
460 | 462 | ||
461 | /* fd_free_task(): (Part of se_subsystem_api_t template) | 463 | /* fd_free_task(): (Part of se_subsystem_api_t template) |
diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c index 7698efe29262..4aa992204438 100644 --- a/drivers/target/target_core_iblock.c +++ b/drivers/target/target_core_iblock.c | |||
@@ -531,7 +531,7 @@ static int iblock_do_task(struct se_task *task) | |||
531 | */ | 531 | */ |
532 | if (dev->se_sub_dev->se_dev_attrib.emulate_write_cache == 0 || | 532 | if (dev->se_sub_dev->se_dev_attrib.emulate_write_cache == 0 || |
533 | (dev->se_sub_dev->se_dev_attrib.emulate_fua_write > 0 && | 533 | (dev->se_sub_dev->se_dev_attrib.emulate_fua_write > 0 && |
534 | task->task_se_cmd->t_tasks_fua)) | 534 | (cmd->se_cmd_flags & SCF_FUA))) |
535 | rw = WRITE_FUA; | 535 | rw = WRITE_FUA; |
536 | else | 536 | else |
537 | rw = WRITE; | 537 | rw = WRITE; |
@@ -554,12 +554,15 @@ static int iblock_do_task(struct se_task *task) | |||
554 | else { | 554 | else { |
555 | pr_err("Unsupported SCSI -> BLOCK LBA conversion:" | 555 | pr_err("Unsupported SCSI -> BLOCK LBA conversion:" |
556 | " %u\n", dev->se_sub_dev->se_dev_attrib.block_size); | 556 | " %u\n", dev->se_sub_dev->se_dev_attrib.block_size); |
557 | return PYX_TRANSPORT_LU_COMM_FAILURE; | 557 | cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
558 | return -ENOSYS; | ||
558 | } | 559 | } |
559 | 560 | ||
560 | bio = iblock_get_bio(task, block_lba, sg_num); | 561 | bio = iblock_get_bio(task, block_lba, sg_num); |
561 | if (!bio) | 562 | if (!bio) { |
562 | return PYX_TRANSPORT_OUT_OF_MEMORY_RESOURCES; | 563 | cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
564 | return -ENOMEM; | ||
565 | } | ||
563 | 566 | ||
564 | bio_list_init(&list); | 567 | bio_list_init(&list); |
565 | bio_list_add(&list, bio); | 568 | bio_list_add(&list, bio); |
@@ -588,12 +591,13 @@ static int iblock_do_task(struct se_task *task) | |||
588 | submit_bio(rw, bio); | 591 | submit_bio(rw, bio); |
589 | blk_finish_plug(&plug); | 592 | blk_finish_plug(&plug); |
590 | 593 | ||
591 | return PYX_TRANSPORT_SENT_TO_TRANSPORT; | 594 | return 0; |
592 | 595 | ||
593 | fail: | 596 | fail: |
594 | while ((bio = bio_list_pop(&list))) | 597 | while ((bio = bio_list_pop(&list))) |
595 | bio_put(bio); | 598 | bio_put(bio); |
596 | return PYX_TRANSPORT_OUT_OF_MEMORY_RESOURCES; | 599 | cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
600 | return -ENOMEM; | ||
597 | } | 601 | } |
598 | 602 | ||
599 | static u32 iblock_get_device_rev(struct se_device *dev) | 603 | static u32 iblock_get_device_rev(struct se_device *dev) |
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c index 5a4ebfc3a54f..95dee7074aeb 100644 --- a/drivers/target/target_core_pr.c +++ b/drivers/target/target_core_pr.c | |||
@@ -191,7 +191,7 @@ static int target_check_scsi2_reservation_conflict(struct se_cmd *cmd, int *ret) | |||
191 | pr_err("Received legacy SPC-2 RESERVE/RELEASE" | 191 | pr_err("Received legacy SPC-2 RESERVE/RELEASE" |
192 | " while active SPC-3 registrations exist," | 192 | " while active SPC-3 registrations exist," |
193 | " returning RESERVATION_CONFLICT\n"); | 193 | " returning RESERVATION_CONFLICT\n"); |
194 | *ret = PYX_TRANSPORT_RESERVATION_CONFLICT; | 194 | cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT; |
195 | return true; | 195 | return true; |
196 | } | 196 | } |
197 | 197 | ||
@@ -252,7 +252,8 @@ int target_scsi2_reservation_reserve(struct se_task *task) | |||
252 | (cmd->t_task_cdb[1] & 0x02)) { | 252 | (cmd->t_task_cdb[1] & 0x02)) { |
253 | pr_err("LongIO and Obselete Bits set, returning" | 253 | pr_err("LongIO and Obselete Bits set, returning" |
254 | " ILLEGAL_REQUEST\n"); | 254 | " ILLEGAL_REQUEST\n"); |
255 | ret = PYX_TRANSPORT_ILLEGAL_REQUEST; | 255 | cmd->scsi_sense_reason = TCM_UNSUPPORTED_SCSI_OPCODE; |
256 | ret = -EINVAL; | ||
256 | goto out; | 257 | goto out; |
257 | } | 258 | } |
258 | /* | 259 | /* |
@@ -277,7 +278,8 @@ int target_scsi2_reservation_reserve(struct se_task *task) | |||
277 | " from %s \n", cmd->se_lun->unpacked_lun, | 278 | " from %s \n", cmd->se_lun->unpacked_lun, |
278 | cmd->se_deve->mapped_lun, | 279 | cmd->se_deve->mapped_lun, |
279 | sess->se_node_acl->initiatorname); | 280 | sess->se_node_acl->initiatorname); |
280 | ret = PYX_TRANSPORT_RESERVATION_CONFLICT; | 281 | cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT; |
282 | ret = -EINVAL; | ||
281 | goto out_unlock; | 283 | goto out_unlock; |
282 | } | 284 | } |
283 | 285 | ||
@@ -1510,7 +1512,8 @@ static int core_scsi3_decode_spec_i_port( | |||
1510 | tidh_new = kzalloc(sizeof(struct pr_transport_id_holder), GFP_KERNEL); | 1512 | tidh_new = kzalloc(sizeof(struct pr_transport_id_holder), GFP_KERNEL); |
1511 | if (!tidh_new) { | 1513 | if (!tidh_new) { |
1512 | pr_err("Unable to allocate tidh_new\n"); | 1514 | pr_err("Unable to allocate tidh_new\n"); |
1513 | return PYX_TRANSPORT_LU_COMM_FAILURE; | 1515 | cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
1516 | return -EINVAL; | ||
1514 | } | 1517 | } |
1515 | INIT_LIST_HEAD(&tidh_new->dest_list); | 1518 | INIT_LIST_HEAD(&tidh_new->dest_list); |
1516 | tidh_new->dest_tpg = tpg; | 1519 | tidh_new->dest_tpg = tpg; |
@@ -1522,7 +1525,8 @@ static int core_scsi3_decode_spec_i_port( | |||
1522 | sa_res_key, all_tg_pt, aptpl); | 1525 | sa_res_key, all_tg_pt, aptpl); |
1523 | if (!local_pr_reg) { | 1526 | if (!local_pr_reg) { |
1524 | kfree(tidh_new); | 1527 | kfree(tidh_new); |
1525 | return PYX_TRANSPORT_LU_COMM_FAILURE; | 1528 | cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
1529 | return -ENOMEM; | ||
1526 | } | 1530 | } |
1527 | tidh_new->dest_pr_reg = local_pr_reg; | 1531 | tidh_new->dest_pr_reg = local_pr_reg; |
1528 | /* | 1532 | /* |
@@ -1548,7 +1552,8 @@ static int core_scsi3_decode_spec_i_port( | |||
1548 | pr_err("SPC-3 PR: Illegal tpdl: %u + 28 byte header" | 1552 | pr_err("SPC-3 PR: Illegal tpdl: %u + 28 byte header" |
1549 | " does not equal CDB data_length: %u\n", tpdl, | 1553 | " does not equal CDB data_length: %u\n", tpdl, |
1550 | cmd->data_length); | 1554 | cmd->data_length); |
1551 | ret = PYX_TRANSPORT_INVALID_PARAMETER_LIST; | 1555 | cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; |
1556 | ret = -EINVAL; | ||
1552 | goto out; | 1557 | goto out; |
1553 | } | 1558 | } |
1554 | /* | 1559 | /* |
@@ -1598,7 +1603,9 @@ static int core_scsi3_decode_spec_i_port( | |||
1598 | " for tmp_tpg\n"); | 1603 | " for tmp_tpg\n"); |
1599 | atomic_dec(&tmp_tpg->tpg_pr_ref_count); | 1604 | atomic_dec(&tmp_tpg->tpg_pr_ref_count); |
1600 | smp_mb__after_atomic_dec(); | 1605 | smp_mb__after_atomic_dec(); |
1601 | ret = PYX_TRANSPORT_LU_COMM_FAILURE; | 1606 | cmd->scsi_sense_reason = |
1607 | TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; | ||
1608 | ret = -EINVAL; | ||
1602 | goto out; | 1609 | goto out; |
1603 | } | 1610 | } |
1604 | /* | 1611 | /* |
@@ -1628,7 +1635,9 @@ static int core_scsi3_decode_spec_i_port( | |||
1628 | atomic_dec(&dest_node_acl->acl_pr_ref_count); | 1635 | atomic_dec(&dest_node_acl->acl_pr_ref_count); |
1629 | smp_mb__after_atomic_dec(); | 1636 | smp_mb__after_atomic_dec(); |
1630 | core_scsi3_tpg_undepend_item(tmp_tpg); | 1637 | core_scsi3_tpg_undepend_item(tmp_tpg); |
1631 | ret = PYX_TRANSPORT_LU_COMM_FAILURE; | 1638 | cmd->scsi_sense_reason = |
1639 | TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; | ||
1640 | ret = -EINVAL; | ||
1632 | goto out; | 1641 | goto out; |
1633 | } | 1642 | } |
1634 | 1643 | ||
@@ -1646,7 +1655,8 @@ static int core_scsi3_decode_spec_i_port( | |||
1646 | if (!dest_tpg) { | 1655 | if (!dest_tpg) { |
1647 | pr_err("SPC-3 PR SPEC_I_PT: Unable to locate" | 1656 | pr_err("SPC-3 PR SPEC_I_PT: Unable to locate" |
1648 | " dest_tpg\n"); | 1657 | " dest_tpg\n"); |
1649 | ret = PYX_TRANSPORT_INVALID_PARAMETER_LIST; | 1658 | cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; |
1659 | ret = -EINVAL; | ||
1650 | goto out; | 1660 | goto out; |
1651 | } | 1661 | } |
1652 | #if 0 | 1662 | #if 0 |
@@ -1660,7 +1670,8 @@ static int core_scsi3_decode_spec_i_port( | |||
1660 | " %u for Transport ID: %s\n", tid_len, ptr); | 1670 | " %u for Transport ID: %s\n", tid_len, ptr); |
1661 | core_scsi3_nodeacl_undepend_item(dest_node_acl); | 1671 | core_scsi3_nodeacl_undepend_item(dest_node_acl); |
1662 | core_scsi3_tpg_undepend_item(dest_tpg); | 1672 | core_scsi3_tpg_undepend_item(dest_tpg); |
1663 | ret = PYX_TRANSPORT_INVALID_PARAMETER_LIST; | 1673 | cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; |
1674 | ret = -EINVAL; | ||
1664 | goto out; | 1675 | goto out; |
1665 | } | 1676 | } |
1666 | /* | 1677 | /* |
@@ -1678,7 +1689,8 @@ static int core_scsi3_decode_spec_i_port( | |||
1678 | 1689 | ||
1679 | core_scsi3_nodeacl_undepend_item(dest_node_acl); | 1690 | core_scsi3_nodeacl_undepend_item(dest_node_acl); |
1680 | core_scsi3_tpg_undepend_item(dest_tpg); | 1691 | core_scsi3_tpg_undepend_item(dest_tpg); |
1681 | ret = PYX_TRANSPORT_INVALID_PARAMETER_LIST; | 1692 | cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; |
1693 | ret = -EINVAL; | ||
1682 | goto out; | 1694 | goto out; |
1683 | } | 1695 | } |
1684 | 1696 | ||
@@ -1690,7 +1702,9 @@ static int core_scsi3_decode_spec_i_port( | |||
1690 | smp_mb__after_atomic_dec(); | 1702 | smp_mb__after_atomic_dec(); |
1691 | core_scsi3_nodeacl_undepend_item(dest_node_acl); | 1703 | core_scsi3_nodeacl_undepend_item(dest_node_acl); |
1692 | core_scsi3_tpg_undepend_item(dest_tpg); | 1704 | core_scsi3_tpg_undepend_item(dest_tpg); |
1693 | ret = PYX_TRANSPORT_LU_COMM_FAILURE; | 1705 | cmd->scsi_sense_reason = |
1706 | TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; | ||
1707 | ret = -EINVAL; | ||
1694 | goto out; | 1708 | goto out; |
1695 | } | 1709 | } |
1696 | #if 0 | 1710 | #if 0 |
@@ -1727,7 +1741,9 @@ static int core_scsi3_decode_spec_i_port( | |||
1727 | core_scsi3_lunacl_undepend_item(dest_se_deve); | 1741 | core_scsi3_lunacl_undepend_item(dest_se_deve); |
1728 | core_scsi3_nodeacl_undepend_item(dest_node_acl); | 1742 | core_scsi3_nodeacl_undepend_item(dest_node_acl); |
1729 | core_scsi3_tpg_undepend_item(dest_tpg); | 1743 | core_scsi3_tpg_undepend_item(dest_tpg); |
1730 | ret = PYX_TRANSPORT_LU_COMM_FAILURE; | 1744 | cmd->scsi_sense_reason = |
1745 | TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; | ||
1746 | ret = -ENOMEM; | ||
1731 | goto out; | 1747 | goto out; |
1732 | } | 1748 | } |
1733 | INIT_LIST_HEAD(&tidh_new->dest_list); | 1749 | INIT_LIST_HEAD(&tidh_new->dest_list); |
@@ -1759,7 +1775,8 @@ static int core_scsi3_decode_spec_i_port( | |||
1759 | core_scsi3_nodeacl_undepend_item(dest_node_acl); | 1775 | core_scsi3_nodeacl_undepend_item(dest_node_acl); |
1760 | core_scsi3_tpg_undepend_item(dest_tpg); | 1776 | core_scsi3_tpg_undepend_item(dest_tpg); |
1761 | kfree(tidh_new); | 1777 | kfree(tidh_new); |
1762 | ret = PYX_TRANSPORT_INVALID_PARAMETER_LIST; | 1778 | cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; |
1779 | ret = -EINVAL; | ||
1763 | goto out; | 1780 | goto out; |
1764 | } | 1781 | } |
1765 | tidh_new->dest_pr_reg = dest_pr_reg; | 1782 | tidh_new->dest_pr_reg = dest_pr_reg; |
@@ -2098,7 +2115,8 @@ static int core_scsi3_emulate_pro_register( | |||
2098 | 2115 | ||
2099 | if (!se_sess || !se_lun) { | 2116 | if (!se_sess || !se_lun) { |
2100 | pr_err("SPC-3 PR: se_sess || struct se_lun is NULL!\n"); | 2117 | pr_err("SPC-3 PR: se_sess || struct se_lun is NULL!\n"); |
2101 | return PYX_TRANSPORT_LU_COMM_FAILURE; | 2118 | cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
2119 | return -EINVAL; | ||
2102 | } | 2120 | } |
2103 | se_tpg = se_sess->se_tpg; | 2121 | se_tpg = se_sess->se_tpg; |
2104 | se_deve = &se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; | 2122 | se_deve = &se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; |
@@ -2117,13 +2135,14 @@ static int core_scsi3_emulate_pro_register( | |||
2117 | if (res_key) { | 2135 | if (res_key) { |
2118 | pr_warn("SPC-3 PR: Reservation Key non-zero" | 2136 | pr_warn("SPC-3 PR: Reservation Key non-zero" |
2119 | " for SA REGISTER, returning CONFLICT\n"); | 2137 | " for SA REGISTER, returning CONFLICT\n"); |
2120 | return PYX_TRANSPORT_RESERVATION_CONFLICT; | 2138 | cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT; |
2139 | return -EINVAL; | ||
2121 | } | 2140 | } |
2122 | /* | 2141 | /* |
2123 | * Do nothing but return GOOD status. | 2142 | * Do nothing but return GOOD status. |
2124 | */ | 2143 | */ |
2125 | if (!sa_res_key) | 2144 | if (!sa_res_key) |
2126 | return PYX_TRANSPORT_SENT_TO_TRANSPORT; | 2145 | return 0; |
2127 | 2146 | ||
2128 | if (!spec_i_pt) { | 2147 | if (!spec_i_pt) { |
2129 | /* | 2148 | /* |
@@ -2138,7 +2157,8 @@ static int core_scsi3_emulate_pro_register( | |||
2138 | if (ret != 0) { | 2157 | if (ret != 0) { |
2139 | pr_err("Unable to allocate" | 2158 | pr_err("Unable to allocate" |
2140 | " struct t10_pr_registration\n"); | 2159 | " struct t10_pr_registration\n"); |
2141 | return PYX_TRANSPORT_INVALID_PARAMETER_LIST; | 2160 | cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; |
2161 | return -EINVAL; | ||
2142 | } | 2162 | } |
2143 | } else { | 2163 | } else { |
2144 | /* | 2164 | /* |
@@ -2197,14 +2217,16 @@ static int core_scsi3_emulate_pro_register( | |||
2197 | " 0x%016Lx\n", res_key, | 2217 | " 0x%016Lx\n", res_key, |
2198 | pr_reg->pr_res_key); | 2218 | pr_reg->pr_res_key); |
2199 | core_scsi3_put_pr_reg(pr_reg); | 2219 | core_scsi3_put_pr_reg(pr_reg); |
2200 | return PYX_TRANSPORT_RESERVATION_CONFLICT; | 2220 | cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT; |
2221 | return -EINVAL; | ||
2201 | } | 2222 | } |
2202 | } | 2223 | } |
2203 | if (spec_i_pt) { | 2224 | if (spec_i_pt) { |
2204 | pr_err("SPC-3 PR UNREGISTER: SPEC_I_PT" | 2225 | pr_err("SPC-3 PR UNREGISTER: SPEC_I_PT" |
2205 | " set while sa_res_key=0\n"); | 2226 | " set while sa_res_key=0\n"); |
2206 | core_scsi3_put_pr_reg(pr_reg); | 2227 | core_scsi3_put_pr_reg(pr_reg); |
2207 | return PYX_TRANSPORT_INVALID_PARAMETER_LIST; | 2228 | cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; |
2229 | return -EINVAL; | ||
2208 | } | 2230 | } |
2209 | /* | 2231 | /* |
2210 | * An existing ALL_TG_PT=1 registration being released | 2232 | * An existing ALL_TG_PT=1 registration being released |
@@ -2215,7 +2237,8 @@ static int core_scsi3_emulate_pro_register( | |||
2215 | " registration exists, but ALL_TG_PT=1 bit not" | 2237 | " registration exists, but ALL_TG_PT=1 bit not" |
2216 | " present in received PROUT\n"); | 2238 | " present in received PROUT\n"); |
2217 | core_scsi3_put_pr_reg(pr_reg); | 2239 | core_scsi3_put_pr_reg(pr_reg); |
2218 | return PYX_TRANSPORT_INVALID_CDB_FIELD; | 2240 | cmd->scsi_sense_reason = TCM_INVALID_CDB_FIELD; |
2241 | return -EINVAL; | ||
2219 | } | 2242 | } |
2220 | /* | 2243 | /* |
2221 | * Allocate APTPL metadata buffer used for UNREGISTER ops | 2244 | * Allocate APTPL metadata buffer used for UNREGISTER ops |
@@ -2227,7 +2250,9 @@ static int core_scsi3_emulate_pro_register( | |||
2227 | pr_err("Unable to allocate" | 2250 | pr_err("Unable to allocate" |
2228 | " pr_aptpl_buf\n"); | 2251 | " pr_aptpl_buf\n"); |
2229 | core_scsi3_put_pr_reg(pr_reg); | 2252 | core_scsi3_put_pr_reg(pr_reg); |
2230 | return PYX_TRANSPORT_LU_COMM_FAILURE; | 2253 | cmd->scsi_sense_reason = |
2254 | TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; | ||
2255 | return -EINVAL; | ||
2231 | } | 2256 | } |
2232 | } | 2257 | } |
2233 | /* | 2258 | /* |
@@ -2241,7 +2266,8 @@ static int core_scsi3_emulate_pro_register( | |||
2241 | if (pr_holder < 0) { | 2266 | if (pr_holder < 0) { |
2242 | kfree(pr_aptpl_buf); | 2267 | kfree(pr_aptpl_buf); |
2243 | core_scsi3_put_pr_reg(pr_reg); | 2268 | core_scsi3_put_pr_reg(pr_reg); |
2244 | return PYX_TRANSPORT_RESERVATION_CONFLICT; | 2269 | cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT; |
2270 | return -EINVAL; | ||
2245 | } | 2271 | } |
2246 | 2272 | ||
2247 | spin_lock(&pr_tmpl->registration_lock); | 2273 | spin_lock(&pr_tmpl->registration_lock); |
@@ -2405,7 +2431,8 @@ static int core_scsi3_pro_reserve( | |||
2405 | 2431 | ||
2406 | if (!se_sess || !se_lun) { | 2432 | if (!se_sess || !se_lun) { |
2407 | pr_err("SPC-3 PR: se_sess || struct se_lun is NULL!\n"); | 2433 | pr_err("SPC-3 PR: se_sess || struct se_lun is NULL!\n"); |
2408 | return PYX_TRANSPORT_LU_COMM_FAILURE; | 2434 | cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
2435 | return -EINVAL; | ||
2409 | } | 2436 | } |
2410 | se_tpg = se_sess->se_tpg; | 2437 | se_tpg = se_sess->se_tpg; |
2411 | se_deve = &se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; | 2438 | se_deve = &se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; |
@@ -2417,7 +2444,8 @@ static int core_scsi3_pro_reserve( | |||
2417 | if (!pr_reg) { | 2444 | if (!pr_reg) { |
2418 | pr_err("SPC-3 PR: Unable to locate" | 2445 | pr_err("SPC-3 PR: Unable to locate" |
2419 | " PR_REGISTERED *pr_reg for RESERVE\n"); | 2446 | " PR_REGISTERED *pr_reg for RESERVE\n"); |
2420 | return PYX_TRANSPORT_LU_COMM_FAILURE; | 2447 | cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
2448 | return -EINVAL; | ||
2421 | } | 2449 | } |
2422 | /* | 2450 | /* |
2423 | * From spc4r17 Section 5.7.9: Reserving: | 2451 | * From spc4r17 Section 5.7.9: Reserving: |
@@ -2433,7 +2461,8 @@ static int core_scsi3_pro_reserve( | |||
2433 | " does not match existing SA REGISTER res_key:" | 2461 | " does not match existing SA REGISTER res_key:" |
2434 | " 0x%016Lx\n", res_key, pr_reg->pr_res_key); | 2462 | " 0x%016Lx\n", res_key, pr_reg->pr_res_key); |
2435 | core_scsi3_put_pr_reg(pr_reg); | 2463 | core_scsi3_put_pr_reg(pr_reg); |
2436 | return PYX_TRANSPORT_RESERVATION_CONFLICT; | 2464 | cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT; |
2465 | return -EINVAL; | ||
2437 | } | 2466 | } |
2438 | /* | 2467 | /* |
2439 | * From spc4r17 Section 5.7.9: Reserving: | 2468 | * From spc4r17 Section 5.7.9: Reserving: |
@@ -2448,7 +2477,8 @@ static int core_scsi3_pro_reserve( | |||
2448 | if (scope != PR_SCOPE_LU_SCOPE) { | 2477 | if (scope != PR_SCOPE_LU_SCOPE) { |
2449 | pr_err("SPC-3 PR: Illegal SCOPE: 0x%02x\n", scope); | 2478 | pr_err("SPC-3 PR: Illegal SCOPE: 0x%02x\n", scope); |
2450 | core_scsi3_put_pr_reg(pr_reg); | 2479 | core_scsi3_put_pr_reg(pr_reg); |
2451 | return PYX_TRANSPORT_INVALID_PARAMETER_LIST; | 2480 | cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; |
2481 | return -EINVAL; | ||
2452 | } | 2482 | } |
2453 | /* | 2483 | /* |
2454 | * See if we have an existing PR reservation holder pointer at | 2484 | * See if we have an existing PR reservation holder pointer at |
@@ -2480,7 +2510,8 @@ static int core_scsi3_pro_reserve( | |||
2480 | 2510 | ||
2481 | spin_unlock(&dev->dev_reservation_lock); | 2511 | spin_unlock(&dev->dev_reservation_lock); |
2482 | core_scsi3_put_pr_reg(pr_reg); | 2512 | core_scsi3_put_pr_reg(pr_reg); |
2483 | return PYX_TRANSPORT_RESERVATION_CONFLICT; | 2513 | cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT; |
2514 | return -EINVAL; | ||
2484 | } | 2515 | } |
2485 | /* | 2516 | /* |
2486 | * From spc4r17 Section 5.7.9: Reserving: | 2517 | * From spc4r17 Section 5.7.9: Reserving: |
@@ -2503,7 +2534,8 @@ static int core_scsi3_pro_reserve( | |||
2503 | 2534 | ||
2504 | spin_unlock(&dev->dev_reservation_lock); | 2535 | spin_unlock(&dev->dev_reservation_lock); |
2505 | core_scsi3_put_pr_reg(pr_reg); | 2536 | core_scsi3_put_pr_reg(pr_reg); |
2506 | return PYX_TRANSPORT_RESERVATION_CONFLICT; | 2537 | cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT; |
2538 | return -EINVAL; | ||
2507 | } | 2539 | } |
2508 | /* | 2540 | /* |
2509 | * From spc4r17 Section 5.7.9: Reserving: | 2541 | * From spc4r17 Section 5.7.9: Reserving: |
@@ -2517,7 +2549,7 @@ static int core_scsi3_pro_reserve( | |||
2517 | */ | 2549 | */ |
2518 | spin_unlock(&dev->dev_reservation_lock); | 2550 | spin_unlock(&dev->dev_reservation_lock); |
2519 | core_scsi3_put_pr_reg(pr_reg); | 2551 | core_scsi3_put_pr_reg(pr_reg); |
2520 | return PYX_TRANSPORT_SENT_TO_TRANSPORT; | 2552 | return 0; |
2521 | } | 2553 | } |
2522 | /* | 2554 | /* |
2523 | * Otherwise, our *pr_reg becomes the PR reservation holder for said | 2555 | * Otherwise, our *pr_reg becomes the PR reservation holder for said |
@@ -2574,7 +2606,8 @@ static int core_scsi3_emulate_pro_reserve( | |||
2574 | default: | 2606 | default: |
2575 | pr_err("SPC-3 PR: Unknown Service Action RESERVE Type:" | 2607 | pr_err("SPC-3 PR: Unknown Service Action RESERVE Type:" |
2576 | " 0x%02x\n", type); | 2608 | " 0x%02x\n", type); |
2577 | return PYX_TRANSPORT_INVALID_CDB_FIELD; | 2609 | cmd->scsi_sense_reason = TCM_INVALID_CDB_FIELD; |
2610 | return -EINVAL; | ||
2578 | } | 2611 | } |
2579 | 2612 | ||
2580 | return ret; | 2613 | return ret; |
@@ -2630,7 +2663,8 @@ static int core_scsi3_emulate_pro_release( | |||
2630 | 2663 | ||
2631 | if (!se_sess || !se_lun) { | 2664 | if (!se_sess || !se_lun) { |
2632 | pr_err("SPC-3 PR: se_sess || struct se_lun is NULL!\n"); | 2665 | pr_err("SPC-3 PR: se_sess || struct se_lun is NULL!\n"); |
2633 | return PYX_TRANSPORT_LU_COMM_FAILURE; | 2666 | cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
2667 | return -EINVAL; | ||
2634 | } | 2668 | } |
2635 | /* | 2669 | /* |
2636 | * Locate the existing *pr_reg via struct se_node_acl pointers | 2670 | * Locate the existing *pr_reg via struct se_node_acl pointers |
@@ -2639,7 +2673,8 @@ static int core_scsi3_emulate_pro_release( | |||
2639 | if (!pr_reg) { | 2673 | if (!pr_reg) { |
2640 | pr_err("SPC-3 PR: Unable to locate" | 2674 | pr_err("SPC-3 PR: Unable to locate" |
2641 | " PR_REGISTERED *pr_reg for RELEASE\n"); | 2675 | " PR_REGISTERED *pr_reg for RELEASE\n"); |
2642 | return PYX_TRANSPORT_LU_COMM_FAILURE; | 2676 | cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
2677 | return -EINVAL; | ||
2643 | } | 2678 | } |
2644 | /* | 2679 | /* |
2645 | * From spc4r17 Section 5.7.11.2 Releasing: | 2680 | * From spc4r17 Section 5.7.11.2 Releasing: |
@@ -2661,7 +2696,7 @@ static int core_scsi3_emulate_pro_release( | |||
2661 | */ | 2696 | */ |
2662 | spin_unlock(&dev->dev_reservation_lock); | 2697 | spin_unlock(&dev->dev_reservation_lock); |
2663 | core_scsi3_put_pr_reg(pr_reg); | 2698 | core_scsi3_put_pr_reg(pr_reg); |
2664 | return PYX_TRANSPORT_SENT_TO_TRANSPORT; | 2699 | return 0; |
2665 | } | 2700 | } |
2666 | if ((pr_res_holder->pr_res_type == PR_TYPE_WRITE_EXCLUSIVE_ALLREG) || | 2701 | if ((pr_res_holder->pr_res_type == PR_TYPE_WRITE_EXCLUSIVE_ALLREG) || |
2667 | (pr_res_holder->pr_res_type == PR_TYPE_EXCLUSIVE_ACCESS_ALLREG)) | 2702 | (pr_res_holder->pr_res_type == PR_TYPE_EXCLUSIVE_ACCESS_ALLREG)) |
@@ -2675,7 +2710,7 @@ static int core_scsi3_emulate_pro_release( | |||
2675 | */ | 2710 | */ |
2676 | spin_unlock(&dev->dev_reservation_lock); | 2711 | spin_unlock(&dev->dev_reservation_lock); |
2677 | core_scsi3_put_pr_reg(pr_reg); | 2712 | core_scsi3_put_pr_reg(pr_reg); |
2678 | return PYX_TRANSPORT_SENT_TO_TRANSPORT; | 2713 | return 0; |
2679 | } | 2714 | } |
2680 | /* | 2715 | /* |
2681 | * From spc4r17 Section 5.7.11.2 Releasing: | 2716 | * From spc4r17 Section 5.7.11.2 Releasing: |
@@ -2697,7 +2732,8 @@ static int core_scsi3_emulate_pro_release( | |||
2697 | " 0x%016Lx\n", res_key, pr_reg->pr_res_key); | 2732 | " 0x%016Lx\n", res_key, pr_reg->pr_res_key); |
2698 | spin_unlock(&dev->dev_reservation_lock); | 2733 | spin_unlock(&dev->dev_reservation_lock); |
2699 | core_scsi3_put_pr_reg(pr_reg); | 2734 | core_scsi3_put_pr_reg(pr_reg); |
2700 | return PYX_TRANSPORT_RESERVATION_CONFLICT; | 2735 | cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT; |
2736 | return -EINVAL; | ||
2701 | } | 2737 | } |
2702 | /* | 2738 | /* |
2703 | * From spc4r17 Section 5.7.11.2 Releasing and above: | 2739 | * From spc4r17 Section 5.7.11.2 Releasing and above: |
@@ -2719,7 +2755,8 @@ static int core_scsi3_emulate_pro_release( | |||
2719 | 2755 | ||
2720 | spin_unlock(&dev->dev_reservation_lock); | 2756 | spin_unlock(&dev->dev_reservation_lock); |
2721 | core_scsi3_put_pr_reg(pr_reg); | 2757 | core_scsi3_put_pr_reg(pr_reg); |
2722 | return PYX_TRANSPORT_RESERVATION_CONFLICT; | 2758 | cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT; |
2759 | return -EINVAL; | ||
2723 | } | 2760 | } |
2724 | /* | 2761 | /* |
2725 | * In response to a persistent reservation release request from the | 2762 | * In response to a persistent reservation release request from the |
@@ -2802,7 +2839,8 @@ static int core_scsi3_emulate_pro_clear( | |||
2802 | if (!pr_reg_n) { | 2839 | if (!pr_reg_n) { |
2803 | pr_err("SPC-3 PR: Unable to locate" | 2840 | pr_err("SPC-3 PR: Unable to locate" |
2804 | " PR_REGISTERED *pr_reg for CLEAR\n"); | 2841 | " PR_REGISTERED *pr_reg for CLEAR\n"); |
2805 | return PYX_TRANSPORT_LU_COMM_FAILURE; | 2842 | cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
2843 | return -EINVAL; | ||
2806 | } | 2844 | } |
2807 | /* | 2845 | /* |
2808 | * From spc4r17 section 5.7.11.6, Clearing: | 2846 | * From spc4r17 section 5.7.11.6, Clearing: |
@@ -2821,7 +2859,8 @@ static int core_scsi3_emulate_pro_clear( | |||
2821 | " existing SA REGISTER res_key:" | 2859 | " existing SA REGISTER res_key:" |
2822 | " 0x%016Lx\n", res_key, pr_reg_n->pr_res_key); | 2860 | " 0x%016Lx\n", res_key, pr_reg_n->pr_res_key); |
2823 | core_scsi3_put_pr_reg(pr_reg_n); | 2861 | core_scsi3_put_pr_reg(pr_reg_n); |
2824 | return PYX_TRANSPORT_RESERVATION_CONFLICT; | 2862 | cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT; |
2863 | return -EINVAL; | ||
2825 | } | 2864 | } |
2826 | /* | 2865 | /* |
2827 | * a) Release the persistent reservation, if any; | 2866 | * a) Release the persistent reservation, if any; |
@@ -2979,8 +3018,10 @@ static int core_scsi3_pro_preempt( | |||
2979 | int all_reg = 0, calling_it_nexus = 0, released_regs = 0; | 3018 | int all_reg = 0, calling_it_nexus = 0, released_regs = 0; |
2980 | int prh_type = 0, prh_scope = 0, ret; | 3019 | int prh_type = 0, prh_scope = 0, ret; |
2981 | 3020 | ||
2982 | if (!se_sess) | 3021 | if (!se_sess) { |
2983 | return PYX_TRANSPORT_LU_COMM_FAILURE; | 3022 | cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
3023 | return -EINVAL; | ||
3024 | } | ||
2984 | 3025 | ||
2985 | se_deve = &se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; | 3026 | se_deve = &se_sess->se_node_acl->device_list[cmd->orig_fe_lun]; |
2986 | pr_reg_n = core_scsi3_locate_pr_reg(cmd->se_dev, se_sess->se_node_acl, | 3027 | pr_reg_n = core_scsi3_locate_pr_reg(cmd->se_dev, se_sess->se_node_acl, |
@@ -2989,16 +3030,19 @@ static int core_scsi3_pro_preempt( | |||
2989 | pr_err("SPC-3 PR: Unable to locate" | 3030 | pr_err("SPC-3 PR: Unable to locate" |
2990 | " PR_REGISTERED *pr_reg for PREEMPT%s\n", | 3031 | " PR_REGISTERED *pr_reg for PREEMPT%s\n", |
2991 | (abort) ? "_AND_ABORT" : ""); | 3032 | (abort) ? "_AND_ABORT" : ""); |
2992 | return PYX_TRANSPORT_RESERVATION_CONFLICT; | 3033 | cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT; |
3034 | return -EINVAL; | ||
2993 | } | 3035 | } |
2994 | if (pr_reg_n->pr_res_key != res_key) { | 3036 | if (pr_reg_n->pr_res_key != res_key) { |
2995 | core_scsi3_put_pr_reg(pr_reg_n); | 3037 | core_scsi3_put_pr_reg(pr_reg_n); |
2996 | return PYX_TRANSPORT_RESERVATION_CONFLICT; | 3038 | cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT; |
3039 | return -EINVAL; | ||
2997 | } | 3040 | } |
2998 | if (scope != PR_SCOPE_LU_SCOPE) { | 3041 | if (scope != PR_SCOPE_LU_SCOPE) { |
2999 | pr_err("SPC-3 PR: Illegal SCOPE: 0x%02x\n", scope); | 3042 | pr_err("SPC-3 PR: Illegal SCOPE: 0x%02x\n", scope); |
3000 | core_scsi3_put_pr_reg(pr_reg_n); | 3043 | core_scsi3_put_pr_reg(pr_reg_n); |
3001 | return PYX_TRANSPORT_INVALID_PARAMETER_LIST; | 3044 | cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; |
3045 | return -EINVAL; | ||
3002 | } | 3046 | } |
3003 | INIT_LIST_HEAD(&preempt_and_abort_list); | 3047 | INIT_LIST_HEAD(&preempt_and_abort_list); |
3004 | 3048 | ||
@@ -3012,7 +3056,8 @@ static int core_scsi3_pro_preempt( | |||
3012 | if (!all_reg && !sa_res_key) { | 3056 | if (!all_reg && !sa_res_key) { |
3013 | spin_unlock(&dev->dev_reservation_lock); | 3057 | spin_unlock(&dev->dev_reservation_lock); |
3014 | core_scsi3_put_pr_reg(pr_reg_n); | 3058 | core_scsi3_put_pr_reg(pr_reg_n); |
3015 | return PYX_TRANSPORT_INVALID_PARAMETER_LIST; | 3059 | cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; |
3060 | return -EINVAL; | ||
3016 | } | 3061 | } |
3017 | /* | 3062 | /* |
3018 | * From spc4r17, section 5.7.11.4.4 Removing Registrations: | 3063 | * From spc4r17, section 5.7.11.4.4 Removing Registrations: |
@@ -3106,7 +3151,8 @@ static int core_scsi3_pro_preempt( | |||
3106 | if (!released_regs) { | 3151 | if (!released_regs) { |
3107 | spin_unlock(&dev->dev_reservation_lock); | 3152 | spin_unlock(&dev->dev_reservation_lock); |
3108 | core_scsi3_put_pr_reg(pr_reg_n); | 3153 | core_scsi3_put_pr_reg(pr_reg_n); |
3109 | return PYX_TRANSPORT_RESERVATION_CONFLICT; | 3154 | cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT; |
3155 | return -EINVAL; | ||
3110 | } | 3156 | } |
3111 | /* | 3157 | /* |
3112 | * For an existing all registrants type reservation | 3158 | * For an existing all registrants type reservation |
@@ -3297,7 +3343,8 @@ static int core_scsi3_emulate_pro_preempt( | |||
3297 | default: | 3343 | default: |
3298 | pr_err("SPC-3 PR: Unknown Service Action PREEMPT%s" | 3344 | pr_err("SPC-3 PR: Unknown Service Action PREEMPT%s" |
3299 | " Type: 0x%02x\n", (abort) ? "_AND_ABORT" : "", type); | 3345 | " Type: 0x%02x\n", (abort) ? "_AND_ABORT" : "", type); |
3300 | return PYX_TRANSPORT_INVALID_CDB_FIELD; | 3346 | cmd->scsi_sense_reason = TCM_INVALID_CDB_FIELD; |
3347 | return -EINVAL; | ||
3301 | } | 3348 | } |
3302 | 3349 | ||
3303 | return ret; | 3350 | return ret; |
@@ -3331,7 +3378,8 @@ static int core_scsi3_emulate_pro_register_and_move( | |||
3331 | 3378 | ||
3332 | if (!se_sess || !se_lun) { | 3379 | if (!se_sess || !se_lun) { |
3333 | pr_err("SPC-3 PR: se_sess || struct se_lun is NULL!\n"); | 3380 | pr_err("SPC-3 PR: se_sess || struct se_lun is NULL!\n"); |
3334 | return PYX_TRANSPORT_LU_COMM_FAILURE; | 3381 | cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
3382 | return -EINVAL; | ||
3335 | } | 3383 | } |
3336 | memset(dest_iport, 0, 64); | 3384 | memset(dest_iport, 0, 64); |
3337 | memset(i_buf, 0, PR_REG_ISID_ID_LEN); | 3385 | memset(i_buf, 0, PR_REG_ISID_ID_LEN); |
@@ -3349,7 +3397,8 @@ static int core_scsi3_emulate_pro_register_and_move( | |||
3349 | if (!pr_reg) { | 3397 | if (!pr_reg) { |
3350 | pr_err("SPC-3 PR: Unable to locate PR_REGISTERED" | 3398 | pr_err("SPC-3 PR: Unable to locate PR_REGISTERED" |
3351 | " *pr_reg for REGISTER_AND_MOVE\n"); | 3399 | " *pr_reg for REGISTER_AND_MOVE\n"); |
3352 | return PYX_TRANSPORT_LU_COMM_FAILURE; | 3400 | cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
3401 | return -EINVAL; | ||
3353 | } | 3402 | } |
3354 | /* | 3403 | /* |
3355 | * The provided reservation key much match the existing reservation key | 3404 | * The provided reservation key much match the existing reservation key |
@@ -3360,7 +3409,8 @@ static int core_scsi3_emulate_pro_register_and_move( | |||
3360 | " res_key: 0x%016Lx does not match existing SA REGISTER" | 3409 | " res_key: 0x%016Lx does not match existing SA REGISTER" |
3361 | " res_key: 0x%016Lx\n", res_key, pr_reg->pr_res_key); | 3410 | " res_key: 0x%016Lx\n", res_key, pr_reg->pr_res_key); |
3362 | core_scsi3_put_pr_reg(pr_reg); | 3411 | core_scsi3_put_pr_reg(pr_reg); |
3363 | return PYX_TRANSPORT_RESERVATION_CONFLICT; | 3412 | cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT; |
3413 | return -EINVAL; | ||
3364 | } | 3414 | } |
3365 | /* | 3415 | /* |
3366 | * The service active reservation key needs to be non zero | 3416 | * The service active reservation key needs to be non zero |
@@ -3369,7 +3419,8 @@ static int core_scsi3_emulate_pro_register_and_move( | |||
3369 | pr_warn("SPC-3 PR REGISTER_AND_MOVE: Received zero" | 3419 | pr_warn("SPC-3 PR REGISTER_AND_MOVE: Received zero" |
3370 | " sa_res_key\n"); | 3420 | " sa_res_key\n"); |
3371 | core_scsi3_put_pr_reg(pr_reg); | 3421 | core_scsi3_put_pr_reg(pr_reg); |
3372 | return PYX_TRANSPORT_INVALID_PARAMETER_LIST; | 3422 | cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; |
3423 | return -EINVAL; | ||
3373 | } | 3424 | } |
3374 | 3425 | ||
3375 | /* | 3426 | /* |
@@ -3392,7 +3443,8 @@ static int core_scsi3_emulate_pro_register_and_move( | |||
3392 | " does not equal CDB data_length: %u\n", tid_len, | 3443 | " does not equal CDB data_length: %u\n", tid_len, |
3393 | cmd->data_length); | 3444 | cmd->data_length); |
3394 | core_scsi3_put_pr_reg(pr_reg); | 3445 | core_scsi3_put_pr_reg(pr_reg); |
3395 | return PYX_TRANSPORT_INVALID_PARAMETER_LIST; | 3446 | cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; |
3447 | return -EINVAL; | ||
3396 | } | 3448 | } |
3397 | 3449 | ||
3398 | spin_lock(&dev->se_port_lock); | 3450 | spin_lock(&dev->se_port_lock); |
@@ -3417,7 +3469,8 @@ static int core_scsi3_emulate_pro_register_and_move( | |||
3417 | atomic_dec(&dest_se_tpg->tpg_pr_ref_count); | 3469 | atomic_dec(&dest_se_tpg->tpg_pr_ref_count); |
3418 | smp_mb__after_atomic_dec(); | 3470 | smp_mb__after_atomic_dec(); |
3419 | core_scsi3_put_pr_reg(pr_reg); | 3471 | core_scsi3_put_pr_reg(pr_reg); |
3420 | return PYX_TRANSPORT_LU_COMM_FAILURE; | 3472 | cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
3473 | return -EINVAL; | ||
3421 | } | 3474 | } |
3422 | 3475 | ||
3423 | spin_lock(&dev->se_port_lock); | 3476 | spin_lock(&dev->se_port_lock); |
@@ -3430,7 +3483,8 @@ static int core_scsi3_emulate_pro_register_and_move( | |||
3430 | " fabric ops from Relative Target Port Identifier:" | 3483 | " fabric ops from Relative Target Port Identifier:" |
3431 | " %hu\n", rtpi); | 3484 | " %hu\n", rtpi); |
3432 | core_scsi3_put_pr_reg(pr_reg); | 3485 | core_scsi3_put_pr_reg(pr_reg); |
3433 | return PYX_TRANSPORT_INVALID_PARAMETER_LIST; | 3486 | cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; |
3487 | return -EINVAL; | ||
3434 | } | 3488 | } |
3435 | 3489 | ||
3436 | buf = transport_kmap_first_data_page(cmd); | 3490 | buf = transport_kmap_first_data_page(cmd); |
@@ -3445,14 +3499,16 @@ static int core_scsi3_emulate_pro_register_and_move( | |||
3445 | " from fabric: %s\n", proto_ident, | 3499 | " from fabric: %s\n", proto_ident, |
3446 | dest_tf_ops->get_fabric_proto_ident(dest_se_tpg), | 3500 | dest_tf_ops->get_fabric_proto_ident(dest_se_tpg), |
3447 | dest_tf_ops->get_fabric_name()); | 3501 | dest_tf_ops->get_fabric_name()); |
3448 | ret = PYX_TRANSPORT_INVALID_PARAMETER_LIST; | 3502 | cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; |
3503 | ret = -EINVAL; | ||
3449 | goto out; | 3504 | goto out; |
3450 | } | 3505 | } |
3451 | if (dest_tf_ops->tpg_parse_pr_out_transport_id == NULL) { | 3506 | if (dest_tf_ops->tpg_parse_pr_out_transport_id == NULL) { |
3452 | pr_err("SPC-3 PR REGISTER_AND_MOVE: Fabric does not" | 3507 | pr_err("SPC-3 PR REGISTER_AND_MOVE: Fabric does not" |
3453 | " containg a valid tpg_parse_pr_out_transport_id" | 3508 | " containg a valid tpg_parse_pr_out_transport_id" |
3454 | " function pointer\n"); | 3509 | " function pointer\n"); |
3455 | ret = PYX_TRANSPORT_LU_COMM_FAILURE; | 3510 | cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
3511 | ret = -EINVAL; | ||
3456 | goto out; | 3512 | goto out; |
3457 | } | 3513 | } |
3458 | initiator_str = dest_tf_ops->tpg_parse_pr_out_transport_id(dest_se_tpg, | 3514 | initiator_str = dest_tf_ops->tpg_parse_pr_out_transport_id(dest_se_tpg, |
@@ -3460,7 +3516,8 @@ static int core_scsi3_emulate_pro_register_and_move( | |||
3460 | if (!initiator_str) { | 3516 | if (!initiator_str) { |
3461 | pr_err("SPC-3 PR REGISTER_AND_MOVE: Unable to locate" | 3517 | pr_err("SPC-3 PR REGISTER_AND_MOVE: Unable to locate" |
3462 | " initiator_str from Transport ID\n"); | 3518 | " initiator_str from Transport ID\n"); |
3463 | ret = PYX_TRANSPORT_INVALID_PARAMETER_LIST; | 3519 | cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; |
3520 | ret = -EINVAL; | ||
3464 | goto out; | 3521 | goto out; |
3465 | } | 3522 | } |
3466 | 3523 | ||
@@ -3489,7 +3546,8 @@ static int core_scsi3_emulate_pro_register_and_move( | |||
3489 | pr_err("SPC-3 PR REGISTER_AND_MOVE: TransportID: %s" | 3546 | pr_err("SPC-3 PR REGISTER_AND_MOVE: TransportID: %s" |
3490 | " matches: %s on received I_T Nexus\n", initiator_str, | 3547 | " matches: %s on received I_T Nexus\n", initiator_str, |
3491 | pr_reg_nacl->initiatorname); | 3548 | pr_reg_nacl->initiatorname); |
3492 | ret = PYX_TRANSPORT_INVALID_PARAMETER_LIST; | 3549 | cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; |
3550 | ret = -EINVAL; | ||
3493 | goto out; | 3551 | goto out; |
3494 | } | 3552 | } |
3495 | if (!strcmp(iport_ptr, pr_reg->pr_reg_isid)) { | 3553 | if (!strcmp(iport_ptr, pr_reg->pr_reg_isid)) { |
@@ -3497,7 +3555,8 @@ static int core_scsi3_emulate_pro_register_and_move( | |||
3497 | " matches: %s %s on received I_T Nexus\n", | 3555 | " matches: %s %s on received I_T Nexus\n", |
3498 | initiator_str, iport_ptr, pr_reg_nacl->initiatorname, | 3556 | initiator_str, iport_ptr, pr_reg_nacl->initiatorname, |
3499 | pr_reg->pr_reg_isid); | 3557 | pr_reg->pr_reg_isid); |
3500 | ret = PYX_TRANSPORT_INVALID_PARAMETER_LIST; | 3558 | cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; |
3559 | ret = -EINVAL; | ||
3501 | goto out; | 3560 | goto out; |
3502 | } | 3561 | } |
3503 | after_iport_check: | 3562 | after_iport_check: |
@@ -3517,7 +3576,8 @@ after_iport_check: | |||
3517 | pr_err("Unable to locate %s dest_node_acl for" | 3576 | pr_err("Unable to locate %s dest_node_acl for" |
3518 | " TransportID%s\n", dest_tf_ops->get_fabric_name(), | 3577 | " TransportID%s\n", dest_tf_ops->get_fabric_name(), |
3519 | initiator_str); | 3578 | initiator_str); |
3520 | ret = PYX_TRANSPORT_INVALID_PARAMETER_LIST; | 3579 | cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; |
3580 | ret = -EINVAL; | ||
3521 | goto out; | 3581 | goto out; |
3522 | } | 3582 | } |
3523 | ret = core_scsi3_nodeacl_depend_item(dest_node_acl); | 3583 | ret = core_scsi3_nodeacl_depend_item(dest_node_acl); |
@@ -3527,7 +3587,8 @@ after_iport_check: | |||
3527 | atomic_dec(&dest_node_acl->acl_pr_ref_count); | 3587 | atomic_dec(&dest_node_acl->acl_pr_ref_count); |
3528 | smp_mb__after_atomic_dec(); | 3588 | smp_mb__after_atomic_dec(); |
3529 | dest_node_acl = NULL; | 3589 | dest_node_acl = NULL; |
3530 | ret = PYX_TRANSPORT_LU_COMM_FAILURE; | 3590 | cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; |
3591 | ret = -EINVAL; | ||
3531 | goto out; | 3592 | goto out; |
3532 | } | 3593 | } |
3533 | #if 0 | 3594 | #if 0 |
@@ -3543,7 +3604,8 @@ after_iport_check: | |||
3543 | if (!dest_se_deve) { | 3604 | if (!dest_se_deve) { |
3544 | pr_err("Unable to locate %s dest_se_deve from RTPI:" | 3605 | pr_err("Unable to locate %s dest_se_deve from RTPI:" |
3545 | " %hu\n", dest_tf_ops->get_fabric_name(), rtpi); | 3606 | " %hu\n", dest_tf_ops->get_fabric_name(), rtpi); |
3546 | ret = PYX_TRANSPORT_INVALID_PARAMETER_LIST; | 3607 | cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; |
3608 | ret = -EINVAL; | ||
3547 | goto out; | 3609 | goto out; |
3548 | } | 3610 | } |
3549 | 3611 | ||
@@ -3553,7 +3615,8 @@ after_iport_check: | |||
3553 | atomic_dec(&dest_se_deve->pr_ref_count); | 3615 | atomic_dec(&dest_se_deve->pr_ref_count); |
3554 | smp_mb__after_atomic_dec(); | 3616 | smp_mb__after_atomic_dec(); |
3555 | dest_se_deve = NULL; | 3617 | dest_se_deve = NULL; |
3556 | ret = PYX_TRANSPORT_LU_COMM_FAILURE; | 3618 | cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
3619 | ret = -EINVAL; | ||
3557 | goto out; | 3620 | goto out; |
3558 | } | 3621 | } |
3559 | #if 0 | 3622 | #if 0 |
@@ -3572,7 +3635,8 @@ after_iport_check: | |||
3572 | pr_warn("SPC-3 PR REGISTER_AND_MOVE: No reservation" | 3635 | pr_warn("SPC-3 PR REGISTER_AND_MOVE: No reservation" |
3573 | " currently held\n"); | 3636 | " currently held\n"); |
3574 | spin_unlock(&dev->dev_reservation_lock); | 3637 | spin_unlock(&dev->dev_reservation_lock); |
3575 | ret = PYX_TRANSPORT_INVALID_CDB_FIELD; | 3638 | cmd->scsi_sense_reason = TCM_INVALID_CDB_FIELD; |
3639 | ret = -EINVAL; | ||
3576 | goto out; | 3640 | goto out; |
3577 | } | 3641 | } |
3578 | /* | 3642 | /* |
@@ -3585,7 +3649,8 @@ after_iport_check: | |||
3585 | pr_warn("SPC-3 PR REGISTER_AND_MOVE: Calling I_T" | 3649 | pr_warn("SPC-3 PR REGISTER_AND_MOVE: Calling I_T" |
3586 | " Nexus is not reservation holder\n"); | 3650 | " Nexus is not reservation holder\n"); |
3587 | spin_unlock(&dev->dev_reservation_lock); | 3651 | spin_unlock(&dev->dev_reservation_lock); |
3588 | ret = PYX_TRANSPORT_RESERVATION_CONFLICT; | 3652 | cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT; |
3653 | ret = -EINVAL; | ||
3589 | goto out; | 3654 | goto out; |
3590 | } | 3655 | } |
3591 | /* | 3656 | /* |
@@ -3603,7 +3668,8 @@ after_iport_check: | |||
3603 | " reservation for type: %s\n", | 3668 | " reservation for type: %s\n", |
3604 | core_scsi3_pr_dump_type(pr_res_holder->pr_res_type)); | 3669 | core_scsi3_pr_dump_type(pr_res_holder->pr_res_type)); |
3605 | spin_unlock(&dev->dev_reservation_lock); | 3670 | spin_unlock(&dev->dev_reservation_lock); |
3606 | ret = PYX_TRANSPORT_RESERVATION_CONFLICT; | 3671 | cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT; |
3672 | ret = -EINVAL; | ||
3607 | goto out; | 3673 | goto out; |
3608 | } | 3674 | } |
3609 | pr_res_nacl = pr_res_holder->pr_reg_nacl; | 3675 | pr_res_nacl = pr_res_holder->pr_reg_nacl; |
@@ -3640,7 +3706,8 @@ after_iport_check: | |||
3640 | sa_res_key, 0, aptpl, 2, 1); | 3706 | sa_res_key, 0, aptpl, 2, 1); |
3641 | if (ret != 0) { | 3707 | if (ret != 0) { |
3642 | spin_unlock(&dev->dev_reservation_lock); | 3708 | spin_unlock(&dev->dev_reservation_lock); |
3643 | ret = PYX_TRANSPORT_INVALID_PARAMETER_LIST; | 3709 | cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; |
3710 | ret = -EINVAL; | ||
3644 | goto out; | 3711 | goto out; |
3645 | } | 3712 | } |
3646 | dest_pr_reg = __core_scsi3_locate_pr_reg(dev, dest_node_acl, | 3713 | dest_pr_reg = __core_scsi3_locate_pr_reg(dev, dest_node_acl, |
@@ -3771,7 +3838,8 @@ int target_scsi3_emulate_pr_out(struct se_task *task) | |||
3771 | pr_err("Received PERSISTENT_RESERVE CDB while legacy" | 3838 | pr_err("Received PERSISTENT_RESERVE CDB while legacy" |
3772 | " SPC-2 reservation is held, returning" | 3839 | " SPC-2 reservation is held, returning" |
3773 | " RESERVATION_CONFLICT\n"); | 3840 | " RESERVATION_CONFLICT\n"); |
3774 | ret = PYX_TRANSPORT_RESERVATION_CONFLICT; | 3841 | cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT; |
3842 | ret = EINVAL; | ||
3775 | goto out; | 3843 | goto out; |
3776 | } | 3844 | } |
3777 | 3845 | ||
@@ -3779,13 +3847,16 @@ int target_scsi3_emulate_pr_out(struct se_task *task) | |||
3779 | * FIXME: A NULL struct se_session pointer means an this is not coming from | 3847 | * FIXME: A NULL struct se_session pointer means an this is not coming from |
3780 | * a $FABRIC_MOD's nexus, but from internal passthrough ops. | 3848 | * a $FABRIC_MOD's nexus, but from internal passthrough ops. |
3781 | */ | 3849 | */ |
3782 | if (!cmd->se_sess) | 3850 | if (!cmd->se_sess) { |
3783 | return PYX_TRANSPORT_LU_COMM_FAILURE; | 3851 | cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
3852 | return -EINVAL; | ||
3853 | } | ||
3784 | 3854 | ||
3785 | if (cmd->data_length < 24) { | 3855 | if (cmd->data_length < 24) { |
3786 | pr_warn("SPC-PR: Received PR OUT parameter list" | 3856 | pr_warn("SPC-PR: Received PR OUT parameter list" |
3787 | " length too small: %u\n", cmd->data_length); | 3857 | " length too small: %u\n", cmd->data_length); |
3788 | ret = PYX_TRANSPORT_INVALID_PARAMETER_LIST; | 3858 | cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; |
3859 | ret = -EINVAL; | ||
3789 | goto out; | 3860 | goto out; |
3790 | } | 3861 | } |
3791 | /* | 3862 | /* |
@@ -3820,7 +3891,8 @@ int target_scsi3_emulate_pr_out(struct se_task *task) | |||
3820 | * SPEC_I_PT=1 is only valid for Service action: REGISTER | 3891 | * SPEC_I_PT=1 is only valid for Service action: REGISTER |
3821 | */ | 3892 | */ |
3822 | if (spec_i_pt && ((cdb[1] & 0x1f) != PRO_REGISTER)) { | 3893 | if (spec_i_pt && ((cdb[1] & 0x1f) != PRO_REGISTER)) { |
3823 | ret = PYX_TRANSPORT_INVALID_PARAMETER_LIST; | 3894 | cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; |
3895 | ret = -EINVAL; | ||
3824 | goto out; | 3896 | goto out; |
3825 | } | 3897 | } |
3826 | 3898 | ||
@@ -3837,7 +3909,8 @@ int target_scsi3_emulate_pr_out(struct se_task *task) | |||
3837 | (cmd->data_length != 24)) { | 3909 | (cmd->data_length != 24)) { |
3838 | pr_warn("SPC-PR: Received PR OUT illegal parameter" | 3910 | pr_warn("SPC-PR: Received PR OUT illegal parameter" |
3839 | " list length: %u\n", cmd->data_length); | 3911 | " list length: %u\n", cmd->data_length); |
3840 | ret = PYX_TRANSPORT_INVALID_PARAMETER_LIST; | 3912 | cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; |
3913 | ret = -EINVAL; | ||
3841 | goto out; | 3914 | goto out; |
3842 | } | 3915 | } |
3843 | /* | 3916 | /* |
@@ -3878,7 +3951,8 @@ int target_scsi3_emulate_pr_out(struct se_task *task) | |||
3878 | default: | 3951 | default: |
3879 | pr_err("Unknown PERSISTENT_RESERVE_OUT service" | 3952 | pr_err("Unknown PERSISTENT_RESERVE_OUT service" |
3880 | " action: 0x%02x\n", cdb[1] & 0x1f); | 3953 | " action: 0x%02x\n", cdb[1] & 0x1f); |
3881 | ret = PYX_TRANSPORT_INVALID_CDB_FIELD; | 3954 | cmd->scsi_sense_reason = TCM_INVALID_CDB_FIELD; |
3955 | ret = -EINVAL; | ||
3882 | break; | 3956 | break; |
3883 | } | 3957 | } |
3884 | 3958 | ||
@@ -3906,7 +3980,8 @@ static int core_scsi3_pri_read_keys(struct se_cmd *cmd) | |||
3906 | if (cmd->data_length < 8) { | 3980 | if (cmd->data_length < 8) { |
3907 | pr_err("PRIN SA READ_KEYS SCSI Data Length: %u" | 3981 | pr_err("PRIN SA READ_KEYS SCSI Data Length: %u" |
3908 | " too small\n", cmd->data_length); | 3982 | " too small\n", cmd->data_length); |
3909 | return PYX_TRANSPORT_INVALID_CDB_FIELD; | 3983 | cmd->scsi_sense_reason = TCM_INVALID_CDB_FIELD; |
3984 | return -EINVAL; | ||
3910 | } | 3985 | } |
3911 | 3986 | ||
3912 | buf = transport_kmap_first_data_page(cmd); | 3987 | buf = transport_kmap_first_data_page(cmd); |
@@ -3965,7 +4040,8 @@ static int core_scsi3_pri_read_reservation(struct se_cmd *cmd) | |||
3965 | if (cmd->data_length < 8) { | 4040 | if (cmd->data_length < 8) { |
3966 | pr_err("PRIN SA READ_RESERVATIONS SCSI Data Length: %u" | 4041 | pr_err("PRIN SA READ_RESERVATIONS SCSI Data Length: %u" |
3967 | " too small\n", cmd->data_length); | 4042 | " too small\n", cmd->data_length); |
3968 | return PYX_TRANSPORT_INVALID_CDB_FIELD; | 4043 | cmd->scsi_sense_reason = TCM_INVALID_CDB_FIELD; |
4044 | return -EINVAL; | ||
3969 | } | 4045 | } |
3970 | 4046 | ||
3971 | buf = transport_kmap_first_data_page(cmd); | 4047 | buf = transport_kmap_first_data_page(cmd); |
@@ -4047,7 +4123,8 @@ static int core_scsi3_pri_report_capabilities(struct se_cmd *cmd) | |||
4047 | if (cmd->data_length < 6) { | 4123 | if (cmd->data_length < 6) { |
4048 | pr_err("PRIN SA REPORT_CAPABILITIES SCSI Data Length:" | 4124 | pr_err("PRIN SA REPORT_CAPABILITIES SCSI Data Length:" |
4049 | " %u too small\n", cmd->data_length); | 4125 | " %u too small\n", cmd->data_length); |
4050 | return PYX_TRANSPORT_INVALID_CDB_FIELD; | 4126 | cmd->scsi_sense_reason = TCM_INVALID_CDB_FIELD; |
4127 | return -EINVAL; | ||
4051 | } | 4128 | } |
4052 | 4129 | ||
4053 | buf = transport_kmap_first_data_page(cmd); | 4130 | buf = transport_kmap_first_data_page(cmd); |
@@ -4108,7 +4185,8 @@ static int core_scsi3_pri_read_full_status(struct se_cmd *cmd) | |||
4108 | if (cmd->data_length < 8) { | 4185 | if (cmd->data_length < 8) { |
4109 | pr_err("PRIN SA READ_FULL_STATUS SCSI Data Length: %u" | 4186 | pr_err("PRIN SA READ_FULL_STATUS SCSI Data Length: %u" |
4110 | " too small\n", cmd->data_length); | 4187 | " too small\n", cmd->data_length); |
4111 | return PYX_TRANSPORT_INVALID_CDB_FIELD; | 4188 | cmd->scsi_sense_reason = TCM_INVALID_CDB_FIELD; |
4189 | return -EINVAL; | ||
4112 | } | 4190 | } |
4113 | 4191 | ||
4114 | buf = transport_kmap_first_data_page(cmd); | 4192 | buf = transport_kmap_first_data_page(cmd); |
@@ -4255,7 +4333,8 @@ int target_scsi3_emulate_pr_in(struct se_task *task) | |||
4255 | pr_err("Received PERSISTENT_RESERVE CDB while legacy" | 4333 | pr_err("Received PERSISTENT_RESERVE CDB while legacy" |
4256 | " SPC-2 reservation is held, returning" | 4334 | " SPC-2 reservation is held, returning" |
4257 | " RESERVATION_CONFLICT\n"); | 4335 | " RESERVATION_CONFLICT\n"); |
4258 | return PYX_TRANSPORT_RESERVATION_CONFLICT; | 4336 | cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT; |
4337 | return -EINVAL; | ||
4259 | } | 4338 | } |
4260 | 4339 | ||
4261 | switch (cmd->t_task_cdb[1] & 0x1f) { | 4340 | switch (cmd->t_task_cdb[1] & 0x1f) { |
@@ -4274,7 +4353,8 @@ int target_scsi3_emulate_pr_in(struct se_task *task) | |||
4274 | default: | 4353 | default: |
4275 | pr_err("Unknown PERSISTENT_RESERVE_IN service" | 4354 | pr_err("Unknown PERSISTENT_RESERVE_IN service" |
4276 | " action: 0x%02x\n", cmd->t_task_cdb[1] & 0x1f); | 4355 | " action: 0x%02x\n", cmd->t_task_cdb[1] & 0x1f); |
4277 | ret = PYX_TRANSPORT_INVALID_CDB_FIELD; | 4356 | cmd->scsi_sense_reason = TCM_INVALID_CDB_FIELD; |
4357 | ret = -EINVAL; | ||
4278 | break; | 4358 | break; |
4279 | } | 4359 | } |
4280 | 4360 | ||
diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c index ed32e1efe429..8b15e56b0384 100644 --- a/drivers/target/target_core_pscsi.c +++ b/drivers/target/target_core_pscsi.c | |||
@@ -963,6 +963,7 @@ static inline struct bio *pscsi_get_bio(int sg_num) | |||
963 | static int pscsi_map_sg(struct se_task *task, struct scatterlist *task_sg, | 963 | static int pscsi_map_sg(struct se_task *task, struct scatterlist *task_sg, |
964 | struct bio **hbio) | 964 | struct bio **hbio) |
965 | { | 965 | { |
966 | struct se_cmd *cmd = task->task_se_cmd; | ||
966 | struct pscsi_dev_virt *pdv = task->task_se_cmd->se_dev->dev_ptr; | 967 | struct pscsi_dev_virt *pdv = task->task_se_cmd->se_dev->dev_ptr; |
967 | u32 task_sg_num = task->task_sg_nents; | 968 | u32 task_sg_num = task->task_sg_nents; |
968 | struct bio *bio = NULL, *tbio = NULL; | 969 | struct bio *bio = NULL, *tbio = NULL; |
@@ -971,7 +972,7 @@ static int pscsi_map_sg(struct se_task *task, struct scatterlist *task_sg, | |||
971 | u32 data_len = task->task_size, i, len, bytes, off; | 972 | u32 data_len = task->task_size, i, len, bytes, off; |
972 | int nr_pages = (task->task_size + task_sg[0].offset + | 973 | int nr_pages = (task->task_size + task_sg[0].offset + |
973 | PAGE_SIZE - 1) >> PAGE_SHIFT; | 974 | PAGE_SIZE - 1) >> PAGE_SHIFT; |
974 | int nr_vecs = 0, rc, ret = PYX_TRANSPORT_OUT_OF_MEMORY_RESOURCES; | 975 | int nr_vecs = 0, rc; |
975 | int rw = (task->task_data_direction == DMA_TO_DEVICE); | 976 | int rw = (task->task_data_direction == DMA_TO_DEVICE); |
976 | 977 | ||
977 | *hbio = NULL; | 978 | *hbio = NULL; |
@@ -1058,11 +1059,13 @@ fail: | |||
1058 | bio->bi_next = NULL; | 1059 | bio->bi_next = NULL; |
1059 | bio_endio(bio, 0); /* XXX: should be error */ | 1060 | bio_endio(bio, 0); /* XXX: should be error */ |
1060 | } | 1061 | } |
1061 | return ret; | 1062 | cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
1063 | return -ENOMEM; | ||
1062 | } | 1064 | } |
1063 | 1065 | ||
1064 | static int pscsi_do_task(struct se_task *task) | 1066 | static int pscsi_do_task(struct se_task *task) |
1065 | { | 1067 | { |
1068 | struct se_cmd *cmd = task->task_se_cmd; | ||
1066 | struct pscsi_dev_virt *pdv = task->task_se_cmd->se_dev->dev_ptr; | 1069 | struct pscsi_dev_virt *pdv = task->task_se_cmd->se_dev->dev_ptr; |
1067 | struct pscsi_plugin_task *pt = PSCSI_TASK(task); | 1070 | struct pscsi_plugin_task *pt = PSCSI_TASK(task); |
1068 | struct request *req; | 1071 | struct request *req; |
@@ -1078,7 +1081,9 @@ static int pscsi_do_task(struct se_task *task) | |||
1078 | if (!req || IS_ERR(req)) { | 1081 | if (!req || IS_ERR(req)) { |
1079 | pr_err("PSCSI: blk_get_request() failed: %ld\n", | 1082 | pr_err("PSCSI: blk_get_request() failed: %ld\n", |
1080 | req ? IS_ERR(req) : -ENOMEM); | 1083 | req ? IS_ERR(req) : -ENOMEM); |
1081 | return PYX_TRANSPORT_LU_COMM_FAILURE; | 1084 | cmd->scsi_sense_reason = |
1085 | TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; | ||
1086 | return -ENODEV; | ||
1082 | } | 1087 | } |
1083 | } else { | 1088 | } else { |
1084 | BUG_ON(!task->task_size); | 1089 | BUG_ON(!task->task_size); |
@@ -1087,8 +1092,11 @@ static int pscsi_do_task(struct se_task *task) | |||
1087 | * Setup the main struct request for the task->task_sg[] payload | 1092 | * Setup the main struct request for the task->task_sg[] payload |
1088 | */ | 1093 | */ |
1089 | ret = pscsi_map_sg(task, task->task_sg, &hbio); | 1094 | ret = pscsi_map_sg(task, task->task_sg, &hbio); |
1090 | if (ret < 0) | 1095 | if (ret < 0) { |
1091 | return PYX_TRANSPORT_LU_COMM_FAILURE; | 1096 | cmd->scsi_sense_reason = |
1097 | TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; | ||
1098 | return ret; | ||
1099 | } | ||
1092 | 1100 | ||
1093 | req = blk_make_request(pdv->pdv_sd->request_queue, hbio, | 1101 | req = blk_make_request(pdv->pdv_sd->request_queue, hbio, |
1094 | GFP_KERNEL); | 1102 | GFP_KERNEL); |
@@ -1115,7 +1123,7 @@ static int pscsi_do_task(struct se_task *task) | |||
1115 | (task->task_se_cmd->sam_task_attr == MSG_HEAD_TAG), | 1123 | (task->task_se_cmd->sam_task_attr == MSG_HEAD_TAG), |
1116 | pscsi_req_done); | 1124 | pscsi_req_done); |
1117 | 1125 | ||
1118 | return PYX_TRANSPORT_SENT_TO_TRANSPORT; | 1126 | return 0; |
1119 | 1127 | ||
1120 | fail: | 1128 | fail: |
1121 | while (hbio) { | 1129 | while (hbio) { |
@@ -1124,7 +1132,8 @@ fail: | |||
1124 | bio->bi_next = NULL; | 1132 | bio->bi_next = NULL; |
1125 | bio_endio(bio, 0); /* XXX: should be error */ | 1133 | bio_endio(bio, 0); /* XXX: should be error */ |
1126 | } | 1134 | } |
1127 | return PYX_TRANSPORT_OUT_OF_MEMORY_RESOURCES; | 1135 | cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
1136 | return -ENOMEM; | ||
1128 | } | 1137 | } |
1129 | 1138 | ||
1130 | /* pscsi_get_sense_buffer(): | 1139 | /* pscsi_get_sense_buffer(): |
@@ -1198,9 +1207,8 @@ static inline void pscsi_process_SAM_status( | |||
1198 | " 0x%02x Result: 0x%08x\n", task, pt->pscsi_cdb[0], | 1207 | " 0x%02x Result: 0x%08x\n", task, pt->pscsi_cdb[0], |
1199 | pt->pscsi_result); | 1208 | pt->pscsi_result); |
1200 | task->task_scsi_status = SAM_STAT_CHECK_CONDITION; | 1209 | task->task_scsi_status = SAM_STAT_CHECK_CONDITION; |
1201 | task->task_error_status = PYX_TRANSPORT_UNKNOWN_SAM_OPCODE; | 1210 | task->task_se_cmd->scsi_sense_reason = |
1202 | task->task_se_cmd->transport_error_status = | 1211 | TCM_UNSUPPORTED_SCSI_OPCODE; |
1203 | PYX_TRANSPORT_UNKNOWN_SAM_OPCODE; | ||
1204 | transport_complete_task(task, 0); | 1212 | transport_complete_task(task, 0); |
1205 | break; | 1213 | break; |
1206 | } | 1214 | } |
diff --git a/drivers/target/target_core_rd.c b/drivers/target/target_core_rd.c index 5158d3846f19..02e51faa2f4e 100644 --- a/drivers/target/target_core_rd.c +++ b/drivers/target/target_core_rd.c | |||
@@ -343,235 +343,74 @@ static struct rd_dev_sg_table *rd_get_sg_table(struct rd_dev *rd_dev, u32 page) | |||
343 | return NULL; | 343 | return NULL; |
344 | } | 344 | } |
345 | 345 | ||
346 | /* rd_MEMCPY_read(): | 346 | static int rd_MEMCPY(struct rd_request *req, u32 read_rd) |
347 | * | ||
348 | * | ||
349 | */ | ||
350 | static int rd_MEMCPY_read(struct rd_request *req) | ||
351 | { | 347 | { |
352 | struct se_task *task = &req->rd_task; | 348 | struct se_task *task = &req->rd_task; |
353 | struct rd_dev *dev = req->rd_task.task_se_cmd->se_dev->dev_ptr; | 349 | struct rd_dev *dev = req->rd_task.task_se_cmd->se_dev->dev_ptr; |
354 | struct rd_dev_sg_table *table; | 350 | struct rd_dev_sg_table *table; |
355 | struct scatterlist *sg_d, *sg_s; | 351 | struct scatterlist *rd_sg; |
356 | void *dst, *src; | 352 | struct sg_mapping_iter m; |
357 | u32 i = 0, j = 0, dst_offset = 0, src_offset = 0; | ||
358 | u32 length, page_end = 0, table_sg_end; | ||
359 | u32 rd_offset = req->rd_offset; | 353 | u32 rd_offset = req->rd_offset; |
354 | u32 src_len; | ||
360 | 355 | ||
361 | table = rd_get_sg_table(dev, req->rd_page); | 356 | table = rd_get_sg_table(dev, req->rd_page); |
362 | if (!table) | 357 | if (!table) |
363 | return -EINVAL; | 358 | return -EINVAL; |
364 | 359 | ||
365 | table_sg_end = (table->page_end_offset - req->rd_page); | 360 | rd_sg = &table->sg_table[req->rd_page - table->page_start_offset]; |
366 | sg_d = task->task_sg; | ||
367 | sg_s = &table->sg_table[req->rd_page - table->page_start_offset]; | ||
368 | 361 | ||
369 | pr_debug("RD[%u]: Read LBA: %llu, Size: %u Page: %u, Offset:" | 362 | pr_debug("RD[%u]: %s LBA: %llu, Size: %u Page: %u, Offset: %u\n", |
370 | " %u\n", dev->rd_dev_id, task->task_lba, req->rd_size, | 363 | dev->rd_dev_id, read_rd ? "Read" : "Write", |
371 | req->rd_page, req->rd_offset); | 364 | task->task_lba, req->rd_size, req->rd_page, |
372 | 365 | rd_offset); | |
373 | src_offset = rd_offset; | ||
374 | 366 | ||
367 | src_len = PAGE_SIZE - rd_offset; | ||
368 | sg_miter_start(&m, task->task_sg, task->task_sg_nents, | ||
369 | read_rd ? SG_MITER_TO_SG : SG_MITER_FROM_SG); | ||
375 | while (req->rd_size) { | 370 | while (req->rd_size) { |
376 | if ((sg_d[i].length - dst_offset) < | 371 | u32 len; |
377 | (sg_s[j].length - src_offset)) { | 372 | void *rd_addr; |
378 | length = (sg_d[i].length - dst_offset); | ||
379 | |||
380 | pr_debug("Step 1 - sg_d[%d]: %p length: %d" | ||
381 | " offset: %u sg_s[%d].length: %u\n", i, | ||
382 | &sg_d[i], sg_d[i].length, sg_d[i].offset, j, | ||
383 | sg_s[j].length); | ||
384 | pr_debug("Step 1 - length: %u dst_offset: %u" | ||
385 | " src_offset: %u\n", length, dst_offset, | ||
386 | src_offset); | ||
387 | |||
388 | if (length > req->rd_size) | ||
389 | length = req->rd_size; | ||
390 | |||
391 | dst = sg_virt(&sg_d[i++]) + dst_offset; | ||
392 | BUG_ON(!dst); | ||
393 | |||
394 | src = sg_virt(&sg_s[j]) + src_offset; | ||
395 | BUG_ON(!src); | ||
396 | |||
397 | dst_offset = 0; | ||
398 | src_offset = length; | ||
399 | page_end = 0; | ||
400 | } else { | ||
401 | length = (sg_s[j].length - src_offset); | ||
402 | |||
403 | pr_debug("Step 2 - sg_d[%d]: %p length: %d" | ||
404 | " offset: %u sg_s[%d].length: %u\n", i, | ||
405 | &sg_d[i], sg_d[i].length, sg_d[i].offset, | ||
406 | j, sg_s[j].length); | ||
407 | pr_debug("Step 2 - length: %u dst_offset: %u" | ||
408 | " src_offset: %u\n", length, dst_offset, | ||
409 | src_offset); | ||
410 | |||
411 | if (length > req->rd_size) | ||
412 | length = req->rd_size; | ||
413 | |||
414 | dst = sg_virt(&sg_d[i]) + dst_offset; | ||
415 | BUG_ON(!dst); | ||
416 | |||
417 | if (sg_d[i].length == length) { | ||
418 | i++; | ||
419 | dst_offset = 0; | ||
420 | } else | ||
421 | dst_offset = length; | ||
422 | |||
423 | src = sg_virt(&sg_s[j++]) + src_offset; | ||
424 | BUG_ON(!src); | ||
425 | |||
426 | src_offset = 0; | ||
427 | page_end = 1; | ||
428 | } | ||
429 | 373 | ||
430 | memcpy(dst, src, length); | 374 | sg_miter_next(&m); |
375 | len = min((u32)m.length, src_len); | ||
376 | m.consumed = len; | ||
431 | 377 | ||
432 | pr_debug("page: %u, remaining size: %u, length: %u," | 378 | rd_addr = sg_virt(rd_sg) + rd_offset; |
433 | " i: %u, j: %u\n", req->rd_page, | ||
434 | (req->rd_size - length), length, i, j); | ||
435 | 379 | ||
436 | req->rd_size -= length; | 380 | if (read_rd) |
437 | if (!req->rd_size) | 381 | memcpy(m.addr, rd_addr, len); |
438 | return 0; | 382 | else |
383 | memcpy(rd_addr, m.addr, len); | ||
439 | 384 | ||
440 | if (!page_end) | 385 | req->rd_size -= len; |
386 | if (!req->rd_size) | ||
441 | continue; | 387 | continue; |
442 | 388 | ||
443 | if (++req->rd_page <= table->page_end_offset) { | 389 | src_len -= len; |
444 | pr_debug("page: %u in same page table\n", | 390 | if (src_len) { |
445 | req->rd_page); | 391 | rd_offset += len; |
446 | continue; | 392 | continue; |
447 | } | 393 | } |
448 | 394 | ||
449 | pr_debug("getting new page table for page: %u\n", | 395 | /* rd page completed, next one please */ |
450 | req->rd_page); | 396 | req->rd_page++; |
451 | 397 | rd_offset = 0; | |
452 | table = rd_get_sg_table(dev, req->rd_page); | 398 | src_len = PAGE_SIZE; |
453 | if (!table) | 399 | if (req->rd_page <= table->page_end_offset) { |
454 | return -EINVAL; | 400 | rd_sg++; |
455 | |||
456 | sg_s = &table->sg_table[j = 0]; | ||
457 | } | ||
458 | |||
459 | return 0; | ||
460 | } | ||
461 | |||
462 | /* rd_MEMCPY_write(): | ||
463 | * | ||
464 | * | ||
465 | */ | ||
466 | static int rd_MEMCPY_write(struct rd_request *req) | ||
467 | { | ||
468 | struct se_task *task = &req->rd_task; | ||
469 | struct rd_dev *dev = req->rd_task.task_se_cmd->se_dev->dev_ptr; | ||
470 | struct rd_dev_sg_table *table; | ||
471 | struct scatterlist *sg_d, *sg_s; | ||
472 | void *dst, *src; | ||
473 | u32 i = 0, j = 0, dst_offset = 0, src_offset = 0; | ||
474 | u32 length, page_end = 0, table_sg_end; | ||
475 | u32 rd_offset = req->rd_offset; | ||
476 | |||
477 | table = rd_get_sg_table(dev, req->rd_page); | ||
478 | if (!table) | ||
479 | return -EINVAL; | ||
480 | |||
481 | table_sg_end = (table->page_end_offset - req->rd_page); | ||
482 | sg_d = &table->sg_table[req->rd_page - table->page_start_offset]; | ||
483 | sg_s = task->task_sg; | ||
484 | |||
485 | pr_debug("RD[%d] Write LBA: %llu, Size: %u, Page: %u," | ||
486 | " Offset: %u\n", dev->rd_dev_id, task->task_lba, req->rd_size, | ||
487 | req->rd_page, req->rd_offset); | ||
488 | |||
489 | dst_offset = rd_offset; | ||
490 | |||
491 | while (req->rd_size) { | ||
492 | if ((sg_s[i].length - src_offset) < | ||
493 | (sg_d[j].length - dst_offset)) { | ||
494 | length = (sg_s[i].length - src_offset); | ||
495 | |||
496 | pr_debug("Step 1 - sg_s[%d]: %p length: %d" | ||
497 | " offset: %d sg_d[%d].length: %u\n", i, | ||
498 | &sg_s[i], sg_s[i].length, sg_s[i].offset, | ||
499 | j, sg_d[j].length); | ||
500 | pr_debug("Step 1 - length: %u src_offset: %u" | ||
501 | " dst_offset: %u\n", length, src_offset, | ||
502 | dst_offset); | ||
503 | |||
504 | if (length > req->rd_size) | ||
505 | length = req->rd_size; | ||
506 | |||
507 | src = sg_virt(&sg_s[i++]) + src_offset; | ||
508 | BUG_ON(!src); | ||
509 | |||
510 | dst = sg_virt(&sg_d[j]) + dst_offset; | ||
511 | BUG_ON(!dst); | ||
512 | |||
513 | src_offset = 0; | ||
514 | dst_offset = length; | ||
515 | page_end = 0; | ||
516 | } else { | ||
517 | length = (sg_d[j].length - dst_offset); | ||
518 | |||
519 | pr_debug("Step 2 - sg_s[%d]: %p length: %d" | ||
520 | " offset: %d sg_d[%d].length: %u\n", i, | ||
521 | &sg_s[i], sg_s[i].length, sg_s[i].offset, | ||
522 | j, sg_d[j].length); | ||
523 | pr_debug("Step 2 - length: %u src_offset: %u" | ||
524 | " dst_offset: %u\n", length, src_offset, | ||
525 | dst_offset); | ||
526 | |||
527 | if (length > req->rd_size) | ||
528 | length = req->rd_size; | ||
529 | |||
530 | src = sg_virt(&sg_s[i]) + src_offset; | ||
531 | BUG_ON(!src); | ||
532 | |||
533 | if (sg_s[i].length == length) { | ||
534 | i++; | ||
535 | src_offset = 0; | ||
536 | } else | ||
537 | src_offset = length; | ||
538 | |||
539 | dst = sg_virt(&sg_d[j++]) + dst_offset; | ||
540 | BUG_ON(!dst); | ||
541 | |||
542 | dst_offset = 0; | ||
543 | page_end = 1; | ||
544 | } | ||
545 | |||
546 | memcpy(dst, src, length); | ||
547 | |||
548 | pr_debug("page: %u, remaining size: %u, length: %u," | ||
549 | " i: %u, j: %u\n", req->rd_page, | ||
550 | (req->rd_size - length), length, i, j); | ||
551 | |||
552 | req->rd_size -= length; | ||
553 | if (!req->rd_size) | ||
554 | return 0; | ||
555 | |||
556 | if (!page_end) | ||
557 | continue; | ||
558 | |||
559 | if (++req->rd_page <= table->page_end_offset) { | ||
560 | pr_debug("page: %u in same page table\n", | ||
561 | req->rd_page); | ||
562 | continue; | 401 | continue; |
563 | } | 402 | } |
564 | 403 | ||
565 | pr_debug("getting new page table for page: %u\n", | ||
566 | req->rd_page); | ||
567 | |||
568 | table = rd_get_sg_table(dev, req->rd_page); | 404 | table = rd_get_sg_table(dev, req->rd_page); |
569 | if (!table) | 405 | if (!table) { |
406 | sg_miter_stop(&m); | ||
570 | return -EINVAL; | 407 | return -EINVAL; |
408 | } | ||
571 | 409 | ||
572 | sg_d = &table->sg_table[j = 0]; | 410 | /* since we increment, the first sg entry is correct */ |
411 | rd_sg = table->sg_table; | ||
573 | } | 412 | } |
574 | 413 | sg_miter_stop(&m); | |
575 | return 0; | 414 | return 0; |
576 | } | 415 | } |
577 | 416 | ||
@@ -583,28 +422,21 @@ static int rd_MEMCPY_do_task(struct se_task *task) | |||
583 | { | 422 | { |
584 | struct se_device *dev = task->task_se_cmd->se_dev; | 423 | struct se_device *dev = task->task_se_cmd->se_dev; |
585 | struct rd_request *req = RD_REQ(task); | 424 | struct rd_request *req = RD_REQ(task); |
586 | unsigned long long lba; | 425 | u64 tmp; |
587 | int ret; | 426 | int ret; |
588 | 427 | ||
589 | req->rd_page = (task->task_lba * dev->se_sub_dev->se_dev_attrib.block_size) / PAGE_SIZE; | 428 | tmp = task->task_lba * dev->se_sub_dev->se_dev_attrib.block_size; |
590 | lba = task->task_lba; | 429 | req->rd_offset = do_div(tmp, PAGE_SIZE); |
591 | req->rd_offset = (do_div(lba, | 430 | req->rd_page = tmp; |
592 | (PAGE_SIZE / dev->se_sub_dev->se_dev_attrib.block_size))) * | ||
593 | dev->se_sub_dev->se_dev_attrib.block_size; | ||
594 | req->rd_size = task->task_size; | 431 | req->rd_size = task->task_size; |
595 | 432 | ||
596 | if (task->task_data_direction == DMA_FROM_DEVICE) | 433 | ret = rd_MEMCPY(req, task->task_data_direction == DMA_FROM_DEVICE); |
597 | ret = rd_MEMCPY_read(req); | ||
598 | else | ||
599 | ret = rd_MEMCPY_write(req); | ||
600 | |||
601 | if (ret != 0) | 434 | if (ret != 0) |
602 | return ret; | 435 | return ret; |
603 | 436 | ||
604 | task->task_scsi_status = GOOD; | 437 | task->task_scsi_status = GOOD; |
605 | transport_complete_task(task, 1); | 438 | transport_complete_task(task, 1); |
606 | 439 | return 0; | |
607 | return PYX_TRANSPORT_SENT_TO_TRANSPORT; | ||
608 | } | 440 | } |
609 | 441 | ||
610 | /* rd_free_task(): (Part of se_subsystem_api_t template) | 442 | /* rd_free_task(): (Part of se_subsystem_api_t template) |
diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c index 217e29df6297..684522805a1f 100644 --- a/drivers/target/target_core_tmr.c +++ b/drivers/target/target_core_tmr.c | |||
@@ -345,10 +345,6 @@ static void core_tmr_drain_cmd_list( | |||
345 | " %d t_fe_count: %d\n", (preempt_and_abort_list) ? | 345 | " %d t_fe_count: %d\n", (preempt_and_abort_list) ? |
346 | "Preempt" : "", cmd, cmd->t_state, | 346 | "Preempt" : "", cmd, cmd->t_state, |
347 | atomic_read(&cmd->t_fe_count)); | 347 | atomic_read(&cmd->t_fe_count)); |
348 | /* | ||
349 | * Signal that the command has failed via cmd->se_cmd_flags, | ||
350 | */ | ||
351 | transport_new_cmd_failure(cmd); | ||
352 | 348 | ||
353 | core_tmr_handle_tas_abort(tmr_nacl, cmd, tas, | 349 | core_tmr_handle_tas_abort(tmr_nacl, cmd, tas, |
354 | atomic_read(&cmd->t_fe_count)); | 350 | atomic_read(&cmd->t_fe_count)); |
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 3400ae6e93f8..0257658e2e3e 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c | |||
@@ -61,7 +61,6 @@ | |||
61 | static int sub_api_initialized; | 61 | static int sub_api_initialized; |
62 | 62 | ||
63 | static struct workqueue_struct *target_completion_wq; | 63 | static struct workqueue_struct *target_completion_wq; |
64 | static struct kmem_cache *se_cmd_cache; | ||
65 | static struct kmem_cache *se_sess_cache; | 64 | static struct kmem_cache *se_sess_cache; |
66 | struct kmem_cache *se_tmr_req_cache; | 65 | struct kmem_cache *se_tmr_req_cache; |
67 | struct kmem_cache *se_ua_cache; | 66 | struct kmem_cache *se_ua_cache; |
@@ -82,24 +81,18 @@ static int transport_generic_get_mem(struct se_cmd *cmd); | |||
82 | static void transport_put_cmd(struct se_cmd *cmd); | 81 | static void transport_put_cmd(struct se_cmd *cmd); |
83 | static void transport_remove_cmd_from_queue(struct se_cmd *cmd); | 82 | static void transport_remove_cmd_from_queue(struct se_cmd *cmd); |
84 | static int transport_set_sense_codes(struct se_cmd *cmd, u8 asc, u8 ascq); | 83 | static int transport_set_sense_codes(struct se_cmd *cmd, u8 asc, u8 ascq); |
85 | static void transport_generic_request_failure(struct se_cmd *, int, int); | 84 | static void transport_generic_request_failure(struct se_cmd *); |
86 | static void target_complete_ok_work(struct work_struct *work); | 85 | static void target_complete_ok_work(struct work_struct *work); |
87 | 86 | ||
88 | int init_se_kmem_caches(void) | 87 | int init_se_kmem_caches(void) |
89 | { | 88 | { |
90 | se_cmd_cache = kmem_cache_create("se_cmd_cache", | ||
91 | sizeof(struct se_cmd), __alignof__(struct se_cmd), 0, NULL); | ||
92 | if (!se_cmd_cache) { | ||
93 | pr_err("kmem_cache_create for struct se_cmd failed\n"); | ||
94 | goto out; | ||
95 | } | ||
96 | se_tmr_req_cache = kmem_cache_create("se_tmr_cache", | 89 | se_tmr_req_cache = kmem_cache_create("se_tmr_cache", |
97 | sizeof(struct se_tmr_req), __alignof__(struct se_tmr_req), | 90 | sizeof(struct se_tmr_req), __alignof__(struct se_tmr_req), |
98 | 0, NULL); | 91 | 0, NULL); |
99 | if (!se_tmr_req_cache) { | 92 | if (!se_tmr_req_cache) { |
100 | pr_err("kmem_cache_create() for struct se_tmr_req" | 93 | pr_err("kmem_cache_create() for struct se_tmr_req" |
101 | " failed\n"); | 94 | " failed\n"); |
102 | goto out_free_cmd_cache; | 95 | goto out; |
103 | } | 96 | } |
104 | se_sess_cache = kmem_cache_create("se_sess_cache", | 97 | se_sess_cache = kmem_cache_create("se_sess_cache", |
105 | sizeof(struct se_session), __alignof__(struct se_session), | 98 | sizeof(struct se_session), __alignof__(struct se_session), |
@@ -182,8 +175,6 @@ out_free_sess_cache: | |||
182 | kmem_cache_destroy(se_sess_cache); | 175 | kmem_cache_destroy(se_sess_cache); |
183 | out_free_tmr_req_cache: | 176 | out_free_tmr_req_cache: |
184 | kmem_cache_destroy(se_tmr_req_cache); | 177 | kmem_cache_destroy(se_tmr_req_cache); |
185 | out_free_cmd_cache: | ||
186 | kmem_cache_destroy(se_cmd_cache); | ||
187 | out: | 178 | out: |
188 | return -ENOMEM; | 179 | return -ENOMEM; |
189 | } | 180 | } |
@@ -191,7 +182,6 @@ out: | |||
191 | void release_se_kmem_caches(void) | 182 | void release_se_kmem_caches(void) |
192 | { | 183 | { |
193 | destroy_workqueue(target_completion_wq); | 184 | destroy_workqueue(target_completion_wq); |
194 | kmem_cache_destroy(se_cmd_cache); | ||
195 | kmem_cache_destroy(se_tmr_req_cache); | 185 | kmem_cache_destroy(se_tmr_req_cache); |
196 | kmem_cache_destroy(se_sess_cache); | 186 | kmem_cache_destroy(se_sess_cache); |
197 | kmem_cache_destroy(se_ua_cache); | 187 | kmem_cache_destroy(se_ua_cache); |
@@ -680,9 +670,9 @@ void transport_complete_sync_cache(struct se_cmd *cmd, int good) | |||
680 | task->task_scsi_status = GOOD; | 670 | task->task_scsi_status = GOOD; |
681 | } else { | 671 | } else { |
682 | task->task_scsi_status = SAM_STAT_CHECK_CONDITION; | 672 | task->task_scsi_status = SAM_STAT_CHECK_CONDITION; |
683 | task->task_error_status = PYX_TRANSPORT_ILLEGAL_REQUEST; | 673 | task->task_se_cmd->scsi_sense_reason = |
684 | task->task_se_cmd->transport_error_status = | 674 | TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
685 | PYX_TRANSPORT_ILLEGAL_REQUEST; | 675 | |
686 | } | 676 | } |
687 | 677 | ||
688 | transport_complete_task(task, good); | 678 | transport_complete_task(task, good); |
@@ -693,7 +683,7 @@ static void target_complete_failure_work(struct work_struct *work) | |||
693 | { | 683 | { |
694 | struct se_cmd *cmd = container_of(work, struct se_cmd, work); | 684 | struct se_cmd *cmd = container_of(work, struct se_cmd, work); |
695 | 685 | ||
696 | transport_generic_request_failure(cmd, 1, 1); | 686 | transport_generic_request_failure(cmd); |
697 | } | 687 | } |
698 | 688 | ||
699 | /* transport_complete_task(): | 689 | /* transport_complete_task(): |
@@ -755,10 +745,11 @@ void transport_complete_task(struct se_task *task, int success) | |||
755 | if (cmd->t_tasks_failed) { | 745 | if (cmd->t_tasks_failed) { |
756 | if (!task->task_error_status) { | 746 | if (!task->task_error_status) { |
757 | task->task_error_status = | 747 | task->task_error_status = |
758 | PYX_TRANSPORT_UNKNOWN_SAM_OPCODE; | 748 | TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
759 | cmd->transport_error_status = | 749 | cmd->scsi_sense_reason = |
760 | PYX_TRANSPORT_UNKNOWN_SAM_OPCODE; | 750 | TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
761 | } | 751 | } |
752 | |||
762 | INIT_WORK(&cmd->work, target_complete_failure_work); | 753 | INIT_WORK(&cmd->work, target_complete_failure_work); |
763 | } else { | 754 | } else { |
764 | atomic_set(&cmd->t_transport_complete, 1); | 755 | atomic_set(&cmd->t_transport_complete, 1); |
@@ -1335,23 +1326,17 @@ struct se_device *transport_add_device_to_core_hba( | |||
1335 | dev->se_hba = hba; | 1326 | dev->se_hba = hba; |
1336 | dev->se_sub_dev = se_dev; | 1327 | dev->se_sub_dev = se_dev; |
1337 | dev->transport = transport; | 1328 | dev->transport = transport; |
1338 | atomic_set(&dev->active_cmds, 0); | ||
1339 | INIT_LIST_HEAD(&dev->dev_list); | 1329 | INIT_LIST_HEAD(&dev->dev_list); |
1340 | INIT_LIST_HEAD(&dev->dev_sep_list); | 1330 | INIT_LIST_HEAD(&dev->dev_sep_list); |
1341 | INIT_LIST_HEAD(&dev->dev_tmr_list); | 1331 | INIT_LIST_HEAD(&dev->dev_tmr_list); |
1342 | INIT_LIST_HEAD(&dev->execute_task_list); | 1332 | INIT_LIST_HEAD(&dev->execute_task_list); |
1343 | INIT_LIST_HEAD(&dev->delayed_cmd_list); | 1333 | INIT_LIST_HEAD(&dev->delayed_cmd_list); |
1344 | INIT_LIST_HEAD(&dev->ordered_cmd_list); | ||
1345 | INIT_LIST_HEAD(&dev->state_task_list); | 1334 | INIT_LIST_HEAD(&dev->state_task_list); |
1346 | INIT_LIST_HEAD(&dev->qf_cmd_list); | 1335 | INIT_LIST_HEAD(&dev->qf_cmd_list); |
1347 | spin_lock_init(&dev->execute_task_lock); | 1336 | spin_lock_init(&dev->execute_task_lock); |
1348 | spin_lock_init(&dev->delayed_cmd_lock); | 1337 | spin_lock_init(&dev->delayed_cmd_lock); |
1349 | spin_lock_init(&dev->ordered_cmd_lock); | ||
1350 | spin_lock_init(&dev->state_task_lock); | ||
1351 | spin_lock_init(&dev->dev_alua_lock); | ||
1352 | spin_lock_init(&dev->dev_reservation_lock); | 1338 | spin_lock_init(&dev->dev_reservation_lock); |
1353 | spin_lock_init(&dev->dev_status_lock); | 1339 | spin_lock_init(&dev->dev_status_lock); |
1354 | spin_lock_init(&dev->dev_status_thr_lock); | ||
1355 | spin_lock_init(&dev->se_port_lock); | 1340 | spin_lock_init(&dev->se_port_lock); |
1356 | spin_lock_init(&dev->se_tmr_lock); | 1341 | spin_lock_init(&dev->se_tmr_lock); |
1357 | spin_lock_init(&dev->qf_cmd_lock); | 1342 | spin_lock_init(&dev->qf_cmd_lock); |
@@ -1507,7 +1492,6 @@ void transport_init_se_cmd( | |||
1507 | { | 1492 | { |
1508 | INIT_LIST_HEAD(&cmd->se_lun_node); | 1493 | INIT_LIST_HEAD(&cmd->se_lun_node); |
1509 | INIT_LIST_HEAD(&cmd->se_delayed_node); | 1494 | INIT_LIST_HEAD(&cmd->se_delayed_node); |
1510 | INIT_LIST_HEAD(&cmd->se_ordered_node); | ||
1511 | INIT_LIST_HEAD(&cmd->se_qf_node); | 1495 | INIT_LIST_HEAD(&cmd->se_qf_node); |
1512 | INIT_LIST_HEAD(&cmd->se_queue_node); | 1496 | INIT_LIST_HEAD(&cmd->se_queue_node); |
1513 | INIT_LIST_HEAD(&cmd->se_cmd_list); | 1497 | INIT_LIST_HEAD(&cmd->se_cmd_list); |
@@ -1573,6 +1557,8 @@ int transport_generic_allocate_tasks( | |||
1573 | pr_err("Received SCSI CDB with command_size: %d that" | 1557 | pr_err("Received SCSI CDB with command_size: %d that" |
1574 | " exceeds SCSI_MAX_VARLEN_CDB_SIZE: %d\n", | 1558 | " exceeds SCSI_MAX_VARLEN_CDB_SIZE: %d\n", |
1575 | scsi_command_size(cdb), SCSI_MAX_VARLEN_CDB_SIZE); | 1559 | scsi_command_size(cdb), SCSI_MAX_VARLEN_CDB_SIZE); |
1560 | cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; | ||
1561 | cmd->scsi_sense_reason = TCM_INVALID_CDB_FIELD; | ||
1576 | return -EINVAL; | 1562 | return -EINVAL; |
1577 | } | 1563 | } |
1578 | /* | 1564 | /* |
@@ -1588,6 +1574,9 @@ int transport_generic_allocate_tasks( | |||
1588 | " %u > sizeof(cmd->__t_task_cdb): %lu ops\n", | 1574 | " %u > sizeof(cmd->__t_task_cdb): %lu ops\n", |
1589 | scsi_command_size(cdb), | 1575 | scsi_command_size(cdb), |
1590 | (unsigned long)sizeof(cmd->__t_task_cdb)); | 1576 | (unsigned long)sizeof(cmd->__t_task_cdb)); |
1577 | cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; | ||
1578 | cmd->scsi_sense_reason = | ||
1579 | TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; | ||
1591 | return -ENOMEM; | 1580 | return -ENOMEM; |
1592 | } | 1581 | } |
1593 | } else | 1582 | } else |
@@ -1658,11 +1647,9 @@ int transport_handle_cdb_direct( | |||
1658 | * and call transport_generic_request_failure() if necessary.. | 1647 | * and call transport_generic_request_failure() if necessary.. |
1659 | */ | 1648 | */ |
1660 | ret = transport_generic_new_cmd(cmd); | 1649 | ret = transport_generic_new_cmd(cmd); |
1661 | if (ret < 0) { | 1650 | if (ret < 0) |
1662 | cmd->transport_error_status = ret; | 1651 | transport_generic_request_failure(cmd); |
1663 | transport_generic_request_failure(cmd, 0, | 1652 | |
1664 | (cmd->data_direction != DMA_TO_DEVICE)); | ||
1665 | } | ||
1666 | return 0; | 1653 | return 0; |
1667 | } | 1654 | } |
1668 | EXPORT_SYMBOL(transport_handle_cdb_direct); | 1655 | EXPORT_SYMBOL(transport_handle_cdb_direct); |
@@ -1798,20 +1785,16 @@ static int transport_stop_tasks_for_cmd(struct se_cmd *cmd) | |||
1798 | /* | 1785 | /* |
1799 | * Handle SAM-esque emulation for generic transport request failures. | 1786 | * Handle SAM-esque emulation for generic transport request failures. |
1800 | */ | 1787 | */ |
1801 | static void transport_generic_request_failure( | 1788 | static void transport_generic_request_failure(struct se_cmd *cmd) |
1802 | struct se_cmd *cmd, | ||
1803 | int complete, | ||
1804 | int sc) | ||
1805 | { | 1789 | { |
1806 | int ret = 0; | 1790 | int ret = 0; |
1807 | 1791 | ||
1808 | pr_debug("-----[ Storage Engine Exception for cmd: %p ITT: 0x%08x" | 1792 | pr_debug("-----[ Storage Engine Exception for cmd: %p ITT: 0x%08x" |
1809 | " CDB: 0x%02x\n", cmd, cmd->se_tfo->get_task_tag(cmd), | 1793 | " CDB: 0x%02x\n", cmd, cmd->se_tfo->get_task_tag(cmd), |
1810 | cmd->t_task_cdb[0]); | 1794 | cmd->t_task_cdb[0]); |
1811 | pr_debug("-----[ i_state: %d t_state: %d transport_error_status: %d\n", | 1795 | pr_debug("-----[ i_state: %d t_state: %d scsi_sense_reason: %d\n", |
1812 | cmd->se_tfo->get_cmd_state(cmd), | 1796 | cmd->se_tfo->get_cmd_state(cmd), |
1813 | cmd->t_state, | 1797 | cmd->t_state, cmd->scsi_sense_reason); |
1814 | cmd->transport_error_status); | ||
1815 | pr_debug("-----[ t_tasks: %d t_task_cdbs_left: %d" | 1798 | pr_debug("-----[ t_tasks: %d t_task_cdbs_left: %d" |
1816 | " t_task_cdbs_sent: %d t_task_cdbs_ex_left: %d --" | 1799 | " t_task_cdbs_sent: %d t_task_cdbs_ex_left: %d --" |
1817 | " t_transport_active: %d t_transport_stop: %d" | 1800 | " t_transport_active: %d t_transport_stop: %d" |
@@ -1829,46 +1812,19 @@ static void transport_generic_request_failure( | |||
1829 | if (cmd->se_dev->dev_task_attr_type == SAM_TASK_ATTR_EMULATED) | 1812 | if (cmd->se_dev->dev_task_attr_type == SAM_TASK_ATTR_EMULATED) |
1830 | transport_complete_task_attr(cmd); | 1813 | transport_complete_task_attr(cmd); |
1831 | 1814 | ||
1832 | if (complete) { | 1815 | switch (cmd->scsi_sense_reason) { |
1833 | cmd->transport_error_status = PYX_TRANSPORT_LU_COMM_FAILURE; | 1816 | case TCM_NON_EXISTENT_LUN: |
1834 | } | 1817 | case TCM_UNSUPPORTED_SCSI_OPCODE: |
1835 | 1818 | case TCM_INVALID_CDB_FIELD: | |
1836 | switch (cmd->transport_error_status) { | 1819 | case TCM_INVALID_PARAMETER_LIST: |
1837 | case PYX_TRANSPORT_UNKNOWN_SAM_OPCODE: | 1820 | case TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE: |
1838 | cmd->scsi_sense_reason = TCM_UNSUPPORTED_SCSI_OPCODE; | 1821 | case TCM_UNKNOWN_MODE_PAGE: |
1839 | break; | 1822 | case TCM_WRITE_PROTECTED: |
1840 | case PYX_TRANSPORT_REQ_TOO_MANY_SECTORS: | 1823 | case TCM_CHECK_CONDITION_ABORT_CMD: |
1841 | cmd->scsi_sense_reason = TCM_SECTOR_COUNT_TOO_MANY; | 1824 | case TCM_CHECK_CONDITION_UNIT_ATTENTION: |
1842 | break; | 1825 | case TCM_CHECK_CONDITION_NOT_READY: |
1843 | case PYX_TRANSPORT_INVALID_CDB_FIELD: | ||
1844 | cmd->scsi_sense_reason = TCM_INVALID_CDB_FIELD; | ||
1845 | break; | ||
1846 | case PYX_TRANSPORT_INVALID_PARAMETER_LIST: | ||
1847 | cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST; | ||
1848 | break; | ||
1849 | case PYX_TRANSPORT_OUT_OF_MEMORY_RESOURCES: | ||
1850 | if (!sc) | ||
1851 | transport_new_cmd_failure(cmd); | ||
1852 | /* | ||
1853 | * Currently for PYX_TRANSPORT_OUT_OF_MEMORY_RESOURCES, | ||
1854 | * we force this session to fall back to session | ||
1855 | * recovery. | ||
1856 | */ | ||
1857 | cmd->se_tfo->fall_back_to_erl0(cmd->se_sess); | ||
1858 | cmd->se_tfo->stop_session(cmd->se_sess, 0, 0); | ||
1859 | |||
1860 | goto check_stop; | ||
1861 | case PYX_TRANSPORT_LU_COMM_FAILURE: | ||
1862 | case PYX_TRANSPORT_ILLEGAL_REQUEST: | ||
1863 | cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; | ||
1864 | break; | ||
1865 | case PYX_TRANSPORT_UNKNOWN_MODE_PAGE: | ||
1866 | cmd->scsi_sense_reason = TCM_UNKNOWN_MODE_PAGE; | ||
1867 | break; | ||
1868 | case PYX_TRANSPORT_WRITE_PROTECTED: | ||
1869 | cmd->scsi_sense_reason = TCM_WRITE_PROTECTED; | ||
1870 | break; | 1826 | break; |
1871 | case PYX_TRANSPORT_RESERVATION_CONFLICT: | 1827 | case TCM_RESERVATION_CONFLICT: |
1872 | /* | 1828 | /* |
1873 | * No SENSE Data payload for this case, set SCSI Status | 1829 | * No SENSE Data payload for this case, set SCSI Status |
1874 | * and queue the response to $FABRIC_MOD. | 1830 | * and queue the response to $FABRIC_MOD. |
@@ -1893,15 +1849,9 @@ static void transport_generic_request_failure( | |||
1893 | if (ret == -EAGAIN || ret == -ENOMEM) | 1849 | if (ret == -EAGAIN || ret == -ENOMEM) |
1894 | goto queue_full; | 1850 | goto queue_full; |
1895 | goto check_stop; | 1851 | goto check_stop; |
1896 | case PYX_TRANSPORT_USE_SENSE_REASON: | ||
1897 | /* | ||
1898 | * struct se_cmd->scsi_sense_reason already set | ||
1899 | */ | ||
1900 | break; | ||
1901 | default: | 1852 | default: |
1902 | pr_err("Unknown transport error for CDB 0x%02x: %d\n", | 1853 | pr_err("Unknown transport error for CDB 0x%02x: %d\n", |
1903 | cmd->t_task_cdb[0], | 1854 | cmd->t_task_cdb[0], cmd->scsi_sense_reason); |
1904 | cmd->transport_error_status); | ||
1905 | cmd->scsi_sense_reason = TCM_UNSUPPORTED_SCSI_OPCODE; | 1855 | cmd->scsi_sense_reason = TCM_UNSUPPORTED_SCSI_OPCODE; |
1906 | break; | 1856 | break; |
1907 | } | 1857 | } |
@@ -1912,14 +1862,10 @@ static void transport_generic_request_failure( | |||
1912 | * transport_send_check_condition_and_sense() after handling | 1862 | * transport_send_check_condition_and_sense() after handling |
1913 | * possible unsoliticied write data payloads. | 1863 | * possible unsoliticied write data payloads. |
1914 | */ | 1864 | */ |
1915 | if (!sc && !cmd->se_tfo->new_cmd_map) | 1865 | ret = transport_send_check_condition_and_sense(cmd, |
1916 | transport_new_cmd_failure(cmd); | 1866 | cmd->scsi_sense_reason, 0); |
1917 | else { | 1867 | if (ret == -EAGAIN || ret == -ENOMEM) |
1918 | ret = transport_send_check_condition_and_sense(cmd, | 1868 | goto queue_full; |
1919 | cmd->scsi_sense_reason, 0); | ||
1920 | if (ret == -EAGAIN || ret == -ENOMEM) | ||
1921 | goto queue_full; | ||
1922 | } | ||
1923 | 1869 | ||
1924 | check_stop: | 1870 | check_stop: |
1925 | transport_lun_remove_cmd(cmd); | 1871 | transport_lun_remove_cmd(cmd); |
@@ -2002,19 +1948,12 @@ static inline int transport_execute_task_attr(struct se_cmd *cmd) | |||
2002 | * to allow the passed struct se_cmd list of tasks to the front of the list. | 1948 | * to allow the passed struct se_cmd list of tasks to the front of the list. |
2003 | */ | 1949 | */ |
2004 | if (cmd->sam_task_attr == MSG_HEAD_TAG) { | 1950 | if (cmd->sam_task_attr == MSG_HEAD_TAG) { |
2005 | atomic_inc(&cmd->se_dev->dev_hoq_count); | ||
2006 | smp_mb__after_atomic_inc(); | ||
2007 | pr_debug("Added HEAD_OF_QUEUE for CDB:" | 1951 | pr_debug("Added HEAD_OF_QUEUE for CDB:" |
2008 | " 0x%02x, se_ordered_id: %u\n", | 1952 | " 0x%02x, se_ordered_id: %u\n", |
2009 | cmd->t_task_cdb[0], | 1953 | cmd->t_task_cdb[0], |
2010 | cmd->se_ordered_id); | 1954 | cmd->se_ordered_id); |
2011 | return 1; | 1955 | return 1; |
2012 | } else if (cmd->sam_task_attr == MSG_ORDERED_TAG) { | 1956 | } else if (cmd->sam_task_attr == MSG_ORDERED_TAG) { |
2013 | spin_lock(&cmd->se_dev->ordered_cmd_lock); | ||
2014 | list_add_tail(&cmd->se_ordered_node, | ||
2015 | &cmd->se_dev->ordered_cmd_list); | ||
2016 | spin_unlock(&cmd->se_dev->ordered_cmd_lock); | ||
2017 | |||
2018 | atomic_inc(&cmd->se_dev->dev_ordered_sync); | 1957 | atomic_inc(&cmd->se_dev->dev_ordered_sync); |
2019 | smp_mb__after_atomic_inc(); | 1958 | smp_mb__after_atomic_inc(); |
2020 | 1959 | ||
@@ -2076,9 +2015,9 @@ static int transport_execute_tasks(struct se_cmd *cmd) | |||
2076 | { | 2015 | { |
2077 | int add_tasks; | 2016 | int add_tasks; |
2078 | 2017 | ||
2079 | if (se_dev_check_online(cmd->se_orig_obj_ptr) != 0) { | 2018 | if (se_dev_check_online(cmd->se_dev) != 0) { |
2080 | cmd->transport_error_status = PYX_TRANSPORT_LU_COMM_FAILURE; | 2019 | cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; |
2081 | transport_generic_request_failure(cmd, 0, 1); | 2020 | transport_generic_request_failure(cmd); |
2082 | return 0; | 2021 | return 0; |
2083 | } | 2022 | } |
2084 | 2023 | ||
@@ -2163,14 +2102,13 @@ check_depth: | |||
2163 | else | 2102 | else |
2164 | error = dev->transport->do_task(task); | 2103 | error = dev->transport->do_task(task); |
2165 | if (error != 0) { | 2104 | if (error != 0) { |
2166 | cmd->transport_error_status = error; | ||
2167 | spin_lock_irqsave(&cmd->t_state_lock, flags); | 2105 | spin_lock_irqsave(&cmd->t_state_lock, flags); |
2168 | task->task_flags &= ~TF_ACTIVE; | 2106 | task->task_flags &= ~TF_ACTIVE; |
2169 | spin_unlock_irqrestore(&cmd->t_state_lock, flags); | 2107 | spin_unlock_irqrestore(&cmd->t_state_lock, flags); |
2170 | atomic_set(&cmd->t_transport_sent, 0); | 2108 | atomic_set(&cmd->t_transport_sent, 0); |
2171 | transport_stop_tasks_for_cmd(cmd); | 2109 | transport_stop_tasks_for_cmd(cmd); |
2172 | atomic_inc(&dev->depth_left); | 2110 | atomic_inc(&dev->depth_left); |
2173 | transport_generic_request_failure(cmd, 0, 1); | 2111 | transport_generic_request_failure(cmd); |
2174 | } | 2112 | } |
2175 | 2113 | ||
2176 | goto check_depth; | 2114 | goto check_depth; |
@@ -2178,19 +2116,6 @@ check_depth: | |||
2178 | return 0; | 2116 | return 0; |
2179 | } | 2117 | } |
2180 | 2118 | ||
2181 | void transport_new_cmd_failure(struct se_cmd *se_cmd) | ||
2182 | { | ||
2183 | unsigned long flags; | ||
2184 | /* | ||
2185 | * Any unsolicited data will get dumped for failed command inside of | ||
2186 | * the fabric plugin | ||
2187 | */ | ||
2188 | spin_lock_irqsave(&se_cmd->t_state_lock, flags); | ||
2189 | se_cmd->se_cmd_flags |= SCF_SE_CMD_FAILED; | ||
2190 | se_cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; | ||
2191 | spin_unlock_irqrestore(&se_cmd->t_state_lock, flags); | ||
2192 | } | ||
2193 | |||
2194 | static inline u32 transport_get_sectors_6( | 2119 | static inline u32 transport_get_sectors_6( |
2195 | unsigned char *cdb, | 2120 | unsigned char *cdb, |
2196 | struct se_cmd *cmd, | 2121 | struct se_cmd *cmd, |
@@ -2213,10 +2138,15 @@ static inline u32 transport_get_sectors_6( | |||
2213 | 2138 | ||
2214 | /* | 2139 | /* |
2215 | * Everything else assume TYPE_DISK Sector CDB location. | 2140 | * Everything else assume TYPE_DISK Sector CDB location. |
2216 | * Use 8-bit sector value. | 2141 | * Use 8-bit sector value. SBC-3 says: |
2142 | * | ||
2143 | * A TRANSFER LENGTH field set to zero specifies that 256 | ||
2144 | * logical blocks shall be written. Any other value | ||
2145 | * specifies the number of logical blocks that shall be | ||
2146 | * written. | ||
2217 | */ | 2147 | */ |
2218 | type_disk: | 2148 | type_disk: |
2219 | return (u32)cdb[4]; | 2149 | return cdb[4] ? : 256; |
2220 | } | 2150 | } |
2221 | 2151 | ||
2222 | static inline u32 transport_get_sectors_10( | 2152 | static inline u32 transport_get_sectors_10( |
@@ -2460,27 +2390,6 @@ static int transport_get_sense_data(struct se_cmd *cmd) | |||
2460 | return -1; | 2390 | return -1; |
2461 | } | 2391 | } |
2462 | 2392 | ||
2463 | static int | ||
2464 | transport_handle_reservation_conflict(struct se_cmd *cmd) | ||
2465 | { | ||
2466 | cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; | ||
2467 | cmd->se_cmd_flags |= SCF_SCSI_RESERVATION_CONFLICT; | ||
2468 | cmd->scsi_status = SAM_STAT_RESERVATION_CONFLICT; | ||
2469 | /* | ||
2470 | * For UA Interlock Code 11b, a RESERVATION CONFLICT will | ||
2471 | * establish a UNIT ATTENTION with PREVIOUS RESERVATION | ||
2472 | * CONFLICT STATUS. | ||
2473 | * | ||
2474 | * See spc4r17, section 7.4.6 Control Mode Page, Table 349 | ||
2475 | */ | ||
2476 | if (cmd->se_sess && | ||
2477 | cmd->se_dev->se_sub_dev->se_dev_attrib.emulate_ua_intlck_ctrl == 2) | ||
2478 | core_scsi3_ua_allocate(cmd->se_sess->se_node_acl, | ||
2479 | cmd->orig_fe_lun, 0x2C, | ||
2480 | ASCQ_2CH_PREVIOUS_RESERVATION_CONFLICT_STATUS); | ||
2481 | return -EINVAL; | ||
2482 | } | ||
2483 | |||
2484 | static inline long long transport_dev_end_lba(struct se_device *dev) | 2393 | static inline long long transport_dev_end_lba(struct se_device *dev) |
2485 | { | 2394 | { |
2486 | return dev->transport->get_blocks(dev) + 1; | 2395 | return dev->transport->get_blocks(dev) + 1; |
@@ -2595,8 +2504,12 @@ static int transport_generic_cmd_sequencer( | |||
2595 | */ | 2504 | */ |
2596 | if (su_dev->t10_pr.pr_ops.t10_reservation_check(cmd, &pr_reg_type) != 0) { | 2505 | if (su_dev->t10_pr.pr_ops.t10_reservation_check(cmd, &pr_reg_type) != 0) { |
2597 | if (su_dev->t10_pr.pr_ops.t10_seq_non_holder( | 2506 | if (su_dev->t10_pr.pr_ops.t10_seq_non_holder( |
2598 | cmd, cdb, pr_reg_type) != 0) | 2507 | cmd, cdb, pr_reg_type) != 0) { |
2599 | return transport_handle_reservation_conflict(cmd); | 2508 | cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; |
2509 | cmd->se_cmd_flags |= SCF_SCSI_RESERVATION_CONFLICT; | ||
2510 | cmd->scsi_sense_reason = TCM_RESERVATION_CONFLICT; | ||
2511 | return -EBUSY; | ||
2512 | } | ||
2600 | /* | 2513 | /* |
2601 | * This means the CDB is allowed for the SCSI Initiator port | 2514 | * This means the CDB is allowed for the SCSI Initiator port |
2602 | * when said port is *NOT* holding the legacy SPC-2 or | 2515 | * when said port is *NOT* holding the legacy SPC-2 or |
@@ -2658,7 +2571,8 @@ static int transport_generic_cmd_sequencer( | |||
2658 | goto out_unsupported_cdb; | 2571 | goto out_unsupported_cdb; |
2659 | size = transport_get_size(sectors, cdb, cmd); | 2572 | size = transport_get_size(sectors, cdb, cmd); |
2660 | cmd->t_task_lba = transport_lba_32(cdb); | 2573 | cmd->t_task_lba = transport_lba_32(cdb); |
2661 | cmd->t_tasks_fua = (cdb[1] & 0x8); | 2574 | if (cdb[1] & 0x8) |
2575 | cmd->se_cmd_flags |= SCF_FUA; | ||
2662 | cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; | 2576 | cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; |
2663 | break; | 2577 | break; |
2664 | case WRITE_12: | 2578 | case WRITE_12: |
@@ -2667,7 +2581,8 @@ static int transport_generic_cmd_sequencer( | |||
2667 | goto out_unsupported_cdb; | 2581 | goto out_unsupported_cdb; |
2668 | size = transport_get_size(sectors, cdb, cmd); | 2582 | size = transport_get_size(sectors, cdb, cmd); |
2669 | cmd->t_task_lba = transport_lba_32(cdb); | 2583 | cmd->t_task_lba = transport_lba_32(cdb); |
2670 | cmd->t_tasks_fua = (cdb[1] & 0x8); | 2584 | if (cdb[1] & 0x8) |
2585 | cmd->se_cmd_flags |= SCF_FUA; | ||
2671 | cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; | 2586 | cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; |
2672 | break; | 2587 | break; |
2673 | case WRITE_16: | 2588 | case WRITE_16: |
@@ -2676,12 +2591,13 @@ static int transport_generic_cmd_sequencer( | |||
2676 | goto out_unsupported_cdb; | 2591 | goto out_unsupported_cdb; |
2677 | size = transport_get_size(sectors, cdb, cmd); | 2592 | size = transport_get_size(sectors, cdb, cmd); |
2678 | cmd->t_task_lba = transport_lba_64(cdb); | 2593 | cmd->t_task_lba = transport_lba_64(cdb); |
2679 | cmd->t_tasks_fua = (cdb[1] & 0x8); | 2594 | if (cdb[1] & 0x8) |
2595 | cmd->se_cmd_flags |= SCF_FUA; | ||
2680 | cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; | 2596 | cmd->se_cmd_flags |= SCF_SCSI_DATA_SG_IO_CDB; |
2681 | break; | 2597 | break; |
2682 | case XDWRITEREAD_10: | 2598 | case XDWRITEREAD_10: |
2683 | if ((cmd->data_direction != DMA_TO_DEVICE) || | 2599 | if ((cmd->data_direction != DMA_TO_DEVICE) || |
2684 | !(cmd->t_tasks_bidi)) | 2600 | !(cmd->se_cmd_flags & SCF_BIDI)) |
2685 | goto out_invalid_cdb_field; | 2601 | goto out_invalid_cdb_field; |
2686 | sectors = transport_get_sectors_10(cdb, cmd, §or_ret); | 2602 | sectors = transport_get_sectors_10(cdb, cmd, §or_ret); |
2687 | if (sector_ret) | 2603 | if (sector_ret) |
@@ -2700,7 +2616,8 @@ static int transport_generic_cmd_sequencer( | |||
2700 | * Setup BIDI XOR callback to be run after I/O completion. | 2616 | * Setup BIDI XOR callback to be run after I/O completion. |
2701 | */ | 2617 | */ |
2702 | cmd->transport_complete_callback = &transport_xor_callback; | 2618 | cmd->transport_complete_callback = &transport_xor_callback; |
2703 | cmd->t_tasks_fua = (cdb[1] & 0x8); | 2619 | if (cdb[1] & 0x8) |
2620 | cmd->se_cmd_flags |= SCF_FUA; | ||
2704 | break; | 2621 | break; |
2705 | case VARIABLE_LENGTH_CMD: | 2622 | case VARIABLE_LENGTH_CMD: |
2706 | service_action = get_unaligned_be16(&cdb[8]); | 2623 | service_action = get_unaligned_be16(&cdb[8]); |
@@ -2728,7 +2645,8 @@ static int transport_generic_cmd_sequencer( | |||
2728 | * completion. | 2645 | * completion. |
2729 | */ | 2646 | */ |
2730 | cmd->transport_complete_callback = &transport_xor_callback; | 2647 | cmd->transport_complete_callback = &transport_xor_callback; |
2731 | cmd->t_tasks_fua = (cdb[10] & 0x8); | 2648 | if (cdb[1] & 0x8) |
2649 | cmd->se_cmd_flags |= SCF_FUA; | ||
2732 | break; | 2650 | break; |
2733 | case WRITE_SAME_32: | 2651 | case WRITE_SAME_32: |
2734 | sectors = transport_get_sectors_32(cdb, cmd, §or_ret); | 2652 | sectors = transport_get_sectors_32(cdb, cmd, §or_ret); |
@@ -3171,18 +3089,13 @@ static void transport_complete_task_attr(struct se_cmd *cmd) | |||
3171 | " SIMPLE: %u\n", dev->dev_cur_ordered_id, | 3089 | " SIMPLE: %u\n", dev->dev_cur_ordered_id, |
3172 | cmd->se_ordered_id); | 3090 | cmd->se_ordered_id); |
3173 | } else if (cmd->sam_task_attr == MSG_HEAD_TAG) { | 3091 | } else if (cmd->sam_task_attr == MSG_HEAD_TAG) { |
3174 | atomic_dec(&dev->dev_hoq_count); | ||
3175 | smp_mb__after_atomic_dec(); | ||
3176 | dev->dev_cur_ordered_id++; | 3092 | dev->dev_cur_ordered_id++; |
3177 | pr_debug("Incremented dev_cur_ordered_id: %u for" | 3093 | pr_debug("Incremented dev_cur_ordered_id: %u for" |
3178 | " HEAD_OF_QUEUE: %u\n", dev->dev_cur_ordered_id, | 3094 | " HEAD_OF_QUEUE: %u\n", dev->dev_cur_ordered_id, |
3179 | cmd->se_ordered_id); | 3095 | cmd->se_ordered_id); |
3180 | } else if (cmd->sam_task_attr == MSG_ORDERED_TAG) { | 3096 | } else if (cmd->sam_task_attr == MSG_ORDERED_TAG) { |
3181 | spin_lock(&dev->ordered_cmd_lock); | ||
3182 | list_del(&cmd->se_ordered_node); | ||
3183 | atomic_dec(&dev->dev_ordered_sync); | 3097 | atomic_dec(&dev->dev_ordered_sync); |
3184 | smp_mb__after_atomic_dec(); | 3098 | smp_mb__after_atomic_dec(); |
3185 | spin_unlock(&dev->ordered_cmd_lock); | ||
3186 | 3099 | ||
3187 | dev->dev_cur_ordered_id++; | 3100 | dev->dev_cur_ordered_id++; |
3188 | pr_debug("Incremented dev_cur_ordered_id: %u for ORDERED:" | 3101 | pr_debug("Incremented dev_cur_ordered_id: %u for ORDERED:" |
@@ -3495,6 +3408,18 @@ int transport_generic_map_mem_to_cmd( | |||
3495 | 3408 | ||
3496 | if ((cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB) || | 3409 | if ((cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB) || |
3497 | (cmd->se_cmd_flags & SCF_SCSI_CONTROL_SG_IO_CDB)) { | 3410 | (cmd->se_cmd_flags & SCF_SCSI_CONTROL_SG_IO_CDB)) { |
3411 | /* | ||
3412 | * Reject SCSI data overflow with map_mem_to_cmd() as incoming | ||
3413 | * scatterlists already have been set to follow what the fabric | ||
3414 | * passes for the original expected data transfer length. | ||
3415 | */ | ||
3416 | if (cmd->se_cmd_flags & SCF_OVERFLOW_BIT) { | ||
3417 | pr_warn("Rejecting SCSI DATA overflow for fabric using" | ||
3418 | " SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC\n"); | ||
3419 | cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; | ||
3420 | cmd->scsi_sense_reason = TCM_INVALID_CDB_FIELD; | ||
3421 | return -EINVAL; | ||
3422 | } | ||
3498 | 3423 | ||
3499 | cmd->t_data_sg = sgl; | 3424 | cmd->t_data_sg = sgl; |
3500 | cmd->t_data_nents = sgl_count; | 3425 | cmd->t_data_nents = sgl_count; |
@@ -3813,7 +3738,7 @@ int transport_generic_new_cmd(struct se_cmd *cmd) | |||
3813 | cmd->data_length) { | 3738 | cmd->data_length) { |
3814 | ret = transport_generic_get_mem(cmd); | 3739 | ret = transport_generic_get_mem(cmd); |
3815 | if (ret < 0) | 3740 | if (ret < 0) |
3816 | return ret; | 3741 | goto out_fail; |
3817 | } | 3742 | } |
3818 | 3743 | ||
3819 | /* | 3744 | /* |
@@ -3842,8 +3767,15 @@ int transport_generic_new_cmd(struct se_cmd *cmd) | |||
3842 | task_cdbs = transport_allocate_control_task(cmd); | 3767 | task_cdbs = transport_allocate_control_task(cmd); |
3843 | } | 3768 | } |
3844 | 3769 | ||
3845 | if (task_cdbs <= 0) | 3770 | if (task_cdbs < 0) |
3846 | goto out_fail; | 3771 | goto out_fail; |
3772 | else if (!task_cdbs && (cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB)) { | ||
3773 | cmd->t_state = TRANSPORT_COMPLETE; | ||
3774 | atomic_set(&cmd->t_transport_active, 1); | ||
3775 | INIT_WORK(&cmd->work, target_complete_ok_work); | ||
3776 | queue_work(target_completion_wq, &cmd->work); | ||
3777 | return 0; | ||
3778 | } | ||
3847 | 3779 | ||
3848 | if (set_counts) { | 3780 | if (set_counts) { |
3849 | atomic_inc(&cmd->t_fe_count); | 3781 | atomic_inc(&cmd->t_fe_count); |
@@ -3929,7 +3861,7 @@ static int transport_generic_write_pending(struct se_cmd *cmd) | |||
3929 | else if (ret < 0) | 3861 | else if (ret < 0) |
3930 | return ret; | 3862 | return ret; |
3931 | 3863 | ||
3932 | return PYX_TRANSPORT_WRITE_PENDING; | 3864 | return 1; |
3933 | 3865 | ||
3934 | queue_full: | 3866 | queue_full: |
3935 | pr_debug("Handling write_pending QUEUE__FULL: se_cmd: %p\n", cmd); | 3867 | pr_debug("Handling write_pending QUEUE__FULL: se_cmd: %p\n", cmd); |
@@ -4602,9 +4534,6 @@ void transport_send_task_abort(struct se_cmd *cmd) | |||
4602 | if (cmd->se_tfo->write_pending_status(cmd) != 0) { | 4534 | if (cmd->se_tfo->write_pending_status(cmd) != 0) { |
4603 | atomic_inc(&cmd->t_transport_aborted); | 4535 | atomic_inc(&cmd->t_transport_aborted); |
4604 | smp_mb__after_atomic_inc(); | 4536 | smp_mb__after_atomic_inc(); |
4605 | cmd->scsi_status = SAM_STAT_TASK_ABORTED; | ||
4606 | transport_new_cmd_failure(cmd); | ||
4607 | return; | ||
4608 | } | 4537 | } |
4609 | } | 4538 | } |
4610 | cmd->scsi_status = SAM_STAT_TASK_ABORTED; | 4539 | cmd->scsi_status = SAM_STAT_TASK_ABORTED; |
@@ -4670,8 +4599,6 @@ static int transport_processing_thread(void *param) | |||
4670 | struct se_cmd *cmd; | 4599 | struct se_cmd *cmd; |
4671 | struct se_device *dev = (struct se_device *) param; | 4600 | struct se_device *dev = (struct se_device *) param; |
4672 | 4601 | ||
4673 | set_user_nice(current, -20); | ||
4674 | |||
4675 | while (!kthread_should_stop()) { | 4602 | while (!kthread_should_stop()) { |
4676 | ret = wait_event_interruptible(dev->dev_queue_obj.thread_wq, | 4603 | ret = wait_event_interruptible(dev->dev_queue_obj.thread_wq, |
4677 | atomic_read(&dev->dev_queue_obj.queue_cnt) || | 4604 | atomic_read(&dev->dev_queue_obj.queue_cnt) || |
@@ -4698,18 +4625,13 @@ get_cmd: | |||
4698 | } | 4625 | } |
4699 | ret = cmd->se_tfo->new_cmd_map(cmd); | 4626 | ret = cmd->se_tfo->new_cmd_map(cmd); |
4700 | if (ret < 0) { | 4627 | if (ret < 0) { |
4701 | cmd->transport_error_status = ret; | 4628 | transport_generic_request_failure(cmd); |
4702 | transport_generic_request_failure(cmd, | ||
4703 | 0, (cmd->data_direction != | ||
4704 | DMA_TO_DEVICE)); | ||
4705 | break; | 4629 | break; |
4706 | } | 4630 | } |
4707 | ret = transport_generic_new_cmd(cmd); | 4631 | ret = transport_generic_new_cmd(cmd); |
4708 | if (ret < 0) { | 4632 | if (ret < 0) { |
4709 | cmd->transport_error_status = ret; | 4633 | transport_generic_request_failure(cmd); |
4710 | transport_generic_request_failure(cmd, | 4634 | break; |
4711 | 0, (cmd->data_direction != | ||
4712 | DMA_TO_DEVICE)); | ||
4713 | } | 4635 | } |
4714 | break; | 4636 | break; |
4715 | case TRANSPORT_PROCESS_WRITE: | 4637 | case TRANSPORT_PROCESS_WRITE: |
diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c index 4fac37c4c615..71fc9cea5dc9 100644 --- a/drivers/target/tcm_fc/tfc_cmd.c +++ b/drivers/target/tcm_fc/tfc_cmd.c | |||
@@ -200,7 +200,7 @@ int ft_write_pending(struct se_cmd *se_cmd) | |||
200 | lport = ep->lp; | 200 | lport = ep->lp; |
201 | fp = fc_frame_alloc(lport, sizeof(*txrdy)); | 201 | fp = fc_frame_alloc(lport, sizeof(*txrdy)); |
202 | if (!fp) | 202 | if (!fp) |
203 | return PYX_TRANSPORT_OUT_OF_MEMORY_RESOURCES; | 203 | return -ENOMEM; /* Signal QUEUE_FULL */ |
204 | 204 | ||
205 | txrdy = fc_frame_payload_get(fp, sizeof(*txrdy)); | 205 | txrdy = fc_frame_payload_get(fp, sizeof(*txrdy)); |
206 | memset(txrdy, 0, sizeof(*txrdy)); | 206 | memset(txrdy, 0, sizeof(*txrdy)); |
diff --git a/drivers/target/tcm_fc/tfc_conf.c b/drivers/target/tcm_fc/tfc_conf.c index 5f770412ca40..9402b7387cac 100644 --- a/drivers/target/tcm_fc/tfc_conf.c +++ b/drivers/target/tcm_fc/tfc_conf.c | |||
@@ -436,8 +436,7 @@ static void ft_del_lport(struct se_wwn *wwn) | |||
436 | struct ft_lport_acl *lacl = container_of(wwn, | 436 | struct ft_lport_acl *lacl = container_of(wwn, |
437 | struct ft_lport_acl, fc_lport_wwn); | 437 | struct ft_lport_acl, fc_lport_wwn); |
438 | 438 | ||
439 | pr_debug("del lport %s\n", | 439 | pr_debug("del lport %s\n", lacl->name); |
440 | config_item_name(&wwn->wwn_group.cg_item)); | ||
441 | mutex_lock(&ft_lport_lock); | 440 | mutex_lock(&ft_lport_lock); |
442 | list_del(&lacl->list); | 441 | list_del(&lacl->list); |
443 | mutex_unlock(&ft_lport_lock); | 442 | mutex_unlock(&ft_lport_lock); |