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