aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target/iscsi/iscsi_target.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-03-22 15:38:04 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-22 15:38:04 -0400
commit1ab142d499294b844ecc81e8004db4ce029b0b61 (patch)
tree9db85a456d0cba3de8b9bd6671b1b52fa939770c /drivers/target/iscsi/iscsi_target.c
parent267d7b23dd62f6ec55e0fba777e456495c308fc7 (diff)
parent187e70a554e0f0717a65998bc9199945cbbd4692 (diff)
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending
Pull SCSI target updates from Nicholas Bellinger: "This contains the usual set of updates and bugfixes to target-core + existing fabric module code, along with a handful of the patches destined for v3.3 stable. It also contains the necessary target-core infrastructure pieces required to run using tcm_qla2xxx.ko WWPNs with the new Qlogic Fibre Channel fabric module currently queued in target-pending/for-next-merge, and coming for round 2. The highlights for this series include: - Add target_submit_tmr() helper function for fabric task management (andy) - Convert tcm_fc to use target_submit_tmr() (andy) - Replace target core various cmd flags with a transport state (hch) - Convert loopback to use workqueue submission (hch) - Convert target core to use array_zalloc for tpg_lun_list (joern) - Convert target core to use array_zalloc for device_list (joern) - Add target core support for TMR_ABORT_TASK (nab) - Add target core se_sess->sess_kref + get/put helpers (nab) - Add target core se_node_acl->acl_kref for ->acl_free_comp usage (nab) - Convert iscsi-target to use target_put_session + sess_kref (nab) - Fix tcm_fc fc_exch memory leak in ft_send_resp_status (nab) - Fix ib_srpt srpt_handle_cmd send_ioctx->ioctx_kref leak on exception (nab) - Fix target core up handling of short INQUIRY buffers (roland) - Untangle target-core front-end and back-end meanings of max_sectors attribute (roland) - Set loopback residual field for SCSI commands (roland) - Fix target-core 16-bit target ports for SET TARGET PORT GROUPS emulation (roland) Thanks again to Andy, Christoph, Joern, Roland, and everyone who has contributed this round!" * 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: (64 commits) ib_srpt: Fix srpt_handle_cmd send_ioctx->ioctx_kref leak on exception loopback: Fix transport_generic_allocate_tasks error handling iscsi-target: remove improper externs iscsi-target: Remove unused variables in iscsi_target_parameters.c target: remove obvious warnings target: Use array_zalloc for device_list target: Use array_zalloc for tpg_lun_list target: Fix sense code for unsupported SERVICE ACTION IN target: Remove hack to make READ CAPACITY(10) lie if thin provisioning is enabled target: Bump core version to v4.1.0-rc2-ml + fabric versions tcm_fc: Fix fc_exch memory leak in ft_send_resp_status target: Drop unused legacy target_core_fabric_ops API callers iscsi-target: Convert to use target_put_session + sess_kref target: Convert se_node_acl->acl_group removal to use ->acl_kref target: Add se_node_acl->acl_kref for ->acl_free_comp usage target: Add se_node_acl->acl_free_comp for NodeACL release path target: Add se_sess->sess_kref + get/put helpers target: Convert session_lock to irqsave target: Fix typo in drivers/target iscsi-target: Fix dynamic -> explict NodeACL pointer reference ...
Diffstat (limited to 'drivers/target/iscsi/iscsi_target.c')
-rw-r--r--drivers/target/iscsi/iscsi_target.c41
1 files changed, 14 insertions, 27 deletions
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index 1c6f700f5faa..8b1d5e62ed40 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -781,7 +781,7 @@ static int iscsit_alloc_buffs(struct iscsi_cmd *cmd)
781 struct scatterlist *sgl; 781 struct scatterlist *sgl;
782 u32 length = cmd->se_cmd.data_length; 782 u32 length = cmd->se_cmd.data_length;
783 int nents = DIV_ROUND_UP(length, PAGE_SIZE); 783 int nents = DIV_ROUND_UP(length, PAGE_SIZE);
784 int i = 0, ret; 784 int i = 0, j = 0, ret;
785 /* 785 /*
786 * If no SCSI payload is present, allocate the default iovecs used for 786 * If no SCSI payload is present, allocate the default iovecs used for
787 * iSCSI PDU Header 787 * iSCSI PDU Header
@@ -822,17 +822,15 @@ static int iscsit_alloc_buffs(struct iscsi_cmd *cmd)
822 */ 822 */
823 ret = iscsit_allocate_iovecs(cmd); 823 ret = iscsit_allocate_iovecs(cmd);
824 if (ret < 0) 824 if (ret < 0)
825 goto page_alloc_failed; 825 return -ENOMEM;
826 826
827 return 0; 827 return 0;
828 828
829page_alloc_failed: 829page_alloc_failed:
830 while (i >= 0) { 830 while (j < i)
831 __free_page(sg_page(&sgl[i])); 831 __free_page(sg_page(&sgl[j++]));
832 i--; 832
833 } 833 kfree(sgl);
834 kfree(cmd->t_mem_sg);
835 cmd->t_mem_sg = NULL;
836 return -ENOMEM; 834 return -ENOMEM;
837} 835}
838 836
@@ -1007,8 +1005,8 @@ done:
1007 /* 1005 /*
1008 * The CDB is going to an se_device_t. 1006 * The CDB is going to an se_device_t.
1009 */ 1007 */
1010 ret = iscsit_get_lun_for_cmd(cmd, hdr->cdb, 1008 ret = transport_lookup_cmd_lun(&cmd->se_cmd,
1011 get_unaligned_le64(&hdr->lun)); 1009 scsilun_to_int(&hdr->lun));
1012 if (ret < 0) { 1010 if (ret < 0) {
1013 if (cmd->se_cmd.scsi_sense_reason == TCM_NON_EXISTENT_LUN) { 1011 if (cmd->se_cmd.scsi_sense_reason == TCM_NON_EXISTENT_LUN) {
1014 pr_debug("Responding to non-acl'ed," 1012 pr_debug("Responding to non-acl'ed,"
@@ -1364,7 +1362,7 @@ static int iscsit_handle_data_out(struct iscsi_conn *conn, unsigned char *buf)
1364 * outstanding_r2ts reaches zero, go ahead and send the delayed 1362 * outstanding_r2ts reaches zero, go ahead and send the delayed
1365 * TASK_ABORTED status. 1363 * TASK_ABORTED status.
1366 */ 1364 */
1367 if (atomic_read(&se_cmd->t_transport_aborted) != 0) { 1365 if (se_cmd->transport_state & CMD_T_ABORTED) {
1368 if (hdr->flags & ISCSI_FLAG_CMD_FINAL) 1366 if (hdr->flags & ISCSI_FLAG_CMD_FINAL)
1369 if (--cmd->outstanding_r2ts < 1) { 1367 if (--cmd->outstanding_r2ts < 1) {
1370 iscsit_stop_dataout_timer(cmd); 1368 iscsit_stop_dataout_timer(cmd);
@@ -1472,14 +1470,12 @@ static int iscsit_handle_nop_out(
1472 unsigned char *ping_data = NULL; 1470 unsigned char *ping_data = NULL;
1473 int cmdsn_ret, niov = 0, ret = 0, rx_got, rx_size; 1471 int cmdsn_ret, niov = 0, ret = 0, rx_got, rx_size;
1474 u32 checksum, data_crc, padding = 0, payload_length; 1472 u32 checksum, data_crc, padding = 0, payload_length;
1475 u64 lun;
1476 struct iscsi_cmd *cmd = NULL; 1473 struct iscsi_cmd *cmd = NULL;
1477 struct kvec *iov = NULL; 1474 struct kvec *iov = NULL;
1478 struct iscsi_nopout *hdr; 1475 struct iscsi_nopout *hdr;
1479 1476
1480 hdr = (struct iscsi_nopout *) buf; 1477 hdr = (struct iscsi_nopout *) buf;
1481 payload_length = ntoh24(hdr->dlength); 1478 payload_length = ntoh24(hdr->dlength);
1482 lun = get_unaligned_le64(&hdr->lun);
1483 hdr->itt = be32_to_cpu(hdr->itt); 1479 hdr->itt = be32_to_cpu(hdr->itt);
1484 hdr->ttt = be32_to_cpu(hdr->ttt); 1480 hdr->ttt = be32_to_cpu(hdr->ttt);
1485 hdr->cmdsn = be32_to_cpu(hdr->cmdsn); 1481 hdr->cmdsn = be32_to_cpu(hdr->cmdsn);
@@ -1689,13 +1685,11 @@ static int iscsit_handle_task_mgt_cmd(
1689 struct se_tmr_req *se_tmr; 1685 struct se_tmr_req *se_tmr;
1690 struct iscsi_tmr_req *tmr_req; 1686 struct iscsi_tmr_req *tmr_req;
1691 struct iscsi_tm *hdr; 1687 struct iscsi_tm *hdr;
1692 u32 payload_length;
1693 int out_of_order_cmdsn = 0; 1688 int out_of_order_cmdsn = 0;
1694 int ret; 1689 int ret;
1695 u8 function; 1690 u8 function;
1696 1691
1697 hdr = (struct iscsi_tm *) buf; 1692 hdr = (struct iscsi_tm *) buf;
1698 payload_length = ntoh24(hdr->dlength);
1699 hdr->itt = be32_to_cpu(hdr->itt); 1693 hdr->itt = be32_to_cpu(hdr->itt);
1700 hdr->rtt = be32_to_cpu(hdr->rtt); 1694 hdr->rtt = be32_to_cpu(hdr->rtt);
1701 hdr->cmdsn = be32_to_cpu(hdr->cmdsn); 1695 hdr->cmdsn = be32_to_cpu(hdr->cmdsn);
@@ -1747,8 +1741,8 @@ static int iscsit_handle_task_mgt_cmd(
1747 * Locate the struct se_lun for all TMRs not related to ERL=2 TASK_REASSIGN 1741 * Locate the struct se_lun for all TMRs not related to ERL=2 TASK_REASSIGN
1748 */ 1742 */
1749 if (function != ISCSI_TM_FUNC_TASK_REASSIGN) { 1743 if (function != ISCSI_TM_FUNC_TASK_REASSIGN) {
1750 ret = iscsit_get_lun_for_tmr(cmd, 1744 ret = transport_lookup_tmr_lun(&cmd->se_cmd,
1751 get_unaligned_le64(&hdr->lun)); 1745 scsilun_to_int(&hdr->lun));
1752 if (ret < 0) { 1746 if (ret < 0) {
1753 cmd->se_cmd.se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION; 1747 cmd->se_cmd.se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
1754 se_tmr->response = ISCSI_TMF_RSP_NO_LUN; 1748 se_tmr->response = ISCSI_TMF_RSP_NO_LUN;
@@ -2207,14 +2201,10 @@ static int iscsit_handle_snack(
2207 struct iscsi_conn *conn, 2201 struct iscsi_conn *conn,
2208 unsigned char *buf) 2202 unsigned char *buf)
2209{ 2203{
2210 u32 unpacked_lun;
2211 u64 lun;
2212 struct iscsi_snack *hdr; 2204 struct iscsi_snack *hdr;
2213 2205
2214 hdr = (struct iscsi_snack *) buf; 2206 hdr = (struct iscsi_snack *) buf;
2215 hdr->flags &= ~ISCSI_FLAG_CMD_FINAL; 2207 hdr->flags &= ~ISCSI_FLAG_CMD_FINAL;
2216 lun = get_unaligned_le64(&hdr->lun);
2217 unpacked_lun = scsilun_to_int((struct scsi_lun *)&lun);
2218 hdr->itt = be32_to_cpu(hdr->itt); 2208 hdr->itt = be32_to_cpu(hdr->itt);
2219 hdr->ttt = be32_to_cpu(hdr->ttt); 2209 hdr->ttt = be32_to_cpu(hdr->ttt);
2220 hdr->exp_statsn = be32_to_cpu(hdr->exp_statsn); 2210 hdr->exp_statsn = be32_to_cpu(hdr->exp_statsn);
@@ -3514,7 +3504,6 @@ int iscsi_target_tx_thread(void *arg)
3514 struct iscsi_cmd *cmd = NULL; 3504 struct iscsi_cmd *cmd = NULL;
3515 struct iscsi_conn *conn; 3505 struct iscsi_conn *conn;
3516 struct iscsi_queue_req *qr = NULL; 3506 struct iscsi_queue_req *qr = NULL;
3517 struct se_cmd *se_cmd;
3518 struct iscsi_thread_set *ts = arg; 3507 struct iscsi_thread_set *ts = arg;
3519 /* 3508 /*
3520 * Allow ourselves to be interrupted by SIGINT so that a 3509 * Allow ourselves to be interrupted by SIGINT so that a
@@ -3697,8 +3686,6 @@ check_rsp_state:
3697 goto transport_err; 3686 goto transport_err;
3698 } 3687 }
3699 3688
3700 se_cmd = &cmd->se_cmd;
3701
3702 if (map_sg && !conn->conn_ops->IFMarker) { 3689 if (map_sg && !conn->conn_ops->IFMarker) {
3703 if (iscsit_fe_sendpage_sg(cmd, conn) < 0) { 3690 if (iscsit_fe_sendpage_sg(cmd, conn) < 0) {
3704 conn->tx_response_queue = 0; 3691 conn->tx_response_queue = 0;
@@ -4171,7 +4158,7 @@ int iscsit_close_connection(
4171 if (!atomic_read(&sess->session_reinstatement) && 4158 if (!atomic_read(&sess->session_reinstatement) &&
4172 atomic_read(&sess->session_fall_back_to_erl0)) { 4159 atomic_read(&sess->session_fall_back_to_erl0)) {
4173 spin_unlock_bh(&sess->conn_lock); 4160 spin_unlock_bh(&sess->conn_lock);
4174 iscsit_close_session(sess); 4161 target_put_session(sess->se_sess);
4175 4162
4176 return 0; 4163 return 0;
4177 } else if (atomic_read(&sess->session_logout)) { 4164 } else if (atomic_read(&sess->session_logout)) {
@@ -4292,7 +4279,7 @@ static void iscsit_logout_post_handler_closesession(
4292 iscsit_dec_conn_usage_count(conn); 4279 iscsit_dec_conn_usage_count(conn);
4293 iscsit_stop_session(sess, 1, 1); 4280 iscsit_stop_session(sess, 1, 1);
4294 iscsit_dec_session_usage_count(sess); 4281 iscsit_dec_session_usage_count(sess);
4295 iscsit_close_session(sess); 4282 target_put_session(sess->se_sess);
4296} 4283}
4297 4284
4298static void iscsit_logout_post_handler_samecid( 4285static void iscsit_logout_post_handler_samecid(
@@ -4458,7 +4445,7 @@ int iscsit_free_session(struct iscsi_session *sess)
4458 } else 4445 } else
4459 spin_unlock_bh(&sess->conn_lock); 4446 spin_unlock_bh(&sess->conn_lock);
4460 4447
4461 iscsit_close_session(sess); 4448 target_put_session(sess->se_sess);
4462 return 0; 4449 return 0;
4463} 4450}
4464 4451