aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShlomo Pongratz <shlomop@mellanox.com>2014-02-07 01:41:38 -0500
committerJames Bottomley <JBottomley@Parallels.com>2014-03-15 13:19:18 -0400
commit659743b02c411075b26601725947b21df0bb29c8 (patch)
tree5c0350e508cdc32c97bf8d86da0ecfa5c15915f5
parent5d0fddd0a72d3023bb0fa97e546f687aa6222be3 (diff)
[SCSI] libiscsi: Reduce locking contention in fast path
Replace the session lock with two locks, a forward lock and a backwards lock named frwd_lock and back_lock respectively. The forward lock protects resources that change while sending a request to the target, such as cmdsn, queued_cmdsn, and allocating task from the commands' pool with kfifo_out. The backward lock protects resources that change while processing a response or in error path, such as cmdsn_exp, cmdsn_max, and returning tasks to the commands' pool with kfifo_in. Under a steady state fast-path situation, that is when one or more processes/threads submit IO to an iscsi device and a single kernel upcall (e.g softirq) is dealing with processing of responses without errors, this patch eliminates the contention between the queuecommand()/request response/scsi_done() flows associated with iscsi sessions. Between the forward and the backward locks exists a strict locking hierarchy. The mutual exclusion zone protected by the forward lock can enclose the mutual exclusion zone protected by the backward lock but not vice versa. For example, in iscsi_conn_teardown or in iscsi_xmit_data when there is a failure and __iscsi_put_task is called, the backward lock is taken while the forward lock is still taken. On the other hand, if in the RX path a nop is to be sent, for example in iscsi_handle_reject or __iscsi_complete_pdu than the forward lock is released and the backward lock is taken for the duration of iscsi_send_nopout, later the backward lock is released and the forward lock is retaken. libiscsi_tcp uses two kernel fifos the r2t pool and the r2t queue. The insertion and deletion from these queues didn't corespond to the assumption taken by the new forward/backwards session locking paradigm. That is, in iscsi_tcp_clenup_task which belongs to the RX (backwards) path, r2t is taken out from r2t queue and inserted to the r2t pool. In iscsi_tcp_get_curr_r2t which belong to the TX (forward) path, r2t is also inserted to the r2t pool and another r2t is pulled from r2t queue. Only in iscsi_tcp_r2t_rsp which is called in the RX path but can requeue to the TX path, r2t is taken from the r2t pool and inserted to the r2t queue. In order to cope with this situation, two spin locks were added, pool2queue and queue2pool. The former protects extracting from the r2t pool and inserting to the r2t queue, and the later protects the extracing from the r2t queue and inserting to the r2t pool. Signed-off-by: Shlomo Pongratz <shlomop@mellanox.com> Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> [minor fix up to apply cleanly and compile fix] Signed-off-by: Mike Christie <michaelc@cs.wisc.edu> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r--drivers/scsi/be2iscsi/be_main.c26
-rw-r--r--drivers/scsi/bnx2i/bnx2i_hwi.c46
-rw-r--r--drivers/scsi/bnx2i/bnx2i_iscsi.c8
-rw-r--r--drivers/scsi/iscsi_tcp.c22
-rw-r--r--drivers/scsi/libiscsi.c214
-rw-r--r--drivers/scsi/libiscsi_tcp.c28
-rw-r--r--drivers/scsi/qla4xxx/ql4_isr.c4
-rw-r--r--include/scsi/libiscsi.h17
-rw-r--r--include/scsi/libiscsi_tcp.h2
9 files changed, 206 insertions, 161 deletions
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 3cd4693bc2b4..9be818f7b26d 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -233,20 +233,20 @@ static int beiscsi_eh_abort(struct scsi_cmnd *sc)
233 cls_session = starget_to_session(scsi_target(sc->device)); 233 cls_session = starget_to_session(scsi_target(sc->device));
234 session = cls_session->dd_data; 234 session = cls_session->dd_data;
235 235
236 spin_lock_bh(&session->lock); 236 spin_lock_bh(&session->frwd_lock);
237 if (!aborted_task || !aborted_task->sc) { 237 if (!aborted_task || !aborted_task->sc) {
238 /* we raced */ 238 /* we raced */
239 spin_unlock_bh(&session->lock); 239 spin_unlock_bh(&session->frwd_lock);
240 return SUCCESS; 240 return SUCCESS;
241 } 241 }
242 242
243 aborted_io_task = aborted_task->dd_data; 243 aborted_io_task = aborted_task->dd_data;
244 if (!aborted_io_task->scsi_cmnd) { 244 if (!aborted_io_task->scsi_cmnd) {
245 /* raced or invalid command */ 245 /* raced or invalid command */
246 spin_unlock_bh(&session->lock); 246 spin_unlock_bh(&session->frwd_lock);
247 return SUCCESS; 247 return SUCCESS;
248 } 248 }
249 spin_unlock_bh(&session->lock); 249 spin_unlock_bh(&session->frwd_lock);
250 /* Invalidate WRB Posted for this Task */ 250 /* Invalidate WRB Posted for this Task */
251 AMAP_SET_BITS(struct amap_iscsi_wrb, invld, 251 AMAP_SET_BITS(struct amap_iscsi_wrb, invld,
252 aborted_io_task->pwrb_handle->pwrb, 252 aborted_io_task->pwrb_handle->pwrb,
@@ -311,9 +311,9 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
311 /* invalidate iocbs */ 311 /* invalidate iocbs */
312 cls_session = starget_to_session(scsi_target(sc->device)); 312 cls_session = starget_to_session(scsi_target(sc->device));
313 session = cls_session->dd_data; 313 session = cls_session->dd_data;
314 spin_lock_bh(&session->lock); 314 spin_lock_bh(&session->frwd_lock);
315 if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN) { 315 if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN) {
316 spin_unlock_bh(&session->lock); 316 spin_unlock_bh(&session->frwd_lock);
317 return FAILED; 317 return FAILED;
318 } 318 }
319 conn = session->leadconn; 319 conn = session->leadconn;
@@ -342,7 +342,7 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
342 num_invalidate++; 342 num_invalidate++;
343 inv_tbl++; 343 inv_tbl++;
344 } 344 }
345 spin_unlock_bh(&session->lock); 345 spin_unlock_bh(&session->frwd_lock);
346 inv_tbl = phba->inv_tbl; 346 inv_tbl = phba->inv_tbl;
347 347
348 nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev, 348 nonemb_cmd.va = pci_alloc_consistent(phba->ctrl.pdev,
@@ -1185,9 +1185,9 @@ beiscsi_process_async_pdu(struct beiscsi_conn *beiscsi_conn,
1185 return 1; 1185 return 1;
1186 } 1186 }
1187 1187
1188 spin_lock_bh(&session->lock); 1188 spin_lock_bh(&session->back_lock);
1189 __iscsi_complete_pdu(conn, (struct iscsi_hdr *)ppdu, pbuffer, buf_len); 1189 __iscsi_complete_pdu(conn, (struct iscsi_hdr *)ppdu, pbuffer, buf_len);
1190 spin_unlock_bh(&session->lock); 1190 spin_unlock_bh(&session->back_lock);
1191 return 0; 1191 return 0;
1192} 1192}
1193 1193
@@ -1606,7 +1606,7 @@ static void hwi_complete_cmd(struct beiscsi_conn *beiscsi_conn,
1606 pwrb = pwrb_handle->pwrb; 1606 pwrb = pwrb_handle->pwrb;
1607 type = ((struct beiscsi_io_task *)task->dd_data)->wrb_type; 1607 type = ((struct beiscsi_io_task *)task->dd_data)->wrb_type;
1608 1608
1609 spin_lock_bh(&session->lock); 1609 spin_lock_bh(&session->back_lock);
1610 switch (type) { 1610 switch (type) {
1611 case HWH_TYPE_IO: 1611 case HWH_TYPE_IO:
1612 case HWH_TYPE_IO_RD: 1612 case HWH_TYPE_IO_RD:
@@ -1645,7 +1645,7 @@ static void hwi_complete_cmd(struct beiscsi_conn *beiscsi_conn,
1645 break; 1645 break;
1646 } 1646 }
1647 1647
1648 spin_unlock_bh(&session->lock); 1648 spin_unlock_bh(&session->back_lock);
1649} 1649}
1650 1650
1651static struct list_head *hwi_get_async_busy_list(struct hwi_async_pdu_context 1651static struct list_head *hwi_get_async_busy_list(struct hwi_async_pdu_context
@@ -4693,9 +4693,9 @@ beiscsi_offload_connection(struct beiscsi_conn *beiscsi_conn,
4693 * login/startup related tasks. 4693 * login/startup related tasks.
4694 */ 4694 */
4695 beiscsi_conn->login_in_progress = 0; 4695 beiscsi_conn->login_in_progress = 0;
4696 spin_lock_bh(&session->lock); 4696 spin_lock_bh(&session->back_lock);
4697 beiscsi_cleanup_task(task); 4697 beiscsi_cleanup_task(task);
4698 spin_unlock_bh(&session->lock); 4698 spin_unlock_bh(&session->back_lock);
4699 4699
4700 pwrb_handle = alloc_wrb_handle(phba, beiscsi_conn->beiscsi_conn_cid); 4700 pwrb_handle = alloc_wrb_handle(phba, beiscsi_conn->beiscsi_conn_cid);
4701 4701
diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
index e4cf23df4b4f..da9cf041dc5d 100644
--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
+++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
@@ -1361,7 +1361,7 @@ int bnx2i_process_scsi_cmd_resp(struct iscsi_session *session,
1361 u32 datalen = 0; 1361 u32 datalen = 0;
1362 1362
1363 resp_cqe = (struct bnx2i_cmd_response *)cqe; 1363 resp_cqe = (struct bnx2i_cmd_response *)cqe;
1364 spin_lock_bh(&session->lock); 1364 spin_lock_bh(&session->back_lock);
1365 task = iscsi_itt_to_task(conn, 1365 task = iscsi_itt_to_task(conn,
1366 resp_cqe->itt & ISCSI_CMD_RESPONSE_INDEX); 1366 resp_cqe->itt & ISCSI_CMD_RESPONSE_INDEX);
1367 if (!task) 1367 if (!task)
@@ -1432,7 +1432,7 @@ done:
1432 __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, 1432 __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr,
1433 conn->data, datalen); 1433 conn->data, datalen);
1434fail: 1434fail:
1435 spin_unlock_bh(&session->lock); 1435 spin_unlock_bh(&session->back_lock);
1436 return 0; 1436 return 0;
1437} 1437}
1438 1438
@@ -1457,7 +1457,7 @@ static int bnx2i_process_login_resp(struct iscsi_session *session,
1457 int pad_len; 1457 int pad_len;
1458 1458
1459 login = (struct bnx2i_login_response *) cqe; 1459 login = (struct bnx2i_login_response *) cqe;
1460 spin_lock(&session->lock); 1460 spin_lock(&session->back_lock);
1461 task = iscsi_itt_to_task(conn, 1461 task = iscsi_itt_to_task(conn,
1462 login->itt & ISCSI_LOGIN_RESPONSE_INDEX); 1462 login->itt & ISCSI_LOGIN_RESPONSE_INDEX);
1463 if (!task) 1463 if (!task)
@@ -1500,7 +1500,7 @@ static int bnx2i_process_login_resp(struct iscsi_session *session,
1500 bnx2i_conn->gen_pdu.resp_buf, 1500 bnx2i_conn->gen_pdu.resp_buf,
1501 bnx2i_conn->gen_pdu.resp_wr_ptr - bnx2i_conn->gen_pdu.resp_buf); 1501 bnx2i_conn->gen_pdu.resp_wr_ptr - bnx2i_conn->gen_pdu.resp_buf);
1502done: 1502done:
1503 spin_unlock(&session->lock); 1503 spin_unlock(&session->back_lock);
1504 return 0; 1504 return 0;
1505} 1505}
1506 1506
@@ -1525,7 +1525,7 @@ static int bnx2i_process_text_resp(struct iscsi_session *session,
1525 int pad_len; 1525 int pad_len;
1526 1526
1527 text = (struct bnx2i_text_response *) cqe; 1527 text = (struct bnx2i_text_response *) cqe;
1528 spin_lock(&session->lock); 1528 spin_lock(&session->back_lock);
1529 task = iscsi_itt_to_task(conn, text->itt & ISCSI_LOGIN_RESPONSE_INDEX); 1529 task = iscsi_itt_to_task(conn, text->itt & ISCSI_LOGIN_RESPONSE_INDEX);
1530 if (!task) 1530 if (!task)
1531 goto done; 1531 goto done;
@@ -1561,7 +1561,7 @@ static int bnx2i_process_text_resp(struct iscsi_session *session,
1561 bnx2i_conn->gen_pdu.resp_wr_ptr - 1561 bnx2i_conn->gen_pdu.resp_wr_ptr -
1562 bnx2i_conn->gen_pdu.resp_buf); 1562 bnx2i_conn->gen_pdu.resp_buf);
1563done: 1563done:
1564 spin_unlock(&session->lock); 1564 spin_unlock(&session->back_lock);
1565 return 0; 1565 return 0;
1566} 1566}
1567 1567
@@ -1584,7 +1584,7 @@ static int bnx2i_process_tmf_resp(struct iscsi_session *session,
1584 struct iscsi_tm_rsp *resp_hdr; 1584 struct iscsi_tm_rsp *resp_hdr;
1585 1585
1586 tmf_cqe = (struct bnx2i_tmf_response *)cqe; 1586 tmf_cqe = (struct bnx2i_tmf_response *)cqe;
1587 spin_lock(&session->lock); 1587 spin_lock(&session->back_lock);
1588 task = iscsi_itt_to_task(conn, 1588 task = iscsi_itt_to_task(conn,
1589 tmf_cqe->itt & ISCSI_TMF_RESPONSE_INDEX); 1589 tmf_cqe->itt & ISCSI_TMF_RESPONSE_INDEX);
1590 if (!task) 1590 if (!task)
@@ -1600,7 +1600,7 @@ static int bnx2i_process_tmf_resp(struct iscsi_session *session,
1600 1600
1601 __iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr, NULL, 0); 1601 __iscsi_complete_pdu(conn, (struct iscsi_hdr *)resp_hdr, NULL, 0);
1602done: 1602done:
1603 spin_unlock(&session->lock); 1603 spin_unlock(&session->back_lock);
1604 return 0; 1604 return 0;
1605} 1605}
1606 1606
@@ -1623,7 +1623,7 @@ static int bnx2i_process_logout_resp(struct iscsi_session *session,
1623 struct iscsi_logout_rsp *resp_hdr; 1623 struct iscsi_logout_rsp *resp_hdr;
1624 1624
1625 logout = (struct bnx2i_logout_response *) cqe; 1625 logout = (struct bnx2i_logout_response *) cqe;
1626 spin_lock(&session->lock); 1626 spin_lock(&session->back_lock);
1627 task = iscsi_itt_to_task(conn, 1627 task = iscsi_itt_to_task(conn,
1628 logout->itt & ISCSI_LOGOUT_RESPONSE_INDEX); 1628 logout->itt & ISCSI_LOGOUT_RESPONSE_INDEX);
1629 if (!task) 1629 if (!task)
@@ -1647,7 +1647,7 @@ static int bnx2i_process_logout_resp(struct iscsi_session *session,
1647 1647
1648 bnx2i_conn->ep->state = EP_STATE_LOGOUT_RESP_RCVD; 1648 bnx2i_conn->ep->state = EP_STATE_LOGOUT_RESP_RCVD;
1649done: 1649done:
1650 spin_unlock(&session->lock); 1650 spin_unlock(&session->back_lock);
1651 return 0; 1651 return 0;
1652} 1652}
1653 1653
@@ -1668,12 +1668,12 @@ static void bnx2i_process_nopin_local_cmpl(struct iscsi_session *session,
1668 struct iscsi_task *task; 1668 struct iscsi_task *task;
1669 1669
1670 nop_in = (struct bnx2i_nop_in_msg *)cqe; 1670 nop_in = (struct bnx2i_nop_in_msg *)cqe;
1671 spin_lock(&session->lock); 1671 spin_lock(&session->back_lock);
1672 task = iscsi_itt_to_task(conn, 1672 task = iscsi_itt_to_task(conn,
1673 nop_in->itt & ISCSI_NOP_IN_MSG_INDEX); 1673 nop_in->itt & ISCSI_NOP_IN_MSG_INDEX);
1674 if (task) 1674 if (task)
1675 __iscsi_put_task(task); 1675 __iscsi_put_task(task);
1676 spin_unlock(&session->lock); 1676 spin_unlock(&session->back_lock);
1677} 1677}
1678 1678
1679/** 1679/**
@@ -1712,7 +1712,7 @@ static int bnx2i_process_nopin_mesg(struct iscsi_session *session,
1712 1712
1713 nop_in = (struct bnx2i_nop_in_msg *)cqe; 1713 nop_in = (struct bnx2i_nop_in_msg *)cqe;
1714 1714
1715 spin_lock(&session->lock); 1715 spin_lock(&session->back_lock);
1716 hdr = (struct iscsi_nopin *)&bnx2i_conn->gen_pdu.resp_hdr; 1716 hdr = (struct iscsi_nopin *)&bnx2i_conn->gen_pdu.resp_hdr;
1717 memset(hdr, 0, sizeof(struct iscsi_hdr)); 1717 memset(hdr, 0, sizeof(struct iscsi_hdr));
1718 hdr->opcode = nop_in->op_code; 1718 hdr->opcode = nop_in->op_code;
@@ -1738,7 +1738,7 @@ static int bnx2i_process_nopin_mesg(struct iscsi_session *session,
1738 } 1738 }
1739done: 1739done:
1740 __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, NULL, 0); 1740 __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, NULL, 0);
1741 spin_unlock(&session->lock); 1741 spin_unlock(&session->back_lock);
1742 1742
1743 return tgt_async_nop; 1743 return tgt_async_nop;
1744} 1744}
@@ -1771,7 +1771,7 @@ static void bnx2i_process_async_mesg(struct iscsi_session *session,
1771 return; 1771 return;
1772 } 1772 }
1773 1773
1774 spin_lock(&session->lock); 1774 spin_lock(&session->back_lock);
1775 resp_hdr = (struct iscsi_async *) &bnx2i_conn->gen_pdu.resp_hdr; 1775 resp_hdr = (struct iscsi_async *) &bnx2i_conn->gen_pdu.resp_hdr;
1776 memset(resp_hdr, 0, sizeof(struct iscsi_hdr)); 1776 memset(resp_hdr, 0, sizeof(struct iscsi_hdr));
1777 resp_hdr->opcode = async_cqe->op_code; 1777 resp_hdr->opcode = async_cqe->op_code;
@@ -1790,7 +1790,7 @@ static void bnx2i_process_async_mesg(struct iscsi_session *session,
1790 1790
1791 __iscsi_complete_pdu(bnx2i_conn->cls_conn->dd_data, 1791 __iscsi_complete_pdu(bnx2i_conn->cls_conn->dd_data,
1792 (struct iscsi_hdr *)resp_hdr, NULL, 0); 1792 (struct iscsi_hdr *)resp_hdr, NULL, 0);
1793 spin_unlock(&session->lock); 1793 spin_unlock(&session->back_lock);
1794} 1794}
1795 1795
1796 1796
@@ -1817,7 +1817,7 @@ static void bnx2i_process_reject_mesg(struct iscsi_session *session,
1817 } else 1817 } else
1818 bnx2i_unsol_pdu_adjust_rq(bnx2i_conn); 1818 bnx2i_unsol_pdu_adjust_rq(bnx2i_conn);
1819 1819
1820 spin_lock(&session->lock); 1820 spin_lock(&session->back_lock);
1821 hdr = (struct iscsi_reject *) &bnx2i_conn->gen_pdu.resp_hdr; 1821 hdr = (struct iscsi_reject *) &bnx2i_conn->gen_pdu.resp_hdr;
1822 memset(hdr, 0, sizeof(struct iscsi_hdr)); 1822 memset(hdr, 0, sizeof(struct iscsi_hdr));
1823 hdr->opcode = reject->op_code; 1823 hdr->opcode = reject->op_code;
@@ -1828,7 +1828,7 @@ static void bnx2i_process_reject_mesg(struct iscsi_session *session,
1828 hdr->ffffffff = cpu_to_be32(RESERVED_ITT); 1828 hdr->ffffffff = cpu_to_be32(RESERVED_ITT);
1829 __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, conn->data, 1829 __iscsi_complete_pdu(conn, (struct iscsi_hdr *)hdr, conn->data,
1830 reject->data_length); 1830 reject->data_length);
1831 spin_unlock(&session->lock); 1831 spin_unlock(&session->back_lock);
1832} 1832}
1833 1833
1834/** 1834/**
@@ -1848,13 +1848,13 @@ static void bnx2i_process_cmd_cleanup_resp(struct iscsi_session *session,
1848 struct iscsi_task *task; 1848 struct iscsi_task *task;
1849 1849
1850 cmd_clean_rsp = (struct bnx2i_cleanup_response *)cqe; 1850 cmd_clean_rsp = (struct bnx2i_cleanup_response *)cqe;
1851 spin_lock(&session->lock); 1851 spin_lock(&session->back_lock);
1852 task = iscsi_itt_to_task(conn, 1852 task = iscsi_itt_to_task(conn,
1853 cmd_clean_rsp->itt & ISCSI_CLEANUP_RESPONSE_INDEX); 1853 cmd_clean_rsp->itt & ISCSI_CLEANUP_RESPONSE_INDEX);
1854 if (!task) 1854 if (!task)
1855 printk(KERN_ALERT "bnx2i: cmd clean ITT %x not active\n", 1855 printk(KERN_ALERT "bnx2i: cmd clean ITT %x not active\n",
1856 cmd_clean_rsp->itt & ISCSI_CLEANUP_RESPONSE_INDEX); 1856 cmd_clean_rsp->itt & ISCSI_CLEANUP_RESPONSE_INDEX);
1857 spin_unlock(&session->lock); 1857 spin_unlock(&session->back_lock);
1858 complete(&bnx2i_conn->cmd_cleanup_cmpl); 1858 complete(&bnx2i_conn->cmd_cleanup_cmpl);
1859} 1859}
1860 1860
@@ -1921,11 +1921,11 @@ static int bnx2i_queue_scsi_cmd_resp(struct iscsi_session *session,
1921 int rc = 0; 1921 int rc = 0;
1922 int cpu; 1922 int cpu;
1923 1923
1924 spin_lock(&session->lock); 1924 spin_lock(&session->back_lock);
1925 task = iscsi_itt_to_task(bnx2i_conn->cls_conn->dd_data, 1925 task = iscsi_itt_to_task(bnx2i_conn->cls_conn->dd_data,
1926 cqe->itt & ISCSI_CMD_RESPONSE_INDEX); 1926 cqe->itt & ISCSI_CMD_RESPONSE_INDEX);
1927 if (!task || !task->sc) { 1927 if (!task || !task->sc) {
1928 spin_unlock(&session->lock); 1928 spin_unlock(&session->back_lock);
1929 return -EINVAL; 1929 return -EINVAL;
1930 } 1930 }
1931 sc = task->sc; 1931 sc = task->sc;
@@ -1935,7 +1935,7 @@ static int bnx2i_queue_scsi_cmd_resp(struct iscsi_session *session,
1935 else 1935 else
1936 cpu = sc->request->cpu; 1936 cpu = sc->request->cpu;
1937 1937
1938 spin_unlock(&session->lock); 1938 spin_unlock(&session->back_lock);
1939 1939
1940 p = &per_cpu(bnx2i_percpu, cpu); 1940 p = &per_cpu(bnx2i_percpu, cpu);
1941 spin_lock(&p->p_work_lock); 1941 spin_lock(&p->p_work_lock);
diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 854dad7d5b03..c00642f10f1f 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1169,10 +1169,10 @@ static void bnx2i_cleanup_task(struct iscsi_task *task)
1169 if (task->state == ISCSI_TASK_ABRT_TMF) { 1169 if (task->state == ISCSI_TASK_ABRT_TMF) {
1170 bnx2i_send_cmd_cleanup_req(hba, task->dd_data); 1170 bnx2i_send_cmd_cleanup_req(hba, task->dd_data);
1171 1171
1172 spin_unlock_bh(&conn->session->lock); 1172 spin_unlock_bh(&conn->session->back_lock);
1173 wait_for_completion_timeout(&bnx2i_conn->cmd_cleanup_cmpl, 1173 wait_for_completion_timeout(&bnx2i_conn->cmd_cleanup_cmpl,
1174 msecs_to_jiffies(ISCSI_CMD_CLEANUP_TIMEOUT)); 1174 msecs_to_jiffies(ISCSI_CMD_CLEANUP_TIMEOUT));
1175 spin_lock_bh(&conn->session->lock); 1175 spin_lock_bh(&conn->session->back_lock);
1176 } 1176 }
1177 bnx2i_iscsi_unmap_sg_list(task->dd_data); 1177 bnx2i_iscsi_unmap_sg_list(task->dd_data);
1178} 1178}
@@ -2059,7 +2059,7 @@ int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep)
2059 goto out; 2059 goto out;
2060 2060
2061 if (session) { 2061 if (session) {
2062 spin_lock_bh(&session->lock); 2062 spin_lock_bh(&session->frwd_lock);
2063 if (bnx2i_ep->state != EP_STATE_TCP_FIN_RCVD) { 2063 if (bnx2i_ep->state != EP_STATE_TCP_FIN_RCVD) {
2064 if (session->state == ISCSI_STATE_LOGGING_OUT) { 2064 if (session->state == ISCSI_STATE_LOGGING_OUT) {
2065 if (bnx2i_ep->state == EP_STATE_LOGOUT_SENT) { 2065 if (bnx2i_ep->state == EP_STATE_LOGOUT_SENT) {
@@ -2075,7 +2075,7 @@ int bnx2i_hw_ep_disconnect(struct bnx2i_endpoint *bnx2i_ep)
2075 } else 2075 } else
2076 close = 1; 2076 close = 1;
2077 2077
2078 spin_unlock_bh(&session->lock); 2078 spin_unlock_bh(&session->frwd_lock);
2079 } 2079 }
2080 2080
2081 bnx2i_ep->state = EP_STATE_DISCONN_START; 2081 bnx2i_ep->state = EP_STATE_DISCONN_START;
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index add6d1566ec8..12b351213c59 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -593,9 +593,9 @@ static void iscsi_sw_tcp_release_conn(struct iscsi_conn *conn)
593 iscsi_sw_tcp_conn_restore_callbacks(conn); 593 iscsi_sw_tcp_conn_restore_callbacks(conn);
594 sock_put(sock->sk); 594 sock_put(sock->sk);
595 595
596 spin_lock_bh(&session->lock); 596 spin_lock_bh(&session->frwd_lock);
597 tcp_sw_conn->sock = NULL; 597 tcp_sw_conn->sock = NULL;
598 spin_unlock_bh(&session->lock); 598 spin_unlock_bh(&session->frwd_lock);
599 sockfd_put(sock); 599 sockfd_put(sock);
600} 600}
601 601
@@ -663,10 +663,10 @@ iscsi_sw_tcp_conn_bind(struct iscsi_cls_session *cls_session,
663 if (err) 663 if (err)
664 goto free_socket; 664 goto free_socket;
665 665
666 spin_lock_bh(&session->lock); 666 spin_lock_bh(&session->frwd_lock);
667 /* bind iSCSI connection and socket */ 667 /* bind iSCSI connection and socket */
668 tcp_sw_conn->sock = sock; 668 tcp_sw_conn->sock = sock;
669 spin_unlock_bh(&session->lock); 669 spin_unlock_bh(&session->frwd_lock);
670 670
671 /* setup Socket parameters */ 671 /* setup Socket parameters */
672 sk = sock->sk; 672 sk = sock->sk;
@@ -726,14 +726,14 @@ static int iscsi_sw_tcp_conn_get_param(struct iscsi_cls_conn *cls_conn,
726 switch(param) { 726 switch(param) {
727 case ISCSI_PARAM_CONN_PORT: 727 case ISCSI_PARAM_CONN_PORT:
728 case ISCSI_PARAM_CONN_ADDRESS: 728 case ISCSI_PARAM_CONN_ADDRESS:
729 spin_lock_bh(&conn->session->lock); 729 spin_lock_bh(&conn->session->frwd_lock);
730 if (!tcp_sw_conn || !tcp_sw_conn->sock) { 730 if (!tcp_sw_conn || !tcp_sw_conn->sock) {
731 spin_unlock_bh(&conn->session->lock); 731 spin_unlock_bh(&conn->session->frwd_lock);
732 return -ENOTCONN; 732 return -ENOTCONN;
733 } 733 }
734 rc = kernel_getpeername(tcp_sw_conn->sock, 734 rc = kernel_getpeername(tcp_sw_conn->sock,
735 (struct sockaddr *)&addr, &len); 735 (struct sockaddr *)&addr, &len);
736 spin_unlock_bh(&conn->session->lock); 736 spin_unlock_bh(&conn->session->frwd_lock);
737 if (rc) 737 if (rc)
738 return rc; 738 return rc;
739 739
@@ -759,23 +759,23 @@ static int iscsi_sw_tcp_host_get_param(struct Scsi_Host *shost,
759 759
760 switch (param) { 760 switch (param) {
761 case ISCSI_HOST_PARAM_IPADDRESS: 761 case ISCSI_HOST_PARAM_IPADDRESS:
762 spin_lock_bh(&session->lock); 762 spin_lock_bh(&session->frwd_lock);
763 conn = session->leadconn; 763 conn = session->leadconn;
764 if (!conn) { 764 if (!conn) {
765 spin_unlock_bh(&session->lock); 765 spin_unlock_bh(&session->frwd_lock);
766 return -ENOTCONN; 766 return -ENOTCONN;
767 } 767 }
768 tcp_conn = conn->dd_data; 768 tcp_conn = conn->dd_data;
769 769
770 tcp_sw_conn = tcp_conn->dd_data; 770 tcp_sw_conn = tcp_conn->dd_data;
771 if (!tcp_sw_conn->sock) { 771 if (!tcp_sw_conn->sock) {
772 spin_unlock_bh(&session->lock); 772 spin_unlock_bh(&session->frwd_lock);
773 return -ENOTCONN; 773 return -ENOTCONN;
774 } 774 }
775 775
776 rc = kernel_getsockname(tcp_sw_conn->sock, 776 rc = kernel_getsockname(tcp_sw_conn->sock,
777 (struct sockaddr *)&addr, &len); 777 (struct sockaddr *)&addr, &len);
778 spin_unlock_bh(&session->lock); 778 spin_unlock_bh(&session->frwd_lock);
779 if (rc) 779 if (rc)
780 return rc; 780 return rc;
781 781
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index cd330c0e0fd5..8738b989a801 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -481,7 +481,7 @@ static int iscsi_prep_scsi_cmd_pdu(struct iscsi_task *task)
481 * iscsi_free_task - free a task 481 * iscsi_free_task - free a task
482 * @task: iscsi cmd task 482 * @task: iscsi cmd task
483 * 483 *
484 * Must be called with session lock. 484 * Must be called with session back_lock.
485 * This function returns the scsi command to scsi-ml or cleans 485 * This function returns the scsi command to scsi-ml or cleans
486 * up mgmt tasks then returns the task to the pool. 486 * up mgmt tasks then returns the task to the pool.
487 */ 487 */
@@ -535,9 +535,10 @@ void iscsi_put_task(struct iscsi_task *task)
535{ 535{
536 struct iscsi_session *session = task->conn->session; 536 struct iscsi_session *session = task->conn->session;
537 537
538 spin_lock_bh(&session->lock); 538 /* regular RX path uses back_lock */
539 spin_lock_bh(&session->back_lock);
539 __iscsi_put_task(task); 540 __iscsi_put_task(task);
540 spin_unlock_bh(&session->lock); 541 spin_unlock_bh(&session->back_lock);
541} 542}
542EXPORT_SYMBOL_GPL(iscsi_put_task); 543EXPORT_SYMBOL_GPL(iscsi_put_task);
543 544
@@ -546,7 +547,7 @@ EXPORT_SYMBOL_GPL(iscsi_put_task);
546 * @task: iscsi cmd task 547 * @task: iscsi cmd task
547 * @state: state to complete task with 548 * @state: state to complete task with
548 * 549 *
549 * Must be called with session lock. 550 * Must be called with session back_lock.
550 */ 551 */
551static void iscsi_complete_task(struct iscsi_task *task, int state) 552static void iscsi_complete_task(struct iscsi_task *task, int state)
552{ 553{
@@ -585,7 +586,7 @@ static void iscsi_complete_task(struct iscsi_task *task, int state)
585 * This is used when drivers do not need or cannot perform 586 * This is used when drivers do not need or cannot perform
586 * lower level pdu processing. 587 * lower level pdu processing.
587 * 588 *
588 * Called with session lock 589 * Called with session back_lock
589 */ 590 */
590void iscsi_complete_scsi_task(struct iscsi_task *task, 591void iscsi_complete_scsi_task(struct iscsi_task *task,
591 uint32_t exp_cmdsn, uint32_t max_cmdsn) 592 uint32_t exp_cmdsn, uint32_t max_cmdsn)
@@ -602,7 +603,7 @@ EXPORT_SYMBOL_GPL(iscsi_complete_scsi_task);
602 603
603 604
604/* 605/*
605 * session lock must be held and if not called for a task that is 606 * session back_lock must be held and if not called for a task that is
606 * still pending or from the xmit thread, then xmit thread must 607 * still pending or from the xmit thread, then xmit thread must
607 * be suspended. 608 * be suspended.
608 */ 609 */
@@ -642,7 +643,10 @@ static void fail_scsi_task(struct iscsi_task *task, int err)
642 scsi_in(sc)->resid = scsi_in(sc)->length; 643 scsi_in(sc)->resid = scsi_in(sc)->length;
643 } 644 }
644 645
646 /* regular RX path uses back_lock */
647 spin_lock_bh(&conn->session->back_lock);
645 iscsi_complete_task(task, state); 648 iscsi_complete_task(task, state);
649 spin_unlock_bh(&conn->session->back_lock);
646} 650}
647 651
648static int iscsi_prep_mgmt_task(struct iscsi_conn *conn, 652static int iscsi_prep_mgmt_task(struct iscsi_conn *conn,
@@ -780,7 +784,10 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
780 return task; 784 return task;
781 785
782free_task: 786free_task:
787 /* regular RX path uses back_lock */
788 spin_lock_bh(&session->back_lock);
783 __iscsi_put_task(task); 789 __iscsi_put_task(task);
790 spin_unlock_bh(&session->back_lock);
784 return NULL; 791 return NULL;
785} 792}
786 793
@@ -791,10 +798,10 @@ int iscsi_conn_send_pdu(struct iscsi_cls_conn *cls_conn, struct iscsi_hdr *hdr,
791 struct iscsi_session *session = conn->session; 798 struct iscsi_session *session = conn->session;
792 int err = 0; 799 int err = 0;
793 800
794 spin_lock_bh(&session->lock); 801 spin_lock_bh(&session->frwd_lock);
795 if (!__iscsi_conn_send_pdu(conn, hdr, data, data_size)) 802 if (!__iscsi_conn_send_pdu(conn, hdr, data, data_size))
796 err = -EPERM; 803 err = -EPERM;
797 spin_unlock_bh(&session->lock); 804 spin_unlock_bh(&session->frwd_lock);
798 return err; 805 return err;
799} 806}
800EXPORT_SYMBOL_GPL(iscsi_conn_send_pdu); 807EXPORT_SYMBOL_GPL(iscsi_conn_send_pdu);
@@ -1031,14 +1038,19 @@ static int iscsi_handle_reject(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
1031 if (opcode != ISCSI_OP_NOOP_OUT) 1038 if (opcode != ISCSI_OP_NOOP_OUT)
1032 return 0; 1039 return 0;
1033 1040
1034 if (rejected_pdu.itt == cpu_to_be32(ISCSI_RESERVED_TAG)) 1041 if (rejected_pdu.itt == cpu_to_be32(ISCSI_RESERVED_TAG)) {
1035 /* 1042 /*
1036 * nop-out in response to target's nop-out rejected. 1043 * nop-out in response to target's nop-out rejected.
1037 * Just resend. 1044 * Just resend.
1038 */ 1045 */
1046 /* In RX path we are under back lock */
1047 spin_unlock(&conn->session->back_lock);
1048 spin_lock(&conn->session->frwd_lock);
1039 iscsi_send_nopout(conn, 1049 iscsi_send_nopout(conn,
1040 (struct iscsi_nopin*)&rejected_pdu); 1050 (struct iscsi_nopin*)&rejected_pdu);
1041 else { 1051 spin_unlock(&conn->session->frwd_lock);
1052 spin_lock(&conn->session->back_lock);
1053 } else {
1042 struct iscsi_task *task; 1054 struct iscsi_task *task;
1043 /* 1055 /*
1044 * Our nop as ping got dropped. We know the target 1056 * Our nop as ping got dropped. We know the target
@@ -1074,7 +1086,7 @@ static int iscsi_handle_reject(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
1074 * This should be used for mgmt tasks like login and nops, or if 1086 * This should be used for mgmt tasks like login and nops, or if
1075 * the LDD's itt space does not include the session age. 1087 * the LDD's itt space does not include the session age.
1076 * 1088 *
1077 * The session lock must be held. 1089 * The session back_lock must be held.
1078 */ 1090 */
1079struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *conn, itt_t itt) 1091struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *conn, itt_t itt)
1080{ 1092{
@@ -1103,7 +1115,7 @@ EXPORT_SYMBOL_GPL(iscsi_itt_to_task);
1103 * @datalen: len of data buffer 1115 * @datalen: len of data buffer
1104 * 1116 *
1105 * Completes pdu processing by freeing any resources allocated at 1117 * Completes pdu processing by freeing any resources allocated at
1106 * queuecommand or send generic. session lock must be held and verify 1118 * queuecommand or send generic. session back_lock must be held and verify
1107 * itt must have been called. 1119 * itt must have been called.
1108 */ 1120 */
1109int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr, 1121int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
@@ -1140,7 +1152,12 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
1140 if (hdr->ttt == cpu_to_be32(ISCSI_RESERVED_TAG)) 1152 if (hdr->ttt == cpu_to_be32(ISCSI_RESERVED_TAG))
1141 break; 1153 break;
1142 1154
1155 /* In RX path we are under back lock */
1156 spin_unlock(&session->back_lock);
1157 spin_lock(&session->frwd_lock);
1143 iscsi_send_nopout(conn, (struct iscsi_nopin*)hdr); 1158 iscsi_send_nopout(conn, (struct iscsi_nopin*)hdr);
1159 spin_unlock(&session->frwd_lock);
1160 spin_lock(&session->back_lock);
1144 break; 1161 break;
1145 case ISCSI_OP_REJECT: 1162 case ISCSI_OP_REJECT:
1146 rc = iscsi_handle_reject(conn, hdr, data, datalen); 1163 rc = iscsi_handle_reject(conn, hdr, data, datalen);
@@ -1247,9 +1264,9 @@ int iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
1247{ 1264{
1248 int rc; 1265 int rc;
1249 1266
1250 spin_lock(&conn->session->lock); 1267 spin_lock(&conn->session->back_lock);
1251 rc = __iscsi_complete_pdu(conn, hdr, data, datalen); 1268 rc = __iscsi_complete_pdu(conn, hdr, data, datalen);
1252 spin_unlock(&conn->session->lock); 1269 spin_unlock(&conn->session->back_lock);
1253 return rc; 1270 return rc;
1254} 1271}
1255EXPORT_SYMBOL_GPL(iscsi_complete_pdu); 1272EXPORT_SYMBOL_GPL(iscsi_complete_pdu);
@@ -1293,7 +1310,7 @@ EXPORT_SYMBOL_GPL(iscsi_verify_itt);
1293 * 1310 *
1294 * This should be used for cmd tasks. 1311 * This should be used for cmd tasks.
1295 * 1312 *
1296 * The session lock must be held. 1313 * The session back_lock must be held.
1297 */ 1314 */
1298struct iscsi_task *iscsi_itt_to_ctask(struct iscsi_conn *conn, itt_t itt) 1315struct iscsi_task *iscsi_itt_to_ctask(struct iscsi_conn *conn, itt_t itt)
1299{ 1316{
@@ -1323,15 +1340,15 @@ void iscsi_session_failure(struct iscsi_session *session,
1323 struct iscsi_conn *conn; 1340 struct iscsi_conn *conn;
1324 struct device *dev; 1341 struct device *dev;
1325 1342
1326 spin_lock_bh(&session->lock); 1343 spin_lock_bh(&session->frwd_lock);
1327 conn = session->leadconn; 1344 conn = session->leadconn;
1328 if (session->state == ISCSI_STATE_TERMINATE || !conn) { 1345 if (session->state == ISCSI_STATE_TERMINATE || !conn) {
1329 spin_unlock_bh(&session->lock); 1346 spin_unlock_bh(&session->frwd_lock);
1330 return; 1347 return;
1331 } 1348 }
1332 1349
1333 dev = get_device(&conn->cls_conn->dev); 1350 dev = get_device(&conn->cls_conn->dev);
1334 spin_unlock_bh(&session->lock); 1351 spin_unlock_bh(&session->frwd_lock);
1335 if (!dev) 1352 if (!dev)
1336 return; 1353 return;
1337 /* 1354 /*
@@ -1351,15 +1368,15 @@ void iscsi_conn_failure(struct iscsi_conn *conn, enum iscsi_err err)
1351{ 1368{
1352 struct iscsi_session *session = conn->session; 1369 struct iscsi_session *session = conn->session;
1353 1370
1354 spin_lock_bh(&session->lock); 1371 spin_lock_bh(&session->frwd_lock);
1355 if (session->state == ISCSI_STATE_FAILED) { 1372 if (session->state == ISCSI_STATE_FAILED) {
1356 spin_unlock_bh(&session->lock); 1373 spin_unlock_bh(&session->frwd_lock);
1357 return; 1374 return;
1358 } 1375 }
1359 1376
1360 if (conn->stop_stage == 0) 1377 if (conn->stop_stage == 0)
1361 session->state = ISCSI_STATE_FAILED; 1378 session->state = ISCSI_STATE_FAILED;
1362 spin_unlock_bh(&session->lock); 1379 spin_unlock_bh(&session->frwd_lock);
1363 1380
1364 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx); 1381 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
1365 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx); 1382 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx);
@@ -1393,15 +1410,18 @@ static int iscsi_xmit_task(struct iscsi_conn *conn)
1393 return -ENODATA; 1410 return -ENODATA;
1394 1411
1395 __iscsi_get_task(task); 1412 __iscsi_get_task(task);
1396 spin_unlock_bh(&conn->session->lock); 1413 spin_unlock_bh(&conn->session->frwd_lock);
1397 rc = conn->session->tt->xmit_task(task); 1414 rc = conn->session->tt->xmit_task(task);
1398 spin_lock_bh(&conn->session->lock); 1415 spin_lock_bh(&conn->session->frwd_lock);
1399 if (!rc) { 1416 if (!rc) {
1400 /* done with this task */ 1417 /* done with this task */
1401 task->last_xfer = jiffies; 1418 task->last_xfer = jiffies;
1402 conn->task = NULL; 1419 conn->task = NULL;
1403 } 1420 }
1421 /* regular RX path uses back_lock */
1422 spin_lock_bh(&conn->session->back_lock);
1404 __iscsi_put_task(task); 1423 __iscsi_put_task(task);
1424 spin_unlock_bh(&conn->session->back_lock);
1405 return rc; 1425 return rc;
1406} 1426}
1407 1427
@@ -1410,7 +1430,7 @@ static int iscsi_xmit_task(struct iscsi_conn *conn)
1410 * @task: task to requeue 1430 * @task: task to requeue
1411 * 1431 *
1412 * LLDs that need to run a task from the session workqueue should call 1432 * LLDs that need to run a task from the session workqueue should call
1413 * this. The session lock must be held. This should only be called 1433 * this. The session frwd_lock must be held. This should only be called
1414 * by software drivers. 1434 * by software drivers.
1415 */ 1435 */
1416void iscsi_requeue_task(struct iscsi_task *task) 1436void iscsi_requeue_task(struct iscsi_task *task)
@@ -1441,10 +1461,10 @@ static int iscsi_data_xmit(struct iscsi_conn *conn)
1441 struct iscsi_task *task; 1461 struct iscsi_task *task;
1442 int rc = 0; 1462 int rc = 0;
1443 1463
1444 spin_lock_bh(&conn->session->lock); 1464 spin_lock_bh(&conn->session->frwd_lock);
1445 if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx)) { 1465 if (test_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx)) {
1446 ISCSI_DBG_SESSION(conn->session, "Tx suspended!\n"); 1466 ISCSI_DBG_SESSION(conn->session, "Tx suspended!\n");
1447 spin_unlock_bh(&conn->session->lock); 1467 spin_unlock_bh(&conn->session->frwd_lock);
1448 return -ENODATA; 1468 return -ENODATA;
1449 } 1469 }
1450 1470
@@ -1465,7 +1485,10 @@ check_mgmt:
1465 struct iscsi_task, running); 1485 struct iscsi_task, running);
1466 list_del_init(&conn->task->running); 1486 list_del_init(&conn->task->running);
1467 if (iscsi_prep_mgmt_task(conn, conn->task)) { 1487 if (iscsi_prep_mgmt_task(conn, conn->task)) {
1488 /* regular RX path uses back_lock */
1489 spin_lock_bh(&conn->session->back_lock);
1468 __iscsi_put_task(conn->task); 1490 __iscsi_put_task(conn->task);
1491 spin_unlock_bh(&conn->session->back_lock);
1469 conn->task = NULL; 1492 conn->task = NULL;
1470 continue; 1493 continue;
1471 } 1494 }
@@ -1527,11 +1550,11 @@ check_mgmt:
1527 if (!list_empty(&conn->mgmtqueue)) 1550 if (!list_empty(&conn->mgmtqueue))
1528 goto check_mgmt; 1551 goto check_mgmt;
1529 } 1552 }
1530 spin_unlock_bh(&conn->session->lock); 1553 spin_unlock_bh(&conn->session->frwd_lock);
1531 return -ENODATA; 1554 return -ENODATA;
1532 1555
1533done: 1556done:
1534 spin_unlock_bh(&conn->session->lock); 1557 spin_unlock_bh(&conn->session->frwd_lock);
1535 return rc; 1558 return rc;
1536} 1559}
1537 1560
@@ -1600,7 +1623,7 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc)
1600 1623
1601 cls_session = starget_to_session(scsi_target(sc->device)); 1624 cls_session = starget_to_session(scsi_target(sc->device));
1602 session = cls_session->dd_data; 1625 session = cls_session->dd_data;
1603 spin_lock_bh(&session->lock); 1626 spin_lock_bh(&session->frwd_lock);
1604 1627
1605 reason = iscsi_session_chkready(cls_session); 1628 reason = iscsi_session_chkready(cls_session);
1606 if (reason) { 1629 if (reason) {
@@ -1686,13 +1709,13 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc)
1686 } 1709 }
1687 1710
1688 session->queued_cmdsn++; 1711 session->queued_cmdsn++;
1689 spin_unlock_bh(&session->lock); 1712 spin_unlock_bh(&session->frwd_lock);
1690 return 0; 1713 return 0;
1691 1714
1692prepd_reject: 1715prepd_reject:
1693 iscsi_complete_task(task, ISCSI_TASK_REQUEUE_SCSIQ); 1716 iscsi_complete_task(task, ISCSI_TASK_REQUEUE_SCSIQ);
1694reject: 1717reject:
1695 spin_unlock_bh(&session->lock); 1718 spin_unlock_bh(&session->frwd_lock);
1696 ISCSI_DBG_SESSION(session, "cmd 0x%x rejected (%d)\n", 1719 ISCSI_DBG_SESSION(session, "cmd 0x%x rejected (%d)\n",
1697 sc->cmnd[0], reason); 1720 sc->cmnd[0], reason);
1698 return SCSI_MLQUEUE_TARGET_BUSY; 1721 return SCSI_MLQUEUE_TARGET_BUSY;
@@ -1700,7 +1723,7 @@ reject:
1700prepd_fault: 1723prepd_fault:
1701 iscsi_complete_task(task, ISCSI_TASK_REQUEUE_SCSIQ); 1724 iscsi_complete_task(task, ISCSI_TASK_REQUEUE_SCSIQ);
1702fault: 1725fault:
1703 spin_unlock_bh(&session->lock); 1726 spin_unlock_bh(&session->frwd_lock);
1704 ISCSI_DBG_SESSION(session, "iscsi: cmd 0x%x is not queued (%d)\n", 1727 ISCSI_DBG_SESSION(session, "iscsi: cmd 0x%x is not queued (%d)\n",
1705 sc->cmnd[0], reason); 1728 sc->cmnd[0], reason);
1706 if (!scsi_bidi_cmnd(sc)) 1729 if (!scsi_bidi_cmnd(sc))
@@ -1748,14 +1771,14 @@ static void iscsi_tmf_timedout(unsigned long data)
1748 struct iscsi_conn *conn = (struct iscsi_conn *)data; 1771 struct iscsi_conn *conn = (struct iscsi_conn *)data;
1749 struct iscsi_session *session = conn->session; 1772 struct iscsi_session *session = conn->session;
1750 1773
1751 spin_lock(&session->lock); 1774 spin_lock(&session->frwd_lock);
1752 if (conn->tmf_state == TMF_QUEUED) { 1775 if (conn->tmf_state == TMF_QUEUED) {
1753 conn->tmf_state = TMF_TIMEDOUT; 1776 conn->tmf_state = TMF_TIMEDOUT;
1754 ISCSI_DBG_EH(session, "tmf timedout\n"); 1777 ISCSI_DBG_EH(session, "tmf timedout\n");
1755 /* unblock eh_abort() */ 1778 /* unblock eh_abort() */
1756 wake_up(&conn->ehwait); 1779 wake_up(&conn->ehwait);
1757 } 1780 }
1758 spin_unlock(&session->lock); 1781 spin_unlock(&session->frwd_lock);
1759} 1782}
1760 1783
1761static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn, 1784static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn,
@@ -1768,10 +1791,10 @@ static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn,
1768 task = __iscsi_conn_send_pdu(conn, (struct iscsi_hdr *)hdr, 1791 task = __iscsi_conn_send_pdu(conn, (struct iscsi_hdr *)hdr,
1769 NULL, 0); 1792 NULL, 0);
1770 if (!task) { 1793 if (!task) {
1771 spin_unlock_bh(&session->lock); 1794 spin_unlock_bh(&session->frwd_lock);
1772 iscsi_conn_printk(KERN_ERR, conn, "Could not send TMF.\n"); 1795 iscsi_conn_printk(KERN_ERR, conn, "Could not send TMF.\n");
1773 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); 1796 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
1774 spin_lock_bh(&session->lock); 1797 spin_lock_bh(&session->frwd_lock);
1775 return -EPERM; 1798 return -EPERM;
1776 } 1799 }
1777 conn->tmfcmd_pdus_cnt++; 1800 conn->tmfcmd_pdus_cnt++;
@@ -1781,7 +1804,7 @@ static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn,
1781 add_timer(&conn->tmf_timer); 1804 add_timer(&conn->tmf_timer);
1782 ISCSI_DBG_EH(session, "tmf set timeout\n"); 1805 ISCSI_DBG_EH(session, "tmf set timeout\n");
1783 1806
1784 spin_unlock_bh(&session->lock); 1807 spin_unlock_bh(&session->frwd_lock);
1785 mutex_unlock(&session->eh_mutex); 1808 mutex_unlock(&session->eh_mutex);
1786 1809
1787 /* 1810 /*
@@ -1800,7 +1823,7 @@ static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn,
1800 del_timer_sync(&conn->tmf_timer); 1823 del_timer_sync(&conn->tmf_timer);
1801 1824
1802 mutex_lock(&session->eh_mutex); 1825 mutex_lock(&session->eh_mutex);
1803 spin_lock_bh(&session->lock); 1826 spin_lock_bh(&session->frwd_lock);
1804 /* if the session drops it will clean up the task */ 1827 /* if the session drops it will clean up the task */
1805 if (age != session->age || 1828 if (age != session->age ||
1806 session->state != ISCSI_STATE_LOGGED_IN) 1829 session->state != ISCSI_STATE_LOGGED_IN)
@@ -1837,7 +1860,7 @@ static void fail_scsi_tasks(struct iscsi_conn *conn, unsigned lun,
1837 * iscsi_suspend_queue - suspend iscsi_queuecommand 1860 * iscsi_suspend_queue - suspend iscsi_queuecommand
1838 * @conn: iscsi conn to stop queueing IO on 1861 * @conn: iscsi conn to stop queueing IO on
1839 * 1862 *
1840 * This grabs the session lock to make sure no one is in 1863 * This grabs the session frwd_lock to make sure no one is in
1841 * xmit_task/queuecommand, and then sets suspend to prevent 1864 * xmit_task/queuecommand, and then sets suspend to prevent
1842 * new commands from being queued. This only needs to be called 1865 * new commands from being queued. This only needs to be called
1843 * by offload drivers that need to sync a path like ep disconnect 1866 * by offload drivers that need to sync a path like ep disconnect
@@ -1846,9 +1869,9 @@ static void fail_scsi_tasks(struct iscsi_conn *conn, unsigned lun,
1846 */ 1869 */
1847void iscsi_suspend_queue(struct iscsi_conn *conn) 1870void iscsi_suspend_queue(struct iscsi_conn *conn)
1848{ 1871{
1849 spin_lock_bh(&conn->session->lock); 1872 spin_lock_bh(&conn->session->frwd_lock);
1850 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx); 1873 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);
1851 spin_unlock_bh(&conn->session->lock); 1874 spin_unlock_bh(&conn->session->frwd_lock);
1852} 1875}
1853EXPORT_SYMBOL_GPL(iscsi_suspend_queue); 1876EXPORT_SYMBOL_GPL(iscsi_suspend_queue);
1854 1877
@@ -1907,7 +1930,7 @@ static enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc)
1907 1930
1908 ISCSI_DBG_EH(session, "scsi cmd %p timedout\n", sc); 1931 ISCSI_DBG_EH(session, "scsi cmd %p timedout\n", sc);
1909 1932
1910 spin_lock(&session->lock); 1933 spin_lock(&session->frwd_lock);
1911 task = (struct iscsi_task *)sc->SCp.ptr; 1934 task = (struct iscsi_task *)sc->SCp.ptr;
1912 if (!task) { 1935 if (!task) {
1913 /* 1936 /*
@@ -2021,7 +2044,7 @@ static enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc)
2021done: 2044done:
2022 if (task) 2045 if (task)
2023 task->last_timeout = jiffies; 2046 task->last_timeout = jiffies;
2024 spin_unlock(&session->lock); 2047 spin_unlock(&session->frwd_lock);
2025 ISCSI_DBG_EH(session, "return %s\n", rc == BLK_EH_RESET_TIMER ? 2048 ISCSI_DBG_EH(session, "return %s\n", rc == BLK_EH_RESET_TIMER ?
2026 "timer reset" : "nh"); 2049 "timer reset" : "nh");
2027 return rc; 2050 return rc;
@@ -2033,7 +2056,7 @@ static void iscsi_check_transport_timeouts(unsigned long data)
2033 struct iscsi_session *session = conn->session; 2056 struct iscsi_session *session = conn->session;
2034 unsigned long recv_timeout, next_timeout = 0, last_recv; 2057 unsigned long recv_timeout, next_timeout = 0, last_recv;
2035 2058
2036 spin_lock(&session->lock); 2059 spin_lock(&session->frwd_lock);
2037 if (session->state != ISCSI_STATE_LOGGED_IN) 2060 if (session->state != ISCSI_STATE_LOGGED_IN)
2038 goto done; 2061 goto done;
2039 2062
@@ -2050,7 +2073,7 @@ static void iscsi_check_transport_timeouts(unsigned long data)
2050 "last ping %lu, now %lu\n", 2073 "last ping %lu, now %lu\n",
2051 conn->ping_timeout, conn->recv_timeout, 2074 conn->ping_timeout, conn->recv_timeout,
2052 last_recv, conn->last_ping, jiffies); 2075 last_recv, conn->last_ping, jiffies);
2053 spin_unlock(&session->lock); 2076 spin_unlock(&session->frwd_lock);
2054 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); 2077 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
2055 return; 2078 return;
2056 } 2079 }
@@ -2066,7 +2089,7 @@ static void iscsi_check_transport_timeouts(unsigned long data)
2066 ISCSI_DBG_CONN(conn, "Setting next tmo %lu\n", next_timeout); 2089 ISCSI_DBG_CONN(conn, "Setting next tmo %lu\n", next_timeout);
2067 mod_timer(&conn->transport_timer, next_timeout); 2090 mod_timer(&conn->transport_timer, next_timeout);
2068done: 2091done:
2069 spin_unlock(&session->lock); 2092 spin_unlock(&session->frwd_lock);
2070} 2093}
2071 2094
2072static void iscsi_prep_abort_task_pdu(struct iscsi_task *task, 2095static void iscsi_prep_abort_task_pdu(struct iscsi_task *task,
@@ -2096,7 +2119,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
2096 ISCSI_DBG_EH(session, "aborting sc %p\n", sc); 2119 ISCSI_DBG_EH(session, "aborting sc %p\n", sc);
2097 2120
2098 mutex_lock(&session->eh_mutex); 2121 mutex_lock(&session->eh_mutex);
2099 spin_lock_bh(&session->lock); 2122 spin_lock_bh(&session->frwd_lock);
2100 /* 2123 /*
2101 * if session was ISCSI_STATE_IN_RECOVERY then we may not have 2124 * if session was ISCSI_STATE_IN_RECOVERY then we may not have
2102 * got the command. 2125 * got the command.
@@ -2104,7 +2127,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
2104 if (!sc->SCp.ptr) { 2127 if (!sc->SCp.ptr) {
2105 ISCSI_DBG_EH(session, "sc never reached iscsi layer or " 2128 ISCSI_DBG_EH(session, "sc never reached iscsi layer or "
2106 "it completed.\n"); 2129 "it completed.\n");
2107 spin_unlock_bh(&session->lock); 2130 spin_unlock_bh(&session->frwd_lock);
2108 mutex_unlock(&session->eh_mutex); 2131 mutex_unlock(&session->eh_mutex);
2109 return SUCCESS; 2132 return SUCCESS;
2110 } 2133 }
@@ -2115,7 +2138,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
2115 */ 2138 */
2116 if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN || 2139 if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN ||
2117 sc->SCp.phase != session->age) { 2140 sc->SCp.phase != session->age) {
2118 spin_unlock_bh(&session->lock); 2141 spin_unlock_bh(&session->frwd_lock);
2119 mutex_unlock(&session->eh_mutex); 2142 mutex_unlock(&session->eh_mutex);
2120 ISCSI_DBG_EH(session, "failing abort due to dropped " 2143 ISCSI_DBG_EH(session, "failing abort due to dropped "
2121 "session.\n"); 2144 "session.\n");
@@ -2156,7 +2179,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
2156 2179
2157 switch (conn->tmf_state) { 2180 switch (conn->tmf_state) {
2158 case TMF_SUCCESS: 2181 case TMF_SUCCESS:
2159 spin_unlock_bh(&session->lock); 2182 spin_unlock_bh(&session->frwd_lock);
2160 /* 2183 /*
2161 * stop tx side incase the target had sent a abort rsp but 2184 * stop tx side incase the target had sent a abort rsp but
2162 * the initiator was still writing out data. 2185 * the initiator was still writing out data.
@@ -2167,15 +2190,15 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
2167 * good and have never sent us a successful tmf response 2190 * good and have never sent us a successful tmf response
2168 * then sent more data for the cmd. 2191 * then sent more data for the cmd.
2169 */ 2192 */
2170 spin_lock_bh(&session->lock); 2193 spin_lock_bh(&session->frwd_lock);
2171 fail_scsi_task(task, DID_ABORT); 2194 fail_scsi_task(task, DID_ABORT);
2172 conn->tmf_state = TMF_INITIAL; 2195 conn->tmf_state = TMF_INITIAL;
2173 memset(hdr, 0, sizeof(*hdr)); 2196 memset(hdr, 0, sizeof(*hdr));
2174 spin_unlock_bh(&session->lock); 2197 spin_unlock_bh(&session->frwd_lock);
2175 iscsi_start_tx(conn); 2198 iscsi_start_tx(conn);
2176 goto success_unlocked; 2199 goto success_unlocked;
2177 case TMF_TIMEDOUT: 2200 case TMF_TIMEDOUT:
2178 spin_unlock_bh(&session->lock); 2201 spin_unlock_bh(&session->frwd_lock);
2179 iscsi_conn_failure(conn, ISCSI_ERR_SCSI_EH_SESSION_RST); 2202 iscsi_conn_failure(conn, ISCSI_ERR_SCSI_EH_SESSION_RST);
2180 goto failed_unlocked; 2203 goto failed_unlocked;
2181 case TMF_NOT_FOUND: 2204 case TMF_NOT_FOUND:
@@ -2194,7 +2217,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
2194 } 2217 }
2195 2218
2196success: 2219success:
2197 spin_unlock_bh(&session->lock); 2220 spin_unlock_bh(&session->frwd_lock);
2198success_unlocked: 2221success_unlocked:
2199 ISCSI_DBG_EH(session, "abort success [sc %p itt 0x%x]\n", 2222 ISCSI_DBG_EH(session, "abort success [sc %p itt 0x%x]\n",
2200 sc, task->itt); 2223 sc, task->itt);
@@ -2202,7 +2225,7 @@ success_unlocked:
2202 return SUCCESS; 2225 return SUCCESS;
2203 2226
2204failed: 2227failed:
2205 spin_unlock_bh(&session->lock); 2228 spin_unlock_bh(&session->frwd_lock);
2206failed_unlocked: 2229failed_unlocked:
2207 ISCSI_DBG_EH(session, "abort failed [sc %p itt 0x%x]\n", sc, 2230 ISCSI_DBG_EH(session, "abort failed [sc %p itt 0x%x]\n", sc,
2208 task ? task->itt : 0); 2231 task ? task->itt : 0);
@@ -2235,7 +2258,7 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc)
2235 ISCSI_DBG_EH(session, "LU Reset [sc %p lun %u]\n", sc, sc->device->lun); 2258 ISCSI_DBG_EH(session, "LU Reset [sc %p lun %u]\n", sc, sc->device->lun);
2236 2259
2237 mutex_lock(&session->eh_mutex); 2260 mutex_lock(&session->eh_mutex);
2238 spin_lock_bh(&session->lock); 2261 spin_lock_bh(&session->frwd_lock);
2239 /* 2262 /*
2240 * Just check if we are not logged in. We cannot check for 2263 * Just check if we are not logged in. We cannot check for
2241 * the phase because the reset could come from a ioctl. 2264 * the phase because the reset could come from a ioctl.
@@ -2262,7 +2285,7 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc)
2262 case TMF_SUCCESS: 2285 case TMF_SUCCESS:
2263 break; 2286 break;
2264 case TMF_TIMEDOUT: 2287 case TMF_TIMEDOUT:
2265 spin_unlock_bh(&session->lock); 2288 spin_unlock_bh(&session->frwd_lock);
2266 iscsi_conn_failure(conn, ISCSI_ERR_SCSI_EH_SESSION_RST); 2289 iscsi_conn_failure(conn, ISCSI_ERR_SCSI_EH_SESSION_RST);
2267 goto done; 2290 goto done;
2268 default: 2291 default:
@@ -2271,21 +2294,21 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc)
2271 } 2294 }
2272 2295
2273 rc = SUCCESS; 2296 rc = SUCCESS;
2274 spin_unlock_bh(&session->lock); 2297 spin_unlock_bh(&session->frwd_lock);
2275 2298
2276 iscsi_suspend_tx(conn); 2299 iscsi_suspend_tx(conn);
2277 2300
2278 spin_lock_bh(&session->lock); 2301 spin_lock_bh(&session->frwd_lock);
2279 memset(hdr, 0, sizeof(*hdr)); 2302 memset(hdr, 0, sizeof(*hdr));
2280 fail_scsi_tasks(conn, sc->device->lun, DID_ERROR); 2303 fail_scsi_tasks(conn, sc->device->lun, DID_ERROR);
2281 conn->tmf_state = TMF_INITIAL; 2304 conn->tmf_state = TMF_INITIAL;
2282 spin_unlock_bh(&session->lock); 2305 spin_unlock_bh(&session->frwd_lock);
2283 2306
2284 iscsi_start_tx(conn); 2307 iscsi_start_tx(conn);
2285 goto done; 2308 goto done;
2286 2309
2287unlock: 2310unlock:
2288 spin_unlock_bh(&session->lock); 2311 spin_unlock_bh(&session->frwd_lock);
2289done: 2312done:
2290 ISCSI_DBG_EH(session, "dev reset result = %s\n", 2313 ISCSI_DBG_EH(session, "dev reset result = %s\n",
2291 rc == SUCCESS ? "SUCCESS" : "FAILED"); 2314 rc == SUCCESS ? "SUCCESS" : "FAILED");
@@ -2298,13 +2321,13 @@ void iscsi_session_recovery_timedout(struct iscsi_cls_session *cls_session)
2298{ 2321{
2299 struct iscsi_session *session = cls_session->dd_data; 2322 struct iscsi_session *session = cls_session->dd_data;
2300 2323
2301 spin_lock_bh(&session->lock); 2324 spin_lock_bh(&session->frwd_lock);
2302 if (session->state != ISCSI_STATE_LOGGED_IN) { 2325 if (session->state != ISCSI_STATE_LOGGED_IN) {
2303 session->state = ISCSI_STATE_RECOVERY_FAILED; 2326 session->state = ISCSI_STATE_RECOVERY_FAILED;
2304 if (session->leadconn) 2327 if (session->leadconn)
2305 wake_up(&session->leadconn->ehwait); 2328 wake_up(&session->leadconn->ehwait);
2306 } 2329 }
2307 spin_unlock_bh(&session->lock); 2330 spin_unlock_bh(&session->frwd_lock);
2308} 2331}
2309EXPORT_SYMBOL_GPL(iscsi_session_recovery_timedout); 2332EXPORT_SYMBOL_GPL(iscsi_session_recovery_timedout);
2310 2333
@@ -2326,19 +2349,19 @@ int iscsi_eh_session_reset(struct scsi_cmnd *sc)
2326 conn = session->leadconn; 2349 conn = session->leadconn;
2327 2350
2328 mutex_lock(&session->eh_mutex); 2351 mutex_lock(&session->eh_mutex);
2329 spin_lock_bh(&session->lock); 2352 spin_lock_bh(&session->frwd_lock);
2330 if (session->state == ISCSI_STATE_TERMINATE) { 2353 if (session->state == ISCSI_STATE_TERMINATE) {
2331failed: 2354failed:
2332 ISCSI_DBG_EH(session, 2355 ISCSI_DBG_EH(session,
2333 "failing session reset: Could not log back into " 2356 "failing session reset: Could not log back into "
2334 "%s, %s [age %d]\n", session->targetname, 2357 "%s, %s [age %d]\n", session->targetname,
2335 conn->persistent_address, session->age); 2358 conn->persistent_address, session->age);
2336 spin_unlock_bh(&session->lock); 2359 spin_unlock_bh(&session->frwd_lock);
2337 mutex_unlock(&session->eh_mutex); 2360 mutex_unlock(&session->eh_mutex);
2338 return FAILED; 2361 return FAILED;
2339 } 2362 }
2340 2363
2341 spin_unlock_bh(&session->lock); 2364 spin_unlock_bh(&session->frwd_lock);
2342 mutex_unlock(&session->eh_mutex); 2365 mutex_unlock(&session->eh_mutex);
2343 /* 2366 /*
2344 * we drop the lock here but the leadconn cannot be destoyed while 2367 * we drop the lock here but the leadconn cannot be destoyed while
@@ -2355,14 +2378,14 @@ failed:
2355 flush_signals(current); 2378 flush_signals(current);
2356 2379
2357 mutex_lock(&session->eh_mutex); 2380 mutex_lock(&session->eh_mutex);
2358 spin_lock_bh(&session->lock); 2381 spin_lock_bh(&session->frwd_lock);
2359 if (session->state == ISCSI_STATE_LOGGED_IN) { 2382 if (session->state == ISCSI_STATE_LOGGED_IN) {
2360 ISCSI_DBG_EH(session, 2383 ISCSI_DBG_EH(session,
2361 "session reset succeeded for %s,%s\n", 2384 "session reset succeeded for %s,%s\n",
2362 session->targetname, conn->persistent_address); 2385 session->targetname, conn->persistent_address);
2363 } else 2386 } else
2364 goto failed; 2387 goto failed;
2365 spin_unlock_bh(&session->lock); 2388 spin_unlock_bh(&session->frwd_lock);
2366 mutex_unlock(&session->eh_mutex); 2389 mutex_unlock(&session->eh_mutex);
2367 return SUCCESS; 2390 return SUCCESS;
2368} 2391}
@@ -2398,7 +2421,7 @@ int iscsi_eh_target_reset(struct scsi_cmnd *sc)
2398 session->targetname); 2421 session->targetname);
2399 2422
2400 mutex_lock(&session->eh_mutex); 2423 mutex_lock(&session->eh_mutex);
2401 spin_lock_bh(&session->lock); 2424 spin_lock_bh(&session->frwd_lock);
2402 /* 2425 /*
2403 * Just check if we are not logged in. We cannot check for 2426 * Just check if we are not logged in. We cannot check for
2404 * the phase because the reset could come from a ioctl. 2427 * the phase because the reset could come from a ioctl.
@@ -2425,7 +2448,7 @@ int iscsi_eh_target_reset(struct scsi_cmnd *sc)
2425 case TMF_SUCCESS: 2448 case TMF_SUCCESS:
2426 break; 2449 break;
2427 case TMF_TIMEDOUT: 2450 case TMF_TIMEDOUT:
2428 spin_unlock_bh(&session->lock); 2451 spin_unlock_bh(&session->frwd_lock);
2429 iscsi_conn_failure(conn, ISCSI_ERR_SCSI_EH_SESSION_RST); 2452 iscsi_conn_failure(conn, ISCSI_ERR_SCSI_EH_SESSION_RST);
2430 goto done; 2453 goto done;
2431 default: 2454 default:
@@ -2434,21 +2457,21 @@ int iscsi_eh_target_reset(struct scsi_cmnd *sc)
2434 } 2457 }
2435 2458
2436 rc = SUCCESS; 2459 rc = SUCCESS;
2437 spin_unlock_bh(&session->lock); 2460 spin_unlock_bh(&session->frwd_lock);
2438 2461
2439 iscsi_suspend_tx(conn); 2462 iscsi_suspend_tx(conn);
2440 2463
2441 spin_lock_bh(&session->lock); 2464 spin_lock_bh(&session->frwd_lock);
2442 memset(hdr, 0, sizeof(*hdr)); 2465 memset(hdr, 0, sizeof(*hdr));
2443 fail_scsi_tasks(conn, -1, DID_ERROR); 2466 fail_scsi_tasks(conn, -1, DID_ERROR);
2444 conn->tmf_state = TMF_INITIAL; 2467 conn->tmf_state = TMF_INITIAL;
2445 spin_unlock_bh(&session->lock); 2468 spin_unlock_bh(&session->frwd_lock);
2446 2469
2447 iscsi_start_tx(conn); 2470 iscsi_start_tx(conn);
2448 goto done; 2471 goto done;
2449 2472
2450unlock: 2473unlock:
2451 spin_unlock_bh(&session->lock); 2474 spin_unlock_bh(&session->frwd_lock);
2452done: 2475done:
2453 ISCSI_DBG_EH(session, "tgt %s reset result = %s\n", session->targetname, 2476 ISCSI_DBG_EH(session, "tgt %s reset result = %s\n", session->targetname,
2454 rc == SUCCESS ? "SUCCESS" : "FAILED"); 2477 rc == SUCCESS ? "SUCCESS" : "FAILED");
@@ -2746,8 +2769,10 @@ iscsi_session_setup(struct iscsi_transport *iscsit, struct Scsi_Host *shost,
2746 session->max_r2t = 1; 2769 session->max_r2t = 1;
2747 session->tt = iscsit; 2770 session->tt = iscsit;
2748 session->dd_data = cls_session->dd_data + sizeof(*session); 2771 session->dd_data = cls_session->dd_data + sizeof(*session);
2772
2749 mutex_init(&session->eh_mutex); 2773 mutex_init(&session->eh_mutex);
2750 spin_lock_init(&session->lock); 2774 spin_lock_init(&session->frwd_lock);
2775 spin_lock_init(&session->back_lock);
2751 2776
2752 /* initialize SCSI PDU commands pool */ 2777 /* initialize SCSI PDU commands pool */
2753 if (iscsi_pool_init(&session->cmdpool, session->cmds_max, 2778 if (iscsi_pool_init(&session->cmdpool, session->cmds_max,
@@ -2861,14 +2886,14 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size,
2861 INIT_WORK(&conn->xmitwork, iscsi_xmitworker); 2886 INIT_WORK(&conn->xmitwork, iscsi_xmitworker);
2862 2887
2863 /* allocate login_task used for the login/text sequences */ 2888 /* allocate login_task used for the login/text sequences */
2864 spin_lock_bh(&session->lock); 2889 spin_lock_bh(&session->frwd_lock);
2865 if (!kfifo_out(&session->cmdpool.queue, 2890 if (!kfifo_out(&session->cmdpool.queue,
2866 (void*)&conn->login_task, 2891 (void*)&conn->login_task,
2867 sizeof(void*))) { 2892 sizeof(void*))) {
2868 spin_unlock_bh(&session->lock); 2893 spin_unlock_bh(&session->frwd_lock);
2869 goto login_task_alloc_fail; 2894 goto login_task_alloc_fail;
2870 } 2895 }
2871 spin_unlock_bh(&session->lock); 2896 spin_unlock_bh(&session->frwd_lock);
2872 2897
2873 data = (char *) __get_free_pages(GFP_KERNEL, 2898 data = (char *) __get_free_pages(GFP_KERNEL,
2874 get_order(ISCSI_DEF_MAX_RECV_SEG_LEN)); 2899 get_order(ISCSI_DEF_MAX_RECV_SEG_LEN));
@@ -2905,7 +2930,7 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
2905 2930
2906 del_timer_sync(&conn->transport_timer); 2931 del_timer_sync(&conn->transport_timer);
2907 2932
2908 spin_lock_bh(&session->lock); 2933 spin_lock_bh(&session->frwd_lock);
2909 conn->c_stage = ISCSI_CONN_CLEANUP_WAIT; 2934 conn->c_stage = ISCSI_CONN_CLEANUP_WAIT;
2910 if (session->leadconn == conn) { 2935 if (session->leadconn == conn) {
2911 /* 2936 /*
@@ -2914,7 +2939,7 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
2914 session->state = ISCSI_STATE_TERMINATE; 2939 session->state = ISCSI_STATE_TERMINATE;
2915 wake_up(&conn->ehwait); 2940 wake_up(&conn->ehwait);
2916 } 2941 }
2917 spin_unlock_bh(&session->lock); 2942 spin_unlock_bh(&session->frwd_lock);
2918 2943
2919 /* 2944 /*
2920 * Block until all in-progress commands for this connection 2945 * Block until all in-progress commands for this connection
@@ -2941,16 +2966,19 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
2941 /* flush queued up work because we free the connection below */ 2966 /* flush queued up work because we free the connection below */
2942 iscsi_suspend_tx(conn); 2967 iscsi_suspend_tx(conn);
2943 2968
2944 spin_lock_bh(&session->lock); 2969 spin_lock_bh(&session->frwd_lock);
2945 free_pages((unsigned long) conn->data, 2970 free_pages((unsigned long) conn->data,
2946 get_order(ISCSI_DEF_MAX_RECV_SEG_LEN)); 2971 get_order(ISCSI_DEF_MAX_RECV_SEG_LEN));
2947 kfree(conn->persistent_address); 2972 kfree(conn->persistent_address);
2948 kfree(conn->local_ipaddr); 2973 kfree(conn->local_ipaddr);
2974 /* regular RX path uses back_lock */
2975 spin_lock_bh(&session->back_lock);
2949 kfifo_in(&session->cmdpool.queue, (void*)&conn->login_task, 2976 kfifo_in(&session->cmdpool.queue, (void*)&conn->login_task,
2950 sizeof(void*)); 2977 sizeof(void*));
2978 spin_unlock_bh(&session->back_lock);
2951 if (session->leadconn == conn) 2979 if (session->leadconn == conn)
2952 session->leadconn = NULL; 2980 session->leadconn = NULL;
2953 spin_unlock_bh(&session->lock); 2981 spin_unlock_bh(&session->frwd_lock);
2954 2982
2955 iscsi_destroy_conn(cls_conn); 2983 iscsi_destroy_conn(cls_conn);
2956} 2984}
@@ -2987,7 +3015,7 @@ int iscsi_conn_start(struct iscsi_cls_conn *cls_conn)
2987 conn->ping_timeout = 5; 3015 conn->ping_timeout = 5;
2988 } 3016 }
2989 3017
2990 spin_lock_bh(&session->lock); 3018 spin_lock_bh(&session->frwd_lock);
2991 conn->c_stage = ISCSI_CONN_STARTED; 3019 conn->c_stage = ISCSI_CONN_STARTED;
2992 session->state = ISCSI_STATE_LOGGED_IN; 3020 session->state = ISCSI_STATE_LOGGED_IN;
2993 session->queued_cmdsn = session->cmdsn; 3021 session->queued_cmdsn = session->cmdsn;
@@ -3016,7 +3044,7 @@ int iscsi_conn_start(struct iscsi_cls_conn *cls_conn)
3016 default: 3044 default:
3017 break; 3045 break;
3018 } 3046 }
3019 spin_unlock_bh(&session->lock); 3047 spin_unlock_bh(&session->frwd_lock);
3020 3048
3021 iscsi_unblock_session(session->cls_session); 3049 iscsi_unblock_session(session->cls_session);
3022 wake_up(&conn->ehwait); 3050 wake_up(&conn->ehwait);
@@ -3055,9 +3083,9 @@ static void iscsi_start_session_recovery(struct iscsi_session *session,
3055 int old_stop_stage; 3083 int old_stop_stage;
3056 3084
3057 mutex_lock(&session->eh_mutex); 3085 mutex_lock(&session->eh_mutex);
3058 spin_lock_bh(&session->lock); 3086 spin_lock_bh(&session->frwd_lock);
3059 if (conn->stop_stage == STOP_CONN_TERM) { 3087 if (conn->stop_stage == STOP_CONN_TERM) {
3060 spin_unlock_bh(&session->lock); 3088 spin_unlock_bh(&session->frwd_lock);
3061 mutex_unlock(&session->eh_mutex); 3089 mutex_unlock(&session->eh_mutex);
3062 return; 3090 return;
3063 } 3091 }
@@ -3074,14 +3102,14 @@ static void iscsi_start_session_recovery(struct iscsi_session *session,
3074 3102
3075 old_stop_stage = conn->stop_stage; 3103 old_stop_stage = conn->stop_stage;
3076 conn->stop_stage = flag; 3104 conn->stop_stage = flag;
3077 spin_unlock_bh(&session->lock); 3105 spin_unlock_bh(&session->frwd_lock);
3078 3106
3079 del_timer_sync(&conn->transport_timer); 3107 del_timer_sync(&conn->transport_timer);
3080 iscsi_suspend_tx(conn); 3108 iscsi_suspend_tx(conn);
3081 3109
3082 spin_lock_bh(&session->lock); 3110 spin_lock_bh(&session->frwd_lock);
3083 conn->c_stage = ISCSI_CONN_STOPPED; 3111 conn->c_stage = ISCSI_CONN_STOPPED;
3084 spin_unlock_bh(&session->lock); 3112 spin_unlock_bh(&session->frwd_lock);
3085 3113
3086 /* 3114 /*
3087 * for connection level recovery we should not calculate 3115 * for connection level recovery we should not calculate
@@ -3102,11 +3130,11 @@ static void iscsi_start_session_recovery(struct iscsi_session *session,
3102 /* 3130 /*
3103 * flush queues. 3131 * flush queues.
3104 */ 3132 */
3105 spin_lock_bh(&session->lock); 3133 spin_lock_bh(&session->frwd_lock);
3106 fail_scsi_tasks(conn, -1, DID_TRANSPORT_DISRUPTED); 3134 fail_scsi_tasks(conn, -1, DID_TRANSPORT_DISRUPTED);
3107 fail_mgmt_tasks(session, conn); 3135 fail_mgmt_tasks(session, conn);
3108 memset(&conn->tmhdr, 0, sizeof(conn->tmhdr)); 3136 memset(&conn->tmhdr, 0, sizeof(conn->tmhdr));
3109 spin_unlock_bh(&session->lock); 3137 spin_unlock_bh(&session->frwd_lock);
3110 mutex_unlock(&session->eh_mutex); 3138 mutex_unlock(&session->eh_mutex);
3111} 3139}
3112 3140
@@ -3133,10 +3161,10 @@ int iscsi_conn_bind(struct iscsi_cls_session *cls_session,
3133 struct iscsi_session *session = cls_session->dd_data; 3161 struct iscsi_session *session = cls_session->dd_data;
3134 struct iscsi_conn *conn = cls_conn->dd_data; 3162 struct iscsi_conn *conn = cls_conn->dd_data;
3135 3163
3136 spin_lock_bh(&session->lock); 3164 spin_lock_bh(&session->frwd_lock);
3137 if (is_leading) 3165 if (is_leading)
3138 session->leadconn = conn; 3166 session->leadconn = conn;
3139 spin_unlock_bh(&session->lock); 3167 spin_unlock_bh(&session->frwd_lock);
3140 3168
3141 /* 3169 /*
3142 * Unblock xmitworker(), Login Phase will pass through. 3170 * Unblock xmitworker(), Login Phase will pass through.
diff --git a/drivers/scsi/libiscsi_tcp.c b/drivers/scsi/libiscsi_tcp.c
index 2f738dddd078..60cb6dc3c6f0 100644
--- a/drivers/scsi/libiscsi_tcp.c
+++ b/drivers/scsi/libiscsi_tcp.c
@@ -446,7 +446,7 @@ iscsi_tcp_data_recv_prep(struct iscsi_tcp_conn *tcp_conn)
446 * iscsi_tcp_cleanup_task - free tcp_task resources 446 * iscsi_tcp_cleanup_task - free tcp_task resources
447 * @task: iscsi task 447 * @task: iscsi task
448 * 448 *
449 * must be called with session lock 449 * must be called with session back_lock
450 */ 450 */
451void iscsi_tcp_cleanup_task(struct iscsi_task *task) 451void iscsi_tcp_cleanup_task(struct iscsi_task *task)
452{ 452{
@@ -457,6 +457,7 @@ void iscsi_tcp_cleanup_task(struct iscsi_task *task)
457 if (!task->sc) 457 if (!task->sc)
458 return; 458 return;
459 459
460 spin_lock_bh(&tcp_task->queue2pool);
460 /* flush task's r2t queues */ 461 /* flush task's r2t queues */
461 while (kfifo_out(&tcp_task->r2tqueue, (void*)&r2t, sizeof(void*))) { 462 while (kfifo_out(&tcp_task->r2tqueue, (void*)&r2t, sizeof(void*))) {
462 kfifo_in(&tcp_task->r2tpool.queue, (void*)&r2t, 463 kfifo_in(&tcp_task->r2tpool.queue, (void*)&r2t,
@@ -470,6 +471,7 @@ void iscsi_tcp_cleanup_task(struct iscsi_task *task)
470 sizeof(void*)); 471 sizeof(void*));
471 tcp_task->r2t = NULL; 472 tcp_task->r2t = NULL;
472 } 473 }
474 spin_unlock_bh(&tcp_task->queue2pool);
473} 475}
474EXPORT_SYMBOL_GPL(iscsi_tcp_cleanup_task); 476EXPORT_SYMBOL_GPL(iscsi_tcp_cleanup_task);
475 477
@@ -577,11 +579,13 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task)
577 return ISCSI_ERR_DATALEN; 579 return ISCSI_ERR_DATALEN;
578 } 580 }
579 581
582 spin_lock(&tcp_task->pool2queue);
580 rc = kfifo_out(&tcp_task->r2tpool.queue, (void *)&r2t, sizeof(void *)); 583 rc = kfifo_out(&tcp_task->r2tpool.queue, (void *)&r2t, sizeof(void *));
581 if (!rc) { 584 if (!rc) {
582 iscsi_conn_printk(KERN_ERR, conn, "Could not allocate R2T. " 585 iscsi_conn_printk(KERN_ERR, conn, "Could not allocate R2T. "
583 "Target has sent more R2Ts than it " 586 "Target has sent more R2Ts than it "
584 "negotiated for or driver has leaked.\n"); 587 "negotiated for or driver has leaked.\n");
588 spin_unlock(&tcp_task->pool2queue);
585 return ISCSI_ERR_PROTO; 589 return ISCSI_ERR_PROTO;
586 } 590 }
587 591
@@ -596,6 +600,7 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task)
596 tcp_task->exp_datasn = r2tsn + 1; 600 tcp_task->exp_datasn = r2tsn + 1;
597 kfifo_in(&tcp_task->r2tqueue, (void*)&r2t, sizeof(void*)); 601 kfifo_in(&tcp_task->r2tqueue, (void*)&r2t, sizeof(void*));
598 conn->r2t_pdus_cnt++; 602 conn->r2t_pdus_cnt++;
603 spin_unlock(&tcp_task->pool2queue);
599 604
600 iscsi_requeue_task(task); 605 iscsi_requeue_task(task);
601 return 0; 606 return 0;
@@ -668,14 +673,14 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr)
668 673
669 switch(opcode) { 674 switch(opcode) {
670 case ISCSI_OP_SCSI_DATA_IN: 675 case ISCSI_OP_SCSI_DATA_IN:
671 spin_lock(&conn->session->lock); 676 spin_lock(&conn->session->back_lock);
672 task = iscsi_itt_to_ctask(conn, hdr->itt); 677 task = iscsi_itt_to_ctask(conn, hdr->itt);
673 if (!task) 678 if (!task)
674 rc = ISCSI_ERR_BAD_ITT; 679 rc = ISCSI_ERR_BAD_ITT;
675 else 680 else
676 rc = iscsi_tcp_data_in(conn, task); 681 rc = iscsi_tcp_data_in(conn, task);
677 if (rc) { 682 if (rc) {
678 spin_unlock(&conn->session->lock); 683 spin_unlock(&conn->session->back_lock);
679 break; 684 break;
680 } 685 }
681 686
@@ -708,11 +713,11 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr)
708 tcp_conn->in.datalen, 713 tcp_conn->in.datalen,
709 iscsi_tcp_process_data_in, 714 iscsi_tcp_process_data_in,
710 rx_hash); 715 rx_hash);
711 spin_unlock(&conn->session->lock); 716 spin_unlock(&conn->session->back_lock);
712 return rc; 717 return rc;
713 } 718 }
714 rc = __iscsi_complete_pdu(conn, hdr, NULL, 0); 719 rc = __iscsi_complete_pdu(conn, hdr, NULL, 0);
715 spin_unlock(&conn->session->lock); 720 spin_unlock(&conn->session->back_lock);
716 break; 721 break;
717 case ISCSI_OP_SCSI_CMD_RSP: 722 case ISCSI_OP_SCSI_CMD_RSP:
718 if (tcp_conn->in.datalen) { 723 if (tcp_conn->in.datalen) {
@@ -722,18 +727,20 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr)
722 rc = iscsi_complete_pdu(conn, hdr, NULL, 0); 727 rc = iscsi_complete_pdu(conn, hdr, NULL, 0);
723 break; 728 break;
724 case ISCSI_OP_R2T: 729 case ISCSI_OP_R2T:
725 spin_lock(&conn->session->lock); 730 spin_lock(&conn->session->back_lock);
726 task = iscsi_itt_to_ctask(conn, hdr->itt); 731 task = iscsi_itt_to_ctask(conn, hdr->itt);
732 spin_unlock(&conn->session->back_lock);
727 if (!task) 733 if (!task)
728 rc = ISCSI_ERR_BAD_ITT; 734 rc = ISCSI_ERR_BAD_ITT;
729 else if (ahslen) 735 else if (ahslen)
730 rc = ISCSI_ERR_AHSLEN; 736 rc = ISCSI_ERR_AHSLEN;
731 else if (task->sc->sc_data_direction == DMA_TO_DEVICE) { 737 else if (task->sc->sc_data_direction == DMA_TO_DEVICE) {
732 task->last_xfer = jiffies; 738 task->last_xfer = jiffies;
739 spin_lock(&conn->session->frwd_lock);
733 rc = iscsi_tcp_r2t_rsp(conn, task); 740 rc = iscsi_tcp_r2t_rsp(conn, task);
741 spin_unlock(&conn->session->frwd_lock);
734 } else 742 } else
735 rc = ISCSI_ERR_PROTO; 743 rc = ISCSI_ERR_PROTO;
736 spin_unlock(&conn->session->lock);
737 break; 744 break;
738 case ISCSI_OP_LOGIN_RSP: 745 case ISCSI_OP_LOGIN_RSP:
739 case ISCSI_OP_TEXT_RSP: 746 case ISCSI_OP_TEXT_RSP:
@@ -981,14 +988,13 @@ EXPORT_SYMBOL_GPL(iscsi_tcp_task_init);
981 988
982static struct iscsi_r2t_info *iscsi_tcp_get_curr_r2t(struct iscsi_task *task) 989static struct iscsi_r2t_info *iscsi_tcp_get_curr_r2t(struct iscsi_task *task)
983{ 990{
984 struct iscsi_session *session = task->conn->session;
985 struct iscsi_tcp_task *tcp_task = task->dd_data; 991 struct iscsi_tcp_task *tcp_task = task->dd_data;
986 struct iscsi_r2t_info *r2t = NULL; 992 struct iscsi_r2t_info *r2t = NULL;
987 993
988 if (iscsi_task_has_unsol_data(task)) 994 if (iscsi_task_has_unsol_data(task))
989 r2t = &task->unsol_r2t; 995 r2t = &task->unsol_r2t;
990 else { 996 else {
991 spin_lock_bh(&session->lock); 997 spin_lock_bh(&tcp_task->queue2pool);
992 if (tcp_task->r2t) { 998 if (tcp_task->r2t) {
993 r2t = tcp_task->r2t; 999 r2t = tcp_task->r2t;
994 /* Continue with this R2T? */ 1000 /* Continue with this R2T? */
@@ -1010,7 +1016,7 @@ static struct iscsi_r2t_info *iscsi_tcp_get_curr_r2t(struct iscsi_task *task)
1010 else 1016 else
1011 r2t = tcp_task->r2t; 1017 r2t = tcp_task->r2t;
1012 } 1018 }
1013 spin_unlock_bh(&session->lock); 1019 spin_unlock_bh(&tcp_task->queue2pool);
1014 } 1020 }
1015 1021
1016 return r2t; 1022 return r2t;
@@ -1140,6 +1146,8 @@ int iscsi_tcp_r2tpool_alloc(struct iscsi_session *session)
1140 iscsi_pool_free(&tcp_task->r2tpool); 1146 iscsi_pool_free(&tcp_task->r2tpool);
1141 goto r2t_alloc_fail; 1147 goto r2t_alloc_fail;
1142 } 1148 }
1149 spin_lock_init(&tcp_task->pool2queue);
1150 spin_lock_init(&tcp_task->queue2pool);
1143 } 1151 }
1144 1152
1145 return 0; 1153 return 0;
diff --git a/drivers/scsi/qla4xxx/ql4_isr.c b/drivers/scsi/qla4xxx/ql4_isr.c
index bb34ef82b1d4..b1925d195f41 100644
--- a/drivers/scsi/qla4xxx/ql4_isr.c
+++ b/drivers/scsi/qla4xxx/ql4_isr.c
@@ -385,9 +385,9 @@ static void qla4xxx_passthru_status_entry(struct scsi_qla_host *ha,
385 385
386 cls_conn = ddb_entry->conn; 386 cls_conn = ddb_entry->conn;
387 conn = cls_conn->dd_data; 387 conn = cls_conn->dd_data;
388 spin_lock(&conn->session->lock); 388 spin_lock(&conn->session->back_lock);
389 task = iscsi_itt_to_task(conn, itt); 389 task = iscsi_itt_to_task(conn, itt);
390 spin_unlock(&conn->session->lock); 390 spin_unlock(&conn->session->back_lock);
391 391
392 if (task == NULL) { 392 if (task == NULL) {
393 ql4_printk(KERN_ERR, ha, "%s: Task is NULL\n", __func__); 393 ql4_printk(KERN_ERR, ha, "%s: Task is NULL\n", __func__);
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index 309f51336fb9..7221a24e821b 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -327,12 +327,19 @@ struct iscsi_session {
327 struct iscsi_transport *tt; 327 struct iscsi_transport *tt;
328 struct Scsi_Host *host; 328 struct Scsi_Host *host;
329 struct iscsi_conn *leadconn; /* leading connection */ 329 struct iscsi_conn *leadconn; /* leading connection */
330 spinlock_t lock; /* protects session state, * 330 /* Between the forward and the backward locks exists a strict locking
331 * sequence numbers, * 331 * hierarchy. The mutual exclusion zone protected by the forward lock
332 * can enclose the mutual exclusion zone protected by the backward lock
333 * but not vice versa.
334 */
335 spinlock_t frwd_lock; /* protects session state, *
336 * cmdsn, queued_cmdsn *
332 * session resources: * 337 * session resources: *
333 * - cmdpool, * 338 * - cmdpool kfifo_out , *
334 * - mgmtpool, * 339 * - mgmtpool, */
335 * - r2tpool */ 340 spinlock_t back_lock; /* protects cmdsn_exp *
341 * cmdsn_max, *
342 * cmdpool kfifo_in */
336 int state; /* session state */ 343 int state; /* session state */
337 int age; /* counts session re-opens */ 344 int age; /* counts session re-opens */
338 345
diff --git a/include/scsi/libiscsi_tcp.h b/include/scsi/libiscsi_tcp.h
index 215469a9b801..2a7aa75dd009 100644
--- a/include/scsi/libiscsi_tcp.h
+++ b/include/scsi/libiscsi_tcp.h
@@ -83,6 +83,8 @@ struct iscsi_tcp_task {
83 struct iscsi_pool r2tpool; 83 struct iscsi_pool r2tpool;
84 struct kfifo r2tqueue; 84 struct kfifo r2tqueue;
85 void *dd_data; 85 void *dd_data;
86 spinlock_t pool2queue;
87 spinlock_t queue2pool;
86}; 88};
87 89
88enum { 90enum {