]>
Commit | Line | Data |
---|---|---|
08e0e7c8 DH |
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 | ||
5a0e3ad6 | 12 | #include <linux/slab.h> |
174cd4b1 IM |
13 | #include <linux/sched/signal.h> |
14 | ||
08e0e7c8 DH |
15 | #include <net/sock.h> |
16 | #include <net/af_rxrpc.h> | |
08e0e7c8 DH |
17 | #include "internal.h" |
18 | #include "afs_cm.h" | |
35dbfba3 | 19 | #include "protocol_yfs.h" |
08e0e7c8 | 20 | |
f044c884 | 21 | struct workqueue_struct *afs_async_calls; |
08e0e7c8 | 22 | |
d001648e | 23 | static void afs_wake_up_call_waiter(struct sock *, struct rxrpc_call *, unsigned long); |
d2ddc776 | 24 | static long afs_wait_for_call_to_complete(struct afs_call *, struct afs_addr_cursor *); |
d001648e | 25 | static void afs_wake_up_async_call(struct sock *, struct rxrpc_call *, unsigned long); |
34fa4761 | 26 | static void afs_delete_async_call(struct work_struct *); |
d001648e | 27 | static void afs_process_async_call(struct work_struct *); |
00e90712 DH |
28 | static void afs_rx_new_call(struct sock *, struct rxrpc_call *, unsigned long); |
29 | static void afs_rx_discard_new_call(struct rxrpc_call *, unsigned long); | |
d001648e | 30 | static int afs_deliver_cm_op_id(struct afs_call *); |
08e0e7c8 | 31 | |
08e0e7c8 DH |
32 | /* asynchronous incoming call initial processing */ |
33 | static const struct afs_call_type afs_RXCMxxxx = { | |
00d3b7a4 | 34 | .name = "CB.xxxx", |
08e0e7c8 | 35 | .deliver = afs_deliver_cm_op_id, |
08e0e7c8 DH |
36 | }; |
37 | ||
08e0e7c8 DH |
38 | /* |
39 | * open an RxRPC socket and bind it to be a server for callback notifications | |
40 | * - the socket is left in blocking mode and non-blocking ops use MSG_DONTWAIT | |
41 | */ | |
f044c884 | 42 | int afs_open_socket(struct afs_net *net) |
08e0e7c8 DH |
43 | { |
44 | struct sockaddr_rxrpc srx; | |
45 | struct socket *socket; | |
4776cab4 | 46 | unsigned int min_level; |
08e0e7c8 DH |
47 | int ret; |
48 | ||
49 | _enter(""); | |
50 | ||
5b86d4ff | 51 | ret = sock_create_kern(net->net, AF_RXRPC, SOCK_DGRAM, PF_INET6, &socket); |
0e119b41 DH |
52 | if (ret < 0) |
53 | goto error_1; | |
08e0e7c8 DH |
54 | |
55 | socket->sk->sk_allocation = GFP_NOFS; | |
56 | ||
57 | /* bind the callback manager's address to make this a server socket */ | |
3838d3ec | 58 | memset(&srx, 0, sizeof(srx)); |
08e0e7c8 DH |
59 | srx.srx_family = AF_RXRPC; |
60 | srx.srx_service = CM_SERVICE; | |
61 | srx.transport_type = SOCK_DGRAM; | |
3838d3ec DH |
62 | srx.transport_len = sizeof(srx.transport.sin6); |
63 | srx.transport.sin6.sin6_family = AF_INET6; | |
64 | srx.transport.sin6.sin6_port = htons(AFS_CM_PORT); | |
08e0e7c8 | 65 | |
4776cab4 DH |
66 | min_level = RXRPC_SECURITY_ENCRYPT; |
67 | ret = kernel_setsockopt(socket, SOL_RXRPC, RXRPC_MIN_SECURITY_LEVEL, | |
68 | (void *)&min_level, sizeof(min_level)); | |
69 | if (ret < 0) | |
70 | goto error_2; | |
71 | ||
08e0e7c8 | 72 | ret = kernel_bind(socket, (struct sockaddr *) &srx, sizeof(srx)); |
83732ec5 MD |
73 | if (ret == -EADDRINUSE) { |
74 | srx.transport.sin6.sin6_port = 0; | |
75 | ret = kernel_bind(socket, (struct sockaddr *) &srx, sizeof(srx)); | |
76 | } | |
0e119b41 DH |
77 | if (ret < 0) |
78 | goto error_2; | |
79 | ||
35dbfba3 DH |
80 | srx.srx_service = YFS_CM_SERVICE; |
81 | ret = kernel_bind(socket, (struct sockaddr *) &srx, sizeof(srx)); | |
82 | if (ret < 0) | |
83 | goto error_2; | |
84 | ||
3bf0fb6f DH |
85 | /* Ideally, we'd turn on service upgrade here, but we can't because |
86 | * OpenAFS is buggy and leaks the userStatus field from packet to | |
87 | * packet and between FS packets and CB packets - so if we try to do an | |
88 | * upgrade on an FS packet, OpenAFS will leak that into the CB packet | |
89 | * it sends back to us. | |
90 | */ | |
35dbfba3 | 91 | |
00e90712 DH |
92 | rxrpc_kernel_new_call_notification(socket, afs_rx_new_call, |
93 | afs_rx_discard_new_call); | |
d001648e | 94 | |
0e119b41 DH |
95 | ret = kernel_listen(socket, INT_MAX); |
96 | if (ret < 0) | |
97 | goto error_2; | |
08e0e7c8 | 98 | |
f044c884 DH |
99 | net->socket = socket; |
100 | afs_charge_preallocation(&net->charge_preallocation_work); | |
08e0e7c8 DH |
101 | _leave(" = 0"); |
102 | return 0; | |
0e119b41 DH |
103 | |
104 | error_2: | |
105 | sock_release(socket); | |
106 | error_1: | |
0e119b41 DH |
107 | _leave(" = %d", ret); |
108 | return ret; | |
08e0e7c8 DH |
109 | } |
110 | ||
111 | /* | |
112 | * close the RxRPC socket AFS was using | |
113 | */ | |
f044c884 | 114 | void afs_close_socket(struct afs_net *net) |
08e0e7c8 DH |
115 | { |
116 | _enter(""); | |
117 | ||
f044c884 | 118 | kernel_listen(net->socket, 0); |
341f741f DH |
119 | flush_workqueue(afs_async_calls); |
120 | ||
f044c884 DH |
121 | if (net->spare_incoming_call) { |
122 | afs_put_call(net->spare_incoming_call); | |
123 | net->spare_incoming_call = NULL; | |
00e90712 DH |
124 | } |
125 | ||
f044c884 | 126 | _debug("outstanding %u", atomic_read(&net->nr_outstanding_calls)); |
ab1fbe32 PZ |
127 | wait_var_event(&net->nr_outstanding_calls, |
128 | !atomic_read(&net->nr_outstanding_calls)); | |
2f02f7ae DH |
129 | _debug("no outstanding calls"); |
130 | ||
f044c884 | 131 | kernel_sock_shutdown(net->socket, SHUT_RDWR); |
d001648e | 132 | flush_workqueue(afs_async_calls); |
f044c884 | 133 | sock_release(net->socket); |
08e0e7c8 DH |
134 | |
135 | _debug("dework"); | |
08e0e7c8 DH |
136 | _leave(""); |
137 | } | |
138 | ||
00d3b7a4 | 139 | /* |
341f741f | 140 | * Allocate a call. |
00d3b7a4 | 141 | */ |
f044c884 DH |
142 | static struct afs_call *afs_alloc_call(struct afs_net *net, |
143 | const struct afs_call_type *type, | |
341f741f | 144 | gfp_t gfp) |
00d3b7a4 | 145 | { |
341f741f DH |
146 | struct afs_call *call; |
147 | int o; | |
00d3b7a4 | 148 | |
341f741f DH |
149 | call = kzalloc(sizeof(*call), gfp); |
150 | if (!call) | |
151 | return NULL; | |
00d3b7a4 | 152 | |
341f741f | 153 | call->type = type; |
f044c884 | 154 | call->net = net; |
a25e21f0 | 155 | call->debug_id = atomic_inc_return(&rxrpc_debug_id); |
341f741f DH |
156 | atomic_set(&call->usage, 1); |
157 | INIT_WORK(&call->async_work, afs_process_async_call); | |
158 | init_waitqueue_head(&call->waitq); | |
98bf40cd | 159 | spin_lock_init(&call->state_lock); |
12bdcf33 | 160 | call->_iter = &call->iter; |
2f02f7ae | 161 | |
f044c884 | 162 | o = atomic_inc_return(&net->nr_outstanding_calls); |
341f741f DH |
163 | trace_afs_call(call, afs_call_trace_alloc, 1, o, |
164 | __builtin_return_address(0)); | |
165 | return call; | |
00d3b7a4 DH |
166 | } |
167 | ||
6c67c7c3 | 168 | /* |
341f741f | 169 | * Dispose of a reference on a call. |
6c67c7c3 | 170 | */ |
341f741f | 171 | void afs_put_call(struct afs_call *call) |
6c67c7c3 | 172 | { |
f044c884 | 173 | struct afs_net *net = call->net; |
341f741f | 174 | int n = atomic_dec_return(&call->usage); |
f044c884 | 175 | int o = atomic_read(&net->nr_outstanding_calls); |
341f741f DH |
176 | |
177 | trace_afs_call(call, afs_call_trace_put, n + 1, o, | |
178 | __builtin_return_address(0)); | |
179 | ||
180 | ASSERTCMP(n, >=, 0); | |
181 | if (n == 0) { | |
182 | ASSERT(!work_pending(&call->async_work)); | |
183 | ASSERT(call->type->name != NULL); | |
184 | ||
185 | if (call->rxcall) { | |
f044c884 | 186 | rxrpc_kernel_end_call(net->socket, call->rxcall); |
341f741f DH |
187 | call->rxcall = NULL; |
188 | } | |
189 | if (call->type->destructor) | |
190 | call->type->destructor(call); | |
191 | ||
d0676a16 | 192 | afs_put_server(call->net, call->cm_server); |
d2ddc776 | 193 | afs_put_cb_interest(call->net, call->cbi); |
3bf0fb6f | 194 | afs_put_addrlist(call->alist); |
341f741f | 195 | kfree(call->request); |
341f741f | 196 | |
341f741f DH |
197 | trace_afs_call(call, afs_call_trace_free, 0, o, |
198 | __builtin_return_address(0)); | |
a25e21f0 DH |
199 | kfree(call); |
200 | ||
201 | o = atomic_dec_return(&net->nr_outstanding_calls); | |
341f741f | 202 | if (o == 0) |
ab1fbe32 | 203 | wake_up_var(&net->nr_outstanding_calls); |
6c67c7c3 | 204 | } |
6cf12869 NWF |
205 | } |
206 | ||
7a75b007 DH |
207 | static struct afs_call *afs_get_call(struct afs_call *call, |
208 | enum afs_call_trace why) | |
209 | { | |
210 | int u = atomic_inc_return(&call->usage); | |
211 | ||
212 | trace_afs_call(call, why, u, | |
213 | atomic_read(&call->net->nr_outstanding_calls), | |
214 | __builtin_return_address(0)); | |
215 | return call; | |
216 | } | |
217 | ||
6cf12869 | 218 | /* |
3bf0fb6f | 219 | * Queue the call for actual work. |
6cf12869 | 220 | */ |
3bf0fb6f | 221 | static void afs_queue_call_work(struct afs_call *call) |
6cf12869 | 222 | { |
3bf0fb6f | 223 | if (call->type->work) { |
3bf0fb6f | 224 | INIT_WORK(&call->work, call->type->work); |
341f741f | 225 | |
7a75b007 | 226 | afs_get_call(call, afs_call_trace_work); |
3bf0fb6f DH |
227 | if (!queue_work(afs_wq, &call->work)) |
228 | afs_put_call(call); | |
229 | } | |
6c67c7c3 DH |
230 | } |
231 | ||
08e0e7c8 DH |
232 | /* |
233 | * allocate a call with flat request and reply buffers | |
234 | */ | |
f044c884 DH |
235 | struct afs_call *afs_alloc_flat_call(struct afs_net *net, |
236 | const struct afs_call_type *type, | |
d001648e | 237 | size_t request_size, size_t reply_max) |
08e0e7c8 DH |
238 | { |
239 | struct afs_call *call; | |
240 | ||
f044c884 | 241 | call = afs_alloc_call(net, type, GFP_NOFS); |
08e0e7c8 DH |
242 | if (!call) |
243 | goto nomem_call; | |
244 | ||
245 | if (request_size) { | |
341f741f | 246 | call->request_size = request_size; |
08e0e7c8 DH |
247 | call->request = kmalloc(request_size, GFP_NOFS); |
248 | if (!call->request) | |
00d3b7a4 | 249 | goto nomem_free; |
08e0e7c8 DH |
250 | } |
251 | ||
d001648e | 252 | if (reply_max) { |
341f741f | 253 | call->reply_max = reply_max; |
d001648e | 254 | call->buffer = kmalloc(reply_max, GFP_NOFS); |
08e0e7c8 | 255 | if (!call->buffer) |
00d3b7a4 | 256 | goto nomem_free; |
08e0e7c8 DH |
257 | } |
258 | ||
12bdcf33 | 259 | afs_extract_to_buf(call, call->reply_max); |
025db80c | 260 | call->operation_ID = type->op; |
08e0e7c8 | 261 | init_waitqueue_head(&call->waitq); |
08e0e7c8 DH |
262 | return call; |
263 | ||
00d3b7a4 | 264 | nomem_free: |
341f741f | 265 | afs_put_call(call); |
08e0e7c8 DH |
266 | nomem_call: |
267 | return NULL; | |
268 | } | |
269 | ||
270 | /* | |
271 | * clean up a call with flat buffer | |
272 | */ | |
273 | void afs_flat_call_destructor(struct afs_call *call) | |
274 | { | |
275 | _enter(""); | |
276 | ||
277 | kfree(call->request); | |
278 | call->request = NULL; | |
279 | kfree(call->buffer); | |
280 | call->buffer = NULL; | |
281 | } | |
282 | ||
2f5705a5 DH |
283 | #define AFS_BVEC_MAX 8 |
284 | ||
285 | /* | |
286 | * Load the given bvec with the next few pages. | |
287 | */ | |
288 | static void afs_load_bvec(struct afs_call *call, struct msghdr *msg, | |
289 | struct bio_vec *bv, pgoff_t first, pgoff_t last, | |
290 | unsigned offset) | |
291 | { | |
292 | struct page *pages[AFS_BVEC_MAX]; | |
293 | unsigned int nr, n, i, to, bytes = 0; | |
294 | ||
295 | nr = min_t(pgoff_t, last - first + 1, AFS_BVEC_MAX); | |
296 | n = find_get_pages_contig(call->mapping, first, nr, pages); | |
297 | ASSERTCMP(n, ==, nr); | |
298 | ||
299 | msg->msg_flags |= MSG_MORE; | |
300 | for (i = 0; i < nr; i++) { | |
301 | to = PAGE_SIZE; | |
302 | if (first + i >= last) { | |
303 | to = call->last_to; | |
304 | msg->msg_flags &= ~MSG_MORE; | |
305 | } | |
306 | bv[i].bv_page = pages[i]; | |
307 | bv[i].bv_len = to - offset; | |
308 | bv[i].bv_offset = offset; | |
309 | bytes += to - offset; | |
310 | offset = 0; | |
311 | } | |
312 | ||
aa563d7b | 313 | iov_iter_bvec(&msg->msg_iter, WRITE, bv, nr, bytes); |
2f5705a5 DH |
314 | } |
315 | ||
e833251a DH |
316 | /* |
317 | * Advance the AFS call state when the RxRPC call ends the transmit phase. | |
318 | */ | |
319 | static void afs_notify_end_request_tx(struct sock *sock, | |
320 | struct rxrpc_call *rxcall, | |
321 | unsigned long call_user_ID) | |
322 | { | |
323 | struct afs_call *call = (struct afs_call *)call_user_ID; | |
324 | ||
98bf40cd | 325 | afs_set_call_state(call, AFS_CALL_CL_REQUESTING, AFS_CALL_CL_AWAIT_REPLY); |
e833251a DH |
326 | } |
327 | ||
31143d5d DH |
328 | /* |
329 | * attach the data from a bunch of pages on an inode to a call | |
330 | */ | |
39c6acea | 331 | static int afs_send_pages(struct afs_call *call, struct msghdr *msg) |
31143d5d | 332 | { |
2f5705a5 DH |
333 | struct bio_vec bv[AFS_BVEC_MAX]; |
334 | unsigned int bytes, nr, loop, offset; | |
31143d5d DH |
335 | pgoff_t first = call->first, last = call->last; |
336 | int ret; | |
337 | ||
31143d5d DH |
338 | offset = call->first_offset; |
339 | call->first_offset = 0; | |
340 | ||
341 | do { | |
2f5705a5 | 342 | afs_load_bvec(call, msg, bv, first, last, offset); |
2c099014 DH |
343 | trace_afs_send_pages(call, msg, first, last, offset); |
344 | ||
2f5705a5 DH |
345 | offset = 0; |
346 | bytes = msg->msg_iter.count; | |
347 | nr = msg->msg_iter.nr_segs; | |
348 | ||
f044c884 | 349 | ret = rxrpc_kernel_send_data(call->net->socket, call->rxcall, msg, |
e833251a | 350 | bytes, afs_notify_end_request_tx); |
2f5705a5 DH |
351 | for (loop = 0; loop < nr; loop++) |
352 | put_page(bv[loop].bv_page); | |
31143d5d DH |
353 | if (ret < 0) |
354 | break; | |
2f5705a5 DH |
355 | |
356 | first += nr; | |
5bbf5d39 | 357 | } while (first <= last); |
31143d5d | 358 | |
2c099014 | 359 | trace_afs_sent_pages(call, call->first, last, first, ret); |
31143d5d DH |
360 | return ret; |
361 | } | |
362 | ||
08e0e7c8 DH |
363 | /* |
364 | * initiate a call | |
365 | */ | |
8b2a464c | 366 | long afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call, |
33cd7f2b | 367 | gfp_t gfp, bool async) |
08e0e7c8 | 368 | { |
2feeaf84 | 369 | struct sockaddr_rxrpc *srx = &ac->alist->addrs[ac->index]; |
08e0e7c8 DH |
370 | struct rxrpc_call *rxcall; |
371 | struct msghdr msg; | |
372 | struct kvec iov[1]; | |
e754eba6 | 373 | s64 tx_total_len; |
08e0e7c8 DH |
374 | int ret; |
375 | ||
4d9df986 | 376 | _enter(",{%pISp},", &srx->transport); |
08e0e7c8 | 377 | |
00d3b7a4 DH |
378 | ASSERT(call->type != NULL); |
379 | ASSERT(call->type->name != NULL); | |
380 | ||
31143d5d DH |
381 | _debug("____MAKE %p{%s,%x} [%d]____", |
382 | call, call->type->name, key_serial(call->key), | |
f044c884 | 383 | atomic_read(&call->net->nr_outstanding_calls)); |
00d3b7a4 | 384 | |
56ff9c83 | 385 | call->async = async; |
3bf0fb6f DH |
386 | call->addr_ix = ac->index; |
387 | call->alist = afs_get_addrlist(ac->alist); | |
08e0e7c8 | 388 | |
e754eba6 DH |
389 | /* Work out the length we're going to transmit. This is awkward for |
390 | * calls such as FS.StoreData where there's an extra injection of data | |
391 | * after the initial fixed part. | |
392 | */ | |
393 | tx_total_len = call->request_size; | |
394 | if (call->send_pages) { | |
1199db60 DH |
395 | if (call->last == call->first) { |
396 | tx_total_len += call->last_to - call->first_offset; | |
397 | } else { | |
398 | /* It looks mathematically like you should be able to | |
399 | * combine the following lines with the ones above, but | |
400 | * unsigned arithmetic is fun when it wraps... | |
401 | */ | |
402 | tx_total_len += PAGE_SIZE - call->first_offset; | |
403 | tx_total_len += call->last_to; | |
404 | tx_total_len += (call->last - call->first - 1) * PAGE_SIZE; | |
405 | } | |
e754eba6 DH |
406 | } |
407 | ||
34fa4761 DH |
408 | /* If the call is going to be asynchronous, we need an extra ref for |
409 | * the call to hold itself so the caller need not hang on to its ref. | |
410 | */ | |
411 | if (call->async) | |
412 | afs_get_call(call, afs_call_trace_get); | |
413 | ||
08e0e7c8 | 414 | /* create a call */ |
4d9df986 | 415 | rxcall = rxrpc_kernel_begin_call(call->net->socket, srx, call->key, |
e754eba6 DH |
416 | (unsigned long)call, |
417 | tx_total_len, gfp, | |
56ff9c83 DH |
418 | (async ? |
419 | afs_wake_up_async_call : | |
a68f4a27 | 420 | afs_wake_up_call_waiter), |
a25e21f0 DH |
421 | call->upgrade, |
422 | call->debug_id); | |
08e0e7c8 DH |
423 | if (IS_ERR(rxcall)) { |
424 | ret = PTR_ERR(rxcall); | |
3bf0fb6f | 425 | call->error = ret; |
08e0e7c8 DH |
426 | goto error_kill_call; |
427 | } | |
428 | ||
429 | call->rxcall = rxcall; | |
430 | ||
431 | /* send the request */ | |
432 | iov[0].iov_base = call->request; | |
433 | iov[0].iov_len = call->request_size; | |
434 | ||
435 | msg.msg_name = NULL; | |
436 | msg.msg_namelen = 0; | |
aa563d7b | 437 | iov_iter_kvec(&msg.msg_iter, WRITE, iov, 1, call->request_size); |
08e0e7c8 DH |
438 | msg.msg_control = NULL; |
439 | msg.msg_controllen = 0; | |
bc5e3a54 | 440 | msg.msg_flags = MSG_WAITALL | (call->send_pages ? MSG_MORE : 0); |
08e0e7c8 | 441 | |
f044c884 | 442 | ret = rxrpc_kernel_send_data(call->net->socket, rxcall, |
e833251a DH |
443 | &msg, call->request_size, |
444 | afs_notify_end_request_tx); | |
08e0e7c8 DH |
445 | if (ret < 0) |
446 | goto error_do_abort; | |
447 | ||
31143d5d | 448 | if (call->send_pages) { |
39c6acea | 449 | ret = afs_send_pages(call, &msg); |
31143d5d DH |
450 | if (ret < 0) |
451 | goto error_do_abort; | |
452 | } | |
453 | ||
34fa4761 DH |
454 | /* Note that at this point, we may have received the reply or an abort |
455 | * - and an asynchronous call may already have completed. | |
456 | */ | |
457 | if (call->async) { | |
458 | afs_put_call(call); | |
56ff9c83 | 459 | return -EINPROGRESS; |
34fa4761 | 460 | } |
56ff9c83 | 461 | |
d2ddc776 | 462 | return afs_wait_for_call_to_complete(call, ac); |
08e0e7c8 DH |
463 | |
464 | error_do_abort: | |
70af0e3b | 465 | if (ret != -ECONNABORTED) { |
f044c884 DH |
466 | rxrpc_kernel_abort_call(call->net->socket, rxcall, |
467 | RX_USER_ABORT, ret, "KSD"); | |
70af0e3b | 468 | } else { |
aa563d7b | 469 | iov_iter_kvec(&msg.msg_iter, READ, NULL, 0, 0); |
eb9950eb DH |
470 | rxrpc_kernel_recv_data(call->net->socket, rxcall, |
471 | &msg.msg_iter, false, | |
472 | &call->abort_code, &call->service_id); | |
d2ddc776 DH |
473 | ac->abort_code = call->abort_code; |
474 | ac->responded = true; | |
70af0e3b | 475 | } |
025db80c DH |
476 | call->error = ret; |
477 | trace_afs_call_done(call); | |
08e0e7c8 | 478 | error_kill_call: |
3bf0fb6f DH |
479 | if (call->type->done) |
480 | call->type->done(call); | |
34fa4761 DH |
481 | |
482 | /* We need to dispose of the extra ref we grabbed for an async call. | |
483 | * The call, however, might be queued on afs_async_calls and we need to | |
484 | * make sure we don't get any more notifications that might requeue it. | |
485 | */ | |
486 | if (call->rxcall) { | |
487 | rxrpc_kernel_end_call(call->net->socket, call->rxcall); | |
488 | call->rxcall = NULL; | |
489 | } | |
490 | if (call->async) { | |
491 | if (cancel_work_sync(&call->async_work)) | |
492 | afs_put_call(call); | |
493 | afs_put_call(call); | |
494 | } | |
495 | ||
d2ddc776 | 496 | ac->error = ret; |
34fa4761 DH |
497 | call->state = AFS_CALL_COMPLETE; |
498 | afs_put_call(call); | |
08e0e7c8 DH |
499 | _leave(" = %d", ret); |
500 | return ret; | |
501 | } | |
502 | ||
08e0e7c8 DH |
503 | /* |
504 | * deliver messages to a call | |
505 | */ | |
506 | static void afs_deliver_to_call(struct afs_call *call) | |
507 | { | |
98bf40cd DH |
508 | enum afs_call_state state; |
509 | u32 abort_code, remote_abort = 0; | |
08e0e7c8 DH |
510 | int ret; |
511 | ||
d001648e DH |
512 | _enter("%s", call->type->name); |
513 | ||
98bf40cd DH |
514 | while (state = READ_ONCE(call->state), |
515 | state == AFS_CALL_CL_AWAIT_REPLY || | |
516 | state == AFS_CALL_SV_AWAIT_OP_ID || | |
517 | state == AFS_CALL_SV_AWAIT_REQUEST || | |
518 | state == AFS_CALL_SV_AWAIT_ACK | |
d001648e | 519 | ) { |
98bf40cd | 520 | if (state == AFS_CALL_SV_AWAIT_ACK) { |
12bdcf33 | 521 | iov_iter_kvec(&call->iter, READ, NULL, 0, 0); |
f044c884 | 522 | ret = rxrpc_kernel_recv_data(call->net->socket, |
12bdcf33 DH |
523 | call->rxcall, &call->iter, |
524 | false, &remote_abort, | |
a68f4a27 | 525 | &call->service_id); |
12bdcf33 | 526 | trace_afs_receive_data(call, &call->iter, false, ret); |
8e8d7f13 | 527 | |
d001648e DH |
528 | if (ret == -EINPROGRESS || ret == -EAGAIN) |
529 | return; | |
98bf40cd DH |
530 | if (ret < 0 || ret == 1) { |
531 | if (ret == 1) | |
532 | ret = 0; | |
025db80c | 533 | goto call_complete; |
98bf40cd | 534 | } |
d001648e | 535 | return; |
08e0e7c8 DH |
536 | } |
537 | ||
12d8e95a DH |
538 | if (call->want_reply_time && |
539 | rxrpc_kernel_get_reply_time(call->net->socket, | |
540 | call->rxcall, | |
541 | &call->reply_time)) | |
542 | call->want_reply_time = false; | |
543 | ||
d001648e | 544 | ret = call->type->deliver(call); |
98bf40cd | 545 | state = READ_ONCE(call->state); |
d001648e DH |
546 | switch (ret) { |
547 | case 0: | |
3bf0fb6f | 548 | afs_queue_call_work(call); |
f2686b09 DH |
549 | if (state == AFS_CALL_CL_PROC_REPLY) { |
550 | if (call->cbi) | |
551 | set_bit(AFS_SERVER_FL_MAY_HAVE_CB, | |
552 | &call->cbi->server->flags); | |
025db80c | 553 | goto call_complete; |
f2686b09 | 554 | } |
98bf40cd | 555 | ASSERTCMP(state, >, AFS_CALL_CL_PROC_REPLY); |
d001648e DH |
556 | goto done; |
557 | case -EINPROGRESS: | |
558 | case -EAGAIN: | |
559 | goto out; | |
70af0e3b | 560 | case -ECONNABORTED: |
98bf40cd DH |
561 | ASSERTCMP(state, ==, AFS_CALL_COMPLETE); |
562 | goto done; | |
d001648e | 563 | case -ENOTSUPP: |
1157f153 | 564 | abort_code = RXGEN_OPCODE; |
f044c884 | 565 | rxrpc_kernel_abort_call(call->net->socket, call->rxcall, |
3a92789a | 566 | abort_code, ret, "KIV"); |
98bf40cd | 567 | goto local_abort; |
4ac15ea5 DH |
568 | case -EIO: |
569 | pr_err("kAFS: Call %u in bad state %u\n", | |
570 | call->debug_id, state); | |
571 | /* Fall through */ | |
d001648e DH |
572 | case -ENODATA: |
573 | case -EBADMSG: | |
574 | case -EMSGSIZE: | |
575 | default: | |
576 | abort_code = RXGEN_CC_UNMARSHAL; | |
98bf40cd | 577 | if (state != AFS_CALL_CL_AWAIT_REPLY) |
d001648e | 578 | abort_code = RXGEN_SS_UNMARSHAL; |
f044c884 | 579 | rxrpc_kernel_abort_call(call->net->socket, call->rxcall, |
12bdcf33 | 580 | abort_code, ret, "KUM"); |
98bf40cd | 581 | goto local_abort; |
d001648e | 582 | } |
08e0e7c8 DH |
583 | } |
584 | ||
d001648e | 585 | done: |
3bf0fb6f DH |
586 | if (call->type->done) |
587 | call->type->done(call); | |
98bf40cd | 588 | if (state == AFS_CALL_COMPLETE && call->incoming) |
341f741f | 589 | afs_put_call(call); |
d001648e | 590 | out: |
08e0e7c8 | 591 | _leave(""); |
d001648e DH |
592 | return; |
593 | ||
98bf40cd DH |
594 | local_abort: |
595 | abort_code = 0; | |
025db80c | 596 | call_complete: |
98bf40cd DH |
597 | afs_set_call_complete(call, ret, remote_abort); |
598 | state = AFS_CALL_COMPLETE; | |
d001648e | 599 | goto done; |
08e0e7c8 DH |
600 | } |
601 | ||
602 | /* | |
603 | * wait synchronously for a call to complete | |
604 | */ | |
d2ddc776 DH |
605 | static long afs_wait_for_call_to_complete(struct afs_call *call, |
606 | struct afs_addr_cursor *ac) | |
08e0e7c8 | 607 | { |
bc5e3a54 | 608 | signed long rtt2, timeout; |
33cd7f2b | 609 | long ret; |
7150ceaa | 610 | bool stalled = false; |
bc5e3a54 DH |
611 | u64 rtt; |
612 | u32 life, last_life; | |
f7f1dd31 | 613 | bool rxrpc_complete = false; |
08e0e7c8 DH |
614 | |
615 | DECLARE_WAITQUEUE(myself, current); | |
616 | ||
617 | _enter(""); | |
618 | ||
f044c884 | 619 | rtt = rxrpc_kernel_get_rtt(call->net->socket, call->rxcall); |
bc5e3a54 DH |
620 | rtt2 = nsecs_to_jiffies64(rtt) * 2; |
621 | if (rtt2 < 2) | |
622 | rtt2 = 2; | |
623 | ||
624 | timeout = rtt2; | |
4611da30 | 625 | rxrpc_kernel_check_life(call->net->socket, call->rxcall, &last_life); |
bc5e3a54 | 626 | |
08e0e7c8 DH |
627 | add_wait_queue(&call->waitq, &myself); |
628 | for (;;) { | |
bc5e3a54 | 629 | set_current_state(TASK_UNINTERRUPTIBLE); |
08e0e7c8 DH |
630 | |
631 | /* deliver any messages that are in the queue */ | |
98bf40cd DH |
632 | if (!afs_check_call_state(call, AFS_CALL_COMPLETE) && |
633 | call->need_attention) { | |
d001648e | 634 | call->need_attention = false; |
08e0e7c8 DH |
635 | __set_current_state(TASK_RUNNING); |
636 | afs_deliver_to_call(call); | |
637 | continue; | |
638 | } | |
639 | ||
98bf40cd | 640 | if (afs_check_call_state(call, AFS_CALL_COMPLETE)) |
08e0e7c8 | 641 | break; |
bc5e3a54 | 642 | |
f7f1dd31 MD |
643 | if (!rxrpc_kernel_check_life(call->net->socket, call->rxcall, &life)) { |
644 | /* rxrpc terminated the call. */ | |
645 | rxrpc_complete = true; | |
646 | break; | |
647 | } | |
648 | ||
bc5e3a54 | 649 | if (timeout == 0 && |
7150ceaa DH |
650 | life == last_life && signal_pending(current)) { |
651 | if (stalled) | |
bc5e3a54 | 652 | break; |
7150ceaa DH |
653 | __set_current_state(TASK_RUNNING); |
654 | rxrpc_kernel_probe_life(call->net->socket, call->rxcall); | |
655 | timeout = rtt2; | |
656 | stalled = true; | |
657 | continue; | |
658 | } | |
bc5e3a54 DH |
659 | |
660 | if (life != last_life) { | |
661 | timeout = rtt2; | |
662 | last_life = life; | |
7150ceaa | 663 | stalled = false; |
bc5e3a54 DH |
664 | } |
665 | ||
666 | timeout = schedule_timeout(timeout); | |
08e0e7c8 DH |
667 | } |
668 | ||
669 | remove_wait_queue(&call->waitq, &myself); | |
670 | __set_current_state(TASK_RUNNING); | |
671 | ||
98bf40cd | 672 | if (!afs_check_call_state(call, AFS_CALL_COMPLETE)) { |
f7f1dd31 MD |
673 | if (rxrpc_complete) { |
674 | afs_set_call_complete(call, call->error, call->abort_code); | |
675 | } else { | |
676 | /* Kill off the call if it's still live. */ | |
677 | _debug("call interrupted"); | |
678 | if (rxrpc_kernel_abort_call(call->net->socket, call->rxcall, | |
679 | RX_USER_ABORT, -EINTR, "KWI")) | |
680 | afs_set_call_complete(call, -EINTR, 0); | |
681 | } | |
08e0e7c8 DH |
682 | } |
683 | ||
98bf40cd | 684 | spin_lock_bh(&call->state_lock); |
d2ddc776 DH |
685 | ac->abort_code = call->abort_code; |
686 | ac->error = call->error; | |
98bf40cd | 687 | spin_unlock_bh(&call->state_lock); |
d2ddc776 DH |
688 | |
689 | ret = ac->error; | |
690 | switch (ret) { | |
691 | case 0: | |
692 | if (call->ret_reply0) { | |
693 | ret = (long)call->reply[0]; | |
694 | call->reply[0] = NULL; | |
695 | } | |
696 | /* Fall through */ | |
697 | case -ECONNABORTED: | |
698 | ac->responded = true; | |
699 | break; | |
33cd7f2b DH |
700 | } |
701 | ||
08e0e7c8 | 702 | _debug("call complete"); |
341f741f | 703 | afs_put_call(call); |
33cd7f2b | 704 | _leave(" = %p", (void *)ret); |
08e0e7c8 DH |
705 | return ret; |
706 | } | |
707 | ||
708 | /* | |
709 | * wake up a waiting call | |
710 | */ | |
d001648e DH |
711 | static void afs_wake_up_call_waiter(struct sock *sk, struct rxrpc_call *rxcall, |
712 | unsigned long call_user_ID) | |
08e0e7c8 | 713 | { |
d001648e DH |
714 | struct afs_call *call = (struct afs_call *)call_user_ID; |
715 | ||
716 | call->need_attention = true; | |
08e0e7c8 DH |
717 | wake_up(&call->waitq); |
718 | } | |
719 | ||
720 | /* | |
721 | * wake up an asynchronous call | |
722 | */ | |
d001648e DH |
723 | static void afs_wake_up_async_call(struct sock *sk, struct rxrpc_call *rxcall, |
724 | unsigned long call_user_ID) | |
08e0e7c8 | 725 | { |
d001648e | 726 | struct afs_call *call = (struct afs_call *)call_user_ID; |
341f741f | 727 | int u; |
d001648e | 728 | |
8e8d7f13 | 729 | trace_afs_notify_call(rxcall, call); |
d001648e | 730 | call->need_attention = true; |
341f741f | 731 | |
bfc18e38 | 732 | u = atomic_fetch_add_unless(&call->usage, 1, 0); |
341f741f DH |
733 | if (u != 0) { |
734 | trace_afs_call(call, afs_call_trace_wake, u, | |
f044c884 | 735 | atomic_read(&call->net->nr_outstanding_calls), |
341f741f DH |
736 | __builtin_return_address(0)); |
737 | ||
738 | if (!queue_work(afs_async_calls, &call->async_work)) | |
739 | afs_put_call(call); | |
740 | } | |
08e0e7c8 DH |
741 | } |
742 | ||
08e0e7c8 | 743 | /* |
341f741f DH |
744 | * Delete an asynchronous call. The work item carries a ref to the call struct |
745 | * that we need to release. | |
08e0e7c8 | 746 | */ |
d001648e | 747 | static void afs_delete_async_call(struct work_struct *work) |
08e0e7c8 | 748 | { |
d001648e DH |
749 | struct afs_call *call = container_of(work, struct afs_call, async_work); |
750 | ||
08e0e7c8 DH |
751 | _enter(""); |
752 | ||
341f741f | 753 | afs_put_call(call); |
08e0e7c8 DH |
754 | |
755 | _leave(""); | |
756 | } | |
757 | ||
758 | /* | |
341f741f DH |
759 | * Perform I/O processing on an asynchronous call. The work item carries a ref |
760 | * to the call struct that we either need to release or to pass on. | |
08e0e7c8 | 761 | */ |
d001648e | 762 | static void afs_process_async_call(struct work_struct *work) |
08e0e7c8 | 763 | { |
d001648e DH |
764 | struct afs_call *call = container_of(work, struct afs_call, async_work); |
765 | ||
08e0e7c8 DH |
766 | _enter(""); |
767 | ||
d001648e DH |
768 | if (call->state < AFS_CALL_COMPLETE && call->need_attention) { |
769 | call->need_attention = false; | |
08e0e7c8 | 770 | afs_deliver_to_call(call); |
d001648e | 771 | } |
08e0e7c8 | 772 | |
56ff9c83 | 773 | if (call->state == AFS_CALL_COMPLETE) { |
341f741f DH |
774 | /* We have two refs to release - one from the alloc and one |
775 | * queued with the work item - and we can't just deallocate the | |
776 | * call because the work item may be queued again. | |
777 | */ | |
d001648e | 778 | call->async_work.func = afs_delete_async_call; |
341f741f DH |
779 | if (!queue_work(afs_async_calls, &call->async_work)) |
780 | afs_put_call(call); | |
08e0e7c8 DH |
781 | } |
782 | ||
341f741f | 783 | afs_put_call(call); |
08e0e7c8 DH |
784 | _leave(""); |
785 | } | |
786 | ||
00e90712 DH |
787 | static void afs_rx_attach(struct rxrpc_call *rxcall, unsigned long user_call_ID) |
788 | { | |
789 | struct afs_call *call = (struct afs_call *)user_call_ID; | |
790 | ||
791 | call->rxcall = rxcall; | |
792 | } | |
793 | ||
794 | /* | |
795 | * Charge the incoming call preallocation. | |
796 | */ | |
f044c884 | 797 | void afs_charge_preallocation(struct work_struct *work) |
00e90712 | 798 | { |
f044c884 DH |
799 | struct afs_net *net = |
800 | container_of(work, struct afs_net, charge_preallocation_work); | |
801 | struct afs_call *call = net->spare_incoming_call; | |
00e90712 DH |
802 | |
803 | for (;;) { | |
804 | if (!call) { | |
f044c884 | 805 | call = afs_alloc_call(net, &afs_RXCMxxxx, GFP_KERNEL); |
00e90712 DH |
806 | if (!call) |
807 | break; | |
808 | ||
56ff9c83 | 809 | call->async = true; |
98bf40cd | 810 | call->state = AFS_CALL_SV_AWAIT_OP_ID; |
56ff9c83 | 811 | init_waitqueue_head(&call->waitq); |
12bdcf33 | 812 | afs_extract_to_tmp(call); |
00e90712 DH |
813 | } |
814 | ||
f044c884 | 815 | if (rxrpc_kernel_charge_accept(net->socket, |
00e90712 DH |
816 | afs_wake_up_async_call, |
817 | afs_rx_attach, | |
818 | (unsigned long)call, | |
a25e21f0 DH |
819 | GFP_KERNEL, |
820 | call->debug_id) < 0) | |
00e90712 DH |
821 | break; |
822 | call = NULL; | |
823 | } | |
f044c884 | 824 | net->spare_incoming_call = call; |
00e90712 DH |
825 | } |
826 | ||
827 | /* | |
828 | * Discard a preallocated call when a socket is shut down. | |
829 | */ | |
830 | static void afs_rx_discard_new_call(struct rxrpc_call *rxcall, | |
831 | unsigned long user_call_ID) | |
832 | { | |
833 | struct afs_call *call = (struct afs_call *)user_call_ID; | |
834 | ||
00e90712 | 835 | call->rxcall = NULL; |
341f741f | 836 | afs_put_call(call); |
00e90712 DH |
837 | } |
838 | ||
d001648e DH |
839 | /* |
840 | * Notification of an incoming call. | |
841 | */ | |
00e90712 DH |
842 | static void afs_rx_new_call(struct sock *sk, struct rxrpc_call *rxcall, |
843 | unsigned long user_call_ID) | |
d001648e | 844 | { |
f044c884 DH |
845 | struct afs_net *net = afs_sock2net(sk); |
846 | ||
847 | queue_work(afs_wq, &net->charge_preallocation_work); | |
d001648e DH |
848 | } |
849 | ||
08e0e7c8 | 850 | /* |
372ee163 DH |
851 | * Grab the operation ID from an incoming cache manager call. The socket |
852 | * buffer is discarded on error or if we don't yet have sufficient data. | |
08e0e7c8 | 853 | */ |
d001648e | 854 | static int afs_deliver_cm_op_id(struct afs_call *call) |
08e0e7c8 | 855 | { |
d001648e | 856 | int ret; |
08e0e7c8 | 857 | |
12bdcf33 | 858 | _enter("{%zu}", iov_iter_count(call->_iter)); |
08e0e7c8 DH |
859 | |
860 | /* the operation ID forms the first four bytes of the request data */ | |
12bdcf33 | 861 | ret = afs_extract_data(call, true); |
d001648e DH |
862 | if (ret < 0) |
863 | return ret; | |
08e0e7c8 | 864 | |
50a2c953 | 865 | call->operation_ID = ntohl(call->tmp); |
98bf40cd | 866 | afs_set_call_state(call, AFS_CALL_SV_AWAIT_OP_ID, AFS_CALL_SV_AWAIT_REQUEST); |
08e0e7c8 DH |
867 | |
868 | /* ask the cache manager to route the call (it'll change the call type | |
869 | * if successful) */ | |
870 | if (!afs_cm_incoming_call(call)) | |
871 | return -ENOTSUPP; | |
872 | ||
8e8d7f13 DH |
873 | trace_afs_cb_call(call); |
874 | ||
08e0e7c8 DH |
875 | /* pass responsibility for the remainer of this message off to the |
876 | * cache manager op */ | |
d001648e | 877 | return call->type->deliver(call); |
08e0e7c8 DH |
878 | } |
879 | ||
e833251a DH |
880 | /* |
881 | * Advance the AFS call state when an RxRPC service call ends the transmit | |
882 | * phase. | |
883 | */ | |
884 | static void afs_notify_end_reply_tx(struct sock *sock, | |
885 | struct rxrpc_call *rxcall, | |
886 | unsigned long call_user_ID) | |
887 | { | |
888 | struct afs_call *call = (struct afs_call *)call_user_ID; | |
889 | ||
98bf40cd | 890 | afs_set_call_state(call, AFS_CALL_SV_REPLYING, AFS_CALL_SV_AWAIT_ACK); |
e833251a DH |
891 | } |
892 | ||
08e0e7c8 DH |
893 | /* |
894 | * send an empty reply | |
895 | */ | |
896 | void afs_send_empty_reply(struct afs_call *call) | |
897 | { | |
f044c884 | 898 | struct afs_net *net = call->net; |
08e0e7c8 | 899 | struct msghdr msg; |
08e0e7c8 DH |
900 | |
901 | _enter(""); | |
902 | ||
f044c884 | 903 | rxrpc_kernel_set_tx_length(net->socket, call->rxcall, 0); |
e754eba6 | 904 | |
08e0e7c8 DH |
905 | msg.msg_name = NULL; |
906 | msg.msg_namelen = 0; | |
aa563d7b | 907 | iov_iter_kvec(&msg.msg_iter, WRITE, NULL, 0, 0); |
08e0e7c8 DH |
908 | msg.msg_control = NULL; |
909 | msg.msg_controllen = 0; | |
910 | msg.msg_flags = 0; | |
911 | ||
f044c884 | 912 | switch (rxrpc_kernel_send_data(net->socket, call->rxcall, &msg, 0, |
e833251a | 913 | afs_notify_end_reply_tx)) { |
08e0e7c8 DH |
914 | case 0: |
915 | _leave(" [replied]"); | |
916 | return; | |
917 | ||
918 | case -ENOMEM: | |
919 | _debug("oom"); | |
f044c884 | 920 | rxrpc_kernel_abort_call(net->socket, call->rxcall, |
3a92789a | 921 | RX_USER_ABORT, -ENOMEM, "KOO"); |
08e0e7c8 | 922 | default: |
08e0e7c8 DH |
923 | _leave(" [error]"); |
924 | return; | |
925 | } | |
926 | } | |
927 | ||
b908fe6b DH |
928 | /* |
929 | * send a simple reply | |
930 | */ | |
931 | void afs_send_simple_reply(struct afs_call *call, const void *buf, size_t len) | |
932 | { | |
f044c884 | 933 | struct afs_net *net = call->net; |
b908fe6b | 934 | struct msghdr msg; |
2e90b1c4 | 935 | struct kvec iov[1]; |
bd6dc742 | 936 | int n; |
b908fe6b DH |
937 | |
938 | _enter(""); | |
939 | ||
f044c884 | 940 | rxrpc_kernel_set_tx_length(net->socket, call->rxcall, len); |
e754eba6 | 941 | |
b908fe6b DH |
942 | iov[0].iov_base = (void *) buf; |
943 | iov[0].iov_len = len; | |
944 | msg.msg_name = NULL; | |
945 | msg.msg_namelen = 0; | |
aa563d7b | 946 | iov_iter_kvec(&msg.msg_iter, WRITE, iov, 1, len); |
b908fe6b DH |
947 | msg.msg_control = NULL; |
948 | msg.msg_controllen = 0; | |
949 | msg.msg_flags = 0; | |
950 | ||
f044c884 | 951 | n = rxrpc_kernel_send_data(net->socket, call->rxcall, &msg, len, |
e833251a | 952 | afs_notify_end_reply_tx); |
bd6dc742 | 953 | if (n >= 0) { |
6c67c7c3 | 954 | /* Success */ |
b908fe6b DH |
955 | _leave(" [replied]"); |
956 | return; | |
bd6dc742 | 957 | } |
6c67c7c3 | 958 | |
bd6dc742 | 959 | if (n == -ENOMEM) { |
b908fe6b | 960 | _debug("oom"); |
f044c884 | 961 | rxrpc_kernel_abort_call(net->socket, call->rxcall, |
3a92789a | 962 | RX_USER_ABORT, -ENOMEM, "KOO"); |
b908fe6b | 963 | } |
bd6dc742 | 964 | _leave(" [error]"); |
b908fe6b DH |
965 | } |
966 | ||
08e0e7c8 | 967 | /* |
372ee163 | 968 | * Extract a piece of data from the received data socket buffers. |
08e0e7c8 | 969 | */ |
12bdcf33 | 970 | int afs_extract_data(struct afs_call *call, bool want_more) |
08e0e7c8 | 971 | { |
f044c884 | 972 | struct afs_net *net = call->net; |
12bdcf33 | 973 | struct iov_iter *iter = call->_iter; |
98bf40cd | 974 | enum afs_call_state state; |
7888da95 | 975 | u32 remote_abort = 0; |
d001648e | 976 | int ret; |
08e0e7c8 | 977 | |
12bdcf33 | 978 | _enter("{%s,%zu},%d", call->type->name, iov_iter_count(iter), want_more); |
eb9950eb | 979 | |
12bdcf33 | 980 | ret = rxrpc_kernel_recv_data(net->socket, call->rxcall, iter, |
98bf40cd | 981 | want_more, &remote_abort, |
a68f4a27 | 982 | &call->service_id); |
d001648e DH |
983 | if (ret == 0 || ret == -EAGAIN) |
984 | return ret; | |
08e0e7c8 | 985 | |
98bf40cd | 986 | state = READ_ONCE(call->state); |
d001648e | 987 | if (ret == 1) { |
98bf40cd DH |
988 | switch (state) { |
989 | case AFS_CALL_CL_AWAIT_REPLY: | |
990 | afs_set_call_state(call, state, AFS_CALL_CL_PROC_REPLY); | |
d001648e | 991 | break; |
98bf40cd DH |
992 | case AFS_CALL_SV_AWAIT_REQUEST: |
993 | afs_set_call_state(call, state, AFS_CALL_SV_REPLYING); | |
d001648e | 994 | break; |
98bf40cd DH |
995 | case AFS_CALL_COMPLETE: |
996 | kdebug("prem complete %d", call->error); | |
f51375cd | 997 | return afs_io_error(call, afs_io_error_extract); |
d001648e DH |
998 | default: |
999 | break; | |
1000 | } | |
1001 | return 0; | |
08e0e7c8 | 1002 | } |
d001648e | 1003 | |
98bf40cd | 1004 | afs_set_call_complete(call, ret, remote_abort); |
d001648e | 1005 | return ret; |
08e0e7c8 | 1006 | } |
5f702c8e DH |
1007 | |
1008 | /* | |
1009 | * Log protocol error production. | |
1010 | */ | |
160cb957 DH |
1011 | noinline int afs_protocol_error(struct afs_call *call, int error, |
1012 | enum afs_eproto_cause cause) | |
5f702c8e | 1013 | { |
160cb957 | 1014 | trace_afs_protocol_error(call, error, cause); |
5f702c8e DH |
1015 | return error; |
1016 | } |