]>
Commit | Line | Data |
---|---|---|
52761858 SL |
1 | From b77159d89958e0e59dfa4d5063d8dca7d30356e4 Mon Sep 17 00:00:00 2001 |
2 | From: Sasha Levin <sashal@kernel.org> | |
3 | Date: Fri, 28 Oct 2022 10:47:09 -0400 | |
4 | Subject: NFSD: Trace delegation revocations | |
5 | ||
6 | From: Chuck Lever <chuck.lever@oracle.com> | |
7 | ||
8 | [ Upstream commit a1c74569bbde91299f24535abf711be5c84df9de ] | |
9 | ||
10 | Delegation revocation is an exceptional event that is not otherwise | |
11 | visible externally (eg, no network traffic is emitted). Generate a | |
12 | trace record when it occurs so that revocation can be observed or | |
13 | other activity can be triggered. Example: | |
14 | ||
15 | nfsd-1104 [005] 1912.002544: nfsd_stid_revoke: client 633c9343:4e82788d stateid 00000003:00000001 ref=2 type=DELEG | |
16 | ||
17 | Trace infrastructure is provided for subsequent additional tracing | |
18 | related to nfs4_stid activity. | |
19 | ||
20 | Signed-off-by: Chuck Lever <chuck.lever@oracle.com> | |
21 | Tested-by: Jeff Layton <jlayton@kernel.org> | |
22 | Reviewed-by: Jeff Layton <jlayton@kernel.org> | |
23 | Signed-off-by: Chuck Lever <chuck.lever@oracle.com> | |
24 | --- | |
25 | fs/nfsd/nfs4state.c | 2 ++ | |
26 | fs/nfsd/trace.h | 55 +++++++++++++++++++++++++++++++++++++++++++++ | |
27 | 2 files changed, 57 insertions(+) | |
28 | ||
29 | diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c | |
30 | index 9351111730834..b2a4d442af669 100644 | |
31 | --- a/fs/nfsd/nfs4state.c | |
32 | +++ b/fs/nfsd/nfs4state.c | |
33 | @@ -1366,6 +1366,8 @@ static void revoke_delegation(struct nfs4_delegation *dp) | |
34 | ||
35 | WARN_ON(!list_empty(&dp->dl_recall_lru)); | |
36 | ||
37 | + trace_nfsd_stid_revoke(&dp->dl_stid); | |
38 | + | |
39 | if (clp->cl_minorversion) { | |
40 | spin_lock(&clp->cl_lock); | |
41 | dp->dl_stid.sc_type = NFS4_REVOKED_DELEG_STID; | |
42 | diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h | |
43 | index d55a05f1a58f7..d50d4d6e822df 100644 | |
44 | --- a/fs/nfsd/trace.h | |
45 | +++ b/fs/nfsd/trace.h | |
46 | @@ -637,6 +637,61 @@ DEFINE_EVENT(nfsd_stateseqid_class, nfsd_##name, \ | |
47 | DEFINE_STATESEQID_EVENT(preprocess); | |
48 | DEFINE_STATESEQID_EVENT(open_confirm); | |
49 | ||
50 | +TRACE_DEFINE_ENUM(NFS4_OPEN_STID); | |
51 | +TRACE_DEFINE_ENUM(NFS4_LOCK_STID); | |
52 | +TRACE_DEFINE_ENUM(NFS4_DELEG_STID); | |
53 | +TRACE_DEFINE_ENUM(NFS4_CLOSED_STID); | |
54 | +TRACE_DEFINE_ENUM(NFS4_REVOKED_DELEG_STID); | |
55 | +TRACE_DEFINE_ENUM(NFS4_CLOSED_DELEG_STID); | |
56 | +TRACE_DEFINE_ENUM(NFS4_LAYOUT_STID); | |
57 | + | |
58 | +#define show_stid_type(x) \ | |
59 | + __print_flags(x, "|", \ | |
60 | + { NFS4_OPEN_STID, "OPEN" }, \ | |
61 | + { NFS4_LOCK_STID, "LOCK" }, \ | |
62 | + { NFS4_DELEG_STID, "DELEG" }, \ | |
63 | + { NFS4_CLOSED_STID, "CLOSED" }, \ | |
64 | + { NFS4_REVOKED_DELEG_STID, "REVOKED" }, \ | |
65 | + { NFS4_CLOSED_DELEG_STID, "CLOSED_DELEG" }, \ | |
66 | + { NFS4_LAYOUT_STID, "LAYOUT" }) | |
67 | + | |
68 | +DECLARE_EVENT_CLASS(nfsd_stid_class, | |
69 | + TP_PROTO( | |
70 | + const struct nfs4_stid *stid | |
71 | + ), | |
72 | + TP_ARGS(stid), | |
73 | + TP_STRUCT__entry( | |
74 | + __field(unsigned long, sc_type) | |
75 | + __field(int, sc_count) | |
76 | + __field(u32, cl_boot) | |
77 | + __field(u32, cl_id) | |
78 | + __field(u32, si_id) | |
79 | + __field(u32, si_generation) | |
80 | + ), | |
81 | + TP_fast_assign( | |
82 | + const stateid_t *stp = &stid->sc_stateid; | |
83 | + | |
84 | + __entry->sc_type = stid->sc_type; | |
85 | + __entry->sc_count = refcount_read(&stid->sc_count); | |
86 | + __entry->cl_boot = stp->si_opaque.so_clid.cl_boot; | |
87 | + __entry->cl_id = stp->si_opaque.so_clid.cl_id; | |
88 | + __entry->si_id = stp->si_opaque.so_id; | |
89 | + __entry->si_generation = stp->si_generation; | |
90 | + ), | |
91 | + TP_printk("client %08x:%08x stateid %08x:%08x ref=%d type=%s", | |
92 | + __entry->cl_boot, __entry->cl_id, | |
93 | + __entry->si_id, __entry->si_generation, | |
94 | + __entry->sc_count, show_stid_type(__entry->sc_type) | |
95 | + ) | |
96 | +); | |
97 | + | |
98 | +#define DEFINE_STID_EVENT(name) \ | |
99 | +DEFINE_EVENT(nfsd_stid_class, nfsd_stid_##name, \ | |
100 | + TP_PROTO(const struct nfs4_stid *stid), \ | |
101 | + TP_ARGS(stid)) | |
102 | + | |
103 | +DEFINE_STID_EVENT(revoke); | |
104 | + | |
105 | DECLARE_EVENT_CLASS(nfsd_clientid_class, | |
106 | TP_PROTO(const clientid_t *clid), | |
107 | TP_ARGS(clid), | |
108 | -- | |
109 | 2.43.0 | |
110 |