afs: Don't put afs_call in afs_wait_for_call_to_complete()
[sfrench/cifs-2.6.git] / fs / afs / rxrpc.c
index 2603db03b7ff8c9b70d581bc8fbe8a2e9e33013f..dad8efadbc441aa47a17ab061d2868d2b0517860 100644 (file)
@@ -575,48 +575,44 @@ call_complete:
 /*
  * Wait synchronously for a call to complete and clean up the call struct.
  */
-long afs_wait_for_call_to_complete(struct afs_call *call,
-                                  struct afs_addr_cursor *ac)
+void afs_wait_for_call_to_complete(struct afs_call *call, struct afs_addr_cursor *ac)
 {
-       long ret;
        bool rxrpc_complete = false;
 
-       DECLARE_WAITQUEUE(myself, current);
-
        _enter("");
 
-       ret = call->error;
-       if (ret < 0)
-               goto out;
+       if (!afs_check_call_state(call, AFS_CALL_COMPLETE)) {
+               DECLARE_WAITQUEUE(myself, current);
+
+               add_wait_queue(&call->waitq, &myself);
+               for (;;) {
+                       set_current_state(TASK_UNINTERRUPTIBLE);
+
+                       /* deliver any messages that are in the queue */
+                       if (!afs_check_call_state(call, AFS_CALL_COMPLETE) &&
+                           call->need_attention) {
+                               call->need_attention = false;
+                               __set_current_state(TASK_RUNNING);
+                               afs_deliver_to_call(call);
+                               continue;
+                       }
 
-       add_wait_queue(&call->waitq, &myself);
-       for (;;) {
-               set_current_state(TASK_UNINTERRUPTIBLE);
-
-               /* deliver any messages that are in the queue */
-               if (!afs_check_call_state(call, AFS_CALL_COMPLETE) &&
-                   call->need_attention) {
-                       call->need_attention = false;
-                       __set_current_state(TASK_RUNNING);
-                       afs_deliver_to_call(call);
-                       continue;
-               }
+                       if (afs_check_call_state(call, AFS_CALL_COMPLETE))
+                               break;
 
-               if (afs_check_call_state(call, AFS_CALL_COMPLETE))
-                       break;
+                       if (!rxrpc_kernel_check_life(call->net->socket, call->rxcall)) {
+                               /* rxrpc terminated the call. */
+                               rxrpc_complete = true;
+                               break;
+                       }
 
-               if (!rxrpc_kernel_check_life(call->net->socket, call->rxcall)) {
-                       /* rxrpc terminated the call. */
-                       rxrpc_complete = true;
-                       break;
+                       schedule();
                }
 
-               schedule();
+               remove_wait_queue(&call->waitq, &myself);
+               __set_current_state(TASK_RUNNING);
        }
 
-       remove_wait_queue(&call->waitq, &myself);
-       __set_current_state(TASK_RUNNING);
-
        if (!afs_check_call_state(call, AFS_CALL_COMPLETE)) {
                if (rxrpc_complete) {
                        afs_set_call_complete(call, call->error, call->abort_code);
@@ -635,23 +631,8 @@ long afs_wait_for_call_to_complete(struct afs_call *call,
        ac->error = call->error;
        spin_unlock_bh(&call->state_lock);
 
-       ret = ac->error;
-       switch (ret) {
-       case 0:
-               ret = call->ret0;
-               call->ret0 = 0;
-
-               fallthrough;
-       case -ECONNABORTED:
+       if (call->error == 0 || call->error == -ECONNABORTED)
                ac->responded = true;
-               break;
-       }
-
-out:
-       _debug("call complete");
-       afs_put_call(call);
-       _leave(" = %p", (void *)ret);
-       return ret;
 }
 
 /*