Skip to content

Commit 8e8d7f1

Browse files
committed
afs: Add some tracepoints
Add three tracepoints to the AFS filesystem: (1) The afs_recv_data tracepoint logs data segments that are extracted from the data received from the peer through afs_extract_data(). (2) The afs_notify_call tracepoint logs notification from AF_RXRPC of data coming in to an asynchronous call. (3) The afs_cb_call tracepoint logs incoming calls that have had their operation ID extracted and mapped into a supported cache manager service call. To make (3) work, the name strings in the afs_call_type struct objects have to be annotated with __tracepoint_string. This is done with the CM_NAME() macro. Further, the AFS call state enum needs a name so that it can be used to declare parameter types. Signed-off-by: David Howells <dhowells@redhat.com>
1 parent 4289e60 commit 8e8d7f1

File tree

5 files changed

+144
-15
lines changed

5 files changed

+144
-15
lines changed

fs/afs/cmservice.c

+16-6
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,16 @@ static int afs_deliver_cb_probe_uuid(struct afs_call *);
2525
static int afs_deliver_cb_tell_me_about_yourself(struct afs_call *);
2626
static void afs_cm_destructor(struct afs_call *);
2727

28+
#define CM_NAME(name) \
29+
const char afs_SRXCB##name##_name[] __tracepoint_string = \
30+
"CB." #name
31+
2832
/*
2933
* CB.CallBack operation type
3034
*/
35+
static CM_NAME(CallBack);
3136
static const struct afs_call_type afs_SRXCBCallBack = {
32-
.name = "CB.CallBack",
37+
.name = afs_SRXCBCallBack_name,
3338
.deliver = afs_deliver_cb_callback,
3439
.abort_to_error = afs_abort_to_error,
3540
.destructor = afs_cm_destructor,
@@ -38,8 +43,9 @@ static const struct afs_call_type afs_SRXCBCallBack = {
3843
/*
3944
* CB.InitCallBackState operation type
4045
*/
46+
static CM_NAME(InitCallBackState);
4147
static const struct afs_call_type afs_SRXCBInitCallBackState = {
42-
.name = "CB.InitCallBackState",
48+
.name = afs_SRXCBInitCallBackState_name,
4349
.deliver = afs_deliver_cb_init_call_back_state,
4450
.abort_to_error = afs_abort_to_error,
4551
.destructor = afs_cm_destructor,
@@ -48,8 +54,9 @@ static const struct afs_call_type afs_SRXCBInitCallBackState = {
4854
/*
4955
* CB.InitCallBackState3 operation type
5056
*/
57+
static CM_NAME(InitCallBackState3);
5158
static const struct afs_call_type afs_SRXCBInitCallBackState3 = {
52-
.name = "CB.InitCallBackState3",
59+
.name = afs_SRXCBInitCallBackState3_name,
5360
.deliver = afs_deliver_cb_init_call_back_state3,
5461
.abort_to_error = afs_abort_to_error,
5562
.destructor = afs_cm_destructor,
@@ -58,8 +65,9 @@ static const struct afs_call_type afs_SRXCBInitCallBackState3 = {
5865
/*
5966
* CB.Probe operation type
6067
*/
68+
static CM_NAME(Probe);
6169
static const struct afs_call_type afs_SRXCBProbe = {
62-
.name = "CB.Probe",
70+
.name = afs_SRXCBProbe_name,
6371
.deliver = afs_deliver_cb_probe,
6472
.abort_to_error = afs_abort_to_error,
6573
.destructor = afs_cm_destructor,
@@ -68,8 +76,9 @@ static const struct afs_call_type afs_SRXCBProbe = {
6876
/*
6977
* CB.ProbeUuid operation type
7078
*/
79+
static CM_NAME(ProbeUuid);
7180
static const struct afs_call_type afs_SRXCBProbeUuid = {
72-
.name = "CB.ProbeUuid",
81+
.name = afs_SRXCBProbeUuid_name,
7382
.deliver = afs_deliver_cb_probe_uuid,
7483
.abort_to_error = afs_abort_to_error,
7584
.destructor = afs_cm_destructor,
@@ -78,8 +87,9 @@ static const struct afs_call_type afs_SRXCBProbeUuid = {
7887
/*
7988
* CB.TellMeAboutYourself operation type
8089
*/
90+
static CM_NAME(TellMeAboutYourself);
8191
static const struct afs_call_type afs_SRXCBTellMeAboutYourself = {
82-
.name = "CB.TellMeAboutYourself",
92+
.name = afs_SRXCBTellMeAboutYourself_name,
8393
.deliver = afs_deliver_cb_tell_me_about_yourself,
8494
.abort_to_error = afs_abort_to_error,
8595
.destructor = afs_cm_destructor,

fs/afs/internal.h

+12-9
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ struct afs_wait_mode {
6868
extern const struct afs_wait_mode afs_sync_call;
6969
extern const struct afs_wait_mode afs_async_call;
7070

71+
enum afs_call_state {
72+
AFS_CALL_REQUESTING, /* request is being sent for outgoing call */
73+
AFS_CALL_AWAIT_REPLY, /* awaiting reply to outgoing call */
74+
AFS_CALL_AWAIT_OP_ID, /* awaiting op ID on incoming call */
75+
AFS_CALL_AWAIT_REQUEST, /* awaiting request data on incoming call */
76+
AFS_CALL_REPLYING, /* replying to incoming call */
77+
AFS_CALL_AWAIT_ACK, /* awaiting final ACK of incoming call */
78+
AFS_CALL_COMPLETE, /* Completed or failed */
79+
};
7180
/*
7281
* a record of an in-progress RxRPC call
7382
*/
@@ -91,15 +100,7 @@ struct afs_call {
91100
pgoff_t first; /* first page in mapping to deal with */
92101
pgoff_t last; /* last page in mapping to deal with */
93102
size_t offset; /* offset into received data store */
94-
enum { /* call state */
95-
AFS_CALL_REQUESTING, /* request is being sent for outgoing call */
96-
AFS_CALL_AWAIT_REPLY, /* awaiting reply to outgoing call */
97-
AFS_CALL_AWAIT_OP_ID, /* awaiting op ID on incoming call */
98-
AFS_CALL_AWAIT_REQUEST, /* awaiting request data on incoming call */
99-
AFS_CALL_REPLYING, /* replying to incoming call */
100-
AFS_CALL_AWAIT_ACK, /* awaiting final ACK of incoming call */
101-
AFS_CALL_COMPLETE, /* Completed or failed */
102-
} state;
103+
enum afs_call_state state;
103104
int error; /* error code */
104105
u32 abort_code; /* Remote abort ID or 0 */
105106
unsigned request_size; /* size of request data */
@@ -773,6 +774,8 @@ extern int afs_fsync(struct file *, loff_t, loff_t, int);
773774
/*
774775
* debug tracing
775776
*/
777+
#include <trace/events/afs.h>
778+
776779
extern unsigned afs_debug;
777780

778781
#define dbgprintk(FMT,...) \

fs/afs/main.c

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/completion.h>
1616
#include <linux/sched.h>
1717
#include <linux/random.h>
18+
#define CREATE_TRACE_POINTS
1819
#include "internal.h"
1920

2021
MODULE_DESCRIPTION("AFS Client File System");

fs/afs/rxrpc.c

+6
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,8 @@ static void afs_deliver_to_call(struct afs_call *call)
416416
ret = rxrpc_kernel_recv_data(afs_socket, call->rxcall,
417417
NULL, 0, &offset, false,
418418
&call->abort_code);
419+
trace_afs_recv_data(call, 0, offset, false, ret);
420+
419421
if (ret == -EINPROGRESS || ret == -EAGAIN)
420422
return;
421423
if (ret == 1 || ret < 0) {
@@ -541,6 +543,7 @@ static void afs_wake_up_async_call(struct sock *sk, struct rxrpc_call *rxcall,
541543
{
542544
struct afs_call *call = (struct afs_call *)call_user_ID;
543545

546+
trace_afs_notify_call(rxcall, call);
544547
call->need_attention = true;
545548
queue_work(afs_async_calls, &call->async_work);
546549
}
@@ -689,6 +692,8 @@ static int afs_deliver_cm_op_id(struct afs_call *call)
689692
if (!afs_cm_incoming_call(call))
690693
return -ENOTSUPP;
691694

695+
trace_afs_cb_call(call);
696+
692697
/* pass responsibility for the remainer of this message off to the
693698
* cache manager op */
694699
return call->type->deliver(call);
@@ -780,6 +785,7 @@ int afs_extract_data(struct afs_call *call, void *buf, size_t count,
780785
ret = rxrpc_kernel_recv_data(afs_socket, call->rxcall,
781786
buf, count, &call->offset,
782787
want_more, &call->abort_code);
788+
trace_afs_recv_data(call, count, call->offset, want_more, ret);
783789
if (ret == 0 || ret == -EAGAIN)
784790
return ret;
785791

include/trace/events/afs.h

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/* AFS tracepoints
2+
*
3+
* Copyright (C) 2016 Red Hat, Inc. All Rights Reserved.
4+
* Written by David Howells (dhowells@redhat.com)
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU General Public Licence
8+
* as published by the Free Software Foundation; either version
9+
* 2 of the Licence, or (at your option) any later version.
10+
*/
11+
#undef TRACE_SYSTEM
12+
#define TRACE_SYSTEM afs
13+
14+
#if !defined(_TRACE_AFS_H) || defined(TRACE_HEADER_MULTI_READ)
15+
#define _TRACE_AFS_H
16+
17+
#include <linux/tracepoint.h>
18+
19+
TRACE_EVENT(afs_recv_data,
20+
TP_PROTO(struct afs_call *call, unsigned count, unsigned offset,
21+
bool want_more, int ret),
22+
23+
TP_ARGS(call, count, offset, want_more, ret),
24+
25+
TP_STRUCT__entry(
26+
__field(struct rxrpc_call *, rxcall )
27+
__field(struct afs_call *, call )
28+
__field(enum afs_call_state, state )
29+
__field(unsigned int, count )
30+
__field(unsigned int, offset )
31+
__field(unsigned short, unmarshall )
32+
__field(bool, want_more )
33+
__field(int, ret )
34+
),
35+
36+
TP_fast_assign(
37+
__entry->rxcall = call->rxcall;
38+
__entry->call = call;
39+
__entry->state = call->state;
40+
__entry->unmarshall = call->unmarshall;
41+
__entry->count = count;
42+
__entry->offset = offset;
43+
__entry->want_more = want_more;
44+
__entry->ret = ret;
45+
),
46+
47+
TP_printk("c=%p ac=%p s=%u u=%u %u/%u wm=%u ret=%d",
48+
__entry->rxcall,
49+
__entry->call,
50+
__entry->state, __entry->unmarshall,
51+
__entry->offset, __entry->count,
52+
__entry->want_more, __entry->ret)
53+
);
54+
55+
TRACE_EVENT(afs_notify_call,
56+
TP_PROTO(struct rxrpc_call *rxcall, struct afs_call *call),
57+
58+
TP_ARGS(rxcall, call),
59+
60+
TP_STRUCT__entry(
61+
__field(struct rxrpc_call *, rxcall )
62+
__field(struct afs_call *, call )
63+
__field(enum afs_call_state, state )
64+
__field(unsigned short, unmarshall )
65+
),
66+
67+
TP_fast_assign(
68+
__entry->rxcall = rxcall;
69+
__entry->call = call;
70+
__entry->state = call->state;
71+
__entry->unmarshall = call->unmarshall;
72+
),
73+
74+
TP_printk("c=%p ac=%p s=%u u=%u",
75+
__entry->rxcall,
76+
__entry->call,
77+
__entry->state, __entry->unmarshall)
78+
);
79+
80+
TRACE_EVENT(afs_cb_call,
81+
TP_PROTO(struct afs_call *call),
82+
83+
TP_ARGS(call),
84+
85+
TP_STRUCT__entry(
86+
__field(struct rxrpc_call *, rxcall )
87+
__field(struct afs_call *, call )
88+
__field(const char *, name )
89+
__field(u32, op )
90+
),
91+
92+
TP_fast_assign(
93+
__entry->rxcall = call->rxcall;
94+
__entry->call = call;
95+
__entry->name = call->type->name;
96+
__entry->op = call->operation_ID;
97+
),
98+
99+
TP_printk("c=%p ac=%p %s o=%u",
100+
__entry->rxcall,
101+
__entry->call,
102+
__entry->name,
103+
__entry->op)
104+
);
105+
106+
#endif /* _TRACE_AFS_H */
107+
108+
/* This part must be outside protection */
109+
#include <trace/define_trace.h>

0 commit comments

Comments
 (0)