diff options
author | David Howells <dhowells@redhat.com> | 2019-08-19 04:25:37 -0400 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2019-08-27 05:03:26 -0400 |
commit | a641fd00d05a5ae38c5a3d50d4da10283b15287b (patch) | |
tree | 1ebf61e89027f61c605a24ea8387729c8ac9f65e | |
parent | 4858e40303fba12e7506bf4354f20fdf550b3cd5 (diff) |
rxrpc: Abstract out rxtx ring cleanup
Abstract out rxtx ring cleanup into its own function from its two callers.
This makes it easier to apply the same changes to both.
Signed-off-by: David Howells <dhowells@redhat.com>
-rw-r--r-- | net/rxrpc/call_object.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/net/rxrpc/call_object.c b/net/rxrpc/call_object.c index 217b12be9e08..c9ab2da957fe 100644 --- a/net/rxrpc/call_object.c +++ b/net/rxrpc/call_object.c | |||
@@ -422,6 +422,21 @@ void rxrpc_get_call(struct rxrpc_call *call, enum rxrpc_call_trace op) | |||
422 | } | 422 | } |
423 | 423 | ||
424 | /* | 424 | /* |
425 | * Clean up the RxTx skb ring. | ||
426 | */ | ||
427 | static void rxrpc_cleanup_ring(struct rxrpc_call *call) | ||
428 | { | ||
429 | int i; | ||
430 | |||
431 | for (i = 0; i < RXRPC_RXTX_BUFF_SIZE; i++) { | ||
432 | rxrpc_free_skb(call->rxtx_buffer[i], | ||
433 | (call->tx_phase ? rxrpc_skb_tx_cleaned : | ||
434 | rxrpc_skb_rx_cleaned)); | ||
435 | call->rxtx_buffer[i] = NULL; | ||
436 | } | ||
437 | } | ||
438 | |||
439 | /* | ||
425 | * Detach a call from its owning socket. | 440 | * Detach a call from its owning socket. |
426 | */ | 441 | */ |
427 | void rxrpc_release_call(struct rxrpc_sock *rx, struct rxrpc_call *call) | 442 | void rxrpc_release_call(struct rxrpc_sock *rx, struct rxrpc_call *call) |
@@ -429,7 +444,6 @@ void rxrpc_release_call(struct rxrpc_sock *rx, struct rxrpc_call *call) | |||
429 | const void *here = __builtin_return_address(0); | 444 | const void *here = __builtin_return_address(0); |
430 | struct rxrpc_connection *conn = call->conn; | 445 | struct rxrpc_connection *conn = call->conn; |
431 | bool put = false; | 446 | bool put = false; |
432 | int i; | ||
433 | 447 | ||
434 | _enter("{%d,%d}", call->debug_id, atomic_read(&call->usage)); | 448 | _enter("{%d,%d}", call->debug_id, atomic_read(&call->usage)); |
435 | 449 | ||
@@ -479,13 +493,7 @@ void rxrpc_release_call(struct rxrpc_sock *rx, struct rxrpc_call *call) | |||
479 | if (conn) | 493 | if (conn) |
480 | rxrpc_disconnect_call(call); | 494 | rxrpc_disconnect_call(call); |
481 | 495 | ||
482 | for (i = 0; i < RXRPC_RXTX_BUFF_SIZE; i++) { | 496 | rxrpc_cleanup_ring(call); |
483 | rxrpc_free_skb(call->rxtx_buffer[i], | ||
484 | (call->tx_phase ? rxrpc_skb_tx_cleaned : | ||
485 | rxrpc_skb_rx_cleaned)); | ||
486 | call->rxtx_buffer[i] = NULL; | ||
487 | } | ||
488 | |||
489 | _leave(""); | 497 | _leave(""); |
490 | } | 498 | } |
491 | 499 | ||
@@ -568,8 +576,6 @@ static void rxrpc_rcu_destroy_call(struct rcu_head *rcu) | |||
568 | */ | 576 | */ |
569 | void rxrpc_cleanup_call(struct rxrpc_call *call) | 577 | void rxrpc_cleanup_call(struct rxrpc_call *call) |
570 | { | 578 | { |
571 | int i; | ||
572 | |||
573 | _net("DESTROY CALL %d", call->debug_id); | 579 | _net("DESTROY CALL %d", call->debug_id); |
574 | 580 | ||
575 | memset(&call->sock_node, 0xcd, sizeof(call->sock_node)); | 581 | memset(&call->sock_node, 0xcd, sizeof(call->sock_node)); |
@@ -580,12 +586,7 @@ void rxrpc_cleanup_call(struct rxrpc_call *call) | |||
580 | ASSERT(test_bit(RXRPC_CALL_RELEASED, &call->flags)); | 586 | ASSERT(test_bit(RXRPC_CALL_RELEASED, &call->flags)); |
581 | ASSERTCMP(call->conn, ==, NULL); | 587 | ASSERTCMP(call->conn, ==, NULL); |
582 | 588 | ||
583 | /* Clean up the Rx/Tx buffer */ | 589 | rxrpc_cleanup_ring(call); |
584 | for (i = 0; i < RXRPC_RXTX_BUFF_SIZE; i++) | ||
585 | rxrpc_free_skb(call->rxtx_buffer[i], | ||
586 | (call->tx_phase ? rxrpc_skb_tx_cleaned : | ||
587 | rxrpc_skb_rx_cleaned)); | ||
588 | |||
589 | rxrpc_free_skb(call->tx_pending, rxrpc_skb_tx_cleaned); | 590 | rxrpc_free_skb(call->tx_pending, rxrpc_skb_tx_cleaned); |
590 | 591 | ||
591 | call_rcu(&call->rcu, rxrpc_rcu_destroy_call); | 592 | call_rcu(&call->rcu, rxrpc_rcu_destroy_call); |