diff options
author | Jiri Kosina <jkosina@suse.cz> | 2012-10-28 14:28:52 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2012-10-28 14:29:19 -0400 |
commit | 3bd7bf1f0fe14f591c089ae61bbfa9bd356f178a (patch) | |
tree | 0058693cc9e70b7461dae551f8a19aff2efd13ca /drivers/target | |
parent | f16f84937d769c893492160b1a8c3672e3992beb (diff) | |
parent | e657e078d3dfa9f96976db7a2b5fd7d7c9f1f1a6 (diff) |
Merge branch 'master' into for-next
Sync up with Linus' tree to be able to apply Cesar's patch
against newer version of the code.
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/target')
41 files changed, 613 insertions, 614 deletions
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 97c0f78c3c9c..d6ce2182e672 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c | |||
@@ -427,7 +427,7 @@ int iscsit_reset_np_thread( | |||
427 | return 0; | 427 | return 0; |
428 | } | 428 | } |
429 | 429 | ||
430 | int iscsit_del_np_comm(struct iscsi_np *np) | 430 | static int iscsit_del_np_comm(struct iscsi_np *np) |
431 | { | 431 | { |
432 | if (np->np_socket) | 432 | if (np->np_socket) |
433 | sock_release(np->np_socket); | 433 | sock_release(np->np_socket); |
@@ -785,10 +785,6 @@ static int iscsit_handle_scsi_cmd( | |||
785 | 785 | ||
786 | hdr = (struct iscsi_scsi_req *) buf; | 786 | hdr = (struct iscsi_scsi_req *) buf; |
787 | payload_length = ntoh24(hdr->dlength); | 787 | payload_length = ntoh24(hdr->dlength); |
788 | hdr->itt = be32_to_cpu(hdr->itt); | ||
789 | hdr->data_length = be32_to_cpu(hdr->data_length); | ||
790 | hdr->cmdsn = be32_to_cpu(hdr->cmdsn); | ||
791 | hdr->exp_statsn = be32_to_cpu(hdr->exp_statsn); | ||
792 | 788 | ||
793 | /* FIXME; Add checks for AdditionalHeaderSegment */ | 789 | /* FIXME; Add checks for AdditionalHeaderSegment */ |
794 | 790 | ||
@@ -852,7 +848,7 @@ done: | |||
852 | buf, conn); | 848 | buf, conn); |
853 | } | 849 | } |
854 | 850 | ||
855 | if ((hdr->data_length == payload_length) && | 851 | if ((be32_to_cpu(hdr->data_length )== payload_length) && |
856 | (!(hdr->flags & ISCSI_FLAG_CMD_FINAL))) { | 852 | (!(hdr->flags & ISCSI_FLAG_CMD_FINAL))) { |
857 | pr_err("Expected Data Transfer Length and Length of" | 853 | pr_err("Expected Data Transfer Length and Length of" |
858 | " Immediate Data are the same, but ISCSI_FLAG_CMD_FINAL" | 854 | " Immediate Data are the same, but ISCSI_FLAG_CMD_FINAL" |
@@ -861,7 +857,7 @@ done: | |||
861 | buf, conn); | 857 | buf, conn); |
862 | } | 858 | } |
863 | 859 | ||
864 | if (payload_length > hdr->data_length) { | 860 | if (payload_length > be32_to_cpu(hdr->data_length)) { |
865 | pr_err("DataSegmentLength: %u is greater than" | 861 | pr_err("DataSegmentLength: %u is greater than" |
866 | " EDTL: %u, protocol error.\n", payload_length, | 862 | " EDTL: %u, protocol error.\n", payload_length, |
867 | hdr->data_length); | 863 | hdr->data_length); |
@@ -869,10 +865,10 @@ done: | |||
869 | buf, conn); | 865 | buf, conn); |
870 | } | 866 | } |
871 | 867 | ||
872 | if (payload_length > conn->conn_ops->MaxRecvDataSegmentLength) { | 868 | if (payload_length > conn->conn_ops->MaxXmitDataSegmentLength) { |
873 | pr_err("DataSegmentLength: %u is greater than" | 869 | pr_err("DataSegmentLength: %u is greater than" |
874 | " MaxRecvDataSegmentLength: %u, protocol error.\n", | 870 | " MaxXmitDataSegmentLength: %u, protocol error.\n", |
875 | payload_length, conn->conn_ops->MaxRecvDataSegmentLength); | 871 | payload_length, conn->conn_ops->MaxXmitDataSegmentLength); |
876 | return iscsit_add_reject(ISCSI_REASON_PROTOCOL_ERROR, 1, | 872 | return iscsit_add_reject(ISCSI_REASON_PROTOCOL_ERROR, 1, |
877 | buf, conn); | 873 | buf, conn); |
878 | } | 874 | } |
@@ -932,8 +928,8 @@ done: | |||
932 | spin_unlock_bh(&conn->sess->ttt_lock); | 928 | spin_unlock_bh(&conn->sess->ttt_lock); |
933 | } else if (hdr->flags & ISCSI_FLAG_CMD_WRITE) | 929 | } else if (hdr->flags & ISCSI_FLAG_CMD_WRITE) |
934 | cmd->targ_xfer_tag = 0xFFFFFFFF; | 930 | cmd->targ_xfer_tag = 0xFFFFFFFF; |
935 | cmd->cmd_sn = hdr->cmdsn; | 931 | cmd->cmd_sn = be32_to_cpu(hdr->cmdsn); |
936 | cmd->exp_stat_sn = hdr->exp_statsn; | 932 | cmd->exp_stat_sn = be32_to_cpu(hdr->exp_statsn); |
937 | cmd->first_burst_len = payload_length; | 933 | cmd->first_burst_len = payload_length; |
938 | 934 | ||
939 | if (cmd->data_direction == DMA_FROM_DEVICE) { | 935 | if (cmd->data_direction == DMA_FROM_DEVICE) { |
@@ -952,8 +948,9 @@ done: | |||
952 | * Initialize struct se_cmd descriptor from target_core_mod infrastructure | 948 | * Initialize struct se_cmd descriptor from target_core_mod infrastructure |
953 | */ | 949 | */ |
954 | transport_init_se_cmd(&cmd->se_cmd, &lio_target_fabric_configfs->tf_ops, | 950 | transport_init_se_cmd(&cmd->se_cmd, &lio_target_fabric_configfs->tf_ops, |
955 | conn->sess->se_sess, hdr->data_length, cmd->data_direction, | 951 | conn->sess->se_sess, be32_to_cpu(hdr->data_length), |
956 | sam_task_attr, &cmd->sense_buffer[0]); | 952 | cmd->data_direction, sam_task_attr, |
953 | cmd->sense_buffer + 2); | ||
957 | 954 | ||
958 | pr_debug("Got SCSI Command, ITT: 0x%08x, CmdSN: 0x%08x," | 955 | pr_debug("Got SCSI Command, ITT: 0x%08x, CmdSN: 0x%08x," |
959 | " ExpXferLen: %u, Length: %u, CID: %hu\n", hdr->itt, | 956 | " ExpXferLen: %u, Length: %u, CID: %hu\n", hdr->itt, |
@@ -1028,7 +1025,7 @@ attach_cmd: | |||
1028 | 1, 0, buf, cmd); | 1025 | 1, 0, buf, cmd); |
1029 | } | 1026 | } |
1030 | 1027 | ||
1031 | iscsit_ack_from_expstatsn(conn, hdr->exp_statsn); | 1028 | iscsit_ack_from_expstatsn(conn, be32_to_cpu(hdr->exp_statsn)); |
1032 | 1029 | ||
1033 | /* | 1030 | /* |
1034 | * If no Immediate Data is attached, it's OK to return now. | 1031 | * If no Immediate Data is attached, it's OK to return now. |
@@ -1194,11 +1191,6 @@ static int iscsit_handle_data_out(struct iscsi_conn *conn, unsigned char *buf) | |||
1194 | 1191 | ||
1195 | hdr = (struct iscsi_data *) buf; | 1192 | hdr = (struct iscsi_data *) buf; |
1196 | payload_length = ntoh24(hdr->dlength); | 1193 | payload_length = ntoh24(hdr->dlength); |
1197 | hdr->itt = be32_to_cpu(hdr->itt); | ||
1198 | hdr->ttt = be32_to_cpu(hdr->ttt); | ||
1199 | hdr->exp_statsn = be32_to_cpu(hdr->exp_statsn); | ||
1200 | hdr->datasn = be32_to_cpu(hdr->datasn); | ||
1201 | hdr->offset = be32_to_cpu(hdr->offset); | ||
1202 | 1194 | ||
1203 | if (!payload_length) { | 1195 | if (!payload_length) { |
1204 | pr_err("DataOUT payload is ZERO, protocol error.\n"); | 1196 | pr_err("DataOUT payload is ZERO, protocol error.\n"); |
@@ -1216,10 +1208,10 @@ static int iscsit_handle_data_out(struct iscsi_conn *conn, unsigned char *buf) | |||
1216 | } | 1208 | } |
1217 | spin_unlock_bh(&conn->sess->session_stats_lock); | 1209 | spin_unlock_bh(&conn->sess->session_stats_lock); |
1218 | 1210 | ||
1219 | if (payload_length > conn->conn_ops->MaxRecvDataSegmentLength) { | 1211 | if (payload_length > conn->conn_ops->MaxXmitDataSegmentLength) { |
1220 | pr_err("DataSegmentLength: %u is greater than" | 1212 | pr_err("DataSegmentLength: %u is greater than" |
1221 | " MaxRecvDataSegmentLength: %u\n", payload_length, | 1213 | " MaxXmitDataSegmentLength: %u\n", payload_length, |
1222 | conn->conn_ops->MaxRecvDataSegmentLength); | 1214 | conn->conn_ops->MaxXmitDataSegmentLength); |
1223 | return iscsit_add_reject(ISCSI_REASON_PROTOCOL_ERROR, 1, | 1215 | return iscsit_add_reject(ISCSI_REASON_PROTOCOL_ERROR, 1, |
1224 | buf, conn); | 1216 | buf, conn); |
1225 | } | 1217 | } |
@@ -1250,7 +1242,7 @@ static int iscsit_handle_data_out(struct iscsi_conn *conn, unsigned char *buf) | |||
1250 | se_cmd = &cmd->se_cmd; | 1242 | se_cmd = &cmd->se_cmd; |
1251 | iscsit_mod_dataout_timer(cmd); | 1243 | iscsit_mod_dataout_timer(cmd); |
1252 | 1244 | ||
1253 | if ((hdr->offset + payload_length) > cmd->se_cmd.data_length) { | 1245 | if ((be32_to_cpu(hdr->offset) + payload_length) > cmd->se_cmd.data_length) { |
1254 | pr_err("DataOut Offset: %u, Length %u greater than" | 1246 | pr_err("DataOut Offset: %u, Length %u greater than" |
1255 | " iSCSI Command EDTL %u, protocol error.\n", | 1247 | " iSCSI Command EDTL %u, protocol error.\n", |
1256 | hdr->offset, payload_length, cmd->se_cmd.data_length); | 1248 | hdr->offset, payload_length, cmd->se_cmd.data_length); |
@@ -1333,7 +1325,8 @@ static int iscsit_handle_data_out(struct iscsi_conn *conn, unsigned char *buf) | |||
1333 | rx_size += payload_length; | 1325 | rx_size += payload_length; |
1334 | iov = &cmd->iov_data[0]; | 1326 | iov = &cmd->iov_data[0]; |
1335 | 1327 | ||
1336 | iov_ret = iscsit_map_iovec(cmd, iov, hdr->offset, payload_length); | 1328 | iov_ret = iscsit_map_iovec(cmd, iov, be32_to_cpu(hdr->offset), |
1329 | payload_length); | ||
1337 | if (iov_ret < 0) | 1330 | if (iov_ret < 0) |
1338 | return -1; | 1331 | return -1; |
1339 | 1332 | ||
@@ -1364,7 +1357,8 @@ static int iscsit_handle_data_out(struct iscsi_conn *conn, unsigned char *buf) | |||
1364 | u32 data_crc; | 1357 | u32 data_crc; |
1365 | 1358 | ||
1366 | data_crc = iscsit_do_crypto_hash_sg(&conn->conn_rx_hash, cmd, | 1359 | data_crc = iscsit_do_crypto_hash_sg(&conn->conn_rx_hash, cmd, |
1367 | hdr->offset, payload_length, padding, | 1360 | be32_to_cpu(hdr->offset), |
1361 | payload_length, padding, | ||
1368 | cmd->pad_bytes); | 1362 | cmd->pad_bytes); |
1369 | 1363 | ||
1370 | if (checksum != data_crc) { | 1364 | if (checksum != data_crc) { |
@@ -1425,30 +1419,26 @@ static int iscsit_handle_nop_out( | |||
1425 | 1419 | ||
1426 | hdr = (struct iscsi_nopout *) buf; | 1420 | hdr = (struct iscsi_nopout *) buf; |
1427 | payload_length = ntoh24(hdr->dlength); | 1421 | payload_length = ntoh24(hdr->dlength); |
1428 | hdr->itt = be32_to_cpu(hdr->itt); | ||
1429 | hdr->ttt = be32_to_cpu(hdr->ttt); | ||
1430 | hdr->cmdsn = be32_to_cpu(hdr->cmdsn); | ||
1431 | hdr->exp_statsn = be32_to_cpu(hdr->exp_statsn); | ||
1432 | 1422 | ||
1433 | if ((hdr->itt == 0xFFFFFFFF) && !(hdr->opcode & ISCSI_OP_IMMEDIATE)) { | 1423 | if (hdr->itt == RESERVED_ITT && !(hdr->opcode & ISCSI_OP_IMMEDIATE)) { |
1434 | pr_err("NOPOUT ITT is reserved, but Immediate Bit is" | 1424 | pr_err("NOPOUT ITT is reserved, but Immediate Bit is" |
1435 | " not set, protocol error.\n"); | 1425 | " not set, protocol error.\n"); |
1436 | return iscsit_add_reject(ISCSI_REASON_PROTOCOL_ERROR, 1, | 1426 | return iscsit_add_reject(ISCSI_REASON_PROTOCOL_ERROR, 1, |
1437 | buf, conn); | 1427 | buf, conn); |
1438 | } | 1428 | } |
1439 | 1429 | ||
1440 | if (payload_length > conn->conn_ops->MaxRecvDataSegmentLength) { | 1430 | if (payload_length > conn->conn_ops->MaxXmitDataSegmentLength) { |
1441 | pr_err("NOPOUT Ping Data DataSegmentLength: %u is" | 1431 | pr_err("NOPOUT Ping Data DataSegmentLength: %u is" |
1442 | " greater than MaxRecvDataSegmentLength: %u, protocol" | 1432 | " greater than MaxXmitDataSegmentLength: %u, protocol" |
1443 | " error.\n", payload_length, | 1433 | " error.\n", payload_length, |
1444 | conn->conn_ops->MaxRecvDataSegmentLength); | 1434 | conn->conn_ops->MaxXmitDataSegmentLength); |
1445 | return iscsit_add_reject(ISCSI_REASON_PROTOCOL_ERROR, 1, | 1435 | return iscsit_add_reject(ISCSI_REASON_PROTOCOL_ERROR, 1, |
1446 | buf, conn); | 1436 | buf, conn); |
1447 | } | 1437 | } |
1448 | 1438 | ||
1449 | pr_debug("Got NOPOUT Ping %s ITT: 0x%08x, TTT: 0x%09x," | 1439 | pr_debug("Got NOPOUT Ping %s ITT: 0x%08x, TTT: 0x%09x," |
1450 | " CmdSN: 0x%08x, ExpStatSN: 0x%08x, Length: %u\n", | 1440 | " CmdSN: 0x%08x, ExpStatSN: 0x%08x, Length: %u\n", |
1451 | (hdr->itt == 0xFFFFFFFF) ? "Response" : "Request", | 1441 | hdr->itt == RESERVED_ITT ? "Response" : "Request", |
1452 | hdr->itt, hdr->ttt, hdr->cmdsn, hdr->exp_statsn, | 1442 | hdr->itt, hdr->ttt, hdr->cmdsn, hdr->exp_statsn, |
1453 | payload_length); | 1443 | payload_length); |
1454 | /* | 1444 | /* |
@@ -1458,7 +1448,7 @@ static int iscsit_handle_nop_out( | |||
1458 | * Either way, make sure we allocate an struct iscsi_cmd, as both | 1448 | * Either way, make sure we allocate an struct iscsi_cmd, as both |
1459 | * can contain ping data. | 1449 | * can contain ping data. |
1460 | */ | 1450 | */ |
1461 | if (hdr->ttt == 0xFFFFFFFF) { | 1451 | if (hdr->ttt == cpu_to_be32(0xFFFFFFFF)) { |
1462 | cmd = iscsit_allocate_cmd(conn, GFP_KERNEL); | 1452 | cmd = iscsit_allocate_cmd(conn, GFP_KERNEL); |
1463 | if (!cmd) | 1453 | if (!cmd) |
1464 | return iscsit_add_reject( | 1454 | return iscsit_add_reject( |
@@ -1471,12 +1461,12 @@ static int iscsit_handle_nop_out( | |||
1471 | 1 : 0); | 1461 | 1 : 0); |
1472 | conn->sess->init_task_tag = cmd->init_task_tag = hdr->itt; | 1462 | conn->sess->init_task_tag = cmd->init_task_tag = hdr->itt; |
1473 | cmd->targ_xfer_tag = 0xFFFFFFFF; | 1463 | cmd->targ_xfer_tag = 0xFFFFFFFF; |
1474 | cmd->cmd_sn = hdr->cmdsn; | 1464 | cmd->cmd_sn = be32_to_cpu(hdr->cmdsn); |
1475 | cmd->exp_stat_sn = hdr->exp_statsn; | 1465 | cmd->exp_stat_sn = be32_to_cpu(hdr->exp_statsn); |
1476 | cmd->data_direction = DMA_NONE; | 1466 | cmd->data_direction = DMA_NONE; |
1477 | } | 1467 | } |
1478 | 1468 | ||
1479 | if (payload_length && (hdr->ttt == 0xFFFFFFFF)) { | 1469 | if (payload_length && hdr->ttt == cpu_to_be32(0xFFFFFFFF)) { |
1480 | rx_size = payload_length; | 1470 | rx_size = payload_length; |
1481 | ping_data = kzalloc(payload_length + 1, GFP_KERNEL); | 1471 | ping_data = kzalloc(payload_length + 1, GFP_KERNEL); |
1482 | if (!ping_data) { | 1472 | if (!ping_data) { |
@@ -1556,7 +1546,7 @@ static int iscsit_handle_nop_out( | |||
1556 | pr_debug("Ping Data: \"%s\"\n", ping_data); | 1546 | pr_debug("Ping Data: \"%s\"\n", ping_data); |
1557 | } | 1547 | } |
1558 | 1548 | ||
1559 | if (hdr->itt != 0xFFFFFFFF) { | 1549 | if (hdr->itt != RESERVED_ITT) { |
1560 | if (!cmd) { | 1550 | if (!cmd) { |
1561 | pr_err("Checking CmdSN for NOPOUT," | 1551 | pr_err("Checking CmdSN for NOPOUT," |
1562 | " but cmd is NULL!\n"); | 1552 | " but cmd is NULL!\n"); |
@@ -1569,7 +1559,7 @@ static int iscsit_handle_nop_out( | |||
1569 | list_add_tail(&cmd->i_conn_node, &conn->conn_cmd_list); | 1559 | list_add_tail(&cmd->i_conn_node, &conn->conn_cmd_list); |
1570 | spin_unlock_bh(&conn->cmd_lock); | 1560 | spin_unlock_bh(&conn->cmd_lock); |
1571 | 1561 | ||
1572 | iscsit_ack_from_expstatsn(conn, hdr->exp_statsn); | 1562 | iscsit_ack_from_expstatsn(conn, be32_to_cpu(hdr->exp_statsn)); |
1573 | 1563 | ||
1574 | if (hdr->opcode & ISCSI_OP_IMMEDIATE) { | 1564 | if (hdr->opcode & ISCSI_OP_IMMEDIATE) { |
1575 | iscsit_add_cmd_to_response_queue(cmd, conn, | 1565 | iscsit_add_cmd_to_response_queue(cmd, conn, |
@@ -1590,11 +1580,11 @@ static int iscsit_handle_nop_out( | |||
1590 | return 0; | 1580 | return 0; |
1591 | } | 1581 | } |
1592 | 1582 | ||
1593 | if (hdr->ttt != 0xFFFFFFFF) { | 1583 | if (hdr->ttt != cpu_to_be32(0xFFFFFFFF)) { |
1594 | /* | 1584 | /* |
1595 | * This was a response to a unsolicited NOPIN ping. | 1585 | * This was a response to a unsolicited NOPIN ping. |
1596 | */ | 1586 | */ |
1597 | cmd = iscsit_find_cmd_from_ttt(conn, hdr->ttt); | 1587 | cmd = iscsit_find_cmd_from_ttt(conn, be32_to_cpu(hdr->ttt)); |
1598 | if (!cmd) | 1588 | if (!cmd) |
1599 | return -1; | 1589 | return -1; |
1600 | 1590 | ||
@@ -1639,12 +1629,6 @@ static int iscsit_handle_task_mgt_cmd( | |||
1639 | u8 function; | 1629 | u8 function; |
1640 | 1630 | ||
1641 | hdr = (struct iscsi_tm *) buf; | 1631 | hdr = (struct iscsi_tm *) buf; |
1642 | hdr->itt = be32_to_cpu(hdr->itt); | ||
1643 | hdr->rtt = be32_to_cpu(hdr->rtt); | ||
1644 | hdr->cmdsn = be32_to_cpu(hdr->cmdsn); | ||
1645 | hdr->exp_statsn = be32_to_cpu(hdr->exp_statsn); | ||
1646 | hdr->refcmdsn = be32_to_cpu(hdr->refcmdsn); | ||
1647 | hdr->exp_datasn = be32_to_cpu(hdr->exp_datasn); | ||
1648 | hdr->flags &= ~ISCSI_FLAG_CMD_FINAL; | 1632 | hdr->flags &= ~ISCSI_FLAG_CMD_FINAL; |
1649 | function = hdr->flags; | 1633 | function = hdr->flags; |
1650 | 1634 | ||
@@ -1655,9 +1639,9 @@ static int iscsit_handle_task_mgt_cmd( | |||
1655 | 1639 | ||
1656 | if ((function != ISCSI_TM_FUNC_ABORT_TASK) && | 1640 | if ((function != ISCSI_TM_FUNC_ABORT_TASK) && |
1657 | ((function != ISCSI_TM_FUNC_TASK_REASSIGN) && | 1641 | ((function != ISCSI_TM_FUNC_TASK_REASSIGN) && |
1658 | (hdr->rtt != ISCSI_RESERVED_TAG))) { | 1642 | hdr->rtt != RESERVED_ITT)) { |
1659 | pr_err("RefTaskTag should be set to 0xFFFFFFFF.\n"); | 1643 | pr_err("RefTaskTag should be set to 0xFFFFFFFF.\n"); |
1660 | hdr->rtt = ISCSI_RESERVED_TAG; | 1644 | hdr->rtt = RESERVED_ITT; |
1661 | } | 1645 | } |
1662 | 1646 | ||
1663 | if ((function == ISCSI_TM_FUNC_TASK_REASSIGN) && | 1647 | if ((function == ISCSI_TM_FUNC_TASK_REASSIGN) && |
@@ -1669,8 +1653,8 @@ static int iscsit_handle_task_mgt_cmd( | |||
1669 | buf, conn); | 1653 | buf, conn); |
1670 | } | 1654 | } |
1671 | if ((function != ISCSI_TM_FUNC_ABORT_TASK) && | 1655 | if ((function != ISCSI_TM_FUNC_ABORT_TASK) && |
1672 | (hdr->refcmdsn != ISCSI_RESERVED_TAG)) | 1656 | be32_to_cpu(hdr->refcmdsn) != ISCSI_RESERVED_TAG) |
1673 | hdr->refcmdsn = ISCSI_RESERVED_TAG; | 1657 | hdr->refcmdsn = cpu_to_be32(ISCSI_RESERVED_TAG); |
1674 | 1658 | ||
1675 | cmd = iscsit_allocate_cmd(conn, GFP_KERNEL); | 1659 | cmd = iscsit_allocate_cmd(conn, GFP_KERNEL); |
1676 | if (!cmd) | 1660 | if (!cmd) |
@@ -1700,7 +1684,7 @@ static int iscsit_handle_task_mgt_cmd( | |||
1700 | transport_init_se_cmd(&cmd->se_cmd, | 1684 | transport_init_se_cmd(&cmd->se_cmd, |
1701 | &lio_target_fabric_configfs->tf_ops, | 1685 | &lio_target_fabric_configfs->tf_ops, |
1702 | conn->sess->se_sess, 0, DMA_NONE, | 1686 | conn->sess->se_sess, 0, DMA_NONE, |
1703 | MSG_SIMPLE_TAG, &cmd->sense_buffer[0]); | 1687 | MSG_SIMPLE_TAG, cmd->sense_buffer + 2); |
1704 | 1688 | ||
1705 | switch (function) { | 1689 | switch (function) { |
1706 | case ISCSI_TM_FUNC_ABORT_TASK: | 1690 | case ISCSI_TM_FUNC_ABORT_TASK: |
@@ -1747,8 +1731,8 @@ static int iscsit_handle_task_mgt_cmd( | |||
1747 | cmd->immediate_cmd = ((hdr->opcode & ISCSI_OP_IMMEDIATE) ? 1 : 0); | 1731 | cmd->immediate_cmd = ((hdr->opcode & ISCSI_OP_IMMEDIATE) ? 1 : 0); |
1748 | cmd->init_task_tag = hdr->itt; | 1732 | cmd->init_task_tag = hdr->itt; |
1749 | cmd->targ_xfer_tag = 0xFFFFFFFF; | 1733 | cmd->targ_xfer_tag = 0xFFFFFFFF; |
1750 | cmd->cmd_sn = hdr->cmdsn; | 1734 | cmd->cmd_sn = be32_to_cpu(hdr->cmdsn); |
1751 | cmd->exp_stat_sn = hdr->exp_statsn; | 1735 | cmd->exp_stat_sn = be32_to_cpu(hdr->exp_statsn); |
1752 | se_tmr = cmd->se_cmd.se_tmr_req; | 1736 | se_tmr = cmd->se_cmd.se_tmr_req; |
1753 | tmr_req = cmd->tmr_req; | 1737 | tmr_req = cmd->tmr_req; |
1754 | /* | 1738 | /* |
@@ -1832,7 +1816,7 @@ attach: | |||
1832 | ISCSI_REASON_PROTOCOL_ERROR, | 1816 | ISCSI_REASON_PROTOCOL_ERROR, |
1833 | 1, 0, buf, cmd); | 1817 | 1, 0, buf, cmd); |
1834 | } | 1818 | } |
1835 | iscsit_ack_from_expstatsn(conn, hdr->exp_statsn); | 1819 | iscsit_ack_from_expstatsn(conn, be32_to_cpu(hdr->exp_statsn)); |
1836 | 1820 | ||
1837 | if (out_of_order_cmdsn || !(hdr->opcode & ISCSI_OP_IMMEDIATE)) | 1821 | if (out_of_order_cmdsn || !(hdr->opcode & ISCSI_OP_IMMEDIATE)) |
1838 | return 0; | 1822 | return 0; |
@@ -1869,15 +1853,11 @@ static int iscsit_handle_text_cmd( | |||
1869 | 1853 | ||
1870 | hdr = (struct iscsi_text *) buf; | 1854 | hdr = (struct iscsi_text *) buf; |
1871 | payload_length = ntoh24(hdr->dlength); | 1855 | payload_length = ntoh24(hdr->dlength); |
1872 | hdr->itt = be32_to_cpu(hdr->itt); | ||
1873 | hdr->ttt = be32_to_cpu(hdr->ttt); | ||
1874 | hdr->cmdsn = be32_to_cpu(hdr->cmdsn); | ||
1875 | hdr->exp_statsn = be32_to_cpu(hdr->exp_statsn); | ||
1876 | 1856 | ||
1877 | if (payload_length > conn->conn_ops->MaxRecvDataSegmentLength) { | 1857 | if (payload_length > conn->conn_ops->MaxXmitDataSegmentLength) { |
1878 | pr_err("Unable to accept text parameter length: %u" | 1858 | pr_err("Unable to accept text parameter length: %u" |
1879 | "greater than MaxRecvDataSegmentLength %u.\n", | 1859 | "greater than MaxXmitDataSegmentLength %u.\n", |
1880 | payload_length, conn->conn_ops->MaxRecvDataSegmentLength); | 1860 | payload_length, conn->conn_ops->MaxXmitDataSegmentLength); |
1881 | return iscsit_add_reject(ISCSI_REASON_PROTOCOL_ERROR, 1, | 1861 | return iscsit_add_reject(ISCSI_REASON_PROTOCOL_ERROR, 1, |
1882 | buf, conn); | 1862 | buf, conn); |
1883 | } | 1863 | } |
@@ -1989,15 +1969,15 @@ static int iscsit_handle_text_cmd( | |||
1989 | cmd->immediate_cmd = ((hdr->opcode & ISCSI_OP_IMMEDIATE) ? 1 : 0); | 1969 | cmd->immediate_cmd = ((hdr->opcode & ISCSI_OP_IMMEDIATE) ? 1 : 0); |
1990 | conn->sess->init_task_tag = cmd->init_task_tag = hdr->itt; | 1970 | conn->sess->init_task_tag = cmd->init_task_tag = hdr->itt; |
1991 | cmd->targ_xfer_tag = 0xFFFFFFFF; | 1971 | cmd->targ_xfer_tag = 0xFFFFFFFF; |
1992 | cmd->cmd_sn = hdr->cmdsn; | 1972 | cmd->cmd_sn = be32_to_cpu(hdr->cmdsn); |
1993 | cmd->exp_stat_sn = hdr->exp_statsn; | 1973 | cmd->exp_stat_sn = be32_to_cpu(hdr->exp_statsn); |
1994 | cmd->data_direction = DMA_NONE; | 1974 | cmd->data_direction = DMA_NONE; |
1995 | 1975 | ||
1996 | spin_lock_bh(&conn->cmd_lock); | 1976 | spin_lock_bh(&conn->cmd_lock); |
1997 | list_add_tail(&cmd->i_conn_node, &conn->conn_cmd_list); | 1977 | list_add_tail(&cmd->i_conn_node, &conn->conn_cmd_list); |
1998 | spin_unlock_bh(&conn->cmd_lock); | 1978 | spin_unlock_bh(&conn->cmd_lock); |
1999 | 1979 | ||
2000 | iscsit_ack_from_expstatsn(conn, hdr->exp_statsn); | 1980 | iscsit_ack_from_expstatsn(conn, be32_to_cpu(hdr->exp_statsn)); |
2001 | 1981 | ||
2002 | if (!(hdr->opcode & ISCSI_OP_IMMEDIATE)) { | 1982 | if (!(hdr->opcode & ISCSI_OP_IMMEDIATE)) { |
2003 | cmdsn_ret = iscsit_sequence_cmd(conn, cmd, hdr->cmdsn); | 1983 | cmdsn_ret = iscsit_sequence_cmd(conn, cmd, hdr->cmdsn); |
@@ -2131,10 +2111,6 @@ static int iscsit_handle_logout_cmd( | |||
2131 | 2111 | ||
2132 | hdr = (struct iscsi_logout *) buf; | 2112 | hdr = (struct iscsi_logout *) buf; |
2133 | reason_code = (hdr->flags & 0x7f); | 2113 | reason_code = (hdr->flags & 0x7f); |
2134 | hdr->itt = be32_to_cpu(hdr->itt); | ||
2135 | hdr->cid = be16_to_cpu(hdr->cid); | ||
2136 | hdr->cmdsn = be32_to_cpu(hdr->cmdsn); | ||
2137 | hdr->exp_statsn = be32_to_cpu(hdr->exp_statsn); | ||
2138 | 2114 | ||
2139 | if (tiqn) { | 2115 | if (tiqn) { |
2140 | spin_lock(&tiqn->logout_stats.lock); | 2116 | spin_lock(&tiqn->logout_stats.lock); |
@@ -2166,9 +2142,9 @@ static int iscsit_handle_logout_cmd( | |||
2166 | cmd->immediate_cmd = ((hdr->opcode & ISCSI_OP_IMMEDIATE) ? 1 : 0); | 2142 | cmd->immediate_cmd = ((hdr->opcode & ISCSI_OP_IMMEDIATE) ? 1 : 0); |
2167 | conn->sess->init_task_tag = cmd->init_task_tag = hdr->itt; | 2143 | conn->sess->init_task_tag = cmd->init_task_tag = hdr->itt; |
2168 | cmd->targ_xfer_tag = 0xFFFFFFFF; | 2144 | cmd->targ_xfer_tag = 0xFFFFFFFF; |
2169 | cmd->cmd_sn = hdr->cmdsn; | 2145 | cmd->cmd_sn = be32_to_cpu(hdr->cmdsn); |
2170 | cmd->exp_stat_sn = hdr->exp_statsn; | 2146 | cmd->exp_stat_sn = be32_to_cpu(hdr->exp_statsn); |
2171 | cmd->logout_cid = hdr->cid; | 2147 | cmd->logout_cid = be16_to_cpu(hdr->cid); |
2172 | cmd->logout_reason = reason_code; | 2148 | cmd->logout_reason = reason_code; |
2173 | cmd->data_direction = DMA_NONE; | 2149 | cmd->data_direction = DMA_NONE; |
2174 | 2150 | ||
@@ -2178,7 +2154,7 @@ static int iscsit_handle_logout_cmd( | |||
2178 | */ | 2154 | */ |
2179 | if ((reason_code == ISCSI_LOGOUT_REASON_CLOSE_SESSION) || | 2155 | if ((reason_code == ISCSI_LOGOUT_REASON_CLOSE_SESSION) || |
2180 | ((reason_code == ISCSI_LOGOUT_REASON_CLOSE_CONNECTION) && | 2156 | ((reason_code == ISCSI_LOGOUT_REASON_CLOSE_CONNECTION) && |
2181 | (hdr->cid == conn->cid))) | 2157 | be16_to_cpu(hdr->cid) == conn->cid)) |
2182 | logout_remove = 1; | 2158 | logout_remove = 1; |
2183 | 2159 | ||
2184 | spin_lock_bh(&conn->cmd_lock); | 2160 | spin_lock_bh(&conn->cmd_lock); |
@@ -2186,7 +2162,7 @@ static int iscsit_handle_logout_cmd( | |||
2186 | spin_unlock_bh(&conn->cmd_lock); | 2162 | spin_unlock_bh(&conn->cmd_lock); |
2187 | 2163 | ||
2188 | if (reason_code != ISCSI_LOGOUT_REASON_RECOVERY) | 2164 | if (reason_code != ISCSI_LOGOUT_REASON_RECOVERY) |
2189 | iscsit_ack_from_expstatsn(conn, hdr->exp_statsn); | 2165 | iscsit_ack_from_expstatsn(conn, be32_to_cpu(hdr->exp_statsn)); |
2190 | 2166 | ||
2191 | /* | 2167 | /* |
2192 | * Immediate commands are executed, well, immediately. | 2168 | * Immediate commands are executed, well, immediately. |
@@ -2219,11 +2195,6 @@ static int iscsit_handle_snack( | |||
2219 | 2195 | ||
2220 | hdr = (struct iscsi_snack *) buf; | 2196 | hdr = (struct iscsi_snack *) buf; |
2221 | hdr->flags &= ~ISCSI_FLAG_CMD_FINAL; | 2197 | hdr->flags &= ~ISCSI_FLAG_CMD_FINAL; |
2222 | hdr->itt = be32_to_cpu(hdr->itt); | ||
2223 | hdr->ttt = be32_to_cpu(hdr->ttt); | ||
2224 | hdr->exp_statsn = be32_to_cpu(hdr->exp_statsn); | ||
2225 | hdr->begrun = be32_to_cpu(hdr->begrun); | ||
2226 | hdr->runlength = be32_to_cpu(hdr->runlength); | ||
2227 | 2198 | ||
2228 | pr_debug("Got ISCSI_INIT_SNACK, ITT: 0x%08x, ExpStatSN:" | 2199 | pr_debug("Got ISCSI_INIT_SNACK, ITT: 0x%08x, ExpStatSN:" |
2229 | " 0x%08x, Type: 0x%02x, BegRun: 0x%08x, RunLength: 0x%08x," | 2200 | " 0x%08x, Type: 0x%02x, BegRun: 0x%08x, RunLength: 0x%08x," |
@@ -2243,13 +2214,18 @@ static int iscsit_handle_snack( | |||
2243 | switch (hdr->flags & ISCSI_FLAG_SNACK_TYPE_MASK) { | 2214 | switch (hdr->flags & ISCSI_FLAG_SNACK_TYPE_MASK) { |
2244 | case 0: | 2215 | case 0: |
2245 | return iscsit_handle_recovery_datain_or_r2t(conn, buf, | 2216 | return iscsit_handle_recovery_datain_or_r2t(conn, buf, |
2246 | hdr->itt, hdr->ttt, hdr->begrun, hdr->runlength); | 2217 | hdr->itt, |
2218 | be32_to_cpu(hdr->ttt), | ||
2219 | be32_to_cpu(hdr->begrun), | ||
2220 | be32_to_cpu(hdr->runlength)); | ||
2247 | case ISCSI_FLAG_SNACK_TYPE_STATUS: | 2221 | case ISCSI_FLAG_SNACK_TYPE_STATUS: |
2248 | return iscsit_handle_status_snack(conn, hdr->itt, hdr->ttt, | 2222 | return iscsit_handle_status_snack(conn, hdr->itt, |
2249 | hdr->begrun, hdr->runlength); | 2223 | be32_to_cpu(hdr->ttt), |
2224 | be32_to_cpu(hdr->begrun), be32_to_cpu(hdr->runlength)); | ||
2250 | case ISCSI_FLAG_SNACK_TYPE_DATA_ACK: | 2225 | case ISCSI_FLAG_SNACK_TYPE_DATA_ACK: |
2251 | return iscsit_handle_data_ack(conn, hdr->ttt, hdr->begrun, | 2226 | return iscsit_handle_data_ack(conn, be32_to_cpu(hdr->ttt), |
2252 | hdr->runlength); | 2227 | be32_to_cpu(hdr->begrun), |
2228 | be32_to_cpu(hdr->runlength)); | ||
2253 | case ISCSI_FLAG_SNACK_TYPE_RDATA: | 2229 | case ISCSI_FLAG_SNACK_TYPE_RDATA: |
2254 | /* FIXME: Support R-Data SNACK */ | 2230 | /* FIXME: Support R-Data SNACK */ |
2255 | pr_err("R-Data SNACK Not Supported.\n"); | 2231 | pr_err("R-Data SNACK Not Supported.\n"); |
@@ -2414,7 +2390,7 @@ static int iscsit_send_conn_drop_async_message( | |||
2414 | hdr = (struct iscsi_async *) cmd->pdu; | 2390 | hdr = (struct iscsi_async *) cmd->pdu; |
2415 | hdr->opcode = ISCSI_OP_ASYNC_EVENT; | 2391 | hdr->opcode = ISCSI_OP_ASYNC_EVENT; |
2416 | hdr->flags = ISCSI_FLAG_CMD_FINAL; | 2392 | hdr->flags = ISCSI_FLAG_CMD_FINAL; |
2417 | cmd->init_task_tag = 0xFFFFFFFF; | 2393 | cmd->init_task_tag = RESERVED_ITT; |
2418 | cmd->targ_xfer_tag = 0xFFFFFFFF; | 2394 | cmd->targ_xfer_tag = 0xFFFFFFFF; |
2419 | put_unaligned_be64(0xFFFFFFFFFFFFFFFFULL, &hdr->rsvd4[0]); | 2395 | put_unaligned_be64(0xFFFFFFFFFFFFFFFFULL, &hdr->rsvd4[0]); |
2420 | cmd->stat_sn = conn->stat_sn++; | 2396 | cmd->stat_sn = conn->stat_sn++; |
@@ -2536,12 +2512,17 @@ static int iscsit_send_data_in( | |||
2536 | else | 2512 | else |
2537 | put_unaligned_le64(0xFFFFFFFFFFFFFFFFULL, &hdr->lun); | 2513 | put_unaligned_le64(0xFFFFFFFFFFFFFFFFULL, &hdr->lun); |
2538 | 2514 | ||
2539 | hdr->itt = cpu_to_be32(cmd->init_task_tag); | 2515 | hdr->itt = cmd->init_task_tag; |
2540 | hdr->ttt = (hdr->flags & ISCSI_FLAG_DATA_ACK) ? | 2516 | |
2541 | cpu_to_be32(cmd->targ_xfer_tag) : | 2517 | if (hdr->flags & ISCSI_FLAG_DATA_ACK) |
2542 | 0xFFFFFFFF; | 2518 | hdr->ttt = cpu_to_be32(cmd->targ_xfer_tag); |
2543 | hdr->statsn = (set_statsn) ? cpu_to_be32(cmd->stat_sn) : | 2519 | else |
2544 | 0xFFFFFFFF; | 2520 | hdr->ttt = cpu_to_be32(0xFFFFFFFF); |
2521 | if (set_statsn) | ||
2522 | hdr->statsn = cpu_to_be32(cmd->stat_sn); | ||
2523 | else | ||
2524 | hdr->statsn = cpu_to_be32(0xFFFFFFFF); | ||
2525 | |||
2545 | hdr->exp_cmdsn = cpu_to_be32(conn->sess->exp_cmd_sn); | 2526 | hdr->exp_cmdsn = cpu_to_be32(conn->sess->exp_cmd_sn); |
2546 | hdr->max_cmdsn = cpu_to_be32(conn->sess->max_cmd_sn); | 2527 | hdr->max_cmdsn = cpu_to_be32(conn->sess->max_cmd_sn); |
2547 | hdr->datasn = cpu_to_be32(datain.data_sn); | 2528 | hdr->datasn = cpu_to_be32(datain.data_sn); |
@@ -2708,7 +2689,7 @@ static int iscsit_send_logout_response( | |||
2708 | hdr->opcode = ISCSI_OP_LOGOUT_RSP; | 2689 | hdr->opcode = ISCSI_OP_LOGOUT_RSP; |
2709 | hdr->flags |= ISCSI_FLAG_CMD_FINAL; | 2690 | hdr->flags |= ISCSI_FLAG_CMD_FINAL; |
2710 | hdr->response = cmd->logout_response; | 2691 | hdr->response = cmd->logout_response; |
2711 | hdr->itt = cpu_to_be32(cmd->init_task_tag); | 2692 | hdr->itt = cmd->init_task_tag; |
2712 | cmd->stat_sn = conn->stat_sn++; | 2693 | cmd->stat_sn = conn->stat_sn++; |
2713 | hdr->statsn = cpu_to_be32(cmd->stat_sn); | 2694 | hdr->statsn = cpu_to_be32(cmd->stat_sn); |
2714 | 2695 | ||
@@ -2759,7 +2740,7 @@ static int iscsit_send_unsolicited_nopin( | |||
2759 | memset(hdr, 0, ISCSI_HDR_LEN); | 2740 | memset(hdr, 0, ISCSI_HDR_LEN); |
2760 | hdr->opcode = ISCSI_OP_NOOP_IN; | 2741 | hdr->opcode = ISCSI_OP_NOOP_IN; |
2761 | hdr->flags |= ISCSI_FLAG_CMD_FINAL; | 2742 | hdr->flags |= ISCSI_FLAG_CMD_FINAL; |
2762 | hdr->itt = cpu_to_be32(cmd->init_task_tag); | 2743 | hdr->itt = cmd->init_task_tag; |
2763 | hdr->ttt = cpu_to_be32(cmd->targ_xfer_tag); | 2744 | hdr->ttt = cpu_to_be32(cmd->targ_xfer_tag); |
2764 | cmd->stat_sn = conn->stat_sn; | 2745 | cmd->stat_sn = conn->stat_sn; |
2765 | hdr->statsn = cpu_to_be32(cmd->stat_sn); | 2746 | hdr->statsn = cpu_to_be32(cmd->stat_sn); |
@@ -2816,7 +2797,7 @@ static int iscsit_send_nopin_response( | |||
2816 | hdr->flags |= ISCSI_FLAG_CMD_FINAL; | 2797 | hdr->flags |= ISCSI_FLAG_CMD_FINAL; |
2817 | hton24(hdr->dlength, cmd->buf_ptr_size); | 2798 | hton24(hdr->dlength, cmd->buf_ptr_size); |
2818 | put_unaligned_le64(0xFFFFFFFFFFFFFFFFULL, &hdr->lun); | 2799 | put_unaligned_le64(0xFFFFFFFFFFFFFFFFULL, &hdr->lun); |
2819 | hdr->itt = cpu_to_be32(cmd->init_task_tag); | 2800 | hdr->itt = cmd->init_task_tag; |
2820 | hdr->ttt = cpu_to_be32(cmd->targ_xfer_tag); | 2801 | hdr->ttt = cpu_to_be32(cmd->targ_xfer_tag); |
2821 | cmd->stat_sn = conn->stat_sn++; | 2802 | cmd->stat_sn = conn->stat_sn++; |
2822 | hdr->statsn = cpu_to_be32(cmd->stat_sn); | 2803 | hdr->statsn = cpu_to_be32(cmd->stat_sn); |
@@ -2906,7 +2887,7 @@ static int iscsit_send_r2t( | |||
2906 | hdr->flags |= ISCSI_FLAG_CMD_FINAL; | 2887 | hdr->flags |= ISCSI_FLAG_CMD_FINAL; |
2907 | int_to_scsilun(cmd->se_cmd.orig_fe_lun, | 2888 | int_to_scsilun(cmd->se_cmd.orig_fe_lun, |
2908 | (struct scsi_lun *)&hdr->lun); | 2889 | (struct scsi_lun *)&hdr->lun); |
2909 | hdr->itt = cpu_to_be32(cmd->init_task_tag); | 2890 | hdr->itt = cmd->init_task_tag; |
2910 | spin_lock_bh(&conn->sess->ttt_lock); | 2891 | spin_lock_bh(&conn->sess->ttt_lock); |
2911 | r2t->targ_xfer_tag = conn->sess->targ_xfer_tag++; | 2892 | r2t->targ_xfer_tag = conn->sess->targ_xfer_tag++; |
2912 | if (r2t->targ_xfer_tag == 0xFFFFFFFF) | 2893 | if (r2t->targ_xfer_tag == 0xFFFFFFFF) |
@@ -3074,7 +3055,7 @@ static int iscsit_send_status( | |||
3074 | } | 3055 | } |
3075 | hdr->response = cmd->iscsi_response; | 3056 | hdr->response = cmd->iscsi_response; |
3076 | hdr->cmd_status = cmd->se_cmd.scsi_status; | 3057 | hdr->cmd_status = cmd->se_cmd.scsi_status; |
3077 | hdr->itt = cpu_to_be32(cmd->init_task_tag); | 3058 | hdr->itt = cmd->init_task_tag; |
3078 | hdr->statsn = cpu_to_be32(cmd->stat_sn); | 3059 | hdr->statsn = cpu_to_be32(cmd->stat_sn); |
3079 | 3060 | ||
3080 | iscsit_increment_maxcmdsn(cmd, conn->sess); | 3061 | iscsit_increment_maxcmdsn(cmd, conn->sess); |
@@ -3092,15 +3073,18 @@ static int iscsit_send_status( | |||
3092 | if (cmd->se_cmd.sense_buffer && | 3073 | if (cmd->se_cmd.sense_buffer && |
3093 | ((cmd->se_cmd.se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) || | 3074 | ((cmd->se_cmd.se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) || |
3094 | (cmd->se_cmd.se_cmd_flags & SCF_EMULATED_TASK_SENSE))) { | 3075 | (cmd->se_cmd.se_cmd_flags & SCF_EMULATED_TASK_SENSE))) { |
3076 | put_unaligned_be16(cmd->se_cmd.scsi_sense_length, cmd->sense_buffer); | ||
3077 | cmd->se_cmd.scsi_sense_length += sizeof (__be16); | ||
3078 | |||
3095 | padding = -(cmd->se_cmd.scsi_sense_length) & 3; | 3079 | padding = -(cmd->se_cmd.scsi_sense_length) & 3; |
3096 | hton24(hdr->dlength, cmd->se_cmd.scsi_sense_length); | 3080 | hton24(hdr->dlength, (u32)cmd->se_cmd.scsi_sense_length); |
3097 | iov[iov_count].iov_base = cmd->se_cmd.sense_buffer; | 3081 | iov[iov_count].iov_base = cmd->sense_buffer; |
3098 | iov[iov_count++].iov_len = | 3082 | iov[iov_count++].iov_len = |
3099 | (cmd->se_cmd.scsi_sense_length + padding); | 3083 | (cmd->se_cmd.scsi_sense_length + padding); |
3100 | tx_size += cmd->se_cmd.scsi_sense_length; | 3084 | tx_size += cmd->se_cmd.scsi_sense_length; |
3101 | 3085 | ||
3102 | if (padding) { | 3086 | if (padding) { |
3103 | memset(cmd->se_cmd.sense_buffer + | 3087 | memset(cmd->sense_buffer + |
3104 | cmd->se_cmd.scsi_sense_length, 0, padding); | 3088 | cmd->se_cmd.scsi_sense_length, 0, padding); |
3105 | tx_size += padding; | 3089 | tx_size += padding; |
3106 | pr_debug("Adding %u bytes of padding to" | 3090 | pr_debug("Adding %u bytes of padding to" |
@@ -3109,7 +3093,7 @@ static int iscsit_send_status( | |||
3109 | 3093 | ||
3110 | if (conn->conn_ops->DataDigest) { | 3094 | if (conn->conn_ops->DataDigest) { |
3111 | iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, | 3095 | iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, |
3112 | cmd->se_cmd.sense_buffer, | 3096 | cmd->sense_buffer, |
3113 | (cmd->se_cmd.scsi_sense_length + padding), | 3097 | (cmd->se_cmd.scsi_sense_length + padding), |
3114 | 0, NULL, (u8 *)&cmd->data_crc); | 3098 | 0, NULL, (u8 *)&cmd->data_crc); |
3115 | 3099 | ||
@@ -3184,7 +3168,7 @@ static int iscsit_send_task_mgt_rsp( | |||
3184 | hdr->opcode = ISCSI_OP_SCSI_TMFUNC_RSP; | 3168 | hdr->opcode = ISCSI_OP_SCSI_TMFUNC_RSP; |
3185 | hdr->flags = ISCSI_FLAG_CMD_FINAL; | 3169 | hdr->flags = ISCSI_FLAG_CMD_FINAL; |
3186 | hdr->response = iscsit_convert_tcm_tmr_rsp(se_tmr); | 3170 | hdr->response = iscsit_convert_tcm_tmr_rsp(se_tmr); |
3187 | hdr->itt = cpu_to_be32(cmd->init_task_tag); | 3171 | hdr->itt = cmd->init_task_tag; |
3188 | cmd->stat_sn = conn->stat_sn++; | 3172 | cmd->stat_sn = conn->stat_sn++; |
3189 | hdr->statsn = cpu_to_be32(cmd->stat_sn); | 3173 | hdr->statsn = cpu_to_be32(cmd->stat_sn); |
3190 | 3174 | ||
@@ -3236,7 +3220,7 @@ static bool iscsit_check_inaddr_any(struct iscsi_np *np) | |||
3236 | struct sockaddr_in * sock_in = | 3220 | struct sockaddr_in * sock_in = |
3237 | (struct sockaddr_in *)&np->np_sockaddr; | 3221 | (struct sockaddr_in *)&np->np_sockaddr; |
3238 | 3222 | ||
3239 | if (sock_in->sin_addr.s_addr == INADDR_ANY) | 3223 | if (sock_in->sin_addr.s_addr == htonl(INADDR_ANY)) |
3240 | ret = true; | 3224 | ret = true; |
3241 | } | 3225 | } |
3242 | 3226 | ||
@@ -3271,7 +3255,6 @@ static int iscsit_build_sendtargets_response(struct iscsi_cmd *cmd) | |||
3271 | len += 1; | 3255 | len += 1; |
3272 | 3256 | ||
3273 | if ((len + payload_len) > buffer_len) { | 3257 | if ((len + payload_len) > buffer_len) { |
3274 | spin_unlock(&tiqn->tiqn_tpg_lock); | ||
3275 | end_of_buf = 1; | 3258 | end_of_buf = 1; |
3276 | goto eob; | 3259 | goto eob; |
3277 | } | 3260 | } |
@@ -3358,7 +3341,7 @@ static int iscsit_send_text_rsp( | |||
3358 | hdr->opcode = ISCSI_OP_TEXT_RSP; | 3341 | hdr->opcode = ISCSI_OP_TEXT_RSP; |
3359 | hdr->flags |= ISCSI_FLAG_CMD_FINAL; | 3342 | hdr->flags |= ISCSI_FLAG_CMD_FINAL; |
3360 | hton24(hdr->dlength, text_length); | 3343 | hton24(hdr->dlength, text_length); |
3361 | hdr->itt = cpu_to_be32(cmd->init_task_tag); | 3344 | hdr->itt = cmd->init_task_tag; |
3362 | hdr->ttt = cpu_to_be32(cmd->targ_xfer_tag); | 3345 | hdr->ttt = cpu_to_be32(cmd->targ_xfer_tag); |
3363 | cmd->stat_sn = conn->stat_sn++; | 3346 | cmd->stat_sn = conn->stat_sn++; |
3364 | hdr->statsn = cpu_to_be32(cmd->stat_sn); | 3347 | hdr->statsn = cpu_to_be32(cmd->stat_sn); |
@@ -3424,6 +3407,7 @@ static int iscsit_send_reject( | |||
3424 | hdr->opcode = ISCSI_OP_REJECT; | 3407 | hdr->opcode = ISCSI_OP_REJECT; |
3425 | hdr->flags |= ISCSI_FLAG_CMD_FINAL; | 3408 | hdr->flags |= ISCSI_FLAG_CMD_FINAL; |
3426 | hton24(hdr->dlength, ISCSI_HDR_LEN); | 3409 | hton24(hdr->dlength, ISCSI_HDR_LEN); |
3410 | hdr->ffffffff = cpu_to_be32(0xffffffff); | ||
3427 | cmd->stat_sn = conn->stat_sn++; | 3411 | cmd->stat_sn = conn->stat_sn++; |
3428 | hdr->statsn = cpu_to_be32(cmd->stat_sn); | 3412 | hdr->statsn = cpu_to_be32(cmd->stat_sn); |
3429 | hdr->exp_cmdsn = cpu_to_be32(conn->sess->exp_cmd_sn); | 3413 | hdr->exp_cmdsn = cpu_to_be32(conn->sess->exp_cmd_sn); |
diff --git a/drivers/target/iscsi/iscsi_target.h b/drivers/target/iscsi/iscsi_target.h index 12abb4c9e34e..f1e4f3155bac 100644 --- a/drivers/target/iscsi/iscsi_target.h +++ b/drivers/target/iscsi/iscsi_target.h | |||
@@ -38,4 +38,9 @@ extern struct kmem_cache *lio_cmd_cache; | |||
38 | extern struct kmem_cache *lio_qr_cache; | 38 | extern struct kmem_cache *lio_qr_cache; |
39 | extern struct kmem_cache *lio_r2t_cache; | 39 | extern struct kmem_cache *lio_r2t_cache; |
40 | 40 | ||
41 | extern struct idr sess_idr; | ||
42 | extern struct mutex auth_id_lock; | ||
43 | extern spinlock_t sess_idr_lock; | ||
44 | |||
45 | |||
41 | #endif /*** ISCSI_TARGET_H ***/ | 46 | #endif /*** ISCSI_TARGET_H ***/ |
diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c index a7b25e783b58..ff6fd4fb624d 100644 --- a/drivers/target/iscsi/iscsi_target_configfs.c +++ b/drivers/target/iscsi/iscsi_target_configfs.c | |||
@@ -135,7 +135,7 @@ static struct configfs_attribute *lio_target_portal_attrs[] = { | |||
135 | 135 | ||
136 | #define MAX_PORTAL_LEN 256 | 136 | #define MAX_PORTAL_LEN 256 |
137 | 137 | ||
138 | struct se_tpg_np *lio_target_call_addnptotpg( | 138 | static struct se_tpg_np *lio_target_call_addnptotpg( |
139 | struct se_portal_group *se_tpg, | 139 | struct se_portal_group *se_tpg, |
140 | struct config_group *group, | 140 | struct config_group *group, |
141 | const char *name) | 141 | const char *name) |
@@ -1034,6 +1034,9 @@ TPG_PARAM_ATTR(ImmediateData, S_IRUGO | S_IWUSR); | |||
1034 | DEF_TPG_PARAM(MaxRecvDataSegmentLength); | 1034 | DEF_TPG_PARAM(MaxRecvDataSegmentLength); |
1035 | TPG_PARAM_ATTR(MaxRecvDataSegmentLength, S_IRUGO | S_IWUSR); | 1035 | TPG_PARAM_ATTR(MaxRecvDataSegmentLength, S_IRUGO | S_IWUSR); |
1036 | 1036 | ||
1037 | DEF_TPG_PARAM(MaxXmitDataSegmentLength); | ||
1038 | TPG_PARAM_ATTR(MaxXmitDataSegmentLength, S_IRUGO | S_IWUSR); | ||
1039 | |||
1037 | DEF_TPG_PARAM(MaxBurstLength); | 1040 | DEF_TPG_PARAM(MaxBurstLength); |
1038 | TPG_PARAM_ATTR(MaxBurstLength, S_IRUGO | S_IWUSR); | 1041 | TPG_PARAM_ATTR(MaxBurstLength, S_IRUGO | S_IWUSR); |
1039 | 1042 | ||
@@ -1079,6 +1082,7 @@ static struct configfs_attribute *lio_target_tpg_param_attrs[] = { | |||
1079 | &iscsi_tpg_param_InitialR2T.attr, | 1082 | &iscsi_tpg_param_InitialR2T.attr, |
1080 | &iscsi_tpg_param_ImmediateData.attr, | 1083 | &iscsi_tpg_param_ImmediateData.attr, |
1081 | &iscsi_tpg_param_MaxRecvDataSegmentLength.attr, | 1084 | &iscsi_tpg_param_MaxRecvDataSegmentLength.attr, |
1085 | &iscsi_tpg_param_MaxXmitDataSegmentLength.attr, | ||
1082 | &iscsi_tpg_param_MaxBurstLength.attr, | 1086 | &iscsi_tpg_param_MaxBurstLength.attr, |
1083 | &iscsi_tpg_param_FirstBurstLength.attr, | 1087 | &iscsi_tpg_param_FirstBurstLength.attr, |
1084 | &iscsi_tpg_param_DefaultTime2Wait.attr, | 1088 | &iscsi_tpg_param_DefaultTime2Wait.attr, |
@@ -1166,7 +1170,7 @@ static struct configfs_attribute *lio_target_tpg_attrs[] = { | |||
1166 | 1170 | ||
1167 | /* Start items for lio_target_tiqn_cit */ | 1171 | /* Start items for lio_target_tiqn_cit */ |
1168 | 1172 | ||
1169 | struct se_portal_group *lio_target_tiqn_addtpg( | 1173 | static struct se_portal_group *lio_target_tiqn_addtpg( |
1170 | struct se_wwn *wwn, | 1174 | struct se_wwn *wwn, |
1171 | struct config_group *group, | 1175 | struct config_group *group, |
1172 | const char *name) | 1176 | const char *name) |
@@ -1216,7 +1220,7 @@ out: | |||
1216 | return NULL; | 1220 | return NULL; |
1217 | } | 1221 | } |
1218 | 1222 | ||
1219 | void lio_target_tiqn_deltpg(struct se_portal_group *se_tpg) | 1223 | static void lio_target_tiqn_deltpg(struct se_portal_group *se_tpg) |
1220 | { | 1224 | { |
1221 | struct iscsi_portal_group *tpg; | 1225 | struct iscsi_portal_group *tpg; |
1222 | struct iscsi_tiqn *tiqn; | 1226 | struct iscsi_tiqn *tiqn; |
@@ -1248,7 +1252,7 @@ static struct configfs_attribute *lio_target_wwn_attrs[] = { | |||
1248 | NULL, | 1252 | NULL, |
1249 | }; | 1253 | }; |
1250 | 1254 | ||
1251 | struct se_wwn *lio_target_call_coreaddtiqn( | 1255 | static struct se_wwn *lio_target_call_coreaddtiqn( |
1252 | struct target_fabric_configfs *tf, | 1256 | struct target_fabric_configfs *tf, |
1253 | struct config_group *group, | 1257 | struct config_group *group, |
1254 | const char *name) | 1258 | const char *name) |
@@ -1296,7 +1300,7 @@ struct se_wwn *lio_target_call_coreaddtiqn( | |||
1296 | return &tiqn->tiqn_wwn; | 1300 | return &tiqn->tiqn_wwn; |
1297 | } | 1301 | } |
1298 | 1302 | ||
1299 | void lio_target_call_coredeltiqn( | 1303 | static void lio_target_call_coredeltiqn( |
1300 | struct se_wwn *wwn) | 1304 | struct se_wwn *wwn) |
1301 | { | 1305 | { |
1302 | struct iscsi_tiqn *tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn); | 1306 | struct iscsi_tiqn *tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn); |
@@ -1471,7 +1475,8 @@ static u32 iscsi_get_task_tag(struct se_cmd *se_cmd) | |||
1471 | { | 1475 | { |
1472 | struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); | 1476 | struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); |
1473 | 1477 | ||
1474 | return cmd->init_task_tag; | 1478 | /* only used for printks or comparism with ->ref_task_tag */ |
1479 | return (__force u32)cmd->init_task_tag; | ||
1475 | } | 1480 | } |
1476 | 1481 | ||
1477 | static int iscsi_get_cmd_state(struct se_cmd *se_cmd) | 1482 | static int iscsi_get_cmd_state(struct se_cmd *se_cmd) |
@@ -1542,29 +1547,6 @@ static int lio_queue_status(struct se_cmd *se_cmd) | |||
1542 | return 0; | 1547 | return 0; |
1543 | } | 1548 | } |
1544 | 1549 | ||
1545 | static u16 lio_set_fabric_sense_len(struct se_cmd *se_cmd, u32 sense_length) | ||
1546 | { | ||
1547 | unsigned char *buffer = se_cmd->sense_buffer; | ||
1548 | /* | ||
1549 | * From RFC-3720 10.4.7. Data Segment - Sense and Response Data Segment | ||
1550 | * 16-bit SenseLength. | ||
1551 | */ | ||
1552 | buffer[0] = ((sense_length >> 8) & 0xff); | ||
1553 | buffer[1] = (sense_length & 0xff); | ||
1554 | /* | ||
1555 | * Return two byte offset into allocated sense_buffer. | ||
1556 | */ | ||
1557 | return 2; | ||
1558 | } | ||
1559 | |||
1560 | static u16 lio_get_fabric_sense_len(void) | ||
1561 | { | ||
1562 | /* | ||
1563 | * Return two byte offset into allocated sense_buffer. | ||
1564 | */ | ||
1565 | return 2; | ||
1566 | } | ||
1567 | |||
1568 | static int lio_queue_tm_rsp(struct se_cmd *se_cmd) | 1550 | static int lio_queue_tm_rsp(struct se_cmd *se_cmd) |
1569 | { | 1551 | { |
1570 | struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); | 1552 | struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd); |
@@ -1748,8 +1730,6 @@ int iscsi_target_register_configfs(void) | |||
1748 | fabric->tf_ops.queue_data_in = &lio_queue_data_in; | 1730 | fabric->tf_ops.queue_data_in = &lio_queue_data_in; |
1749 | fabric->tf_ops.queue_status = &lio_queue_status; | 1731 | fabric->tf_ops.queue_status = &lio_queue_status; |
1750 | fabric->tf_ops.queue_tm_rsp = &lio_queue_tm_rsp; | 1732 | fabric->tf_ops.queue_tm_rsp = &lio_queue_tm_rsp; |
1751 | fabric->tf_ops.set_fabric_sense_len = &lio_set_fabric_sense_len; | ||
1752 | fabric->tf_ops.get_fabric_sense_len = &lio_get_fabric_sense_len; | ||
1753 | /* | 1733 | /* |
1754 | * Setup function pointers for generic logic in target_core_fabric_configfs.c | 1734 | * Setup function pointers for generic logic in target_core_fabric_configfs.c |
1755 | */ | 1735 | */ |
diff --git a/drivers/target/iscsi/iscsi_target_core.h b/drivers/target/iscsi/iscsi_target_core.h index 8a908b28d8b2..2ba9f9b9435c 100644 --- a/drivers/target/iscsi/iscsi_target_core.h +++ b/drivers/target/iscsi/iscsi_target_core.h | |||
@@ -25,10 +25,10 @@ | |||
25 | #define NA_DATAOUT_TIMEOUT_RETRIES 5 | 25 | #define NA_DATAOUT_TIMEOUT_RETRIES 5 |
26 | #define NA_DATAOUT_TIMEOUT_RETRIES_MAX 15 | 26 | #define NA_DATAOUT_TIMEOUT_RETRIES_MAX 15 |
27 | #define NA_DATAOUT_TIMEOUT_RETRIES_MIN 1 | 27 | #define NA_DATAOUT_TIMEOUT_RETRIES_MIN 1 |
28 | #define NA_NOPIN_TIMEOUT 5 | 28 | #define NA_NOPIN_TIMEOUT 15 |
29 | #define NA_NOPIN_TIMEOUT_MAX 60 | 29 | #define NA_NOPIN_TIMEOUT_MAX 60 |
30 | #define NA_NOPIN_TIMEOUT_MIN 3 | 30 | #define NA_NOPIN_TIMEOUT_MIN 3 |
31 | #define NA_NOPIN_RESPONSE_TIMEOUT 5 | 31 | #define NA_NOPIN_RESPONSE_TIMEOUT 30 |
32 | #define NA_NOPIN_RESPONSE_TIMEOUT_MAX 60 | 32 | #define NA_NOPIN_RESPONSE_TIMEOUT_MAX 60 |
33 | #define NA_NOPIN_RESPONSE_TIMEOUT_MIN 3 | 33 | #define NA_NOPIN_RESPONSE_TIMEOUT_MIN 3 |
34 | #define NA_RANDOM_DATAIN_PDU_OFFSETS 0 | 34 | #define NA_RANDOM_DATAIN_PDU_OFFSETS 0 |
@@ -239,6 +239,7 @@ struct iscsi_conn_ops { | |||
239 | u8 HeaderDigest; /* [0,1] == [None,CRC32C] */ | 239 | u8 HeaderDigest; /* [0,1] == [None,CRC32C] */ |
240 | u8 DataDigest; /* [0,1] == [None,CRC32C] */ | 240 | u8 DataDigest; /* [0,1] == [None,CRC32C] */ |
241 | u32 MaxRecvDataSegmentLength; /* [512..2**24-1] */ | 241 | u32 MaxRecvDataSegmentLength; /* [512..2**24-1] */ |
242 | u32 MaxXmitDataSegmentLength; /* [512..2**24-1] */ | ||
242 | u8 OFMarker; /* [0,1] == [No,Yes] */ | 243 | u8 OFMarker; /* [0,1] == [No,Yes] */ |
243 | u8 IFMarker; /* [0,1] == [No,Yes] */ | 244 | u8 IFMarker; /* [0,1] == [No,Yes] */ |
244 | u32 OFMarkInt; /* [1..65535] */ | 245 | u32 OFMarkInt; /* [1..65535] */ |
@@ -360,7 +361,7 @@ struct iscsi_cmd { | |||
360 | /* Command flags */ | 361 | /* Command flags */ |
361 | enum cmd_flags_table cmd_flags; | 362 | enum cmd_flags_table cmd_flags; |
362 | /* Initiator Task Tag assigned from Initiator */ | 363 | /* Initiator Task Tag assigned from Initiator */ |
363 | u32 init_task_tag; | 364 | itt_t init_task_tag; |
364 | /* Target Transfer Tag assigned from Target */ | 365 | /* Target Transfer Tag assigned from Target */ |
365 | u32 targ_xfer_tag; | 366 | u32 targ_xfer_tag; |
366 | /* CmdSN assigned from Initiator */ | 367 | /* CmdSN assigned from Initiator */ |
@@ -478,7 +479,6 @@ struct iscsi_cmd { | |||
478 | 479 | ||
479 | struct iscsi_tmr_req { | 480 | struct iscsi_tmr_req { |
480 | bool task_reassign:1; | 481 | bool task_reassign:1; |
481 | u32 ref_cmd_sn; | ||
482 | u32 exp_data_sn; | 482 | u32 exp_data_sn; |
483 | struct iscsi_cmd *ref_cmd; | 483 | struct iscsi_cmd *ref_cmd; |
484 | struct iscsi_conn_recovery *conn_recovery; | 484 | struct iscsi_conn_recovery *conn_recovery; |
@@ -505,7 +505,7 @@ struct iscsi_conn { | |||
505 | u32 auth_id; | 505 | u32 auth_id; |
506 | u32 conn_flags; | 506 | u32 conn_flags; |
507 | /* Used for iscsi_tx_login_rsp() */ | 507 | /* Used for iscsi_tx_login_rsp() */ |
508 | u32 login_itt; | 508 | itt_t login_itt; |
509 | u32 exp_statsn; | 509 | u32 exp_statsn; |
510 | /* Per connection status sequence number */ | 510 | /* Per connection status sequence number */ |
511 | u32 stat_sn; | 511 | u32 stat_sn; |
@@ -578,6 +578,7 @@ struct iscsi_conn_recovery { | |||
578 | u16 cid; | 578 | u16 cid; |
579 | u32 cmd_count; | 579 | u32 cmd_count; |
580 | u32 maxrecvdatasegmentlength; | 580 | u32 maxrecvdatasegmentlength; |
581 | u32 maxxmitdatasegmentlength; | ||
581 | int ready_for_reallegiance; | 582 | int ready_for_reallegiance; |
582 | struct list_head conn_recovery_cmd_list; | 583 | struct list_head conn_recovery_cmd_list; |
583 | spinlock_t conn_recovery_cmd_lock; | 584 | spinlock_t conn_recovery_cmd_lock; |
@@ -597,7 +598,7 @@ struct iscsi_session { | |||
597 | /* state session is currently in */ | 598 | /* state session is currently in */ |
598 | u32 session_state; | 599 | u32 session_state; |
599 | /* session wide counter: initiator assigned task tag */ | 600 | /* session wide counter: initiator assigned task tag */ |
600 | u32 init_task_tag; | 601 | itt_t init_task_tag; |
601 | /* session wide counter: target assigned task tag */ | 602 | /* session wide counter: target assigned task tag */ |
602 | u32 targ_xfer_tag; | 603 | u32 targ_xfer_tag; |
603 | u32 cmdsn_window; | 604 | u32 cmdsn_window; |
@@ -663,7 +664,7 @@ struct iscsi_login { | |||
663 | u8 version_max; | 664 | u8 version_max; |
664 | char isid[6]; | 665 | char isid[6]; |
665 | u32 cmd_sn; | 666 | u32 cmd_sn; |
666 | u32 init_task_tag; | 667 | itt_t init_task_tag; |
667 | u32 initial_exp_statsn; | 668 | u32 initial_exp_statsn; |
668 | u32 rsp_length; | 669 | u32 rsp_length; |
669 | u16 cid; | 670 | u16 cid; |
diff --git a/drivers/target/iscsi/iscsi_target_erl0.c b/drivers/target/iscsi/iscsi_target_erl0.c index 1a02016ecdab..8aacf611b86d 100644 --- a/drivers/target/iscsi/iscsi_target_erl0.c +++ b/drivers/target/iscsi/iscsi_target_erl0.c | |||
@@ -48,9 +48,9 @@ void iscsit_set_dataout_sequence_values( | |||
48 | if (cmd->unsolicited_data) { | 48 | if (cmd->unsolicited_data) { |
49 | cmd->seq_start_offset = cmd->write_data_done; | 49 | cmd->seq_start_offset = cmd->write_data_done; |
50 | cmd->seq_end_offset = (cmd->write_data_done + | 50 | cmd->seq_end_offset = (cmd->write_data_done + |
51 | (cmd->se_cmd.data_length > | 51 | ((cmd->se_cmd.data_length > |
52 | conn->sess->sess_ops->FirstBurstLength) ? | 52 | conn->sess->sess_ops->FirstBurstLength) ? |
53 | conn->sess->sess_ops->FirstBurstLength : cmd->se_cmd.data_length); | 53 | conn->sess->sess_ops->FirstBurstLength : cmd->se_cmd.data_length)); |
54 | return; | 54 | return; |
55 | } | 55 | } |
56 | 56 | ||
@@ -95,14 +95,15 @@ static int iscsit_dataout_within_command_recovery_check( | |||
95 | */ | 95 | */ |
96 | if (conn->sess->sess_ops->DataSequenceInOrder) { | 96 | if (conn->sess->sess_ops->DataSequenceInOrder) { |
97 | if ((cmd->cmd_flags & ICF_WITHIN_COMMAND_RECOVERY) && | 97 | if ((cmd->cmd_flags & ICF_WITHIN_COMMAND_RECOVERY) && |
98 | (cmd->write_data_done != hdr->offset)) | 98 | cmd->write_data_done != be32_to_cpu(hdr->offset)) |
99 | goto dump; | 99 | goto dump; |
100 | 100 | ||
101 | cmd->cmd_flags &= ~ICF_WITHIN_COMMAND_RECOVERY; | 101 | cmd->cmd_flags &= ~ICF_WITHIN_COMMAND_RECOVERY; |
102 | } else { | 102 | } else { |
103 | struct iscsi_seq *seq; | 103 | struct iscsi_seq *seq; |
104 | 104 | ||
105 | seq = iscsit_get_seq_holder(cmd, hdr->offset, payload_length); | 105 | seq = iscsit_get_seq_holder(cmd, be32_to_cpu(hdr->offset), |
106 | payload_length); | ||
106 | if (!seq) | 107 | if (!seq) |
107 | return DATAOUT_CANNOT_RECOVER; | 108 | return DATAOUT_CANNOT_RECOVER; |
108 | /* | 109 | /* |
@@ -111,15 +112,15 @@ static int iscsit_dataout_within_command_recovery_check( | |||
111 | cmd->seq_ptr = seq; | 112 | cmd->seq_ptr = seq; |
112 | 113 | ||
113 | if (conn->sess->sess_ops->DataPDUInOrder) { | 114 | if (conn->sess->sess_ops->DataPDUInOrder) { |
114 | if ((seq->status == | 115 | if (seq->status == |
115 | DATAOUT_SEQUENCE_WITHIN_COMMAND_RECOVERY) && | 116 | DATAOUT_SEQUENCE_WITHIN_COMMAND_RECOVERY && |
116 | ((seq->offset != hdr->offset) || | 117 | (seq->offset != be32_to_cpu(hdr->offset) || |
117 | (seq->data_sn != hdr->datasn))) | 118 | seq->data_sn != be32_to_cpu(hdr->datasn))) |
118 | goto dump; | 119 | goto dump; |
119 | } else { | 120 | } else { |
120 | if ((seq->status == | 121 | if (seq->status == |
121 | DATAOUT_SEQUENCE_WITHIN_COMMAND_RECOVERY) && | 122 | DATAOUT_SEQUENCE_WITHIN_COMMAND_RECOVERY && |
122 | (seq->data_sn != hdr->datasn)) | 123 | seq->data_sn != be32_to_cpu(hdr->datasn)) |
123 | goto dump; | 124 | goto dump; |
124 | } | 125 | } |
125 | 126 | ||
@@ -148,12 +149,12 @@ static int iscsit_dataout_check_unsolicited_sequence( | |||
148 | u32 payload_length = ntoh24(hdr->dlength); | 149 | u32 payload_length = ntoh24(hdr->dlength); |
149 | 150 | ||
150 | 151 | ||
151 | if ((hdr->offset < cmd->seq_start_offset) || | 152 | if ((be32_to_cpu(hdr->offset) < cmd->seq_start_offset) || |
152 | ((hdr->offset + payload_length) > cmd->seq_end_offset)) { | 153 | ((be32_to_cpu(hdr->offset) + payload_length) > cmd->seq_end_offset)) { |
153 | pr_err("Command ITT: 0x%08x with Offset: %u," | 154 | pr_err("Command ITT: 0x%08x with Offset: %u," |
154 | " Length: %u outside of Unsolicited Sequence %u:%u while" | 155 | " Length: %u outside of Unsolicited Sequence %u:%u while" |
155 | " DataSequenceInOrder=Yes.\n", cmd->init_task_tag, | 156 | " DataSequenceInOrder=Yes.\n", cmd->init_task_tag, |
156 | hdr->offset, payload_length, cmd->seq_start_offset, | 157 | be32_to_cpu(hdr->offset), payload_length, cmd->seq_start_offset, |
157 | cmd->seq_end_offset); | 158 | cmd->seq_end_offset); |
158 | return DATAOUT_CANNOT_RECOVER; | 159 | return DATAOUT_CANNOT_RECOVER; |
159 | } | 160 | } |
@@ -236,12 +237,12 @@ static int iscsit_dataout_check_sequence( | |||
236 | * fullfilling an Recovery R2T, it's best to just dump the | 237 | * fullfilling an Recovery R2T, it's best to just dump the |
237 | * payload here, instead of erroring out. | 238 | * payload here, instead of erroring out. |
238 | */ | 239 | */ |
239 | if ((hdr->offset < cmd->seq_start_offset) || | 240 | if ((be32_to_cpu(hdr->offset) < cmd->seq_start_offset) || |
240 | ((hdr->offset + payload_length) > cmd->seq_end_offset)) { | 241 | ((be32_to_cpu(hdr->offset) + payload_length) > cmd->seq_end_offset)) { |
241 | pr_err("Command ITT: 0x%08x with Offset: %u," | 242 | pr_err("Command ITT: 0x%08x with Offset: %u," |
242 | " Length: %u outside of Sequence %u:%u while" | 243 | " Length: %u outside of Sequence %u:%u while" |
243 | " DataSequenceInOrder=Yes.\n", cmd->init_task_tag, | 244 | " DataSequenceInOrder=Yes.\n", cmd->init_task_tag, |
244 | hdr->offset, payload_length, cmd->seq_start_offset, | 245 | be32_to_cpu(hdr->offset), payload_length, cmd->seq_start_offset, |
245 | cmd->seq_end_offset); | 246 | cmd->seq_end_offset); |
246 | 247 | ||
247 | if (iscsit_dump_data_payload(conn, payload_length, 1) < 0) | 248 | if (iscsit_dump_data_payload(conn, payload_length, 1) < 0) |
@@ -251,7 +252,8 @@ static int iscsit_dataout_check_sequence( | |||
251 | 252 | ||
252 | next_burst_len = (cmd->next_burst_len + payload_length); | 253 | next_burst_len = (cmd->next_burst_len + payload_length); |
253 | } else { | 254 | } else { |
254 | seq = iscsit_get_seq_holder(cmd, hdr->offset, payload_length); | 255 | seq = iscsit_get_seq_holder(cmd, be32_to_cpu(hdr->offset), |
256 | payload_length); | ||
255 | if (!seq) | 257 | if (!seq) |
256 | return DATAOUT_CANNOT_RECOVER; | 258 | return DATAOUT_CANNOT_RECOVER; |
257 | /* | 259 | /* |
@@ -366,16 +368,16 @@ static int iscsit_dataout_check_datasn( | |||
366 | data_sn = seq->data_sn; | 368 | data_sn = seq->data_sn; |
367 | } | 369 | } |
368 | 370 | ||
369 | if (hdr->datasn > data_sn) { | 371 | if (be32_to_cpu(hdr->datasn) > data_sn) { |
370 | pr_err("Command ITT: 0x%08x, received DataSN: 0x%08x" | 372 | pr_err("Command ITT: 0x%08x, received DataSN: 0x%08x" |
371 | " higher than expected 0x%08x.\n", cmd->init_task_tag, | 373 | " higher than expected 0x%08x.\n", cmd->init_task_tag, |
372 | hdr->datasn, data_sn); | 374 | be32_to_cpu(hdr->datasn), data_sn); |
373 | recovery = 1; | 375 | recovery = 1; |
374 | goto recover; | 376 | goto recover; |
375 | } else if (hdr->datasn < data_sn) { | 377 | } else if (be32_to_cpu(hdr->datasn) < data_sn) { |
376 | pr_err("Command ITT: 0x%08x, received DataSN: 0x%08x" | 378 | pr_err("Command ITT: 0x%08x, received DataSN: 0x%08x" |
377 | " lower than expected 0x%08x, discarding payload.\n", | 379 | " lower than expected 0x%08x, discarding payload.\n", |
378 | cmd->init_task_tag, hdr->datasn, data_sn); | 380 | cmd->init_task_tag, be32_to_cpu(hdr->datasn), data_sn); |
379 | dump = 1; | 381 | dump = 1; |
380 | goto dump; | 382 | goto dump; |
381 | } | 383 | } |
@@ -415,26 +417,27 @@ static int iscsit_dataout_pre_datapduinorder_yes( | |||
415 | * error has occured and fail the connection. | 417 | * error has occured and fail the connection. |
416 | */ | 418 | */ |
417 | if (conn->sess->sess_ops->DataSequenceInOrder) { | 419 | if (conn->sess->sess_ops->DataSequenceInOrder) { |
418 | if (hdr->offset != cmd->write_data_done) { | 420 | if (be32_to_cpu(hdr->offset) != cmd->write_data_done) { |
419 | pr_err("Command ITT: 0x%08x, received offset" | 421 | pr_err("Command ITT: 0x%08x, received offset" |
420 | " %u different than expected %u.\n", cmd->init_task_tag, | 422 | " %u different than expected %u.\n", cmd->init_task_tag, |
421 | hdr->offset, cmd->write_data_done); | 423 | be32_to_cpu(hdr->offset), cmd->write_data_done); |
422 | recovery = 1; | 424 | recovery = 1; |
423 | goto recover; | 425 | goto recover; |
424 | } | 426 | } |
425 | } else { | 427 | } else { |
426 | struct iscsi_seq *seq = cmd->seq_ptr; | 428 | struct iscsi_seq *seq = cmd->seq_ptr; |
427 | 429 | ||
428 | if (hdr->offset > seq->offset) { | 430 | if (be32_to_cpu(hdr->offset) > seq->offset) { |
429 | pr_err("Command ITT: 0x%08x, received offset" | 431 | pr_err("Command ITT: 0x%08x, received offset" |
430 | " %u greater than expected %u.\n", cmd->init_task_tag, | 432 | " %u greater than expected %u.\n", cmd->init_task_tag, |
431 | hdr->offset, seq->offset); | 433 | be32_to_cpu(hdr->offset), seq->offset); |
432 | recovery = 1; | 434 | recovery = 1; |
433 | goto recover; | 435 | goto recover; |
434 | } else if (hdr->offset < seq->offset) { | 436 | } else if (be32_to_cpu(hdr->offset) < seq->offset) { |
435 | pr_err("Command ITT: 0x%08x, received offset" | 437 | pr_err("Command ITT: 0x%08x, received offset" |
436 | " %u less than expected %u, discarding payload.\n", | 438 | " %u less than expected %u, discarding payload.\n", |
437 | cmd->init_task_tag, hdr->offset, seq->offset); | 439 | cmd->init_task_tag, be32_to_cpu(hdr->offset), |
440 | seq->offset); | ||
438 | dump = 1; | 441 | dump = 1; |
439 | goto dump; | 442 | goto dump; |
440 | } | 443 | } |
@@ -453,7 +456,7 @@ dump: | |||
453 | return DATAOUT_CANNOT_RECOVER; | 456 | return DATAOUT_CANNOT_RECOVER; |
454 | 457 | ||
455 | return (recovery) ? iscsit_recover_dataout_sequence(cmd, | 458 | return (recovery) ? iscsit_recover_dataout_sequence(cmd, |
456 | hdr->offset, payload_length) : | 459 | be32_to_cpu(hdr->offset), payload_length) : |
457 | (dump) ? DATAOUT_WITHIN_COMMAND_RECOVERY : DATAOUT_NORMAL; | 460 | (dump) ? DATAOUT_WITHIN_COMMAND_RECOVERY : DATAOUT_NORMAL; |
458 | } | 461 | } |
459 | 462 | ||
@@ -465,7 +468,8 @@ static int iscsit_dataout_pre_datapduinorder_no( | |||
465 | struct iscsi_data *hdr = (struct iscsi_data *) buf; | 468 | struct iscsi_data *hdr = (struct iscsi_data *) buf; |
466 | u32 payload_length = ntoh24(hdr->dlength); | 469 | u32 payload_length = ntoh24(hdr->dlength); |
467 | 470 | ||
468 | pdu = iscsit_get_pdu_holder(cmd, hdr->offset, payload_length); | 471 | pdu = iscsit_get_pdu_holder(cmd, be32_to_cpu(hdr->offset), |
472 | payload_length); | ||
469 | if (!pdu) | 473 | if (!pdu) |
470 | return DATAOUT_CANNOT_RECOVER; | 474 | return DATAOUT_CANNOT_RECOVER; |
471 | 475 | ||
@@ -479,7 +483,7 @@ static int iscsit_dataout_pre_datapduinorder_no( | |||
479 | case ISCSI_PDU_RECEIVED_OK: | 483 | case ISCSI_PDU_RECEIVED_OK: |
480 | pr_err("Command ITT: 0x%08x received already gotten" | 484 | pr_err("Command ITT: 0x%08x received already gotten" |
481 | " Offset: %u, Length: %u\n", cmd->init_task_tag, | 485 | " Offset: %u, Length: %u\n", cmd->init_task_tag, |
482 | hdr->offset, payload_length); | 486 | be32_to_cpu(hdr->offset), payload_length); |
483 | return iscsit_dump_data_payload(cmd->conn, payload_length, 1); | 487 | return iscsit_dump_data_payload(cmd->conn, payload_length, 1); |
484 | default: | 488 | default: |
485 | return DATAOUT_CANNOT_RECOVER; | 489 | return DATAOUT_CANNOT_RECOVER; |
@@ -553,7 +557,7 @@ static int iscsit_dataout_post_crc_passed( | |||
553 | if (cmd->unsolicited_data) { | 557 | if (cmd->unsolicited_data) { |
554 | if ((cmd->first_burst_len + payload_length) == | 558 | if ((cmd->first_burst_len + payload_length) == |
555 | conn->sess->sess_ops->FirstBurstLength) { | 559 | conn->sess->sess_ops->FirstBurstLength) { |
556 | if (iscsit_dataout_update_r2t(cmd, hdr->offset, | 560 | if (iscsit_dataout_update_r2t(cmd, be32_to_cpu(hdr->offset), |
557 | payload_length) < 0) | 561 | payload_length) < 0) |
558 | return DATAOUT_CANNOT_RECOVER; | 562 | return DATAOUT_CANNOT_RECOVER; |
559 | send_r2t = 1; | 563 | send_r2t = 1; |
@@ -561,7 +565,8 @@ static int iscsit_dataout_post_crc_passed( | |||
561 | 565 | ||
562 | if (!conn->sess->sess_ops->DataPDUInOrder) { | 566 | if (!conn->sess->sess_ops->DataPDUInOrder) { |
563 | ret = iscsit_dataout_update_datapduinorder_no(cmd, | 567 | ret = iscsit_dataout_update_datapduinorder_no(cmd, |
564 | hdr->datasn, (hdr->flags & ISCSI_FLAG_CMD_FINAL)); | 568 | be32_to_cpu(hdr->datasn), |
569 | (hdr->flags & ISCSI_FLAG_CMD_FINAL)); | ||
565 | if (ret == DATAOUT_CANNOT_RECOVER) | 570 | if (ret == DATAOUT_CANNOT_RECOVER) |
566 | return ret; | 571 | return ret; |
567 | } | 572 | } |
@@ -586,7 +591,8 @@ static int iscsit_dataout_post_crc_passed( | |||
586 | if (conn->sess->sess_ops->DataSequenceInOrder) { | 591 | if (conn->sess->sess_ops->DataSequenceInOrder) { |
587 | if ((cmd->next_burst_len + payload_length) == | 592 | if ((cmd->next_burst_len + payload_length) == |
588 | conn->sess->sess_ops->MaxBurstLength) { | 593 | conn->sess->sess_ops->MaxBurstLength) { |
589 | if (iscsit_dataout_update_r2t(cmd, hdr->offset, | 594 | if (iscsit_dataout_update_r2t(cmd, |
595 | be32_to_cpu(hdr->offset), | ||
590 | payload_length) < 0) | 596 | payload_length) < 0) |
591 | return DATAOUT_CANNOT_RECOVER; | 597 | return DATAOUT_CANNOT_RECOVER; |
592 | send_r2t = 1; | 598 | send_r2t = 1; |
@@ -594,7 +600,7 @@ static int iscsit_dataout_post_crc_passed( | |||
594 | 600 | ||
595 | if (!conn->sess->sess_ops->DataPDUInOrder) { | 601 | if (!conn->sess->sess_ops->DataPDUInOrder) { |
596 | ret = iscsit_dataout_update_datapduinorder_no( | 602 | ret = iscsit_dataout_update_datapduinorder_no( |
597 | cmd, hdr->datasn, | 603 | cmd, be32_to_cpu(hdr->datasn), |
598 | (hdr->flags & ISCSI_FLAG_CMD_FINAL)); | 604 | (hdr->flags & ISCSI_FLAG_CMD_FINAL)); |
599 | if (ret == DATAOUT_CANNOT_RECOVER) | 605 | if (ret == DATAOUT_CANNOT_RECOVER) |
600 | return ret; | 606 | return ret; |
@@ -610,7 +616,8 @@ static int iscsit_dataout_post_crc_passed( | |||
610 | 616 | ||
611 | if ((seq->next_burst_len + payload_length) == | 617 | if ((seq->next_burst_len + payload_length) == |
612 | seq->xfer_len) { | 618 | seq->xfer_len) { |
613 | if (iscsit_dataout_update_r2t(cmd, hdr->offset, | 619 | if (iscsit_dataout_update_r2t(cmd, |
620 | be32_to_cpu(hdr->offset), | ||
614 | payload_length) < 0) | 621 | payload_length) < 0) |
615 | return DATAOUT_CANNOT_RECOVER; | 622 | return DATAOUT_CANNOT_RECOVER; |
616 | send_r2t = 1; | 623 | send_r2t = 1; |
@@ -618,7 +625,7 @@ static int iscsit_dataout_post_crc_passed( | |||
618 | 625 | ||
619 | if (!conn->sess->sess_ops->DataPDUInOrder) { | 626 | if (!conn->sess->sess_ops->DataPDUInOrder) { |
620 | ret = iscsit_dataout_update_datapduinorder_no( | 627 | ret = iscsit_dataout_update_datapduinorder_no( |
621 | cmd, hdr->datasn, | 628 | cmd, be32_to_cpu(hdr->datasn), |
622 | (hdr->flags & ISCSI_FLAG_CMD_FINAL)); | 629 | (hdr->flags & ISCSI_FLAG_CMD_FINAL)); |
623 | if (ret == DATAOUT_CANNOT_RECOVER) | 630 | if (ret == DATAOUT_CANNOT_RECOVER) |
624 | return ret; | 631 | return ret; |
@@ -678,14 +685,15 @@ static int iscsit_dataout_post_crc_failed( | |||
678 | } | 685 | } |
679 | 686 | ||
680 | recover: | 687 | recover: |
681 | return iscsit_recover_dataout_sequence(cmd, hdr->offset, payload_length); | 688 | return iscsit_recover_dataout_sequence(cmd, be32_to_cpu(hdr->offset), |
689 | payload_length); | ||
682 | } | 690 | } |
683 | 691 | ||
684 | /* | 692 | /* |
685 | * Called from iscsit_handle_data_out() before DataOUT Payload is received | 693 | * Called from iscsit_handle_data_out() before DataOUT Payload is received |
686 | * and CRC computed. | 694 | * and CRC computed. |
687 | */ | 695 | */ |
688 | extern int iscsit_check_pre_dataout( | 696 | int iscsit_check_pre_dataout( |
689 | struct iscsi_cmd *cmd, | 697 | struct iscsi_cmd *cmd, |
690 | unsigned char *buf) | 698 | unsigned char *buf) |
691 | { | 699 | { |
@@ -789,7 +797,7 @@ static void iscsit_handle_time2retain_timeout(unsigned long data) | |||
789 | target_put_session(sess->se_sess); | 797 | target_put_session(sess->se_sess); |
790 | } | 798 | } |
791 | 799 | ||
792 | extern void iscsit_start_time2retain_handler(struct iscsi_session *sess) | 800 | void iscsit_start_time2retain_handler(struct iscsi_session *sess) |
793 | { | 801 | { |
794 | int tpg_active; | 802 | int tpg_active; |
795 | /* | 803 | /* |
@@ -822,7 +830,7 @@ extern void iscsit_start_time2retain_handler(struct iscsi_session *sess) | |||
822 | /* | 830 | /* |
823 | * Called with spin_lock_bh(&struct se_portal_group->session_lock) held | 831 | * Called with spin_lock_bh(&struct se_portal_group->session_lock) held |
824 | */ | 832 | */ |
825 | extern int iscsit_stop_time2retain_timer(struct iscsi_session *sess) | 833 | int iscsit_stop_time2retain_timer(struct iscsi_session *sess) |
826 | { | 834 | { |
827 | struct iscsi_portal_group *tpg = ISCSI_TPG_S(sess); | 835 | struct iscsi_portal_group *tpg = ISCSI_TPG_S(sess); |
828 | struct se_portal_group *se_tpg = &tpg->tpg_se_tpg; | 836 | struct se_portal_group *se_tpg = &tpg->tpg_se_tpg; |
@@ -926,7 +934,7 @@ static void iscsit_handle_connection_cleanup(struct iscsi_conn *conn) | |||
926 | } | 934 | } |
927 | } | 935 | } |
928 | 936 | ||
929 | extern void iscsit_take_action_for_connection_exit(struct iscsi_conn *conn) | 937 | void iscsit_take_action_for_connection_exit(struct iscsi_conn *conn) |
930 | { | 938 | { |
931 | spin_lock_bh(&conn->state_lock); | 939 | spin_lock_bh(&conn->state_lock); |
932 | if (atomic_read(&conn->connection_exit)) { | 940 | if (atomic_read(&conn->connection_exit)) { |
diff --git a/drivers/target/iscsi/iscsi_target_erl1.c b/drivers/target/iscsi/iscsi_target_erl1.c index 3df8a2cef86f..21f29d91a8cb 100644 --- a/drivers/target/iscsi/iscsi_target_erl1.c +++ b/drivers/target/iscsi/iscsi_target_erl1.c | |||
@@ -466,7 +466,7 @@ static int iscsit_handle_recovery_datain( | |||
466 | int iscsit_handle_recovery_datain_or_r2t( | 466 | int iscsit_handle_recovery_datain_or_r2t( |
467 | struct iscsi_conn *conn, | 467 | struct iscsi_conn *conn, |
468 | unsigned char *buf, | 468 | unsigned char *buf, |
469 | u32 init_task_tag, | 469 | itt_t init_task_tag, |
470 | u32 targ_xfer_tag, | 470 | u32 targ_xfer_tag, |
471 | u32 begrun, | 471 | u32 begrun, |
472 | u32 runlength) | 472 | u32 runlength) |
@@ -498,7 +498,7 @@ int iscsit_handle_recovery_datain_or_r2t( | |||
498 | /* #warning FIXME: Status SNACK needs to be dependent on OPCODE!!! */ | 498 | /* #warning FIXME: Status SNACK needs to be dependent on OPCODE!!! */ |
499 | int iscsit_handle_status_snack( | 499 | int iscsit_handle_status_snack( |
500 | struct iscsi_conn *conn, | 500 | struct iscsi_conn *conn, |
501 | u32 init_task_tag, | 501 | itt_t init_task_tag, |
502 | u32 targ_xfer_tag, | 502 | u32 targ_xfer_tag, |
503 | u32 begrun, | 503 | u32 begrun, |
504 | u32 runlength) | 504 | u32 runlength) |
diff --git a/drivers/target/iscsi/iscsi_target_erl1.h b/drivers/target/iscsi/iscsi_target_erl1.h index 85e67e29de6b..2a3ebf118a34 100644 --- a/drivers/target/iscsi/iscsi_target_erl1.h +++ b/drivers/target/iscsi/iscsi_target_erl1.h | |||
@@ -7,8 +7,8 @@ extern int iscsit_create_recovery_datain_values_datasequenceinorder_yes( | |||
7 | extern int iscsit_create_recovery_datain_values_datasequenceinorder_no( | 7 | extern int iscsit_create_recovery_datain_values_datasequenceinorder_no( |
8 | struct iscsi_cmd *, struct iscsi_datain_req *); | 8 | struct iscsi_cmd *, struct iscsi_datain_req *); |
9 | extern int iscsit_handle_recovery_datain_or_r2t(struct iscsi_conn *, unsigned char *, | 9 | extern int iscsit_handle_recovery_datain_or_r2t(struct iscsi_conn *, unsigned char *, |
10 | u32, u32, u32, u32); | 10 | itt_t, u32, u32, u32); |
11 | extern int iscsit_handle_status_snack(struct iscsi_conn *, u32, u32, | 11 | extern int iscsit_handle_status_snack(struct iscsi_conn *, itt_t, u32, |
12 | u32, u32); | 12 | u32, u32); |
13 | extern int iscsit_handle_data_ack(struct iscsi_conn *, u32, u32, u32); | 13 | extern int iscsit_handle_data_ack(struct iscsi_conn *, u32, u32, u32); |
14 | extern int iscsit_dataout_datapduinorder_no_fbit(struct iscsi_cmd *, struct iscsi_pdu *); | 14 | extern int iscsit_dataout_datapduinorder_no_fbit(struct iscsi_cmd *, struct iscsi_pdu *); |
diff --git a/drivers/target/iscsi/iscsi_target_erl2.c b/drivers/target/iscsi/iscsi_target_erl2.c index 65aac14fd831..17d8c20094fd 100644 --- a/drivers/target/iscsi/iscsi_target_erl2.c +++ b/drivers/target/iscsi/iscsi_target_erl2.c | |||
@@ -36,7 +36,7 @@ | |||
36 | */ | 36 | */ |
37 | void iscsit_create_conn_recovery_datain_values( | 37 | void iscsit_create_conn_recovery_datain_values( |
38 | struct iscsi_cmd *cmd, | 38 | struct iscsi_cmd *cmd, |
39 | u32 exp_data_sn) | 39 | __be32 exp_data_sn) |
40 | { | 40 | { |
41 | u32 data_sn = 0; | 41 | u32 data_sn = 0; |
42 | struct iscsi_conn *conn = cmd->conn; | 42 | struct iscsi_conn *conn = cmd->conn; |
@@ -44,7 +44,7 @@ void iscsit_create_conn_recovery_datain_values( | |||
44 | cmd->next_burst_len = 0; | 44 | cmd->next_burst_len = 0; |
45 | cmd->read_data_done = 0; | 45 | cmd->read_data_done = 0; |
46 | 46 | ||
47 | while (exp_data_sn > data_sn) { | 47 | while (be32_to_cpu(exp_data_sn) > data_sn) { |
48 | if ((cmd->next_burst_len + | 48 | if ((cmd->next_burst_len + |
49 | conn->conn_ops->MaxRecvDataSegmentLength) < | 49 | conn->conn_ops->MaxRecvDataSegmentLength) < |
50 | conn->sess->sess_ops->MaxBurstLength) { | 50 | conn->sess->sess_ops->MaxBurstLength) { |
@@ -193,15 +193,13 @@ int iscsit_remove_active_connection_recovery_entry( | |||
193 | return 0; | 193 | return 0; |
194 | } | 194 | } |
195 | 195 | ||
196 | int iscsit_remove_inactive_connection_recovery_entry( | 196 | static void iscsit_remove_inactive_connection_recovery_entry( |
197 | struct iscsi_conn_recovery *cr, | 197 | struct iscsi_conn_recovery *cr, |
198 | struct iscsi_session *sess) | 198 | struct iscsi_session *sess) |
199 | { | 199 | { |
200 | spin_lock(&sess->cr_i_lock); | 200 | spin_lock(&sess->cr_i_lock); |
201 | list_del(&cr->cr_list); | 201 | list_del(&cr->cr_list); |
202 | spin_unlock(&sess->cr_i_lock); | 202 | spin_unlock(&sess->cr_i_lock); |
203 | |||
204 | return 0; | ||
205 | } | 203 | } |
206 | 204 | ||
207 | /* | 205 | /* |
@@ -421,6 +419,7 @@ int iscsit_prepare_cmds_for_realligance(struct iscsi_conn *conn) | |||
421 | cr->cid = conn->cid; | 419 | cr->cid = conn->cid; |
422 | cr->cmd_count = cmd_count; | 420 | cr->cmd_count = cmd_count; |
423 | cr->maxrecvdatasegmentlength = conn->conn_ops->MaxRecvDataSegmentLength; | 421 | cr->maxrecvdatasegmentlength = conn->conn_ops->MaxRecvDataSegmentLength; |
422 | cr->maxxmitdatasegmentlength = conn->conn_ops->MaxXmitDataSegmentLength; | ||
424 | cr->sess = conn->sess; | 423 | cr->sess = conn->sess; |
425 | 424 | ||
426 | iscsit_attach_inactive_connection_recovery_entry(conn->sess, cr); | 425 | iscsit_attach_inactive_connection_recovery_entry(conn->sess, cr); |
diff --git a/drivers/target/iscsi/iscsi_target_erl2.h b/drivers/target/iscsi/iscsi_target_erl2.h index 22f8d24780a6..63f2501f3fe0 100644 --- a/drivers/target/iscsi/iscsi_target_erl2.h +++ b/drivers/target/iscsi/iscsi_target_erl2.h | |||
@@ -1,7 +1,7 @@ | |||
1 | #ifndef ISCSI_TARGET_ERL2_H | 1 | #ifndef ISCSI_TARGET_ERL2_H |
2 | #define ISCSI_TARGET_ERL2_H | 2 | #define ISCSI_TARGET_ERL2_H |
3 | 3 | ||
4 | extern void iscsit_create_conn_recovery_datain_values(struct iscsi_cmd *, u32); | 4 | extern void iscsit_create_conn_recovery_datain_values(struct iscsi_cmd *, __be32); |
5 | extern void iscsit_create_conn_recovery_dataout_values(struct iscsi_cmd *); | 5 | extern void iscsit_create_conn_recovery_dataout_values(struct iscsi_cmd *); |
6 | extern struct iscsi_conn_recovery *iscsit_get_inactive_connection_recovery_entry( | 6 | extern struct iscsi_conn_recovery *iscsit_get_inactive_connection_recovery_entry( |
7 | struct iscsi_session *, u16); | 7 | struct iscsi_session *, u16); |
diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c index 6aba4395e8d8..cdc8a10939c3 100644 --- a/drivers/target/iscsi/iscsi_target_login.c +++ b/drivers/target/iscsi/iscsi_target_login.c | |||
@@ -39,10 +39,6 @@ | |||
39 | #include "iscsi_target.h" | 39 | #include "iscsi_target.h" |
40 | #include "iscsi_target_parameters.h" | 40 | #include "iscsi_target_parameters.h" |
41 | 41 | ||
42 | extern struct idr sess_idr; | ||
43 | extern struct mutex auth_id_lock; | ||
44 | extern spinlock_t sess_idr_lock; | ||
45 | |||
46 | static int iscsi_login_init_conn(struct iscsi_conn *conn) | 42 | static int iscsi_login_init_conn(struct iscsi_conn *conn) |
47 | { | 43 | { |
48 | INIT_LIST_HEAD(&conn->conn_list); | 44 | INIT_LIST_HEAD(&conn->conn_list); |
@@ -196,10 +192,10 @@ int iscsi_check_for_session_reinstatement(struct iscsi_conn *conn) | |||
196 | static void iscsi_login_set_conn_values( | 192 | static void iscsi_login_set_conn_values( |
197 | struct iscsi_session *sess, | 193 | struct iscsi_session *sess, |
198 | struct iscsi_conn *conn, | 194 | struct iscsi_conn *conn, |
199 | u16 cid) | 195 | __be16 cid) |
200 | { | 196 | { |
201 | conn->sess = sess; | 197 | conn->sess = sess; |
202 | conn->cid = cid; | 198 | conn->cid = be16_to_cpu(cid); |
203 | /* | 199 | /* |
204 | * Generate a random Status sequence number (statsn) for the new | 200 | * Generate a random Status sequence number (statsn) for the new |
205 | * iSCSI connection. | 201 | * iSCSI connection. |
@@ -234,7 +230,7 @@ static int iscsi_login_zero_tsih_s1( | |||
234 | iscsi_login_set_conn_values(sess, conn, pdu->cid); | 230 | iscsi_login_set_conn_values(sess, conn, pdu->cid); |
235 | sess->init_task_tag = pdu->itt; | 231 | sess->init_task_tag = pdu->itt; |
236 | memcpy(&sess->isid, pdu->isid, 6); | 232 | memcpy(&sess->isid, pdu->isid, 6); |
237 | sess->exp_cmd_sn = pdu->cmdsn; | 233 | sess->exp_cmd_sn = be32_to_cpu(pdu->cmdsn); |
238 | INIT_LIST_HEAD(&sess->sess_conn_list); | 234 | INIT_LIST_HEAD(&sess->sess_conn_list); |
239 | INIT_LIST_HEAD(&sess->sess_ooo_cmdsn_list); | 235 | INIT_LIST_HEAD(&sess->sess_ooo_cmdsn_list); |
240 | INIT_LIST_HEAD(&sess->cr_active_list); | 236 | INIT_LIST_HEAD(&sess->cr_active_list); |
@@ -275,7 +271,7 @@ static int iscsi_login_zero_tsih_s1( | |||
275 | * The FFP CmdSN window values will be allocated from the TPG's | 271 | * The FFP CmdSN window values will be allocated from the TPG's |
276 | * Initiator Node's ACL once the login has been successfully completed. | 272 | * Initiator Node's ACL once the login has been successfully completed. |
277 | */ | 273 | */ |
278 | sess->max_cmd_sn = pdu->cmdsn; | 274 | sess->max_cmd_sn = be32_to_cpu(pdu->cmdsn); |
279 | 275 | ||
280 | sess->sess_ops = kzalloc(sizeof(struct iscsi_sess_ops), GFP_KERNEL); | 276 | sess->sess_ops = kzalloc(sizeof(struct iscsi_sess_ops), GFP_KERNEL); |
281 | if (!sess->sess_ops) { | 277 | if (!sess->sess_ops) { |
@@ -453,7 +449,7 @@ static int iscsi_login_non_zero_tsih_s2( | |||
453 | (sess_p->time2retain_timer_flags & ISCSI_TF_EXPIRED)) | 449 | (sess_p->time2retain_timer_flags & ISCSI_TF_EXPIRED)) |
454 | continue; | 450 | continue; |
455 | if (!memcmp(sess_p->isid, pdu->isid, 6) && | 451 | if (!memcmp(sess_p->isid, pdu->isid, 6) && |
456 | (sess_p->tsih == pdu->tsih)) { | 452 | (sess_p->tsih == be16_to_cpu(pdu->tsih))) { |
457 | iscsit_inc_session_usage_count(sess_p); | 453 | iscsit_inc_session_usage_count(sess_p); |
458 | iscsit_stop_time2retain_timer(sess_p); | 454 | iscsit_stop_time2retain_timer(sess_p); |
459 | sess = sess_p; | 455 | sess = sess_p; |
@@ -955,11 +951,7 @@ static int __iscsi_target_login_thread(struct iscsi_np *np) | |||
955 | } | 951 | } |
956 | 952 | ||
957 | pdu = (struct iscsi_login_req *) buffer; | 953 | pdu = (struct iscsi_login_req *) buffer; |
958 | pdu->cid = be16_to_cpu(pdu->cid); | 954 | |
959 | pdu->tsih = be16_to_cpu(pdu->tsih); | ||
960 | pdu->itt = be32_to_cpu(pdu->itt); | ||
961 | pdu->cmdsn = be32_to_cpu(pdu->cmdsn); | ||
962 | pdu->exp_statsn = be32_to_cpu(pdu->exp_statsn); | ||
963 | /* | 955 | /* |
964 | * Used by iscsit_tx_login_rsp() for Login Resonses PDUs | 956 | * Used by iscsit_tx_login_rsp() for Login Resonses PDUs |
965 | * when Status-Class != 0. | 957 | * when Status-Class != 0. |
diff --git a/drivers/target/iscsi/iscsi_target_nego.c b/drivers/target/iscsi/iscsi_target_nego.c index 2dba448cac19..e9053a04f24c 100644 --- a/drivers/target/iscsi/iscsi_target_nego.c +++ b/drivers/target/iscsi/iscsi_target_nego.c | |||
@@ -44,7 +44,7 @@ void convert_null_to_semi(char *buf, int len) | |||
44 | buf[i] = ';'; | 44 | buf[i] = ';'; |
45 | } | 45 | } |
46 | 46 | ||
47 | int strlen_semi(char *buf) | 47 | static int strlen_semi(char *buf) |
48 | { | 48 | { |
49 | int i = 0; | 49 | int i = 0; |
50 | 50 | ||
@@ -339,14 +339,14 @@ static int iscsi_target_do_tx_login_io(struct iscsi_conn *conn, struct iscsi_log | |||
339 | hton24(login_rsp->dlength, login->rsp_length); | 339 | hton24(login_rsp->dlength, login->rsp_length); |
340 | memcpy(login_rsp->isid, login->isid, 6); | 340 | memcpy(login_rsp->isid, login->isid, 6); |
341 | login_rsp->tsih = cpu_to_be16(login->tsih); | 341 | login_rsp->tsih = cpu_to_be16(login->tsih); |
342 | login_rsp->itt = cpu_to_be32(login->init_task_tag); | 342 | login_rsp->itt = login->init_task_tag; |
343 | login_rsp->statsn = cpu_to_be32(conn->stat_sn++); | 343 | login_rsp->statsn = cpu_to_be32(conn->stat_sn++); |
344 | login_rsp->exp_cmdsn = cpu_to_be32(conn->sess->exp_cmd_sn); | 344 | login_rsp->exp_cmdsn = cpu_to_be32(conn->sess->exp_cmd_sn); |
345 | login_rsp->max_cmdsn = cpu_to_be32(conn->sess->max_cmd_sn); | 345 | login_rsp->max_cmdsn = cpu_to_be32(conn->sess->max_cmd_sn); |
346 | 346 | ||
347 | pr_debug("Sending Login Response, Flags: 0x%02x, ITT: 0x%08x," | 347 | pr_debug("Sending Login Response, Flags: 0x%02x, ITT: 0x%08x," |
348 | " ExpCmdSN; 0x%08x, MaxCmdSN: 0x%08x, StatSN: 0x%08x, Length:" | 348 | " ExpCmdSN; 0x%08x, MaxCmdSN: 0x%08x, StatSN: 0x%08x, Length:" |
349 | " %u\n", login_rsp->flags, ntohl(login_rsp->itt), | 349 | " %u\n", login_rsp->flags, (__force u32)login_rsp->itt, |
350 | ntohl(login_rsp->exp_cmdsn), ntohl(login_rsp->max_cmdsn), | 350 | ntohl(login_rsp->exp_cmdsn), ntohl(login_rsp->max_cmdsn), |
351 | ntohl(login_rsp->statsn), login->rsp_length); | 351 | ntohl(login_rsp->statsn), login->rsp_length); |
352 | 352 | ||
@@ -360,12 +360,9 @@ static int iscsi_target_do_tx_login_io(struct iscsi_conn *conn, struct iscsi_log | |||
360 | return -1; | 360 | return -1; |
361 | 361 | ||
362 | login->rsp_length = 0; | 362 | login->rsp_length = 0; |
363 | login_rsp->tsih = be16_to_cpu(login_rsp->tsih); | ||
364 | login_rsp->itt = be32_to_cpu(login_rsp->itt); | ||
365 | login_rsp->statsn = be32_to_cpu(login_rsp->statsn); | ||
366 | mutex_lock(&sess->cmdsn_mutex); | 363 | mutex_lock(&sess->cmdsn_mutex); |
367 | login_rsp->exp_cmdsn = be32_to_cpu(sess->exp_cmd_sn); | 364 | login_rsp->exp_cmdsn = cpu_to_be32(sess->exp_cmd_sn); |
368 | login_rsp->max_cmdsn = be32_to_cpu(sess->max_cmd_sn); | 365 | login_rsp->max_cmdsn = cpu_to_be32(sess->max_cmd_sn); |
369 | mutex_unlock(&sess->cmdsn_mutex); | 366 | mutex_unlock(&sess->cmdsn_mutex); |
370 | 367 | ||
371 | return 0; | 368 | return 0; |
@@ -381,11 +378,6 @@ static int iscsi_target_do_rx_login_io(struct iscsi_conn *conn, struct iscsi_log | |||
381 | 378 | ||
382 | login_req = (struct iscsi_login_req *) login->req; | 379 | login_req = (struct iscsi_login_req *) login->req; |
383 | payload_length = ntoh24(login_req->dlength); | 380 | payload_length = ntoh24(login_req->dlength); |
384 | login_req->tsih = be16_to_cpu(login_req->tsih); | ||
385 | login_req->itt = be32_to_cpu(login_req->itt); | ||
386 | login_req->cid = be16_to_cpu(login_req->cid); | ||
387 | login_req->cmdsn = be32_to_cpu(login_req->cmdsn); | ||
388 | login_req->exp_statsn = be32_to_cpu(login_req->exp_statsn); | ||
389 | 381 | ||
390 | pr_debug("Got Login Command, Flags 0x%02x, ITT: 0x%08x," | 382 | pr_debug("Got Login Command, Flags 0x%02x, ITT: 0x%08x," |
391 | " CmdSN: 0x%08x, ExpStatSN: 0x%08x, CID: %hu, Length: %u\n", | 383 | " CmdSN: 0x%08x, ExpStatSN: 0x%08x, CID: %hu, Length: %u\n", |
@@ -550,7 +542,7 @@ static int iscsi_target_handle_csg_zero( | |||
550 | SENDER_INITIATOR|SENDER_RECEIVER, | 542 | SENDER_INITIATOR|SENDER_RECEIVER, |
551 | login->req_buf, | 543 | login->req_buf, |
552 | payload_length, | 544 | payload_length, |
553 | conn->param_list); | 545 | conn); |
554 | if (ret < 0) | 546 | if (ret < 0) |
555 | return -1; | 547 | return -1; |
556 | 548 | ||
@@ -627,7 +619,7 @@ static int iscsi_target_handle_csg_one(struct iscsi_conn *conn, struct iscsi_log | |||
627 | SENDER_INITIATOR|SENDER_RECEIVER, | 619 | SENDER_INITIATOR|SENDER_RECEIVER, |
628 | login->req_buf, | 620 | login->req_buf, |
629 | payload_length, | 621 | payload_length, |
630 | conn->param_list); | 622 | conn); |
631 | if (ret < 0) | 623 | if (ret < 0) |
632 | return -1; | 624 | return -1; |
633 | 625 | ||
@@ -762,11 +754,11 @@ static int iscsi_target_locate_portal( | |||
762 | login->version_min = login_req->min_version; | 754 | login->version_min = login_req->min_version; |
763 | login->version_max = login_req->max_version; | 755 | login->version_max = login_req->max_version; |
764 | memcpy(login->isid, login_req->isid, 6); | 756 | memcpy(login->isid, login_req->isid, 6); |
765 | login->cmd_sn = login_req->cmdsn; | 757 | login->cmd_sn = be32_to_cpu(login_req->cmdsn); |
766 | login->init_task_tag = login_req->itt; | 758 | login->init_task_tag = login_req->itt; |
767 | login->initial_exp_statsn = login_req->exp_statsn; | 759 | login->initial_exp_statsn = be32_to_cpu(login_req->exp_statsn); |
768 | login->cid = login_req->cid; | 760 | login->cid = be16_to_cpu(login_req->cid); |
769 | login->tsih = login_req->tsih; | 761 | login->tsih = be16_to_cpu(login_req->tsih); |
770 | 762 | ||
771 | if (iscsi_target_get_initial_payload(conn, login) < 0) | 763 | if (iscsi_target_get_initial_payload(conn, login) < 0) |
772 | return -1; | 764 | return -1; |
@@ -1000,7 +992,6 @@ struct iscsi_login *iscsi_target_init_negotiation( | |||
1000 | * Locates Target Portal from NP -> Target IQN | 992 | * Locates Target Portal from NP -> Target IQN |
1001 | */ | 993 | */ |
1002 | if (iscsi_target_locate_portal(np, conn, login) < 0) { | 994 | if (iscsi_target_locate_portal(np, conn, login) < 0) { |
1003 | pr_err("iSCSI Login negotiation failed.\n"); | ||
1004 | goto out; | 995 | goto out; |
1005 | } | 996 | } |
1006 | 997 | ||
diff --git a/drivers/target/iscsi/iscsi_target_parameters.c b/drivers/target/iscsi/iscsi_target_parameters.c index 1e5c5a8587ac..1bf7432bfcbc 100644 --- a/drivers/target/iscsi/iscsi_target_parameters.c +++ b/drivers/target/iscsi/iscsi_target_parameters.c | |||
@@ -334,6 +334,13 @@ int iscsi_create_default_params(struct iscsi_param_list **param_list_ptr) | |||
334 | if (!param) | 334 | if (!param) |
335 | goto out; | 335 | goto out; |
336 | 336 | ||
337 | param = iscsi_set_default_param(pl, MAXXMITDATASEGMENTLENGTH, | ||
338 | INITIAL_MAXXMITDATASEGMENTLENGTH, | ||
339 | PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH, | ||
340 | TYPERANGE_512_TO_16777215, USE_ALL); | ||
341 | if (!param) | ||
342 | goto out; | ||
343 | |||
337 | param = iscsi_set_default_param(pl, MAXRECVDATASEGMENTLENGTH, | 344 | param = iscsi_set_default_param(pl, MAXRECVDATASEGMENTLENGTH, |
338 | INITIAL_MAXRECVDATASEGMENTLENGTH, | 345 | INITIAL_MAXRECVDATASEGMENTLENGTH, |
339 | PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH, | 346 | PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH, |
@@ -467,6 +474,8 @@ int iscsi_set_keys_to_negotiate( | |||
467 | SET_PSTATE_NEGOTIATE(param); | 474 | SET_PSTATE_NEGOTIATE(param); |
468 | } else if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH)) { | 475 | } else if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH)) { |
469 | SET_PSTATE_NEGOTIATE(param); | 476 | SET_PSTATE_NEGOTIATE(param); |
477 | } else if (!strcmp(param->name, MAXXMITDATASEGMENTLENGTH)) { | ||
478 | continue; | ||
470 | } else if (!strcmp(param->name, MAXBURSTLENGTH)) { | 479 | } else if (!strcmp(param->name, MAXBURSTLENGTH)) { |
471 | SET_PSTATE_NEGOTIATE(param); | 480 | SET_PSTATE_NEGOTIATE(param); |
472 | } else if (!strcmp(param->name, FIRSTBURSTLENGTH)) { | 481 | } else if (!strcmp(param->name, FIRSTBURSTLENGTH)) { |
@@ -1056,7 +1065,8 @@ out: | |||
1056 | return proposer_values; | 1065 | return proposer_values; |
1057 | } | 1066 | } |
1058 | 1067 | ||
1059 | static int iscsi_check_acceptor_state(struct iscsi_param *param, char *value) | 1068 | static int iscsi_check_acceptor_state(struct iscsi_param *param, char *value, |
1069 | struct iscsi_conn *conn) | ||
1060 | { | 1070 | { |
1061 | u8 acceptor_boolean_value = 0, proposer_boolean_value = 0; | 1071 | u8 acceptor_boolean_value = 0, proposer_boolean_value = 0; |
1062 | char *negoitated_value = NULL; | 1072 | char *negoitated_value = NULL; |
@@ -1131,8 +1141,35 @@ static int iscsi_check_acceptor_state(struct iscsi_param *param, char *value) | |||
1131 | return -1; | 1141 | return -1; |
1132 | } | 1142 | } |
1133 | 1143 | ||
1134 | if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH)) | 1144 | if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH)) { |
1135 | SET_PSTATE_REPLY_OPTIONAL(param); | 1145 | struct iscsi_param *param_mxdsl; |
1146 | unsigned long long tmp; | ||
1147 | int rc; | ||
1148 | |||
1149 | rc = strict_strtoull(param->value, 0, &tmp); | ||
1150 | if (rc < 0) | ||
1151 | return -1; | ||
1152 | |||
1153 | conn->conn_ops->MaxRecvDataSegmentLength = tmp; | ||
1154 | pr_debug("Saving op->MaxRecvDataSegmentLength from" | ||
1155 | " original initiator received value: %u\n", | ||
1156 | conn->conn_ops->MaxRecvDataSegmentLength); | ||
1157 | |||
1158 | param_mxdsl = iscsi_find_param_from_key( | ||
1159 | MAXXMITDATASEGMENTLENGTH, | ||
1160 | conn->param_list); | ||
1161 | if (!param_mxdsl) | ||
1162 | return -1; | ||
1163 | |||
1164 | rc = iscsi_update_param_value(param, | ||
1165 | param_mxdsl->value); | ||
1166 | if (rc < 0) | ||
1167 | return -1; | ||
1168 | |||
1169 | pr_debug("Updated %s to target MXDSL value: %s\n", | ||
1170 | param->name, param->value); | ||
1171 | } | ||
1172 | |||
1136 | } else if (IS_TYPE_NUMBER_RANGE(param)) { | 1173 | } else if (IS_TYPE_NUMBER_RANGE(param)) { |
1137 | negoitated_value = iscsi_get_value_from_number_range( | 1174 | negoitated_value = iscsi_get_value_from_number_range( |
1138 | param, value); | 1175 | param, value); |
@@ -1527,8 +1564,9 @@ int iscsi_decode_text_input( | |||
1527 | u8 sender, | 1564 | u8 sender, |
1528 | char *textbuf, | 1565 | char *textbuf, |
1529 | u32 length, | 1566 | u32 length, |
1530 | struct iscsi_param_list *param_list) | 1567 | struct iscsi_conn *conn) |
1531 | { | 1568 | { |
1569 | struct iscsi_param_list *param_list = conn->param_list; | ||
1532 | char *tmpbuf, *start = NULL, *end = NULL; | 1570 | char *tmpbuf, *start = NULL, *end = NULL; |
1533 | 1571 | ||
1534 | tmpbuf = kzalloc(length + 1, GFP_KERNEL); | 1572 | tmpbuf = kzalloc(length + 1, GFP_KERNEL); |
@@ -1586,7 +1624,7 @@ int iscsi_decode_text_input( | |||
1586 | } | 1624 | } |
1587 | SET_PSTATE_RESPONSE_GOT(param); | 1625 | SET_PSTATE_RESPONSE_GOT(param); |
1588 | } else { | 1626 | } else { |
1589 | if (iscsi_check_acceptor_state(param, value) < 0) { | 1627 | if (iscsi_check_acceptor_state(param, value, conn) < 0) { |
1590 | kfree(tmpbuf); | 1628 | kfree(tmpbuf); |
1591 | return -1; | 1629 | return -1; |
1592 | } | 1630 | } |
@@ -1721,6 +1759,18 @@ void iscsi_set_connection_parameters( | |||
1721 | pr_debug("---------------------------------------------------" | 1759 | pr_debug("---------------------------------------------------" |
1722 | "---------------\n"); | 1760 | "---------------\n"); |
1723 | list_for_each_entry(param, ¶m_list->param_list, p_list) { | 1761 | list_for_each_entry(param, ¶m_list->param_list, p_list) { |
1762 | /* | ||
1763 | * Special case to set MAXXMITDATASEGMENTLENGTH from the | ||
1764 | * target requested MaxRecvDataSegmentLength, even though | ||
1765 | * this key is not sent over the wire. | ||
1766 | */ | ||
1767 | if (!strcmp(param->name, MAXXMITDATASEGMENTLENGTH)) { | ||
1768 | ops->MaxXmitDataSegmentLength = | ||
1769 | simple_strtoul(param->value, &tmpptr, 0); | ||
1770 | pr_debug("MaxXmitDataSegmentLength: %s\n", | ||
1771 | param->value); | ||
1772 | } | ||
1773 | |||
1724 | if (!IS_PSTATE_ACCEPTOR(param) && !IS_PSTATE_PROPOSER(param)) | 1774 | if (!IS_PSTATE_ACCEPTOR(param) && !IS_PSTATE_PROPOSER(param)) |
1725 | continue; | 1775 | continue; |
1726 | if (!strcmp(param->name, AUTHMETHOD)) { | 1776 | if (!strcmp(param->name, AUTHMETHOD)) { |
@@ -1735,10 +1785,13 @@ void iscsi_set_connection_parameters( | |||
1735 | pr_debug("DataDigest: %s\n", | 1785 | pr_debug("DataDigest: %s\n", |
1736 | param->value); | 1786 | param->value); |
1737 | } else if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH)) { | 1787 | } else if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH)) { |
1738 | ops->MaxRecvDataSegmentLength = | 1788 | /* |
1739 | simple_strtoul(param->value, &tmpptr, 0); | 1789 | * At this point iscsi_check_acceptor_state() will have |
1740 | pr_debug("MaxRecvDataSegmentLength: %s\n", | 1790 | * set ops->MaxRecvDataSegmentLength from the original |
1741 | param->value); | 1791 | * initiator provided value. |
1792 | */ | ||
1793 | pr_debug("MaxRecvDataSegmentLength: %u\n", | ||
1794 | ops->MaxRecvDataSegmentLength); | ||
1742 | } else if (!strcmp(param->name, OFMARKER)) { | 1795 | } else if (!strcmp(param->name, OFMARKER)) { |
1743 | ops->OFMarker = !strcmp(param->value, YES); | 1796 | ops->OFMarker = !strcmp(param->value, YES); |
1744 | pr_debug("OFMarker: %s\n", | 1797 | pr_debug("OFMarker: %s\n", |
diff --git a/drivers/target/iscsi/iscsi_target_parameters.h b/drivers/target/iscsi/iscsi_target_parameters.h index 6a37fd6f1285..1e1b7504a76b 100644 --- a/drivers/target/iscsi/iscsi_target_parameters.h +++ b/drivers/target/iscsi/iscsi_target_parameters.h | |||
@@ -36,7 +36,7 @@ extern void iscsi_release_param_list(struct iscsi_param_list *); | |||
36 | extern struct iscsi_param *iscsi_find_param_from_key(char *, struct iscsi_param_list *); | 36 | extern struct iscsi_param *iscsi_find_param_from_key(char *, struct iscsi_param_list *); |
37 | extern int iscsi_extract_key_value(char *, char **, char **); | 37 | extern int iscsi_extract_key_value(char *, char **, char **); |
38 | extern int iscsi_update_param_value(struct iscsi_param *, char *); | 38 | extern int iscsi_update_param_value(struct iscsi_param *, char *); |
39 | extern int iscsi_decode_text_input(u8, u8, char *, u32, struct iscsi_param_list *); | 39 | extern int iscsi_decode_text_input(u8, u8, char *, u32, struct iscsi_conn *); |
40 | extern int iscsi_encode_text_output(u8, u8, char *, u32 *, | 40 | extern int iscsi_encode_text_output(u8, u8, char *, u32 *, |
41 | struct iscsi_param_list *); | 41 | struct iscsi_param_list *); |
42 | extern int iscsi_check_negotiated_keys(struct iscsi_param_list *); | 42 | extern int iscsi_check_negotiated_keys(struct iscsi_param_list *); |
@@ -70,6 +70,7 @@ extern void iscsi_set_session_parameters(struct iscsi_sess_ops *, | |||
70 | #define INITIALR2T "InitialR2T" | 70 | #define INITIALR2T "InitialR2T" |
71 | #define IMMEDIATEDATA "ImmediateData" | 71 | #define IMMEDIATEDATA "ImmediateData" |
72 | #define MAXRECVDATASEGMENTLENGTH "MaxRecvDataSegmentLength" | 72 | #define MAXRECVDATASEGMENTLENGTH "MaxRecvDataSegmentLength" |
73 | #define MAXXMITDATASEGMENTLENGTH "MaxXmitDataSegmentLength" | ||
73 | #define MAXBURSTLENGTH "MaxBurstLength" | 74 | #define MAXBURSTLENGTH "MaxBurstLength" |
74 | #define FIRSTBURSTLENGTH "FirstBurstLength" | 75 | #define FIRSTBURSTLENGTH "FirstBurstLength" |
75 | #define DEFAULTTIME2WAIT "DefaultTime2Wait" | 76 | #define DEFAULTTIME2WAIT "DefaultTime2Wait" |
@@ -113,6 +114,10 @@ extern void iscsi_set_session_parameters(struct iscsi_sess_ops *, | |||
113 | #define INITIAL_INITIALR2T YES | 114 | #define INITIAL_INITIALR2T YES |
114 | #define INITIAL_IMMEDIATEDATA YES | 115 | #define INITIAL_IMMEDIATEDATA YES |
115 | #define INITIAL_MAXRECVDATASEGMENTLENGTH "8192" | 116 | #define INITIAL_MAXRECVDATASEGMENTLENGTH "8192" |
117 | /* | ||
118 | * Match outgoing MXDSL default to incoming Open-iSCSI default | ||
119 | */ | ||
120 | #define INITIAL_MAXXMITDATASEGMENTLENGTH "262144" | ||
116 | #define INITIAL_MAXBURSTLENGTH "262144" | 121 | #define INITIAL_MAXBURSTLENGTH "262144" |
117 | #define INITIAL_FIRSTBURSTLENGTH "65536" | 122 | #define INITIAL_FIRSTBURSTLENGTH "65536" |
118 | #define INITIAL_DEFAULTTIME2WAIT "2" | 123 | #define INITIAL_DEFAULTTIME2WAIT "2" |
diff --git a/drivers/target/iscsi/iscsi_target_seq_pdu_list.c b/drivers/target/iscsi/iscsi_target_seq_pdu_list.c index 85a306e067ba..edb592a368ef 100644 --- a/drivers/target/iscsi/iscsi_target_seq_pdu_list.c +++ b/drivers/target/iscsi/iscsi_target_seq_pdu_list.c | |||
@@ -219,8 +219,14 @@ static void iscsit_determine_counts_for_list( | |||
219 | int check_immediate = 0; | 219 | int check_immediate = 0; |
220 | u32 burstlength = 0, offset = 0; | 220 | u32 burstlength = 0, offset = 0; |
221 | u32 unsolicited_data_length = 0; | 221 | u32 unsolicited_data_length = 0; |
222 | u32 mdsl; | ||
222 | struct iscsi_conn *conn = cmd->conn; | 223 | struct iscsi_conn *conn = cmd->conn; |
223 | 224 | ||
225 | if (cmd->se_cmd.data_direction == DMA_TO_DEVICE) | ||
226 | mdsl = cmd->conn->conn_ops->MaxXmitDataSegmentLength; | ||
227 | else | ||
228 | mdsl = cmd->conn->conn_ops->MaxRecvDataSegmentLength; | ||
229 | |||
224 | if ((bl->type == PDULIST_IMMEDIATE) || | 230 | if ((bl->type == PDULIST_IMMEDIATE) || |
225 | (bl->type == PDULIST_IMMEDIATE_AND_UNSOLICITED)) | 231 | (bl->type == PDULIST_IMMEDIATE_AND_UNSOLICITED)) |
226 | check_immediate = 1; | 232 | check_immediate = 1; |
@@ -243,14 +249,13 @@ static void iscsit_determine_counts_for_list( | |||
243 | continue; | 249 | continue; |
244 | } | 250 | } |
245 | if (unsolicited_data_length > 0) { | 251 | if (unsolicited_data_length > 0) { |
246 | if ((offset + conn->conn_ops->MaxRecvDataSegmentLength) | 252 | if ((offset + mdsl) >= cmd->se_cmd.data_length) { |
247 | >= cmd->se_cmd.data_length) { | ||
248 | unsolicited_data_length -= | 253 | unsolicited_data_length -= |
249 | (cmd->se_cmd.data_length - offset); | 254 | (cmd->se_cmd.data_length - offset); |
250 | offset += (cmd->se_cmd.data_length - offset); | 255 | offset += (cmd->se_cmd.data_length - offset); |
251 | continue; | 256 | continue; |
252 | } | 257 | } |
253 | if ((offset + conn->conn_ops->MaxRecvDataSegmentLength) | 258 | if ((offset + mdsl) |
254 | >= conn->sess->sess_ops->FirstBurstLength) { | 259 | >= conn->sess->sess_ops->FirstBurstLength) { |
255 | unsolicited_data_length -= | 260 | unsolicited_data_length -= |
256 | (conn->sess->sess_ops->FirstBurstLength - | 261 | (conn->sess->sess_ops->FirstBurstLength - |
@@ -262,17 +267,15 @@ static void iscsit_determine_counts_for_list( | |||
262 | continue; | 267 | continue; |
263 | } | 268 | } |
264 | 269 | ||
265 | offset += conn->conn_ops->MaxRecvDataSegmentLength; | 270 | offset += mdsl; |
266 | unsolicited_data_length -= | 271 | unsolicited_data_length -= mdsl; |
267 | conn->conn_ops->MaxRecvDataSegmentLength; | ||
268 | continue; | 272 | continue; |
269 | } | 273 | } |
270 | if ((offset + conn->conn_ops->MaxRecvDataSegmentLength) >= | 274 | if ((offset + mdsl) >= cmd->se_cmd.data_length) { |
271 | cmd->se_cmd.data_length) { | ||
272 | offset += (cmd->se_cmd.data_length - offset); | 275 | offset += (cmd->se_cmd.data_length - offset); |
273 | continue; | 276 | continue; |
274 | } | 277 | } |
275 | if ((burstlength + conn->conn_ops->MaxRecvDataSegmentLength) >= | 278 | if ((burstlength + mdsl) >= |
276 | conn->sess->sess_ops->MaxBurstLength) { | 279 | conn->sess->sess_ops->MaxBurstLength) { |
277 | offset += (conn->sess->sess_ops->MaxBurstLength - | 280 | offset += (conn->sess->sess_ops->MaxBurstLength - |
278 | burstlength); | 281 | burstlength); |
@@ -281,8 +284,8 @@ static void iscsit_determine_counts_for_list( | |||
281 | continue; | 284 | continue; |
282 | } | 285 | } |
283 | 286 | ||
284 | burstlength += conn->conn_ops->MaxRecvDataSegmentLength; | 287 | burstlength += mdsl; |
285 | offset += conn->conn_ops->MaxRecvDataSegmentLength; | 288 | offset += mdsl; |
286 | } | 289 | } |
287 | } | 290 | } |
288 | 291 | ||
@@ -296,12 +299,17 @@ static int iscsit_do_build_pdu_and_seq_lists( | |||
296 | struct iscsi_build_list *bl) | 299 | struct iscsi_build_list *bl) |
297 | { | 300 | { |
298 | int check_immediate = 0, datapduinorder, datasequenceinorder; | 301 | int check_immediate = 0, datapduinorder, datasequenceinorder; |
299 | u32 burstlength = 0, offset = 0, i = 0; | 302 | u32 burstlength = 0, offset = 0, i = 0, mdsl; |
300 | u32 pdu_count = 0, seq_no = 0, unsolicited_data_length = 0; | 303 | u32 pdu_count = 0, seq_no = 0, unsolicited_data_length = 0; |
301 | struct iscsi_conn *conn = cmd->conn; | 304 | struct iscsi_conn *conn = cmd->conn; |
302 | struct iscsi_pdu *pdu = cmd->pdu_list; | 305 | struct iscsi_pdu *pdu = cmd->pdu_list; |
303 | struct iscsi_seq *seq = cmd->seq_list; | 306 | struct iscsi_seq *seq = cmd->seq_list; |
304 | 307 | ||
308 | if (cmd->se_cmd.data_direction == DMA_TO_DEVICE) | ||
309 | mdsl = cmd->conn->conn_ops->MaxXmitDataSegmentLength; | ||
310 | else | ||
311 | mdsl = cmd->conn->conn_ops->MaxRecvDataSegmentLength; | ||
312 | |||
305 | datapduinorder = conn->sess->sess_ops->DataPDUInOrder; | 313 | datapduinorder = conn->sess->sess_ops->DataPDUInOrder; |
306 | datasequenceinorder = conn->sess->sess_ops->DataSequenceInOrder; | 314 | datasequenceinorder = conn->sess->sess_ops->DataSequenceInOrder; |
307 | 315 | ||
@@ -348,9 +356,7 @@ static int iscsit_do_build_pdu_and_seq_lists( | |||
348 | continue; | 356 | continue; |
349 | } | 357 | } |
350 | if (unsolicited_data_length > 0) { | 358 | if (unsolicited_data_length > 0) { |
351 | if ((offset + | 359 | if ((offset + mdsl) >= cmd->se_cmd.data_length) { |
352 | conn->conn_ops->MaxRecvDataSegmentLength) >= | ||
353 | cmd->se_cmd.data_length) { | ||
354 | if (!datapduinorder) { | 360 | if (!datapduinorder) { |
355 | pdu[i].type = PDUTYPE_UNSOLICITED; | 361 | pdu[i].type = PDUTYPE_UNSOLICITED; |
356 | pdu[i].length = | 362 | pdu[i].length = |
@@ -367,8 +373,7 @@ static int iscsit_do_build_pdu_and_seq_lists( | |||
367 | offset += (cmd->se_cmd.data_length - offset); | 373 | offset += (cmd->se_cmd.data_length - offset); |
368 | continue; | 374 | continue; |
369 | } | 375 | } |
370 | if ((offset + | 376 | if ((offset + mdsl) >= |
371 | conn->conn_ops->MaxRecvDataSegmentLength) >= | ||
372 | conn->sess->sess_ops->FirstBurstLength) { | 377 | conn->sess->sess_ops->FirstBurstLength) { |
373 | if (!datapduinorder) { | 378 | if (!datapduinorder) { |
374 | pdu[i].type = PDUTYPE_UNSOLICITED; | 379 | pdu[i].type = PDUTYPE_UNSOLICITED; |
@@ -396,17 +401,14 @@ static int iscsit_do_build_pdu_and_seq_lists( | |||
396 | 401 | ||
397 | if (!datapduinorder) { | 402 | if (!datapduinorder) { |
398 | pdu[i].type = PDUTYPE_UNSOLICITED; | 403 | pdu[i].type = PDUTYPE_UNSOLICITED; |
399 | pdu[i++].length = | 404 | pdu[i++].length = mdsl; |
400 | conn->conn_ops->MaxRecvDataSegmentLength; | ||
401 | } | 405 | } |
402 | burstlength += conn->conn_ops->MaxRecvDataSegmentLength; | 406 | burstlength += mdsl; |
403 | offset += conn->conn_ops->MaxRecvDataSegmentLength; | 407 | offset += mdsl; |
404 | unsolicited_data_length -= | 408 | unsolicited_data_length -= mdsl; |
405 | conn->conn_ops->MaxRecvDataSegmentLength; | ||
406 | continue; | 409 | continue; |
407 | } | 410 | } |
408 | if ((offset + conn->conn_ops->MaxRecvDataSegmentLength) >= | 411 | if ((offset + mdsl) >= cmd->se_cmd.data_length) { |
409 | cmd->se_cmd.data_length) { | ||
410 | if (!datapduinorder) { | 412 | if (!datapduinorder) { |
411 | pdu[i].type = PDUTYPE_NORMAL; | 413 | pdu[i].type = PDUTYPE_NORMAL; |
412 | pdu[i].length = (cmd->se_cmd.data_length - offset); | 414 | pdu[i].length = (cmd->se_cmd.data_length - offset); |
@@ -420,7 +422,7 @@ static int iscsit_do_build_pdu_and_seq_lists( | |||
420 | offset += (cmd->se_cmd.data_length - offset); | 422 | offset += (cmd->se_cmd.data_length - offset); |
421 | continue; | 423 | continue; |
422 | } | 424 | } |
423 | if ((burstlength + conn->conn_ops->MaxRecvDataSegmentLength) >= | 425 | if ((burstlength + mdsl) >= |
424 | conn->sess->sess_ops->MaxBurstLength) { | 426 | conn->sess->sess_ops->MaxBurstLength) { |
425 | if (!datapduinorder) { | 427 | if (!datapduinorder) { |
426 | pdu[i].type = PDUTYPE_NORMAL; | 428 | pdu[i].type = PDUTYPE_NORMAL; |
@@ -445,11 +447,10 @@ static int iscsit_do_build_pdu_and_seq_lists( | |||
445 | 447 | ||
446 | if (!datapduinorder) { | 448 | if (!datapduinorder) { |
447 | pdu[i].type = PDUTYPE_NORMAL; | 449 | pdu[i].type = PDUTYPE_NORMAL; |
448 | pdu[i++].length = | 450 | pdu[i++].length = mdsl; |
449 | conn->conn_ops->MaxRecvDataSegmentLength; | ||
450 | } | 451 | } |
451 | burstlength += conn->conn_ops->MaxRecvDataSegmentLength; | 452 | burstlength += mdsl; |
452 | offset += conn->conn_ops->MaxRecvDataSegmentLength; | 453 | offset += mdsl; |
453 | } | 454 | } |
454 | 455 | ||
455 | if (!datasequenceinorder) { | 456 | if (!datasequenceinorder) { |
diff --git a/drivers/target/iscsi/iscsi_target_tmr.c b/drivers/target/iscsi/iscsi_target_tmr.c index f62fe123d902..4a99820d063b 100644 --- a/drivers/target/iscsi/iscsi_target_tmr.c +++ b/drivers/target/iscsi/iscsi_target_tmr.c | |||
@@ -50,21 +50,20 @@ u8 iscsit_tmr_abort_task( | |||
50 | if (!ref_cmd) { | 50 | if (!ref_cmd) { |
51 | pr_err("Unable to locate RefTaskTag: 0x%08x on CID:" | 51 | pr_err("Unable to locate RefTaskTag: 0x%08x on CID:" |
52 | " %hu.\n", hdr->rtt, conn->cid); | 52 | " %hu.\n", hdr->rtt, conn->cid); |
53 | return ((hdr->refcmdsn >= conn->sess->exp_cmd_sn) && | 53 | return (be32_to_cpu(hdr->refcmdsn) >= conn->sess->exp_cmd_sn && |
54 | (hdr->refcmdsn <= conn->sess->max_cmd_sn)) ? | 54 | be32_to_cpu(hdr->refcmdsn) <= conn->sess->max_cmd_sn) ? |
55 | ISCSI_TMF_RSP_COMPLETE : ISCSI_TMF_RSP_NO_TASK; | 55 | ISCSI_TMF_RSP_COMPLETE : ISCSI_TMF_RSP_NO_TASK; |
56 | } | 56 | } |
57 | if (ref_cmd->cmd_sn != hdr->refcmdsn) { | 57 | if (ref_cmd->cmd_sn != be32_to_cpu(hdr->refcmdsn)) { |
58 | pr_err("RefCmdSN 0x%08x does not equal" | 58 | pr_err("RefCmdSN 0x%08x does not equal" |
59 | " task's CmdSN 0x%08x. Rejecting ABORT_TASK.\n", | 59 | " task's CmdSN 0x%08x. Rejecting ABORT_TASK.\n", |
60 | hdr->refcmdsn, ref_cmd->cmd_sn); | 60 | hdr->refcmdsn, ref_cmd->cmd_sn); |
61 | return ISCSI_TMF_RSP_REJECTED; | 61 | return ISCSI_TMF_RSP_REJECTED; |
62 | } | 62 | } |
63 | 63 | ||
64 | se_tmr->ref_task_tag = hdr->rtt; | 64 | se_tmr->ref_task_tag = (__force u32)hdr->rtt; |
65 | tmr_req->ref_cmd = ref_cmd; | 65 | tmr_req->ref_cmd = ref_cmd; |
66 | tmr_req->ref_cmd_sn = hdr->refcmdsn; | 66 | tmr_req->exp_data_sn = be32_to_cpu(hdr->exp_datasn); |
67 | tmr_req->exp_data_sn = hdr->exp_datasn; | ||
68 | 67 | ||
69 | return ISCSI_TMF_RSP_COMPLETE; | 68 | return ISCSI_TMF_RSP_COMPLETE; |
70 | } | 69 | } |
@@ -146,7 +145,7 @@ u8 iscsit_tmr_task_reassign( | |||
146 | } | 145 | } |
147 | /* | 146 | /* |
148 | * Temporary check to prevent connection recovery for | 147 | * Temporary check to prevent connection recovery for |
149 | * connections with a differing MaxRecvDataSegmentLength. | 148 | * connections with a differing Max*DataSegmentLength. |
150 | */ | 149 | */ |
151 | if (cr->maxrecvdatasegmentlength != | 150 | if (cr->maxrecvdatasegmentlength != |
152 | conn->conn_ops->MaxRecvDataSegmentLength) { | 151 | conn->conn_ops->MaxRecvDataSegmentLength) { |
@@ -155,6 +154,13 @@ u8 iscsit_tmr_task_reassign( | |||
155 | " TMR TASK_REASSIGN.\n"); | 154 | " TMR TASK_REASSIGN.\n"); |
156 | return ISCSI_TMF_RSP_REJECTED; | 155 | return ISCSI_TMF_RSP_REJECTED; |
157 | } | 156 | } |
157 | if (cr->maxxmitdatasegmentlength != | ||
158 | conn->conn_ops->MaxXmitDataSegmentLength) { | ||
159 | pr_err("Unable to perform connection recovery for" | ||
160 | " differing MaxXmitDataSegmentLength, rejecting" | ||
161 | " TMR TASK_REASSIGN.\n"); | ||
162 | return ISCSI_TMF_RSP_REJECTED; | ||
163 | } | ||
158 | 164 | ||
159 | ref_lun = scsilun_to_int(&hdr->lun); | 165 | ref_lun = scsilun_to_int(&hdr->lun); |
160 | if (ref_lun != ref_cmd->se_cmd.orig_fe_lun) { | 166 | if (ref_lun != ref_cmd->se_cmd.orig_fe_lun) { |
@@ -164,10 +170,9 @@ u8 iscsit_tmr_task_reassign( | |||
164 | return ISCSI_TMF_RSP_REJECTED; | 170 | return ISCSI_TMF_RSP_REJECTED; |
165 | } | 171 | } |
166 | 172 | ||
167 | se_tmr->ref_task_tag = hdr->rtt; | 173 | se_tmr->ref_task_tag = (__force u32)hdr->rtt; |
168 | tmr_req->ref_cmd = ref_cmd; | 174 | tmr_req->ref_cmd = ref_cmd; |
169 | tmr_req->ref_cmd_sn = hdr->refcmdsn; | 175 | tmr_req->exp_data_sn = be32_to_cpu(hdr->exp_datasn); |
170 | tmr_req->exp_data_sn = hdr->exp_datasn; | ||
171 | tmr_req->conn_recovery = cr; | 176 | tmr_req->conn_recovery = cr; |
172 | tmr_req->task_reassign = 1; | 177 | tmr_req->task_reassign = 1; |
173 | /* | 178 | /* |
@@ -455,7 +460,7 @@ static int iscsit_task_reassign_complete( | |||
455 | * Right now the only one that its really needed for is | 460 | * Right now the only one that its really needed for is |
456 | * connection recovery releated TASK_REASSIGN. | 461 | * connection recovery releated TASK_REASSIGN. |
457 | */ | 462 | */ |
458 | extern int iscsit_tmr_post_handler(struct iscsi_cmd *cmd, struct iscsi_conn *conn) | 463 | int iscsit_tmr_post_handler(struct iscsi_cmd *cmd, struct iscsi_conn *conn) |
459 | { | 464 | { |
460 | struct iscsi_tmr_req *tmr_req = cmd->tmr_req; | 465 | struct iscsi_tmr_req *tmr_req = cmd->tmr_req; |
461 | struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req; | 466 | struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req; |
@@ -470,7 +475,7 @@ extern int iscsit_tmr_post_handler(struct iscsi_cmd *cmd, struct iscsi_conn *con | |||
470 | /* | 475 | /* |
471 | * Nothing to do here, but leave it for good measure. :-) | 476 | * Nothing to do here, but leave it for good measure. :-) |
472 | */ | 477 | */ |
473 | int iscsit_task_reassign_prepare_read( | 478 | static int iscsit_task_reassign_prepare_read( |
474 | struct iscsi_tmr_req *tmr_req, | 479 | struct iscsi_tmr_req *tmr_req, |
475 | struct iscsi_conn *conn) | 480 | struct iscsi_conn *conn) |
476 | { | 481 | { |
@@ -545,7 +550,7 @@ static void iscsit_task_reassign_prepare_unsolicited_dataout( | |||
545 | } | 550 | } |
546 | } | 551 | } |
547 | 552 | ||
548 | int iscsit_task_reassign_prepare_write( | 553 | static int iscsit_task_reassign_prepare_write( |
549 | struct iscsi_tmr_req *tmr_req, | 554 | struct iscsi_tmr_req *tmr_req, |
550 | struct iscsi_conn *conn) | 555 | struct iscsi_conn *conn) |
551 | { | 556 | { |
diff --git a/drivers/target/iscsi/iscsi_target_tpg.c b/drivers/target/iscsi/iscsi_target_tpg.c index a38a3f8ab0d9..de9ea32b6104 100644 --- a/drivers/target/iscsi/iscsi_target_tpg.c +++ b/drivers/target/iscsi/iscsi_target_tpg.c | |||
@@ -677,6 +677,12 @@ int iscsit_ta_generate_node_acls( | |||
677 | pr_debug("iSCSI_TPG[%hu] - Generate Initiator Portal Group ACLs: %s\n", | 677 | pr_debug("iSCSI_TPG[%hu] - Generate Initiator Portal Group ACLs: %s\n", |
678 | tpg->tpgt, (a->generate_node_acls) ? "Enabled" : "Disabled"); | 678 | tpg->tpgt, (a->generate_node_acls) ? "Enabled" : "Disabled"); |
679 | 679 | ||
680 | if (flag == 1 && a->cache_dynamic_acls == 0) { | ||
681 | pr_debug("Explicitly setting cache_dynamic_acls=1 when " | ||
682 | "generate_node_acls=1\n"); | ||
683 | a->cache_dynamic_acls = 1; | ||
684 | } | ||
685 | |||
680 | return 0; | 686 | return 0; |
681 | } | 687 | } |
682 | 688 | ||
@@ -716,6 +722,12 @@ int iscsit_ta_cache_dynamic_acls( | |||
716 | return -EINVAL; | 722 | return -EINVAL; |
717 | } | 723 | } |
718 | 724 | ||
725 | if (a->generate_node_acls == 1 && flag == 0) { | ||
726 | pr_debug("Skipping cache_dynamic_acls=0 when" | ||
727 | " generate_node_acls=1\n"); | ||
728 | return 0; | ||
729 | } | ||
730 | |||
719 | a->cache_dynamic_acls = flag; | 731 | a->cache_dynamic_acls = flag; |
720 | pr_debug("iSCSI_TPG[%hu] - Cache Dynamic Initiator Portal Group" | 732 | pr_debug("iSCSI_TPG[%hu] - Cache Dynamic Initiator Portal Group" |
721 | " ACLs %s\n", tpg->tpgt, (a->cache_dynamic_acls) ? | 733 | " ACLs %s\n", tpg->tpgt, (a->cache_dynamic_acls) ? |
diff --git a/drivers/target/iscsi/iscsi_target_tq.c b/drivers/target/iscsi/iscsi_target_tq.c index 977e1cf90e83..9d881a000e42 100644 --- a/drivers/target/iscsi/iscsi_target_tq.c +++ b/drivers/target/iscsi/iscsi_target_tq.c | |||
@@ -40,7 +40,7 @@ static void iscsi_add_ts_to_active_list(struct iscsi_thread_set *ts) | |||
40 | spin_unlock(&active_ts_lock); | 40 | spin_unlock(&active_ts_lock); |
41 | } | 41 | } |
42 | 42 | ||
43 | extern void iscsi_add_ts_to_inactive_list(struct iscsi_thread_set *ts) | 43 | static void iscsi_add_ts_to_inactive_list(struct iscsi_thread_set *ts) |
44 | { | 44 | { |
45 | spin_lock(&inactive_ts_lock); | 45 | spin_lock(&inactive_ts_lock); |
46 | list_add_tail(&ts->ts_list, &inactive_ts_list); | 46 | list_add_tail(&ts->ts_list, &inactive_ts_list); |
@@ -76,7 +76,7 @@ static struct iscsi_thread_set *iscsi_get_ts_from_inactive_list(void) | |||
76 | return ts; | 76 | return ts; |
77 | } | 77 | } |
78 | 78 | ||
79 | extern int iscsi_allocate_thread_sets(u32 thread_pair_count) | 79 | int iscsi_allocate_thread_sets(u32 thread_pair_count) |
80 | { | 80 | { |
81 | int allocated_thread_pair_count = 0, i, thread_id; | 81 | int allocated_thread_pair_count = 0, i, thread_id; |
82 | struct iscsi_thread_set *ts = NULL; | 82 | struct iscsi_thread_set *ts = NULL; |
@@ -140,7 +140,7 @@ extern int iscsi_allocate_thread_sets(u32 thread_pair_count) | |||
140 | return allocated_thread_pair_count; | 140 | return allocated_thread_pair_count; |
141 | } | 141 | } |
142 | 142 | ||
143 | extern void iscsi_deallocate_thread_sets(void) | 143 | void iscsi_deallocate_thread_sets(void) |
144 | { | 144 | { |
145 | u32 released_count = 0; | 145 | u32 released_count = 0; |
146 | struct iscsi_thread_set *ts = NULL; | 146 | struct iscsi_thread_set *ts = NULL; |
diff --git a/drivers/target/iscsi/iscsi_target_tq.h b/drivers/target/iscsi/iscsi_target_tq.h index 26e6a95ec203..547d11831282 100644 --- a/drivers/target/iscsi/iscsi_target_tq.h +++ b/drivers/target/iscsi/iscsi_target_tq.h | |||
@@ -5,7 +5,6 @@ | |||
5 | * Defines for thread sets. | 5 | * Defines for thread sets. |
6 | */ | 6 | */ |
7 | extern int iscsi_thread_set_force_reinstatement(struct iscsi_conn *); | 7 | extern int iscsi_thread_set_force_reinstatement(struct iscsi_conn *); |
8 | extern void iscsi_add_ts_to_inactive_list(struct iscsi_thread_set *); | ||
9 | extern int iscsi_allocate_thread_sets(u32); | 8 | extern int iscsi_allocate_thread_sets(u32); |
10 | extern void iscsi_deallocate_thread_sets(void); | 9 | extern void iscsi_deallocate_thread_sets(void); |
11 | extern void iscsi_activate_thread_set(struct iscsi_conn *, struct iscsi_thread_set *); | 10 | extern void iscsi_activate_thread_set(struct iscsi_conn *, struct iscsi_thread_set *); |
diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c index b42cdeb153df..afd98ccd40ae 100644 --- a/drivers/target/iscsi/iscsi_target_util.c +++ b/drivers/target/iscsi/iscsi_target_util.c | |||
@@ -274,14 +274,14 @@ static inline int iscsit_check_received_cmdsn(struct iscsi_session *sess, u32 cm | |||
274 | int iscsit_sequence_cmd( | 274 | int iscsit_sequence_cmd( |
275 | struct iscsi_conn *conn, | 275 | struct iscsi_conn *conn, |
276 | struct iscsi_cmd *cmd, | 276 | struct iscsi_cmd *cmd, |
277 | u32 cmdsn) | 277 | __be32 cmdsn) |
278 | { | 278 | { |
279 | int ret; | 279 | int ret; |
280 | int cmdsn_ret; | 280 | int cmdsn_ret; |
281 | 281 | ||
282 | mutex_lock(&conn->sess->cmdsn_mutex); | 282 | mutex_lock(&conn->sess->cmdsn_mutex); |
283 | 283 | ||
284 | cmdsn_ret = iscsit_check_received_cmdsn(conn->sess, cmdsn); | 284 | cmdsn_ret = iscsit_check_received_cmdsn(conn->sess, be32_to_cpu(cmdsn)); |
285 | switch (cmdsn_ret) { | 285 | switch (cmdsn_ret) { |
286 | case CMDSN_NORMAL_OPERATION: | 286 | case CMDSN_NORMAL_OPERATION: |
287 | ret = iscsit_execute_cmd(cmd, 0); | 287 | ret = iscsit_execute_cmd(cmd, 0); |
@@ -289,7 +289,7 @@ int iscsit_sequence_cmd( | |||
289 | iscsit_execute_ooo_cmdsns(conn->sess); | 289 | iscsit_execute_ooo_cmdsns(conn->sess); |
290 | break; | 290 | break; |
291 | case CMDSN_HIGHER_THAN_EXP: | 291 | case CMDSN_HIGHER_THAN_EXP: |
292 | ret = iscsit_handle_ooo_cmdsn(conn->sess, cmd, cmdsn); | 292 | ret = iscsit_handle_ooo_cmdsn(conn->sess, cmd, be32_to_cpu(cmdsn)); |
293 | break; | 293 | break; |
294 | case CMDSN_LOWER_THAN_EXP: | 294 | case CMDSN_LOWER_THAN_EXP: |
295 | cmd->i_state = ISTATE_REMOVE; | 295 | cmd->i_state = ISTATE_REMOVE; |
@@ -351,7 +351,7 @@ int iscsit_check_unsolicited_dataout(struct iscsi_cmd *cmd, unsigned char *buf) | |||
351 | 351 | ||
352 | struct iscsi_cmd *iscsit_find_cmd_from_itt( | 352 | struct iscsi_cmd *iscsit_find_cmd_from_itt( |
353 | struct iscsi_conn *conn, | 353 | struct iscsi_conn *conn, |
354 | u32 init_task_tag) | 354 | itt_t init_task_tag) |
355 | { | 355 | { |
356 | struct iscsi_cmd *cmd; | 356 | struct iscsi_cmd *cmd; |
357 | 357 | ||
@@ -371,7 +371,7 @@ struct iscsi_cmd *iscsit_find_cmd_from_itt( | |||
371 | 371 | ||
372 | struct iscsi_cmd *iscsit_find_cmd_from_itt_or_dump( | 372 | struct iscsi_cmd *iscsit_find_cmd_from_itt_or_dump( |
373 | struct iscsi_conn *conn, | 373 | struct iscsi_conn *conn, |
374 | u32 init_task_tag, | 374 | itt_t init_task_tag, |
375 | u32 length) | 375 | u32 length) |
376 | { | 376 | { |
377 | struct iscsi_cmd *cmd; | 377 | struct iscsi_cmd *cmd; |
@@ -417,7 +417,7 @@ int iscsit_find_cmd_for_recovery( | |||
417 | struct iscsi_session *sess, | 417 | struct iscsi_session *sess, |
418 | struct iscsi_cmd **cmd_ptr, | 418 | struct iscsi_cmd **cmd_ptr, |
419 | struct iscsi_conn_recovery **cr_ptr, | 419 | struct iscsi_conn_recovery **cr_ptr, |
420 | u32 init_task_tag) | 420 | itt_t init_task_tag) |
421 | { | 421 | { |
422 | struct iscsi_cmd *cmd = NULL; | 422 | struct iscsi_cmd *cmd = NULL; |
423 | struct iscsi_conn_recovery *cr; | 423 | struct iscsi_conn_recovery *cr; |
@@ -855,7 +855,7 @@ static int iscsit_add_nopin(struct iscsi_conn *conn, int want_response) | |||
855 | cmd->iscsi_opcode = ISCSI_OP_NOOP_IN; | 855 | cmd->iscsi_opcode = ISCSI_OP_NOOP_IN; |
856 | state = (want_response) ? ISTATE_SEND_NOPIN_WANT_RESPONSE : | 856 | state = (want_response) ? ISTATE_SEND_NOPIN_WANT_RESPONSE : |
857 | ISTATE_SEND_NOPIN_NO_RESPONSE; | 857 | ISTATE_SEND_NOPIN_NO_RESPONSE; |
858 | cmd->init_task_tag = 0xFFFFFFFF; | 858 | cmd->init_task_tag = RESERVED_ITT; |
859 | spin_lock_bh(&conn->sess->ttt_lock); | 859 | spin_lock_bh(&conn->sess->ttt_lock); |
860 | cmd->targ_xfer_tag = (want_response) ? conn->sess->targ_xfer_tag++ : | 860 | cmd->targ_xfer_tag = (want_response) ? conn->sess->targ_xfer_tag++ : |
861 | 0xFFFFFFFF; | 861 | 0xFFFFFFFF; |
@@ -1222,7 +1222,7 @@ int iscsit_tx_login_rsp(struct iscsi_conn *conn, u8 status_class, u8 status_deta | |||
1222 | hdr->opcode = ISCSI_OP_LOGIN_RSP; | 1222 | hdr->opcode = ISCSI_OP_LOGIN_RSP; |
1223 | hdr->status_class = status_class; | 1223 | hdr->status_class = status_class; |
1224 | hdr->status_detail = status_detail; | 1224 | hdr->status_detail = status_detail; |
1225 | hdr->itt = cpu_to_be32(conn->login_itt); | 1225 | hdr->itt = conn->login_itt; |
1226 | 1226 | ||
1227 | iov.iov_base = &iscsi_hdr; | 1227 | iov.iov_base = &iscsi_hdr; |
1228 | iov.iov_len = ISCSI_HDR_LEN; | 1228 | iov.iov_len = ISCSI_HDR_LEN; |
diff --git a/drivers/target/iscsi/iscsi_target_util.h b/drivers/target/iscsi/iscsi_target_util.h index e1c729b8a1c5..44054bd35437 100644 --- a/drivers/target/iscsi/iscsi_target_util.h +++ b/drivers/target/iscsi/iscsi_target_util.h | |||
@@ -12,14 +12,14 @@ extern struct iscsi_cmd *iscsit_allocate_cmd(struct iscsi_conn *, gfp_t); | |||
12 | extern struct iscsi_seq *iscsit_get_seq_holder_for_datain(struct iscsi_cmd *, u32); | 12 | extern struct iscsi_seq *iscsit_get_seq_holder_for_datain(struct iscsi_cmd *, u32); |
13 | extern struct iscsi_seq *iscsit_get_seq_holder_for_r2t(struct iscsi_cmd *); | 13 | extern struct iscsi_seq *iscsit_get_seq_holder_for_r2t(struct iscsi_cmd *); |
14 | extern struct iscsi_r2t *iscsit_get_holder_for_r2tsn(struct iscsi_cmd *, u32); | 14 | extern struct iscsi_r2t *iscsit_get_holder_for_r2tsn(struct iscsi_cmd *, u32); |
15 | int iscsit_sequence_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, u32 cmdsn); | 15 | int iscsit_sequence_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd, __be32 cmdsn); |
16 | extern int iscsit_check_unsolicited_dataout(struct iscsi_cmd *, unsigned char *); | 16 | extern int iscsit_check_unsolicited_dataout(struct iscsi_cmd *, unsigned char *); |
17 | extern struct iscsi_cmd *iscsit_find_cmd_from_itt(struct iscsi_conn *, u32); | 17 | extern struct iscsi_cmd *iscsit_find_cmd_from_itt(struct iscsi_conn *, itt_t); |
18 | extern struct iscsi_cmd *iscsit_find_cmd_from_itt_or_dump(struct iscsi_conn *, | 18 | extern struct iscsi_cmd *iscsit_find_cmd_from_itt_or_dump(struct iscsi_conn *, |
19 | u32, u32); | 19 | itt_t, u32); |
20 | extern struct iscsi_cmd *iscsit_find_cmd_from_ttt(struct iscsi_conn *, u32); | 20 | extern struct iscsi_cmd *iscsit_find_cmd_from_ttt(struct iscsi_conn *, u32); |
21 | extern int iscsit_find_cmd_for_recovery(struct iscsi_session *, struct iscsi_cmd **, | 21 | extern int iscsit_find_cmd_for_recovery(struct iscsi_session *, struct iscsi_cmd **, |
22 | struct iscsi_conn_recovery **, u32); | 22 | struct iscsi_conn_recovery **, itt_t); |
23 | extern void iscsit_add_cmd_to_immediate_queue(struct iscsi_cmd *, struct iscsi_conn *, u8); | 23 | extern void iscsit_add_cmd_to_immediate_queue(struct iscsi_cmd *, struct iscsi_conn *, u8); |
24 | extern struct iscsi_queue_req *iscsit_get_cmd_from_immediate_queue(struct iscsi_conn *); | 24 | extern struct iscsi_queue_req *iscsit_get_cmd_from_immediate_queue(struct iscsi_conn *); |
25 | extern void iscsit_add_cmd_to_response_queue(struct iscsi_cmd *, struct iscsi_conn *, u8); | 25 | extern void iscsit_add_cmd_to_response_queue(struct iscsi_cmd *, struct iscsi_conn *, u8); |
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index 5491c632a15e..2d444b1ccd33 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c | |||
@@ -166,7 +166,7 @@ static void tcm_loop_submission_work(struct work_struct *work) | |||
166 | struct tcm_loop_tpg *tl_tpg; | 166 | struct tcm_loop_tpg *tl_tpg; |
167 | struct scatterlist *sgl_bidi = NULL; | 167 | struct scatterlist *sgl_bidi = NULL; |
168 | u32 sgl_bidi_count = 0; | 168 | u32 sgl_bidi_count = 0; |
169 | int ret; | 169 | int rc; |
170 | 170 | ||
171 | tl_hba = *(struct tcm_loop_hba **)shost_priv(sc->device->host); | 171 | tl_hba = *(struct tcm_loop_hba **)shost_priv(sc->device->host); |
172 | tl_tpg = &tl_hba->tl_hba_tpgs[sc->device->id]; | 172 | tl_tpg = &tl_hba->tl_hba_tpgs[sc->device->id]; |
@@ -187,12 +187,6 @@ static void tcm_loop_submission_work(struct work_struct *work) | |||
187 | set_host_byte(sc, DID_ERROR); | 187 | set_host_byte(sc, DID_ERROR); |
188 | goto out_done; | 188 | goto out_done; |
189 | } | 189 | } |
190 | |||
191 | transport_init_se_cmd(se_cmd, tl_tpg->tl_se_tpg.se_tpg_tfo, | ||
192 | tl_nexus->se_sess, | ||
193 | scsi_bufflen(sc), sc->sc_data_direction, | ||
194 | tcm_loop_sam_attr(sc), &tl_cmd->tl_sense_buf[0]); | ||
195 | |||
196 | if (scsi_bidi_cmnd(sc)) { | 190 | if (scsi_bidi_cmnd(sc)) { |
197 | struct scsi_data_buffer *sdb = scsi_in(sc); | 191 | struct scsi_data_buffer *sdb = scsi_in(sc); |
198 | 192 | ||
@@ -201,56 +195,16 @@ static void tcm_loop_submission_work(struct work_struct *work) | |||
201 | se_cmd->se_cmd_flags |= SCF_BIDI; | 195 | se_cmd->se_cmd_flags |= SCF_BIDI; |
202 | 196 | ||
203 | } | 197 | } |
204 | 198 | rc = target_submit_cmd_map_sgls(se_cmd, tl_nexus->se_sess, sc->cmnd, | |
205 | if (transport_lookup_cmd_lun(se_cmd, tl_cmd->sc->device->lun) < 0) { | 199 | &tl_cmd->tl_sense_buf[0], tl_cmd->sc->device->lun, |
206 | kmem_cache_free(tcm_loop_cmd_cache, tl_cmd); | 200 | scsi_bufflen(sc), tcm_loop_sam_attr(sc), |
201 | sc->sc_data_direction, 0, | ||
202 | scsi_sglist(sc), scsi_sg_count(sc), | ||
203 | sgl_bidi, sgl_bidi_count); | ||
204 | if (rc < 0) { | ||
207 | set_host_byte(sc, DID_NO_CONNECT); | 205 | set_host_byte(sc, DID_NO_CONNECT); |
208 | goto out_done; | 206 | goto out_done; |
209 | } | 207 | } |
210 | |||
211 | /* | ||
212 | * Because some userspace code via scsi-generic do not memset their | ||
213 | * associated read buffers, go ahead and do that here for type | ||
214 | * non-data CDBs. Also note that this is currently guaranteed to be a | ||
215 | * single SGL for this case by target core in | ||
216 | * target_setup_cmd_from_cdb() -> transport_generic_cmd_sequencer(). | ||
217 | */ | ||
218 | if (!(se_cmd->se_cmd_flags & SCF_SCSI_DATA_CDB) && | ||
219 | se_cmd->data_direction == DMA_FROM_DEVICE) { | ||
220 | struct scatterlist *sg = scsi_sglist(sc); | ||
221 | unsigned char *buf = kmap(sg_page(sg)) + sg->offset; | ||
222 | |||
223 | if (buf != NULL) { | ||
224 | memset(buf, 0, sg->length); | ||
225 | kunmap(sg_page(sg)); | ||
226 | } | ||
227 | } | ||
228 | |||
229 | ret = target_setup_cmd_from_cdb(se_cmd, sc->cmnd); | ||
230 | if (ret == -ENOMEM) { | ||
231 | transport_send_check_condition_and_sense(se_cmd, | ||
232 | TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE, 0); | ||
233 | transport_generic_free_cmd(se_cmd, 0); | ||
234 | return; | ||
235 | } else if (ret < 0) { | ||
236 | if (se_cmd->se_cmd_flags & SCF_SCSI_RESERVATION_CONFLICT) | ||
237 | tcm_loop_queue_status(se_cmd); | ||
238 | else | ||
239 | transport_send_check_condition_and_sense(se_cmd, | ||
240 | se_cmd->scsi_sense_reason, 0); | ||
241 | transport_generic_free_cmd(se_cmd, 0); | ||
242 | return; | ||
243 | } | ||
244 | |||
245 | ret = transport_generic_map_mem_to_cmd(se_cmd, scsi_sglist(sc), | ||
246 | scsi_sg_count(sc), sgl_bidi, sgl_bidi_count); | ||
247 | if (ret) { | ||
248 | transport_send_check_condition_and_sense(se_cmd, | ||
249 | se_cmd->scsi_sense_reason, 0); | ||
250 | transport_generic_free_cmd(se_cmd, 0); | ||
251 | return; | ||
252 | } | ||
253 | transport_handle_cdb_direct(se_cmd); | ||
254 | return; | 208 | return; |
255 | 209 | ||
256 | out_done: | 210 | out_done: |
@@ -846,16 +800,6 @@ static int tcm_loop_queue_tm_rsp(struct se_cmd *se_cmd) | |||
846 | return 0; | 800 | return 0; |
847 | } | 801 | } |
848 | 802 | ||
849 | static u16 tcm_loop_set_fabric_sense_len(struct se_cmd *se_cmd, u32 sense_length) | ||
850 | { | ||
851 | return 0; | ||
852 | } | ||
853 | |||
854 | static u16 tcm_loop_get_fabric_sense_len(void) | ||
855 | { | ||
856 | return 0; | ||
857 | } | ||
858 | |||
859 | static char *tcm_loop_dump_proto_id(struct tcm_loop_hba *tl_hba) | 803 | static char *tcm_loop_dump_proto_id(struct tcm_loop_hba *tl_hba) |
860 | { | 804 | { |
861 | switch (tl_hba->tl_proto_id) { | 805 | switch (tl_hba->tl_proto_id) { |
@@ -1373,8 +1317,6 @@ static int tcm_loop_register_configfs(void) | |||
1373 | fabric->tf_ops.queue_data_in = &tcm_loop_queue_data_in; | 1317 | fabric->tf_ops.queue_data_in = &tcm_loop_queue_data_in; |
1374 | fabric->tf_ops.queue_status = &tcm_loop_queue_status; | 1318 | fabric->tf_ops.queue_status = &tcm_loop_queue_status; |
1375 | fabric->tf_ops.queue_tm_rsp = &tcm_loop_queue_tm_rsp; | 1319 | fabric->tf_ops.queue_tm_rsp = &tcm_loop_queue_tm_rsp; |
1376 | fabric->tf_ops.set_fabric_sense_len = &tcm_loop_set_fabric_sense_len; | ||
1377 | fabric->tf_ops.get_fabric_sense_len = &tcm_loop_get_fabric_sense_len; | ||
1378 | 1320 | ||
1379 | /* | 1321 | /* |
1380 | * Setup function pointers for generic logic in target_core_fabric_configfs.c | 1322 | * Setup function pointers for generic logic in target_core_fabric_configfs.c |
diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c index 39ddba584b30..0d6d7c1f025e 100644 --- a/drivers/target/sbp/sbp_target.c +++ b/drivers/target/sbp/sbp_target.c | |||
@@ -660,8 +660,7 @@ static void session_reconnect_expired(struct sbp_session *sess) | |||
660 | spin_lock_bh(&sess->lock); | 660 | spin_lock_bh(&sess->lock); |
661 | list_for_each_entry_safe(login, temp, &sess->login_list, link) { | 661 | list_for_each_entry_safe(login, temp, &sess->login_list, link) { |
662 | login->sess = NULL; | 662 | login->sess = NULL; |
663 | list_del(&login->link); | 663 | list_move_tail(&login->link, &login_list); |
664 | list_add_tail(&login->link, &login_list); | ||
665 | } | 664 | } |
666 | spin_unlock_bh(&sess->lock); | 665 | spin_unlock_bh(&sess->lock); |
667 | 666 | ||
@@ -1847,16 +1846,6 @@ static int sbp_queue_tm_rsp(struct se_cmd *se_cmd) | |||
1847 | return 0; | 1846 | return 0; |
1848 | } | 1847 | } |
1849 | 1848 | ||
1850 | static u16 sbp_set_fabric_sense_len(struct se_cmd *se_cmd, u32 sense_length) | ||
1851 | { | ||
1852 | return 0; | ||
1853 | } | ||
1854 | |||
1855 | static u16 sbp_get_fabric_sense_len(void) | ||
1856 | { | ||
1857 | return 0; | ||
1858 | } | ||
1859 | |||
1860 | static int sbp_check_stop_free(struct se_cmd *se_cmd) | 1849 | static int sbp_check_stop_free(struct se_cmd *se_cmd) |
1861 | { | 1850 | { |
1862 | struct sbp_target_request *req = container_of(se_cmd, | 1851 | struct sbp_target_request *req = container_of(se_cmd, |
@@ -2068,7 +2057,7 @@ static int sbp_update_unit_directory(struct sbp_tport *tport) | |||
2068 | return ret; | 2057 | return ret; |
2069 | } | 2058 | } |
2070 | 2059 | ||
2071 | static ssize_t sbp_parse_wwn(const char *name, u64 *wwn, int strict) | 2060 | static ssize_t sbp_parse_wwn(const char *name, u64 *wwn) |
2072 | { | 2061 | { |
2073 | const char *cp; | 2062 | const char *cp; |
2074 | char c, nibble; | 2063 | char c, nibble; |
@@ -2088,7 +2077,7 @@ static ssize_t sbp_parse_wwn(const char *name, u64 *wwn, int strict) | |||
2088 | err = 3; | 2077 | err = 3; |
2089 | if (isdigit(c)) | 2078 | if (isdigit(c)) |
2090 | nibble = c - '0'; | 2079 | nibble = c - '0'; |
2091 | else if (isxdigit(c) && (islower(c) || !strict)) | 2080 | else if (isxdigit(c)) |
2092 | nibble = tolower(c) - 'a' + 10; | 2081 | nibble = tolower(c) - 'a' + 10; |
2093 | else | 2082 | else |
2094 | goto fail; | 2083 | goto fail; |
@@ -2117,7 +2106,7 @@ static struct se_node_acl *sbp_make_nodeacl( | |||
2117 | u64 guid = 0; | 2106 | u64 guid = 0; |
2118 | u32 nexus_depth = 1; | 2107 | u32 nexus_depth = 1; |
2119 | 2108 | ||
2120 | if (sbp_parse_wwn(name, &guid, 1) < 0) | 2109 | if (sbp_parse_wwn(name, &guid) < 0) |
2121 | return ERR_PTR(-EINVAL); | 2110 | return ERR_PTR(-EINVAL); |
2122 | 2111 | ||
2123 | se_nacl_new = sbp_alloc_fabric_acl(se_tpg); | 2112 | se_nacl_new = sbp_alloc_fabric_acl(se_tpg); |
@@ -2253,7 +2242,7 @@ static struct se_wwn *sbp_make_tport( | |||
2253 | struct sbp_tport *tport; | 2242 | struct sbp_tport *tport; |
2254 | u64 guid = 0; | 2243 | u64 guid = 0; |
2255 | 2244 | ||
2256 | if (sbp_parse_wwn(name, &guid, 1) < 0) | 2245 | if (sbp_parse_wwn(name, &guid) < 0) |
2257 | return ERR_PTR(-EINVAL); | 2246 | return ERR_PTR(-EINVAL); |
2258 | 2247 | ||
2259 | tport = kzalloc(sizeof(*tport), GFP_KERNEL); | 2248 | tport = kzalloc(sizeof(*tport), GFP_KERNEL); |
@@ -2534,8 +2523,6 @@ static struct target_core_fabric_ops sbp_ops = { | |||
2534 | .queue_data_in = sbp_queue_data_in, | 2523 | .queue_data_in = sbp_queue_data_in, |
2535 | .queue_status = sbp_queue_status, | 2524 | .queue_status = sbp_queue_status, |
2536 | .queue_tm_rsp = sbp_queue_tm_rsp, | 2525 | .queue_tm_rsp = sbp_queue_tm_rsp, |
2537 | .get_fabric_sense_len = sbp_get_fabric_sense_len, | ||
2538 | .set_fabric_sense_len = sbp_set_fabric_sense_len, | ||
2539 | .check_stop_free = sbp_check_stop_free, | 2526 | .check_stop_free = sbp_check_stop_free, |
2540 | 2527 | ||
2541 | .fabric_make_wwn = sbp_make_tport, | 2528 | .fabric_make_wwn = sbp_make_tport, |
@@ -2556,9 +2543,9 @@ static int sbp_register_configfs(void) | |||
2556 | int ret; | 2543 | int ret; |
2557 | 2544 | ||
2558 | fabric = target_fabric_configfs_init(THIS_MODULE, "sbp"); | 2545 | fabric = target_fabric_configfs_init(THIS_MODULE, "sbp"); |
2559 | if (!fabric) { | 2546 | if (IS_ERR(fabric)) { |
2560 | pr_err("target_fabric_configfs_init() failed\n"); | 2547 | pr_err("target_fabric_configfs_init() failed\n"); |
2561 | return -ENOMEM; | 2548 | return PTR_ERR(fabric); |
2562 | } | 2549 | } |
2563 | 2550 | ||
2564 | fabric->tf_ops = sbp_ops; | 2551 | fabric->tf_ops = sbp_ops; |
diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c index 41641ba54828..9a5f9a7aecd2 100644 --- a/drivers/target/target_core_alua.c +++ b/drivers/target/target_core_alua.c | |||
@@ -344,7 +344,7 @@ int target_emulate_set_target_port_groups(struct se_cmd *cmd) | |||
344 | */ | 344 | */ |
345 | rtpi = get_unaligned_be16(ptr + 2); | 345 | rtpi = get_unaligned_be16(ptr + 2); |
346 | /* | 346 | /* |
347 | * Locate the matching relative target port identifer | 347 | * Locate the matching relative target port identifier |
348 | * for the struct se_device storage object. | 348 | * for the struct se_device storage object. |
349 | */ | 349 | */ |
350 | spin_lock(&dev->se_port_lock); | 350 | spin_lock(&dev->se_port_lock); |
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index 801efa892046..015f5be27bf6 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c | |||
@@ -457,14 +457,6 @@ static int target_fabric_tf_ops_check( | |||
457 | pr_err("Missing tfo->queue_tm_rsp()\n"); | 457 | pr_err("Missing tfo->queue_tm_rsp()\n"); |
458 | return -EINVAL; | 458 | return -EINVAL; |
459 | } | 459 | } |
460 | if (!tfo->set_fabric_sense_len) { | ||
461 | pr_err("Missing tfo->set_fabric_sense_len()\n"); | ||
462 | return -EINVAL; | ||
463 | } | ||
464 | if (!tfo->get_fabric_sense_len) { | ||
465 | pr_err("Missing tfo->get_fabric_sense_len()\n"); | ||
466 | return -EINVAL; | ||
467 | } | ||
468 | /* | 460 | /* |
469 | * We at least require tfo->fabric_make_wwn(), tfo->fabric_drop_wwn() | 461 | * We at least require tfo->fabric_make_wwn(), tfo->fabric_drop_wwn() |
470 | * tfo->fabric_make_tpg() and tfo->fabric_drop_tpg() in | 462 | * tfo->fabric_make_tpg() and tfo->fabric_drop_tpg() in |
@@ -1208,7 +1200,7 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_holder_tg_port( | |||
1208 | " Target Node Endpoint: %s\n", tfo->get_fabric_name(), | 1200 | " Target Node Endpoint: %s\n", tfo->get_fabric_name(), |
1209 | tfo->tpg_get_wwn(se_tpg)); | 1201 | tfo->tpg_get_wwn(se_tpg)); |
1210 | len += sprintf(page+len, "SPC-3 Reservation: Relative Port" | 1202 | len += sprintf(page+len, "SPC-3 Reservation: Relative Port" |
1211 | " Identifer Tag: %hu %s Portal Group Tag: %hu" | 1203 | " Identifier Tag: %hu %s Portal Group Tag: %hu" |
1212 | " %s Logical Unit: %u\n", lun->lun_sep->sep_rtpi, | 1204 | " %s Logical Unit: %u\n", lun->lun_sep->sep_rtpi, |
1213 | tfo->get_fabric_name(), tfo->tpg_get_tag(se_tpg), | 1205 | tfo->get_fabric_name(), tfo->tpg_get_tag(se_tpg), |
1214 | tfo->get_fabric_name(), lun->unpacked_lun); | 1206 | tfo->get_fabric_name(), lun->unpacked_lun); |
@@ -3132,6 +3124,7 @@ static int __init target_core_init_configfs(void) | |||
3132 | GFP_KERNEL); | 3124 | GFP_KERNEL); |
3133 | if (!target_cg->default_groups) { | 3125 | if (!target_cg->default_groups) { |
3134 | pr_err("Unable to allocate target_cg->default_groups\n"); | 3126 | pr_err("Unable to allocate target_cg->default_groups\n"); |
3127 | ret = -ENOMEM; | ||
3135 | goto out_global; | 3128 | goto out_global; |
3136 | } | 3129 | } |
3137 | 3130 | ||
@@ -3147,6 +3140,7 @@ static int __init target_core_init_configfs(void) | |||
3147 | GFP_KERNEL); | 3140 | GFP_KERNEL); |
3148 | if (!hba_cg->default_groups) { | 3141 | if (!hba_cg->default_groups) { |
3149 | pr_err("Unable to allocate hba_cg->default_groups\n"); | 3142 | pr_err("Unable to allocate hba_cg->default_groups\n"); |
3143 | ret = -ENOMEM; | ||
3150 | goto out_global; | 3144 | goto out_global; |
3151 | } | 3145 | } |
3152 | config_group_init_type_name(&alua_group, | 3146 | config_group_init_type_name(&alua_group, |
@@ -3162,6 +3156,7 @@ static int __init target_core_init_configfs(void) | |||
3162 | GFP_KERNEL); | 3156 | GFP_KERNEL); |
3163 | if (!alua_cg->default_groups) { | 3157 | if (!alua_cg->default_groups) { |
3164 | pr_err("Unable to allocate alua_cg->default_groups\n"); | 3158 | pr_err("Unable to allocate alua_cg->default_groups\n"); |
3159 | ret = -ENOMEM; | ||
3165 | goto out_global; | 3160 | goto out_global; |
3166 | } | 3161 | } |
3167 | 3162 | ||
@@ -3173,14 +3168,17 @@ static int __init target_core_init_configfs(void) | |||
3173 | * Add core/alua/lu_gps/default_lu_gp | 3168 | * Add core/alua/lu_gps/default_lu_gp |
3174 | */ | 3169 | */ |
3175 | lu_gp = core_alua_allocate_lu_gp("default_lu_gp", 1); | 3170 | lu_gp = core_alua_allocate_lu_gp("default_lu_gp", 1); |
3176 | if (IS_ERR(lu_gp)) | 3171 | if (IS_ERR(lu_gp)) { |
3172 | ret = -ENOMEM; | ||
3177 | goto out_global; | 3173 | goto out_global; |
3174 | } | ||
3178 | 3175 | ||
3179 | lu_gp_cg = &alua_lu_gps_group; | 3176 | lu_gp_cg = &alua_lu_gps_group; |
3180 | lu_gp_cg->default_groups = kzalloc(sizeof(struct config_group) * 2, | 3177 | lu_gp_cg->default_groups = kzalloc(sizeof(struct config_group) * 2, |
3181 | GFP_KERNEL); | 3178 | GFP_KERNEL); |
3182 | if (!lu_gp_cg->default_groups) { | 3179 | if (!lu_gp_cg->default_groups) { |
3183 | pr_err("Unable to allocate lu_gp_cg->default_groups\n"); | 3180 | pr_err("Unable to allocate lu_gp_cg->default_groups\n"); |
3181 | ret = -ENOMEM; | ||
3184 | goto out_global; | 3182 | goto out_global; |
3185 | } | 3183 | } |
3186 | 3184 | ||
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index 9fc9a6006ca0..8d774da16320 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c | |||
@@ -531,7 +531,7 @@ static struct se_port *core_alloc_port(struct se_device *dev) | |||
531 | } | 531 | } |
532 | again: | 532 | again: |
533 | /* | 533 | /* |
534 | * Allocate the next RELATIVE TARGET PORT IDENTIFER for this struct se_device | 534 | * Allocate the next RELATIVE TARGET PORT IDENTIFIER for this struct se_device |
535 | * Here is the table from spc4r17 section 7.7.3.8. | 535 | * Here is the table from spc4r17 section 7.7.3.8. |
536 | * | 536 | * |
537 | * Table 473 -- RELATIVE TARGET PORT IDENTIFIER field | 537 | * Table 473 -- RELATIVE TARGET PORT IDENTIFIER field |
@@ -548,7 +548,7 @@ again: | |||
548 | 548 | ||
549 | list_for_each_entry(port_tmp, &dev->dev_sep_list, sep_list) { | 549 | list_for_each_entry(port_tmp, &dev->dev_sep_list, sep_list) { |
550 | /* | 550 | /* |
551 | * Make sure RELATIVE TARGET PORT IDENTIFER is unique | 551 | * Make sure RELATIVE TARGET PORT IDENTIFIER is unique |
552 | * for 16-bit wrap.. | 552 | * for 16-bit wrap.. |
553 | */ | 553 | */ |
554 | if (port->sep_rtpi == port_tmp->sep_rtpi) | 554 | if (port->sep_rtpi == port_tmp->sep_rtpi) |
@@ -595,7 +595,7 @@ static void core_export_port( | |||
595 | } | 595 | } |
596 | 596 | ||
597 | dev->dev_port_count++; | 597 | dev->dev_port_count++; |
598 | port->sep_index = port->sep_rtpi; /* RELATIVE TARGET PORT IDENTIFER */ | 598 | port->sep_index = port->sep_rtpi; /* RELATIVE TARGET PORT IDENTIFIER */ |
599 | } | 599 | } |
600 | 600 | ||
601 | /* | 601 | /* |
@@ -988,8 +988,9 @@ int se_dev_set_emulate_fua_write(struct se_device *dev, int flag) | |||
988 | return -EINVAL; | 988 | return -EINVAL; |
989 | } | 989 | } |
990 | 990 | ||
991 | if (flag && dev->transport->fua_write_emulated == 0) { | 991 | if (flag && |
992 | pr_err("fua_write_emulated not supported\n"); | 992 | dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV) { |
993 | pr_err("emulate_fua_write not supported for pSCSI\n"); | ||
993 | return -EINVAL; | 994 | return -EINVAL; |
994 | } | 995 | } |
995 | dev->se_sub_dev->se_dev_attrib.emulate_fua_write = flag; | 996 | dev->se_sub_dev->se_dev_attrib.emulate_fua_write = flag; |
@@ -1019,8 +1020,9 @@ int se_dev_set_emulate_write_cache(struct se_device *dev, int flag) | |||
1019 | pr_err("Illegal value %d\n", flag); | 1020 | pr_err("Illegal value %d\n", flag); |
1020 | return -EINVAL; | 1021 | return -EINVAL; |
1021 | } | 1022 | } |
1022 | if (flag && dev->transport->write_cache_emulated == 0) { | 1023 | if (flag && |
1023 | pr_err("write_cache_emulated not supported\n"); | 1024 | dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV) { |
1025 | pr_err("emulate_write_cache not supported for pSCSI\n"); | ||
1024 | return -EINVAL; | 1026 | return -EINVAL; |
1025 | } | 1027 | } |
1026 | dev->se_sub_dev->se_dev_attrib.emulate_write_cache = flag; | 1028 | dev->se_sub_dev->se_dev_attrib.emulate_write_cache = flag; |
diff --git a/drivers/target/target_core_fabric_configfs.c b/drivers/target/target_core_fabric_configfs.c index ea479e54f5fd..bca737bb813d 100644 --- a/drivers/target/target_core_fabric_configfs.c +++ b/drivers/target/target_core_fabric_configfs.c | |||
@@ -22,7 +22,6 @@ | |||
22 | 22 | ||
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
24 | #include <linux/moduleparam.h> | 24 | #include <linux/moduleparam.h> |
25 | #include <generated/utsrelease.h> | ||
26 | #include <linux/utsname.h> | 25 | #include <linux/utsname.h> |
27 | #include <linux/init.h> | 26 | #include <linux/init.h> |
28 | #include <linux/fs.h> | 27 | #include <linux/fs.h> |
diff --git a/drivers/target/target_core_fabric_lib.c b/drivers/target/target_core_fabric_lib.c index 283a36e464e6..e460d6233a0a 100644 --- a/drivers/target/target_core_fabric_lib.c +++ b/drivers/target/target_core_fabric_lib.c | |||
@@ -338,7 +338,7 @@ u32 iscsi_get_pr_transport_id_len( | |||
338 | * 00b: iSCSI Initiator device TransportID format | 338 | * 00b: iSCSI Initiator device TransportID format |
339 | */ | 339 | */ |
340 | if (pr_reg->isid_present_at_reg) { | 340 | if (pr_reg->isid_present_at_reg) { |
341 | len += 5; /* For ",i,0x" ASCII seperator */ | 341 | len += 5; /* For ",i,0x" ASCII separator */ |
342 | len += 7; /* For iSCSI Initiator Session ID + Null terminator */ | 342 | len += 7; /* For iSCSI Initiator Session ID + Null terminator */ |
343 | *format_code = 1; | 343 | *format_code = 1; |
344 | } else | 344 | } else |
@@ -415,20 +415,20 @@ char *iscsi_parse_pr_out_transport_id( | |||
415 | *out_tid_len = (add_len + 4); | 415 | *out_tid_len = (add_len + 4); |
416 | } | 416 | } |
417 | /* | 417 | /* |
418 | * Check for ',i,0x' seperator between iSCSI Name and iSCSI Initiator | 418 | * Check for ',i,0x' separator between iSCSI Name and iSCSI Initiator |
419 | * Session ID as defined in Table 390 - iSCSI initiator port TransportID | 419 | * Session ID as defined in Table 390 - iSCSI initiator port TransportID |
420 | * format. | 420 | * format. |
421 | */ | 421 | */ |
422 | if (format_code == 0x40) { | 422 | if (format_code == 0x40) { |
423 | p = strstr(&buf[4], ",i,0x"); | 423 | p = strstr(&buf[4], ",i,0x"); |
424 | if (!p) { | 424 | if (!p) { |
425 | pr_err("Unable to locate \",i,0x\" seperator" | 425 | pr_err("Unable to locate \",i,0x\" separator" |
426 | " for Initiator port identifier: %s\n", | 426 | " for Initiator port identifier: %s\n", |
427 | &buf[4]); | 427 | &buf[4]); |
428 | return NULL; | 428 | return NULL; |
429 | } | 429 | } |
430 | *p = '\0'; /* Terminate iSCSI Name */ | 430 | *p = '\0'; /* Terminate iSCSI Name */ |
431 | p += 5; /* Skip over ",i,0x" seperator */ | 431 | p += 5; /* Skip over ",i,0x" separator */ |
432 | 432 | ||
433 | *port_nexus_ptr = p; | 433 | *port_nexus_ptr = p; |
434 | /* | 434 | /* |
diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c index cbb5aaf3e567..0360383dfb94 100644 --- a/drivers/target/target_core_file.c +++ b/drivers/target/target_core_file.c | |||
@@ -125,6 +125,19 @@ static struct se_device *fd_create_virtdevice( | |||
125 | * of pure timestamp updates. | 125 | * of pure timestamp updates. |
126 | */ | 126 | */ |
127 | flags = O_RDWR | O_CREAT | O_LARGEFILE | O_DSYNC; | 127 | flags = O_RDWR | O_CREAT | O_LARGEFILE | O_DSYNC; |
128 | /* | ||
129 | * Optionally allow fd_buffered_io=1 to be enabled for people | ||
130 | * who want use the fs buffer cache as an WriteCache mechanism. | ||
131 | * | ||
132 | * This means that in event of a hard failure, there is a risk | ||
133 | * of silent data-loss if the SCSI client has *not* performed a | ||
134 | * forced unit access (FUA) write, or issued SYNCHRONIZE_CACHE | ||
135 | * to write-out the entire device cache. | ||
136 | */ | ||
137 | if (fd_dev->fbd_flags & FDBD_HAS_BUFFERED_IO_WCE) { | ||
138 | pr_debug("FILEIO: Disabling O_DSYNC, using buffered FILEIO\n"); | ||
139 | flags &= ~O_DSYNC; | ||
140 | } | ||
128 | 141 | ||
129 | file = filp_open(fd_dev->fd_dev_name, flags, 0600); | 142 | file = filp_open(fd_dev->fd_dev_name, flags, 0600); |
130 | if (IS_ERR(file)) { | 143 | if (IS_ERR(file)) { |
@@ -188,6 +201,12 @@ static struct se_device *fd_create_virtdevice( | |||
188 | if (!dev) | 201 | if (!dev) |
189 | goto fail; | 202 | goto fail; |
190 | 203 | ||
204 | if (fd_dev->fbd_flags & FDBD_HAS_BUFFERED_IO_WCE) { | ||
205 | pr_debug("FILEIO: Forcing setting of emulate_write_cache=1" | ||
206 | " with FDBD_HAS_BUFFERED_IO_WCE\n"); | ||
207 | dev->se_sub_dev->se_dev_attrib.emulate_write_cache = 1; | ||
208 | } | ||
209 | |||
191 | fd_dev->fd_dev_id = fd_host->fd_host_dev_id_count++; | 210 | fd_dev->fd_dev_id = fd_host->fd_host_dev_id_count++; |
192 | fd_dev->fd_queue_depth = dev->queue_depth; | 211 | fd_dev->fd_queue_depth = dev->queue_depth; |
193 | 212 | ||
@@ -407,6 +426,7 @@ enum { | |||
407 | static match_table_t tokens = { | 426 | static match_table_t tokens = { |
408 | {Opt_fd_dev_name, "fd_dev_name=%s"}, | 427 | {Opt_fd_dev_name, "fd_dev_name=%s"}, |
409 | {Opt_fd_dev_size, "fd_dev_size=%s"}, | 428 | {Opt_fd_dev_size, "fd_dev_size=%s"}, |
429 | {Opt_fd_buffered_io, "fd_buffered_io=%d"}, | ||
410 | {Opt_err, NULL} | 430 | {Opt_err, NULL} |
411 | }; | 431 | }; |
412 | 432 | ||
@@ -418,7 +438,7 @@ static ssize_t fd_set_configfs_dev_params( | |||
418 | struct fd_dev *fd_dev = se_dev->se_dev_su_ptr; | 438 | struct fd_dev *fd_dev = se_dev->se_dev_su_ptr; |
419 | char *orig, *ptr, *arg_p, *opts; | 439 | char *orig, *ptr, *arg_p, *opts; |
420 | substring_t args[MAX_OPT_ARGS]; | 440 | substring_t args[MAX_OPT_ARGS]; |
421 | int ret = 0, token; | 441 | int ret = 0, arg, token; |
422 | 442 | ||
423 | opts = kstrdup(page, GFP_KERNEL); | 443 | opts = kstrdup(page, GFP_KERNEL); |
424 | if (!opts) | 444 | if (!opts) |
@@ -459,6 +479,19 @@ static ssize_t fd_set_configfs_dev_params( | |||
459 | " bytes\n", fd_dev->fd_dev_size); | 479 | " bytes\n", fd_dev->fd_dev_size); |
460 | fd_dev->fbd_flags |= FBDF_HAS_SIZE; | 480 | fd_dev->fbd_flags |= FBDF_HAS_SIZE; |
461 | break; | 481 | break; |
482 | case Opt_fd_buffered_io: | ||
483 | match_int(args, &arg); | ||
484 | if (arg != 1) { | ||
485 | pr_err("bogus fd_buffered_io=%d value\n", arg); | ||
486 | ret = -EINVAL; | ||
487 | goto out; | ||
488 | } | ||
489 | |||
490 | pr_debug("FILEIO: Using buffered I/O" | ||
491 | " operations for struct fd_dev\n"); | ||
492 | |||
493 | fd_dev->fbd_flags |= FDBD_HAS_BUFFERED_IO_WCE; | ||
494 | break; | ||
462 | default: | 495 | default: |
463 | break; | 496 | break; |
464 | } | 497 | } |
@@ -490,8 +523,10 @@ static ssize_t fd_show_configfs_dev_params( | |||
490 | ssize_t bl = 0; | 523 | ssize_t bl = 0; |
491 | 524 | ||
492 | bl = sprintf(b + bl, "TCM FILEIO ID: %u", fd_dev->fd_dev_id); | 525 | bl = sprintf(b + bl, "TCM FILEIO ID: %u", fd_dev->fd_dev_id); |
493 | bl += sprintf(b + bl, " File: %s Size: %llu Mode: O_DSYNC\n", | 526 | bl += sprintf(b + bl, " File: %s Size: %llu Mode: %s\n", |
494 | fd_dev->fd_dev_name, fd_dev->fd_dev_size); | 527 | fd_dev->fd_dev_name, fd_dev->fd_dev_size, |
528 | (fd_dev->fbd_flags & FDBD_HAS_BUFFERED_IO_WCE) ? | ||
529 | "Buffered-WCE" : "O_DSYNC"); | ||
495 | return bl; | 530 | return bl; |
496 | } | 531 | } |
497 | 532 | ||
@@ -546,8 +581,6 @@ static struct se_subsystem_api fileio_template = { | |||
546 | .name = "fileio", | 581 | .name = "fileio", |
547 | .owner = THIS_MODULE, | 582 | .owner = THIS_MODULE, |
548 | .transport_type = TRANSPORT_PLUGIN_VHBA_PDEV, | 583 | .transport_type = TRANSPORT_PLUGIN_VHBA_PDEV, |
549 | .write_cache_emulated = 1, | ||
550 | .fua_write_emulated = 1, | ||
551 | .attach_hba = fd_attach_hba, | 584 | .attach_hba = fd_attach_hba, |
552 | .detach_hba = fd_detach_hba, | 585 | .detach_hba = fd_detach_hba, |
553 | .allocate_virtdevice = fd_allocate_virtdevice, | 586 | .allocate_virtdevice = fd_allocate_virtdevice, |
diff --git a/drivers/target/target_core_file.h b/drivers/target/target_core_file.h index 70ce7fd7111d..876ae53ef5b8 100644 --- a/drivers/target/target_core_file.h +++ b/drivers/target/target_core_file.h | |||
@@ -14,6 +14,7 @@ | |||
14 | 14 | ||
15 | #define FBDF_HAS_PATH 0x01 | 15 | #define FBDF_HAS_PATH 0x01 |
16 | #define FBDF_HAS_SIZE 0x02 | 16 | #define FBDF_HAS_SIZE 0x02 |
17 | #define FDBD_HAS_BUFFERED_IO_WCE 0x04 | ||
17 | 18 | ||
18 | struct fd_dev { | 19 | struct fd_dev { |
19 | u32 fbd_flags; | 20 | u32 fbd_flags; |
diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c index 9ba495477fd2..57d7674c5013 100644 --- a/drivers/target/target_core_iblock.c +++ b/drivers/target/target_core_iblock.c | |||
@@ -454,14 +454,11 @@ static ssize_t iblock_set_configfs_dev_params(struct se_hba *hba, | |||
454 | ret = -EEXIST; | 454 | ret = -EEXIST; |
455 | goto out; | 455 | goto out; |
456 | } | 456 | } |
457 | arg_p = match_strdup(&args[0]); | 457 | if (match_strlcpy(ib_dev->ibd_udev_path, &args[0], |
458 | if (!arg_p) { | 458 | SE_UDEV_PATH_LEN) == 0) { |
459 | ret = -ENOMEM; | 459 | ret = -EINVAL; |
460 | break; | 460 | break; |
461 | } | 461 | } |
462 | snprintf(ib_dev->ibd_udev_path, SE_UDEV_PATH_LEN, | ||
463 | "%s", arg_p); | ||
464 | kfree(arg_p); | ||
465 | pr_debug("IBLOCK: Referencing UDEV path: %s\n", | 462 | pr_debug("IBLOCK: Referencing UDEV path: %s\n", |
466 | ib_dev->ibd_udev_path); | 463 | ib_dev->ibd_udev_path); |
467 | ib_dev->ibd_flags |= IBDF_HAS_UDEV_PATH; | 464 | ib_dev->ibd_flags |= IBDF_HAS_UDEV_PATH; |
@@ -556,14 +553,6 @@ static void iblock_complete_cmd(struct se_cmd *cmd) | |||
556 | kfree(ibr); | 553 | kfree(ibr); |
557 | } | 554 | } |
558 | 555 | ||
559 | static void iblock_bio_destructor(struct bio *bio) | ||
560 | { | ||
561 | struct se_cmd *cmd = bio->bi_private; | ||
562 | struct iblock_dev *ib_dev = cmd->se_dev->dev_ptr; | ||
563 | |||
564 | bio_free(bio, ib_dev->ibd_bio_set); | ||
565 | } | ||
566 | |||
567 | static struct bio * | 556 | static struct bio * |
568 | iblock_get_bio(struct se_cmd *cmd, sector_t lba, u32 sg_num) | 557 | iblock_get_bio(struct se_cmd *cmd, sector_t lba, u32 sg_num) |
569 | { | 558 | { |
@@ -585,7 +574,6 @@ iblock_get_bio(struct se_cmd *cmd, sector_t lba, u32 sg_num) | |||
585 | 574 | ||
586 | bio->bi_bdev = ib_dev->ibd_bd; | 575 | bio->bi_bdev = ib_dev->ibd_bd; |
587 | bio->bi_private = cmd; | 576 | bio->bi_private = cmd; |
588 | bio->bi_destructor = iblock_bio_destructor; | ||
589 | bio->bi_end_io = &iblock_bio_done; | 577 | bio->bi_end_io = &iblock_bio_done; |
590 | bio->bi_sector = lba; | 578 | bio->bi_sector = lba; |
591 | return bio; | 579 | return bio; |
@@ -657,6 +645,12 @@ static int iblock_execute_rw(struct se_cmd *cmd) | |||
657 | goto fail; | 645 | goto fail; |
658 | cmd->priv = ibr; | 646 | cmd->priv = ibr; |
659 | 647 | ||
648 | if (!sgl_nents) { | ||
649 | atomic_set(&ibr->pending, 1); | ||
650 | iblock_complete_cmd(cmd); | ||
651 | return 0; | ||
652 | } | ||
653 | |||
660 | bio = iblock_get_bio(cmd, block_lba, sgl_nents); | 654 | bio = iblock_get_bio(cmd, block_lba, sgl_nents); |
661 | if (!bio) | 655 | if (!bio) |
662 | goto fail_free_ibr; | 656 | goto fail_free_ibr; |
@@ -769,8 +763,6 @@ static struct se_subsystem_api iblock_template = { | |||
769 | .name = "iblock", | 763 | .name = "iblock", |
770 | .owner = THIS_MODULE, | 764 | .owner = THIS_MODULE, |
771 | .transport_type = TRANSPORT_PLUGIN_VHBA_PDEV, | 765 | .transport_type = TRANSPORT_PLUGIN_VHBA_PDEV, |
772 | .write_cache_emulated = 1, | ||
773 | .fua_write_emulated = 1, | ||
774 | .attach_hba = iblock_attach_hba, | 766 | .attach_hba = iblock_attach_hba, |
775 | .detach_hba = iblock_detach_hba, | 767 | .detach_hba = iblock_detach_hba, |
776 | .allocate_virtdevice = iblock_allocate_virtdevice, | 768 | .allocate_virtdevice = iblock_allocate_virtdevice, |
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c index 956c84c6b666..8c323a98c4a0 100644 --- a/drivers/target/target_core_pr.c +++ b/drivers/target/target_core_pr.c | |||
@@ -197,10 +197,10 @@ int target_scsi2_reservation_release(struct se_cmd *cmd) | |||
197 | { | 197 | { |
198 | struct se_device *dev = cmd->se_dev; | 198 | struct se_device *dev = cmd->se_dev; |
199 | struct se_session *sess = cmd->se_sess; | 199 | struct se_session *sess = cmd->se_sess; |
200 | struct se_portal_group *tpg = sess->se_tpg; | 200 | struct se_portal_group *tpg; |
201 | int ret = 0, rc; | 201 | int ret = 0, rc; |
202 | 202 | ||
203 | if (!sess || !tpg) | 203 | if (!sess || !sess->se_tpg) |
204 | goto out; | 204 | goto out; |
205 | rc = target_check_scsi2_reservation_conflict(cmd); | 205 | rc = target_check_scsi2_reservation_conflict(cmd); |
206 | if (rc == 1) | 206 | if (rc == 1) |
@@ -228,6 +228,7 @@ int target_scsi2_reservation_release(struct se_cmd *cmd) | |||
228 | dev->dev_res_bin_isid = 0; | 228 | dev->dev_res_bin_isid = 0; |
229 | dev->dev_flags &= ~DF_SPC2_RESERVATIONS_WITH_ISID; | 229 | dev->dev_flags &= ~DF_SPC2_RESERVATIONS_WITH_ISID; |
230 | } | 230 | } |
231 | tpg = sess->se_tpg; | ||
231 | pr_debug("SCSI-2 Released reservation for %s LUN: %u ->" | 232 | pr_debug("SCSI-2 Released reservation for %s LUN: %u ->" |
232 | " MAPPED LUN: %u for %s\n", tpg->se_tpg_tfo->get_fabric_name(), | 233 | " MAPPED LUN: %u for %s\n", tpg->se_tpg_tfo->get_fabric_name(), |
233 | cmd->se_lun->unpacked_lun, cmd->se_deve->mapped_lun, | 234 | cmd->se_lun->unpacked_lun, cmd->se_deve->mapped_lun, |
@@ -245,7 +246,7 @@ int target_scsi2_reservation_reserve(struct se_cmd *cmd) | |||
245 | { | 246 | { |
246 | struct se_device *dev = cmd->se_dev; | 247 | struct se_device *dev = cmd->se_dev; |
247 | struct se_session *sess = cmd->se_sess; | 248 | struct se_session *sess = cmd->se_sess; |
248 | struct se_portal_group *tpg = sess->se_tpg; | 249 | struct se_portal_group *tpg; |
249 | int ret = 0, rc; | 250 | int ret = 0, rc; |
250 | 251 | ||
251 | if ((cmd->t_task_cdb[1] & 0x01) && | 252 | if ((cmd->t_task_cdb[1] & 0x01) && |
@@ -260,7 +261,7 @@ int target_scsi2_reservation_reserve(struct se_cmd *cmd) | |||
260 | * This is currently the case for target_core_mod passthrough struct se_cmd | 261 | * This is currently the case for target_core_mod passthrough struct se_cmd |
261 | * ops | 262 | * ops |
262 | */ | 263 | */ |
263 | if (!sess || !tpg) | 264 | if (!sess || !sess->se_tpg) |
264 | goto out; | 265 | goto out; |
265 | rc = target_check_scsi2_reservation_conflict(cmd); | 266 | rc = target_check_scsi2_reservation_conflict(cmd); |
266 | if (rc == 1) | 267 | if (rc == 1) |
@@ -272,6 +273,7 @@ int target_scsi2_reservation_reserve(struct se_cmd *cmd) | |||
272 | } | 273 | } |
273 | 274 | ||
274 | ret = 0; | 275 | ret = 0; |
276 | tpg = sess->se_tpg; | ||
275 | spin_lock(&dev->dev_reservation_lock); | 277 | spin_lock(&dev->dev_reservation_lock); |
276 | if (dev->dev_reserved_node_acl && | 278 | if (dev->dev_reserved_node_acl && |
277 | (dev->dev_reserved_node_acl != sess->se_node_acl)) { | 279 | (dev->dev_reserved_node_acl != sess->se_node_acl)) { |
@@ -1620,7 +1622,7 @@ static int core_scsi3_decode_spec_i_port( | |||
1620 | goto out; | 1622 | goto out; |
1621 | } | 1623 | } |
1622 | /* | 1624 | /* |
1623 | * Locate the desination initiator ACL to be registered | 1625 | * Locate the destination initiator ACL to be registered |
1624 | * from the decoded fabric module specific TransportID | 1626 | * from the decoded fabric module specific TransportID |
1625 | * at *i_str. | 1627 | * at *i_str. |
1626 | */ | 1628 | */ |
@@ -4257,7 +4259,7 @@ static int core_scsi3_pri_read_full_status(struct se_cmd *cmd) | |||
4257 | buf[off++] = ((port->sep_rtpi >> 8) & 0xff); | 4259 | buf[off++] = ((port->sep_rtpi >> 8) & 0xff); |
4258 | buf[off++] = (port->sep_rtpi & 0xff); | 4260 | buf[off++] = (port->sep_rtpi & 0xff); |
4259 | } else | 4261 | } else |
4260 | off += 2; /* Skip over RELATIVE TARGET PORT IDENTIFER */ | 4262 | off += 2; /* Skip over RELATIVE TARGET PORT IDENTIFIER */ |
4261 | 4263 | ||
4262 | /* | 4264 | /* |
4263 | * Now, have the $FABRIC_MOD fill in the protocol identifier | 4265 | * Now, have the $FABRIC_MOD fill in the protocol identifier |
diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c index 9d7ce3daa262..617c086a8a02 100644 --- a/drivers/target/target_core_pscsi.c +++ b/drivers/target/target_core_pscsi.c | |||
@@ -264,7 +264,7 @@ pscsi_get_inquiry_vpd_device_ident(struct scsi_device *sdev, | |||
264 | " length zero!\n"); | 264 | " length zero!\n"); |
265 | break; | 265 | break; |
266 | } | 266 | } |
267 | pr_debug("T10 VPD Identifer Length: %d\n", ident_len); | 267 | pr_debug("T10 VPD Identifier Length: %d\n", ident_len); |
268 | 268 | ||
269 | vpd = kzalloc(sizeof(struct t10_vpd), GFP_KERNEL); | 269 | vpd = kzalloc(sizeof(struct t10_vpd), GFP_KERNEL); |
270 | if (!vpd) { | 270 | if (!vpd) { |
diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c index a9dd9469e3bd..868f8aa04f13 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c | |||
@@ -40,8 +40,9 @@ | |||
40 | static int sbc_emulate_readcapacity(struct se_cmd *cmd) | 40 | static int sbc_emulate_readcapacity(struct se_cmd *cmd) |
41 | { | 41 | { |
42 | struct se_device *dev = cmd->se_dev; | 42 | struct se_device *dev = cmd->se_dev; |
43 | unsigned char *buf; | ||
44 | unsigned long long blocks_long = dev->transport->get_blocks(dev); | 43 | unsigned long long blocks_long = dev->transport->get_blocks(dev); |
44 | unsigned char *rbuf; | ||
45 | unsigned char buf[8]; | ||
45 | u32 blocks; | 46 | u32 blocks; |
46 | 47 | ||
47 | if (blocks_long >= 0x00000000ffffffff) | 48 | if (blocks_long >= 0x00000000ffffffff) |
@@ -49,8 +50,6 @@ static int sbc_emulate_readcapacity(struct se_cmd *cmd) | |||
49 | else | 50 | else |
50 | blocks = (u32)blocks_long; | 51 | blocks = (u32)blocks_long; |
51 | 52 | ||
52 | buf = transport_kmap_data_sg(cmd); | ||
53 | |||
54 | buf[0] = (blocks >> 24) & 0xff; | 53 | buf[0] = (blocks >> 24) & 0xff; |
55 | buf[1] = (blocks >> 16) & 0xff; | 54 | buf[1] = (blocks >> 16) & 0xff; |
56 | buf[2] = (blocks >> 8) & 0xff; | 55 | buf[2] = (blocks >> 8) & 0xff; |
@@ -60,7 +59,11 @@ static int sbc_emulate_readcapacity(struct se_cmd *cmd) | |||
60 | buf[6] = (dev->se_sub_dev->se_dev_attrib.block_size >> 8) & 0xff; | 59 | buf[6] = (dev->se_sub_dev->se_dev_attrib.block_size >> 8) & 0xff; |
61 | buf[7] = dev->se_sub_dev->se_dev_attrib.block_size & 0xff; | 60 | buf[7] = dev->se_sub_dev->se_dev_attrib.block_size & 0xff; |
62 | 61 | ||
63 | transport_kunmap_data_sg(cmd); | 62 | rbuf = transport_kmap_data_sg(cmd); |
63 | if (rbuf) { | ||
64 | memcpy(rbuf, buf, min_t(u32, sizeof(buf), cmd->data_length)); | ||
65 | transport_kunmap_data_sg(cmd); | ||
66 | } | ||
64 | 67 | ||
65 | target_complete_cmd(cmd, GOOD); | 68 | target_complete_cmd(cmd, GOOD); |
66 | return 0; | 69 | return 0; |
@@ -69,11 +72,11 @@ static int sbc_emulate_readcapacity(struct se_cmd *cmd) | |||
69 | static int sbc_emulate_readcapacity_16(struct se_cmd *cmd) | 72 | static int sbc_emulate_readcapacity_16(struct se_cmd *cmd) |
70 | { | 73 | { |
71 | struct se_device *dev = cmd->se_dev; | 74 | struct se_device *dev = cmd->se_dev; |
72 | unsigned char *buf; | 75 | unsigned char *rbuf; |
76 | unsigned char buf[32]; | ||
73 | unsigned long long blocks = dev->transport->get_blocks(dev); | 77 | unsigned long long blocks = dev->transport->get_blocks(dev); |
74 | 78 | ||
75 | buf = transport_kmap_data_sg(cmd); | 79 | memset(buf, 0, sizeof(buf)); |
76 | |||
77 | buf[0] = (blocks >> 56) & 0xff; | 80 | buf[0] = (blocks >> 56) & 0xff; |
78 | buf[1] = (blocks >> 48) & 0xff; | 81 | buf[1] = (blocks >> 48) & 0xff; |
79 | buf[2] = (blocks >> 40) & 0xff; | 82 | buf[2] = (blocks >> 40) & 0xff; |
@@ -93,7 +96,11 @@ static int sbc_emulate_readcapacity_16(struct se_cmd *cmd) | |||
93 | if (dev->se_sub_dev->se_dev_attrib.emulate_tpu || dev->se_sub_dev->se_dev_attrib.emulate_tpws) | 96 | if (dev->se_sub_dev->se_dev_attrib.emulate_tpu || dev->se_sub_dev->se_dev_attrib.emulate_tpws) |
94 | buf[14] = 0x80; | 97 | buf[14] = 0x80; |
95 | 98 | ||
96 | transport_kunmap_data_sg(cmd); | 99 | rbuf = transport_kmap_data_sg(cmd); |
100 | if (rbuf) { | ||
101 | memcpy(rbuf, buf, min_t(u32, sizeof(buf), cmd->data_length)); | ||
102 | transport_kunmap_data_sg(cmd); | ||
103 | } | ||
97 | 104 | ||
98 | target_complete_cmd(cmd, GOOD); | 105 | target_complete_cmd(cmd, GOOD); |
99 | return 0; | 106 | return 0; |
diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c index 388a922c8f6d..9229bd9ad61b 100644 --- a/drivers/target/target_core_spc.c +++ b/drivers/target/target_core_spc.c | |||
@@ -600,30 +600,11 @@ static int spc_emulate_inquiry(struct se_cmd *cmd) | |||
600 | { | 600 | { |
601 | struct se_device *dev = cmd->se_dev; | 601 | struct se_device *dev = cmd->se_dev; |
602 | struct se_portal_group *tpg = cmd->se_lun->lun_sep->sep_tpg; | 602 | struct se_portal_group *tpg = cmd->se_lun->lun_sep->sep_tpg; |
603 | unsigned char *buf, *map_buf; | 603 | unsigned char *rbuf; |
604 | unsigned char *cdb = cmd->t_task_cdb; | 604 | unsigned char *cdb = cmd->t_task_cdb; |
605 | unsigned char buf[SE_INQUIRY_BUF]; | ||
605 | int p, ret; | 606 | int p, ret; |
606 | 607 | ||
607 | map_buf = transport_kmap_data_sg(cmd); | ||
608 | /* | ||
609 | * If SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC is not set, then we | ||
610 | * know we actually allocated a full page. Otherwise, if the | ||
611 | * data buffer is too small, allocate a temporary buffer so we | ||
612 | * don't have to worry about overruns in all our INQUIRY | ||
613 | * emulation handling. | ||
614 | */ | ||
615 | if (cmd->data_length < SE_INQUIRY_BUF && | ||
616 | (cmd->se_cmd_flags & SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC)) { | ||
617 | buf = kzalloc(SE_INQUIRY_BUF, GFP_KERNEL); | ||
618 | if (!buf) { | ||
619 | transport_kunmap_data_sg(cmd); | ||
620 | cmd->scsi_sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; | ||
621 | return -ENOMEM; | ||
622 | } | ||
623 | } else { | ||
624 | buf = map_buf; | ||
625 | } | ||
626 | |||
627 | if (dev == tpg->tpg_virt_lun0.lun_se_dev) | 608 | if (dev == tpg->tpg_virt_lun0.lun_se_dev) |
628 | buf[0] = 0x3f; /* Not connected */ | 609 | buf[0] = 0x3f; /* Not connected */ |
629 | else | 610 | else |
@@ -655,11 +636,11 @@ static int spc_emulate_inquiry(struct se_cmd *cmd) | |||
655 | ret = -EINVAL; | 636 | ret = -EINVAL; |
656 | 637 | ||
657 | out: | 638 | out: |
658 | if (buf != map_buf) { | 639 | rbuf = transport_kmap_data_sg(cmd); |
659 | memcpy(map_buf, buf, cmd->data_length); | 640 | if (rbuf) { |
660 | kfree(buf); | 641 | memcpy(rbuf, buf, min_t(u32, sizeof(buf), cmd->data_length)); |
642 | transport_kunmap_data_sg(cmd); | ||
661 | } | 643 | } |
662 | transport_kunmap_data_sg(cmd); | ||
663 | 644 | ||
664 | if (!ret) | 645 | if (!ret) |
665 | target_complete_cmd(cmd, GOOD); | 646 | target_complete_cmd(cmd, GOOD); |
@@ -803,7 +784,7 @@ static int spc_emulate_modesense(struct se_cmd *cmd) | |||
803 | unsigned char *rbuf; | 784 | unsigned char *rbuf; |
804 | int type = dev->transport->get_device_type(dev); | 785 | int type = dev->transport->get_device_type(dev); |
805 | int ten = (cmd->t_task_cdb[0] == MODE_SENSE_10); | 786 | int ten = (cmd->t_task_cdb[0] == MODE_SENSE_10); |
806 | int offset = ten ? 8 : 4; | 787 | u32 offset = ten ? 8 : 4; |
807 | int length = 0; | 788 | int length = 0; |
808 | unsigned char buf[SE_MODE_PAGE_BUF]; | 789 | unsigned char buf[SE_MODE_PAGE_BUF]; |
809 | 790 | ||
@@ -836,6 +817,7 @@ static int spc_emulate_modesense(struct se_cmd *cmd) | |||
836 | offset -= 2; | 817 | offset -= 2; |
837 | buf[0] = (offset >> 8) & 0xff; | 818 | buf[0] = (offset >> 8) & 0xff; |
838 | buf[1] = offset & 0xff; | 819 | buf[1] = offset & 0xff; |
820 | offset += 2; | ||
839 | 821 | ||
840 | if ((cmd->se_lun->lun_access & TRANSPORT_LUNFLAGS_READ_ONLY) || | 822 | if ((cmd->se_lun->lun_access & TRANSPORT_LUNFLAGS_READ_ONLY) || |
841 | (cmd->se_deve && | 823 | (cmd->se_deve && |
@@ -845,13 +827,10 @@ static int spc_emulate_modesense(struct se_cmd *cmd) | |||
845 | if ((dev->se_sub_dev->se_dev_attrib.emulate_write_cache > 0) && | 827 | if ((dev->se_sub_dev->se_dev_attrib.emulate_write_cache > 0) && |
846 | (dev->se_sub_dev->se_dev_attrib.emulate_fua_write > 0)) | 828 | (dev->se_sub_dev->se_dev_attrib.emulate_fua_write > 0)) |
847 | spc_modesense_dpofua(&buf[3], type); | 829 | spc_modesense_dpofua(&buf[3], type); |
848 | |||
849 | if ((offset + 2) > cmd->data_length) | ||
850 | offset = cmd->data_length; | ||
851 | |||
852 | } else { | 830 | } else { |
853 | offset -= 1; | 831 | offset -= 1; |
854 | buf[0] = offset & 0xff; | 832 | buf[0] = offset & 0xff; |
833 | offset += 1; | ||
855 | 834 | ||
856 | if ((cmd->se_lun->lun_access & TRANSPORT_LUNFLAGS_READ_ONLY) || | 835 | if ((cmd->se_lun->lun_access & TRANSPORT_LUNFLAGS_READ_ONLY) || |
857 | (cmd->se_deve && | 836 | (cmd->se_deve && |
@@ -861,14 +840,13 @@ static int spc_emulate_modesense(struct se_cmd *cmd) | |||
861 | if ((dev->se_sub_dev->se_dev_attrib.emulate_write_cache > 0) && | 840 | if ((dev->se_sub_dev->se_dev_attrib.emulate_write_cache > 0) && |
862 | (dev->se_sub_dev->se_dev_attrib.emulate_fua_write > 0)) | 841 | (dev->se_sub_dev->se_dev_attrib.emulate_fua_write > 0)) |
863 | spc_modesense_dpofua(&buf[2], type); | 842 | spc_modesense_dpofua(&buf[2], type); |
864 | |||
865 | if ((offset + 1) > cmd->data_length) | ||
866 | offset = cmd->data_length; | ||
867 | } | 843 | } |
868 | 844 | ||
869 | rbuf = transport_kmap_data_sg(cmd); | 845 | rbuf = transport_kmap_data_sg(cmd); |
870 | memcpy(rbuf, buf, offset); | 846 | if (rbuf) { |
871 | transport_kunmap_data_sg(cmd); | 847 | memcpy(rbuf, buf, min(offset, cmd->data_length)); |
848 | transport_kunmap_data_sg(cmd); | ||
849 | } | ||
872 | 850 | ||
873 | target_complete_cmd(cmd, GOOD); | 851 | target_complete_cmd(cmd, GOOD); |
874 | return 0; | 852 | return 0; |
diff --git a/drivers/target/target_core_stat.c b/drivers/target/target_core_stat.c index 3d44beb0cf1f..cb6b0036ae95 100644 --- a/drivers/target/target_core_stat.c +++ b/drivers/target/target_core_stat.c | |||
@@ -32,7 +32,6 @@ | |||
32 | #include <linux/delay.h> | 32 | #include <linux/delay.h> |
33 | #include <linux/timer.h> | 33 | #include <linux/timer.h> |
34 | #include <linux/string.h> | 34 | #include <linux/string.h> |
35 | #include <generated/utsrelease.h> | ||
36 | #include <linux/utsname.h> | 35 | #include <linux/utsname.h> |
37 | #include <linux/proc_fs.h> | 36 | #include <linux/proc_fs.h> |
38 | #include <linux/seq_file.h> | 37 | #include <linux/seq_file.h> |
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c index b8628a5014b9..a531fe282b1e 100644 --- a/drivers/target/target_core_tpg.c +++ b/drivers/target/target_core_tpg.c | |||
@@ -303,7 +303,7 @@ struct se_node_acl *core_tpg_check_initiator_node_acl( | |||
303 | } | 303 | } |
304 | /* | 304 | /* |
305 | * Here we only create demo-mode MappedLUNs from the active | 305 | * Here we only create demo-mode MappedLUNs from the active |
306 | * TPG LUNs if the fabric is not explictly asking for | 306 | * TPG LUNs if the fabric is not explicitly asking for |
307 | * tpg_check_demo_mode_login_only() == 1. | 307 | * tpg_check_demo_mode_login_only() == 1. |
308 | */ | 308 | */ |
309 | if ((tpg->se_tpg_tfo->tpg_check_demo_mode_login_only == NULL) || | 309 | if ((tpg->se_tpg_tfo->tpg_check_demo_mode_login_only == NULL) || |
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 269f54488397..c33baff86aa6 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c | |||
@@ -55,8 +55,6 @@ | |||
55 | #include "target_core_pr.h" | 55 | #include "target_core_pr.h" |
56 | #include "target_core_ua.h" | 56 | #include "target_core_ua.h" |
57 | 57 | ||
58 | static int sub_api_initialized; | ||
59 | |||
60 | static struct workqueue_struct *target_completion_wq; | 58 | static struct workqueue_struct *target_completion_wq; |
61 | static struct kmem_cache *se_sess_cache; | 59 | static struct kmem_cache *se_sess_cache; |
62 | struct kmem_cache *se_ua_cache; | 60 | struct kmem_cache *se_ua_cache; |
@@ -195,6 +193,7 @@ u32 scsi_get_new_index(scsi_index_t type) | |||
195 | void transport_subsystem_check_init(void) | 193 | void transport_subsystem_check_init(void) |
196 | { | 194 | { |
197 | int ret; | 195 | int ret; |
196 | static int sub_api_initialized; | ||
198 | 197 | ||
199 | if (sub_api_initialized) | 198 | if (sub_api_initialized) |
200 | return; | 199 | return; |
@@ -211,12 +210,7 @@ void transport_subsystem_check_init(void) | |||
211 | if (ret != 0) | 210 | if (ret != 0) |
212 | pr_err("Unable to load target_core_pscsi\n"); | 211 | pr_err("Unable to load target_core_pscsi\n"); |
213 | 212 | ||
214 | ret = request_module("target_core_stgt"); | ||
215 | if (ret != 0) | ||
216 | pr_err("Unable to load target_core_stgt\n"); | ||
217 | |||
218 | sub_api_initialized = 1; | 213 | sub_api_initialized = 1; |
219 | return; | ||
220 | } | 214 | } |
221 | 215 | ||
222 | struct se_session *transport_init_session(void) | 216 | struct se_session *transport_init_session(void) |
@@ -573,9 +567,7 @@ static void target_complete_failure_work(struct work_struct *work) | |||
573 | */ | 567 | */ |
574 | static unsigned char *transport_get_sense_buffer(struct se_cmd *cmd) | 568 | static unsigned char *transport_get_sense_buffer(struct se_cmd *cmd) |
575 | { | 569 | { |
576 | unsigned char *buffer = cmd->sense_buffer; | ||
577 | struct se_device *dev = cmd->se_dev; | 570 | struct se_device *dev = cmd->se_dev; |
578 | u32 offset = 0; | ||
579 | 571 | ||
580 | WARN_ON(!cmd->se_lun); | 572 | WARN_ON(!cmd->se_lun); |
581 | 573 | ||
@@ -585,14 +577,11 @@ static unsigned char *transport_get_sense_buffer(struct se_cmd *cmd) | |||
585 | if (cmd->se_cmd_flags & SCF_SENT_CHECK_CONDITION) | 577 | if (cmd->se_cmd_flags & SCF_SENT_CHECK_CONDITION) |
586 | return NULL; | 578 | return NULL; |
587 | 579 | ||
588 | offset = cmd->se_tfo->set_fabric_sense_len(cmd, TRANSPORT_SENSE_BUFFER); | 580 | cmd->scsi_sense_length = TRANSPORT_SENSE_BUFFER; |
589 | |||
590 | /* Automatically padded */ | ||
591 | cmd->scsi_sense_length = TRANSPORT_SENSE_BUFFER + offset; | ||
592 | 581 | ||
593 | pr_debug("HBA_[%u]_PLUG[%s]: Requesting sense for SAM STATUS: 0x%02x\n", | 582 | pr_debug("HBA_[%u]_PLUG[%s]: Requesting sense for SAM STATUS: 0x%02x\n", |
594 | dev->se_hba->hba_id, dev->transport->name, cmd->scsi_status); | 583 | dev->se_hba->hba_id, dev->transport->name, cmd->scsi_status); |
595 | return &buffer[offset]; | 584 | return cmd->sense_buffer; |
596 | } | 585 | } |
597 | 586 | ||
598 | void target_complete_cmd(struct se_cmd *cmd, u8 scsi_status) | 587 | void target_complete_cmd(struct se_cmd *cmd, u8 scsi_status) |
@@ -969,7 +958,7 @@ int | |||
969 | transport_set_vpd_ident(struct t10_vpd *vpd, unsigned char *page_83) | 958 | transport_set_vpd_ident(struct t10_vpd *vpd, unsigned char *page_83) |
970 | { | 959 | { |
971 | static const char hex_str[] = "0123456789abcdef"; | 960 | static const char hex_str[] = "0123456789abcdef"; |
972 | int j = 0, i = 4; /* offset to start of the identifer */ | 961 | int j = 0, i = 4; /* offset to start of the identifier */ |
973 | 962 | ||
974 | /* | 963 | /* |
975 | * The VPD Code Set (encoding) | 964 | * The VPD Code Set (encoding) |
@@ -1466,8 +1455,9 @@ int transport_handle_cdb_direct( | |||
1466 | } | 1455 | } |
1467 | EXPORT_SYMBOL(transport_handle_cdb_direct); | 1456 | EXPORT_SYMBOL(transport_handle_cdb_direct); |
1468 | 1457 | ||
1469 | /** | 1458 | /* |
1470 | * target_submit_cmd - lookup unpacked lun and submit uninitialized se_cmd | 1459 | * target_submit_cmd_map_sgls - lookup unpacked lun and submit uninitialized |
1460 | * se_cmd + use pre-allocated SGL memory. | ||
1471 | * | 1461 | * |
1472 | * @se_cmd: command descriptor to submit | 1462 | * @se_cmd: command descriptor to submit |
1473 | * @se_sess: associated se_sess for endpoint | 1463 | * @se_sess: associated se_sess for endpoint |
@@ -1478,6 +1468,10 @@ EXPORT_SYMBOL(transport_handle_cdb_direct); | |||
1478 | * @task_addr: SAM task attribute | 1468 | * @task_addr: SAM task attribute |
1479 | * @data_dir: DMA data direction | 1469 | * @data_dir: DMA data direction |
1480 | * @flags: flags for command submission from target_sc_flags_tables | 1470 | * @flags: flags for command submission from target_sc_flags_tables |
1471 | * @sgl: struct scatterlist memory for unidirectional mapping | ||
1472 | * @sgl_count: scatterlist count for unidirectional mapping | ||
1473 | * @sgl_bidi: struct scatterlist memory for bidirectional READ mapping | ||
1474 | * @sgl_bidi_count: scatterlist count for bidirectional READ mapping | ||
1481 | * | 1475 | * |
1482 | * Returns non zero to signal active I/O shutdown failure. All other | 1476 | * Returns non zero to signal active I/O shutdown failure. All other |
1483 | * setup exceptions will be returned as a SCSI CHECK_CONDITION response, | 1477 | * setup exceptions will be returned as a SCSI CHECK_CONDITION response, |
@@ -1485,10 +1479,12 @@ EXPORT_SYMBOL(transport_handle_cdb_direct); | |||
1485 | * | 1479 | * |
1486 | * This may only be called from process context, and also currently | 1480 | * This may only be called from process context, and also currently |
1487 | * assumes internal allocation of fabric payload buffer by target-core. | 1481 | * assumes internal allocation of fabric payload buffer by target-core. |
1488 | **/ | 1482 | */ |
1489 | int target_submit_cmd(struct se_cmd *se_cmd, struct se_session *se_sess, | 1483 | int target_submit_cmd_map_sgls(struct se_cmd *se_cmd, struct se_session *se_sess, |
1490 | unsigned char *cdb, unsigned char *sense, u32 unpacked_lun, | 1484 | unsigned char *cdb, unsigned char *sense, u32 unpacked_lun, |
1491 | u32 data_length, int task_attr, int data_dir, int flags) | 1485 | u32 data_length, int task_attr, int data_dir, int flags, |
1486 | struct scatterlist *sgl, u32 sgl_count, | ||
1487 | struct scatterlist *sgl_bidi, u32 sgl_bidi_count) | ||
1492 | { | 1488 | { |
1493 | struct se_portal_group *se_tpg; | 1489 | struct se_portal_group *se_tpg; |
1494 | int rc; | 1490 | int rc; |
@@ -1535,7 +1531,42 @@ int target_submit_cmd(struct se_cmd *se_cmd, struct se_session *se_sess, | |||
1535 | transport_generic_request_failure(se_cmd); | 1531 | transport_generic_request_failure(se_cmd); |
1536 | return 0; | 1532 | return 0; |
1537 | } | 1533 | } |
1534 | /* | ||
1535 | * When a non zero sgl_count has been passed perform SGL passthrough | ||
1536 | * mapping for pre-allocated fabric memory instead of having target | ||
1537 | * core perform an internal SGL allocation.. | ||
1538 | */ | ||
1539 | if (sgl_count != 0) { | ||
1540 | BUG_ON(!sgl); | ||
1541 | |||
1542 | /* | ||
1543 | * A work-around for tcm_loop as some userspace code via | ||
1544 | * scsi-generic do not memset their associated read buffers, | ||
1545 | * so go ahead and do that here for type non-data CDBs. Also | ||
1546 | * note that this is currently guaranteed to be a single SGL | ||
1547 | * for this case by target core in target_setup_cmd_from_cdb() | ||
1548 | * -> transport_generic_cmd_sequencer(). | ||
1549 | */ | ||
1550 | if (!(se_cmd->se_cmd_flags & SCF_SCSI_DATA_CDB) && | ||
1551 | se_cmd->data_direction == DMA_FROM_DEVICE) { | ||
1552 | unsigned char *buf = NULL; | ||
1553 | |||
1554 | if (sgl) | ||
1555 | buf = kmap(sg_page(sgl)) + sgl->offset; | ||
1556 | |||
1557 | if (buf) { | ||
1558 | memset(buf, 0, sgl->length); | ||
1559 | kunmap(sg_page(sgl)); | ||
1560 | } | ||
1561 | } | ||
1538 | 1562 | ||
1563 | rc = transport_generic_map_mem_to_cmd(se_cmd, sgl, sgl_count, | ||
1564 | sgl_bidi, sgl_bidi_count); | ||
1565 | if (rc != 0) { | ||
1566 | transport_generic_request_failure(se_cmd); | ||
1567 | return 0; | ||
1568 | } | ||
1569 | } | ||
1539 | /* | 1570 | /* |
1540 | * Check if we need to delay processing because of ALUA | 1571 | * Check if we need to delay processing because of ALUA |
1541 | * Active/NonOptimized primary access state.. | 1572 | * Active/NonOptimized primary access state.. |
@@ -1545,6 +1576,38 @@ int target_submit_cmd(struct se_cmd *se_cmd, struct se_session *se_sess, | |||
1545 | transport_handle_cdb_direct(se_cmd); | 1576 | transport_handle_cdb_direct(se_cmd); |
1546 | return 0; | 1577 | return 0; |
1547 | } | 1578 | } |
1579 | EXPORT_SYMBOL(target_submit_cmd_map_sgls); | ||
1580 | |||
1581 | /* | ||
1582 | * target_submit_cmd - lookup unpacked lun and submit uninitialized se_cmd | ||
1583 | * | ||
1584 | * @se_cmd: command descriptor to submit | ||
1585 | * @se_sess: associated se_sess for endpoint | ||
1586 | * @cdb: pointer to SCSI CDB | ||
1587 | * @sense: pointer to SCSI sense buffer | ||
1588 | * @unpacked_lun: unpacked LUN to reference for struct se_lun | ||
1589 | * @data_length: fabric expected data transfer length | ||
1590 | * @task_addr: SAM task attribute | ||
1591 | * @data_dir: DMA data direction | ||
1592 | * @flags: flags for command submission from target_sc_flags_tables | ||
1593 | * | ||
1594 | * Returns non zero to signal active I/O shutdown failure. All other | ||
1595 | * setup exceptions will be returned as a SCSI CHECK_CONDITION response, | ||
1596 | * but still return zero here. | ||
1597 | * | ||
1598 | * This may only be called from process context, and also currently | ||
1599 | * assumes internal allocation of fabric payload buffer by target-core. | ||
1600 | * | ||
1601 | * It also assumes interal target core SGL memory allocation. | ||
1602 | */ | ||
1603 | int target_submit_cmd(struct se_cmd *se_cmd, struct se_session *se_sess, | ||
1604 | unsigned char *cdb, unsigned char *sense, u32 unpacked_lun, | ||
1605 | u32 data_length, int task_attr, int data_dir, int flags) | ||
1606 | { | ||
1607 | return target_submit_cmd_map_sgls(se_cmd, se_sess, cdb, sense, | ||
1608 | unpacked_lun, data_length, task_attr, data_dir, | ||
1609 | flags, NULL, 0, NULL, 0); | ||
1610 | } | ||
1548 | EXPORT_SYMBOL(target_submit_cmd); | 1611 | EXPORT_SYMBOL(target_submit_cmd); |
1549 | 1612 | ||
1550 | static void target_complete_tmr_failure(struct work_struct *work) | 1613 | static void target_complete_tmr_failure(struct work_struct *work) |
@@ -2300,23 +2363,6 @@ int transport_generic_new_cmd(struct se_cmd *cmd) | |||
2300 | if (ret < 0) | 2363 | if (ret < 0) |
2301 | goto out_fail; | 2364 | goto out_fail; |
2302 | } | 2365 | } |
2303 | /* | ||
2304 | * If this command doesn't have any payload and we don't have to call | ||
2305 | * into the fabric for data transfers, go ahead and complete it right | ||
2306 | * away. | ||
2307 | */ | ||
2308 | if (!cmd->data_length && | ||
2309 | cmd->t_task_cdb[0] != REQUEST_SENSE && | ||
2310 | cmd->se_dev->transport->transport_type != TRANSPORT_PLUGIN_PHBA_PDEV) { | ||
2311 | spin_lock_irq(&cmd->t_state_lock); | ||
2312 | cmd->t_state = TRANSPORT_COMPLETE; | ||
2313 | cmd->transport_state |= CMD_T_ACTIVE; | ||
2314 | spin_unlock_irq(&cmd->t_state_lock); | ||
2315 | |||
2316 | INIT_WORK(&cmd->work, target_complete_ok_work); | ||
2317 | queue_work(target_completion_wq, &cmd->work); | ||
2318 | return 0; | ||
2319 | } | ||
2320 | 2366 | ||
2321 | atomic_inc(&cmd->t_fe_count); | 2367 | atomic_inc(&cmd->t_fe_count); |
2322 | 2368 | ||
@@ -2771,7 +2817,7 @@ bool transport_wait_for_tasks(struct se_cmd *cmd) | |||
2771 | spin_lock_irqsave(&cmd->t_state_lock, flags); | 2817 | spin_lock_irqsave(&cmd->t_state_lock, flags); |
2772 | cmd->transport_state &= ~(CMD_T_ACTIVE | CMD_T_STOP); | 2818 | cmd->transport_state &= ~(CMD_T_ACTIVE | CMD_T_STOP); |
2773 | 2819 | ||
2774 | pr_debug("wait_for_tasks: Stopped wait_for_compltion(" | 2820 | pr_debug("wait_for_tasks: Stopped wait_for_completion(" |
2775 | "&cmd->t_transport_stop_comp) for ITT: 0x%08x\n", | 2821 | "&cmd->t_transport_stop_comp) for ITT: 0x%08x\n", |
2776 | cmd->se_tfo->get_task_tag(cmd)); | 2822 | cmd->se_tfo->get_task_tag(cmd)); |
2777 | 2823 | ||
@@ -2810,7 +2856,6 @@ int transport_send_check_condition_and_sense( | |||
2810 | { | 2856 | { |
2811 | unsigned char *buffer = cmd->sense_buffer; | 2857 | unsigned char *buffer = cmd->sense_buffer; |
2812 | unsigned long flags; | 2858 | unsigned long flags; |
2813 | int offset; | ||
2814 | u8 asc = 0, ascq = 0; | 2859 | u8 asc = 0, ascq = 0; |
2815 | 2860 | ||
2816 | spin_lock_irqsave(&cmd->t_state_lock, flags); | 2861 | spin_lock_irqsave(&cmd->t_state_lock, flags); |
@@ -2826,14 +2871,7 @@ int transport_send_check_condition_and_sense( | |||
2826 | 2871 | ||
2827 | if (!from_transport) | 2872 | if (!from_transport) |
2828 | cmd->se_cmd_flags |= SCF_EMULATED_TASK_SENSE; | 2873 | cmd->se_cmd_flags |= SCF_EMULATED_TASK_SENSE; |
2829 | /* | 2874 | |
2830 | * Data Segment and SenseLength of the fabric response PDU. | ||
2831 | * | ||
2832 | * TRANSPORT_SENSE_BUFFER is now set to SCSI_SENSE_BUFFERSIZE | ||
2833 | * from include/scsi/scsi_cmnd.h | ||
2834 | */ | ||
2835 | offset = cmd->se_tfo->set_fabric_sense_len(cmd, | ||
2836 | TRANSPORT_SENSE_BUFFER); | ||
2837 | /* | 2875 | /* |
2838 | * Actual SENSE DATA, see SPC-3 7.23.2 SPC_SENSE_KEY_OFFSET uses | 2876 | * Actual SENSE DATA, see SPC-3 7.23.2 SPC_SENSE_KEY_OFFSET uses |
2839 | * SENSE KEY values from include/scsi/scsi.h | 2877 | * SENSE KEY values from include/scsi/scsi.h |
@@ -2841,151 +2879,151 @@ int transport_send_check_condition_and_sense( | |||
2841 | switch (reason) { | 2879 | switch (reason) { |
2842 | case TCM_NON_EXISTENT_LUN: | 2880 | case TCM_NON_EXISTENT_LUN: |
2843 | /* CURRENT ERROR */ | 2881 | /* CURRENT ERROR */ |
2844 | buffer[offset] = 0x70; | 2882 | buffer[0] = 0x70; |
2845 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | 2883 | buffer[SPC_ADD_SENSE_LEN_OFFSET] = 10; |
2846 | /* ILLEGAL REQUEST */ | 2884 | /* ILLEGAL REQUEST */ |
2847 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; | 2885 | buffer[SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; |
2848 | /* LOGICAL UNIT NOT SUPPORTED */ | 2886 | /* LOGICAL UNIT NOT SUPPORTED */ |
2849 | buffer[offset+SPC_ASC_KEY_OFFSET] = 0x25; | 2887 | buffer[SPC_ASC_KEY_OFFSET] = 0x25; |
2850 | break; | 2888 | break; |
2851 | case TCM_UNSUPPORTED_SCSI_OPCODE: | 2889 | case TCM_UNSUPPORTED_SCSI_OPCODE: |
2852 | case TCM_SECTOR_COUNT_TOO_MANY: | 2890 | case TCM_SECTOR_COUNT_TOO_MANY: |
2853 | /* CURRENT ERROR */ | 2891 | /* CURRENT ERROR */ |
2854 | buffer[offset] = 0x70; | 2892 | buffer[0] = 0x70; |
2855 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | 2893 | buffer[SPC_ADD_SENSE_LEN_OFFSET] = 10; |
2856 | /* ILLEGAL REQUEST */ | 2894 | /* ILLEGAL REQUEST */ |
2857 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; | 2895 | buffer[SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; |
2858 | /* INVALID COMMAND OPERATION CODE */ | 2896 | /* INVALID COMMAND OPERATION CODE */ |
2859 | buffer[offset+SPC_ASC_KEY_OFFSET] = 0x20; | 2897 | buffer[SPC_ASC_KEY_OFFSET] = 0x20; |
2860 | break; | 2898 | break; |
2861 | case TCM_UNKNOWN_MODE_PAGE: | 2899 | case TCM_UNKNOWN_MODE_PAGE: |
2862 | /* CURRENT ERROR */ | 2900 | /* CURRENT ERROR */ |
2863 | buffer[offset] = 0x70; | 2901 | buffer[0] = 0x70; |
2864 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | 2902 | buffer[SPC_ADD_SENSE_LEN_OFFSET] = 10; |
2865 | /* ILLEGAL REQUEST */ | 2903 | /* ILLEGAL REQUEST */ |
2866 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; | 2904 | buffer[SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; |
2867 | /* INVALID FIELD IN CDB */ | 2905 | /* INVALID FIELD IN CDB */ |
2868 | buffer[offset+SPC_ASC_KEY_OFFSET] = 0x24; | 2906 | buffer[SPC_ASC_KEY_OFFSET] = 0x24; |
2869 | break; | 2907 | break; |
2870 | case TCM_CHECK_CONDITION_ABORT_CMD: | 2908 | case TCM_CHECK_CONDITION_ABORT_CMD: |
2871 | /* CURRENT ERROR */ | 2909 | /* CURRENT ERROR */ |
2872 | buffer[offset] = 0x70; | 2910 | buffer[0] = 0x70; |
2873 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | 2911 | buffer[SPC_ADD_SENSE_LEN_OFFSET] = 10; |
2874 | /* ABORTED COMMAND */ | 2912 | /* ABORTED COMMAND */ |
2875 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; | 2913 | buffer[SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; |
2876 | /* BUS DEVICE RESET FUNCTION OCCURRED */ | 2914 | /* BUS DEVICE RESET FUNCTION OCCURRED */ |
2877 | buffer[offset+SPC_ASC_KEY_OFFSET] = 0x29; | 2915 | buffer[SPC_ASC_KEY_OFFSET] = 0x29; |
2878 | buffer[offset+SPC_ASCQ_KEY_OFFSET] = 0x03; | 2916 | buffer[SPC_ASCQ_KEY_OFFSET] = 0x03; |
2879 | break; | 2917 | break; |
2880 | case TCM_INCORRECT_AMOUNT_OF_DATA: | 2918 | case TCM_INCORRECT_AMOUNT_OF_DATA: |
2881 | /* CURRENT ERROR */ | 2919 | /* CURRENT ERROR */ |
2882 | buffer[offset] = 0x70; | 2920 | buffer[0] = 0x70; |
2883 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | 2921 | buffer[SPC_ADD_SENSE_LEN_OFFSET] = 10; |
2884 | /* ABORTED COMMAND */ | 2922 | /* ABORTED COMMAND */ |
2885 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; | 2923 | buffer[SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; |
2886 | /* WRITE ERROR */ | 2924 | /* WRITE ERROR */ |
2887 | buffer[offset+SPC_ASC_KEY_OFFSET] = 0x0c; | 2925 | buffer[SPC_ASC_KEY_OFFSET] = 0x0c; |
2888 | /* NOT ENOUGH UNSOLICITED DATA */ | 2926 | /* NOT ENOUGH UNSOLICITED DATA */ |
2889 | buffer[offset+SPC_ASCQ_KEY_OFFSET] = 0x0d; | 2927 | buffer[SPC_ASCQ_KEY_OFFSET] = 0x0d; |
2890 | break; | 2928 | break; |
2891 | case TCM_INVALID_CDB_FIELD: | 2929 | case TCM_INVALID_CDB_FIELD: |
2892 | /* CURRENT ERROR */ | 2930 | /* CURRENT ERROR */ |
2893 | buffer[offset] = 0x70; | 2931 | buffer[0] = 0x70; |
2894 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | 2932 | buffer[SPC_ADD_SENSE_LEN_OFFSET] = 10; |
2895 | /* ILLEGAL REQUEST */ | 2933 | /* ILLEGAL REQUEST */ |
2896 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; | 2934 | buffer[SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; |
2897 | /* INVALID FIELD IN CDB */ | 2935 | /* INVALID FIELD IN CDB */ |
2898 | buffer[offset+SPC_ASC_KEY_OFFSET] = 0x24; | 2936 | buffer[SPC_ASC_KEY_OFFSET] = 0x24; |
2899 | break; | 2937 | break; |
2900 | case TCM_INVALID_PARAMETER_LIST: | 2938 | case TCM_INVALID_PARAMETER_LIST: |
2901 | /* CURRENT ERROR */ | 2939 | /* CURRENT ERROR */ |
2902 | buffer[offset] = 0x70; | 2940 | buffer[0] = 0x70; |
2903 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | 2941 | buffer[SPC_ADD_SENSE_LEN_OFFSET] = 10; |
2904 | /* ILLEGAL REQUEST */ | 2942 | /* ILLEGAL REQUEST */ |
2905 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; | 2943 | buffer[SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; |
2906 | /* INVALID FIELD IN PARAMETER LIST */ | 2944 | /* INVALID FIELD IN PARAMETER LIST */ |
2907 | buffer[offset+SPC_ASC_KEY_OFFSET] = 0x26; | 2945 | buffer[SPC_ASC_KEY_OFFSET] = 0x26; |
2908 | break; | 2946 | break; |
2909 | case TCM_UNEXPECTED_UNSOLICITED_DATA: | 2947 | case TCM_UNEXPECTED_UNSOLICITED_DATA: |
2910 | /* CURRENT ERROR */ | 2948 | /* CURRENT ERROR */ |
2911 | buffer[offset] = 0x70; | 2949 | buffer[0] = 0x70; |
2912 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | 2950 | buffer[SPC_ADD_SENSE_LEN_OFFSET] = 10; |
2913 | /* ABORTED COMMAND */ | 2951 | /* ABORTED COMMAND */ |
2914 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; | 2952 | buffer[SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; |
2915 | /* WRITE ERROR */ | 2953 | /* WRITE ERROR */ |
2916 | buffer[offset+SPC_ASC_KEY_OFFSET] = 0x0c; | 2954 | buffer[SPC_ASC_KEY_OFFSET] = 0x0c; |
2917 | /* UNEXPECTED_UNSOLICITED_DATA */ | 2955 | /* UNEXPECTED_UNSOLICITED_DATA */ |
2918 | buffer[offset+SPC_ASCQ_KEY_OFFSET] = 0x0c; | 2956 | buffer[SPC_ASCQ_KEY_OFFSET] = 0x0c; |
2919 | break; | 2957 | break; |
2920 | case TCM_SERVICE_CRC_ERROR: | 2958 | case TCM_SERVICE_CRC_ERROR: |
2921 | /* CURRENT ERROR */ | 2959 | /* CURRENT ERROR */ |
2922 | buffer[offset] = 0x70; | 2960 | buffer[0] = 0x70; |
2923 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | 2961 | buffer[SPC_ADD_SENSE_LEN_OFFSET] = 10; |
2924 | /* ABORTED COMMAND */ | 2962 | /* ABORTED COMMAND */ |
2925 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; | 2963 | buffer[SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; |
2926 | /* PROTOCOL SERVICE CRC ERROR */ | 2964 | /* PROTOCOL SERVICE CRC ERROR */ |
2927 | buffer[offset+SPC_ASC_KEY_OFFSET] = 0x47; | 2965 | buffer[SPC_ASC_KEY_OFFSET] = 0x47; |
2928 | /* N/A */ | 2966 | /* N/A */ |
2929 | buffer[offset+SPC_ASCQ_KEY_OFFSET] = 0x05; | 2967 | buffer[SPC_ASCQ_KEY_OFFSET] = 0x05; |
2930 | break; | 2968 | break; |
2931 | case TCM_SNACK_REJECTED: | 2969 | case TCM_SNACK_REJECTED: |
2932 | /* CURRENT ERROR */ | 2970 | /* CURRENT ERROR */ |
2933 | buffer[offset] = 0x70; | 2971 | buffer[0] = 0x70; |
2934 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | 2972 | buffer[SPC_ADD_SENSE_LEN_OFFSET] = 10; |
2935 | /* ABORTED COMMAND */ | 2973 | /* ABORTED COMMAND */ |
2936 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; | 2974 | buffer[SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND; |
2937 | /* READ ERROR */ | 2975 | /* READ ERROR */ |
2938 | buffer[offset+SPC_ASC_KEY_OFFSET] = 0x11; | 2976 | buffer[SPC_ASC_KEY_OFFSET] = 0x11; |
2939 | /* FAILED RETRANSMISSION REQUEST */ | 2977 | /* FAILED RETRANSMISSION REQUEST */ |
2940 | buffer[offset+SPC_ASCQ_KEY_OFFSET] = 0x13; | 2978 | buffer[SPC_ASCQ_KEY_OFFSET] = 0x13; |
2941 | break; | 2979 | break; |
2942 | case TCM_WRITE_PROTECTED: | 2980 | case TCM_WRITE_PROTECTED: |
2943 | /* CURRENT ERROR */ | 2981 | /* CURRENT ERROR */ |
2944 | buffer[offset] = 0x70; | 2982 | buffer[0] = 0x70; |
2945 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | 2983 | buffer[SPC_ADD_SENSE_LEN_OFFSET] = 10; |
2946 | /* DATA PROTECT */ | 2984 | /* DATA PROTECT */ |
2947 | buffer[offset+SPC_SENSE_KEY_OFFSET] = DATA_PROTECT; | 2985 | buffer[SPC_SENSE_KEY_OFFSET] = DATA_PROTECT; |
2948 | /* WRITE PROTECTED */ | 2986 | /* WRITE PROTECTED */ |
2949 | buffer[offset+SPC_ASC_KEY_OFFSET] = 0x27; | 2987 | buffer[SPC_ASC_KEY_OFFSET] = 0x27; |
2950 | break; | 2988 | break; |
2951 | case TCM_ADDRESS_OUT_OF_RANGE: | 2989 | case TCM_ADDRESS_OUT_OF_RANGE: |
2952 | /* CURRENT ERROR */ | 2990 | /* CURRENT ERROR */ |
2953 | buffer[offset] = 0x70; | 2991 | buffer[0] = 0x70; |
2954 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | 2992 | buffer[SPC_ADD_SENSE_LEN_OFFSET] = 10; |
2955 | /* ILLEGAL REQUEST */ | 2993 | /* ILLEGAL REQUEST */ |
2956 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; | 2994 | buffer[SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; |
2957 | /* LOGICAL BLOCK ADDRESS OUT OF RANGE */ | 2995 | /* LOGICAL BLOCK ADDRESS OUT OF RANGE */ |
2958 | buffer[offset+SPC_ASC_KEY_OFFSET] = 0x21; | 2996 | buffer[SPC_ASC_KEY_OFFSET] = 0x21; |
2959 | break; | 2997 | break; |
2960 | case TCM_CHECK_CONDITION_UNIT_ATTENTION: | 2998 | case TCM_CHECK_CONDITION_UNIT_ATTENTION: |
2961 | /* CURRENT ERROR */ | 2999 | /* CURRENT ERROR */ |
2962 | buffer[offset] = 0x70; | 3000 | buffer[0] = 0x70; |
2963 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | 3001 | buffer[SPC_ADD_SENSE_LEN_OFFSET] = 10; |
2964 | /* UNIT ATTENTION */ | 3002 | /* UNIT ATTENTION */ |
2965 | buffer[offset+SPC_SENSE_KEY_OFFSET] = UNIT_ATTENTION; | 3003 | buffer[SPC_SENSE_KEY_OFFSET] = UNIT_ATTENTION; |
2966 | core_scsi3_ua_for_check_condition(cmd, &asc, &ascq); | 3004 | core_scsi3_ua_for_check_condition(cmd, &asc, &ascq); |
2967 | buffer[offset+SPC_ASC_KEY_OFFSET] = asc; | 3005 | buffer[SPC_ASC_KEY_OFFSET] = asc; |
2968 | buffer[offset+SPC_ASCQ_KEY_OFFSET] = ascq; | 3006 | buffer[SPC_ASCQ_KEY_OFFSET] = ascq; |
2969 | break; | 3007 | break; |
2970 | case TCM_CHECK_CONDITION_NOT_READY: | 3008 | case TCM_CHECK_CONDITION_NOT_READY: |
2971 | /* CURRENT ERROR */ | 3009 | /* CURRENT ERROR */ |
2972 | buffer[offset] = 0x70; | 3010 | buffer[0] = 0x70; |
2973 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | 3011 | buffer[SPC_ADD_SENSE_LEN_OFFSET] = 10; |
2974 | /* Not Ready */ | 3012 | /* Not Ready */ |
2975 | buffer[offset+SPC_SENSE_KEY_OFFSET] = NOT_READY; | 3013 | buffer[SPC_SENSE_KEY_OFFSET] = NOT_READY; |
2976 | transport_get_sense_codes(cmd, &asc, &ascq); | 3014 | transport_get_sense_codes(cmd, &asc, &ascq); |
2977 | buffer[offset+SPC_ASC_KEY_OFFSET] = asc; | 3015 | buffer[SPC_ASC_KEY_OFFSET] = asc; |
2978 | buffer[offset+SPC_ASCQ_KEY_OFFSET] = ascq; | 3016 | buffer[SPC_ASCQ_KEY_OFFSET] = ascq; |
2979 | break; | 3017 | break; |
2980 | case TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE: | 3018 | case TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE: |
2981 | default: | 3019 | default: |
2982 | /* CURRENT ERROR */ | 3020 | /* CURRENT ERROR */ |
2983 | buffer[offset] = 0x70; | 3021 | buffer[0] = 0x70; |
2984 | buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10; | 3022 | buffer[SPC_ADD_SENSE_LEN_OFFSET] = 10; |
2985 | /* ILLEGAL REQUEST */ | 3023 | /* ILLEGAL REQUEST */ |
2986 | buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; | 3024 | buffer[SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST; |
2987 | /* LOGICAL UNIT COMMUNICATION FAILURE */ | 3025 | /* LOGICAL UNIT COMMUNICATION FAILURE */ |
2988 | buffer[offset+SPC_ASC_KEY_OFFSET] = 0x80; | 3026 | buffer[SPC_ASC_KEY_OFFSET] = 0x80; |
2989 | break; | 3027 | break; |
2990 | } | 3028 | } |
2991 | /* | 3029 | /* |
@@ -2996,7 +3034,7 @@ int transport_send_check_condition_and_sense( | |||
2996 | * Automatically padded, this value is encoded in the fabric's | 3034 | * Automatically padded, this value is encoded in the fabric's |
2997 | * data_length response PDU containing the SCSI defined sense data. | 3035 | * data_length response PDU containing the SCSI defined sense data. |
2998 | */ | 3036 | */ |
2999 | cmd->scsi_sense_length = TRANSPORT_SENSE_BUFFER + offset; | 3037 | cmd->scsi_sense_length = TRANSPORT_SENSE_BUFFER; |
3000 | 3038 | ||
3001 | after_reason: | 3039 | after_reason: |
3002 | return cmd->se_tfo->queue_status(cmd); | 3040 | return cmd->se_tfo->queue_status(cmd); |
diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c index 823e6922249d..b406f178ff39 100644 --- a/drivers/target/tcm_fc/tfc_cmd.c +++ b/drivers/target/tcm_fc/tfc_cmd.c | |||
@@ -19,7 +19,6 @@ | |||
19 | 19 | ||
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/moduleparam.h> | 21 | #include <linux/moduleparam.h> |
22 | #include <generated/utsrelease.h> | ||
23 | #include <linux/utsname.h> | 22 | #include <linux/utsname.h> |
24 | #include <linux/init.h> | 23 | #include <linux/init.h> |
25 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
diff --git a/drivers/target/tcm_fc/tfc_conf.c b/drivers/target/tcm_fc/tfc_conf.c index 9501844fae2d..b74feb0d5133 100644 --- a/drivers/target/tcm_fc/tfc_conf.c +++ b/drivers/target/tcm_fc/tfc_conf.c | |||
@@ -495,16 +495,6 @@ static void ft_set_default_node_attr(struct se_node_acl *se_nacl) | |||
495 | { | 495 | { |
496 | } | 496 | } |
497 | 497 | ||
498 | static u16 ft_get_fabric_sense_len(void) | ||
499 | { | ||
500 | return 0; | ||
501 | } | ||
502 | |||
503 | static u16 ft_set_fabric_sense_len(struct se_cmd *se_cmd, u32 sense_len) | ||
504 | { | ||
505 | return 0; | ||
506 | } | ||
507 | |||
508 | static u32 ft_tpg_get_inst_index(struct se_portal_group *se_tpg) | 498 | static u32 ft_tpg_get_inst_index(struct se_portal_group *se_tpg) |
509 | { | 499 | { |
510 | struct ft_tpg *tpg = se_tpg->se_tpg_fabric_ptr; | 500 | struct ft_tpg *tpg = se_tpg->se_tpg_fabric_ptr; |
@@ -542,8 +532,6 @@ static struct target_core_fabric_ops ft_fabric_ops = { | |||
542 | .queue_data_in = ft_queue_data_in, | 532 | .queue_data_in = ft_queue_data_in, |
543 | .queue_status = ft_queue_status, | 533 | .queue_status = ft_queue_status, |
544 | .queue_tm_rsp = ft_queue_tm_resp, | 534 | .queue_tm_rsp = ft_queue_tm_resp, |
545 | .get_fabric_sense_len = ft_get_fabric_sense_len, | ||
546 | .set_fabric_sense_len = ft_set_fabric_sense_len, | ||
547 | /* | 535 | /* |
548 | * Setup function pointers for generic logic in | 536 | * Setup function pointers for generic logic in |
549 | * target_core_fabric_configfs.c | 537 | * target_core_fabric_configfs.c |
diff --git a/drivers/target/tcm_fc/tfc_io.c b/drivers/target/tcm_fc/tfc_io.c index ad36ede1a1ea..b6fd4cf42840 100644 --- a/drivers/target/tcm_fc/tfc_io.c +++ b/drivers/target/tcm_fc/tfc_io.c | |||
@@ -28,7 +28,6 @@ | |||
28 | 28 | ||
29 | #include <linux/module.h> | 29 | #include <linux/module.h> |
30 | #include <linux/moduleparam.h> | 30 | #include <linux/moduleparam.h> |
31 | #include <generated/utsrelease.h> | ||
32 | #include <linux/utsname.h> | 31 | #include <linux/utsname.h> |
33 | #include <linux/init.h> | 32 | #include <linux/init.h> |
34 | #include <linux/slab.h> | 33 | #include <linux/slab.h> |
@@ -328,11 +327,12 @@ drop: | |||
328 | */ | 327 | */ |
329 | void ft_invl_hw_context(struct ft_cmd *cmd) | 328 | void ft_invl_hw_context(struct ft_cmd *cmd) |
330 | { | 329 | { |
331 | struct fc_seq *seq = cmd->seq; | 330 | struct fc_seq *seq; |
332 | struct fc_exch *ep = NULL; | 331 | struct fc_exch *ep = NULL; |
333 | struct fc_lport *lport = NULL; | 332 | struct fc_lport *lport = NULL; |
334 | 333 | ||
335 | BUG_ON(!cmd); | 334 | BUG_ON(!cmd); |
335 | seq = cmd->seq; | ||
336 | 336 | ||
337 | /* Cleanup the DDP context in HW if DDP was setup */ | 337 | /* Cleanup the DDP context in HW if DDP was setup */ |
338 | if (cmd->was_ddp_setup && seq) { | 338 | if (cmd->was_ddp_setup && seq) { |
diff --git a/drivers/target/tcm_fc/tfc_sess.c b/drivers/target/tcm_fc/tfc_sess.c index 3c9e5b57caab..9585010964ec 100644 --- a/drivers/target/tcm_fc/tfc_sess.c +++ b/drivers/target/tcm_fc/tfc_sess.c | |||
@@ -19,7 +19,6 @@ | |||
19 | 19 | ||
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/moduleparam.h> | 21 | #include <linux/moduleparam.h> |
22 | #include <generated/utsrelease.h> | ||
23 | #include <linux/utsname.h> | 22 | #include <linux/utsname.h> |
24 | #include <linux/init.h> | 23 | #include <linux/init.h> |
25 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |