rxrpc: Trace rxrpc_call usage
[cascardo/linux.git] / net / rxrpc / peer_event.c
index 8940674..27b9eca 100644 (file)
@@ -248,13 +248,21 @@ void rxrpc_peer_error_distributor(struct work_struct *work)
        struct rxrpc_peer *peer =
                container_of(work, struct rxrpc_peer, error_distributor);
        struct rxrpc_call *call;
-       int error_report;
+       enum rxrpc_call_completion compl;
+       bool queue;
+       int error;
 
        _enter("");
 
-       error_report = READ_ONCE(peer->error_report);
+       error = READ_ONCE(peer->error_report);
+       if (error < RXRPC_LOCAL_ERROR_OFFSET) {
+               compl = RXRPC_CALL_NETWORK_ERROR;
+       } else {
+               compl = RXRPC_CALL_LOCAL_ERROR;
+               error -= RXRPC_LOCAL_ERROR_OFFSET;
+       }
 
-       _debug("ISSUE ERROR %d", error_report);
+       _debug("ISSUE ERROR %s %d", rxrpc_call_completions[compl], error);
 
        spin_lock_bh(&peer->lock);
 
@@ -262,16 +270,17 @@ void rxrpc_peer_error_distributor(struct work_struct *work)
                call = hlist_entry(peer->error_targets.first,
                                   struct rxrpc_call, error_link);
                hlist_del_init(&call->error_link);
+               rxrpc_see_call(call);
 
+               queue = false;
                write_lock(&call->state_lock);
-               if (call->state != RXRPC_CALL_COMPLETE &&
-                   call->state < RXRPC_CALL_NETWORK_ERROR) {
-                       call->error_report = error_report;
-                       call->state = RXRPC_CALL_NETWORK_ERROR;
+               if (__rxrpc_set_call_completion(call, compl, 0, error)) {
                        set_bit(RXRPC_CALL_EV_RCVD_ERROR, &call->events);
-                       rxrpc_queue_call(call);
+                       queue = true;
                }
                write_unlock(&call->state_lock);
+               if (queue)
+                       rxrpc_queue_call(call);
        }
 
        spin_unlock_bh(&peer->lock);