Skip to content

Commit f4d15fb

Browse files
committed
rxrpc: Provide functions for allowing cleaner handling of signals
Provide a couple of functions to allow cleaner handling of signals in a kernel service. They are: (1) rxrpc_kernel_get_rtt() This allows the kernel service to find out the RTT time for a call, so as to better judge how large a timeout to employ. Note, though, that whilst this returns a value in nanoseconds, the timeouts can only actually be in jiffies. (2) rxrpc_kernel_check_life() This returns a number that is updated when ACKs are received from the peer (notably including PING RESPONSE ACKs which we can elicit by sending PING ACKs to see if the call still exists on the server). The caller should compare the numbers of two calls to see if the call is still alive. These can be used to provide an extending timeout rather than returning immediately in the case that a signal occurs that would otherwise abort an RPC operation. The timeout would be extended if the server is still responsive and the call is still apparently alive on the server. For most operations this isn't that necessary - but for FS.StoreData it is: OpenAFS writes the data to storage as it comes in without making a backup, so if we immediately abort it when partially complete on a CTRL+C, say, we have no idea of the state of the file after the abort. Signed-off-by: David Howells <[email protected]>
1 parent a68f4a2 commit f4d15fb

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed

Documentation/networking/rxrpc.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,30 @@ The kernel interface functions are as follows:
10331033

10341034
It returns 0 if the call was requeued and an error otherwise.
10351035

1036+
(*) Get call RTT.
1037+
1038+
u64 rxrpc_kernel_get_rtt(struct socket *sock, struct rxrpc_call *call);
1039+
1040+
Get the RTT time to the peer in use by a call. The value returned is in
1041+
nanoseconds.
1042+
1043+
(*) Check call still alive.
1044+
1045+
u32 rxrpc_kernel_check_life(struct socket *sock,
1046+
struct rxrpc_call *call);
1047+
1048+
This returns a number that is updated when ACKs are received from the peer
1049+
(notably including PING RESPONSE ACKs which we can elicit by sending PING
1050+
ACKs to see if the call still exists on the server). The caller should
1051+
compare the numbers of two calls to see if the call is still alive after
1052+
waiting for a suitable interval.
1053+
1054+
This allows the caller to work out if the server is still contactable and
1055+
if the call is still alive on the server whilst waiting for the server to
1056+
process a client operation.
1057+
1058+
This function may transmit a PING ACK.
1059+
10361060

10371061
=======================
10381062
CONFIGURABLE PARAMETERS

include/net/af_rxrpc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,14 @@ bool rxrpc_kernel_abort_call(struct socket *, struct rxrpc_call *,
6161
void rxrpc_kernel_end_call(struct socket *, struct rxrpc_call *);
6262
void rxrpc_kernel_get_peer(struct socket *, struct rxrpc_call *,
6363
struct sockaddr_rxrpc *);
64+
u64 rxrpc_kernel_get_rtt(struct socket *, struct rxrpc_call *);
6465
int rxrpc_kernel_charge_accept(struct socket *, rxrpc_notify_rx_t,
6566
rxrpc_user_attach_call_t, unsigned long, gfp_t);
6667
void rxrpc_kernel_set_tx_length(struct socket *, struct rxrpc_call *, s64);
6768
int rxrpc_kernel_retry_call(struct socket *, struct rxrpc_call *,
6869
struct sockaddr_rxrpc *, struct key *);
6970
int rxrpc_kernel_check_call(struct socket *, struct rxrpc_call *,
7071
enum rxrpc_call_completion *, u32 *);
72+
u32 rxrpc_kernel_check_life(struct socket *, struct rxrpc_call *);
7173

7274
#endif /* _NET_RXRPC_H */

net/rxrpc/af_rxrpc.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,25 @@ void rxrpc_kernel_end_call(struct socket *sock, struct rxrpc_call *call)
339339
}
340340
EXPORT_SYMBOL(rxrpc_kernel_end_call);
341341

342+
/**
343+
* rxrpc_kernel_check_life - Check to see whether a call is still alive
344+
* @sock: The socket the call is on
345+
* @call: The call to check
346+
*
347+
* Allow a kernel service to find out whether a call is still alive - ie. we're
348+
* getting ACKs from the server. Returns a number representing the life state
349+
* which can be compared to that returned by a previous call.
350+
*
351+
* If this is a client call, ping ACKs will be sent to the server to find out
352+
* whether it's still responsive and whether the call is still alive on the
353+
* server.
354+
*/
355+
u32 rxrpc_kernel_check_life(struct socket *sock, struct rxrpc_call *call)
356+
{
357+
return call->acks_latest;
358+
}
359+
EXPORT_SYMBOL(rxrpc_kernel_check_life);
360+
342361
/**
343362
* rxrpc_kernel_check_call - Check a call's state
344363
* @sock: The socket the call is on

net/rxrpc/peer_object.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,3 +411,16 @@ void rxrpc_kernel_get_peer(struct socket *sock, struct rxrpc_call *call,
411411
*_srx = call->peer->srx;
412412
}
413413
EXPORT_SYMBOL(rxrpc_kernel_get_peer);
414+
415+
/**
416+
* rxrpc_kernel_get_rtt - Get a call's peer RTT
417+
* @sock: The socket on which the call is in progress.
418+
* @call: The call to query
419+
*
420+
* Get the call's peer RTT.
421+
*/
422+
u64 rxrpc_kernel_get_rtt(struct socket *sock, struct rxrpc_call *call)
423+
{
424+
return call->peer->rtt;
425+
}
426+
EXPORT_SYMBOL(rxrpc_kernel_get_rtt);

0 commit comments

Comments
 (0)