@@ -1841,38 +1841,48 @@ static int srpt_disconnect_ch(struct srpt_rdma_ch *ch)
1841
1841
return ret ;
1842
1842
}
1843
1843
1844
+ static bool srpt_ch_closed (struct srpt_device * sdev , struct srpt_rdma_ch * ch )
1845
+ {
1846
+ struct srpt_rdma_ch * ch2 ;
1847
+ bool res = true;
1848
+
1849
+ rcu_read_lock ();
1850
+ list_for_each_entry (ch2 , & sdev -> rch_list , list ) {
1851
+ if (ch2 == ch ) {
1852
+ res = false;
1853
+ break ;
1854
+ }
1855
+ }
1856
+ rcu_read_unlock ();
1857
+
1858
+ return res ;
1859
+ }
1860
+
1844
1861
/*
1845
1862
* Send DREQ and wait for DREP. Return true if and only if this function
1846
1863
* changed the state of @ch.
1847
1864
*/
1848
1865
static bool srpt_disconnect_ch_sync (struct srpt_rdma_ch * ch )
1849
1866
__must_hold (& sdev - > mutex )
1850
1867
{
1851
- DECLARE_COMPLETION_ONSTACK (release_done );
1852
1868
struct srpt_device * sdev = ch -> sport -> sdev ;
1853
- bool wait ;
1869
+ int ret ;
1854
1870
1855
1871
lockdep_assert_held (& sdev -> mutex );
1856
1872
1857
1873
pr_debug ("ch %s-%d state %d\n" , ch -> sess_name , ch -> qp -> qp_num ,
1858
1874
ch -> state );
1859
1875
1860
- WARN_ON (ch -> release_done );
1861
- ch -> release_done = & release_done ;
1862
- wait = !list_empty (& ch -> list );
1863
- srpt_disconnect_ch (ch );
1876
+ ret = srpt_disconnect_ch (ch );
1864
1877
mutex_unlock (& sdev -> mutex );
1865
1878
1866
- if (!wait )
1867
- goto out ;
1868
-
1869
- while (wait_for_completion_timeout (& release_done , 180 * HZ ) == 0 )
1879
+ while (wait_event_timeout (sdev -> ch_releaseQ , srpt_ch_closed (sdev , ch ),
1880
+ 5 * HZ ) == 0 )
1870
1881
pr_info ("%s(%s-%d state %d): still waiting ...\n" , __func__ ,
1871
1882
ch -> sess_name , ch -> qp -> qp_num , ch -> state );
1872
1883
1873
- out :
1874
1884
mutex_lock (& sdev -> mutex );
1875
- return wait ;
1885
+ return ret == 0 ;
1876
1886
}
1877
1887
1878
1888
static void srpt_set_enabled (struct srpt_port * sport , bool enabled )
@@ -1916,8 +1926,7 @@ static void srpt_release_channel_work(struct work_struct *w)
1916
1926
struct se_session * se_sess ;
1917
1927
1918
1928
ch = container_of (w , struct srpt_rdma_ch , release_work );
1919
- pr_debug ("%s: %s-%d; release_done = %p\n" , __func__ , ch -> sess_name ,
1920
- ch -> qp -> qp_num , ch -> release_done );
1929
+ pr_debug ("%s-%d\n" , ch -> sess_name , ch -> qp -> qp_num );
1921
1930
1922
1931
sdev = ch -> sport -> sdev ;
1923
1932
BUG_ON (!sdev );
@@ -1946,14 +1955,6 @@ static void srpt_release_channel_work(struct work_struct *w)
1946
1955
1947
1956
mutex_lock (& sdev -> mutex );
1948
1957
list_del_rcu (& ch -> list );
1949
- if (ch -> release_done )
1950
- complete (ch -> release_done );
1951
- mutex_unlock (& sdev -> mutex );
1952
-
1953
- synchronize_rcu ();
1954
-
1955
- mutex_lock (& sdev -> mutex );
1956
- INIT_LIST_HEAD (& ch -> list );
1957
1958
mutex_unlock (& sdev -> mutex );
1958
1959
1959
1960
wake_up (& sdev -> ch_releaseQ );
0 commit comments