Skip to content

Commit 8d73a73

Browse files
committed
Merge tag 'rxrpc-fixes-20200820' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs
David Howells says: ==================== rxrpc, afs: Fix probing issues Here are some fixes for rxrpc and afs to fix issues in the RTT measuring in rxrpc and thence the Volume Location server probing in afs: (1) Move the serial number of a received ACK into a local variable to simplify the next patch. (2) Fix the loss of RTT samples due to extra interposed ACKs causing baseline information to be discarded too early. This is a particular problem for afs when it sends a single very short call to probe a server it hasn't talked to recently. (3) Fix rxrpc_kernel_get_srtt() to indicate whether it actually has seen any valid samples or not. (4) Remove a field that's set/woken, but never read/waited on. (5) Expose the RTT and other probe information through procfs to make debugging of this stuff easier. (6) Fix VL rotation in afs to only use summary information from VL probing and not the probe running state (which gets clobbered when next a probe is issued). (7) Fix VL rotation to actually return the error aggregated from the probe errors. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents af8ea11 + e4686c7 commit 8d73a73

14 files changed

Lines changed: 251 additions & 129 deletions

File tree

‎fs/afs/fs_probe.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ void afs_fileserver_probe_result(struct afs_call *call)
161161
}
162162
}
163163

164-
rtt_us = rxrpc_kernel_get_srtt(call->net->socket, call->rxcall);
165-
if (rtt_us < server->probe.rtt) {
164+
if (rxrpc_kernel_get_srtt(call->net->socket, call->rxcall, &rtt_us) &&
165+
rtt_us < server->probe.rtt) {
166166
server->probe.rtt = rtt_us;
167167
server->rtt = rtt_us;
168168
alist->preferred = index;

‎fs/afs/internal.h‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -401,22 +401,24 @@ struct afs_vlserver {
401401
#define AFS_VLSERVER_FL_PROBED 0 /* The VL server has been probed */
402402
#define AFS_VLSERVER_FL_PROBING 1 /* VL server is being probed */
403403
#define AFS_VLSERVER_FL_IS_YFS 2 /* Server is YFS not AFS */
404+
#define AFS_VLSERVER_FL_RESPONDING 3 /* VL server is responding */
404405
rwlock_t lock; /* Lock on addresses */
405406
atomic_t usage;
407+
unsigned int rtt; /* Server's current RTT in uS */
406408

407409
/* Probe state */
408410
wait_queue_head_t probe_wq;
409411
atomic_t probe_outstanding;
410412
spinlock_t probe_lock;
411413
struct {
412-
unsigned int rtt; /* RTT as ktime/64 */
414+
unsigned int rtt; /* RTT in uS */
413415
u32 abort_code;
414416
short error;
415-
bool have_result;
416-
bool responded:1;
417-
bool is_yfs:1;
418-
bool not_yfs:1;
419-
bool local_failure:1;
417+
unsigned short flags;
418+
#define AFS_VLSERVER_PROBE_RESPONDED 0x01 /* At least once response (may be abort) */
419+
#define AFS_VLSERVER_PROBE_IS_YFS 0x02 /* The peer appears to be YFS */
420+
#define AFS_VLSERVER_PROBE_NOT_YFS 0x04 /* The peer appears not to be YFS */
421+
#define AFS_VLSERVER_PROBE_LOCAL_FAILURE 0x08 /* A local failure prevented a probe */
420422
} probe;
421423

422424
u16 port;

‎fs/afs/proc.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,11 @@ static int afs_proc_cell_vlservers_show(struct seq_file *m, void *v)
310310
alist->preferred == i ? '>' : '-',
311311
&alist->addrs[i].transport);
312312
}
313+
seq_printf(m, " info: fl=%lx rtt=%d\n", vlserver->flags, vlserver->rtt);
314+
seq_printf(m, " probe: fl=%x e=%d ac=%d out=%d\n",
315+
vlserver->probe.flags, vlserver->probe.error,
316+
vlserver->probe.abort_code,
317+
atomic_read(&vlserver->probe_outstanding));
313318
return 0;
314319
}
315320

‎fs/afs/vl_list.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ struct afs_vlserver *afs_alloc_vlserver(const char *name, size_t name_len,
2121
rwlock_init(&vlserver->lock);
2222
init_waitqueue_head(&vlserver->probe_wq);
2323
spin_lock_init(&vlserver->probe_lock);
24+
vlserver->rtt = UINT_MAX;
2425
vlserver->name_len = name_len;
2526
vlserver->port = port;
2627
memcpy(vlserver->name, name, name_len);

‎fs/afs/vl_probe.c‎

Lines changed: 51 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,33 @@
1111
#include "internal.h"
1212
#include "protocol_yfs.h"
1313

14-
static bool afs_vl_probe_done(struct afs_vlserver *server)
14+
15+
/*
16+
* Handle the completion of a set of probes.
17+
*/
18+
static void afs_finished_vl_probe(struct afs_vlserver *server)
1519
{
16-
if (!atomic_dec_and_test(&server->probe_outstanding))
17-
return false;
20+
if (!(server->probe.flags & AFS_VLSERVER_PROBE_RESPONDED)) {
21+
server->rtt = UINT_MAX;
22+
clear_bit(AFS_VLSERVER_FL_RESPONDING, &server->flags);
23+
}
1824

19-
wake_up_var(&server->probe_outstanding);
2025
clear_bit_unlock(AFS_VLSERVER_FL_PROBING, &server->flags);
2126
wake_up_bit(&server->flags, AFS_VLSERVER_FL_PROBING);
22-
return true;
27+
}
28+
29+
/*
30+
* Handle the completion of a probe RPC call.
31+
*/
32+
static void afs_done_one_vl_probe(struct afs_vlserver *server, bool wake_up)
33+
{
34+
if (atomic_dec_and_test(&server->probe_outstanding)) {
35+
afs_finished_vl_probe(server);
36+
wake_up = true;
37+
}
38+
39+
if (wake_up)
40+
wake_up_all(&server->probe_wq);
2341
}
2442

2543
/*
@@ -45,15 +63,20 @@ void afs_vlserver_probe_result(struct afs_call *call)
4563
server->probe.error = 0;
4664
goto responded;
4765
case -ECONNABORTED:
48-
if (!server->probe.responded) {
66+
if (!(server->probe.flags & AFS_VLSERVER_PROBE_RESPONDED)) {
4967
server->probe.abort_code = call->abort_code;
5068
server->probe.error = ret;
5169
}
5270
goto responded;
5371
case -ENOMEM:
5472
case -ENONET:
55-
server->probe.local_failure = true;
56-
afs_io_error(call, afs_io_error_vl_probe_fail);
73+
case -EKEYEXPIRED:
74+
case -EKEYREVOKED:
75+
case -EKEYREJECTED:
76+
server->probe.flags |= AFS_VLSERVER_PROBE_LOCAL_FAILURE;
77+
if (server->probe.error == 0)
78+
server->probe.error = ret;
79+
trace_afs_io_error(call->debug_id, ret, afs_io_error_vl_probe_fail);
5780
goto out;
5881
case -ECONNRESET: /* Responded, but call expired. */
5982
case -ERFKILL:
@@ -67,12 +90,12 @@ void afs_vlserver_probe_result(struct afs_call *call)
6790
default:
6891
clear_bit(index, &alist->responded);
6992
set_bit(index, &alist->failed);
70-
if (!server->probe.responded &&
93+
if (!(server->probe.flags & AFS_VLSERVER_PROBE_RESPONDED) &&
7194
(server->probe.error == 0 ||
7295
server->probe.error == -ETIMEDOUT ||
7396
server->probe.error == -ETIME))
7497
server->probe.error = ret;
75-
afs_io_error(call, afs_io_error_vl_probe_fail);
98+
trace_afs_io_error(call->debug_id, ret, afs_io_error_vl_probe_fail);
7699
goto out;
77100
}
78101

@@ -81,39 +104,36 @@ void afs_vlserver_probe_result(struct afs_call *call)
81104
clear_bit(index, &alist->failed);
82105

83106
if (call->service_id == YFS_VL_SERVICE) {
84-
server->probe.is_yfs = true;
107+
server->probe.flags |= AFS_VLSERVER_PROBE_IS_YFS;
85108
set_bit(AFS_VLSERVER_FL_IS_YFS, &server->flags);
86109
alist->addrs[index].srx_service = call->service_id;
87110
} else {
88-
server->probe.not_yfs = true;
89-
if (!server->probe.is_yfs) {
111+
server->probe.flags |= AFS_VLSERVER_PROBE_NOT_YFS;
112+
if (!(server->probe.flags & AFS_VLSERVER_PROBE_IS_YFS)) {
90113
clear_bit(AFS_VLSERVER_FL_IS_YFS, &server->flags);
91114
alist->addrs[index].srx_service = call->service_id;
92115
}
93116
}
94117

95-
rtt_us = rxrpc_kernel_get_srtt(call->net->socket, call->rxcall);
96-
if (rtt_us < server->probe.rtt) {
118+
if (rxrpc_kernel_get_srtt(call->net->socket, call->rxcall, &rtt_us) &&
119+
rtt_us < server->probe.rtt) {
97120
server->probe.rtt = rtt_us;
121+
server->rtt = rtt_us;
98122
alist->preferred = index;
99-
have_result = true;
100123
}
101124

102125
smp_wmb(); /* Set rtt before responded. */
103-
server->probe.responded = true;
126+
server->probe.flags |= AFS_VLSERVER_PROBE_RESPONDED;
104127
set_bit(AFS_VLSERVER_FL_PROBED, &server->flags);
128+
set_bit(AFS_VLSERVER_FL_RESPONDING, &server->flags);
129+
have_result = true;
105130
out:
106131
spin_unlock(&server->probe_lock);
107132

108133
_debug("probe [%u][%u] %pISpc rtt=%u ret=%d",
109134
server_index, index, &alist->addrs[index].transport, rtt_us, ret);
110135

111-
have_result |= afs_vl_probe_done(server);
112-
if (have_result) {
113-
server->probe.have_result = true;
114-
wake_up_var(&server->probe.have_result);
115-
wake_up_all(&server->probe_wq);
116-
}
136+
afs_done_one_vl_probe(server, have_result);
117137
}
118138

119139
/*
@@ -151,11 +171,10 @@ static bool afs_do_probe_vlserver(struct afs_net *net,
151171
in_progress = true;
152172
} else {
153173
afs_prioritise_error(_e, PTR_ERR(call), ac.abort_code);
174+
afs_done_one_vl_probe(server, false);
154175
}
155176
}
156177

157-
if (!in_progress)
158-
afs_vl_probe_done(server);
159178
return in_progress;
160179
}
161180

@@ -193,7 +212,7 @@ int afs_wait_for_vl_probes(struct afs_vlserver_list *vllist,
193212
{
194213
struct wait_queue_entry *waits;
195214
struct afs_vlserver *server;
196-
unsigned int rtt = UINT_MAX;
215+
unsigned int rtt = UINT_MAX, rtt_s;
197216
bool have_responders = false;
198217
int pref = -1, i;
199218

@@ -205,7 +224,7 @@ int afs_wait_for_vl_probes(struct afs_vlserver_list *vllist,
205224
server = vllist->servers[i].server;
206225
if (!test_bit(AFS_VLSERVER_FL_PROBING, &server->flags))
207226
__clear_bit(i, &untried);
208-
if (server->probe.responded)
227+
if (server->probe.flags & AFS_VLSERVER_PROBE_RESPONDED)
209228
have_responders = true;
210229
}
211230
}
@@ -231,7 +250,7 @@ int afs_wait_for_vl_probes(struct afs_vlserver_list *vllist,
231250
for (i = 0; i < vllist->nr_servers; i++) {
232251
if (test_bit(i, &untried)) {
233252
server = vllist->servers[i].server;
234-
if (server->probe.responded)
253+
if (server->probe.flags & AFS_VLSERVER_PROBE_RESPONDED)
235254
goto stop;
236255
if (test_bit(AFS_VLSERVER_FL_PROBING, &server->flags))
237256
still_probing = true;
@@ -249,10 +268,11 @@ int afs_wait_for_vl_probes(struct afs_vlserver_list *vllist,
249268
for (i = 0; i < vllist->nr_servers; i++) {
250269
if (test_bit(i, &untried)) {
251270
server = vllist->servers[i].server;
252-
if (server->probe.responded &&
253-
server->probe.rtt < rtt) {
271+
rtt_s = READ_ONCE(server->rtt);
272+
if (test_bit(AFS_VLSERVER_FL_RESPONDING, &server->flags) &&
273+
rtt_s < rtt) {
254274
pref = i;
255-
rtt = server->probe.rtt;
275+
rtt = rtt_s;
256276
}
257277

258278
remove_wait_queue(&server->probe_wq, &waits[i]);

‎fs/afs/vl_rotate.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ bool afs_select_vlserver(struct afs_vl_cursor *vc)
192192
for (i = 0; i < vc->server_list->nr_servers; i++) {
193193
struct afs_vlserver *s = vc->server_list->servers[i].server;
194194

195-
if (!test_bit(i, &vc->untried) || !s->probe.responded)
195+
if (!test_bit(i, &vc->untried) ||
196+
!test_bit(AFS_VLSERVER_FL_RESPONDING, &s->flags))
196197
continue;
197198
if (s->probe.rtt < rtt) {
198199
vc->index = i;
@@ -262,10 +263,14 @@ bool afs_select_vlserver(struct afs_vl_cursor *vc)
262263
for (i = 0; i < vc->server_list->nr_servers; i++) {
263264
struct afs_vlserver *s = vc->server_list->servers[i].server;
264265

266+
if (test_bit(AFS_VLSERVER_FL_RESPONDING, &s->flags))
267+
e.responded = true;
265268
afs_prioritise_error(&e, READ_ONCE(s->probe.error),
266269
s->probe.abort_code);
267270
}
268271

272+
error = e.error;
273+
269274
failed_set_error:
270275
vc->error = error;
271276
failed:

‎include/net/af_rxrpc.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ bool rxrpc_kernel_abort_call(struct socket *, struct rxrpc_call *,
5959
void rxrpc_kernel_end_call(struct socket *, struct rxrpc_call *);
6060
void rxrpc_kernel_get_peer(struct socket *, struct rxrpc_call *,
6161
struct sockaddr_rxrpc *);
62-
u32 rxrpc_kernel_get_srtt(struct socket *, struct rxrpc_call *);
62+
bool rxrpc_kernel_get_srtt(struct socket *, struct rxrpc_call *, u32 *);
6363
int rxrpc_kernel_charge_accept(struct socket *, rxrpc_notify_rx_t,
6464
rxrpc_user_attach_call_t, unsigned long, gfp_t,
6565
unsigned int);

‎include/trace/events/rxrpc.h‎

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,16 @@ enum rxrpc_recvmsg_trace {
138138
};
139139

140140
enum rxrpc_rtt_tx_trace {
141+
rxrpc_rtt_tx_cancel,
141142
rxrpc_rtt_tx_data,
143+
rxrpc_rtt_tx_no_slot,
142144
rxrpc_rtt_tx_ping,
143145
};
144146

145147
enum rxrpc_rtt_rx_trace {
148+
rxrpc_rtt_rx_cancel,
149+
rxrpc_rtt_rx_lost,
150+
rxrpc_rtt_rx_obsolete,
146151
rxrpc_rtt_rx_ping_response,
147152
rxrpc_rtt_rx_requested_ack,
148153
};
@@ -339,10 +344,15 @@ enum rxrpc_tx_point {
339344
E_(rxrpc_recvmsg_wait, "WAIT")
340345

341346
#define rxrpc_rtt_tx_traces \
347+
EM(rxrpc_rtt_tx_cancel, "CNCE") \
342348
EM(rxrpc_rtt_tx_data, "DATA") \
349+
EM(rxrpc_rtt_tx_no_slot, "FULL") \
343350
E_(rxrpc_rtt_tx_ping, "PING")
344351

345352
#define rxrpc_rtt_rx_traces \
353+
EM(rxrpc_rtt_rx_cancel, "CNCL") \
354+
EM(rxrpc_rtt_rx_obsolete, "OBSL") \
355+
EM(rxrpc_rtt_rx_lost, "LOST") \
346356
EM(rxrpc_rtt_rx_ping_response, "PONG") \
347357
E_(rxrpc_rtt_rx_requested_ack, "RACK")
348358

@@ -1087,38 +1097,43 @@ TRACE_EVENT(rxrpc_recvmsg,
10871097

10881098
TRACE_EVENT(rxrpc_rtt_tx,
10891099
TP_PROTO(struct rxrpc_call *call, enum rxrpc_rtt_tx_trace why,
1090-
rxrpc_serial_t send_serial),
1100+
int slot, rxrpc_serial_t send_serial),
10911101

1092-
TP_ARGS(call, why, send_serial),
1102+
TP_ARGS(call, why, slot, send_serial),
10931103

10941104
TP_STRUCT__entry(
10951105
__field(unsigned int, call )
10961106
__field(enum rxrpc_rtt_tx_trace, why )
1107+
__field(int, slot )
10971108
__field(rxrpc_serial_t, send_serial )
10981109
),
10991110

11001111
TP_fast_assign(
11011112
__entry->call = call->debug_id;
11021113
__entry->why = why;
1114+
__entry->slot = slot;
11031115
__entry->send_serial = send_serial;
11041116
),
11051117

1106-
TP_printk("c=%08x %s sr=%08x",
1118+
TP_printk("c=%08x [%d] %s sr=%08x",
11071119
__entry->call,
1120+
__entry->slot,
11081121
__print_symbolic(__entry->why, rxrpc_rtt_tx_traces),
11091122
__entry->send_serial)
11101123
);
11111124

11121125
TRACE_EVENT(rxrpc_rtt_rx,
11131126
TP_PROTO(struct rxrpc_call *call, enum rxrpc_rtt_rx_trace why,
1127+
int slot,
11141128
rxrpc_serial_t send_serial, rxrpc_serial_t resp_serial,
11151129
u32 rtt, u32 rto),
11161130

1117-
TP_ARGS(call, why, send_serial, resp_serial, rtt, rto),
1131+
TP_ARGS(call, why, slot, send_serial, resp_serial, rtt, rto),
11181132

11191133
TP_STRUCT__entry(
11201134
__field(unsigned int, call )
11211135
__field(enum rxrpc_rtt_rx_trace, why )
1136+
__field(int, slot )
11221137
__field(rxrpc_serial_t, send_serial )
11231138
__field(rxrpc_serial_t, resp_serial )
11241139
__field(u32, rtt )
@@ -1128,14 +1143,16 @@ TRACE_EVENT(rxrpc_rtt_rx,
11281143
TP_fast_assign(
11291144
__entry->call = call->debug_id;
11301145
__entry->why = why;
1146+
__entry->slot = slot;
11311147
__entry->send_serial = send_serial;
11321148
__entry->resp_serial = resp_serial;
11331149
__entry->rtt = rtt;
11341150
__entry->rto = rto;
11351151
),
11361152

1137-
TP_printk("c=%08x %s sr=%08x rr=%08x rtt=%u rto=%u",
1153+
TP_printk("c=%08x [%d] %s sr=%08x rr=%08x rtt=%u rto=%u",
11381154
__entry->call,
1155+
__entry->slot,
11391156
__print_symbolic(__entry->why, rxrpc_rtt_rx_traces),
11401157
__entry->send_serial,
11411158
__entry->resp_serial,

0 commit comments

Comments
 (0)