Skip to content

Commit b960a34

Browse files
committed
rxrpc: Allow the kernel to mark a call as being non-interruptible
Allow kernel services using AF_RXRPC to indicate that a call should be non-interruptible. This allows kafs to make things like lock-extension and writeback data storage calls non-interruptible. If this is set, signals will be ignored for operations on that call where possible - such as waiting to get a call channel on an rxrpc connection. It doesn't prevent UDP sendmsg from being interrupted, but that will be handled by packet retransmission. rxrpc_kernel_recv_data() isn't affected by this since that never waits, preferring instead to return -EAGAIN and leave the waiting to the caller. Userspace initiated calls can't be set to be uninterruptible at this time. Signed-off-by: David Howells <dhowells@redhat.com>
1 parent 0ab4c95 commit b960a34

8 files changed

Lines changed: 28 additions & 4 deletions

File tree

‎Documentation/networking/rxrpc.txt‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,9 @@ The kernel interface functions are as follows:
796796
s64 tx_total_len,
797797
gfp_t gfp,
798798
rxrpc_notify_rx_t notify_rx,
799-
bool upgrade);
799+
bool upgrade,
800+
bool intr,
801+
unsigned int debug_id);
800802

801803
This allocates the infrastructure to make a new RxRPC call and assigns
802804
call and connection numbers. The call will be made on the UDP port that
@@ -824,6 +826,13 @@ The kernel interface functions are as follows:
824826
the server upgrade the service to a better one. The resultant service ID
825827
is returned by rxrpc_kernel_recv_data().
826828

829+
intr should be set to true if the call should be interruptible. If this
830+
is not set, this function may not return until a channel has been
831+
allocated; if it is set, the function may return -ERESTARTSYS.
832+
833+
debug_id is the call debugging ID to be used for tracing. This can be
834+
obtained by atomically incrementing rxrpc_debug_id.
835+
827836
If this function is successful, an opaque reference to the RxRPC call is
828837
returned. The caller now holds a reference on this and it must be
829838
properly ended.

‎fs/afs/rxrpc.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ void afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call, gfp_t gfp)
417417
afs_wake_up_async_call :
418418
afs_wake_up_call_waiter),
419419
call->upgrade,
420+
true,
420421
call->debug_id);
421422
if (IS_ERR(rxcall)) {
422423
ret = PTR_ERR(rxcall);

‎include/net/af_rxrpc.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *,
4545
gfp_t,
4646
rxrpc_notify_rx_t,
4747
bool,
48+
bool,
4849
unsigned int);
4950
int rxrpc_kernel_send_data(struct socket *, struct rxrpc_call *,
5051
struct msghdr *, size_t,

‎net/rxrpc/af_rxrpc.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ static int rxrpc_listen(struct socket *sock, int backlog)
270270
* @gfp: The allocation constraints
271271
* @notify_rx: Where to send notifications instead of socket queue
272272
* @upgrade: Request service upgrade for call
273+
* @intr: The call is interruptible
273274
* @debug_id: The debug ID for tracing to be assigned to the call
274275
*
275276
* Allow a kernel service to begin a call on the nominated socket. This just
@@ -287,6 +288,7 @@ struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *sock,
287288
gfp_t gfp,
288289
rxrpc_notify_rx_t notify_rx,
289290
bool upgrade,
291+
bool intr,
290292
unsigned int debug_id)
291293
{
292294
struct rxrpc_conn_parameters cp;
@@ -311,6 +313,7 @@ struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *sock,
311313
memset(&p, 0, sizeof(p));
312314
p.user_call_ID = user_call_ID;
313315
p.tx_total_len = tx_total_len;
316+
p.intr = intr;
314317

315318
memset(&cp, 0, sizeof(cp));
316319
cp.local = rx->local;

‎net/rxrpc/ar-internal.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ enum rxrpc_call_flag {
482482
RXRPC_CALL_BEGAN_RX_TIMER, /* We began the expect_rx_by timer */
483483
RXRPC_CALL_RX_HEARD, /* The peer responded at least once to this call */
484484
RXRPC_CALL_RX_UNDERRUN, /* Got data underrun */
485+
RXRPC_CALL_IS_INTR, /* The call is interruptible */
485486
};
486487

487488
/*
@@ -711,6 +712,7 @@ struct rxrpc_call_params {
711712
u32 normal; /* Max time since last call packet (msec) */
712713
} timeouts;
713714
u8 nr_timeouts; /* Number of timeouts specified */
715+
bool intr; /* The call is interruptible */
714716
};
715717

716718
struct rxrpc_send_params {

‎net/rxrpc/call_object.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ struct rxrpc_call *rxrpc_new_client_call(struct rxrpc_sock *rx,
241241
return call;
242242
}
243243

244+
if (p->intr)
245+
__set_bit(RXRPC_CALL_IS_INTR, &call->flags);
244246
call->tx_total_len = p->tx_total_len;
245247
trace_rxrpc_call(call, rxrpc_call_new_client, atomic_read(&call->usage),
246248
here, (const void *)p->user_call_ID);

‎net/rxrpc/conn_client.c‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -656,10 +656,14 @@ static int rxrpc_wait_for_channel(struct rxrpc_call *call, gfp_t gfp)
656656

657657
add_wait_queue_exclusive(&call->waitq, &myself);
658658
for (;;) {
659-
set_current_state(TASK_INTERRUPTIBLE);
659+
if (test_bit(RXRPC_CALL_IS_INTR, &call->flags))
660+
set_current_state(TASK_INTERRUPTIBLE);
661+
else
662+
set_current_state(TASK_UNINTERRUPTIBLE);
660663
if (call->call_id)
661664
break;
662-
if (signal_pending(current)) {
665+
if (test_bit(RXRPC_CALL_IS_INTR, &call->flags) &&
666+
signal_pending(current)) {
663667
ret = -ERESTARTSYS;
664668
break;
665669
}

‎net/rxrpc/sendmsg.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ static int rxrpc_wait_for_tx_window_nonintr(struct rxrpc_sock *rx,
8080
if (call->state >= RXRPC_CALL_COMPLETE)
8181
return call->error;
8282

83-
if (timeout == 0 &&
83+
if (test_bit(RXRPC_CALL_IS_INTR, &call->flags) &&
84+
timeout == 0 &&
8485
tx_win == tx_start && signal_pending(current))
8586
return -EINTR;
8687

@@ -620,6 +621,7 @@ int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len)
620621
.call.tx_total_len = -1,
621622
.call.user_call_ID = 0,
622623
.call.nr_timeouts = 0,
624+
.call.intr = true,
623625
.abort_code = 0,
624626
.command = RXRPC_CMD_SEND_DATA,
625627
.exclusive = false,

0 commit comments

Comments
 (0)