conn_object.c (4092de1ba34eb376791809fb366bc15f8a9e0b7c) conn_object.c (4c1295dccc0afe0905b6ca4c62ade7f2406f2cfb)
1// SPDX-License-Identifier: GPL-2.0-or-later
2/* RxRPC virtual connection handler, common bits.
3 *
4 * Copyright (C) 2007, 2016 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
6 */
7
8#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

--- 255 unchanged lines hidden (view full) ---

264 */
265bool rxrpc_queue_conn(struct rxrpc_connection *conn)
266{
267 const void *here = __builtin_return_address(0);
268 int n = atomic_fetch_add_unless(&conn->usage, 1, 0);
269 if (n == 0)
270 return false;
271 if (rxrpc_queue_work(&conn->processor))
1// SPDX-License-Identifier: GPL-2.0-or-later
2/* RxRPC virtual connection handler, common bits.
3 *
4 * Copyright (C) 2007, 2016 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
6 */
7
8#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

--- 255 unchanged lines hidden (view full) ---

264 */
265bool rxrpc_queue_conn(struct rxrpc_connection *conn)
266{
267 const void *here = __builtin_return_address(0);
268 int n = atomic_fetch_add_unless(&conn->usage, 1, 0);
269 if (n == 0)
270 return false;
271 if (rxrpc_queue_work(&conn->processor))
272 trace_rxrpc_conn(conn, rxrpc_conn_queued, n + 1, here);
272 trace_rxrpc_conn(conn->debug_id, rxrpc_conn_queued, n + 1, here);
273 else
274 rxrpc_put_connection(conn);
275 return true;
276}
277
278/*
279 * Note the re-emergence of a connection.
280 */
281void rxrpc_see_connection(struct rxrpc_connection *conn)
282{
283 const void *here = __builtin_return_address(0);
284 if (conn) {
285 int n = atomic_read(&conn->usage);
286
273 else
274 rxrpc_put_connection(conn);
275 return true;
276}
277
278/*
279 * Note the re-emergence of a connection.
280 */
281void rxrpc_see_connection(struct rxrpc_connection *conn)
282{
283 const void *here = __builtin_return_address(0);
284 if (conn) {
285 int n = atomic_read(&conn->usage);
286
287 trace_rxrpc_conn(conn, rxrpc_conn_seen, n, here);
287 trace_rxrpc_conn(conn->debug_id, rxrpc_conn_seen, n, here);
288 }
289}
290
291/*
292 * Get a ref on a connection.
293 */
294void rxrpc_get_connection(struct rxrpc_connection *conn)
295{
296 const void *here = __builtin_return_address(0);
297 int n = atomic_inc_return(&conn->usage);
298
288 }
289}
290
291/*
292 * Get a ref on a connection.
293 */
294void rxrpc_get_connection(struct rxrpc_connection *conn)
295{
296 const void *here = __builtin_return_address(0);
297 int n = atomic_inc_return(&conn->usage);
298
299 trace_rxrpc_conn(conn, rxrpc_conn_got, n, here);
299 trace_rxrpc_conn(conn->debug_id, rxrpc_conn_got, n, here);
300}
301
302/*
303 * Try to get a ref on a connection.
304 */
305struct rxrpc_connection *
306rxrpc_get_connection_maybe(struct rxrpc_connection *conn)
307{
308 const void *here = __builtin_return_address(0);
309
310 if (conn) {
311 int n = atomic_fetch_add_unless(&conn->usage, 1, 0);
312 if (n > 0)
300}
301
302/*
303 * Try to get a ref on a connection.
304 */
305struct rxrpc_connection *
306rxrpc_get_connection_maybe(struct rxrpc_connection *conn)
307{
308 const void *here = __builtin_return_address(0);
309
310 if (conn) {
311 int n = atomic_fetch_add_unless(&conn->usage, 1, 0);
312 if (n > 0)
313 trace_rxrpc_conn(conn, rxrpc_conn_got, n + 1, here);
313 trace_rxrpc_conn(conn->debug_id, rxrpc_conn_got, n + 1, here);
314 else
315 conn = NULL;
316 }
317 return conn;
318}
319
320/*
321 * Set the service connection reap timer.

--- 6 unchanged lines hidden (view full) ---

328}
329
330/*
331 * Release a service connection
332 */
333void rxrpc_put_service_conn(struct rxrpc_connection *conn)
334{
335 const void *here = __builtin_return_address(0);
314 else
315 conn = NULL;
316 }
317 return conn;
318}
319
320/*
321 * Set the service connection reap timer.

--- 6 unchanged lines hidden (view full) ---

328}
329
330/*
331 * Release a service connection
332 */
333void rxrpc_put_service_conn(struct rxrpc_connection *conn)
334{
335 const void *here = __builtin_return_address(0);
336 unsigned int debug_id = conn->debug_id;
336 int n;
337
338 n = atomic_dec_return(&conn->usage);
337 int n;
338
339 n = atomic_dec_return(&conn->usage);
339 trace_rxrpc_conn(conn, rxrpc_conn_put_service, n, here);
340 trace_rxrpc_conn(debug_id, rxrpc_conn_put_service, n, here);
340 ASSERTCMP(n, >=, 0);
341 if (n == 1)
342 rxrpc_set_service_reap_timer(conn->params.local->rxnet,
343 jiffies + rxrpc_connection_expiry);
344}
345
346/*
347 * destroy a virtual connection

--- 67 unchanged lines hidden (view full) ---

415 }
416 }
417
418 /* The usage count sits at 1 whilst the object is unused on the
419 * list; we reduce that to 0 to make the object unavailable.
420 */
421 if (atomic_cmpxchg(&conn->usage, 1, 0) != 1)
422 continue;
341 ASSERTCMP(n, >=, 0);
342 if (n == 1)
343 rxrpc_set_service_reap_timer(conn->params.local->rxnet,
344 jiffies + rxrpc_connection_expiry);
345}
346
347/*
348 * destroy a virtual connection

--- 67 unchanged lines hidden (view full) ---

416 }
417 }
418
419 /* The usage count sits at 1 whilst the object is unused on the
420 * list; we reduce that to 0 to make the object unavailable.
421 */
422 if (atomic_cmpxchg(&conn->usage, 1, 0) != 1)
423 continue;
423 trace_rxrpc_conn(conn, rxrpc_conn_reap_service, 0, NULL);
424 trace_rxrpc_conn(conn->debug_id, rxrpc_conn_reap_service, 0, NULL);
424
425 if (rxrpc_conn_is_client(conn))
426 BUG();
427 else
428 rxrpc_unpublish_service_conn(conn);
429
430 list_move_tail(&conn->link, &graveyard);
431 }

--- 55 unchanged lines hidden ---
425
426 if (rxrpc_conn_is_client(conn))
427 BUG();
428 else
429 rxrpc_unpublish_service_conn(conn);
430
431 list_move_tail(&conn->link, &graveyard);
432 }

--- 55 unchanged lines hidden ---