37608be52abd2809a02b3349146029bbf5e50d94
[linux-block.git] / fs / afs / rxrpc.c
1 /* Maintain an RxRPC server socket to do AFS communications through
2  *
3  * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4  * Written by David Howells (dhowells@redhat.com)
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version
9  * 2 of the License, or (at your option) any later version.
10  */
11
12 #include <linux/slab.h>
13 #include <net/sock.h>
14 #include <net/af_rxrpc.h>
15 #include <rxrpc/packet.h>
16 #include "internal.h"
17 #include "afs_cm.h"
18
19 struct socket *afs_socket; /* my RxRPC socket */
20 static struct workqueue_struct *afs_async_calls;
21 static atomic_t afs_outstanding_calls;
22
23 static void afs_free_call(struct afs_call *);
24 static void afs_wake_up_call_waiter(struct sock *, struct rxrpc_call *, unsigned long);
25 static int afs_wait_for_call_to_complete(struct afs_call *);
26 static void afs_wake_up_async_call(struct sock *, struct rxrpc_call *, unsigned long);
27 static int afs_dont_wait_for_call_to_complete(struct afs_call *);
28 static void afs_process_async_call(struct work_struct *);
29 static void afs_rx_new_call(struct sock *);
30 static int afs_deliver_cm_op_id(struct afs_call *);
31
32 /* synchronous call management */
33 const struct afs_wait_mode afs_sync_call = {
34         .notify_rx      = afs_wake_up_call_waiter,
35         .wait           = afs_wait_for_call_to_complete,
36 };
37
38 /* asynchronous call management */
39 const struct afs_wait_mode afs_async_call = {
40         .notify_rx      = afs_wake_up_async_call,
41         .wait           = afs_dont_wait_for_call_to_complete,
42 };
43
44 /* asynchronous incoming call management */
45 static const struct afs_wait_mode afs_async_incoming_call = {
46         .notify_rx      = afs_wake_up_async_call,
47 };
48
49 /* asynchronous incoming call initial processing */
50 static const struct afs_call_type afs_RXCMxxxx = {
51         .name           = "CB.xxxx",
52         .deliver        = afs_deliver_cm_op_id,
53         .abort_to_error = afs_abort_to_error,
54 };
55
56 static void afs_collect_incoming_call(struct work_struct *);
57
58 static DECLARE_WORK(afs_collect_incoming_call_work, afs_collect_incoming_call);
59
60 static int afs_wait_atomic_t(atomic_t *p)
61 {
62         schedule();
63         return 0;
64 }
65
66 /*
67  * open an RxRPC socket and bind it to be a server for callback notifications
68  * - the socket is left in blocking mode and non-blocking ops use MSG_DONTWAIT
69  */
70 int afs_open_socket(void)
71 {
72         struct sockaddr_rxrpc srx;
73         struct socket *socket;
74         int ret;
75
76         _enter("");
77
78         ret = -ENOMEM;
79         afs_async_calls = alloc_workqueue("kafsd", WQ_MEM_RECLAIM, 0);
80         if (!afs_async_calls)
81                 goto error_0;
82
83         ret = sock_create_kern(&init_net, AF_RXRPC, SOCK_DGRAM, PF_INET, &socket);
84         if (ret < 0)
85                 goto error_1;
86
87         socket->sk->sk_allocation = GFP_NOFS;
88
89         /* bind the callback manager's address to make this a server socket */
90         srx.srx_family                  = AF_RXRPC;
91         srx.srx_service                 = CM_SERVICE;
92         srx.transport_type              = SOCK_DGRAM;
93         srx.transport_len               = sizeof(srx.transport.sin);
94         srx.transport.sin.sin_family    = AF_INET;
95         srx.transport.sin.sin_port      = htons(AFS_CM_PORT);
96         memset(&srx.transport.sin.sin_addr, 0,
97                sizeof(srx.transport.sin.sin_addr));
98
99         ret = kernel_bind(socket, (struct sockaddr *) &srx, sizeof(srx));
100         if (ret < 0)
101                 goto error_2;
102
103         rxrpc_kernel_new_call_notification(socket, afs_rx_new_call);
104
105         ret = kernel_listen(socket, INT_MAX);
106         if (ret < 0)
107                 goto error_2;
108
109         afs_socket = socket;
110         _leave(" = 0");
111         return 0;
112
113 error_2:
114         sock_release(socket);
115 error_1:
116         destroy_workqueue(afs_async_calls);
117 error_0:
118         _leave(" = %d", ret);
119         return ret;
120 }
121
122 /*
123  * close the RxRPC socket AFS was using
124  */
125 void afs_close_socket(void)
126 {
127         _enter("");
128
129         _debug("outstanding %u", atomic_read(&afs_outstanding_calls));
130         wait_on_atomic_t(&afs_outstanding_calls, afs_wait_atomic_t,
131                          TASK_UNINTERRUPTIBLE);
132         _debug("no outstanding calls");
133
134         flush_workqueue(afs_async_calls);
135         sock_release(afs_socket);
136
137         _debug("dework");
138         destroy_workqueue(afs_async_calls);
139         _leave("");
140 }
141
142 /*
143  * free a call
144  */
145 static void afs_free_call(struct afs_call *call)
146 {
147         _debug("DONE %p{%s} [%d]",
148                call, call->type->name, atomic_read(&afs_outstanding_calls));
149
150         ASSERTCMP(call->rxcall, ==, NULL);
151         ASSERT(!work_pending(&call->async_work));
152         ASSERT(call->type->name != NULL);
153
154         kfree(call->request);
155         kfree(call);
156
157         if (atomic_dec_and_test(&afs_outstanding_calls))
158                 wake_up_atomic_t(&afs_outstanding_calls);
159 }
160
161 /*
162  * End a call but do not free it
163  */
164 static void afs_end_call_nofree(struct afs_call *call)
165 {
166         if (call->rxcall) {
167                 rxrpc_kernel_end_call(afs_socket, call->rxcall);
168                 call->rxcall = NULL;
169         }
170         if (call->type->destructor)
171                 call->type->destructor(call);
172 }
173
174 /*
175  * End a call and free it
176  */
177 static void afs_end_call(struct afs_call *call)
178 {
179         afs_end_call_nofree(call);
180         afs_free_call(call);
181 }
182
183 /*
184  * allocate a call with flat request and reply buffers
185  */
186 struct afs_call *afs_alloc_flat_call(const struct afs_call_type *type,
187                                      size_t request_size, size_t reply_max)
188 {
189         struct afs_call *call;
190
191         call = kzalloc(sizeof(*call), GFP_NOFS);
192         if (!call)
193                 goto nomem_call;
194
195         _debug("CALL %p{%s} [%d]",
196                call, type->name, atomic_read(&afs_outstanding_calls));
197         atomic_inc(&afs_outstanding_calls);
198
199         call->type = type;
200         call->request_size = request_size;
201         call->reply_max = reply_max;
202
203         if (request_size) {
204                 call->request = kmalloc(request_size, GFP_NOFS);
205                 if (!call->request)
206                         goto nomem_free;
207         }
208
209         if (reply_max) {
210                 call->buffer = kmalloc(reply_max, GFP_NOFS);
211                 if (!call->buffer)
212                         goto nomem_free;
213         }
214
215         init_waitqueue_head(&call->waitq);
216         return call;
217
218 nomem_free:
219         afs_free_call(call);
220 nomem_call:
221         return NULL;
222 }
223
224 /*
225  * clean up a call with flat buffer
226  */
227 void afs_flat_call_destructor(struct afs_call *call)
228 {
229         _enter("");
230
231         kfree(call->request);
232         call->request = NULL;
233         kfree(call->buffer);
234         call->buffer = NULL;
235 }
236
237 /*
238  * attach the data from a bunch of pages on an inode to a call
239  */
240 static int afs_send_pages(struct afs_call *call, struct msghdr *msg,
241                           struct kvec *iov)
242 {
243         struct page *pages[8];
244         unsigned count, n, loop, offset, to;
245         pgoff_t first = call->first, last = call->last;
246         int ret;
247
248         _enter("");
249
250         offset = call->first_offset;
251         call->first_offset = 0;
252
253         do {
254                 _debug("attach %lx-%lx", first, last);
255
256                 count = last - first + 1;
257                 if (count > ARRAY_SIZE(pages))
258                         count = ARRAY_SIZE(pages);
259                 n = find_get_pages_contig(call->mapping, first, count, pages);
260                 ASSERTCMP(n, ==, count);
261
262                 loop = 0;
263                 do {
264                         msg->msg_flags = 0;
265                         to = PAGE_SIZE;
266                         if (first + loop >= last)
267                                 to = call->last_to;
268                         else
269                                 msg->msg_flags = MSG_MORE;
270                         iov->iov_base = kmap(pages[loop]) + offset;
271                         iov->iov_len = to - offset;
272                         offset = 0;
273
274                         _debug("- range %u-%u%s",
275                                offset, to, msg->msg_flags ? " [more]" : "");
276                         iov_iter_kvec(&msg->msg_iter, WRITE | ITER_KVEC,
277                                       iov, 1, to - offset);
278
279                         /* have to change the state *before* sending the last
280                          * packet as RxRPC might give us the reply before it
281                          * returns from sending the request */
282                         if (first + loop >= last)
283                                 call->state = AFS_CALL_AWAIT_REPLY;
284                         ret = rxrpc_kernel_send_data(afs_socket, call->rxcall,
285                                                      msg, to - offset);
286                         kunmap(pages[loop]);
287                         if (ret < 0)
288                                 break;
289                 } while (++loop < count);
290                 first += count;
291
292                 for (loop = 0; loop < count; loop++)
293                         put_page(pages[loop]);
294                 if (ret < 0)
295                         break;
296         } while (first <= last);
297
298         _leave(" = %d", ret);
299         return ret;
300 }
301
302 /*
303  * initiate a call
304  */
305 int afs_make_call(struct in_addr *addr, struct afs_call *call, gfp_t gfp,
306                   const struct afs_wait_mode *wait_mode)
307 {
308         struct sockaddr_rxrpc srx;
309         struct rxrpc_call *rxcall;
310         struct msghdr msg;
311         struct kvec iov[1];
312         int ret;
313
314         _enter("%x,{%d},", addr->s_addr, ntohs(call->port));
315
316         ASSERT(call->type != NULL);
317         ASSERT(call->type->name != NULL);
318
319         _debug("____MAKE %p{%s,%x} [%d]____",
320                call, call->type->name, key_serial(call->key),
321                atomic_read(&afs_outstanding_calls));
322
323         call->wait_mode = wait_mode;
324         INIT_WORK(&call->async_work, afs_process_async_call);
325
326         memset(&srx, 0, sizeof(srx));
327         srx.srx_family = AF_RXRPC;
328         srx.srx_service = call->service_id;
329         srx.transport_type = SOCK_DGRAM;
330         srx.transport_len = sizeof(srx.transport.sin);
331         srx.transport.sin.sin_family = AF_INET;
332         srx.transport.sin.sin_port = call->port;
333         memcpy(&srx.transport.sin.sin_addr, addr, 4);
334
335         /* create a call */
336         rxcall = rxrpc_kernel_begin_call(afs_socket, &srx, call->key,
337                                          (unsigned long) call, gfp,
338                                          wait_mode->notify_rx);
339         call->key = NULL;
340         if (IS_ERR(rxcall)) {
341                 ret = PTR_ERR(rxcall);
342                 goto error_kill_call;
343         }
344
345         call->rxcall = rxcall;
346
347         /* send the request */
348         iov[0].iov_base = call->request;
349         iov[0].iov_len  = call->request_size;
350
351         msg.msg_name            = NULL;
352         msg.msg_namelen         = 0;
353         iov_iter_kvec(&msg.msg_iter, WRITE | ITER_KVEC, iov, 1,
354                       call->request_size);
355         msg.msg_control         = NULL;
356         msg.msg_controllen      = 0;
357         msg.msg_flags           = (call->send_pages ? MSG_MORE : 0);
358
359         /* have to change the state *before* sending the last packet as RxRPC
360          * might give us the reply before it returns from sending the
361          * request */
362         if (!call->send_pages)
363                 call->state = AFS_CALL_AWAIT_REPLY;
364         ret = rxrpc_kernel_send_data(afs_socket, rxcall,
365                                      &msg, call->request_size);
366         if (ret < 0)
367                 goto error_do_abort;
368
369         if (call->send_pages) {
370                 ret = afs_send_pages(call, &msg, iov);
371                 if (ret < 0)
372                         goto error_do_abort;
373         }
374
375         /* at this point, an async call may no longer exist as it may have
376          * already completed */
377         return wait_mode->wait(call);
378
379 error_do_abort:
380         rxrpc_kernel_abort_call(afs_socket, rxcall, RX_USER_ABORT);
381 error_kill_call:
382         afs_end_call(call);
383         _leave(" = %d", ret);
384         return ret;
385 }
386
387 /*
388  * deliver messages to a call
389  */
390 static void afs_deliver_to_call(struct afs_call *call)
391 {
392         u32 abort_code;
393         int ret;
394
395         _enter("%s", call->type->name);
396
397         while (call->state == AFS_CALL_AWAIT_REPLY ||
398                call->state == AFS_CALL_AWAIT_OP_ID ||
399                call->state == AFS_CALL_AWAIT_REQUEST ||
400                call->state == AFS_CALL_AWAIT_ACK
401                ) {
402                 if (call->state == AFS_CALL_AWAIT_ACK) {
403                         size_t offset = 0;
404                         ret = rxrpc_kernel_recv_data(afs_socket, call->rxcall,
405                                                      NULL, 0, &offset, false,
406                                                      &call->abort_code);
407                         if (ret == -EINPROGRESS || ret == -EAGAIN)
408                                 return;
409                         if (ret == 1) {
410                                 call->state = AFS_CALL_COMPLETE;
411                                 goto done;
412                         }
413                         return;
414                 }
415
416                 ret = call->type->deliver(call);
417                 switch (ret) {
418                 case 0:
419                         if (call->state == AFS_CALL_AWAIT_REPLY)
420                                 call->state = AFS_CALL_COMPLETE;
421                         goto done;
422                 case -EINPROGRESS:
423                 case -EAGAIN:
424                         goto out;
425                 case -ENOTCONN:
426                         abort_code = RX_CALL_DEAD;
427                         rxrpc_kernel_abort_call(afs_socket, call->rxcall,
428                                                 abort_code);
429                         goto do_abort;
430                 case -ENOTSUPP:
431                         abort_code = RX_INVALID_OPERATION;
432                         rxrpc_kernel_abort_call(afs_socket, call->rxcall,
433                                                 abort_code);
434                         goto do_abort;
435                 case -ENODATA:
436                 case -EBADMSG:
437                 case -EMSGSIZE:
438                 default:
439                         abort_code = RXGEN_CC_UNMARSHAL;
440                         if (call->state != AFS_CALL_AWAIT_REPLY)
441                                 abort_code = RXGEN_SS_UNMARSHAL;
442                         rxrpc_kernel_abort_call(afs_socket, call->rxcall,
443                                                 abort_code);
444                         goto do_abort;
445                 }
446         }
447
448 done:
449         if (call->state == AFS_CALL_COMPLETE && call->incoming)
450                 afs_end_call(call);
451 out:
452         _leave("");
453         return;
454
455 do_abort:
456         call->error = ret;
457         call->state = AFS_CALL_COMPLETE;
458         goto done;
459 }
460
461 /*
462  * wait synchronously for a call to complete
463  */
464 static int afs_wait_for_call_to_complete(struct afs_call *call)
465 {
466         int ret;
467
468         DECLARE_WAITQUEUE(myself, current);
469
470         _enter("");
471
472         add_wait_queue(&call->waitq, &myself);
473         for (;;) {
474                 set_current_state(TASK_INTERRUPTIBLE);
475
476                 /* deliver any messages that are in the queue */
477                 if (call->state < AFS_CALL_COMPLETE && call->need_attention) {
478                         call->need_attention = false;
479                         __set_current_state(TASK_RUNNING);
480                         afs_deliver_to_call(call);
481                         continue;
482                 }
483
484                 ret = call->error;
485                 if (call->state == AFS_CALL_COMPLETE)
486                         break;
487                 ret = -EINTR;
488                 if (signal_pending(current))
489                         break;
490                 schedule();
491         }
492
493         remove_wait_queue(&call->waitq, &myself);
494         __set_current_state(TASK_RUNNING);
495
496         /* kill the call */
497         if (call->state < AFS_CALL_COMPLETE) {
498                 _debug("call incomplete");
499                 rxrpc_kernel_abort_call(afs_socket, call->rxcall,
500                                         RX_CALL_DEAD);
501         }
502
503         _debug("call complete");
504         afs_end_call(call);
505         _leave(" = %d", ret);
506         return ret;
507 }
508
509 /*
510  * wake up a waiting call
511  */
512 static void afs_wake_up_call_waiter(struct sock *sk, struct rxrpc_call *rxcall,
513                                     unsigned long call_user_ID)
514 {
515         struct afs_call *call = (struct afs_call *)call_user_ID;
516
517         call->need_attention = true;
518         wake_up(&call->waitq);
519 }
520
521 /*
522  * wake up an asynchronous call
523  */
524 static void afs_wake_up_async_call(struct sock *sk, struct rxrpc_call *rxcall,
525                                    unsigned long call_user_ID)
526 {
527         struct afs_call *call = (struct afs_call *)call_user_ID;
528
529         call->need_attention = true;
530         queue_work(afs_async_calls, &call->async_work);
531 }
532
533 /*
534  * put a call into asynchronous mode
535  * - mustn't touch the call descriptor as the call my have completed by the
536  *   time we get here
537  */
538 static int afs_dont_wait_for_call_to_complete(struct afs_call *call)
539 {
540         _enter("");
541         return -EINPROGRESS;
542 }
543
544 /*
545  * delete an asynchronous call
546  */
547 static void afs_delete_async_call(struct work_struct *work)
548 {
549         struct afs_call *call = container_of(work, struct afs_call, async_work);
550
551         _enter("");
552
553         afs_free_call(call);
554
555         _leave("");
556 }
557
558 /*
559  * perform processing on an asynchronous call
560  */
561 static void afs_process_async_call(struct work_struct *work)
562 {
563         struct afs_call *call = container_of(work, struct afs_call, async_work);
564
565         _enter("");
566
567         if (call->state < AFS_CALL_COMPLETE && call->need_attention) {
568                 call->need_attention = false;
569                 afs_deliver_to_call(call);
570         }
571
572         if (call->state == AFS_CALL_COMPLETE && call->wait_mode) {
573                 if (call->wait_mode->async_complete)
574                         call->wait_mode->async_complete(call->reply,
575                                                         call->error);
576                 call->reply = NULL;
577
578                 /* kill the call */
579                 afs_end_call_nofree(call);
580
581                 /* we can't just delete the call because the work item may be
582                  * queued */
583                 call->async_work.func = afs_delete_async_call;
584                 queue_work(afs_async_calls, &call->async_work);
585         }
586
587         _leave("");
588 }
589
590 /*
591  * accept the backlog of incoming calls
592  */
593 static void afs_collect_incoming_call(struct work_struct *work)
594 {
595         struct rxrpc_call *rxcall;
596         struct afs_call *call = NULL;
597
598         _enter("");
599
600         do {
601                 if (!call) {
602                         call = kzalloc(sizeof(struct afs_call), GFP_KERNEL);
603                         if (!call) {
604                                 rxrpc_kernel_reject_call(afs_socket);
605                                 return;
606                         }
607
608                         INIT_WORK(&call->async_work, afs_process_async_call);
609                         call->wait_mode = &afs_async_incoming_call;
610                         call->type = &afs_RXCMxxxx;
611                         init_waitqueue_head(&call->waitq);
612                         call->state = AFS_CALL_AWAIT_OP_ID;
613
614                         _debug("CALL %p{%s} [%d]",
615                                call, call->type->name,
616                                atomic_read(&afs_outstanding_calls));
617                         atomic_inc(&afs_outstanding_calls);
618                 }
619
620                 rxcall = rxrpc_kernel_accept_call(afs_socket,
621                                                   (unsigned long)call,
622                                                   afs_wake_up_async_call);
623                 if (!IS_ERR(rxcall)) {
624                         call->rxcall = rxcall;
625                         call->need_attention = true;
626                         queue_work(afs_async_calls, &call->async_work);
627                         call = NULL;
628                 }
629         } while (!call);
630
631         if (call)
632                 afs_free_call(call);
633 }
634
635 /*
636  * Notification of an incoming call.
637  */
638 static void afs_rx_new_call(struct sock *sk)
639 {
640         queue_work(afs_wq, &afs_collect_incoming_call_work);
641 }
642
643 /*
644  * Grab the operation ID from an incoming cache manager call.  The socket
645  * buffer is discarded on error or if we don't yet have sufficient data.
646  */
647 static int afs_deliver_cm_op_id(struct afs_call *call)
648 {
649         int ret;
650
651         _enter("{%zu}", call->offset);
652
653         ASSERTCMP(call->offset, <, 4);
654
655         /* the operation ID forms the first four bytes of the request data */
656         ret = afs_extract_data(call, &call->operation_ID, 4, true);
657         if (ret < 0)
658                 return ret;
659
660         call->state = AFS_CALL_AWAIT_REQUEST;
661         call->offset = 0;
662
663         /* ask the cache manager to route the call (it'll change the call type
664          * if successful) */
665         if (!afs_cm_incoming_call(call))
666                 return -ENOTSUPP;
667
668         /* pass responsibility for the remainer of this message off to the
669          * cache manager op */
670         return call->type->deliver(call);
671 }
672
673 /*
674  * send an empty reply
675  */
676 void afs_send_empty_reply(struct afs_call *call)
677 {
678         struct msghdr msg;
679
680         _enter("");
681
682         msg.msg_name            = NULL;
683         msg.msg_namelen         = 0;
684         iov_iter_kvec(&msg.msg_iter, WRITE | ITER_KVEC, NULL, 0, 0);
685         msg.msg_control         = NULL;
686         msg.msg_controllen      = 0;
687         msg.msg_flags           = 0;
688
689         call->state = AFS_CALL_AWAIT_ACK;
690         switch (rxrpc_kernel_send_data(afs_socket, call->rxcall, &msg, 0)) {
691         case 0:
692                 _leave(" [replied]");
693                 return;
694
695         case -ENOMEM:
696                 _debug("oom");
697                 rxrpc_kernel_abort_call(afs_socket, call->rxcall,
698                                         RX_USER_ABORT);
699         default:
700                 afs_end_call(call);
701                 _leave(" [error]");
702                 return;
703         }
704 }
705
706 /*
707  * send a simple reply
708  */
709 void afs_send_simple_reply(struct afs_call *call, const void *buf, size_t len)
710 {
711         struct msghdr msg;
712         struct kvec iov[1];
713         int n;
714
715         _enter("");
716
717         iov[0].iov_base         = (void *) buf;
718         iov[0].iov_len          = len;
719         msg.msg_name            = NULL;
720         msg.msg_namelen         = 0;
721         iov_iter_kvec(&msg.msg_iter, WRITE | ITER_KVEC, iov, 1, len);
722         msg.msg_control         = NULL;
723         msg.msg_controllen      = 0;
724         msg.msg_flags           = 0;
725
726         call->state = AFS_CALL_AWAIT_ACK;
727         n = rxrpc_kernel_send_data(afs_socket, call->rxcall, &msg, len);
728         if (n >= 0) {
729                 /* Success */
730                 _leave(" [replied]");
731                 return;
732         }
733
734         if (n == -ENOMEM) {
735                 _debug("oom");
736                 rxrpc_kernel_abort_call(afs_socket, call->rxcall,
737                                         RX_USER_ABORT);
738         }
739         afs_end_call(call);
740         _leave(" [error]");
741 }
742
743 /*
744  * Extract a piece of data from the received data socket buffers.
745  */
746 int afs_extract_data(struct afs_call *call, void *buf, size_t count,
747                      bool want_more)
748 {
749         int ret;
750
751         _enter("{%s,%zu},,%zu,%d",
752                call->type->name, call->offset, count, want_more);
753
754         ASSERTCMP(call->offset, <=, count);
755
756         ret = rxrpc_kernel_recv_data(afs_socket, call->rxcall,
757                                      buf, count, &call->offset,
758                                      want_more, &call->abort_code);
759         if (ret == 0 || ret == -EAGAIN)
760                 return ret;
761
762         if (ret == 1) {
763                 switch (call->state) {
764                 case AFS_CALL_AWAIT_REPLY:
765                         call->state = AFS_CALL_COMPLETE;
766                         break;
767                 case AFS_CALL_AWAIT_REQUEST:
768                         call->state = AFS_CALL_REPLYING;
769                         break;
770                 default:
771                         break;
772                 }
773                 return 0;
774         }
775
776         if (ret == -ECONNABORTED)
777                 call->error = call->type->abort_to_error(call->abort_code);
778         else
779                 call->error = ret;
780         call->state = AFS_CALL_COMPLETE;
781         return ret;
782 }