blob: f8d677dd67056d64e02c793d61825229b390b660 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Trond Myklebustf4ce1292013-08-19 18:59:33 -04002/*
3 * Copyright (c) 2013 Trond Myklebust <Trond.Myklebust@netapp.com>
4 */
5#undef TRACE_SYSTEM
6#define TRACE_SYSTEM nfs
7
8#if !defined(_TRACE_NFS_H) || defined(TRACE_HEADER_MULTI_READ)
9#define _TRACE_NFS_H
10
11#include <linux/tracepoint.h>
Jeff Layton1eb5d982018-01-09 08:21:17 -050012#include <linux/iversion.h>
Trond Myklebustf4ce1292013-08-19 18:59:33 -040013
Chuck Lever7d4006c2019-06-19 10:34:03 -040014TRACE_DEFINE_ENUM(DT_UNKNOWN);
15TRACE_DEFINE_ENUM(DT_FIFO);
16TRACE_DEFINE_ENUM(DT_CHR);
17TRACE_DEFINE_ENUM(DT_DIR);
18TRACE_DEFINE_ENUM(DT_BLK);
19TRACE_DEFINE_ENUM(DT_REG);
20TRACE_DEFINE_ENUM(DT_LNK);
21TRACE_DEFINE_ENUM(DT_SOCK);
22TRACE_DEFINE_ENUM(DT_WHT);
23
Trond Myklebustf4ce1292013-08-19 18:59:33 -040024#define nfs_show_file_type(ftype) \
25 __print_symbolic(ftype, \
26 { DT_UNKNOWN, "UNKNOWN" }, \
27 { DT_FIFO, "FIFO" }, \
28 { DT_CHR, "CHR" }, \
29 { DT_DIR, "DIR" }, \
30 { DT_BLK, "BLK" }, \
31 { DT_REG, "REG" }, \
32 { DT_LNK, "LNK" }, \
33 { DT_SOCK, "SOCK" }, \
34 { DT_WHT, "WHT" })
35
Chuck Lever7d4006c2019-06-19 10:34:03 -040036TRACE_DEFINE_ENUM(NFS_INO_INVALID_DATA);
37TRACE_DEFINE_ENUM(NFS_INO_INVALID_ATIME);
38TRACE_DEFINE_ENUM(NFS_INO_INVALID_ACCESS);
39TRACE_DEFINE_ENUM(NFS_INO_INVALID_ACL);
40TRACE_DEFINE_ENUM(NFS_INO_REVAL_PAGECACHE);
41TRACE_DEFINE_ENUM(NFS_INO_REVAL_FORCED);
42TRACE_DEFINE_ENUM(NFS_INO_INVALID_LABEL);
43TRACE_DEFINE_ENUM(NFS_INO_INVALID_CHANGE);
44TRACE_DEFINE_ENUM(NFS_INO_INVALID_CTIME);
45TRACE_DEFINE_ENUM(NFS_INO_INVALID_MTIME);
46TRACE_DEFINE_ENUM(NFS_INO_INVALID_SIZE);
47TRACE_DEFINE_ENUM(NFS_INO_INVALID_OTHER);
48
Trond Myklebustf4ce1292013-08-19 18:59:33 -040049#define nfs_show_cache_validity(v) \
50 __print_flags(v, "|", \
Trond Myklebustf4ce1292013-08-19 18:59:33 -040051 { NFS_INO_INVALID_DATA, "INVALID_DATA" }, \
52 { NFS_INO_INVALID_ATIME, "INVALID_ATIME" }, \
53 { NFS_INO_INVALID_ACCESS, "INVALID_ACCESS" }, \
54 { NFS_INO_INVALID_ACL, "INVALID_ACL" }, \
55 { NFS_INO_REVAL_PAGECACHE, "REVAL_PAGECACHE" }, \
56 { NFS_INO_REVAL_FORCED, "REVAL_FORCED" }, \
Chuck Lever7d4006c2019-06-19 10:34:03 -040057 { NFS_INO_INVALID_LABEL, "INVALID_LABEL" }, \
58 { NFS_INO_INVALID_CHANGE, "INVALID_CHANGE" }, \
59 { NFS_INO_INVALID_CTIME, "INVALID_CTIME" }, \
60 { NFS_INO_INVALID_MTIME, "INVALID_MTIME" }, \
61 { NFS_INO_INVALID_SIZE, "INVALID_SIZE" }, \
62 { NFS_INO_INVALID_OTHER, "INVALID_OTHER" })
63
64TRACE_DEFINE_ENUM(NFS_INO_ADVISE_RDPLUS);
65TRACE_DEFINE_ENUM(NFS_INO_STALE);
66TRACE_DEFINE_ENUM(NFS_INO_ACL_LRU_SET);
67TRACE_DEFINE_ENUM(NFS_INO_INVALIDATING);
68TRACE_DEFINE_ENUM(NFS_INO_FSCACHE);
69TRACE_DEFINE_ENUM(NFS_INO_FSCACHE_LOCK);
70TRACE_DEFINE_ENUM(NFS_INO_LAYOUTCOMMIT);
71TRACE_DEFINE_ENUM(NFS_INO_LAYOUTCOMMITTING);
72TRACE_DEFINE_ENUM(NFS_INO_LAYOUTSTATS);
73TRACE_DEFINE_ENUM(NFS_INO_ODIRECT);
Trond Myklebustf4ce1292013-08-19 18:59:33 -040074
75#define nfs_show_nfsi_flags(v) \
76 __print_flags(v, "|", \
Chuck Lever7d4006c2019-06-19 10:34:03 -040077 { BIT(NFS_INO_ADVISE_RDPLUS), "ADVISE_RDPLUS" }, \
78 { BIT(NFS_INO_STALE), "STALE" }, \
79 { BIT(NFS_INO_ACL_LRU_SET), "ACL_LRU_SET" }, \
80 { BIT(NFS_INO_INVALIDATING), "INVALIDATING" }, \
81 { BIT(NFS_INO_FSCACHE), "FSCACHE" }, \
82 { BIT(NFS_INO_FSCACHE_LOCK), "FSCACHE_LOCK" }, \
83 { BIT(NFS_INO_LAYOUTCOMMIT), "NEED_LAYOUTCOMMIT" }, \
84 { BIT(NFS_INO_LAYOUTCOMMITTING), "LAYOUTCOMMIT" }, \
85 { BIT(NFS_INO_LAYOUTSTATS), "LAYOUTSTATS" }, \
86 { BIT(NFS_INO_ODIRECT), "ODIRECT" })
Trond Myklebustf4ce1292013-08-19 18:59:33 -040087
88DECLARE_EVENT_CLASS(nfs_inode_event,
89 TP_PROTO(
90 const struct inode *inode
91 ),
92
93 TP_ARGS(inode),
94
95 TP_STRUCT__entry(
96 __field(dev_t, dev)
97 __field(u32, fhandle)
98 __field(u64, fileid)
99 __field(u64, version)
100 ),
101
102 TP_fast_assign(
103 const struct nfs_inode *nfsi = NFS_I(inode);
104 __entry->dev = inode->i_sb->s_dev;
105 __entry->fileid = nfsi->fileid;
106 __entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
Jeff Layton1eb5d982018-01-09 08:21:17 -0500107 __entry->version = inode_peek_iversion_raw(inode);
Trond Myklebustf4ce1292013-08-19 18:59:33 -0400108 ),
109
110 TP_printk(
111 "fileid=%02x:%02x:%llu fhandle=0x%08x version=%llu ",
112 MAJOR(__entry->dev), MINOR(__entry->dev),
113 (unsigned long long)__entry->fileid,
114 __entry->fhandle,
115 (unsigned long long)__entry->version
116 )
117);
118
119DECLARE_EVENT_CLASS(nfs_inode_event_done,
120 TP_PROTO(
121 const struct inode *inode,
122 int error
123 ),
124
125 TP_ARGS(inode, error),
126
127 TP_STRUCT__entry(
Chuck Lever38a638a2019-06-19 10:33:58 -0400128 __field(unsigned long, error)
Trond Myklebustf4ce1292013-08-19 18:59:33 -0400129 __field(dev_t, dev)
130 __field(u32, fhandle)
131 __field(unsigned char, type)
132 __field(u64, fileid)
133 __field(u64, version)
134 __field(loff_t, size)
135 __field(unsigned long, nfsi_flags)
136 __field(unsigned long, cache_validity)
137 ),
138
139 TP_fast_assign(
140 const struct nfs_inode *nfsi = NFS_I(inode);
Chuck Lever38a638a2019-06-19 10:33:58 -0400141 __entry->error = error < 0 ? -error : 0;
Trond Myklebustf4ce1292013-08-19 18:59:33 -0400142 __entry->dev = inode->i_sb->s_dev;
143 __entry->fileid = nfsi->fileid;
144 __entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
145 __entry->type = nfs_umode_to_dtype(inode->i_mode);
Jeff Layton1eb5d982018-01-09 08:21:17 -0500146 __entry->version = inode_peek_iversion_raw(inode);
Trond Myklebustf4ce1292013-08-19 18:59:33 -0400147 __entry->size = i_size_read(inode);
148 __entry->nfsi_flags = nfsi->flags;
149 __entry->cache_validity = nfsi->cache_validity;
150 ),
151
152 TP_printk(
Chuck Lever38a638a2019-06-19 10:33:58 -0400153 "error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
Trond Myklebustf4ce1292013-08-19 18:59:33 -0400154 "type=%u (%s) version=%llu size=%lld "
Chuck Lever7d4006c2019-06-19 10:34:03 -0400155 "cache_validity=0x%lx (%s) nfs_flags=0x%lx (%s)",
Chuck Lever38a638a2019-06-19 10:33:58 -0400156 -__entry->error, nfs_show_status(__entry->error),
Trond Myklebustf4ce1292013-08-19 18:59:33 -0400157 MAJOR(__entry->dev), MINOR(__entry->dev),
158 (unsigned long long)__entry->fileid,
159 __entry->fhandle,
160 __entry->type,
161 nfs_show_file_type(__entry->type),
162 (unsigned long long)__entry->version,
163 (long long)__entry->size,
164 __entry->cache_validity,
165 nfs_show_cache_validity(__entry->cache_validity),
166 __entry->nfsi_flags,
167 nfs_show_nfsi_flags(__entry->nfsi_flags)
168 )
169);
170
171#define DEFINE_NFS_INODE_EVENT(name) \
172 DEFINE_EVENT(nfs_inode_event, name, \
173 TP_PROTO( \
174 const struct inode *inode \
175 ), \
176 TP_ARGS(inode))
177#define DEFINE_NFS_INODE_EVENT_DONE(name) \
178 DEFINE_EVENT(nfs_inode_event_done, name, \
179 TP_PROTO( \
180 const struct inode *inode, \
181 int error \
182 ), \
183 TP_ARGS(inode, error))
184DEFINE_NFS_INODE_EVENT(nfs_refresh_inode_enter);
185DEFINE_NFS_INODE_EVENT_DONE(nfs_refresh_inode_exit);
186DEFINE_NFS_INODE_EVENT(nfs_revalidate_inode_enter);
187DEFINE_NFS_INODE_EVENT_DONE(nfs_revalidate_inode_exit);
188DEFINE_NFS_INODE_EVENT(nfs_invalidate_mapping_enter);
189DEFINE_NFS_INODE_EVENT_DONE(nfs_invalidate_mapping_exit);
190DEFINE_NFS_INODE_EVENT(nfs_getattr_enter);
191DEFINE_NFS_INODE_EVENT_DONE(nfs_getattr_exit);
192DEFINE_NFS_INODE_EVENT(nfs_setattr_enter);
193DEFINE_NFS_INODE_EVENT_DONE(nfs_setattr_exit);
194DEFINE_NFS_INODE_EVENT(nfs_writeback_page_enter);
195DEFINE_NFS_INODE_EVENT_DONE(nfs_writeback_page_exit);
196DEFINE_NFS_INODE_EVENT(nfs_writeback_inode_enter);
197DEFINE_NFS_INODE_EVENT_DONE(nfs_writeback_inode_exit);
198DEFINE_NFS_INODE_EVENT(nfs_fsync_enter);
199DEFINE_NFS_INODE_EVENT_DONE(nfs_fsync_exit);
200DEFINE_NFS_INODE_EVENT(nfs_access_enter);
Trond Myklebuste8194b72020-01-06 15:25:12 -0500201
202TRACE_EVENT(nfs_access_exit,
203 TP_PROTO(
204 const struct inode *inode,
205 unsigned int mask,
206 unsigned int permitted,
207 int error
208 ),
209
210 TP_ARGS(inode, mask, permitted, error),
211
212 TP_STRUCT__entry(
213 __field(unsigned long, error)
214 __field(dev_t, dev)
215 __field(u32, fhandle)
216 __field(unsigned char, type)
217 __field(u64, fileid)
218 __field(u64, version)
219 __field(loff_t, size)
220 __field(unsigned long, nfsi_flags)
221 __field(unsigned long, cache_validity)
222 __field(unsigned int, mask)
223 __field(unsigned int, permitted)
224 ),
225
226 TP_fast_assign(
227 const struct nfs_inode *nfsi = NFS_I(inode);
228 __entry->error = error < 0 ? -error : 0;
229 __entry->dev = inode->i_sb->s_dev;
230 __entry->fileid = nfsi->fileid;
231 __entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
232 __entry->type = nfs_umode_to_dtype(inode->i_mode);
233 __entry->version = inode_peek_iversion_raw(inode);
234 __entry->size = i_size_read(inode);
235 __entry->nfsi_flags = nfsi->flags;
236 __entry->cache_validity = nfsi->cache_validity;
237 __entry->mask = mask;
238 __entry->permitted = permitted;
239 ),
240
241 TP_printk(
242 "error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
243 "type=%u (%s) version=%llu size=%lld "
244 "cache_validity=0x%lx (%s) nfs_flags=0x%lx (%s) "
245 "mask=0x%x permitted=0x%x",
246 -__entry->error, nfs_show_status(__entry->error),
247 MAJOR(__entry->dev), MINOR(__entry->dev),
248 (unsigned long long)__entry->fileid,
249 __entry->fhandle,
250 __entry->type,
251 nfs_show_file_type(__entry->type),
252 (unsigned long long)__entry->version,
253 (long long)__entry->size,
254 __entry->cache_validity,
255 nfs_show_cache_validity(__entry->cache_validity),
256 __entry->nfsi_flags,
257 nfs_show_nfsi_flags(__entry->nfsi_flags),
258 __entry->mask, __entry->permitted
259 )
260);
Trond Myklebustf4ce1292013-08-19 18:59:33 -0400261
Chuck Lever7d4006c2019-06-19 10:34:03 -0400262TRACE_DEFINE_ENUM(LOOKUP_FOLLOW);
263TRACE_DEFINE_ENUM(LOOKUP_DIRECTORY);
264TRACE_DEFINE_ENUM(LOOKUP_AUTOMOUNT);
265TRACE_DEFINE_ENUM(LOOKUP_PARENT);
266TRACE_DEFINE_ENUM(LOOKUP_REVAL);
267TRACE_DEFINE_ENUM(LOOKUP_RCU);
268TRACE_DEFINE_ENUM(LOOKUP_NO_REVAL);
Chuck Lever7d4006c2019-06-19 10:34:03 -0400269TRACE_DEFINE_ENUM(LOOKUP_OPEN);
270TRACE_DEFINE_ENUM(LOOKUP_CREATE);
271TRACE_DEFINE_ENUM(LOOKUP_EXCL);
272TRACE_DEFINE_ENUM(LOOKUP_RENAME_TARGET);
273TRACE_DEFINE_ENUM(LOOKUP_JUMPED);
274TRACE_DEFINE_ENUM(LOOKUP_ROOT);
275TRACE_DEFINE_ENUM(LOOKUP_EMPTY);
276TRACE_DEFINE_ENUM(LOOKUP_DOWN);
277
Trond Myklebust6e0d0be2013-08-20 11:26:17 -0400278#define show_lookup_flags(flags) \
Chuck Lever7d4006c2019-06-19 10:34:03 -0400279 __print_flags(flags, "|", \
280 { LOOKUP_FOLLOW, "FOLLOW" }, \
Trond Myklebust6e0d0be2013-08-20 11:26:17 -0400281 { LOOKUP_DIRECTORY, "DIRECTORY" }, \
Chuck Lever7d4006c2019-06-19 10:34:03 -0400282 { LOOKUP_AUTOMOUNT, "AUTOMOUNT" }, \
283 { LOOKUP_PARENT, "PARENT" }, \
284 { LOOKUP_REVAL, "REVAL" }, \
285 { LOOKUP_RCU, "RCU" }, \
286 { LOOKUP_NO_REVAL, "NO_REVAL" }, \
Trond Myklebust6e0d0be2013-08-20 11:26:17 -0400287 { LOOKUP_OPEN, "OPEN" }, \
288 { LOOKUP_CREATE, "CREATE" }, \
Chuck Lever7d4006c2019-06-19 10:34:03 -0400289 { LOOKUP_EXCL, "EXCL" }, \
290 { LOOKUP_RENAME_TARGET, "RENAME_TARGET" }, \
291 { LOOKUP_JUMPED, "JUMPED" }, \
292 { LOOKUP_ROOT, "ROOT" }, \
293 { LOOKUP_EMPTY, "EMPTY" }, \
294 { LOOKUP_DOWN, "DOWN" })
Trond Myklebust6e0d0be2013-08-20 11:26:17 -0400295
296DECLARE_EVENT_CLASS(nfs_lookup_event,
297 TP_PROTO(
298 const struct inode *dir,
299 const struct dentry *dentry,
300 unsigned int flags
301 ),
302
303 TP_ARGS(dir, dentry, flags),
304
305 TP_STRUCT__entry(
Chuck Lever7d4006c2019-06-19 10:34:03 -0400306 __field(unsigned long, flags)
Trond Myklebust6e0d0be2013-08-20 11:26:17 -0400307 __field(dev_t, dev)
308 __field(u64, dir)
309 __string(name, dentry->d_name.name)
310 ),
311
312 TP_fast_assign(
313 __entry->dev = dir->i_sb->s_dev;
314 __entry->dir = NFS_FILEID(dir);
315 __entry->flags = flags;
316 __assign_str(name, dentry->d_name.name);
317 ),
318
319 TP_printk(
Chuck Lever7d4006c2019-06-19 10:34:03 -0400320 "flags=0x%lx (%s) name=%02x:%02x:%llu/%s",
Trond Myklebust6e0d0be2013-08-20 11:26:17 -0400321 __entry->flags,
322 show_lookup_flags(__entry->flags),
323 MAJOR(__entry->dev), MINOR(__entry->dev),
324 (unsigned long long)__entry->dir,
325 __get_str(name)
326 )
327);
328
329#define DEFINE_NFS_LOOKUP_EVENT(name) \
330 DEFINE_EVENT(nfs_lookup_event, name, \
331 TP_PROTO( \
332 const struct inode *dir, \
333 const struct dentry *dentry, \
334 unsigned int flags \
335 ), \
336 TP_ARGS(dir, dentry, flags))
337
338DECLARE_EVENT_CLASS(nfs_lookup_event_done,
339 TP_PROTO(
340 const struct inode *dir,
341 const struct dentry *dentry,
342 unsigned int flags,
343 int error
344 ),
345
346 TP_ARGS(dir, dentry, flags, error),
347
348 TP_STRUCT__entry(
Chuck Lever38a638a2019-06-19 10:33:58 -0400349 __field(unsigned long, error)
Chuck Lever7d4006c2019-06-19 10:34:03 -0400350 __field(unsigned long, flags)
Trond Myklebust6e0d0be2013-08-20 11:26:17 -0400351 __field(dev_t, dev)
352 __field(u64, dir)
353 __string(name, dentry->d_name.name)
354 ),
355
356 TP_fast_assign(
357 __entry->dev = dir->i_sb->s_dev;
358 __entry->dir = NFS_FILEID(dir);
Chuck Lever38a638a2019-06-19 10:33:58 -0400359 __entry->error = error < 0 ? -error : 0;
Trond Myklebust6e0d0be2013-08-20 11:26:17 -0400360 __entry->flags = flags;
361 __assign_str(name, dentry->d_name.name);
362 ),
363
364 TP_printk(
Chuck Lever7d4006c2019-06-19 10:34:03 -0400365 "error=%ld (%s) flags=0x%lx (%s) name=%02x:%02x:%llu/%s",
Chuck Lever38a638a2019-06-19 10:33:58 -0400366 -__entry->error, nfs_show_status(__entry->error),
Trond Myklebust6e0d0be2013-08-20 11:26:17 -0400367 __entry->flags,
368 show_lookup_flags(__entry->flags),
369 MAJOR(__entry->dev), MINOR(__entry->dev),
370 (unsigned long long)__entry->dir,
371 __get_str(name)
372 )
373);
374
375#define DEFINE_NFS_LOOKUP_EVENT_DONE(name) \
376 DEFINE_EVENT(nfs_lookup_event_done, name, \
377 TP_PROTO( \
378 const struct inode *dir, \
379 const struct dentry *dentry, \
380 unsigned int flags, \
381 int error \
382 ), \
383 TP_ARGS(dir, dentry, flags, error))
384
385DEFINE_NFS_LOOKUP_EVENT(nfs_lookup_enter);
386DEFINE_NFS_LOOKUP_EVENT_DONE(nfs_lookup_exit);
387DEFINE_NFS_LOOKUP_EVENT(nfs_lookup_revalidate_enter);
388DEFINE_NFS_LOOKUP_EVENT_DONE(nfs_lookup_revalidate_exit);
389
Chuck Lever7d4006c2019-06-19 10:34:03 -0400390TRACE_DEFINE_ENUM(O_WRONLY);
391TRACE_DEFINE_ENUM(O_RDWR);
392TRACE_DEFINE_ENUM(O_CREAT);
393TRACE_DEFINE_ENUM(O_EXCL);
394TRACE_DEFINE_ENUM(O_NOCTTY);
395TRACE_DEFINE_ENUM(O_TRUNC);
396TRACE_DEFINE_ENUM(O_APPEND);
397TRACE_DEFINE_ENUM(O_NONBLOCK);
398TRACE_DEFINE_ENUM(O_DSYNC);
399TRACE_DEFINE_ENUM(O_DIRECT);
400TRACE_DEFINE_ENUM(O_LARGEFILE);
401TRACE_DEFINE_ENUM(O_DIRECTORY);
402TRACE_DEFINE_ENUM(O_NOFOLLOW);
403TRACE_DEFINE_ENUM(O_NOATIME);
404TRACE_DEFINE_ENUM(O_CLOEXEC);
405
Trond Myklebust6e0d0be2013-08-20 11:26:17 -0400406#define show_open_flags(flags) \
Chuck Lever7d4006c2019-06-19 10:34:03 -0400407 __print_flags(flags, "|", \
408 { O_WRONLY, "O_WRONLY" }, \
409 { O_RDWR, "O_RDWR" }, \
Trond Myklebust6e0d0be2013-08-20 11:26:17 -0400410 { O_CREAT, "O_CREAT" }, \
411 { O_EXCL, "O_EXCL" }, \
Chuck Lever7d4006c2019-06-19 10:34:03 -0400412 { O_NOCTTY, "O_NOCTTY" }, \
Trond Myklebust6e0d0be2013-08-20 11:26:17 -0400413 { O_TRUNC, "O_TRUNC" }, \
414 { O_APPEND, "O_APPEND" }, \
Chuck Lever7d4006c2019-06-19 10:34:03 -0400415 { O_NONBLOCK, "O_NONBLOCK" }, \
Trond Myklebust6e0d0be2013-08-20 11:26:17 -0400416 { O_DSYNC, "O_DSYNC" }, \
417 { O_DIRECT, "O_DIRECT" }, \
Chuck Lever7d4006c2019-06-19 10:34:03 -0400418 { O_LARGEFILE, "O_LARGEFILE" }, \
419 { O_DIRECTORY, "O_DIRECTORY" }, \
420 { O_NOFOLLOW, "O_NOFOLLOW" }, \
421 { O_NOATIME, "O_NOATIME" }, \
422 { O_CLOEXEC, "O_CLOEXEC" })
423
424TRACE_DEFINE_ENUM(FMODE_READ);
425TRACE_DEFINE_ENUM(FMODE_WRITE);
426TRACE_DEFINE_ENUM(FMODE_EXEC);
Trond Myklebust6e0d0be2013-08-20 11:26:17 -0400427
428#define show_fmode_flags(mode) \
429 __print_flags(mode, "|", \
430 { ((__force unsigned long)FMODE_READ), "READ" }, \
431 { ((__force unsigned long)FMODE_WRITE), "WRITE" }, \
432 { ((__force unsigned long)FMODE_EXEC), "EXEC" })
433
434TRACE_EVENT(nfs_atomic_open_enter,
435 TP_PROTO(
436 const struct inode *dir,
437 const struct nfs_open_context *ctx,
438 unsigned int flags
439 ),
440
441 TP_ARGS(dir, ctx, flags),
442
443 TP_STRUCT__entry(
Chuck Lever7d4006c2019-06-19 10:34:03 -0400444 __field(unsigned long, flags)
Trond Myklebust6e0d0be2013-08-20 11:26:17 -0400445 __field(unsigned int, fmode)
446 __field(dev_t, dev)
447 __field(u64, dir)
448 __string(name, ctx->dentry->d_name.name)
449 ),
450
451 TP_fast_assign(
452 __entry->dev = dir->i_sb->s_dev;
453 __entry->dir = NFS_FILEID(dir);
454 __entry->flags = flags;
455 __entry->fmode = (__force unsigned int)ctx->mode;
456 __assign_str(name, ctx->dentry->d_name.name);
457 ),
458
459 TP_printk(
Chuck Lever7d4006c2019-06-19 10:34:03 -0400460 "flags=0x%lx (%s) fmode=%s name=%02x:%02x:%llu/%s",
Trond Myklebust6e0d0be2013-08-20 11:26:17 -0400461 __entry->flags,
462 show_open_flags(__entry->flags),
463 show_fmode_flags(__entry->fmode),
464 MAJOR(__entry->dev), MINOR(__entry->dev),
465 (unsigned long long)__entry->dir,
466 __get_str(name)
467 )
468);
469
470TRACE_EVENT(nfs_atomic_open_exit,
471 TP_PROTO(
472 const struct inode *dir,
473 const struct nfs_open_context *ctx,
474 unsigned int flags,
475 int error
476 ),
477
478 TP_ARGS(dir, ctx, flags, error),
479
480 TP_STRUCT__entry(
Chuck Lever38a638a2019-06-19 10:33:58 -0400481 __field(unsigned long, error)
Chuck Lever7d4006c2019-06-19 10:34:03 -0400482 __field(unsigned long, flags)
Trond Myklebust6e0d0be2013-08-20 11:26:17 -0400483 __field(unsigned int, fmode)
484 __field(dev_t, dev)
485 __field(u64, dir)
486 __string(name, ctx->dentry->d_name.name)
487 ),
488
489 TP_fast_assign(
Chuck Lever38a638a2019-06-19 10:33:58 -0400490 __entry->error = -error;
Trond Myklebust6e0d0be2013-08-20 11:26:17 -0400491 __entry->dev = dir->i_sb->s_dev;
492 __entry->dir = NFS_FILEID(dir);
493 __entry->flags = flags;
494 __entry->fmode = (__force unsigned int)ctx->mode;
495 __assign_str(name, ctx->dentry->d_name.name);
496 ),
497
498 TP_printk(
Chuck Lever7d4006c2019-06-19 10:34:03 -0400499 "error=%ld (%s) flags=0x%lx (%s) fmode=%s "
Trond Myklebust6e0d0be2013-08-20 11:26:17 -0400500 "name=%02x:%02x:%llu/%s",
Chuck Lever38a638a2019-06-19 10:33:58 -0400501 -__entry->error, nfs_show_status(__entry->error),
Trond Myklebust6e0d0be2013-08-20 11:26:17 -0400502 __entry->flags,
503 show_open_flags(__entry->flags),
504 show_fmode_flags(__entry->fmode),
505 MAJOR(__entry->dev), MINOR(__entry->dev),
506 (unsigned long long)__entry->dir,
507 __get_str(name)
508 )
509);
510
Trond Myklebust8b0ad3d2013-08-21 10:53:09 -0400511TRACE_EVENT(nfs_create_enter,
512 TP_PROTO(
513 const struct inode *dir,
514 const struct dentry *dentry,
515 unsigned int flags
516 ),
517
518 TP_ARGS(dir, dentry, flags),
519
520 TP_STRUCT__entry(
Chuck Lever7d4006c2019-06-19 10:34:03 -0400521 __field(unsigned long, flags)
Trond Myklebust8b0ad3d2013-08-21 10:53:09 -0400522 __field(dev_t, dev)
523 __field(u64, dir)
524 __string(name, dentry->d_name.name)
525 ),
526
527 TP_fast_assign(
528 __entry->dev = dir->i_sb->s_dev;
529 __entry->dir = NFS_FILEID(dir);
530 __entry->flags = flags;
531 __assign_str(name, dentry->d_name.name);
532 ),
533
534 TP_printk(
Chuck Lever7d4006c2019-06-19 10:34:03 -0400535 "flags=0x%lx (%s) name=%02x:%02x:%llu/%s",
Trond Myklebust8b0ad3d2013-08-21 10:53:09 -0400536 __entry->flags,
537 show_open_flags(__entry->flags),
538 MAJOR(__entry->dev), MINOR(__entry->dev),
539 (unsigned long long)__entry->dir,
540 __get_str(name)
541 )
542);
543
544TRACE_EVENT(nfs_create_exit,
545 TP_PROTO(
546 const struct inode *dir,
547 const struct dentry *dentry,
548 unsigned int flags,
549 int error
550 ),
551
552 TP_ARGS(dir, dentry, flags, error),
553
554 TP_STRUCT__entry(
Chuck Lever38a638a2019-06-19 10:33:58 -0400555 __field(unsigned long, error)
Chuck Lever7d4006c2019-06-19 10:34:03 -0400556 __field(unsigned long, flags)
Trond Myklebust8b0ad3d2013-08-21 10:53:09 -0400557 __field(dev_t, dev)
558 __field(u64, dir)
559 __string(name, dentry->d_name.name)
560 ),
561
562 TP_fast_assign(
Chuck Lever38a638a2019-06-19 10:33:58 -0400563 __entry->error = -error;
Trond Myklebust8b0ad3d2013-08-21 10:53:09 -0400564 __entry->dev = dir->i_sb->s_dev;
565 __entry->dir = NFS_FILEID(dir);
566 __entry->flags = flags;
567 __assign_str(name, dentry->d_name.name);
568 ),
569
570 TP_printk(
Chuck Lever7d4006c2019-06-19 10:34:03 -0400571 "error=%ld (%s) flags=0x%lx (%s) name=%02x:%02x:%llu/%s",
Chuck Lever38a638a2019-06-19 10:33:58 -0400572 -__entry->error, nfs_show_status(__entry->error),
Trond Myklebust8b0ad3d2013-08-21 10:53:09 -0400573 __entry->flags,
574 show_open_flags(__entry->flags),
575 MAJOR(__entry->dev), MINOR(__entry->dev),
576 (unsigned long long)__entry->dir,
577 __get_str(name)
578 )
579);
580
Trond Myklebust1ca42382013-08-21 12:36:04 -0400581DECLARE_EVENT_CLASS(nfs_directory_event,
582 TP_PROTO(
583 const struct inode *dir,
584 const struct dentry *dentry
585 ),
586
587 TP_ARGS(dir, dentry),
588
589 TP_STRUCT__entry(
590 __field(dev_t, dev)
591 __field(u64, dir)
592 __string(name, dentry->d_name.name)
593 ),
594
595 TP_fast_assign(
596 __entry->dev = dir->i_sb->s_dev;
597 __entry->dir = NFS_FILEID(dir);
598 __assign_str(name, dentry->d_name.name);
599 ),
600
601 TP_printk(
602 "name=%02x:%02x:%llu/%s",
603 MAJOR(__entry->dev), MINOR(__entry->dev),
604 (unsigned long long)__entry->dir,
605 __get_str(name)
606 )
607);
608
609#define DEFINE_NFS_DIRECTORY_EVENT(name) \
610 DEFINE_EVENT(nfs_directory_event, name, \
611 TP_PROTO( \
612 const struct inode *dir, \
613 const struct dentry *dentry \
614 ), \
615 TP_ARGS(dir, dentry))
616
617DECLARE_EVENT_CLASS(nfs_directory_event_done,
618 TP_PROTO(
619 const struct inode *dir,
620 const struct dentry *dentry,
621 int error
622 ),
623
624 TP_ARGS(dir, dentry, error),
625
626 TP_STRUCT__entry(
Chuck Lever38a638a2019-06-19 10:33:58 -0400627 __field(unsigned long, error)
Trond Myklebust1ca42382013-08-21 12:36:04 -0400628 __field(dev_t, dev)
629 __field(u64, dir)
630 __string(name, dentry->d_name.name)
631 ),
632
633 TP_fast_assign(
634 __entry->dev = dir->i_sb->s_dev;
635 __entry->dir = NFS_FILEID(dir);
Chuck Lever38a638a2019-06-19 10:33:58 -0400636 __entry->error = error < 0 ? -error : 0;
Trond Myklebust1ca42382013-08-21 12:36:04 -0400637 __assign_str(name, dentry->d_name.name);
638 ),
639
640 TP_printk(
Chuck Lever38a638a2019-06-19 10:33:58 -0400641 "error=%ld (%s) name=%02x:%02x:%llu/%s",
642 -__entry->error, nfs_show_status(__entry->error),
Trond Myklebust1ca42382013-08-21 12:36:04 -0400643 MAJOR(__entry->dev), MINOR(__entry->dev),
644 (unsigned long long)__entry->dir,
645 __get_str(name)
646 )
647);
648
649#define DEFINE_NFS_DIRECTORY_EVENT_DONE(name) \
650 DEFINE_EVENT(nfs_directory_event_done, name, \
651 TP_PROTO( \
652 const struct inode *dir, \
653 const struct dentry *dentry, \
654 int error \
655 ), \
656 TP_ARGS(dir, dentry, error))
657
658DEFINE_NFS_DIRECTORY_EVENT(nfs_mknod_enter);
659DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_mknod_exit);
660DEFINE_NFS_DIRECTORY_EVENT(nfs_mkdir_enter);
661DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_mkdir_exit);
662DEFINE_NFS_DIRECTORY_EVENT(nfs_rmdir_enter);
663DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_rmdir_exit);
664DEFINE_NFS_DIRECTORY_EVENT(nfs_remove_enter);
665DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_remove_exit);
666DEFINE_NFS_DIRECTORY_EVENT(nfs_unlink_enter);
667DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_unlink_exit);
668DEFINE_NFS_DIRECTORY_EVENT(nfs_symlink_enter);
669DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_symlink_exit);
670
Trond Myklebust1fd10852013-08-21 13:54:44 -0400671TRACE_EVENT(nfs_link_enter,
672 TP_PROTO(
673 const struct inode *inode,
674 const struct inode *dir,
675 const struct dentry *dentry
676 ),
677
678 TP_ARGS(inode, dir, dentry),
679
680 TP_STRUCT__entry(
681 __field(dev_t, dev)
682 __field(u64, fileid)
683 __field(u64, dir)
684 __string(name, dentry->d_name.name)
685 ),
686
687 TP_fast_assign(
688 __entry->dev = inode->i_sb->s_dev;
689 __entry->fileid = NFS_FILEID(inode);
690 __entry->dir = NFS_FILEID(dir);
691 __assign_str(name, dentry->d_name.name);
692 ),
693
694 TP_printk(
695 "fileid=%02x:%02x:%llu name=%02x:%02x:%llu/%s",
696 MAJOR(__entry->dev), MINOR(__entry->dev),
697 __entry->fileid,
698 MAJOR(__entry->dev), MINOR(__entry->dev),
699 (unsigned long long)__entry->dir,
700 __get_str(name)
701 )
702);
703
704TRACE_EVENT(nfs_link_exit,
705 TP_PROTO(
706 const struct inode *inode,
707 const struct inode *dir,
708 const struct dentry *dentry,
709 int error
710 ),
711
712 TP_ARGS(inode, dir, dentry, error),
713
714 TP_STRUCT__entry(
Chuck Lever38a638a2019-06-19 10:33:58 -0400715 __field(unsigned long, error)
Trond Myklebust1fd10852013-08-21 13:54:44 -0400716 __field(dev_t, dev)
717 __field(u64, fileid)
718 __field(u64, dir)
719 __string(name, dentry->d_name.name)
720 ),
721
722 TP_fast_assign(
723 __entry->dev = inode->i_sb->s_dev;
724 __entry->fileid = NFS_FILEID(inode);
725 __entry->dir = NFS_FILEID(dir);
Chuck Lever38a638a2019-06-19 10:33:58 -0400726 __entry->error = error < 0 ? -error : 0;
Trond Myklebust1fd10852013-08-21 13:54:44 -0400727 __assign_str(name, dentry->d_name.name);
728 ),
729
730 TP_printk(
Chuck Lever38a638a2019-06-19 10:33:58 -0400731 "error=%ld (%s) fileid=%02x:%02x:%llu name=%02x:%02x:%llu/%s",
732 -__entry->error, nfs_show_status(__entry->error),
Trond Myklebust1fd10852013-08-21 13:54:44 -0400733 MAJOR(__entry->dev), MINOR(__entry->dev),
734 __entry->fileid,
735 MAJOR(__entry->dev), MINOR(__entry->dev),
736 (unsigned long long)__entry->dir,
737 __get_str(name)
738 )
739);
740
Trond Myklebust70ded202013-08-21 12:08:45 -0400741DECLARE_EVENT_CLASS(nfs_rename_event,
742 TP_PROTO(
743 const struct inode *old_dir,
744 const struct dentry *old_dentry,
745 const struct inode *new_dir,
746 const struct dentry *new_dentry
747 ),
748
749 TP_ARGS(old_dir, old_dentry, new_dir, new_dentry),
750
751 TP_STRUCT__entry(
752 __field(dev_t, dev)
753 __field(u64, old_dir)
754 __field(u64, new_dir)
755 __string(old_name, old_dentry->d_name.name)
756 __string(new_name, new_dentry->d_name.name)
757 ),
758
759 TP_fast_assign(
760 __entry->dev = old_dir->i_sb->s_dev;
761 __entry->old_dir = NFS_FILEID(old_dir);
762 __entry->new_dir = NFS_FILEID(new_dir);
763 __assign_str(old_name, old_dentry->d_name.name);
764 __assign_str(new_name, new_dentry->d_name.name);
765 ),
766
767 TP_printk(
768 "old_name=%02x:%02x:%llu/%s new_name=%02x:%02x:%llu/%s",
769 MAJOR(__entry->dev), MINOR(__entry->dev),
770 (unsigned long long)__entry->old_dir,
771 __get_str(old_name),
772 MAJOR(__entry->dev), MINOR(__entry->dev),
773 (unsigned long long)__entry->new_dir,
774 __get_str(new_name)
775 )
776);
777#define DEFINE_NFS_RENAME_EVENT(name) \
778 DEFINE_EVENT(nfs_rename_event, name, \
779 TP_PROTO( \
780 const struct inode *old_dir, \
781 const struct dentry *old_dentry, \
782 const struct inode *new_dir, \
783 const struct dentry *new_dentry \
784 ), \
785 TP_ARGS(old_dir, old_dentry, new_dir, new_dentry))
786
787DECLARE_EVENT_CLASS(nfs_rename_event_done,
788 TP_PROTO(
789 const struct inode *old_dir,
790 const struct dentry *old_dentry,
791 const struct inode *new_dir,
792 const struct dentry *new_dentry,
793 int error
794 ),
795
796 TP_ARGS(old_dir, old_dentry, new_dir, new_dentry, error),
797
798 TP_STRUCT__entry(
799 __field(dev_t, dev)
Chuck Lever38a638a2019-06-19 10:33:58 -0400800 __field(unsigned long, error)
Trond Myklebust70ded202013-08-21 12:08:45 -0400801 __field(u64, old_dir)
802 __string(old_name, old_dentry->d_name.name)
803 __field(u64, new_dir)
804 __string(new_name, new_dentry->d_name.name)
805 ),
806
807 TP_fast_assign(
808 __entry->dev = old_dir->i_sb->s_dev;
Chuck Lever38a638a2019-06-19 10:33:58 -0400809 __entry->error = -error;
Trond Myklebust70ded202013-08-21 12:08:45 -0400810 __entry->old_dir = NFS_FILEID(old_dir);
811 __entry->new_dir = NFS_FILEID(new_dir);
Trond Myklebust70ded202013-08-21 12:08:45 -0400812 __assign_str(old_name, old_dentry->d_name.name);
813 __assign_str(new_name, new_dentry->d_name.name);
814 ),
815
816 TP_printk(
Chuck Lever38a638a2019-06-19 10:33:58 -0400817 "error=%ld (%s) old_name=%02x:%02x:%llu/%s "
Trond Myklebust70ded202013-08-21 12:08:45 -0400818 "new_name=%02x:%02x:%llu/%s",
Chuck Lever38a638a2019-06-19 10:33:58 -0400819 -__entry->error, nfs_show_status(__entry->error),
Trond Myklebust70ded202013-08-21 12:08:45 -0400820 MAJOR(__entry->dev), MINOR(__entry->dev),
821 (unsigned long long)__entry->old_dir,
822 __get_str(old_name),
823 MAJOR(__entry->dev), MINOR(__entry->dev),
824 (unsigned long long)__entry->new_dir,
825 __get_str(new_name)
826 )
827);
828#define DEFINE_NFS_RENAME_EVENT_DONE(name) \
829 DEFINE_EVENT(nfs_rename_event_done, name, \
830 TP_PROTO( \
831 const struct inode *old_dir, \
832 const struct dentry *old_dentry, \
833 const struct inode *new_dir, \
834 const struct dentry *new_dentry, \
835 int error \
836 ), \
837 TP_ARGS(old_dir, old_dentry, new_dir, \
838 new_dentry, error))
839
840DEFINE_NFS_RENAME_EVENT(nfs_rename_enter);
841DEFINE_NFS_RENAME_EVENT_DONE(nfs_rename_exit);
842
843DEFINE_NFS_RENAME_EVENT_DONE(nfs_sillyrename_rename);
844
845TRACE_EVENT(nfs_sillyrename_unlink,
846 TP_PROTO(
847 const struct nfs_unlinkdata *data,
848 int error
849 ),
850
851 TP_ARGS(data, error),
852
853 TP_STRUCT__entry(
854 __field(dev_t, dev)
Chuck Lever38a638a2019-06-19 10:33:58 -0400855 __field(unsigned long, error)
Trond Myklebust70ded202013-08-21 12:08:45 -0400856 __field(u64, dir)
857 __dynamic_array(char, name, data->args.name.len + 1)
858 ),
859
860 TP_fast_assign(
Al Viro884be172016-04-28 23:56:31 -0400861 struct inode *dir = d_inode(data->dentry->d_parent);
Trond Myklebust70ded202013-08-21 12:08:45 -0400862 size_t len = data->args.name.len;
863 __entry->dev = dir->i_sb->s_dev;
864 __entry->dir = NFS_FILEID(dir);
Chuck Lever38a638a2019-06-19 10:33:58 -0400865 __entry->error = -error;
Daniel Bristot de Oliveira752d5962016-07-01 20:44:36 -0300866 memcpy(__get_str(name),
Trond Myklebust70ded202013-08-21 12:08:45 -0400867 data->args.name.name, len);
Daniel Bristot de Oliveira752d5962016-07-01 20:44:36 -0300868 __get_str(name)[len] = 0;
Trond Myklebust70ded202013-08-21 12:08:45 -0400869 ),
870
871 TP_printk(
Chuck Lever38a638a2019-06-19 10:33:58 -0400872 "error=%ld (%s) name=%02x:%02x:%llu/%s",
873 -__entry->error, nfs_show_status(__entry->error),
Trond Myklebust70ded202013-08-21 12:08:45 -0400874 MAJOR(__entry->dev), MINOR(__entry->dev),
875 (unsigned long long)__entry->dir,
876 __get_str(name)
877 )
878);
Chuck Lever8224b272017-08-21 15:00:49 -0400879
880TRACE_EVENT(nfs_initiate_read,
881 TP_PROTO(
Trond Myklebust23431722020-01-06 15:25:08 -0500882 const struct nfs_pgio_header *hdr
Chuck Lever8224b272017-08-21 15:00:49 -0400883 ),
884
Trond Myklebust23431722020-01-06 15:25:08 -0500885 TP_ARGS(hdr),
Chuck Lever8224b272017-08-21 15:00:49 -0400886
887 TP_STRUCT__entry(
Chuck Lever8224b272017-08-21 15:00:49 -0400888 __field(dev_t, dev)
889 __field(u32, fhandle)
890 __field(u64, fileid)
Trond Myklebust23431722020-01-06 15:25:08 -0500891 __field(loff_t, offset)
892 __field(u32, count)
Chuck Lever8224b272017-08-21 15:00:49 -0400893 ),
894
895 TP_fast_assign(
Trond Myklebust23431722020-01-06 15:25:08 -0500896 const struct inode *inode = hdr->inode;
Chuck Lever8224b272017-08-21 15:00:49 -0400897 const struct nfs_inode *nfsi = NFS_I(inode);
Trond Myklebust23431722020-01-06 15:25:08 -0500898 const struct nfs_fh *fh = hdr->args.fh ?
899 hdr->args.fh : &nfsi->fh;
Chuck Lever8224b272017-08-21 15:00:49 -0400900
Trond Myklebust23431722020-01-06 15:25:08 -0500901 __entry->offset = hdr->args.offset;
902 __entry->count = hdr->args.count;
Chuck Lever8224b272017-08-21 15:00:49 -0400903 __entry->dev = inode->i_sb->s_dev;
904 __entry->fileid = nfsi->fileid;
Trond Myklebust23431722020-01-06 15:25:08 -0500905 __entry->fhandle = nfs_fhandle_hash(fh);
Chuck Lever8224b272017-08-21 15:00:49 -0400906 ),
907
908 TP_printk(
909 "fileid=%02x:%02x:%llu fhandle=0x%08x "
Trond Myklebust23431722020-01-06 15:25:08 -0500910 "offset=%lld count=%u",
Chuck Lever8224b272017-08-21 15:00:49 -0400911 MAJOR(__entry->dev), MINOR(__entry->dev),
912 (unsigned long long)__entry->fileid,
913 __entry->fhandle,
Trond Myklebust23431722020-01-06 15:25:08 -0500914 (long long)__entry->offset, __entry->count
Chuck Lever8224b272017-08-21 15:00:49 -0400915 )
916);
917
918TRACE_EVENT(nfs_readpage_done,
919 TP_PROTO(
Trond Myklebust23431722020-01-06 15:25:08 -0500920 const struct rpc_task *task,
921 const struct nfs_pgio_header *hdr
Chuck Lever8224b272017-08-21 15:00:49 -0400922 ),
923
Trond Myklebust23431722020-01-06 15:25:08 -0500924 TP_ARGS(task, hdr),
Chuck Lever8224b272017-08-21 15:00:49 -0400925
926 TP_STRUCT__entry(
Chuck Lever8224b272017-08-21 15:00:49 -0400927 __field(dev_t, dev)
928 __field(u32, fhandle)
929 __field(u64, fileid)
Trond Myklebust23431722020-01-06 15:25:08 -0500930 __field(loff_t, offset)
931 __field(u32, arg_count)
932 __field(u32, res_count)
933 __field(bool, eof)
934 __field(int, status)
Chuck Lever8224b272017-08-21 15:00:49 -0400935 ),
936
937 TP_fast_assign(
Trond Myklebust23431722020-01-06 15:25:08 -0500938 const struct inode *inode = hdr->inode;
Chuck Lever8224b272017-08-21 15:00:49 -0400939 const struct nfs_inode *nfsi = NFS_I(inode);
Trond Myklebust23431722020-01-06 15:25:08 -0500940 const struct nfs_fh *fh = hdr->args.fh ?
941 hdr->args.fh : &nfsi->fh;
Chuck Lever8224b272017-08-21 15:00:49 -0400942
Trond Myklebust23431722020-01-06 15:25:08 -0500943 __entry->status = task->tk_status;
944 __entry->offset = hdr->args.offset;
945 __entry->arg_count = hdr->args.count;
946 __entry->res_count = hdr->res.count;
947 __entry->eof = hdr->res.eof;
Chuck Lever8224b272017-08-21 15:00:49 -0400948 __entry->dev = inode->i_sb->s_dev;
949 __entry->fileid = nfsi->fileid;
Trond Myklebust23431722020-01-06 15:25:08 -0500950 __entry->fhandle = nfs_fhandle_hash(fh);
Chuck Lever8224b272017-08-21 15:00:49 -0400951 ),
952
953 TP_printk(
954 "fileid=%02x:%02x:%llu fhandle=0x%08x "
Trond Myklebust23431722020-01-06 15:25:08 -0500955 "offset=%lld count=%u res=%u status=%d%s",
Chuck Lever8224b272017-08-21 15:00:49 -0400956 MAJOR(__entry->dev), MINOR(__entry->dev),
957 (unsigned long long)__entry->fileid,
958 __entry->fhandle,
Trond Myklebust23431722020-01-06 15:25:08 -0500959 (long long)__entry->offset, __entry->arg_count,
960 __entry->res_count, __entry->status,
Chuck Lever8224b272017-08-21 15:00:49 -0400961 __entry->eof ? " eof" : ""
962 )
963);
964
Chuck Lever06e19022018-01-18 14:55:01 -0500965TRACE_DEFINE_ENUM(NFS_UNSTABLE);
966TRACE_DEFINE_ENUM(NFS_DATA_SYNC);
967TRACE_DEFINE_ENUM(NFS_FILE_SYNC);
968
Chuck Lever8224b272017-08-21 15:00:49 -0400969#define nfs_show_stable(stable) \
970 __print_symbolic(stable, \
Chuck Lever06e19022018-01-18 14:55:01 -0500971 { NFS_UNSTABLE, "UNSTABLE" }, \
972 { NFS_DATA_SYNC, "DATA_SYNC" }, \
973 { NFS_FILE_SYNC, "FILE_SYNC" })
Chuck Lever8224b272017-08-21 15:00:49 -0400974
975TRACE_EVENT(nfs_initiate_write,
976 TP_PROTO(
Trond Myklebust5bb2a7c2020-01-06 15:25:09 -0500977 const struct nfs_pgio_header *hdr
Chuck Lever8224b272017-08-21 15:00:49 -0400978 ),
979
Trond Myklebust5bb2a7c2020-01-06 15:25:09 -0500980 TP_ARGS(hdr),
Chuck Lever8224b272017-08-21 15:00:49 -0400981
982 TP_STRUCT__entry(
Chuck Lever8224b272017-08-21 15:00:49 -0400983 __field(dev_t, dev)
984 __field(u32, fhandle)
985 __field(u64, fileid)
Trond Myklebust5bb2a7c2020-01-06 15:25:09 -0500986 __field(loff_t, offset)
987 __field(u32, count)
988 __field(enum nfs3_stable_how, stable)
Chuck Lever8224b272017-08-21 15:00:49 -0400989 ),
990
991 TP_fast_assign(
Trond Myklebust5bb2a7c2020-01-06 15:25:09 -0500992 const struct inode *inode = hdr->inode;
Chuck Lever8224b272017-08-21 15:00:49 -0400993 const struct nfs_inode *nfsi = NFS_I(inode);
Trond Myklebust5bb2a7c2020-01-06 15:25:09 -0500994 const struct nfs_fh *fh = hdr->args.fh ?
995 hdr->args.fh : &nfsi->fh;
Chuck Lever8224b272017-08-21 15:00:49 -0400996
Trond Myklebust5bb2a7c2020-01-06 15:25:09 -0500997 __entry->offset = hdr->args.offset;
998 __entry->count = hdr->args.count;
999 __entry->stable = hdr->args.stable;
Chuck Lever8224b272017-08-21 15:00:49 -04001000 __entry->dev = inode->i_sb->s_dev;
1001 __entry->fileid = nfsi->fileid;
Trond Myklebust5bb2a7c2020-01-06 15:25:09 -05001002 __entry->fhandle = nfs_fhandle_hash(fh);
Chuck Lever8224b272017-08-21 15:00:49 -04001003 ),
1004
1005 TP_printk(
1006 "fileid=%02x:%02x:%llu fhandle=0x%08x "
Trond Myklebust5bb2a7c2020-01-06 15:25:09 -05001007 "offset=%lld count=%u stable=%s",
Chuck Lever8224b272017-08-21 15:00:49 -04001008 MAJOR(__entry->dev), MINOR(__entry->dev),
1009 (unsigned long long)__entry->fileid,
1010 __entry->fhandle,
Trond Myklebust5bb2a7c2020-01-06 15:25:09 -05001011 (long long)__entry->offset, __entry->count,
Chuck Lever06e19022018-01-18 14:55:01 -05001012 nfs_show_stable(__entry->stable)
Chuck Lever8224b272017-08-21 15:00:49 -04001013 )
1014);
1015
1016TRACE_EVENT(nfs_writeback_done,
1017 TP_PROTO(
Trond Myklebust5bb2a7c2020-01-06 15:25:09 -05001018 const struct rpc_task *task,
1019 const struct nfs_pgio_header *hdr
Chuck Lever8224b272017-08-21 15:00:49 -04001020 ),
1021
Trond Myklebust5bb2a7c2020-01-06 15:25:09 -05001022 TP_ARGS(task, hdr),
Chuck Lever8224b272017-08-21 15:00:49 -04001023
1024 TP_STRUCT__entry(
Chuck Lever8224b272017-08-21 15:00:49 -04001025 __field(dev_t, dev)
1026 __field(u32, fhandle)
1027 __field(u64, fileid)
Trond Myklebust5bb2a7c2020-01-06 15:25:09 -05001028 __field(loff_t, offset)
1029 __field(u32, arg_count)
1030 __field(u32, res_count)
1031 __field(int, status)
1032 __field(enum nfs3_stable_how, stable)
1033 __array(char, verifier, NFS4_VERIFIER_SIZE)
Chuck Lever8224b272017-08-21 15:00:49 -04001034 ),
1035
1036 TP_fast_assign(
Trond Myklebust5bb2a7c2020-01-06 15:25:09 -05001037 const struct inode *inode = hdr->inode;
Chuck Lever8224b272017-08-21 15:00:49 -04001038 const struct nfs_inode *nfsi = NFS_I(inode);
Trond Myklebust5bb2a7c2020-01-06 15:25:09 -05001039 const struct nfs_fh *fh = hdr->args.fh ?
1040 hdr->args.fh : &nfsi->fh;
1041 const struct nfs_writeverf *verf = hdr->res.verf;
Chuck Lever8224b272017-08-21 15:00:49 -04001042
Trond Myklebust5bb2a7c2020-01-06 15:25:09 -05001043 __entry->status = task->tk_status;
1044 __entry->offset = hdr->args.offset;
1045 __entry->arg_count = hdr->args.count;
1046 __entry->res_count = hdr->res.count;
1047 __entry->stable = verf->committed;
1048 memcpy(__entry->verifier,
1049 &verf->verifier,
1050 NFS4_VERIFIER_SIZE);
Chuck Lever8224b272017-08-21 15:00:49 -04001051 __entry->dev = inode->i_sb->s_dev;
1052 __entry->fileid = nfsi->fileid;
Trond Myklebust5bb2a7c2020-01-06 15:25:09 -05001053 __entry->fhandle = nfs_fhandle_hash(fh);
Chuck Lever8224b272017-08-21 15:00:49 -04001054 ),
1055
1056 TP_printk(
1057 "fileid=%02x:%02x:%llu fhandle=0x%08x "
Trond Myklebust5bb2a7c2020-01-06 15:25:09 -05001058 "offset=%lld count=%u res=%u status=%d stable=%s "
1059 "verifier=%s",
Chuck Lever8224b272017-08-21 15:00:49 -04001060 MAJOR(__entry->dev), MINOR(__entry->dev),
1061 (unsigned long long)__entry->fileid,
1062 __entry->fhandle,
Trond Myklebust5bb2a7c2020-01-06 15:25:09 -05001063 (long long)__entry->offset, __entry->arg_count,
1064 __entry->res_count, __entry->status,
Chuck Lever06e19022018-01-18 14:55:01 -05001065 nfs_show_stable(__entry->stable),
Trond Myklebust5bb2a7c2020-01-06 15:25:09 -05001066 __print_hex_str(__entry->verifier, NFS4_VERIFIER_SIZE)
Chuck Lever8224b272017-08-21 15:00:49 -04001067 )
1068);
1069
Chuck Lever861e1672019-12-23 10:28:33 -05001070DECLARE_EVENT_CLASS(nfs_page_error_class,
1071 TP_PROTO(
1072 const struct nfs_page *req,
1073 int error
1074 ),
1075
1076 TP_ARGS(req, error),
1077
1078 TP_STRUCT__entry(
1079 __field(const void *, req)
1080 __field(pgoff_t, index)
1081 __field(unsigned int, offset)
1082 __field(unsigned int, pgbase)
1083 __field(unsigned int, bytes)
1084 __field(int, error)
1085 ),
1086
1087 TP_fast_assign(
1088 __entry->req = req;
1089 __entry->index = req->wb_index;
1090 __entry->offset = req->wb_offset;
1091 __entry->pgbase = req->wb_pgbase;
1092 __entry->bytes = req->wb_bytes;
1093 __entry->error = error;
1094 ),
1095
1096 TP_printk(
1097 "req=%p index=%lu offset=%u pgbase=%u bytes=%u error=%d",
1098 __entry->req, __entry->index, __entry->offset,
1099 __entry->pgbase, __entry->bytes, __entry->error
1100 )
1101);
1102
1103#define DEFINE_NFS_PAGEERR_EVENT(name) \
1104 DEFINE_EVENT(nfs_page_error_class, name, \
1105 TP_PROTO( \
1106 const struct nfs_page *req, \
1107 int error \
1108 ), \
1109 TP_ARGS(req, error))
1110
1111DEFINE_NFS_PAGEERR_EVENT(nfs_write_error);
1112DEFINE_NFS_PAGEERR_EVENT(nfs_comp_error);
1113DEFINE_NFS_PAGEERR_EVENT(nfs_commit_error);
1114
Chuck Lever8224b272017-08-21 15:00:49 -04001115TRACE_EVENT(nfs_initiate_commit,
1116 TP_PROTO(
1117 const struct nfs_commit_data *data
1118 ),
1119
1120 TP_ARGS(data),
1121
1122 TP_STRUCT__entry(
Chuck Lever8224b272017-08-21 15:00:49 -04001123 __field(dev_t, dev)
1124 __field(u32, fhandle)
1125 __field(u64, fileid)
Trond Myklebust7bdd2972020-01-06 15:25:10 -05001126 __field(loff_t, offset)
1127 __field(u32, count)
Chuck Lever8224b272017-08-21 15:00:49 -04001128 ),
1129
1130 TP_fast_assign(
1131 const struct inode *inode = data->inode;
1132 const struct nfs_inode *nfsi = NFS_I(inode);
Trond Myklebust7bdd2972020-01-06 15:25:10 -05001133 const struct nfs_fh *fh = data->args.fh ?
1134 data->args.fh : &nfsi->fh;
Chuck Lever8224b272017-08-21 15:00:49 -04001135
1136 __entry->offset = data->args.offset;
1137 __entry->count = data->args.count;
1138 __entry->dev = inode->i_sb->s_dev;
1139 __entry->fileid = nfsi->fileid;
Trond Myklebust7bdd2972020-01-06 15:25:10 -05001140 __entry->fhandle = nfs_fhandle_hash(fh);
Chuck Lever8224b272017-08-21 15:00:49 -04001141 ),
1142
1143 TP_printk(
1144 "fileid=%02x:%02x:%llu fhandle=0x%08x "
Trond Myklebust7bdd2972020-01-06 15:25:10 -05001145 "offset=%lld count=%u",
Chuck Lever8224b272017-08-21 15:00:49 -04001146 MAJOR(__entry->dev), MINOR(__entry->dev),
1147 (unsigned long long)__entry->fileid,
1148 __entry->fhandle,
Trond Myklebust7bdd2972020-01-06 15:25:10 -05001149 (long long)__entry->offset, __entry->count
Chuck Lever8224b272017-08-21 15:00:49 -04001150 )
1151);
1152
1153TRACE_EVENT(nfs_commit_done,
1154 TP_PROTO(
Trond Myklebust7bdd2972020-01-06 15:25:10 -05001155 const struct rpc_task *task,
Chuck Lever8224b272017-08-21 15:00:49 -04001156 const struct nfs_commit_data *data
1157 ),
1158
Trond Myklebust7bdd2972020-01-06 15:25:10 -05001159 TP_ARGS(task, data),
Chuck Lever8224b272017-08-21 15:00:49 -04001160
1161 TP_STRUCT__entry(
Chuck Lever8224b272017-08-21 15:00:49 -04001162 __field(dev_t, dev)
1163 __field(u32, fhandle)
1164 __field(u64, fileid)
Trond Myklebust7bdd2972020-01-06 15:25:10 -05001165 __field(loff_t, offset)
1166 __field(int, status)
1167 __field(enum nfs3_stable_how, stable)
1168 __array(char, verifier, NFS4_VERIFIER_SIZE)
Chuck Lever8224b272017-08-21 15:00:49 -04001169 ),
1170
1171 TP_fast_assign(
1172 const struct inode *inode = data->inode;
1173 const struct nfs_inode *nfsi = NFS_I(inode);
Trond Myklebust7bdd2972020-01-06 15:25:10 -05001174 const struct nfs_fh *fh = data->args.fh ?
1175 data->args.fh : &nfsi->fh;
1176 const struct nfs_writeverf *verf = data->res.verf;
Chuck Lever8224b272017-08-21 15:00:49 -04001177
Trond Myklebust7bdd2972020-01-06 15:25:10 -05001178 __entry->status = task->tk_status;
Chuck Lever8224b272017-08-21 15:00:49 -04001179 __entry->offset = data->args.offset;
Trond Myklebust7bdd2972020-01-06 15:25:10 -05001180 __entry->stable = verf->committed;
1181 memcpy(__entry->verifier,
1182 &verf->verifier,
1183 NFS4_VERIFIER_SIZE);
Chuck Lever8224b272017-08-21 15:00:49 -04001184 __entry->dev = inode->i_sb->s_dev;
1185 __entry->fileid = nfsi->fileid;
Trond Myklebust7bdd2972020-01-06 15:25:10 -05001186 __entry->fhandle = nfs_fhandle_hash(fh);
Chuck Lever8224b272017-08-21 15:00:49 -04001187 ),
1188
1189 TP_printk(
1190 "fileid=%02x:%02x:%llu fhandle=0x%08x "
Trond Myklebust7bdd2972020-01-06 15:25:10 -05001191 "offset=%lld status=%d stable=%s verifier=%s",
Chuck Lever8224b272017-08-21 15:00:49 -04001192 MAJOR(__entry->dev), MINOR(__entry->dev),
1193 (unsigned long long)__entry->fileid,
1194 __entry->fhandle,
Trond Myklebust7bdd2972020-01-06 15:25:10 -05001195 (long long)__entry->offset, __entry->status,
1196 nfs_show_stable(__entry->stable),
1197 __print_hex_str(__entry->verifier, NFS4_VERIFIER_SIZE)
Chuck Lever8224b272017-08-21 15:00:49 -04001198 )
1199);
1200
Trond Myklebust43622ea2019-11-01 15:33:55 -04001201TRACE_EVENT(nfs_fh_to_dentry,
1202 TP_PROTO(
1203 const struct super_block *sb,
1204 const struct nfs_fh *fh,
1205 u64 fileid,
1206 int error
1207 ),
1208
1209 TP_ARGS(sb, fh, fileid, error),
1210
1211 TP_STRUCT__entry(
1212 __field(int, error)
1213 __field(dev_t, dev)
1214 __field(u32, fhandle)
1215 __field(u64, fileid)
1216 ),
1217
1218 TP_fast_assign(
1219 __entry->error = error;
1220 __entry->dev = sb->s_dev;
1221 __entry->fileid = fileid;
1222 __entry->fhandle = nfs_fhandle_hash(fh);
1223 ),
1224
1225 TP_printk(
1226 "error=%d fileid=%02x:%02x:%llu fhandle=0x%08x ",
1227 __entry->error,
1228 MAJOR(__entry->dev), MINOR(__entry->dev),
1229 (unsigned long long)__entry->fileid,
1230 __entry->fhandle
1231 )
1232);
1233
Chuck Leverf23f6582019-02-11 11:24:26 -05001234TRACE_DEFINE_ENUM(NFS_OK);
1235TRACE_DEFINE_ENUM(NFSERR_PERM);
1236TRACE_DEFINE_ENUM(NFSERR_NOENT);
1237TRACE_DEFINE_ENUM(NFSERR_IO);
1238TRACE_DEFINE_ENUM(NFSERR_NXIO);
Chuck Lever38a638a2019-06-19 10:33:58 -04001239TRACE_DEFINE_ENUM(ECHILD);
1240TRACE_DEFINE_ENUM(NFSERR_EAGAIN);
Chuck Leverf23f6582019-02-11 11:24:26 -05001241TRACE_DEFINE_ENUM(NFSERR_ACCES);
1242TRACE_DEFINE_ENUM(NFSERR_EXIST);
1243TRACE_DEFINE_ENUM(NFSERR_XDEV);
1244TRACE_DEFINE_ENUM(NFSERR_NODEV);
1245TRACE_DEFINE_ENUM(NFSERR_NOTDIR);
1246TRACE_DEFINE_ENUM(NFSERR_ISDIR);
1247TRACE_DEFINE_ENUM(NFSERR_INVAL);
1248TRACE_DEFINE_ENUM(NFSERR_FBIG);
1249TRACE_DEFINE_ENUM(NFSERR_NOSPC);
1250TRACE_DEFINE_ENUM(NFSERR_ROFS);
1251TRACE_DEFINE_ENUM(NFSERR_MLINK);
Chuck Lever38a638a2019-06-19 10:33:58 -04001252TRACE_DEFINE_ENUM(NFSERR_OPNOTSUPP);
Chuck Leverf23f6582019-02-11 11:24:26 -05001253TRACE_DEFINE_ENUM(NFSERR_NAMETOOLONG);
1254TRACE_DEFINE_ENUM(NFSERR_NOTEMPTY);
1255TRACE_DEFINE_ENUM(NFSERR_DQUOT);
1256TRACE_DEFINE_ENUM(NFSERR_STALE);
1257TRACE_DEFINE_ENUM(NFSERR_REMOTE);
1258TRACE_DEFINE_ENUM(NFSERR_WFLUSH);
1259TRACE_DEFINE_ENUM(NFSERR_BADHANDLE);
1260TRACE_DEFINE_ENUM(NFSERR_NOT_SYNC);
1261TRACE_DEFINE_ENUM(NFSERR_BAD_COOKIE);
1262TRACE_DEFINE_ENUM(NFSERR_NOTSUPP);
1263TRACE_DEFINE_ENUM(NFSERR_TOOSMALL);
1264TRACE_DEFINE_ENUM(NFSERR_SERVERFAULT);
1265TRACE_DEFINE_ENUM(NFSERR_BADTYPE);
1266TRACE_DEFINE_ENUM(NFSERR_JUKEBOX);
1267
1268#define nfs_show_status(x) \
1269 __print_symbolic(x, \
1270 { NFS_OK, "OK" }, \
1271 { NFSERR_PERM, "PERM" }, \
1272 { NFSERR_NOENT, "NOENT" }, \
1273 { NFSERR_IO, "IO" }, \
1274 { NFSERR_NXIO, "NXIO" }, \
Chuck Lever38a638a2019-06-19 10:33:58 -04001275 { ECHILD, "CHILD" }, \
1276 { NFSERR_EAGAIN, "AGAIN" }, \
Chuck Leverf23f6582019-02-11 11:24:26 -05001277 { NFSERR_ACCES, "ACCES" }, \
1278 { NFSERR_EXIST, "EXIST" }, \
1279 { NFSERR_XDEV, "XDEV" }, \
1280 { NFSERR_NODEV, "NODEV" }, \
1281 { NFSERR_NOTDIR, "NOTDIR" }, \
1282 { NFSERR_ISDIR, "ISDIR" }, \
1283 { NFSERR_INVAL, "INVAL" }, \
1284 { NFSERR_FBIG, "FBIG" }, \
1285 { NFSERR_NOSPC, "NOSPC" }, \
1286 { NFSERR_ROFS, "ROFS" }, \
1287 { NFSERR_MLINK, "MLINK" }, \
Chuck Lever38a638a2019-06-19 10:33:58 -04001288 { NFSERR_OPNOTSUPP, "OPNOTSUPP" }, \
Chuck Leverf23f6582019-02-11 11:24:26 -05001289 { NFSERR_NAMETOOLONG, "NAMETOOLONG" }, \
1290 { NFSERR_NOTEMPTY, "NOTEMPTY" }, \
1291 { NFSERR_DQUOT, "DQUOT" }, \
1292 { NFSERR_STALE, "STALE" }, \
1293 { NFSERR_REMOTE, "REMOTE" }, \
1294 { NFSERR_WFLUSH, "WFLUSH" }, \
1295 { NFSERR_BADHANDLE, "BADHANDLE" }, \
1296 { NFSERR_NOT_SYNC, "NOTSYNC" }, \
1297 { NFSERR_BAD_COOKIE, "BADCOOKIE" }, \
1298 { NFSERR_NOTSUPP, "NOTSUPP" }, \
1299 { NFSERR_TOOSMALL, "TOOSMALL" }, \
1300 { NFSERR_SERVERFAULT, "REMOTEIO" }, \
1301 { NFSERR_BADTYPE, "BADTYPE" }, \
1302 { NFSERR_JUKEBOX, "JUKEBOX" })
1303
1304TRACE_EVENT(nfs_xdr_status,
1305 TP_PROTO(
Chuck Lever62a92ba2019-06-19 10:34:09 -04001306 const struct xdr_stream *xdr,
Chuck Leverf23f6582019-02-11 11:24:26 -05001307 int error
1308 ),
1309
Chuck Lever62a92ba2019-06-19 10:34:09 -04001310 TP_ARGS(xdr, error),
Chuck Leverf23f6582019-02-11 11:24:26 -05001311
1312 TP_STRUCT__entry(
Chuck Lever62a92ba2019-06-19 10:34:09 -04001313 __field(unsigned int, task_id)
1314 __field(unsigned int, client_id)
1315 __field(u32, xid)
Chuck Lever38a638a2019-06-19 10:33:58 -04001316 __field(unsigned long, error)
Chuck Leverf23f6582019-02-11 11:24:26 -05001317 ),
1318
1319 TP_fast_assign(
Chuck Lever62a92ba2019-06-19 10:34:09 -04001320 const struct rpc_rqst *rqstp = xdr->rqst;
1321 const struct rpc_task *task = rqstp->rq_task;
1322
1323 __entry->task_id = task->tk_pid;
1324 __entry->client_id = task->tk_client->cl_clid;
1325 __entry->xid = be32_to_cpu(rqstp->rq_xid);
Chuck Leverf23f6582019-02-11 11:24:26 -05001326 __entry->error = error;
1327 ),
1328
1329 TP_printk(
Chuck Lever62a92ba2019-06-19 10:34:09 -04001330 "task:%u@%d xid=0x%08x error=%ld (%s)",
1331 __entry->task_id, __entry->client_id, __entry->xid,
Chuck Lever38a638a2019-06-19 10:33:58 -04001332 -__entry->error, nfs_show_status(__entry->error)
Chuck Leverf23f6582019-02-11 11:24:26 -05001333 )
1334);
1335
Trond Myklebustf4ce1292013-08-19 18:59:33 -04001336#endif /* _TRACE_NFS_H */
1337
1338#undef TRACE_INCLUDE_PATH
1339#define TRACE_INCLUDE_PATH .
1340#define TRACE_INCLUDE_FILE nfstrace
1341/* This part must be outside protection */
1342#include <trace/define_trace.h>