rxrpc: Rewrite the data and ack handling code
[GitHub/moto-9609/android_kernel_motorola_exynos9610.git] / fs / afs / rxrpc.c
index 720ef05a24fe370205d10cd37ba768b3cc01e6d4..59bdaa7527b650736aee94832285ebf95d81f422 100644 (file)
@@ -55,10 +55,8 @@ static const struct afs_call_type afs_RXCMxxxx = {
        .abort_to_error = afs_abort_to_error,
 };
 
-static void afs_collect_incoming_call(struct work_struct *);
 static void afs_charge_preallocation(struct work_struct *);
 
-static DECLARE_WORK(afs_collect_incoming_call_work, afs_collect_incoming_call);
 static DECLARE_WORK(afs_charge_preallocation_work, afs_charge_preallocation);
 
 static int afs_wait_atomic_t(atomic_t *p)
@@ -143,6 +141,8 @@ void afs_close_socket(void)
                         TASK_UNINTERRUPTIBLE);
        _debug("no outstanding calls");
 
+       flush_workqueue(afs_async_calls);
+       kernel_sock_shutdown(afs_socket, SHUT_RDWR);
        flush_workqueue(afs_async_calls);
        sock_release(afs_socket);
 
@@ -602,51 +602,6 @@ static void afs_process_async_call(struct work_struct *work)
        _leave("");
 }
 
-/*
- * accept the backlog of incoming calls
- */
-static void afs_collect_incoming_call(struct work_struct *work)
-{
-       struct rxrpc_call *rxcall;
-       struct afs_call *call = NULL;
-
-       _enter("");
-
-       do {
-               if (!call) {
-                       call = kzalloc(sizeof(struct afs_call), GFP_KERNEL);
-                       if (!call) {
-                               rxrpc_kernel_reject_call(afs_socket);
-                               return;
-                       }
-
-                       INIT_WORK(&call->async_work, afs_process_async_call);
-                       call->wait_mode = &afs_async_incoming_call;
-                       call->type = &afs_RXCMxxxx;
-                       init_waitqueue_head(&call->waitq);
-                       call->state = AFS_CALL_AWAIT_OP_ID;
-
-                       _debug("CALL %p{%s} [%d]",
-                              call, call->type->name,
-                              atomic_read(&afs_outstanding_calls));
-                       atomic_inc(&afs_outstanding_calls);
-               }
-
-               rxcall = rxrpc_kernel_accept_call(afs_socket,
-                                                 (unsigned long)call,
-                                                 afs_wake_up_async_call);
-               if (!IS_ERR(rxcall)) {
-                       call->rxcall = rxcall;
-                       call->need_attention = true;
-                       queue_work(afs_async_calls, &call->async_work);
-                       call = NULL;
-               }
-       } while (!call);
-
-       if (call)
-               afs_free_call(call);
-}
-
 static void afs_rx_attach(struct rxrpc_call *rxcall, unsigned long user_call_ID)
 {
        struct afs_call *call = (struct afs_call *)user_call_ID;
@@ -704,7 +659,7 @@ static void afs_rx_discard_new_call(struct rxrpc_call *rxcall,
 static void afs_rx_new_call(struct sock *sk, struct rxrpc_call *rxcall,
                            unsigned long user_call_ID)
 {
-       queue_work(afs_wq, &afs_collect_incoming_call_work);
+       atomic_inc(&afs_outstanding_calls);
        queue_work(afs_wq, &afs_charge_preallocation_work);
 }