@@ -34,12 +34,6 @@ __read_mostly unsigned int rxrpc_reap_client_connections = 900;
34
34
__read_mostly unsigned long rxrpc_conn_idle_client_expiry = 2 * 60 * HZ ;
35
35
__read_mostly unsigned long rxrpc_conn_idle_client_fast_expiry = 2 * HZ ;
36
36
37
- /*
38
- * We use machine-unique IDs for our client connections.
39
- */
40
- DEFINE_IDR (rxrpc_client_conn_ids );
41
- static DEFINE_SPINLOCK (rxrpc_conn_id_lock );
42
-
43
37
static void rxrpc_deactivate_bundle (struct rxrpc_bundle * bundle );
44
38
45
39
/*
@@ -51,65 +45,65 @@ static void rxrpc_deactivate_bundle(struct rxrpc_bundle *bundle);
51
45
static int rxrpc_get_client_connection_id (struct rxrpc_connection * conn ,
52
46
gfp_t gfp )
53
47
{
54
- struct rxrpc_net * rxnet = conn -> rxnet ;
48
+ struct rxrpc_local * local = conn -> local ;
55
49
int id ;
56
50
57
51
_enter ("" );
58
52
59
53
idr_preload (gfp );
60
- spin_lock (& rxrpc_conn_id_lock );
54
+ spin_lock (& local -> conn_lock );
61
55
62
- id = idr_alloc_cyclic (& rxrpc_client_conn_ids , conn ,
56
+ id = idr_alloc_cyclic (& local -> conn_ids , conn ,
63
57
1 , 0x40000000 , GFP_NOWAIT );
64
58
if (id < 0 )
65
59
goto error ;
66
60
67
- spin_unlock (& rxrpc_conn_id_lock );
61
+ spin_unlock (& local -> conn_lock );
68
62
idr_preload_end ();
69
63
70
- conn -> proto .epoch = rxnet -> epoch ;
64
+ conn -> proto .epoch = local -> rxnet -> epoch ;
71
65
conn -> proto .cid = id << RXRPC_CIDSHIFT ;
72
66
set_bit (RXRPC_CONN_HAS_IDR , & conn -> flags );
73
67
_leave (" [CID %x]" , conn -> proto .cid );
74
68
return 0 ;
75
69
76
70
error :
77
- spin_unlock (& rxrpc_conn_id_lock );
71
+ spin_unlock (& local -> conn_lock );
78
72
idr_preload_end ();
79
73
_leave (" = %d" , id );
80
74
return id ;
81
75
}
82
76
83
77
/*
84
- * Release a connection ID for a client connection from the global pool .
78
+ * Release a connection ID for a client connection.
85
79
*/
86
- static void rxrpc_put_client_connection_id (struct rxrpc_connection * conn )
80
+ static void rxrpc_put_client_connection_id (struct rxrpc_local * local ,
81
+ struct rxrpc_connection * conn )
87
82
{
88
83
if (test_bit (RXRPC_CONN_HAS_IDR , & conn -> flags )) {
89
- spin_lock (& rxrpc_conn_id_lock );
90
- idr_remove (& rxrpc_client_conn_ids ,
91
- conn -> proto .cid >> RXRPC_CIDSHIFT );
92
- spin_unlock (& rxrpc_conn_id_lock );
84
+ spin_lock (& local -> conn_lock );
85
+ idr_remove (& local -> conn_ids , conn -> proto .cid >> RXRPC_CIDSHIFT );
86
+ spin_unlock (& local -> conn_lock );
93
87
}
94
88
}
95
89
96
90
/*
97
91
* Destroy the client connection ID tree.
98
92
*/
99
- void rxrpc_destroy_client_conn_ids (void )
93
+ void rxrpc_destroy_client_conn_ids (struct rxrpc_local * local )
100
94
{
101
95
struct rxrpc_connection * conn ;
102
96
int id ;
103
97
104
- if (!idr_is_empty (& rxrpc_client_conn_ids )) {
105
- idr_for_each_entry (& rxrpc_client_conn_ids , conn , id ) {
98
+ if (!idr_is_empty (& local -> conn_ids )) {
99
+ idr_for_each_entry (& local -> conn_ids , conn , id ) {
106
100
pr_err ("AF_RXRPC: Leaked client conn %p {%d}\n" ,
107
101
conn , refcount_read (& conn -> ref ));
108
102
}
109
103
BUG ();
110
104
}
111
105
112
- idr_destroy (& rxrpc_client_conn_ids );
106
+ idr_destroy (& local -> conn_ids );
113
107
}
114
108
115
109
/*
@@ -225,7 +219,7 @@ rxrpc_alloc_client_connection(struct rxrpc_bundle *bundle, gfp_t gfp)
225
219
return conn ;
226
220
227
221
error_1 :
228
- rxrpc_put_client_connection_id (conn );
222
+ rxrpc_put_client_connection_id (bundle -> local , conn );
229
223
error_0 :
230
224
kfree (conn );
231
225
_leave (" = %d" , ret );
@@ -257,7 +251,7 @@ static bool rxrpc_may_reuse_conn(struct rxrpc_connection *conn)
257
251
* times the maximum number of client conns away from the current
258
252
* allocation point to try and keep the IDs concentrated.
259
253
*/
260
- id_cursor = idr_get_cursor (& rxrpc_client_conn_ids );
254
+ id_cursor = idr_get_cursor (& conn -> local -> conn_ids );
261
255
id = conn -> proto .cid >> RXRPC_CIDSHIFT ;
262
256
distance = id - id_cursor ;
263
257
if (distance < 0 )
@@ -982,7 +976,7 @@ void rxrpc_kill_client_conn(struct rxrpc_connection *conn)
982
976
trace_rxrpc_client (conn , -1 , rxrpc_client_cleanup );
983
977
atomic_dec (& rxnet -> nr_client_conns );
984
978
985
- rxrpc_put_client_connection_id (conn );
979
+ rxrpc_put_client_connection_id (local , conn );
986
980
}
987
981
988
982
/*
0 commit comments