blob: f5ee8bfa5bef4d153c25b1f6c99f15bdf9a0e57a [file] [log] [blame]
David Howells4a3388c2016-04-04 14:00:37 +01001/* Client connection-specific management code.
2 *
3 * Copyright (C) 2016 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
David Howells45025bc2016-08-24 07:30:52 +010010 *
11 *
12 * Client connections need to be cached for a little while after they've made a
13 * call so as to handle retransmitted DATA packets in case the server didn't
14 * receive the final ACK or terminating ABORT we sent it.
15 *
16 * Client connections can be in one of a number of cache states:
17 *
18 * (1) INACTIVE - The connection is not held in any list and may not have been
19 * exposed to the world. If it has been previously exposed, it was
20 * discarded from the idle list after expiring.
21 *
22 * (2) WAITING - The connection is waiting for the number of client conns to
23 * drop below the maximum capacity. Calls may be in progress upon it from
24 * when it was active and got culled.
25 *
26 * The connection is on the rxrpc_waiting_client_conns list which is kept
27 * in to-be-granted order. Culled conns with waiters go to the back of
28 * the queue just like new conns.
29 *
30 * (3) ACTIVE - The connection has at least one call in progress upon it, it
31 * may freely grant available channels to new calls and calls may be
32 * waiting on it for channels to become available.
33 *
34 * The connection is on the rxrpc_active_client_conns list which is kept
35 * in activation order for culling purposes.
36 *
37 * rxrpc_nr_active_client_conns is held incremented also.
38 *
39 * (4) CULLED - The connection got summarily culled to try and free up
40 * capacity. Calls currently in progress on the connection are allowed to
41 * continue, but new calls will have to wait. There can be no waiters in
42 * this state - the conn would have to go to the WAITING state instead.
43 *
44 * (5) IDLE - The connection has no calls in progress upon it and must have
45 * been exposed to the world (ie. the EXPOSED flag must be set). When it
46 * expires, the EXPOSED flag is cleared and the connection transitions to
47 * the INACTIVE state.
48 *
49 * The connection is on the rxrpc_idle_client_conns list which is kept in
50 * order of how soon they'll expire.
51 *
52 * There are flags of relevance to the cache:
53 *
54 * (1) EXPOSED - The connection ID got exposed to the world. If this flag is
55 * set, an extra ref is added to the connection preventing it from being
56 * reaped when it has no calls outstanding. This flag is cleared and the
57 * ref dropped when a conn is discarded from the idle list.
58 *
59 * This allows us to move terminal call state retransmission to the
60 * connection and to discard the call immediately we think it is done
61 * with. It also give us a chance to reuse the connection.
62 *
63 * (2) DONT_REUSE - The connection should be discarded as soon as possible and
64 * should not be reused. This is set when an exclusive connection is used
65 * or a call ID counter overflows.
66 *
67 * The caching state may only be changed if the cache lock is held.
68 *
69 * There are two idle client connection expiry durations. If the total number
70 * of connections is below the reap threshold, we use the normal duration; if
71 * it's above, we use the fast duration.
David Howells4a3388c2016-04-04 14:00:37 +010072 */
73
74#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
75
76#include <linux/slab.h>
77#include <linux/idr.h>
78#include <linux/timer.h>
79#include "ar-internal.h"
80
David Howells45025bc2016-08-24 07:30:52 +010081__read_mostly unsigned int rxrpc_max_client_connections = 1000;
82__read_mostly unsigned int rxrpc_reap_client_connections = 900;
83__read_mostly unsigned int rxrpc_conn_idle_client_expiry = 2 * 60 * HZ;
84__read_mostly unsigned int rxrpc_conn_idle_client_fast_expiry = 2 * HZ;
85
86static unsigned int rxrpc_nr_client_conns;
87static unsigned int rxrpc_nr_active_client_conns;
88static __read_mostly bool rxrpc_kill_all_client_conns;
89
90static DEFINE_SPINLOCK(rxrpc_client_conn_cache_lock);
91static DEFINE_SPINLOCK(rxrpc_client_conn_discard_mutex);
92static LIST_HEAD(rxrpc_waiting_client_conns);
93static LIST_HEAD(rxrpc_active_client_conns);
94static LIST_HEAD(rxrpc_idle_client_conns);
95
David Howells4a3388c2016-04-04 14:00:37 +010096/*
97 * We use machine-unique IDs for our client connections.
98 */
99DEFINE_IDR(rxrpc_client_conn_ids);
100static DEFINE_SPINLOCK(rxrpc_conn_id_lock);
101
David Howells45025bc2016-08-24 07:30:52 +0100102static void rxrpc_cull_active_client_conns(void);
103static void rxrpc_discard_expired_client_conns(struct work_struct *);
104
105static DECLARE_DELAYED_WORK(rxrpc_client_conn_reap,
106 rxrpc_discard_expired_client_conns);
107
David Howells363deea2016-09-17 10:49:14 +0100108const char rxrpc_conn_cache_states[RXRPC_CONN__NR_CACHE_STATES][5] = {
109 [RXRPC_CONN_CLIENT_INACTIVE] = "Inac",
110 [RXRPC_CONN_CLIENT_WAITING] = "Wait",
111 [RXRPC_CONN_CLIENT_ACTIVE] = "Actv",
112 [RXRPC_CONN_CLIENT_CULLED] = "Cull",
113 [RXRPC_CONN_CLIENT_IDLE] = "Idle",
114};
115
David Howells4a3388c2016-04-04 14:00:37 +0100116/*
117 * Get a connection ID and epoch for a client connection from the global pool.
118 * The connection struct pointer is then recorded in the idr radix tree. The
David Howells090f85d2016-09-04 13:14:46 +0100119 * epoch doesn't change until the client is rebooted (or, at least, unless the
120 * module is unloaded).
David Howells4a3388c2016-04-04 14:00:37 +0100121 */
David Howellsc6d2b8d2016-04-04 14:00:40 +0100122static int rxrpc_get_client_connection_id(struct rxrpc_connection *conn,
123 gfp_t gfp)
David Howells4a3388c2016-04-04 14:00:37 +0100124{
David Howells4a3388c2016-04-04 14:00:37 +0100125 int id;
126
127 _enter("");
128
129 idr_preload(gfp);
David Howells4a3388c2016-04-04 14:00:37 +0100130 spin_lock(&rxrpc_conn_id_lock);
131
David Howells090f85d2016-09-04 13:14:46 +0100132 id = idr_alloc_cyclic(&rxrpc_client_conn_ids, conn,
133 1, 0x40000000, GFP_NOWAIT);
134 if (id < 0)
135 goto error;
David Howells4a3388c2016-04-04 14:00:37 +0100136
137 spin_unlock(&rxrpc_conn_id_lock);
David Howells4a3388c2016-04-04 14:00:37 +0100138 idr_preload_end();
139
David Howells090f85d2016-09-04 13:14:46 +0100140 conn->proto.epoch = rxrpc_epoch;
David Howells4a3388c2016-04-04 14:00:37 +0100141 conn->proto.cid = id << RXRPC_CIDSHIFT;
142 set_bit(RXRPC_CONN_HAS_IDR, &conn->flags);
David Howells090f85d2016-09-04 13:14:46 +0100143 _leave(" [CID %x]", conn->proto.cid);
David Howells4a3388c2016-04-04 14:00:37 +0100144 return 0;
145
146error:
147 spin_unlock(&rxrpc_conn_id_lock);
David Howells4a3388c2016-04-04 14:00:37 +0100148 idr_preload_end();
149 _leave(" = %d", id);
150 return id;
151}
152
153/*
154 * Release a connection ID for a client connection from the global pool.
155 */
David Howells001c1122016-06-30 10:45:22 +0100156static void rxrpc_put_client_connection_id(struct rxrpc_connection *conn)
David Howells4a3388c2016-04-04 14:00:37 +0100157{
158 if (test_bit(RXRPC_CONN_HAS_IDR, &conn->flags)) {
159 spin_lock(&rxrpc_conn_id_lock);
160 idr_remove(&rxrpc_client_conn_ids,
161 conn->proto.cid >> RXRPC_CIDSHIFT);
162 spin_unlock(&rxrpc_conn_id_lock);
163 }
164}
David Howellseb9b9d22016-06-27 10:32:02 +0100165
166/*
167 * Destroy the client connection ID tree.
168 */
169void rxrpc_destroy_client_conn_ids(void)
170{
171 struct rxrpc_connection *conn;
172 int id;
173
174 if (!idr_is_empty(&rxrpc_client_conn_ids)) {
175 idr_for_each_entry(&rxrpc_client_conn_ids, conn, id) {
176 pr_err("AF_RXRPC: Leaked client conn %p {%d}\n",
177 conn, atomic_read(&conn->usage));
178 }
179 BUG();
180 }
181
182 idr_destroy(&rxrpc_client_conn_ids);
183}
David Howellsc6d2b8d2016-04-04 14:00:40 +0100184
185/*
David Howells45025bc2016-08-24 07:30:52 +0100186 * Allocate a client connection.
David Howellsc6d2b8d2016-04-04 14:00:40 +0100187 */
188static struct rxrpc_connection *
189rxrpc_alloc_client_connection(struct rxrpc_conn_parameters *cp, gfp_t gfp)
190{
191 struct rxrpc_connection *conn;
192 int ret;
193
194 _enter("");
195
196 conn = rxrpc_alloc_connection(gfp);
197 if (!conn) {
198 _leave(" = -ENOMEM");
199 return ERR_PTR(-ENOMEM);
200 }
201
David Howells45025bc2016-08-24 07:30:52 +0100202 atomic_set(&conn->usage, 1);
David Howells8732db62016-09-29 22:37:15 +0100203 if (cp->exclusive)
David Howells45025bc2016-08-24 07:30:52 +0100204 __set_bit(RXRPC_CONN_DONT_REUSE, &conn->flags);
205
David Howellsc6d2b8d2016-04-04 14:00:40 +0100206 conn->params = *cp;
David Howellsc6d2b8d2016-04-04 14:00:40 +0100207 conn->out_clientflag = RXRPC_CLIENT_INITIATED;
208 conn->state = RXRPC_CONN_CLIENT;
209
David Howellsc6d2b8d2016-04-04 14:00:40 +0100210 ret = rxrpc_get_client_connection_id(conn, gfp);
211 if (ret < 0)
212 goto error_0;
213
214 ret = rxrpc_init_client_conn_security(conn);
215 if (ret < 0)
216 goto error_1;
217
218 ret = conn->security->prime_packet_security(conn);
219 if (ret < 0)
220 goto error_2;
221
222 write_lock(&rxrpc_connection_lock);
David Howells4d028b22016-08-24 07:30:52 +0100223 list_add_tail(&conn->proc_link, &rxrpc_connection_proc_list);
David Howellsc6d2b8d2016-04-04 14:00:40 +0100224 write_unlock(&rxrpc_connection_lock);
225
226 /* We steal the caller's peer ref. */
227 cp->peer = NULL;
228 rxrpc_get_local(conn->params.local);
229 key_get(conn->params.key);
230
David Howells363deea2016-09-17 10:49:14 +0100231 trace_rxrpc_conn(conn, rxrpc_conn_new_client, atomic_read(&conn->usage),
232 __builtin_return_address(0));
233 trace_rxrpc_client(conn, -1, rxrpc_client_alloc);
David Howellsc6d2b8d2016-04-04 14:00:40 +0100234 _leave(" = %p", conn);
235 return conn;
236
237error_2:
238 conn->security->clear(conn);
239error_1:
240 rxrpc_put_client_connection_id(conn);
241error_0:
242 kfree(conn);
243 _leave(" = %d", ret);
244 return ERR_PTR(ret);
245}
246
247/*
David Howells45025bc2016-08-24 07:30:52 +0100248 * Determine if a connection may be reused.
David Howellsc6d2b8d2016-04-04 14:00:40 +0100249 */
David Howells45025bc2016-08-24 07:30:52 +0100250static bool rxrpc_may_reuse_conn(struct rxrpc_connection *conn)
251{
252 int id_cursor, id, distance, limit;
253
254 if (test_bit(RXRPC_CONN_DONT_REUSE, &conn->flags))
255 goto dont_reuse;
256
257 if (conn->proto.epoch != rxrpc_epoch)
258 goto mark_dont_reuse;
259
260 /* The IDR tree gets very expensive on memory if the connection IDs are
261 * widely scattered throughout the number space, so we shall want to
262 * kill off connections that, say, have an ID more than about four
263 * times the maximum number of client conns away from the current
264 * allocation point to try and keep the IDs concentrated.
265 */
266 id_cursor = READ_ONCE(rxrpc_client_conn_ids.cur);
267 id = conn->proto.cid >> RXRPC_CIDSHIFT;
268 distance = id - id_cursor;
269 if (distance < 0)
270 distance = -distance;
271 limit = round_up(rxrpc_max_client_connections, IDR_SIZE) * 4;
272 if (distance > limit)
273 goto mark_dont_reuse;
274
275 return true;
276
277mark_dont_reuse:
278 set_bit(RXRPC_CONN_DONT_REUSE, &conn->flags);
279dont_reuse:
280 return false;
281}
282
283/*
284 * Create or find a client connection to use for a call.
285 *
286 * If we return with a connection, the call will be on its waiting list. It's
287 * left to the caller to assign a channel and wake up the call.
288 */
289static int rxrpc_get_client_conn(struct rxrpc_call *call,
290 struct rxrpc_conn_parameters *cp,
291 struct sockaddr_rxrpc *srx,
292 gfp_t gfp)
David Howellsc6d2b8d2016-04-04 14:00:40 +0100293{
294 struct rxrpc_connection *conn, *candidate = NULL;
295 struct rxrpc_local *local = cp->local;
296 struct rb_node *p, **pp, *parent;
297 long diff;
David Howells45025bc2016-08-24 07:30:52 +0100298 int ret = -ENOMEM;
David Howellsc6d2b8d2016-04-04 14:00:40 +0100299
300 _enter("{%d,%lx},", call->debug_id, call->user_call_ID);
301
302 cp->peer = rxrpc_lookup_peer(cp->local, srx, gfp);
303 if (!cp->peer)
David Howells45025bc2016-08-24 07:30:52 +0100304 goto error;
David Howellsc6d2b8d2016-04-04 14:00:40 +0100305
David Howells45025bc2016-08-24 07:30:52 +0100306 /* If the connection is not meant to be exclusive, search the available
307 * connections to see if the connection we want to use already exists.
308 */
David Howellsc6d2b8d2016-04-04 14:00:40 +0100309 if (!cp->exclusive) {
David Howellsc6d2b8d2016-04-04 14:00:40 +0100310 _debug("search 1");
311 spin_lock(&local->client_conns_lock);
312 p = local->client_conns.rb_node;
313 while (p) {
314 conn = rb_entry(p, struct rxrpc_connection, client_node);
315
316#define cmp(X) ((long)conn->params.X - (long)cp->X)
317 diff = (cmp(peer) ?:
318 cmp(key) ?:
319 cmp(security_level));
David Howells45025bc2016-08-24 07:30:52 +0100320#undef cmp
321 if (diff < 0) {
David Howellsc6d2b8d2016-04-04 14:00:40 +0100322 p = p->rb_left;
David Howells45025bc2016-08-24 07:30:52 +0100323 } else if (diff > 0) {
David Howellsc6d2b8d2016-04-04 14:00:40 +0100324 p = p->rb_right;
David Howells45025bc2016-08-24 07:30:52 +0100325 } else {
326 if (rxrpc_may_reuse_conn(conn) &&
327 rxrpc_get_connection_maybe(conn))
328 goto found_extant_conn;
329 /* The connection needs replacing. It's better
330 * to effect that when we have something to
331 * replace it with so that we don't have to
332 * rebalance the tree twice.
333 */
334 break;
335 }
David Howellsc6d2b8d2016-04-04 14:00:40 +0100336 }
337 spin_unlock(&local->client_conns_lock);
338 }
339
David Howells45025bc2016-08-24 07:30:52 +0100340 /* There wasn't a connection yet or we need an exclusive connection.
341 * We need to create a candidate and then potentially redo the search
342 * in case we're racing with another thread also trying to connect on a
343 * shareable connection.
344 */
345 _debug("new conn");
David Howellsc6d2b8d2016-04-04 14:00:40 +0100346 candidate = rxrpc_alloc_client_connection(cp, gfp);
David Howells45025bc2016-08-24 07:30:52 +0100347 if (IS_ERR(candidate)) {
348 ret = PTR_ERR(candidate);
349 goto error_peer;
David Howellsc6d2b8d2016-04-04 14:00:40 +0100350 }
351
David Howells45025bc2016-08-24 07:30:52 +0100352 /* Add the call to the new connection's waiting list in case we're
353 * going to have to wait for the connection to come live. It's our
354 * connection, so we want first dibs on the channel slots. We would
355 * normally have to take channel_lock but we do this before anyone else
356 * can see the connection.
357 */
358 list_add_tail(&call->chan_wait_link, &candidate->waiting_calls);
359
David Howellsc6d2b8d2016-04-04 14:00:40 +0100360 if (cp->exclusive) {
David Howells45025bc2016-08-24 07:30:52 +0100361 call->conn = candidate;
David Howells278ac0c2016-09-07 15:19:25 +0100362 call->security_ix = candidate->security_ix;
David Howells45025bc2016-08-24 07:30:52 +0100363 _leave(" = 0 [exclusive %d]", candidate->debug_id);
364 return 0;
David Howellsc6d2b8d2016-04-04 14:00:40 +0100365 }
366
David Howells45025bc2016-08-24 07:30:52 +0100367 /* Publish the new connection for userspace to find. We need to redo
368 * the search before doing this lest we race with someone else adding a
369 * conflicting instance.
David Howellsc6d2b8d2016-04-04 14:00:40 +0100370 */
371 _debug("search 2");
372 spin_lock(&local->client_conns_lock);
373
374 pp = &local->client_conns.rb_node;
375 parent = NULL;
376 while (*pp) {
377 parent = *pp;
378 conn = rb_entry(parent, struct rxrpc_connection, client_node);
379
David Howells45025bc2016-08-24 07:30:52 +0100380#define cmp(X) ((long)conn->params.X - (long)candidate->params.X)
David Howellsc6d2b8d2016-04-04 14:00:40 +0100381 diff = (cmp(peer) ?:
382 cmp(key) ?:
383 cmp(security_level));
David Howells45025bc2016-08-24 07:30:52 +0100384#undef cmp
385 if (diff < 0) {
David Howellsc6d2b8d2016-04-04 14:00:40 +0100386 pp = &(*pp)->rb_left;
David Howells45025bc2016-08-24 07:30:52 +0100387 } else if (diff > 0) {
David Howellsc6d2b8d2016-04-04 14:00:40 +0100388 pp = &(*pp)->rb_right;
David Howells45025bc2016-08-24 07:30:52 +0100389 } else {
390 if (rxrpc_may_reuse_conn(conn) &&
391 rxrpc_get_connection_maybe(conn))
392 goto found_extant_conn;
393 /* The old connection is from an outdated epoch. */
394 _debug("replace conn");
395 clear_bit(RXRPC_CONN_IN_CLIENT_CONNS, &conn->flags);
396 rb_replace_node(&conn->client_node,
397 &candidate->client_node,
398 &local->client_conns);
David Howells363deea2016-09-17 10:49:14 +0100399 trace_rxrpc_client(conn, -1, rxrpc_client_replace);
David Howells45025bc2016-08-24 07:30:52 +0100400 goto candidate_published;
401 }
David Howellsc6d2b8d2016-04-04 14:00:40 +0100402 }
403
David Howellsc6d2b8d2016-04-04 14:00:40 +0100404 _debug("new conn");
David Howells001c1122016-06-30 10:45:22 +0100405 rb_link_node(&candidate->client_node, parent, pp);
406 rb_insert_color(&candidate->client_node, &local->client_conns);
David Howellsc6d2b8d2016-04-04 14:00:40 +0100407
David Howells45025bc2016-08-24 07:30:52 +0100408candidate_published:
409 set_bit(RXRPC_CONN_IN_CLIENT_CONNS, &candidate->flags);
410 call->conn = candidate;
David Howells278ac0c2016-09-07 15:19:25 +0100411 call->security_ix = candidate->security_ix;
David Howellsc6d2b8d2016-04-04 14:00:40 +0100412 spin_unlock(&local->client_conns_lock);
David Howells45025bc2016-08-24 07:30:52 +0100413 _leave(" = 0 [new %d]", candidate->debug_id);
David Howellsc6d2b8d2016-04-04 14:00:40 +0100414 return 0;
415
David Howells45025bc2016-08-24 07:30:52 +0100416 /* We come here if we found a suitable connection already in existence.
417 * Discard any candidate we may have allocated, and try to get a
418 * channel on this one.
David Howellsc6d2b8d2016-04-04 14:00:40 +0100419 */
420found_extant_conn:
421 _debug("found conn");
David Howellsc6d2b8d2016-04-04 14:00:40 +0100422 spin_unlock(&local->client_conns_lock);
423
David Howells363deea2016-09-17 10:49:14 +0100424 if (candidate) {
425 trace_rxrpc_client(candidate, -1, rxrpc_client_duplicate);
426 rxrpc_put_connection(candidate);
427 candidate = NULL;
428 }
David Howellsc6d2b8d2016-04-04 14:00:40 +0100429
David Howellsc6d2b8d2016-04-04 14:00:40 +0100430 spin_lock(&conn->channel_lock);
David Howells45025bc2016-08-24 07:30:52 +0100431 call->conn = conn;
David Howells278ac0c2016-09-07 15:19:25 +0100432 call->security_ix = conn->security_ix;
David Howells45025bc2016-08-24 07:30:52 +0100433 list_add(&call->chan_wait_link, &conn->waiting_calls);
434 spin_unlock(&conn->channel_lock);
435 _leave(" = 0 [extant %d]", conn->debug_id);
436 return 0;
David Howellsc6d2b8d2016-04-04 14:00:40 +0100437
David Howells45025bc2016-08-24 07:30:52 +0100438error_peer:
David Howellsc6d2b8d2016-04-04 14:00:40 +0100439 rxrpc_put_peer(cp->peer);
440 cp->peer = NULL;
David Howells45025bc2016-08-24 07:30:52 +0100441error:
442 _leave(" = %d", ret);
443 return ret;
David Howellsc6d2b8d2016-04-04 14:00:40 +0100444}
David Howells001c1122016-06-30 10:45:22 +0100445
446/*
David Howells45025bc2016-08-24 07:30:52 +0100447 * Activate a connection.
David Howells001c1122016-06-30 10:45:22 +0100448 */
David Howells45025bc2016-08-24 07:30:52 +0100449static void rxrpc_activate_conn(struct rxrpc_connection *conn)
David Howells001c1122016-06-30 10:45:22 +0100450{
David Howells363deea2016-09-17 10:49:14 +0100451 trace_rxrpc_client(conn, -1, rxrpc_client_to_active);
David Howells45025bc2016-08-24 07:30:52 +0100452 conn->cache_state = RXRPC_CONN_CLIENT_ACTIVE;
453 rxrpc_nr_active_client_conns++;
454 list_move_tail(&conn->cache_link, &rxrpc_active_client_conns);
455}
David Howells001c1122016-06-30 10:45:22 +0100456
David Howells45025bc2016-08-24 07:30:52 +0100457/*
458 * Attempt to animate a connection for a new call.
459 *
460 * If it's not exclusive, the connection is in the endpoint tree, and we're in
461 * the conn's list of those waiting to grab a channel. There is, however, a
462 * limit on the number of live connections allowed at any one time, so we may
463 * have to wait for capacity to become available.
464 *
465 * Note that a connection on the waiting queue might *also* have active
466 * channels if it has been culled to make space and then re-requested by a new
467 * call.
468 */
469static void rxrpc_animate_client_conn(struct rxrpc_connection *conn)
470{
471 unsigned int nr_conns;
472
473 _enter("%d,%d", conn->debug_id, conn->cache_state);
474
475 if (conn->cache_state == RXRPC_CONN_CLIENT_ACTIVE)
476 goto out;
477
478 spin_lock(&rxrpc_client_conn_cache_lock);
479
480 nr_conns = rxrpc_nr_client_conns;
David Howells363deea2016-09-17 10:49:14 +0100481 if (!test_and_set_bit(RXRPC_CONN_COUNTED, &conn->flags)) {
482 trace_rxrpc_client(conn, -1, rxrpc_client_count);
David Howells45025bc2016-08-24 07:30:52 +0100483 rxrpc_nr_client_conns = nr_conns + 1;
David Howells363deea2016-09-17 10:49:14 +0100484 }
David Howells45025bc2016-08-24 07:30:52 +0100485
486 switch (conn->cache_state) {
487 case RXRPC_CONN_CLIENT_ACTIVE:
488 case RXRPC_CONN_CLIENT_WAITING:
489 break;
490
491 case RXRPC_CONN_CLIENT_INACTIVE:
492 case RXRPC_CONN_CLIENT_CULLED:
493 case RXRPC_CONN_CLIENT_IDLE:
494 if (nr_conns >= rxrpc_max_client_connections)
495 goto wait_for_capacity;
496 goto activate_conn;
497
498 default:
499 BUG();
500 }
501
502out_unlock:
503 spin_unlock(&rxrpc_client_conn_cache_lock);
504out:
505 _leave(" [%d]", conn->cache_state);
506 return;
507
508activate_conn:
509 _debug("activate");
510 rxrpc_activate_conn(conn);
511 goto out_unlock;
512
513wait_for_capacity:
514 _debug("wait");
David Howells363deea2016-09-17 10:49:14 +0100515 trace_rxrpc_client(conn, -1, rxrpc_client_to_waiting);
David Howells45025bc2016-08-24 07:30:52 +0100516 conn->cache_state = RXRPC_CONN_CLIENT_WAITING;
517 list_move_tail(&conn->cache_link, &rxrpc_waiting_client_conns);
518 goto out_unlock;
519}
520
521/*
522 * Deactivate a channel.
523 */
524static void rxrpc_deactivate_one_channel(struct rxrpc_connection *conn,
525 unsigned int channel)
526{
527 struct rxrpc_channel *chan = &conn->channels[channel];
528
529 rcu_assign_pointer(chan->call, NULL);
530 conn->active_chans &= ~(1 << channel);
531}
532
533/*
534 * Assign a channel to the call at the front of the queue and wake the call up.
535 * We don't increment the callNumber counter until this number has been exposed
536 * to the world.
537 */
538static void rxrpc_activate_one_channel(struct rxrpc_connection *conn,
539 unsigned int channel)
540{
541 struct rxrpc_channel *chan = &conn->channels[channel];
542 struct rxrpc_call *call = list_entry(conn->waiting_calls.next,
543 struct rxrpc_call, chan_wait_link);
544 u32 call_id = chan->call_counter + 1;
545
David Howells363deea2016-09-17 10:49:14 +0100546 trace_rxrpc_client(conn, channel, rxrpc_client_chan_activate);
547
David Howellsaf338a92016-09-04 13:10:10 +0100548 write_lock_bh(&call->state_lock);
549 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
550 write_unlock_bh(&call->state_lock);
551
David Howellse34d4232016-08-30 09:49:29 +0100552 rxrpc_see_call(call);
David Howells45025bc2016-08-24 07:30:52 +0100553 list_del_init(&call->chan_wait_link);
554 conn->active_chans |= 1 << channel;
555 call->peer = rxrpc_get_peer(conn->params.peer);
556 call->cid = conn->proto.cid | channel;
557 call->call_id = call_id;
558
559 _net("CONNECT call %08x:%08x as call %d on conn %d",
560 call->cid, call->call_id, call->debug_id, conn->debug_id);
561
562 /* Paired with the read barrier in rxrpc_wait_for_channel(). This
563 * orders cid and epoch in the connection wrt to call_id without the
564 * need to take the channel_lock.
565 *
566 * We provisionally assign a callNumber at this point, but we don't
567 * confirm it until the call is about to be exposed.
568 *
569 * TODO: Pair with a barrier in the data_ready handler when that looks
570 * at the call ID through a connection channel.
571 */
572 smp_wmb();
573 chan->call_id = call_id;
574 rcu_assign_pointer(chan->call, call);
575 wake_up(&call->waitq);
576}
577
578/*
579 * Assign channels and callNumbers to waiting calls.
580 */
581static void rxrpc_activate_channels(struct rxrpc_connection *conn)
582{
583 unsigned char mask;
584
585 _enter("%d", conn->debug_id);
586
David Howells363deea2016-09-17 10:49:14 +0100587 trace_rxrpc_client(conn, -1, rxrpc_client_activate_chans);
588
David Howells45025bc2016-08-24 07:30:52 +0100589 if (conn->cache_state != RXRPC_CONN_CLIENT_ACTIVE ||
590 conn->active_chans == RXRPC_ACTIVE_CHANS_MASK)
591 return;
592
593 spin_lock(&conn->channel_lock);
594
595 while (!list_empty(&conn->waiting_calls) &&
596 (mask = ~conn->active_chans,
597 mask &= RXRPC_ACTIVE_CHANS_MASK,
598 mask != 0))
599 rxrpc_activate_one_channel(conn, __ffs(mask));
600
601 spin_unlock(&conn->channel_lock);
602 _leave("");
603}
604
605/*
606 * Wait for a callNumber and a channel to be granted to a call.
607 */
608static int rxrpc_wait_for_channel(struct rxrpc_call *call, gfp_t gfp)
609{
610 int ret = 0;
611
612 _enter("%d", call->debug_id);
613
614 if (!call->call_id) {
615 DECLARE_WAITQUEUE(myself, current);
616
617 if (!gfpflags_allow_blocking(gfp)) {
618 ret = -EAGAIN;
619 goto out;
620 }
621
622 add_wait_queue_exclusive(&call->waitq, &myself);
623 for (;;) {
624 set_current_state(TASK_INTERRUPTIBLE);
625 if (call->call_id)
626 break;
627 if (signal_pending(current)) {
628 ret = -ERESTARTSYS;
629 break;
630 }
631 schedule();
632 }
633 remove_wait_queue(&call->waitq, &myself);
634 __set_current_state(TASK_RUNNING);
635 }
636
637 /* Paired with the write barrier in rxrpc_activate_one_channel(). */
638 smp_rmb();
639
640out:
641 _leave(" = %d", ret);
642 return ret;
643}
644
645/*
646 * find a connection for a call
647 * - called in process context with IRQs enabled
648 */
649int rxrpc_connect_call(struct rxrpc_call *call,
650 struct rxrpc_conn_parameters *cp,
651 struct sockaddr_rxrpc *srx,
652 gfp_t gfp)
653{
654 int ret;
655
656 _enter("{%d,%lx},", call->debug_id, call->user_call_ID);
657
658 rxrpc_discard_expired_client_conns(NULL);
659 rxrpc_cull_active_client_conns();
660
661 ret = rxrpc_get_client_conn(call, cp, srx, gfp);
662 if (ret < 0)
663 return ret;
664
665 rxrpc_animate_client_conn(call->conn);
666 rxrpc_activate_channels(call->conn);
667
668 ret = rxrpc_wait_for_channel(call, gfp);
669 if (ret < 0)
670 rxrpc_disconnect_client_call(call);
671
672 _leave(" = %d", ret);
673 return ret;
674}
675
676/*
677 * Note that a connection is about to be exposed to the world. Once it is
678 * exposed, we maintain an extra ref on it that stops it from being summarily
679 * discarded before it's (a) had a chance to deal with retransmission and (b)
680 * had a chance at re-use (the per-connection security negotiation is
681 * expensive).
682 */
David Howells363deea2016-09-17 10:49:14 +0100683static void rxrpc_expose_client_conn(struct rxrpc_connection *conn,
684 unsigned int channel)
David Howells45025bc2016-08-24 07:30:52 +0100685{
David Howells363deea2016-09-17 10:49:14 +0100686 if (!test_and_set_bit(RXRPC_CONN_EXPOSED, &conn->flags)) {
687 trace_rxrpc_client(conn, channel, rxrpc_client_exposed);
David Howells45025bc2016-08-24 07:30:52 +0100688 rxrpc_get_connection(conn);
David Howells363deea2016-09-17 10:49:14 +0100689 }
David Howells45025bc2016-08-24 07:30:52 +0100690}
691
692/*
693 * Note that a call, and thus a connection, is about to be exposed to the
694 * world.
695 */
696void rxrpc_expose_client_call(struct rxrpc_call *call)
697{
David Howells363deea2016-09-17 10:49:14 +0100698 unsigned int channel = call->cid & RXRPC_CHANNELMASK;
David Howells45025bc2016-08-24 07:30:52 +0100699 struct rxrpc_connection *conn = call->conn;
David Howells363deea2016-09-17 10:49:14 +0100700 struct rxrpc_channel *chan = &conn->channels[channel];
David Howells45025bc2016-08-24 07:30:52 +0100701
702 if (!test_and_set_bit(RXRPC_CALL_EXPOSED, &call->flags)) {
703 /* Mark the call ID as being used. If the callNumber counter
704 * exceeds ~2 billion, we kill the connection after its
705 * outstanding calls have finished so that the counter doesn't
706 * wrap.
707 */
708 chan->call_counter++;
709 if (chan->call_counter >= INT_MAX)
710 set_bit(RXRPC_CONN_DONT_REUSE, &conn->flags);
David Howells363deea2016-09-17 10:49:14 +0100711 rxrpc_expose_client_conn(conn, channel);
David Howells45025bc2016-08-24 07:30:52 +0100712 }
713}
714
715/*
716 * Disconnect a client call.
717 */
718void rxrpc_disconnect_client_call(struct rxrpc_call *call)
719{
720 unsigned int channel = call->cid & RXRPC_CHANNELMASK;
721 struct rxrpc_connection *conn = call->conn;
722 struct rxrpc_channel *chan = &conn->channels[channel];
723
David Howells363deea2016-09-17 10:49:14 +0100724 trace_rxrpc_client(conn, channel, rxrpc_client_chan_disconnect);
David Howells45025bc2016-08-24 07:30:52 +0100725 call->conn = NULL;
726
727 spin_lock(&conn->channel_lock);
728
729 /* Calls that have never actually been assigned a channel can simply be
730 * discarded. If the conn didn't get used either, it will follow
731 * immediately unless someone else grabs it in the meantime.
732 */
733 if (!list_empty(&call->chan_wait_link)) {
734 _debug("call is waiting");
735 ASSERTCMP(call->call_id, ==, 0);
736 ASSERT(!test_bit(RXRPC_CALL_EXPOSED, &call->flags));
737 list_del_init(&call->chan_wait_link);
738
David Howells363deea2016-09-17 10:49:14 +0100739 trace_rxrpc_client(conn, channel, rxrpc_client_chan_unstarted);
740
David Howells45025bc2016-08-24 07:30:52 +0100741 /* We must deactivate or idle the connection if it's now
742 * waiting for nothing.
743 */
744 spin_lock(&rxrpc_client_conn_cache_lock);
745 if (conn->cache_state == RXRPC_CONN_CLIENT_WAITING &&
746 list_empty(&conn->waiting_calls) &&
747 !conn->active_chans)
748 goto idle_connection;
749 goto out;
750 }
751
752 ASSERTCMP(rcu_access_pointer(chan->call), ==, call);
David Howells45025bc2016-08-24 07:30:52 +0100753
754 /* If a client call was exposed to the world, we save the result for
755 * retransmission.
756 *
757 * We use a barrier here so that the call number and abort code can be
758 * read without needing to take a lock.
759 *
760 * TODO: Make the incoming packet handler check this and handle
761 * terminal retransmission without requiring access to the call.
762 */
763 if (test_bit(RXRPC_CALL_EXPOSED, &call->flags)) {
David Howellsf5c17aa2016-08-30 09:49:28 +0100764 _debug("exposed %u,%u", call->call_id, call->abort_code);
David Howells45025bc2016-08-24 07:30:52 +0100765 __rxrpc_disconnect_call(conn, call);
766 }
767
768 /* See if we can pass the channel directly to another call. */
769 if (conn->cache_state == RXRPC_CONN_CLIENT_ACTIVE &&
770 !list_empty(&conn->waiting_calls)) {
David Howells363deea2016-09-17 10:49:14 +0100771 trace_rxrpc_client(conn, channel, rxrpc_client_chan_pass);
David Howells45025bc2016-08-24 07:30:52 +0100772 rxrpc_activate_one_channel(conn, channel);
773 goto out_2;
774 }
775
776 /* Things are more complex and we need the cache lock. We might be
777 * able to simply idle the conn or it might now be lurking on the wait
778 * list. It might even get moved back to the active list whilst we're
779 * waiting for the lock.
780 */
781 spin_lock(&rxrpc_client_conn_cache_lock);
782
783 switch (conn->cache_state) {
784 case RXRPC_CONN_CLIENT_ACTIVE:
785 if (list_empty(&conn->waiting_calls)) {
786 rxrpc_deactivate_one_channel(conn, channel);
787 if (!conn->active_chans) {
788 rxrpc_nr_active_client_conns--;
789 goto idle_connection;
790 }
791 goto out;
792 }
793
David Howells363deea2016-09-17 10:49:14 +0100794 trace_rxrpc_client(conn, channel, rxrpc_client_chan_pass);
David Howells45025bc2016-08-24 07:30:52 +0100795 rxrpc_activate_one_channel(conn, channel);
796 goto out;
797
798 case RXRPC_CONN_CLIENT_CULLED:
799 rxrpc_deactivate_one_channel(conn, channel);
800 ASSERT(list_empty(&conn->waiting_calls));
801 if (!conn->active_chans)
802 goto idle_connection;
803 goto out;
804
805 case RXRPC_CONN_CLIENT_WAITING:
806 rxrpc_deactivate_one_channel(conn, channel);
807 goto out;
808
809 default:
810 BUG();
811 }
812
813out:
814 spin_unlock(&rxrpc_client_conn_cache_lock);
815out_2:
816 spin_unlock(&conn->channel_lock);
817 rxrpc_put_connection(conn);
818 _leave("");
819 return;
820
821idle_connection:
822 /* As no channels remain active, the connection gets deactivated
823 * immediately or moved to the idle list for a short while.
824 */
825 if (test_bit(RXRPC_CONN_EXPOSED, &conn->flags)) {
David Howells363deea2016-09-17 10:49:14 +0100826 trace_rxrpc_client(conn, channel, rxrpc_client_to_idle);
David Howells45025bc2016-08-24 07:30:52 +0100827 conn->idle_timestamp = jiffies;
828 conn->cache_state = RXRPC_CONN_CLIENT_IDLE;
829 list_move_tail(&conn->cache_link, &rxrpc_idle_client_conns);
830 if (rxrpc_idle_client_conns.next == &conn->cache_link &&
831 !rxrpc_kill_all_client_conns)
832 queue_delayed_work(rxrpc_workqueue,
833 &rxrpc_client_conn_reap,
834 rxrpc_conn_idle_client_expiry);
835 } else {
David Howells363deea2016-09-17 10:49:14 +0100836 trace_rxrpc_client(conn, channel, rxrpc_client_to_inactive);
David Howells45025bc2016-08-24 07:30:52 +0100837 conn->cache_state = RXRPC_CONN_CLIENT_INACTIVE;
838 list_del_init(&conn->cache_link);
839 }
840 goto out;
841}
842
843/*
844 * Clean up a dead client connection.
845 */
846static struct rxrpc_connection *
847rxrpc_put_one_client_conn(struct rxrpc_connection *conn)
848{
David Howells66d58af2016-09-17 10:49:12 +0100849 struct rxrpc_connection *next = NULL;
David Howells45025bc2016-08-24 07:30:52 +0100850 struct rxrpc_local *local = conn->params.local;
851 unsigned int nr_conns;
852
David Howells363deea2016-09-17 10:49:14 +0100853 trace_rxrpc_client(conn, -1, rxrpc_client_cleanup);
854
David Howells45025bc2016-08-24 07:30:52 +0100855 if (test_bit(RXRPC_CONN_IN_CLIENT_CONNS, &conn->flags)) {
856 spin_lock(&local->client_conns_lock);
857 if (test_and_clear_bit(RXRPC_CONN_IN_CLIENT_CONNS,
858 &conn->flags))
859 rb_erase(&conn->client_node, &local->client_conns);
860 spin_unlock(&local->client_conns_lock);
861 }
David Howells001c1122016-06-30 10:45:22 +0100862
863 rxrpc_put_client_connection_id(conn);
David Howells45025bc2016-08-24 07:30:52 +0100864
865 ASSERTCMP(conn->cache_state, ==, RXRPC_CONN_CLIENT_INACTIVE);
866
David Howells66d58af2016-09-17 10:49:12 +0100867 if (test_bit(RXRPC_CONN_COUNTED, &conn->flags)) {
David Howells363deea2016-09-17 10:49:14 +0100868 trace_rxrpc_client(conn, -1, rxrpc_client_uncount);
David Howells66d58af2016-09-17 10:49:12 +0100869 spin_lock(&rxrpc_client_conn_cache_lock);
870 nr_conns = --rxrpc_nr_client_conns;
David Howells45025bc2016-08-24 07:30:52 +0100871
David Howells66d58af2016-09-17 10:49:12 +0100872 if (nr_conns < rxrpc_max_client_connections &&
873 !list_empty(&rxrpc_waiting_client_conns)) {
874 next = list_entry(rxrpc_waiting_client_conns.next,
875 struct rxrpc_connection, cache_link);
876 rxrpc_get_connection(next);
877 rxrpc_activate_conn(next);
878 }
David Howells45025bc2016-08-24 07:30:52 +0100879
David Howells66d58af2016-09-17 10:49:12 +0100880 spin_unlock(&rxrpc_client_conn_cache_lock);
David Howells45025bc2016-08-24 07:30:52 +0100881 }
882
David Howells45025bc2016-08-24 07:30:52 +0100883 rxrpc_kill_connection(conn);
David Howells45025bc2016-08-24 07:30:52 +0100884 if (next)
885 rxrpc_activate_channels(next);
886
887 /* We need to get rid of the temporary ref we took upon next, but we
888 * can't call rxrpc_put_connection() recursively.
889 */
890 return next;
891}
892
893/*
894 * Clean up a dead client connections.
895 */
896void rxrpc_put_client_conn(struct rxrpc_connection *conn)
897{
David Howells363deea2016-09-17 10:49:14 +0100898 const void *here = __builtin_return_address(0);
899 int n;
David Howells45025bc2016-08-24 07:30:52 +0100900
901 do {
David Howells363deea2016-09-17 10:49:14 +0100902 n = atomic_dec_return(&conn->usage);
903 trace_rxrpc_conn(conn, rxrpc_conn_put_client, n, here);
904 if (n > 0)
905 return;
906 ASSERTCMP(n, >=, 0);
David Howells45025bc2016-08-24 07:30:52 +0100907
David Howells363deea2016-09-17 10:49:14 +0100908 conn = rxrpc_put_one_client_conn(conn);
909 } while (conn);
David Howells45025bc2016-08-24 07:30:52 +0100910}
911
912/*
913 * Kill the longest-active client connections to make room for new ones.
914 */
915static void rxrpc_cull_active_client_conns(void)
916{
917 struct rxrpc_connection *conn;
918 unsigned int nr_conns = rxrpc_nr_client_conns;
919 unsigned int nr_active, limit;
920
921 _enter("");
922
923 ASSERTCMP(nr_conns, >=, 0);
924 if (nr_conns < rxrpc_max_client_connections) {
925 _leave(" [ok]");
926 return;
927 }
928 limit = rxrpc_reap_client_connections;
929
930 spin_lock(&rxrpc_client_conn_cache_lock);
931 nr_active = rxrpc_nr_active_client_conns;
932
933 while (nr_active > limit) {
934 ASSERT(!list_empty(&rxrpc_active_client_conns));
935 conn = list_entry(rxrpc_active_client_conns.next,
936 struct rxrpc_connection, cache_link);
937 ASSERTCMP(conn->cache_state, ==, RXRPC_CONN_CLIENT_ACTIVE);
938
939 if (list_empty(&conn->waiting_calls)) {
David Howells363deea2016-09-17 10:49:14 +0100940 trace_rxrpc_client(conn, -1, rxrpc_client_to_culled);
David Howells45025bc2016-08-24 07:30:52 +0100941 conn->cache_state = RXRPC_CONN_CLIENT_CULLED;
942 list_del_init(&conn->cache_link);
943 } else {
David Howells363deea2016-09-17 10:49:14 +0100944 trace_rxrpc_client(conn, -1, rxrpc_client_to_waiting);
David Howells45025bc2016-08-24 07:30:52 +0100945 conn->cache_state = RXRPC_CONN_CLIENT_WAITING;
946 list_move_tail(&conn->cache_link,
947 &rxrpc_waiting_client_conns);
948 }
949
950 nr_active--;
951 }
952
953 rxrpc_nr_active_client_conns = nr_active;
954 spin_unlock(&rxrpc_client_conn_cache_lock);
955 ASSERTCMP(nr_active, >=, 0);
956 _leave(" [culled]");
957}
958
959/*
960 * Discard expired client connections from the idle list. Each conn in the
961 * idle list has been exposed and holds an extra ref because of that.
962 *
963 * This may be called from conn setup or from a work item so cannot be
964 * considered non-reentrant.
965 */
966static void rxrpc_discard_expired_client_conns(struct work_struct *work)
967{
968 struct rxrpc_connection *conn;
969 unsigned long expiry, conn_expires_at, now;
970 unsigned int nr_conns;
971 bool did_discard = false;
972
973 _enter("%c", work ? 'w' : 'n');
974
975 if (list_empty(&rxrpc_idle_client_conns)) {
976 _leave(" [empty]");
977 return;
978 }
979
980 /* Don't double up on the discarding */
981 if (!spin_trylock(&rxrpc_client_conn_discard_mutex)) {
982 _leave(" [already]");
983 return;
984 }
985
986 /* We keep an estimate of what the number of conns ought to be after
987 * we've discarded some so that we don't overdo the discarding.
988 */
989 nr_conns = rxrpc_nr_client_conns;
990
991next:
992 spin_lock(&rxrpc_client_conn_cache_lock);
993
994 if (list_empty(&rxrpc_idle_client_conns))
995 goto out;
996
997 conn = list_entry(rxrpc_idle_client_conns.next,
998 struct rxrpc_connection, cache_link);
999 ASSERT(test_bit(RXRPC_CONN_EXPOSED, &conn->flags));
1000
1001 if (!rxrpc_kill_all_client_conns) {
1002 /* If the number of connections is over the reap limit, we
1003 * expedite discard by reducing the expiry timeout. We must,
1004 * however, have at least a short grace period to be able to do
1005 * final-ACK or ABORT retransmission.
1006 */
1007 expiry = rxrpc_conn_idle_client_expiry;
1008 if (nr_conns > rxrpc_reap_client_connections)
1009 expiry = rxrpc_conn_idle_client_fast_expiry;
1010
1011 conn_expires_at = conn->idle_timestamp + expiry;
1012
1013 now = READ_ONCE(jiffies);
1014 if (time_after(conn_expires_at, now))
1015 goto not_yet_expired;
1016 }
1017
David Howells363deea2016-09-17 10:49:14 +01001018 trace_rxrpc_client(conn, -1, rxrpc_client_discard);
David Howells45025bc2016-08-24 07:30:52 +01001019 if (!test_and_clear_bit(RXRPC_CONN_EXPOSED, &conn->flags))
1020 BUG();
1021 conn->cache_state = RXRPC_CONN_CLIENT_INACTIVE;
1022 list_del_init(&conn->cache_link);
1023
1024 spin_unlock(&rxrpc_client_conn_cache_lock);
1025
1026 /* When we cleared the EXPOSED flag, we took on responsibility for the
1027 * reference that that had on the usage count. We deal with that here.
1028 * If someone re-sets the flag and re-gets the ref, that's fine.
1029 */
1030 rxrpc_put_connection(conn);
1031 did_discard = true;
1032 nr_conns--;
1033 goto next;
1034
1035not_yet_expired:
1036 /* The connection at the front of the queue hasn't yet expired, so
1037 * schedule the work item for that point if we discarded something.
1038 *
1039 * We don't worry if the work item is already scheduled - it can look
1040 * after rescheduling itself at a later time. We could cancel it, but
1041 * then things get messier.
1042 */
1043 _debug("not yet");
1044 if (!rxrpc_kill_all_client_conns)
1045 queue_delayed_work(rxrpc_workqueue,
1046 &rxrpc_client_conn_reap,
1047 conn_expires_at - now);
1048
1049out:
1050 spin_unlock(&rxrpc_client_conn_cache_lock);
1051 spin_unlock(&rxrpc_client_conn_discard_mutex);
1052 _leave("");
1053}
1054
1055/*
1056 * Preemptively destroy all the client connection records rather than waiting
1057 * for them to time out
1058 */
1059void __exit rxrpc_destroy_all_client_connections(void)
1060{
1061 _enter("");
1062
1063 spin_lock(&rxrpc_client_conn_cache_lock);
1064 rxrpc_kill_all_client_conns = true;
1065 spin_unlock(&rxrpc_client_conn_cache_lock);
1066
1067 cancel_delayed_work(&rxrpc_client_conn_reap);
1068
1069 if (!queue_delayed_work(rxrpc_workqueue, &rxrpc_client_conn_reap, 0))
1070 _debug("destroy: queue failed");
1071
1072 _leave("");
David Howells001c1122016-06-30 10:45:22 +01001073}