1 /* Maintain an RxRPC server socket to do AFS communications through
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
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.
12 #include <linux/slab.h>
13 #include <linux/sched/signal.h>
16 #include <net/af_rxrpc.h>
19 #include "protocol_yfs.h"
21 struct workqueue_struct
*afs_async_calls
;
23 static void afs_wake_up_call_waiter(struct sock
*, struct rxrpc_call
*, unsigned long);
24 static long afs_wait_for_call_to_complete(struct afs_call
*, struct afs_addr_cursor
*);
25 static void afs_wake_up_async_call(struct sock
*, struct rxrpc_call
*, unsigned long);
26 static void afs_process_async_call(struct work_struct
*);
27 static void afs_rx_new_call(struct sock
*, struct rxrpc_call
*, unsigned long);
28 static void afs_rx_discard_new_call(struct rxrpc_call
*, unsigned long);
29 static int afs_deliver_cm_op_id(struct afs_call
*);
31 /* asynchronous incoming call initial processing */
32 static const struct afs_call_type afs_RXCMxxxx
= {
34 .deliver
= afs_deliver_cm_op_id
,
38 * open an RxRPC socket and bind it to be a server for callback notifications
39 * - the socket is left in blocking mode and non-blocking ops use MSG_DONTWAIT
41 int afs_open_socket(struct afs_net
*net
)
43 struct sockaddr_rxrpc srx
;
44 struct socket
*socket
;
45 unsigned int min_level
;
50 ret
= sock_create_kern(net
->net
, AF_RXRPC
, SOCK_DGRAM
, PF_INET6
, &socket
);
54 socket
->sk
->sk_allocation
= GFP_NOFS
;
56 /* bind the callback manager's address to make this a server socket */
57 memset(&srx
, 0, sizeof(srx
));
58 srx
.srx_family
= AF_RXRPC
;
59 srx
.srx_service
= CM_SERVICE
;
60 srx
.transport_type
= SOCK_DGRAM
;
61 srx
.transport_len
= sizeof(srx
.transport
.sin6
);
62 srx
.transport
.sin6
.sin6_family
= AF_INET6
;
63 srx
.transport
.sin6
.sin6_port
= htons(AFS_CM_PORT
);
65 min_level
= RXRPC_SECURITY_ENCRYPT
;
66 ret
= kernel_setsockopt(socket
, SOL_RXRPC
, RXRPC_MIN_SECURITY_LEVEL
,
67 (void *)&min_level
, sizeof(min_level
));
71 ret
= kernel_bind(socket
, (struct sockaddr
*) &srx
, sizeof(srx
));
72 if (ret
== -EADDRINUSE
) {
73 srx
.transport
.sin6
.sin6_port
= 0;
74 ret
= kernel_bind(socket
, (struct sockaddr
*) &srx
, sizeof(srx
));
79 srx
.srx_service
= YFS_CM_SERVICE
;
80 ret
= kernel_bind(socket
, (struct sockaddr
*) &srx
, sizeof(srx
));
84 /* Ideally, we'd turn on service upgrade here, but we can't because
85 * OpenAFS is buggy and leaks the userStatus field from packet to
86 * packet and between FS packets and CB packets - so if we try to do an
87 * upgrade on an FS packet, OpenAFS will leak that into the CB packet
88 * it sends back to us.
91 rxrpc_kernel_new_call_notification(socket
, afs_rx_new_call
,
92 afs_rx_discard_new_call
);
94 ret
= kernel_listen(socket
, INT_MAX
);
99 afs_charge_preallocation(&net
->charge_preallocation_work
);
104 sock_release(socket
);
106 _leave(" = %d", ret
);
111 * close the RxRPC socket AFS was using
113 void afs_close_socket(struct afs_net
*net
)
117 kernel_listen(net
->socket
, 0);
118 flush_workqueue(afs_async_calls
);
120 if (net
->spare_incoming_call
) {
121 afs_put_call(net
->spare_incoming_call
);
122 net
->spare_incoming_call
= NULL
;
125 _debug("outstanding %u", atomic_read(&net
->nr_outstanding_calls
));
126 wait_var_event(&net
->nr_outstanding_calls
,
127 !atomic_read(&net
->nr_outstanding_calls
));
128 _debug("no outstanding calls");
130 kernel_sock_shutdown(net
->socket
, SHUT_RDWR
);
131 flush_workqueue(afs_async_calls
);
132 sock_release(net
->socket
);
141 static struct afs_call
*afs_alloc_call(struct afs_net
*net
,
142 const struct afs_call_type
*type
,
145 struct afs_call
*call
;
148 call
= kzalloc(sizeof(*call
), gfp
);
154 call
->debug_id
= atomic_inc_return(&rxrpc_debug_id
);
155 atomic_set(&call
->usage
, 1);
156 INIT_WORK(&call
->async_work
, afs_process_async_call
);
157 init_waitqueue_head(&call
->waitq
);
158 spin_lock_init(&call
->state_lock
);
159 call
->_iter
= &call
->iter
;
161 o
= atomic_inc_return(&net
->nr_outstanding_calls
);
162 trace_afs_call(call
, afs_call_trace_alloc
, 1, o
,
163 __builtin_return_address(0));
168 * Dispose of a reference on a call.
170 void afs_put_call(struct afs_call
*call
)
172 struct afs_net
*net
= call
->net
;
173 int n
= atomic_dec_return(&call
->usage
);
174 int o
= atomic_read(&net
->nr_outstanding_calls
);
176 trace_afs_call(call
, afs_call_trace_put
, n
+ 1, o
,
177 __builtin_return_address(0));
181 ASSERT(!work_pending(&call
->async_work
));
182 ASSERT(call
->type
->name
!= NULL
);
185 rxrpc_kernel_end_call(net
->socket
, call
->rxcall
);
188 if (call
->type
->destructor
)
189 call
->type
->destructor(call
);
191 afs_put_server(call
->net
, call
->cm_server
);
192 afs_put_cb_interest(call
->net
, call
->cbi
);
193 afs_put_addrlist(call
->alist
);
194 kfree(call
->request
);
196 trace_afs_call(call
, afs_call_trace_free
, 0, o
,
197 __builtin_return_address(0));
200 o
= atomic_dec_return(&net
->nr_outstanding_calls
);
202 wake_up_var(&net
->nr_outstanding_calls
);
207 * Queue the call for actual work.
209 static void afs_queue_call_work(struct afs_call
*call
)
211 if (call
->type
->work
) {
212 int u
= atomic_inc_return(&call
->usage
);
214 trace_afs_call(call
, afs_call_trace_work
, u
,
215 atomic_read(&call
->net
->nr_outstanding_calls
),
216 __builtin_return_address(0));
218 INIT_WORK(&call
->work
, call
->type
->work
);
220 if (!queue_work(afs_wq
, &call
->work
))
226 * allocate a call with flat request and reply buffers
228 struct afs_call
*afs_alloc_flat_call(struct afs_net
*net
,
229 const struct afs_call_type
*type
,
230 size_t request_size
, size_t reply_max
)
232 struct afs_call
*call
;
234 call
= afs_alloc_call(net
, type
, GFP_NOFS
);
239 call
->request_size
= request_size
;
240 call
->request
= kmalloc(request_size
, GFP_NOFS
);
246 call
->reply_max
= reply_max
;
247 call
->buffer
= kmalloc(reply_max
, GFP_NOFS
);
252 afs_extract_to_buf(call
, call
->reply_max
);
253 call
->operation_ID
= type
->op
;
254 init_waitqueue_head(&call
->waitq
);
264 * clean up a call with flat buffer
266 void afs_flat_call_destructor(struct afs_call
*call
)
270 kfree(call
->request
);
271 call
->request
= NULL
;
276 #define AFS_BVEC_MAX 8
279 * Load the given bvec with the next few pages.
281 static void afs_load_bvec(struct afs_call
*call
, struct msghdr
*msg
,
282 struct bio_vec
*bv
, pgoff_t first
, pgoff_t last
,
285 struct page
*pages
[AFS_BVEC_MAX
];
286 unsigned int nr
, n
, i
, to
, bytes
= 0;
288 nr
= min_t(pgoff_t
, last
- first
+ 1, AFS_BVEC_MAX
);
289 n
= find_get_pages_contig(call
->mapping
, first
, nr
, pages
);
290 ASSERTCMP(n
, ==, nr
);
292 msg
->msg_flags
|= MSG_MORE
;
293 for (i
= 0; i
< nr
; i
++) {
295 if (first
+ i
>= last
) {
297 msg
->msg_flags
&= ~MSG_MORE
;
299 bv
[i
].bv_page
= pages
[i
];
300 bv
[i
].bv_len
= to
- offset
;
301 bv
[i
].bv_offset
= offset
;
302 bytes
+= to
- offset
;
306 iov_iter_bvec(&msg
->msg_iter
, WRITE
, bv
, nr
, bytes
);
310 * Advance the AFS call state when the RxRPC call ends the transmit phase.
312 static void afs_notify_end_request_tx(struct sock
*sock
,
313 struct rxrpc_call
*rxcall
,
314 unsigned long call_user_ID
)
316 struct afs_call
*call
= (struct afs_call
*)call_user_ID
;
318 afs_set_call_state(call
, AFS_CALL_CL_REQUESTING
, AFS_CALL_CL_AWAIT_REPLY
);
322 * attach the data from a bunch of pages on an inode to a call
324 static int afs_send_pages(struct afs_call
*call
, struct msghdr
*msg
)
326 struct bio_vec bv
[AFS_BVEC_MAX
];
327 unsigned int bytes
, nr
, loop
, offset
;
328 pgoff_t first
= call
->first
, last
= call
->last
;
331 offset
= call
->first_offset
;
332 call
->first_offset
= 0;
335 afs_load_bvec(call
, msg
, bv
, first
, last
, offset
);
336 trace_afs_send_pages(call
, msg
, first
, last
, offset
);
339 bytes
= msg
->msg_iter
.count
;
340 nr
= msg
->msg_iter
.nr_segs
;
342 ret
= rxrpc_kernel_send_data(call
->net
->socket
, call
->rxcall
, msg
,
343 bytes
, afs_notify_end_request_tx
);
344 for (loop
= 0; loop
< nr
; loop
++)
345 put_page(bv
[loop
].bv_page
);
350 } while (first
<= last
);
352 trace_afs_sent_pages(call
, call
->first
, last
, first
, ret
);
359 long afs_make_call(struct afs_addr_cursor
*ac
, struct afs_call
*call
,
360 gfp_t gfp
, bool async
)
362 struct sockaddr_rxrpc
*srx
= &ac
->alist
->addrs
[ac
->index
];
363 struct rxrpc_call
*rxcall
;
369 _enter(",{%pISp},", &srx
->transport
);
371 ASSERT(call
->type
!= NULL
);
372 ASSERT(call
->type
->name
!= NULL
);
374 _debug("____MAKE %p{%s,%x} [%d]____",
375 call
, call
->type
->name
, key_serial(call
->key
),
376 atomic_read(&call
->net
->nr_outstanding_calls
));
379 call
->addr_ix
= ac
->index
;
380 call
->alist
= afs_get_addrlist(ac
->alist
);
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.
386 tx_total_len
= call
->request_size
;
387 if (call
->send_pages
) {
388 if (call
->last
== call
->first
) {
389 tx_total_len
+= call
->last_to
- call
->first_offset
;
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...
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
;
402 rxcall
= rxrpc_kernel_begin_call(call
->net
->socket
, srx
, call
->key
,
406 afs_wake_up_async_call
:
407 afs_wake_up_call_waiter
),
410 if (IS_ERR(rxcall
)) {
411 ret
= PTR_ERR(rxcall
);
413 goto error_kill_call
;
416 call
->rxcall
= rxcall
;
418 /* send the request */
419 iov
[0].iov_base
= call
->request
;
420 iov
[0].iov_len
= call
->request_size
;
424 iov_iter_kvec(&msg
.msg_iter
, WRITE
, iov
, 1, call
->request_size
);
425 msg
.msg_control
= NULL
;
426 msg
.msg_controllen
= 0;
427 msg
.msg_flags
= MSG_WAITALL
| (call
->send_pages
? MSG_MORE
: 0);
429 ret
= rxrpc_kernel_send_data(call
->net
->socket
, rxcall
,
430 &msg
, call
->request_size
,
431 afs_notify_end_request_tx
);
435 if (call
->send_pages
) {
436 ret
= afs_send_pages(call
, &msg
);
441 /* at this point, an async call may no longer exist as it may have
442 * already completed */
446 return afs_wait_for_call_to_complete(call
, ac
);
449 call
->state
= AFS_CALL_COMPLETE
;
450 if (ret
!= -ECONNABORTED
) {
451 rxrpc_kernel_abort_call(call
->net
->socket
, rxcall
,
452 RX_USER_ABORT
, ret
, "KSD");
454 iov_iter_kvec(&msg
.msg_iter
, READ
, NULL
, 0, 0);
455 rxrpc_kernel_recv_data(call
->net
->socket
, rxcall
,
456 &msg
.msg_iter
, false,
457 &call
->abort_code
, &call
->service_id
);
458 ac
->abort_code
= call
->abort_code
;
459 ac
->responded
= true;
462 trace_afs_call_done(call
);
464 if (call
->type
->done
)
465 call
->type
->done(call
);
468 _leave(" = %d", ret
);
473 * deliver messages to a call
475 static void afs_deliver_to_call(struct afs_call
*call
)
477 enum afs_call_state state
;
478 u32 abort_code
, remote_abort
= 0;
481 _enter("%s", call
->type
->name
);
483 while (state
= READ_ONCE(call
->state
),
484 state
== AFS_CALL_CL_AWAIT_REPLY
||
485 state
== AFS_CALL_SV_AWAIT_OP_ID
||
486 state
== AFS_CALL_SV_AWAIT_REQUEST
||
487 state
== AFS_CALL_SV_AWAIT_ACK
489 if (state
== AFS_CALL_SV_AWAIT_ACK
) {
490 iov_iter_kvec(&call
->iter
, READ
, NULL
, 0, 0);
491 ret
= rxrpc_kernel_recv_data(call
->net
->socket
,
492 call
->rxcall
, &call
->iter
,
493 false, &remote_abort
,
495 trace_afs_receive_data(call
, &call
->iter
, false, ret
);
497 if (ret
== -EINPROGRESS
|| ret
== -EAGAIN
)
499 if (ret
< 0 || ret
== 1) {
507 if (call
->want_reply_time
&&
508 rxrpc_kernel_get_reply_time(call
->net
->socket
,
511 call
->want_reply_time
= false;
513 ret
= call
->type
->deliver(call
);
514 state
= READ_ONCE(call
->state
);
517 afs_queue_call_work(call
);
518 if (state
== AFS_CALL_CL_PROC_REPLY
) {
520 set_bit(AFS_SERVER_FL_MAY_HAVE_CB
,
521 &call
->cbi
->server
->flags
);
524 ASSERTCMP(state
, >, AFS_CALL_CL_PROC_REPLY
);
530 ASSERTCMP(state
, ==, AFS_CALL_COMPLETE
);
533 abort_code
= RXGEN_OPCODE
;
534 rxrpc_kernel_abort_call(call
->net
->socket
, call
->rxcall
,
535 abort_code
, ret
, "KIV");
538 pr_err("kAFS: Call %u in bad state %u\n",
539 call
->debug_id
, state
);
545 abort_code
= RXGEN_CC_UNMARSHAL
;
546 if (state
!= AFS_CALL_CL_AWAIT_REPLY
)
547 abort_code
= RXGEN_SS_UNMARSHAL
;
548 rxrpc_kernel_abort_call(call
->net
->socket
, call
->rxcall
,
549 abort_code
, ret
, "KUM");
555 if (call
->type
->done
)
556 call
->type
->done(call
);
557 if (state
== AFS_CALL_COMPLETE
&& call
->incoming
)
566 afs_set_call_complete(call
, ret
, remote_abort
);
567 state
= AFS_CALL_COMPLETE
;
572 * wait synchronously for a call to complete
574 static long afs_wait_for_call_to_complete(struct afs_call
*call
,
575 struct afs_addr_cursor
*ac
)
577 signed long rtt2
, timeout
;
579 bool stalled
= false;
583 DECLARE_WAITQUEUE(myself
, current
);
587 rtt
= rxrpc_kernel_get_rtt(call
->net
->socket
, call
->rxcall
);
588 rtt2
= nsecs_to_jiffies64(rtt
) * 2;
593 last_life
= rxrpc_kernel_check_life(call
->net
->socket
, call
->rxcall
);
595 add_wait_queue(&call
->waitq
, &myself
);
597 set_current_state(TASK_UNINTERRUPTIBLE
);
599 /* deliver any messages that are in the queue */
600 if (!afs_check_call_state(call
, AFS_CALL_COMPLETE
) &&
601 call
->need_attention
) {
602 call
->need_attention
= false;
603 __set_current_state(TASK_RUNNING
);
604 afs_deliver_to_call(call
);
608 if (afs_check_call_state(call
, AFS_CALL_COMPLETE
))
611 life
= rxrpc_kernel_check_life(call
->net
->socket
, call
->rxcall
);
613 life
== last_life
&& signal_pending(current
)) {
616 __set_current_state(TASK_RUNNING
);
617 rxrpc_kernel_probe_life(call
->net
->socket
, call
->rxcall
);
623 if (life
!= last_life
) {
629 timeout
= schedule_timeout(timeout
);
632 remove_wait_queue(&call
->waitq
, &myself
);
633 __set_current_state(TASK_RUNNING
);
635 /* Kill off the call if it's still live. */
636 if (!afs_check_call_state(call
, AFS_CALL_COMPLETE
)) {
637 _debug("call interrupted");
638 if (rxrpc_kernel_abort_call(call
->net
->socket
, call
->rxcall
,
639 RX_USER_ABORT
, -EINTR
, "KWI"))
640 afs_set_call_complete(call
, -EINTR
, 0);
643 spin_lock_bh(&call
->state_lock
);
644 ac
->abort_code
= call
->abort_code
;
645 ac
->error
= call
->error
;
646 spin_unlock_bh(&call
->state_lock
);
651 if (call
->ret_reply0
) {
652 ret
= (long)call
->reply
[0];
653 call
->reply
[0] = NULL
;
657 ac
->responded
= true;
661 _debug("call complete");
663 _leave(" = %p", (void *)ret
);
668 * wake up a waiting call
670 static void afs_wake_up_call_waiter(struct sock
*sk
, struct rxrpc_call
*rxcall
,
671 unsigned long call_user_ID
)
673 struct afs_call
*call
= (struct afs_call
*)call_user_ID
;
675 call
->need_attention
= true;
676 wake_up(&call
->waitq
);
680 * wake up an asynchronous call
682 static void afs_wake_up_async_call(struct sock
*sk
, struct rxrpc_call
*rxcall
,
683 unsigned long call_user_ID
)
685 struct afs_call
*call
= (struct afs_call
*)call_user_ID
;
688 trace_afs_notify_call(rxcall
, call
);
689 call
->need_attention
= true;
691 u
= atomic_fetch_add_unless(&call
->usage
, 1, 0);
693 trace_afs_call(call
, afs_call_trace_wake
, u
,
694 atomic_read(&call
->net
->nr_outstanding_calls
),
695 __builtin_return_address(0));
697 if (!queue_work(afs_async_calls
, &call
->async_work
))
703 * Delete an asynchronous call. The work item carries a ref to the call struct
704 * that we need to release.
706 static void afs_delete_async_call(struct work_struct
*work
)
708 struct afs_call
*call
= container_of(work
, struct afs_call
, async_work
);
718 * Perform I/O processing on an asynchronous call. The work item carries a ref
719 * to the call struct that we either need to release or to pass on.
721 static void afs_process_async_call(struct work_struct
*work
)
723 struct afs_call
*call
= container_of(work
, struct afs_call
, async_work
);
727 if (call
->state
< AFS_CALL_COMPLETE
&& call
->need_attention
) {
728 call
->need_attention
= false;
729 afs_deliver_to_call(call
);
732 if (call
->state
== AFS_CALL_COMPLETE
) {
733 /* We have two refs to release - one from the alloc and one
734 * queued with the work item - and we can't just deallocate the
735 * call because the work item may be queued again.
737 call
->async_work
.func
= afs_delete_async_call
;
738 if (!queue_work(afs_async_calls
, &call
->async_work
))
746 static void afs_rx_attach(struct rxrpc_call
*rxcall
, unsigned long user_call_ID
)
748 struct afs_call
*call
= (struct afs_call
*)user_call_ID
;
750 call
->rxcall
= rxcall
;
754 * Charge the incoming call preallocation.
756 void afs_charge_preallocation(struct work_struct
*work
)
758 struct afs_net
*net
=
759 container_of(work
, struct afs_net
, charge_preallocation_work
);
760 struct afs_call
*call
= net
->spare_incoming_call
;
764 call
= afs_alloc_call(net
, &afs_RXCMxxxx
, GFP_KERNEL
);
769 call
->state
= AFS_CALL_SV_AWAIT_OP_ID
;
770 init_waitqueue_head(&call
->waitq
);
771 afs_extract_to_tmp(call
);
774 if (rxrpc_kernel_charge_accept(net
->socket
,
775 afs_wake_up_async_call
,
783 net
->spare_incoming_call
= call
;
787 * Discard a preallocated call when a socket is shut down.
789 static void afs_rx_discard_new_call(struct rxrpc_call
*rxcall
,
790 unsigned long user_call_ID
)
792 struct afs_call
*call
= (struct afs_call
*)user_call_ID
;
799 * Notification of an incoming call.
801 static void afs_rx_new_call(struct sock
*sk
, struct rxrpc_call
*rxcall
,
802 unsigned long user_call_ID
)
804 struct afs_net
*net
= afs_sock2net(sk
);
806 queue_work(afs_wq
, &net
->charge_preallocation_work
);
810 * Grab the operation ID from an incoming cache manager call. The socket
811 * buffer is discarded on error or if we don't yet have sufficient data.
813 static int afs_deliver_cm_op_id(struct afs_call
*call
)
817 _enter("{%zu}", iov_iter_count(call
->_iter
));
819 /* the operation ID forms the first four bytes of the request data */
820 ret
= afs_extract_data(call
, true);
824 call
->operation_ID
= ntohl(call
->tmp
);
825 afs_set_call_state(call
, AFS_CALL_SV_AWAIT_OP_ID
, AFS_CALL_SV_AWAIT_REQUEST
);
827 /* ask the cache manager to route the call (it'll change the call type
829 if (!afs_cm_incoming_call(call
))
832 trace_afs_cb_call(call
);
834 /* pass responsibility for the remainer of this message off to the
835 * cache manager op */
836 return call
->type
->deliver(call
);
840 * Advance the AFS call state when an RxRPC service call ends the transmit
843 static void afs_notify_end_reply_tx(struct sock
*sock
,
844 struct rxrpc_call
*rxcall
,
845 unsigned long call_user_ID
)
847 struct afs_call
*call
= (struct afs_call
*)call_user_ID
;
849 afs_set_call_state(call
, AFS_CALL_SV_REPLYING
, AFS_CALL_SV_AWAIT_ACK
);
853 * send an empty reply
855 void afs_send_empty_reply(struct afs_call
*call
)
857 struct afs_net
*net
= call
->net
;
862 rxrpc_kernel_set_tx_length(net
->socket
, call
->rxcall
, 0);
866 iov_iter_kvec(&msg
.msg_iter
, WRITE
, NULL
, 0, 0);
867 msg
.msg_control
= NULL
;
868 msg
.msg_controllen
= 0;
871 switch (rxrpc_kernel_send_data(net
->socket
, call
->rxcall
, &msg
, 0,
872 afs_notify_end_reply_tx
)) {
874 _leave(" [replied]");
879 rxrpc_kernel_abort_call(net
->socket
, call
->rxcall
,
880 RX_USER_ABORT
, -ENOMEM
, "KOO");
888 * send a simple reply
890 void afs_send_simple_reply(struct afs_call
*call
, const void *buf
, size_t len
)
892 struct afs_net
*net
= call
->net
;
899 rxrpc_kernel_set_tx_length(net
->socket
, call
->rxcall
, len
);
901 iov
[0].iov_base
= (void *) buf
;
902 iov
[0].iov_len
= len
;
905 iov_iter_kvec(&msg
.msg_iter
, WRITE
, iov
, 1, len
);
906 msg
.msg_control
= NULL
;
907 msg
.msg_controllen
= 0;
910 n
= rxrpc_kernel_send_data(net
->socket
, call
->rxcall
, &msg
, len
,
911 afs_notify_end_reply_tx
);
914 _leave(" [replied]");
920 rxrpc_kernel_abort_call(net
->socket
, call
->rxcall
,
921 RX_USER_ABORT
, -ENOMEM
, "KOO");
927 * Extract a piece of data from the received data socket buffers.
929 int afs_extract_data(struct afs_call
*call
, bool want_more
)
931 struct afs_net
*net
= call
->net
;
932 struct iov_iter
*iter
= call
->_iter
;
933 enum afs_call_state state
;
934 u32 remote_abort
= 0;
937 _enter("{%s,%zu},%d", call
->type
->name
, iov_iter_count(iter
), want_more
);
939 ret
= rxrpc_kernel_recv_data(net
->socket
, call
->rxcall
, iter
,
940 want_more
, &remote_abort
,
942 if (ret
== 0 || ret
== -EAGAIN
)
945 state
= READ_ONCE(call
->state
);
948 case AFS_CALL_CL_AWAIT_REPLY
:
949 afs_set_call_state(call
, state
, AFS_CALL_CL_PROC_REPLY
);
951 case AFS_CALL_SV_AWAIT_REQUEST
:
952 afs_set_call_state(call
, state
, AFS_CALL_SV_REPLYING
);
954 case AFS_CALL_COMPLETE
:
955 kdebug("prem complete %d", call
->error
);
956 return afs_io_error(call
, afs_io_error_extract
);
963 afs_set_call_complete(call
, ret
, remote_abort
);
968 * Log protocol error production.
970 noinline
int afs_protocol_error(struct afs_call
*call
, int error
,
971 enum afs_eproto_cause cause
)
973 trace_afs_protocol_error(call
, error
, cause
);