@@ -492,8 +492,8 @@ isert_connect_request(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
492
492
isert_conn -> state = ISER_CONN_INIT ;
493
493
INIT_LIST_HEAD (& isert_conn -> conn_accept_node );
494
494
init_completion (& isert_conn -> conn_login_comp );
495
- init_waitqueue_head (& isert_conn -> conn_wait );
496
- init_waitqueue_head (& isert_conn -> conn_wait_comp_err );
495
+ init_completion (& isert_conn -> conn_wait );
496
+ init_completion (& isert_conn -> conn_wait_comp_err );
497
497
kref_init (& isert_conn -> conn_kref );
498
498
kref_get (& isert_conn -> conn_kref );
499
499
mutex_init (& isert_conn -> conn_mutex );
@@ -688,11 +688,11 @@ isert_disconnect_work(struct work_struct *work)
688
688
689
689
pr_debug ("isert_disconnect_work(): >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" );
690
690
mutex_lock (& isert_conn -> conn_mutex );
691
- isert_conn -> state = ISER_CONN_DOWN ;
691
+ if (isert_conn -> state == ISER_CONN_UP )
692
+ isert_conn -> state = ISER_CONN_TERMINATING ;
692
693
693
694
if (isert_conn -> post_recv_buf_count == 0 &&
694
695
atomic_read (& isert_conn -> post_send_buf_count ) == 0 ) {
695
- pr_debug ("Calling wake_up(&isert_conn->conn_wait);\n" );
696
696
mutex_unlock (& isert_conn -> conn_mutex );
697
697
goto wake_up ;
698
698
}
@@ -712,7 +712,7 @@ isert_disconnect_work(struct work_struct *work)
712
712
mutex_unlock (& isert_conn -> conn_mutex );
713
713
714
714
wake_up :
715
- wake_up (& isert_conn -> conn_wait );
715
+ complete (& isert_conn -> conn_wait );
716
716
isert_put_conn (isert_conn );
717
717
}
718
718
@@ -1589,7 +1589,7 @@ isert_do_control_comp(struct work_struct *work)
1589
1589
pr_debug ("Calling iscsit_logout_post_handler >>>>>>>>>>>>>>\n" );
1590
1590
/*
1591
1591
* Call atomic_dec(&isert_conn->post_send_buf_count)
1592
- * from isert_free_conn ()
1592
+ * from isert_wait_conn ()
1593
1593
*/
1594
1594
isert_conn -> logout_posted = true;
1595
1595
iscsit_logout_post_handler (cmd , cmd -> conn );
@@ -1691,31 +1691,39 @@ isert_send_completion(struct iser_tx_desc *tx_desc,
1691
1691
}
1692
1692
1693
1693
static void
1694
- isert_cq_comp_err (struct iser_tx_desc * tx_desc , struct isert_conn * isert_conn )
1694
+ isert_cq_tx_comp_err (struct iser_tx_desc * tx_desc , struct isert_conn * isert_conn )
1695
1695
{
1696
1696
struct ib_device * ib_dev = isert_conn -> conn_cm_id -> device ;
1697
+ struct isert_cmd * isert_cmd = tx_desc -> isert_cmd ;
1698
+
1699
+ if (!isert_cmd )
1700
+ isert_unmap_tx_desc (tx_desc , ib_dev );
1701
+ else
1702
+ isert_completion_put (tx_desc , isert_cmd , ib_dev );
1703
+ }
1704
+
1705
+ static void
1706
+ isert_cq_rx_comp_err (struct isert_conn * isert_conn )
1707
+ {
1708
+ struct ib_device * ib_dev = isert_conn -> conn_cm_id -> device ;
1709
+ struct iscsi_conn * conn = isert_conn -> conn ;
1697
1710
1698
- if (tx_desc ) {
1699
- struct isert_cmd * isert_cmd = tx_desc -> isert_cmd ;
1711
+ if (isert_conn -> post_recv_buf_count )
1712
+ return ;
1700
1713
1701
- if (!isert_cmd )
1702
- isert_unmap_tx_desc (tx_desc , ib_dev );
1703
- else
1704
- isert_completion_put (tx_desc , isert_cmd , ib_dev );
1714
+ if (conn -> sess ) {
1715
+ target_sess_cmd_list_set_waiting (conn -> sess -> se_sess );
1716
+ target_wait_for_sess_cmds (conn -> sess -> se_sess );
1705
1717
}
1706
1718
1707
- if (isert_conn -> post_recv_buf_count == 0 &&
1708
- atomic_read (& isert_conn -> post_send_buf_count ) == 0 ) {
1709
- pr_debug ("isert_cq_comp_err >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" );
1710
- pr_debug ("Calling wake_up from isert_cq_comp_err\n" );
1719
+ while (atomic_read (& isert_conn -> post_send_buf_count ))
1720
+ msleep (3000 );
1711
1721
1712
- mutex_lock (& isert_conn -> conn_mutex );
1713
- if (isert_conn -> state != ISER_CONN_DOWN )
1714
- isert_conn -> state = ISER_CONN_TERMINATING ;
1715
- mutex_unlock (& isert_conn -> conn_mutex );
1722
+ mutex_lock (& isert_conn -> conn_mutex );
1723
+ isert_conn -> state = ISER_CONN_DOWN ;
1724
+ mutex_unlock (& isert_conn -> conn_mutex );
1716
1725
1717
- wake_up (& isert_conn -> conn_wait_comp_err );
1718
- }
1726
+ complete (& isert_conn -> conn_wait_comp_err );
1719
1727
}
1720
1728
1721
1729
static void
@@ -1740,8 +1748,9 @@ isert_cq_tx_work(struct work_struct *work)
1740
1748
pr_debug ("TX wc.status != IB_WC_SUCCESS >>>>>>>>>>>>>>\n" );
1741
1749
pr_debug ("TX wc.status: 0x%08x\n" , wc .status );
1742
1750
pr_debug ("TX wc.vendor_err: 0x%08x\n" , wc .vendor_err );
1751
+
1743
1752
atomic_dec (& isert_conn -> post_send_buf_count );
1744
- isert_cq_comp_err (tx_desc , isert_conn );
1753
+ isert_cq_tx_comp_err (tx_desc , isert_conn );
1745
1754
}
1746
1755
}
1747
1756
@@ -1784,7 +1793,7 @@ isert_cq_rx_work(struct work_struct *work)
1784
1793
wc .vendor_err );
1785
1794
}
1786
1795
isert_conn -> post_recv_buf_count -- ;
1787
- isert_cq_comp_err ( NULL , isert_conn );
1796
+ isert_cq_rx_comp_err ( isert_conn );
1788
1797
}
1789
1798
}
1790
1799
@@ -2702,22 +2711,11 @@ isert_free_np(struct iscsi_np *np)
2702
2711
kfree (isert_np );
2703
2712
}
2704
2713
2705
- static int isert_check_state (struct isert_conn * isert_conn , int state )
2706
- {
2707
- int ret ;
2708
-
2709
- mutex_lock (& isert_conn -> conn_mutex );
2710
- ret = (isert_conn -> state == state );
2711
- mutex_unlock (& isert_conn -> conn_mutex );
2712
-
2713
- return ret ;
2714
- }
2715
-
2716
- static void isert_free_conn (struct iscsi_conn * conn )
2714
+ static void isert_wait_conn (struct iscsi_conn * conn )
2717
2715
{
2718
2716
struct isert_conn * isert_conn = conn -> context ;
2719
2717
2720
- pr_debug ("isert_free_conn : Starting \n" );
2718
+ pr_debug ("isert_wait_conn : Starting \n" );
2721
2719
/*
2722
2720
* Decrement post_send_buf_count for special case when called
2723
2721
* from isert_do_control_comp() -> iscsit_logout_post_handler()
@@ -2727,38 +2725,29 @@ static void isert_free_conn(struct iscsi_conn *conn)
2727
2725
atomic_dec (& isert_conn -> post_send_buf_count );
2728
2726
2729
2727
if (isert_conn -> conn_cm_id && isert_conn -> state != ISER_CONN_DOWN ) {
2730
- pr_debug ("Calling rdma_disconnect from isert_free_conn \n" );
2728
+ pr_debug ("Calling rdma_disconnect from isert_wait_conn \n" );
2731
2729
rdma_disconnect (isert_conn -> conn_cm_id );
2732
2730
}
2733
2731
/*
2734
2732
* Only wait for conn_wait_comp_err if the isert_conn made it
2735
2733
* into full feature phase..
2736
2734
*/
2737
- if (isert_conn -> state == ISER_CONN_UP ) {
2738
- pr_debug ("isert_free_conn: Before wait_event comp_err %d\n" ,
2739
- isert_conn -> state );
2740
- mutex_unlock (& isert_conn -> conn_mutex );
2741
-
2742
- wait_event (isert_conn -> conn_wait_comp_err ,
2743
- (isert_check_state (isert_conn , ISER_CONN_TERMINATING )));
2744
-
2745
- wait_event (isert_conn -> conn_wait ,
2746
- (isert_check_state (isert_conn , ISER_CONN_DOWN )));
2747
-
2748
- isert_put_conn (isert_conn );
2749
- return ;
2750
- }
2751
2735
if (isert_conn -> state == ISER_CONN_INIT ) {
2752
2736
mutex_unlock (& isert_conn -> conn_mutex );
2753
- isert_put_conn (isert_conn );
2754
2737
return ;
2755
2738
}
2756
- pr_debug ( "isert_free_conn: wait_event conn_wait %d\n" ,
2757
- isert_conn -> state ) ;
2739
+ if ( isert_conn -> state == ISER_CONN_UP )
2740
+ isert_conn -> state = ISER_CONN_TERMINATING ;
2758
2741
mutex_unlock (& isert_conn -> conn_mutex );
2759
2742
2760
- wait_event (isert_conn -> conn_wait ,
2761
- (isert_check_state (isert_conn , ISER_CONN_DOWN )));
2743
+ wait_for_completion (& isert_conn -> conn_wait_comp_err );
2744
+
2745
+ wait_for_completion (& isert_conn -> conn_wait );
2746
+ }
2747
+
2748
+ static void isert_free_conn (struct iscsi_conn * conn )
2749
+ {
2750
+ struct isert_conn * isert_conn = conn -> context ;
2762
2751
2763
2752
isert_put_conn (isert_conn );
2764
2753
}
@@ -2771,6 +2760,7 @@ static struct iscsit_transport iser_target_transport = {
2771
2760
.iscsit_setup_np = isert_setup_np ,
2772
2761
.iscsit_accept_np = isert_accept_np ,
2773
2762
.iscsit_free_np = isert_free_np ,
2763
+ .iscsit_wait_conn = isert_wait_conn ,
2774
2764
.iscsit_free_conn = isert_free_conn ,
2775
2765
.iscsit_get_login_rx = isert_get_login_rx ,
2776
2766
.iscsit_put_login_tx = isert_put_login_tx ,
0 commit comments