diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-15 17:25:10 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-15 17:25:10 -0500 |
commit | 5bd665f28db2b04a8d6fe277342479906fc60b62 (patch) | |
tree | 4f9f63120fed3a61b44bbb7ec4ebaaa4dc4fc571 /drivers/target/iscsi | |
parent | 115b1cc2ef0f43ecb42bdbf55f06e9d2231d5a7e (diff) | |
parent | 79e62fc3827bd437c304c1810f36896fc1e717b1 (diff) |
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending
Pull target updates from Nicholas Bellinger:
"It has been a very busy development cycle this time around in target
land, with the highlights including:
- Kill struct se_subsystem_dev, in favor of direct se_device usage
(hch)
- Simplify reservations code by combining SPC-3 + SCSI-2 support for
virtual backends only (hch)
- Simplify ALUA code for virtual only backends, and remove left over
abstractions (hch)
- Pass sense_reason_t as return value for I/O submission path (hch)
- Refactor MODE_SENSE emulation to allow for easier addition of new
mode pages. (roland)
- Add emulation of MODE_SELECT (roland)
- Fix bug in handling of ExpStatSN wrap-around (steve)
- Fix bug in TMR ABORT_TASK lookup in qla2xxx target (steve)
- Add WRITE_SAME w/ UNMAP=0 support for IBLOCK backends (nab)
- Convert ib_srpt to use modern target_submit_cmd caller + drop
legacy ioctx->kref usage (nab)
- Convert ib_srpt to use modern target_submit_tmr caller (nab)
- Add link_magic for fabric allow_link destination target_items for
symlinks within target_core_fabric_configfs.c code (nab)
- Allocate pointers in instead of full structs for
config_group->default_groups (sebastian)
- Fix 32-bit highmem breakage for FILEIO (sebastian)
All told, hch was able to shave off another ~1K LOC by killing the
se_subsystem_dev abstraction, along with a number of PR + ALUA
simplifications. Also, a nice patch by Roland is the refactoring of
MODE_SENSE handling, along with the addition of initial MODE_SELECT
emulation support for virtual backends.
Sebastian found a long-standing issue wrt to allocation of full
config_group instead of pointers for config_group->default_group[]
setup in a number of areas, which ends up saving memory with big
configurations. He also managed to fix another long-standing BUG wrt
to broken 32-bit highmem support within the FILEIO backend driver.
Thank you again to everyone who contributed this round!"
* 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: (50 commits)
target/iscsi_target: Add NodeACL tags for initiator group support
target/tcm_fc: fix the lockdep warning due to inconsistent lock state
sbp-target: fix error path in sbp_make_tpg()
sbp-target: use simple assignment in tgt_agent_rw_agent_state()
iscsi-target: use kstrdup() for iscsi_param
target/file: merge fd_do_readv() and fd_do_writev()
target/file: Fix 32-bit highmem breakage for SGL -> iovec mapping
target: Add link_magic for fabric allow_link destination target_items
ib_srpt: Convert TMR path to target_submit_tmr
ib_srpt: Convert I/O path to target_submit_cmd + drop legacy ioctx->kref
target: Make spc_get_write_same_sectors return sector_t
target/configfs: use kmalloc() instead of kzalloc() for default groups
target/configfs: allocate only 6 slots for dev_cg->default_groups
target/configfs: allocate pointers instead of full struct for default_groups
target: update error handling for sbc_setup_write_same()
iscsit: use GFP_ATOMIC under spin lock
iscsi_target: Remove redundant null check before kfree
target/iblock: Forward declare bio helpers
target: Clean up flow in transport_check_aborted_status()
target: Clean up logic in transport_put_cmd()
...
Diffstat (limited to 'drivers/target/iscsi')
-rw-r--r-- | drivers/target/iscsi/iscsi_target.c | 84 | ||||
-rw-r--r-- | drivers/target/iscsi/iscsi_target_configfs.c | 28 | ||||
-rw-r--r-- | drivers/target/iscsi/iscsi_target_core.h | 2 | ||||
-rw-r--r-- | drivers/target/iscsi/iscsi_target_erl1.c | 11 | ||||
-rw-r--r-- | drivers/target/iscsi/iscsi_target_erl2.c | 2 | ||||
-rw-r--r-- | drivers/target/iscsi/iscsi_target_login.c | 18 | ||||
-rw-r--r-- | drivers/target/iscsi/iscsi_target_nego.c | 10 | ||||
-rw-r--r-- | drivers/target/iscsi/iscsi_target_parameters.c | 16 | ||||
-rw-r--r-- | drivers/target/iscsi/iscsi_target_tmr.c | 4 | ||||
-rw-r--r-- | drivers/target/iscsi/iscsi_target_tq.c | 3 | ||||
-rw-r--r-- | drivers/target/iscsi/iscsi_target_util.c | 8 |
11 files changed, 89 insertions, 97 deletions
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 035c2c762537..339f97f7085b 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c | |||
@@ -735,7 +735,7 @@ static void iscsit_ack_from_expstatsn(struct iscsi_conn *conn, u32 exp_statsn) | |||
735 | list_for_each_entry(cmd, &conn->conn_cmd_list, i_conn_node) { | 735 | list_for_each_entry(cmd, &conn->conn_cmd_list, i_conn_node) { |
736 | spin_lock(&cmd->istate_lock); | 736 | spin_lock(&cmd->istate_lock); |
737 | if ((cmd->i_state == ISTATE_SENT_STATUS) && | 737 | if ((cmd->i_state == ISTATE_SENT_STATUS) && |
738 | (cmd->stat_sn < exp_statsn)) { | 738 | iscsi_sna_lt(cmd->stat_sn, exp_statsn)) { |
739 | cmd->i_state = ISTATE_REMOVE; | 739 | cmd->i_state = ISTATE_REMOVE; |
740 | spin_unlock(&cmd->istate_lock); | 740 | spin_unlock(&cmd->istate_lock); |
741 | iscsit_add_cmd_to_immediate_queue(cmd, conn, | 741 | iscsit_add_cmd_to_immediate_queue(cmd, conn, |
@@ -767,9 +767,8 @@ static int iscsit_handle_scsi_cmd( | |||
767 | struct iscsi_conn *conn, | 767 | struct iscsi_conn *conn, |
768 | unsigned char *buf) | 768 | unsigned char *buf) |
769 | { | 769 | { |
770 | int data_direction, cmdsn_ret = 0, immed_ret, ret, transport_ret; | 770 | int data_direction, payload_length, cmdsn_ret = 0, immed_ret; |
771 | int dump_immediate_data = 0, send_check_condition = 0, payload_length; | 771 | struct iscsi_cmd *cmd = NULL; |
772 | struct iscsi_cmd *cmd = NULL; | ||
773 | struct iscsi_scsi_req *hdr; | 772 | struct iscsi_scsi_req *hdr; |
774 | int iscsi_task_attr; | 773 | int iscsi_task_attr; |
775 | int sam_task_attr; | 774 | int sam_task_attr; |
@@ -956,38 +955,26 @@ done: | |||
956 | " ExpXferLen: %u, Length: %u, CID: %hu\n", hdr->itt, | 955 | " ExpXferLen: %u, Length: %u, CID: %hu\n", hdr->itt, |
957 | hdr->cmdsn, hdr->data_length, payload_length, conn->cid); | 956 | hdr->cmdsn, hdr->data_length, payload_length, conn->cid); |
958 | 957 | ||
959 | /* | 958 | cmd->sense_reason = transport_lookup_cmd_lun(&cmd->se_cmd, |
960 | * The CDB is going to an se_device_t. | 959 | scsilun_to_int(&hdr->lun)); |
961 | */ | 960 | if (cmd->sense_reason) |
962 | ret = transport_lookup_cmd_lun(&cmd->se_cmd, | 961 | goto attach_cmd; |
963 | scsilun_to_int(&hdr->lun)); | 962 | |
964 | if (ret < 0) { | 963 | cmd->sense_reason = target_setup_cmd_from_cdb(&cmd->se_cmd, hdr->cdb); |
965 | if (cmd->se_cmd.scsi_sense_reason == TCM_NON_EXISTENT_LUN) { | 964 | if (cmd->sense_reason) { |
966 | pr_debug("Responding to non-acl'ed," | 965 | if (cmd->sense_reason == TCM_OUT_OF_RESOURCES) { |
967 | " non-existent or non-exported iSCSI LUN:" | 966 | return iscsit_add_reject_from_cmd( |
968 | " 0x%016Lx\n", get_unaligned_le64(&hdr->lun)); | 967 | ISCSI_REASON_BOOKMARK_NO_RESOURCES, |
968 | 1, 1, buf, cmd); | ||
969 | } | 969 | } |
970 | send_check_condition = 1; | 970 | |
971 | goto attach_cmd; | 971 | goto attach_cmd; |
972 | } | 972 | } |
973 | 973 | ||
974 | transport_ret = target_setup_cmd_from_cdb(&cmd->se_cmd, hdr->cdb); | 974 | if (iscsit_build_pdu_and_seq_lists(cmd, payload_length) < 0) { |
975 | if (transport_ret == -ENOMEM) { | ||
976 | return iscsit_add_reject_from_cmd( | 975 | return iscsit_add_reject_from_cmd( |
977 | ISCSI_REASON_BOOKMARK_NO_RESOURCES, | 976 | ISCSI_REASON_BOOKMARK_NO_RESOURCES, |
978 | 1, 1, buf, cmd); | 977 | 1, 1, buf, cmd); |
979 | } else if (transport_ret < 0) { | ||
980 | /* | ||
981 | * Unsupported SAM Opcode. CHECK_CONDITION will be sent | ||
982 | * in iscsit_execute_cmd() during the CmdSN OOO Execution | ||
983 | * Mechinism. | ||
984 | */ | ||
985 | send_check_condition = 1; | ||
986 | } else { | ||
987 | if (iscsit_build_pdu_and_seq_lists(cmd, payload_length) < 0) | ||
988 | return iscsit_add_reject_from_cmd( | ||
989 | ISCSI_REASON_BOOKMARK_NO_RESOURCES, | ||
990 | 1, 1, buf, cmd); | ||
991 | } | 978 | } |
992 | 979 | ||
993 | attach_cmd: | 980 | attach_cmd: |
@@ -1000,11 +987,12 @@ attach_cmd: | |||
1000 | */ | 987 | */ |
1001 | core_alua_check_nonop_delay(&cmd->se_cmd); | 988 | core_alua_check_nonop_delay(&cmd->se_cmd); |
1002 | 989 | ||
1003 | ret = iscsit_allocate_iovecs(cmd); | 990 | if (iscsit_allocate_iovecs(cmd) < 0) { |
1004 | if (ret < 0) | ||
1005 | return iscsit_add_reject_from_cmd( | 991 | return iscsit_add_reject_from_cmd( |
1006 | ISCSI_REASON_BOOKMARK_NO_RESOURCES, | 992 | ISCSI_REASON_BOOKMARK_NO_RESOURCES, |
1007 | 1, 0, buf, cmd); | 993 | 1, 0, buf, cmd); |
994 | } | ||
995 | |||
1008 | /* | 996 | /* |
1009 | * Check the CmdSN against ExpCmdSN/MaxCmdSN here if | 997 | * Check the CmdSN against ExpCmdSN/MaxCmdSN here if |
1010 | * the Immediate Bit is not set, and no Immediate | 998 | * the Immediate Bit is not set, and no Immediate |
@@ -1031,10 +1019,7 @@ attach_cmd: | |||
1031 | * If no Immediate Data is attached, it's OK to return now. | 1019 | * If no Immediate Data is attached, it's OK to return now. |
1032 | */ | 1020 | */ |
1033 | if (!cmd->immediate_data) { | 1021 | if (!cmd->immediate_data) { |
1034 | if (send_check_condition) | 1022 | if (!cmd->sense_reason && cmd->unsolicited_data) { |
1035 | return 0; | ||
1036 | |||
1037 | if (cmd->unsolicited_data) { | ||
1038 | iscsit_set_dataout_sequence_values(cmd); | 1023 | iscsit_set_dataout_sequence_values(cmd); |
1039 | 1024 | ||
1040 | spin_lock_bh(&cmd->dataout_timeout_lock); | 1025 | spin_lock_bh(&cmd->dataout_timeout_lock); |
@@ -1050,19 +1035,17 @@ attach_cmd: | |||
1050 | * thread. They are processed in CmdSN order by | 1035 | * thread. They are processed in CmdSN order by |
1051 | * iscsit_check_received_cmdsn() below. | 1036 | * iscsit_check_received_cmdsn() below. |
1052 | */ | 1037 | */ |
1053 | if (send_check_condition) { | 1038 | if (cmd->sense_reason) { |
1054 | immed_ret = IMMEDIATE_DATA_NORMAL_OPERATION; | 1039 | immed_ret = IMMEDIATE_DATA_NORMAL_OPERATION; |
1055 | dump_immediate_data = 1; | ||
1056 | goto after_immediate_data; | 1040 | goto after_immediate_data; |
1057 | } | 1041 | } |
1058 | /* | 1042 | /* |
1059 | * Call directly into transport_generic_new_cmd() to perform | 1043 | * Call directly into transport_generic_new_cmd() to perform |
1060 | * the backend memory allocation. | 1044 | * the backend memory allocation. |
1061 | */ | 1045 | */ |
1062 | ret = transport_generic_new_cmd(&cmd->se_cmd); | 1046 | cmd->sense_reason = transport_generic_new_cmd(&cmd->se_cmd); |
1063 | if (ret < 0) { | 1047 | if (cmd->sense_reason) { |
1064 | immed_ret = IMMEDIATE_DATA_NORMAL_OPERATION; | 1048 | immed_ret = IMMEDIATE_DATA_NORMAL_OPERATION; |
1065 | dump_immediate_data = 1; | ||
1066 | goto after_immediate_data; | 1049 | goto after_immediate_data; |
1067 | } | 1050 | } |
1068 | 1051 | ||
@@ -1079,7 +1062,7 @@ after_immediate_data: | |||
1079 | * Special case for Unsupported SAM WRITE Opcodes | 1062 | * Special case for Unsupported SAM WRITE Opcodes |
1080 | * and ImmediateData=Yes. | 1063 | * and ImmediateData=Yes. |
1081 | */ | 1064 | */ |
1082 | if (dump_immediate_data) { | 1065 | if (cmd->sense_reason) { |
1083 | if (iscsit_dump_data_payload(conn, payload_length, 1) < 0) | 1066 | if (iscsit_dump_data_payload(conn, payload_length, 1) < 0) |
1084 | return -1; | 1067 | return -1; |
1085 | } else if (cmd->unsolicited_data) { | 1068 | } else if (cmd->unsolicited_data) { |
@@ -1272,8 +1255,7 @@ static int iscsit_handle_data_out(struct iscsi_conn *conn, unsigned char *buf) | |||
1272 | spin_unlock_irqrestore(&se_cmd->t_state_lock, flags); | 1255 | spin_unlock_irqrestore(&se_cmd->t_state_lock, flags); |
1273 | 1256 | ||
1274 | spin_lock_irqsave(&se_cmd->t_state_lock, flags); | 1257 | spin_lock_irqsave(&se_cmd->t_state_lock, flags); |
1275 | if (!(se_cmd->se_cmd_flags & SCF_SUPPORTED_SAM_OPCODE) || | 1258 | if (!(se_cmd->se_cmd_flags & SCF_SUPPORTED_SAM_OPCODE)) |
1276 | (se_cmd->se_cmd_flags & SCF_SCSI_CDB_EXCEPTION)) | ||
1277 | dump_unsolicited_data = 1; | 1259 | dump_unsolicited_data = 1; |
1278 | spin_unlock_irqrestore(&se_cmd->t_state_lock, flags); | 1260 | spin_unlock_irqrestore(&se_cmd->t_state_lock, flags); |
1279 | 1261 | ||
@@ -1742,7 +1724,6 @@ static int iscsit_handle_task_mgt_cmd( | |||
1742 | ret = transport_lookup_tmr_lun(&cmd->se_cmd, | 1724 | ret = transport_lookup_tmr_lun(&cmd->se_cmd, |
1743 | scsilun_to_int(&hdr->lun)); | 1725 | scsilun_to_int(&hdr->lun)); |
1744 | if (ret < 0) { | 1726 | if (ret < 0) { |
1745 | cmd->se_cmd.se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; | ||
1746 | se_tmr->response = ISCSI_TMF_RSP_NO_LUN; | 1727 | se_tmr->response = ISCSI_TMF_RSP_NO_LUN; |
1747 | goto attach; | 1728 | goto attach; |
1748 | } | 1729 | } |
@@ -1751,10 +1732,8 @@ static int iscsit_handle_task_mgt_cmd( | |||
1751 | switch (function) { | 1732 | switch (function) { |
1752 | case ISCSI_TM_FUNC_ABORT_TASK: | 1733 | case ISCSI_TM_FUNC_ABORT_TASK: |
1753 | se_tmr->response = iscsit_tmr_abort_task(cmd, buf); | 1734 | se_tmr->response = iscsit_tmr_abort_task(cmd, buf); |
1754 | if (se_tmr->response != ISCSI_TMF_RSP_COMPLETE) { | 1735 | if (se_tmr->response) |
1755 | cmd->se_cmd.se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; | ||
1756 | goto attach; | 1736 | goto attach; |
1757 | } | ||
1758 | break; | 1737 | break; |
1759 | case ISCSI_TM_FUNC_ABORT_TASK_SET: | 1738 | case ISCSI_TM_FUNC_ABORT_TASK_SET: |
1760 | case ISCSI_TM_FUNC_CLEAR_ACA: | 1739 | case ISCSI_TM_FUNC_CLEAR_ACA: |
@@ -1763,14 +1742,12 @@ static int iscsit_handle_task_mgt_cmd( | |||
1763 | break; | 1742 | break; |
1764 | case ISCSI_TM_FUNC_TARGET_WARM_RESET: | 1743 | case ISCSI_TM_FUNC_TARGET_WARM_RESET: |
1765 | if (iscsit_tmr_task_warm_reset(conn, tmr_req, buf) < 0) { | 1744 | if (iscsit_tmr_task_warm_reset(conn, tmr_req, buf) < 0) { |
1766 | cmd->se_cmd.se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; | ||
1767 | se_tmr->response = ISCSI_TMF_RSP_AUTH_FAILED; | 1745 | se_tmr->response = ISCSI_TMF_RSP_AUTH_FAILED; |
1768 | goto attach; | 1746 | goto attach; |
1769 | } | 1747 | } |
1770 | break; | 1748 | break; |
1771 | case ISCSI_TM_FUNC_TARGET_COLD_RESET: | 1749 | case ISCSI_TM_FUNC_TARGET_COLD_RESET: |
1772 | if (iscsit_tmr_task_cold_reset(conn, tmr_req, buf) < 0) { | 1750 | if (iscsit_tmr_task_cold_reset(conn, tmr_req, buf) < 0) { |
1773 | cmd->se_cmd.se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; | ||
1774 | se_tmr->response = ISCSI_TMF_RSP_AUTH_FAILED; | 1751 | se_tmr->response = ISCSI_TMF_RSP_AUTH_FAILED; |
1775 | goto attach; | 1752 | goto attach; |
1776 | } | 1753 | } |
@@ -1781,7 +1758,7 @@ static int iscsit_handle_task_mgt_cmd( | |||
1781 | * Perform sanity checks on the ExpDataSN only if the | 1758 | * Perform sanity checks on the ExpDataSN only if the |
1782 | * TASK_REASSIGN was successful. | 1759 | * TASK_REASSIGN was successful. |
1783 | */ | 1760 | */ |
1784 | if (se_tmr->response != ISCSI_TMF_RSP_COMPLETE) | 1761 | if (se_tmr->response) |
1785 | break; | 1762 | break; |
1786 | 1763 | ||
1787 | if (iscsit_check_task_reassign_expdatasn(tmr_req, conn) < 0) | 1764 | if (iscsit_check_task_reassign_expdatasn(tmr_req, conn) < 0) |
@@ -1792,7 +1769,6 @@ static int iscsit_handle_task_mgt_cmd( | |||
1792 | default: | 1769 | default: |
1793 | pr_err("Unknown TMR function: 0x%02x, protocol" | 1770 | pr_err("Unknown TMR function: 0x%02x, protocol" |
1794 | " error.\n", function); | 1771 | " error.\n", function); |
1795 | cmd->se_cmd.se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; | ||
1796 | se_tmr->response = ISCSI_TMF_RSP_NOT_SUPPORTED; | 1772 | se_tmr->response = ISCSI_TMF_RSP_NOT_SUPPORTED; |
1797 | goto attach; | 1773 | goto attach; |
1798 | } | 1774 | } |
@@ -2360,7 +2336,7 @@ static void iscsit_build_conn_drop_async_message(struct iscsi_conn *conn) | |||
2360 | if (!conn_p) | 2336 | if (!conn_p) |
2361 | return; | 2337 | return; |
2362 | 2338 | ||
2363 | cmd = iscsit_allocate_cmd(conn_p, GFP_KERNEL); | 2339 | cmd = iscsit_allocate_cmd(conn_p, GFP_ATOMIC); |
2364 | if (!cmd) { | 2340 | if (!cmd) { |
2365 | iscsit_dec_conn_usage_count(conn_p); | 2341 | iscsit_dec_conn_usage_count(conn_p); |
2366 | return; | 2342 | return; |
diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c index 0f03b7919d7c..78d75c8567d0 100644 --- a/drivers/target/iscsi/iscsi_target_configfs.c +++ b/drivers/target/iscsi/iscsi_target_configfs.c | |||
@@ -754,9 +754,33 @@ static ssize_t lio_target_nacl_store_cmdsn_depth( | |||
754 | 754 | ||
755 | TF_NACL_BASE_ATTR(lio_target, cmdsn_depth, S_IRUGO | S_IWUSR); | 755 | TF_NACL_BASE_ATTR(lio_target, cmdsn_depth, S_IRUGO | S_IWUSR); |
756 | 756 | ||
757 | static ssize_t lio_target_nacl_show_tag( | ||
758 | struct se_node_acl *se_nacl, | ||
759 | char *page) | ||
760 | { | ||
761 | return snprintf(page, PAGE_SIZE, "%s", se_nacl->acl_tag); | ||
762 | } | ||
763 | |||
764 | static ssize_t lio_target_nacl_store_tag( | ||
765 | struct se_node_acl *se_nacl, | ||
766 | const char *page, | ||
767 | size_t count) | ||
768 | { | ||
769 | int ret; | ||
770 | |||
771 | ret = core_tpg_set_initiator_node_tag(se_nacl->se_tpg, se_nacl, page); | ||
772 | |||
773 | if (ret < 0) | ||
774 | return ret; | ||
775 | return count; | ||
776 | } | ||
777 | |||
778 | TF_NACL_BASE_ATTR(lio_target, tag, S_IRUGO | S_IWUSR); | ||
779 | |||
757 | static struct configfs_attribute *lio_target_initiator_attrs[] = { | 780 | static struct configfs_attribute *lio_target_initiator_attrs[] = { |
758 | &lio_target_nacl_info.attr, | 781 | &lio_target_nacl_info.attr, |
759 | &lio_target_nacl_cmdsn_depth.attr, | 782 | &lio_target_nacl_cmdsn_depth.attr, |
783 | &lio_target_nacl_tag.attr, | ||
760 | NULL, | 784 | NULL, |
761 | }; | 785 | }; |
762 | 786 | ||
@@ -803,7 +827,7 @@ static struct se_node_acl *lio_target_make_nodeacl( | |||
803 | acl = container_of(se_nacl, struct iscsi_node_acl, se_node_acl); | 827 | acl = container_of(se_nacl, struct iscsi_node_acl, se_node_acl); |
804 | stats_cg = &se_nacl->acl_fabric_stat_group; | 828 | stats_cg = &se_nacl->acl_fabric_stat_group; |
805 | 829 | ||
806 | stats_cg->default_groups = kzalloc(sizeof(struct config_group) * 2, | 830 | stats_cg->default_groups = kmalloc(sizeof(struct config_group *) * 2, |
807 | GFP_KERNEL); | 831 | GFP_KERNEL); |
808 | if (!stats_cg->default_groups) { | 832 | if (!stats_cg->default_groups) { |
809 | pr_err("Unable to allocate memory for" | 833 | pr_err("Unable to allocate memory for" |
@@ -1268,7 +1292,7 @@ static struct se_wwn *lio_target_call_coreaddtiqn( | |||
1268 | */ | 1292 | */ |
1269 | stats_cg = &tiqn->tiqn_wwn.fabric_stat_group; | 1293 | stats_cg = &tiqn->tiqn_wwn.fabric_stat_group; |
1270 | 1294 | ||
1271 | stats_cg->default_groups = kzalloc(sizeof(struct config_group) * 6, | 1295 | stats_cg->default_groups = kmalloc(sizeof(struct config_group *) * 6, |
1272 | GFP_KERNEL); | 1296 | GFP_KERNEL); |
1273 | if (!stats_cg->default_groups) { | 1297 | if (!stats_cg->default_groups) { |
1274 | pr_err("Unable to allocate memory for" | 1298 | pr_err("Unable to allocate memory for" |
diff --git a/drivers/target/iscsi/iscsi_target_core.h b/drivers/target/iscsi/iscsi_target_core.h index 21048dbf7d13..7a333d28d9a2 100644 --- a/drivers/target/iscsi/iscsi_target_core.h +++ b/drivers/target/iscsi/iscsi_target_core.h | |||
@@ -474,7 +474,7 @@ struct iscsi_cmd { | |||
474 | struct scatterlist *first_data_sg; | 474 | struct scatterlist *first_data_sg; |
475 | u32 first_data_sg_off; | 475 | u32 first_data_sg_off; |
476 | u32 kmapped_nents; | 476 | u32 kmapped_nents; |
477 | 477 | sense_reason_t sense_reason; | |
478 | } ____cacheline_aligned; | 478 | } ____cacheline_aligned; |
479 | 479 | ||
480 | struct iscsi_tmr_req { | 480 | struct iscsi_tmr_req { |
diff --git a/drivers/target/iscsi/iscsi_target_erl1.c b/drivers/target/iscsi/iscsi_target_erl1.c index 21f29d91a8cb..0b52a2371305 100644 --- a/drivers/target/iscsi/iscsi_target_erl1.c +++ b/drivers/target/iscsi/iscsi_target_erl1.c | |||
@@ -929,11 +929,10 @@ int iscsit_execute_cmd(struct iscsi_cmd *cmd, int ooo) | |||
929 | case ISCSI_OP_SCSI_CMD: | 929 | case ISCSI_OP_SCSI_CMD: |
930 | /* | 930 | /* |
931 | * Go ahead and send the CHECK_CONDITION status for | 931 | * Go ahead and send the CHECK_CONDITION status for |
932 | * any SCSI CDB exceptions that may have occurred, also | 932 | * any SCSI CDB exceptions that may have occurred. |
933 | * handle the SCF_SCSI_RESERVATION_CONFLICT case here as well. | ||
934 | */ | 933 | */ |
935 | if (se_cmd->se_cmd_flags & SCF_SCSI_CDB_EXCEPTION) { | 934 | if (cmd->sense_reason) { |
936 | if (se_cmd->scsi_sense_reason == TCM_RESERVATION_CONFLICT) { | 935 | if (cmd->sense_reason == TCM_RESERVATION_CONFLICT) { |
937 | cmd->i_state = ISTATE_SEND_STATUS; | 936 | cmd->i_state = ISTATE_SEND_STATUS; |
938 | spin_unlock_bh(&cmd->istate_lock); | 937 | spin_unlock_bh(&cmd->istate_lock); |
939 | iscsit_add_cmd_to_response_queue(cmd, cmd->conn, | 938 | iscsit_add_cmd_to_response_queue(cmd, cmd->conn, |
@@ -956,7 +955,7 @@ int iscsit_execute_cmd(struct iscsi_cmd *cmd, int ooo) | |||
956 | * exception | 955 | * exception |
957 | */ | 956 | */ |
958 | return transport_send_check_condition_and_sense(se_cmd, | 957 | return transport_send_check_condition_and_sense(se_cmd, |
959 | se_cmd->scsi_sense_reason, 0); | 958 | cmd->sense_reason, 0); |
960 | } | 959 | } |
961 | /* | 960 | /* |
962 | * Special case for delayed CmdSN with Immediate | 961 | * Special case for delayed CmdSN with Immediate |
@@ -1013,7 +1012,7 @@ int iscsit_execute_cmd(struct iscsi_cmd *cmd, int ooo) | |||
1013 | iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state); | 1012 | iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state); |
1014 | break; | 1013 | break; |
1015 | case ISCSI_OP_SCSI_TMFUNC: | 1014 | case ISCSI_OP_SCSI_TMFUNC: |
1016 | if (se_cmd->se_cmd_flags & SCF_SCSI_CDB_EXCEPTION) { | 1015 | if (cmd->se_cmd.se_tmr_req->response) { |
1017 | spin_unlock_bh(&cmd->istate_lock); | 1016 | spin_unlock_bh(&cmd->istate_lock); |
1018 | iscsit_add_cmd_to_response_queue(cmd, cmd->conn, | 1017 | iscsit_add_cmd_to_response_queue(cmd, cmd->conn, |
1019 | cmd->i_state); | 1018 | cmd->i_state); |
diff --git a/drivers/target/iscsi/iscsi_target_erl2.c b/drivers/target/iscsi/iscsi_target_erl2.c index 17d8c20094fd..9ac4c151eae4 100644 --- a/drivers/target/iscsi/iscsi_target_erl2.c +++ b/drivers/target/iscsi/iscsi_target_erl2.c | |||
@@ -372,7 +372,7 @@ int iscsit_prepare_cmds_for_realligance(struct iscsi_conn *conn) | |||
372 | * made generic here. | 372 | * made generic here. |
373 | */ | 373 | */ |
374 | if (!(cmd->cmd_flags & ICF_OOO_CMDSN) && !cmd->immediate_cmd && | 374 | if (!(cmd->cmd_flags & ICF_OOO_CMDSN) && !cmd->immediate_cmd && |
375 | (cmd->cmd_sn >= conn->sess->exp_cmd_sn)) { | 375 | iscsi_sna_gte(cmd->stat_sn, conn->sess->exp_cmd_sn)) { |
376 | list_del(&cmd->i_conn_node); | 376 | list_del(&cmd->i_conn_node); |
377 | spin_unlock_bh(&conn->cmd_lock); | 377 | spin_unlock_bh(&conn->cmd_lock); |
378 | iscsit_free_cmd(cmd); | 378 | iscsit_free_cmd(cmd); |
diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c index f8dbec05d5e5..fdb632f0ab85 100644 --- a/drivers/target/iscsi/iscsi_target_login.c +++ b/drivers/target/iscsi/iscsi_target_login.c | |||
@@ -127,13 +127,13 @@ int iscsi_check_for_session_reinstatement(struct iscsi_conn *conn) | |||
127 | 127 | ||
128 | initiatorname_param = iscsi_find_param_from_key( | 128 | initiatorname_param = iscsi_find_param_from_key( |
129 | INITIATORNAME, conn->param_list); | 129 | INITIATORNAME, conn->param_list); |
130 | if (!initiatorname_param) | ||
131 | return -1; | ||
132 | |||
133 | sessiontype_param = iscsi_find_param_from_key( | 130 | sessiontype_param = iscsi_find_param_from_key( |
134 | SESSIONTYPE, conn->param_list); | 131 | SESSIONTYPE, conn->param_list); |
135 | if (!sessiontype_param) | 132 | if (!initiatorname_param || !sessiontype_param) { |
133 | iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_INITIATOR_ERR, | ||
134 | ISCSI_LOGIN_STATUS_MISSING_FIELDS); | ||
136 | return -1; | 135 | return -1; |
136 | } | ||
137 | 137 | ||
138 | sessiontype = (strncmp(sessiontype_param->value, NORMAL, 6)) ? 1 : 0; | 138 | sessiontype = (strncmp(sessiontype_param->value, NORMAL, 6)) ? 1 : 0; |
139 | 139 | ||
@@ -254,9 +254,9 @@ static int iscsi_login_zero_tsih_s1( | |||
254 | kfree(sess); | 254 | kfree(sess); |
255 | return -ENOMEM; | 255 | return -ENOMEM; |
256 | } | 256 | } |
257 | spin_lock(&sess_idr_lock); | 257 | spin_lock_bh(&sess_idr_lock); |
258 | ret = idr_get_new(&sess_idr, NULL, &sess->session_index); | 258 | ret = idr_get_new(&sess_idr, NULL, &sess->session_index); |
259 | spin_unlock(&sess_idr_lock); | 259 | spin_unlock_bh(&sess_idr_lock); |
260 | 260 | ||
261 | if (ret < 0) { | 261 | if (ret < 0) { |
262 | pr_err("idr_get_new() for sess_idr failed\n"); | 262 | pr_err("idr_get_new() for sess_idr failed\n"); |
@@ -1118,10 +1118,8 @@ new_sess_out: | |||
1118 | idr_remove(&sess_idr, conn->sess->session_index); | 1118 | idr_remove(&sess_idr, conn->sess->session_index); |
1119 | spin_unlock_bh(&sess_idr_lock); | 1119 | spin_unlock_bh(&sess_idr_lock); |
1120 | } | 1120 | } |
1121 | if (conn->sess->sess_ops) | 1121 | kfree(conn->sess->sess_ops); |
1122 | kfree(conn->sess->sess_ops); | 1122 | kfree(conn->sess); |
1123 | if (conn->sess) | ||
1124 | kfree(conn->sess); | ||
1125 | old_sess_out: | 1123 | old_sess_out: |
1126 | iscsi_stop_login_thread_timer(np); | 1124 | iscsi_stop_login_thread_timer(np); |
1127 | /* | 1125 | /* |
diff --git a/drivers/target/iscsi/iscsi_target_nego.c b/drivers/target/iscsi/iscsi_target_nego.c index e9053a04f24c..9d902aefe01a 100644 --- a/drivers/target/iscsi/iscsi_target_nego.c +++ b/drivers/target/iscsi/iscsi_target_nego.c | |||
@@ -620,8 +620,11 @@ static int iscsi_target_handle_csg_one(struct iscsi_conn *conn, struct iscsi_log | |||
620 | login->req_buf, | 620 | login->req_buf, |
621 | payload_length, | 621 | payload_length, |
622 | conn); | 622 | conn); |
623 | if (ret < 0) | 623 | if (ret < 0) { |
624 | iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_INITIATOR_ERR, | ||
625 | ISCSI_LOGIN_STATUS_INIT_ERR); | ||
624 | return -1; | 626 | return -1; |
627 | } | ||
625 | 628 | ||
626 | if (login->first_request) | 629 | if (login->first_request) |
627 | if (iscsi_target_check_first_request(conn, login) < 0) | 630 | if (iscsi_target_check_first_request(conn, login) < 0) |
@@ -636,8 +639,11 @@ static int iscsi_target_handle_csg_one(struct iscsi_conn *conn, struct iscsi_log | |||
636 | login->rsp_buf, | 639 | login->rsp_buf, |
637 | &login->rsp_length, | 640 | &login->rsp_length, |
638 | conn->param_list); | 641 | conn->param_list); |
639 | if (ret < 0) | 642 | if (ret < 0) { |
643 | iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_INITIATOR_ERR, | ||
644 | ISCSI_LOGIN_STATUS_INIT_ERR); | ||
640 | return -1; | 645 | return -1; |
646 | } | ||
641 | 647 | ||
642 | if (!login->auth_complete && | 648 | if (!login->auth_complete && |
643 | ISCSI_TPG_ATTRIB(ISCSI_TPG_C(conn))->authentication) { | 649 | ISCSI_TPG_ATTRIB(ISCSI_TPG_C(conn))->authentication) { |
diff --git a/drivers/target/iscsi/iscsi_target_parameters.c b/drivers/target/iscsi/iscsi_target_parameters.c index 1bf7432bfcbc..d89164287d00 100644 --- a/drivers/target/iscsi/iscsi_target_parameters.c +++ b/drivers/target/iscsi/iscsi_target_parameters.c | |||
@@ -154,22 +154,18 @@ static struct iscsi_param *iscsi_set_default_param(struct iscsi_param_list *para | |||
154 | } | 154 | } |
155 | INIT_LIST_HEAD(¶m->p_list); | 155 | INIT_LIST_HEAD(¶m->p_list); |
156 | 156 | ||
157 | param->name = kzalloc(strlen(name) + 1, GFP_KERNEL); | 157 | param->name = kstrdup(name, GFP_KERNEL); |
158 | if (!param->name) { | 158 | if (!param->name) { |
159 | pr_err("Unable to allocate memory for parameter name.\n"); | 159 | pr_err("Unable to allocate memory for parameter name.\n"); |
160 | goto out; | 160 | goto out; |
161 | } | 161 | } |
162 | 162 | ||
163 | param->value = kzalloc(strlen(value) + 1, GFP_KERNEL); | 163 | param->value = kstrdup(value, GFP_KERNEL); |
164 | if (!param->value) { | 164 | if (!param->value) { |
165 | pr_err("Unable to allocate memory for parameter value.\n"); | 165 | pr_err("Unable to allocate memory for parameter value.\n"); |
166 | goto out; | 166 | goto out; |
167 | } | 167 | } |
168 | 168 | ||
169 | memcpy(param->name, name, strlen(name)); | ||
170 | param->name[strlen(name)] = '\0'; | ||
171 | memcpy(param->value, value, strlen(value)); | ||
172 | param->value[strlen(value)] = '\0'; | ||
173 | param->phase = phase; | 169 | param->phase = phase; |
174 | param->scope = scope; | 170 | param->scope = scope; |
175 | param->sender = sender; | 171 | param->sender = sender; |
@@ -635,11 +631,8 @@ void iscsi_release_param_list(struct iscsi_param_list *param_list) | |||
635 | list_del(¶m->p_list); | 631 | list_del(¶m->p_list); |
636 | 632 | ||
637 | kfree(param->name); | 633 | kfree(param->name); |
638 | param->name = NULL; | ||
639 | kfree(param->value); | 634 | kfree(param->value); |
640 | param->value = NULL; | ||
641 | kfree(param); | 635 | kfree(param); |
642 | param = NULL; | ||
643 | } | 636 | } |
644 | 637 | ||
645 | iscsi_release_extra_responses(param_list); | 638 | iscsi_release_extra_responses(param_list); |
@@ -687,15 +680,12 @@ int iscsi_update_param_value(struct iscsi_param *param, char *value) | |||
687 | { | 680 | { |
688 | kfree(param->value); | 681 | kfree(param->value); |
689 | 682 | ||
690 | param->value = kzalloc(strlen(value) + 1, GFP_KERNEL); | 683 | param->value = kstrdup(value, GFP_KERNEL); |
691 | if (!param->value) { | 684 | if (!param->value) { |
692 | pr_err("Unable to allocate memory for value.\n"); | 685 | pr_err("Unable to allocate memory for value.\n"); |
693 | return -ENOMEM; | 686 | return -ENOMEM; |
694 | } | 687 | } |
695 | 688 | ||
696 | memcpy(param->value, value, strlen(value)); | ||
697 | param->value[strlen(value)] = '\0'; | ||
698 | |||
699 | pr_debug("iSCSI Parameter updated to %s=%s\n", | 689 | pr_debug("iSCSI Parameter updated to %s=%s\n", |
700 | param->name, param->value); | 690 | param->name, param->value); |
701 | return 0; | 691 | return 0; |
diff --git a/drivers/target/iscsi/iscsi_target_tmr.c b/drivers/target/iscsi/iscsi_target_tmr.c index 4a99820d063b..9d4417aae921 100644 --- a/drivers/target/iscsi/iscsi_target_tmr.c +++ b/drivers/target/iscsi/iscsi_target_tmr.c | |||
@@ -50,8 +50,8 @@ 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 (be32_to_cpu(hdr->refcmdsn) >= conn->sess->exp_cmd_sn && | 53 | return (iscsi_sna_gte(be32_to_cpu(hdr->refcmdsn), conn->sess->exp_cmd_sn) && |
54 | be32_to_cpu(hdr->refcmdsn) <= conn->sess->max_cmd_sn) ? | 54 | iscsi_sna_lte(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 != be32_to_cpu(hdr->refcmdsn)) { | 57 | if (ref_cmd->cmd_sn != be32_to_cpu(hdr->refcmdsn)) { |
diff --git a/drivers/target/iscsi/iscsi_target_tq.c b/drivers/target/iscsi/iscsi_target_tq.c index 9d881a000e42..81289520f96b 100644 --- a/drivers/target/iscsi/iscsi_target_tq.c +++ b/drivers/target/iscsi/iscsi_target_tq.c | |||
@@ -66,8 +66,7 @@ static struct iscsi_thread_set *iscsi_get_ts_from_inactive_list(void) | |||
66 | return NULL; | 66 | return NULL; |
67 | } | 67 | } |
68 | 68 | ||
69 | list_for_each_entry(ts, &inactive_ts_list, ts_list) | 69 | ts = list_first_entry(&inactive_ts_list, struct iscsi_thread_set, ts_list); |
70 | break; | ||
71 | 70 | ||
72 | list_del(&ts->ts_list); | 71 | list_del(&ts->ts_list); |
73 | iscsit_global->inactive_ts--; | 72 | iscsit_global->inactive_ts--; |
diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c index 69e0cfd98870..7ce350578c82 100644 --- a/drivers/target/iscsi/iscsi_target_util.c +++ b/drivers/target/iscsi/iscsi_target_util.c | |||
@@ -500,8 +500,8 @@ struct iscsi_queue_req *iscsit_get_cmd_from_immediate_queue(struct iscsi_conn *c | |||
500 | spin_unlock_bh(&conn->immed_queue_lock); | 500 | spin_unlock_bh(&conn->immed_queue_lock); |
501 | return NULL; | 501 | return NULL; |
502 | } | 502 | } |
503 | list_for_each_entry(qr, &conn->immed_queue_list, qr_list) | 503 | qr = list_first_entry(&conn->immed_queue_list, |
504 | break; | 504 | struct iscsi_queue_req, qr_list); |
505 | 505 | ||
506 | list_del(&qr->qr_list); | 506 | list_del(&qr->qr_list); |
507 | if (qr->cmd) | 507 | if (qr->cmd) |
@@ -575,8 +575,8 @@ struct iscsi_queue_req *iscsit_get_cmd_from_response_queue(struct iscsi_conn *co | |||
575 | return NULL; | 575 | return NULL; |
576 | } | 576 | } |
577 | 577 | ||
578 | list_for_each_entry(qr, &conn->response_queue_list, qr_list) | 578 | qr = list_first_entry(&conn->response_queue_list, |
579 | break; | 579 | struct iscsi_queue_req, qr_list); |
580 | 580 | ||
581 | list_del(&qr->qr_list); | 581 | list_del(&qr->qr_list); |
582 | if (qr->cmd) | 582 | if (qr->cmd) |