xref: /openbmc/linux/fs/nfs/nfstrace.h (revision 82df5b73)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
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>
12 #include <linux/iversion.h>
13 
14 TRACE_DEFINE_ENUM(DT_UNKNOWN);
15 TRACE_DEFINE_ENUM(DT_FIFO);
16 TRACE_DEFINE_ENUM(DT_CHR);
17 TRACE_DEFINE_ENUM(DT_DIR);
18 TRACE_DEFINE_ENUM(DT_BLK);
19 TRACE_DEFINE_ENUM(DT_REG);
20 TRACE_DEFINE_ENUM(DT_LNK);
21 TRACE_DEFINE_ENUM(DT_SOCK);
22 TRACE_DEFINE_ENUM(DT_WHT);
23 
24 #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 
36 TRACE_DEFINE_ENUM(NFS_INO_INVALID_DATA);
37 TRACE_DEFINE_ENUM(NFS_INO_INVALID_ATIME);
38 TRACE_DEFINE_ENUM(NFS_INO_INVALID_ACCESS);
39 TRACE_DEFINE_ENUM(NFS_INO_INVALID_ACL);
40 TRACE_DEFINE_ENUM(NFS_INO_REVAL_PAGECACHE);
41 TRACE_DEFINE_ENUM(NFS_INO_REVAL_FORCED);
42 TRACE_DEFINE_ENUM(NFS_INO_INVALID_LABEL);
43 TRACE_DEFINE_ENUM(NFS_INO_INVALID_CHANGE);
44 TRACE_DEFINE_ENUM(NFS_INO_INVALID_CTIME);
45 TRACE_DEFINE_ENUM(NFS_INO_INVALID_MTIME);
46 TRACE_DEFINE_ENUM(NFS_INO_INVALID_SIZE);
47 TRACE_DEFINE_ENUM(NFS_INO_INVALID_OTHER);
48 
49 #define nfs_show_cache_validity(v) \
50 	__print_flags(v, "|", \
51 			{ 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" }, \
57 			{ 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 
64 TRACE_DEFINE_ENUM(NFS_INO_ADVISE_RDPLUS);
65 TRACE_DEFINE_ENUM(NFS_INO_STALE);
66 TRACE_DEFINE_ENUM(NFS_INO_ACL_LRU_SET);
67 TRACE_DEFINE_ENUM(NFS_INO_INVALIDATING);
68 TRACE_DEFINE_ENUM(NFS_INO_FSCACHE);
69 TRACE_DEFINE_ENUM(NFS_INO_FSCACHE_LOCK);
70 TRACE_DEFINE_ENUM(NFS_INO_LAYOUTCOMMIT);
71 TRACE_DEFINE_ENUM(NFS_INO_LAYOUTCOMMITTING);
72 TRACE_DEFINE_ENUM(NFS_INO_LAYOUTSTATS);
73 TRACE_DEFINE_ENUM(NFS_INO_ODIRECT);
74 
75 #define nfs_show_nfsi_flags(v) \
76 	__print_flags(v, "|", \
77 			{ 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" })
87 
88 DECLARE_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);
107 			__entry->version = inode_peek_iversion_raw(inode);
108 		),
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 
119 DECLARE_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(
128 			__field(unsigned long, error)
129 			__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);
141 			__entry->error = error < 0 ? -error : 0;
142 			__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);
146 			__entry->version = inode_peek_iversion_raw(inode);
147 			__entry->size = i_size_read(inode);
148 			__entry->nfsi_flags = nfsi->flags;
149 			__entry->cache_validity = nfsi->cache_validity;
150 		),
151 
152 		TP_printk(
153 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
154 			"type=%u (%s) version=%llu size=%lld "
155 			"cache_validity=0x%lx (%s) nfs_flags=0x%lx (%s)",
156 			-__entry->error, nfs_show_status(__entry->error),
157 			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))
184 DEFINE_NFS_INODE_EVENT(nfs_set_inode_stale);
185 DEFINE_NFS_INODE_EVENT(nfs_refresh_inode_enter);
186 DEFINE_NFS_INODE_EVENT_DONE(nfs_refresh_inode_exit);
187 DEFINE_NFS_INODE_EVENT(nfs_revalidate_inode_enter);
188 DEFINE_NFS_INODE_EVENT_DONE(nfs_revalidate_inode_exit);
189 DEFINE_NFS_INODE_EVENT(nfs_invalidate_mapping_enter);
190 DEFINE_NFS_INODE_EVENT_DONE(nfs_invalidate_mapping_exit);
191 DEFINE_NFS_INODE_EVENT(nfs_getattr_enter);
192 DEFINE_NFS_INODE_EVENT_DONE(nfs_getattr_exit);
193 DEFINE_NFS_INODE_EVENT(nfs_setattr_enter);
194 DEFINE_NFS_INODE_EVENT_DONE(nfs_setattr_exit);
195 DEFINE_NFS_INODE_EVENT(nfs_writeback_page_enter);
196 DEFINE_NFS_INODE_EVENT_DONE(nfs_writeback_page_exit);
197 DEFINE_NFS_INODE_EVENT(nfs_writeback_inode_enter);
198 DEFINE_NFS_INODE_EVENT_DONE(nfs_writeback_inode_exit);
199 DEFINE_NFS_INODE_EVENT(nfs_fsync_enter);
200 DEFINE_NFS_INODE_EVENT_DONE(nfs_fsync_exit);
201 DEFINE_NFS_INODE_EVENT(nfs_access_enter);
202 
203 TRACE_EVENT(nfs_access_exit,
204 		TP_PROTO(
205 			const struct inode *inode,
206 			unsigned int mask,
207 			unsigned int permitted,
208 			int error
209 		),
210 
211 		TP_ARGS(inode, mask, permitted, error),
212 
213 		TP_STRUCT__entry(
214 			__field(unsigned long, error)
215 			__field(dev_t, dev)
216 			__field(u32, fhandle)
217 			__field(unsigned char, type)
218 			__field(u64, fileid)
219 			__field(u64, version)
220 			__field(loff_t, size)
221 			__field(unsigned long, nfsi_flags)
222 			__field(unsigned long, cache_validity)
223 			__field(unsigned int, mask)
224 			__field(unsigned int, permitted)
225 		),
226 
227 		TP_fast_assign(
228 			const struct nfs_inode *nfsi = NFS_I(inode);
229 			__entry->error = error < 0 ? -error : 0;
230 			__entry->dev = inode->i_sb->s_dev;
231 			__entry->fileid = nfsi->fileid;
232 			__entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
233 			__entry->type = nfs_umode_to_dtype(inode->i_mode);
234 			__entry->version = inode_peek_iversion_raw(inode);
235 			__entry->size = i_size_read(inode);
236 			__entry->nfsi_flags = nfsi->flags;
237 			__entry->cache_validity = nfsi->cache_validity;
238 			__entry->mask = mask;
239 			__entry->permitted = permitted;
240 		),
241 
242 		TP_printk(
243 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
244 			"type=%u (%s) version=%llu size=%lld "
245 			"cache_validity=0x%lx (%s) nfs_flags=0x%lx (%s) "
246 			"mask=0x%x permitted=0x%x",
247 			-__entry->error, nfs_show_status(__entry->error),
248 			MAJOR(__entry->dev), MINOR(__entry->dev),
249 			(unsigned long long)__entry->fileid,
250 			__entry->fhandle,
251 			__entry->type,
252 			nfs_show_file_type(__entry->type),
253 			(unsigned long long)__entry->version,
254 			(long long)__entry->size,
255 			__entry->cache_validity,
256 			nfs_show_cache_validity(__entry->cache_validity),
257 			__entry->nfsi_flags,
258 			nfs_show_nfsi_flags(__entry->nfsi_flags),
259 			__entry->mask, __entry->permitted
260 		)
261 );
262 
263 TRACE_DEFINE_ENUM(LOOKUP_FOLLOW);
264 TRACE_DEFINE_ENUM(LOOKUP_DIRECTORY);
265 TRACE_DEFINE_ENUM(LOOKUP_AUTOMOUNT);
266 TRACE_DEFINE_ENUM(LOOKUP_PARENT);
267 TRACE_DEFINE_ENUM(LOOKUP_REVAL);
268 TRACE_DEFINE_ENUM(LOOKUP_RCU);
269 TRACE_DEFINE_ENUM(LOOKUP_OPEN);
270 TRACE_DEFINE_ENUM(LOOKUP_CREATE);
271 TRACE_DEFINE_ENUM(LOOKUP_EXCL);
272 TRACE_DEFINE_ENUM(LOOKUP_RENAME_TARGET);
273 TRACE_DEFINE_ENUM(LOOKUP_JUMPED);
274 TRACE_DEFINE_ENUM(LOOKUP_ROOT);
275 TRACE_DEFINE_ENUM(LOOKUP_EMPTY);
276 TRACE_DEFINE_ENUM(LOOKUP_DOWN);
277 
278 #define show_lookup_flags(flags) \
279 	__print_flags(flags, "|", \
280 			{ LOOKUP_FOLLOW, "FOLLOW" }, \
281 			{ LOOKUP_DIRECTORY, "DIRECTORY" }, \
282 			{ LOOKUP_AUTOMOUNT, "AUTOMOUNT" }, \
283 			{ LOOKUP_PARENT, "PARENT" }, \
284 			{ LOOKUP_REVAL, "REVAL" }, \
285 			{ LOOKUP_RCU, "RCU" }, \
286 			{ LOOKUP_OPEN, "OPEN" }, \
287 			{ LOOKUP_CREATE, "CREATE" }, \
288 			{ LOOKUP_EXCL, "EXCL" }, \
289 			{ LOOKUP_RENAME_TARGET, "RENAME_TARGET" }, \
290 			{ LOOKUP_JUMPED, "JUMPED" }, \
291 			{ LOOKUP_ROOT, "ROOT" }, \
292 			{ LOOKUP_EMPTY, "EMPTY" }, \
293 			{ LOOKUP_DOWN, "DOWN" })
294 
295 DECLARE_EVENT_CLASS(nfs_lookup_event,
296 		TP_PROTO(
297 			const struct inode *dir,
298 			const struct dentry *dentry,
299 			unsigned int flags
300 		),
301 
302 		TP_ARGS(dir, dentry, flags),
303 
304 		TP_STRUCT__entry(
305 			__field(unsigned long, flags)
306 			__field(dev_t, dev)
307 			__field(u64, dir)
308 			__string(name, dentry->d_name.name)
309 		),
310 
311 		TP_fast_assign(
312 			__entry->dev = dir->i_sb->s_dev;
313 			__entry->dir = NFS_FILEID(dir);
314 			__entry->flags = flags;
315 			__assign_str(name, dentry->d_name.name);
316 		),
317 
318 		TP_printk(
319 			"flags=0x%lx (%s) name=%02x:%02x:%llu/%s",
320 			__entry->flags,
321 			show_lookup_flags(__entry->flags),
322 			MAJOR(__entry->dev), MINOR(__entry->dev),
323 			(unsigned long long)__entry->dir,
324 			__get_str(name)
325 		)
326 );
327 
328 #define DEFINE_NFS_LOOKUP_EVENT(name) \
329 	DEFINE_EVENT(nfs_lookup_event, name, \
330 			TP_PROTO( \
331 				const struct inode *dir, \
332 				const struct dentry *dentry, \
333 				unsigned int flags \
334 			), \
335 			TP_ARGS(dir, dentry, flags))
336 
337 DECLARE_EVENT_CLASS(nfs_lookup_event_done,
338 		TP_PROTO(
339 			const struct inode *dir,
340 			const struct dentry *dentry,
341 			unsigned int flags,
342 			int error
343 		),
344 
345 		TP_ARGS(dir, dentry, flags, error),
346 
347 		TP_STRUCT__entry(
348 			__field(unsigned long, error)
349 			__field(unsigned long, flags)
350 			__field(dev_t, dev)
351 			__field(u64, dir)
352 			__string(name, dentry->d_name.name)
353 		),
354 
355 		TP_fast_assign(
356 			__entry->dev = dir->i_sb->s_dev;
357 			__entry->dir = NFS_FILEID(dir);
358 			__entry->error = error < 0 ? -error : 0;
359 			__entry->flags = flags;
360 			__assign_str(name, dentry->d_name.name);
361 		),
362 
363 		TP_printk(
364 			"error=%ld (%s) flags=0x%lx (%s) name=%02x:%02x:%llu/%s",
365 			-__entry->error, nfs_show_status(__entry->error),
366 			__entry->flags,
367 			show_lookup_flags(__entry->flags),
368 			MAJOR(__entry->dev), MINOR(__entry->dev),
369 			(unsigned long long)__entry->dir,
370 			__get_str(name)
371 		)
372 );
373 
374 #define DEFINE_NFS_LOOKUP_EVENT_DONE(name) \
375 	DEFINE_EVENT(nfs_lookup_event_done, name, \
376 			TP_PROTO( \
377 				const struct inode *dir, \
378 				const struct dentry *dentry, \
379 				unsigned int flags, \
380 				int error \
381 			), \
382 			TP_ARGS(dir, dentry, flags, error))
383 
384 DEFINE_NFS_LOOKUP_EVENT(nfs_lookup_enter);
385 DEFINE_NFS_LOOKUP_EVENT_DONE(nfs_lookup_exit);
386 DEFINE_NFS_LOOKUP_EVENT(nfs_lookup_revalidate_enter);
387 DEFINE_NFS_LOOKUP_EVENT_DONE(nfs_lookup_revalidate_exit);
388 
389 TRACE_DEFINE_ENUM(O_WRONLY);
390 TRACE_DEFINE_ENUM(O_RDWR);
391 TRACE_DEFINE_ENUM(O_CREAT);
392 TRACE_DEFINE_ENUM(O_EXCL);
393 TRACE_DEFINE_ENUM(O_NOCTTY);
394 TRACE_DEFINE_ENUM(O_TRUNC);
395 TRACE_DEFINE_ENUM(O_APPEND);
396 TRACE_DEFINE_ENUM(O_NONBLOCK);
397 TRACE_DEFINE_ENUM(O_DSYNC);
398 TRACE_DEFINE_ENUM(O_DIRECT);
399 TRACE_DEFINE_ENUM(O_LARGEFILE);
400 TRACE_DEFINE_ENUM(O_DIRECTORY);
401 TRACE_DEFINE_ENUM(O_NOFOLLOW);
402 TRACE_DEFINE_ENUM(O_NOATIME);
403 TRACE_DEFINE_ENUM(O_CLOEXEC);
404 
405 #define show_open_flags(flags) \
406 	__print_flags(flags, "|", \
407 		{ O_WRONLY, "O_WRONLY" }, \
408 		{ O_RDWR, "O_RDWR" }, \
409 		{ O_CREAT, "O_CREAT" }, \
410 		{ O_EXCL, "O_EXCL" }, \
411 		{ O_NOCTTY, "O_NOCTTY" }, \
412 		{ O_TRUNC, "O_TRUNC" }, \
413 		{ O_APPEND, "O_APPEND" }, \
414 		{ O_NONBLOCK, "O_NONBLOCK" }, \
415 		{ O_DSYNC, "O_DSYNC" }, \
416 		{ O_DIRECT, "O_DIRECT" }, \
417 		{ O_LARGEFILE, "O_LARGEFILE" }, \
418 		{ O_DIRECTORY, "O_DIRECTORY" }, \
419 		{ O_NOFOLLOW, "O_NOFOLLOW" }, \
420 		{ O_NOATIME, "O_NOATIME" }, \
421 		{ O_CLOEXEC, "O_CLOEXEC" })
422 
423 TRACE_DEFINE_ENUM(FMODE_READ);
424 TRACE_DEFINE_ENUM(FMODE_WRITE);
425 TRACE_DEFINE_ENUM(FMODE_EXEC);
426 
427 #define show_fmode_flags(mode) \
428 	__print_flags(mode, "|", \
429 		{ ((__force unsigned long)FMODE_READ), "READ" }, \
430 		{ ((__force unsigned long)FMODE_WRITE), "WRITE" }, \
431 		{ ((__force unsigned long)FMODE_EXEC), "EXEC" })
432 
433 TRACE_EVENT(nfs_atomic_open_enter,
434 		TP_PROTO(
435 			const struct inode *dir,
436 			const struct nfs_open_context *ctx,
437 			unsigned int flags
438 		),
439 
440 		TP_ARGS(dir, ctx, flags),
441 
442 		TP_STRUCT__entry(
443 			__field(unsigned long, flags)
444 			__field(unsigned int, fmode)
445 			__field(dev_t, dev)
446 			__field(u64, dir)
447 			__string(name, ctx->dentry->d_name.name)
448 		),
449 
450 		TP_fast_assign(
451 			__entry->dev = dir->i_sb->s_dev;
452 			__entry->dir = NFS_FILEID(dir);
453 			__entry->flags = flags;
454 			__entry->fmode = (__force unsigned int)ctx->mode;
455 			__assign_str(name, ctx->dentry->d_name.name);
456 		),
457 
458 		TP_printk(
459 			"flags=0x%lx (%s) fmode=%s name=%02x:%02x:%llu/%s",
460 			__entry->flags,
461 			show_open_flags(__entry->flags),
462 			show_fmode_flags(__entry->fmode),
463 			MAJOR(__entry->dev), MINOR(__entry->dev),
464 			(unsigned long long)__entry->dir,
465 			__get_str(name)
466 		)
467 );
468 
469 TRACE_EVENT(nfs_atomic_open_exit,
470 		TP_PROTO(
471 			const struct inode *dir,
472 			const struct nfs_open_context *ctx,
473 			unsigned int flags,
474 			int error
475 		),
476 
477 		TP_ARGS(dir, ctx, flags, error),
478 
479 		TP_STRUCT__entry(
480 			__field(unsigned long, error)
481 			__field(unsigned long, flags)
482 			__field(unsigned int, fmode)
483 			__field(dev_t, dev)
484 			__field(u64, dir)
485 			__string(name, ctx->dentry->d_name.name)
486 		),
487 
488 		TP_fast_assign(
489 			__entry->error = -error;
490 			__entry->dev = dir->i_sb->s_dev;
491 			__entry->dir = NFS_FILEID(dir);
492 			__entry->flags = flags;
493 			__entry->fmode = (__force unsigned int)ctx->mode;
494 			__assign_str(name, ctx->dentry->d_name.name);
495 		),
496 
497 		TP_printk(
498 			"error=%ld (%s) flags=0x%lx (%s) fmode=%s "
499 			"name=%02x:%02x:%llu/%s",
500 			-__entry->error, nfs_show_status(__entry->error),
501 			__entry->flags,
502 			show_open_flags(__entry->flags),
503 			show_fmode_flags(__entry->fmode),
504 			MAJOR(__entry->dev), MINOR(__entry->dev),
505 			(unsigned long long)__entry->dir,
506 			__get_str(name)
507 		)
508 );
509 
510 TRACE_EVENT(nfs_create_enter,
511 		TP_PROTO(
512 			const struct inode *dir,
513 			const struct dentry *dentry,
514 			unsigned int flags
515 		),
516 
517 		TP_ARGS(dir, dentry, flags),
518 
519 		TP_STRUCT__entry(
520 			__field(unsigned long, flags)
521 			__field(dev_t, dev)
522 			__field(u64, dir)
523 			__string(name, dentry->d_name.name)
524 		),
525 
526 		TP_fast_assign(
527 			__entry->dev = dir->i_sb->s_dev;
528 			__entry->dir = NFS_FILEID(dir);
529 			__entry->flags = flags;
530 			__assign_str(name, dentry->d_name.name);
531 		),
532 
533 		TP_printk(
534 			"flags=0x%lx (%s) name=%02x:%02x:%llu/%s",
535 			__entry->flags,
536 			show_open_flags(__entry->flags),
537 			MAJOR(__entry->dev), MINOR(__entry->dev),
538 			(unsigned long long)__entry->dir,
539 			__get_str(name)
540 		)
541 );
542 
543 TRACE_EVENT(nfs_create_exit,
544 		TP_PROTO(
545 			const struct inode *dir,
546 			const struct dentry *dentry,
547 			unsigned int flags,
548 			int error
549 		),
550 
551 		TP_ARGS(dir, dentry, flags, error),
552 
553 		TP_STRUCT__entry(
554 			__field(unsigned long, error)
555 			__field(unsigned long, flags)
556 			__field(dev_t, dev)
557 			__field(u64, dir)
558 			__string(name, dentry->d_name.name)
559 		),
560 
561 		TP_fast_assign(
562 			__entry->error = -error;
563 			__entry->dev = dir->i_sb->s_dev;
564 			__entry->dir = NFS_FILEID(dir);
565 			__entry->flags = flags;
566 			__assign_str(name, dentry->d_name.name);
567 		),
568 
569 		TP_printk(
570 			"error=%ld (%s) flags=0x%lx (%s) name=%02x:%02x:%llu/%s",
571 			-__entry->error, nfs_show_status(__entry->error),
572 			__entry->flags,
573 			show_open_flags(__entry->flags),
574 			MAJOR(__entry->dev), MINOR(__entry->dev),
575 			(unsigned long long)__entry->dir,
576 			__get_str(name)
577 		)
578 );
579 
580 DECLARE_EVENT_CLASS(nfs_directory_event,
581 		TP_PROTO(
582 			const struct inode *dir,
583 			const struct dentry *dentry
584 		),
585 
586 		TP_ARGS(dir, dentry),
587 
588 		TP_STRUCT__entry(
589 			__field(dev_t, dev)
590 			__field(u64, dir)
591 			__string(name, dentry->d_name.name)
592 		),
593 
594 		TP_fast_assign(
595 			__entry->dev = dir->i_sb->s_dev;
596 			__entry->dir = NFS_FILEID(dir);
597 			__assign_str(name, dentry->d_name.name);
598 		),
599 
600 		TP_printk(
601 			"name=%02x:%02x:%llu/%s",
602 			MAJOR(__entry->dev), MINOR(__entry->dev),
603 			(unsigned long long)__entry->dir,
604 			__get_str(name)
605 		)
606 );
607 
608 #define DEFINE_NFS_DIRECTORY_EVENT(name) \
609 	DEFINE_EVENT(nfs_directory_event, name, \
610 			TP_PROTO( \
611 				const struct inode *dir, \
612 				const struct dentry *dentry \
613 			), \
614 			TP_ARGS(dir, dentry))
615 
616 DECLARE_EVENT_CLASS(nfs_directory_event_done,
617 		TP_PROTO(
618 			const struct inode *dir,
619 			const struct dentry *dentry,
620 			int error
621 		),
622 
623 		TP_ARGS(dir, dentry, error),
624 
625 		TP_STRUCT__entry(
626 			__field(unsigned long, error)
627 			__field(dev_t, dev)
628 			__field(u64, dir)
629 			__string(name, dentry->d_name.name)
630 		),
631 
632 		TP_fast_assign(
633 			__entry->dev = dir->i_sb->s_dev;
634 			__entry->dir = NFS_FILEID(dir);
635 			__entry->error = error < 0 ? -error : 0;
636 			__assign_str(name, dentry->d_name.name);
637 		),
638 
639 		TP_printk(
640 			"error=%ld (%s) name=%02x:%02x:%llu/%s",
641 			-__entry->error, nfs_show_status(__entry->error),
642 			MAJOR(__entry->dev), MINOR(__entry->dev),
643 			(unsigned long long)__entry->dir,
644 			__get_str(name)
645 		)
646 );
647 
648 #define DEFINE_NFS_DIRECTORY_EVENT_DONE(name) \
649 	DEFINE_EVENT(nfs_directory_event_done, name, \
650 			TP_PROTO( \
651 				const struct inode *dir, \
652 				const struct dentry *dentry, \
653 				int error \
654 			), \
655 			TP_ARGS(dir, dentry, error))
656 
657 DEFINE_NFS_DIRECTORY_EVENT(nfs_mknod_enter);
658 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_mknod_exit);
659 DEFINE_NFS_DIRECTORY_EVENT(nfs_mkdir_enter);
660 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_mkdir_exit);
661 DEFINE_NFS_DIRECTORY_EVENT(nfs_rmdir_enter);
662 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_rmdir_exit);
663 DEFINE_NFS_DIRECTORY_EVENT(nfs_remove_enter);
664 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_remove_exit);
665 DEFINE_NFS_DIRECTORY_EVENT(nfs_unlink_enter);
666 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_unlink_exit);
667 DEFINE_NFS_DIRECTORY_EVENT(nfs_symlink_enter);
668 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_symlink_exit);
669 
670 TRACE_EVENT(nfs_link_enter,
671 		TP_PROTO(
672 			const struct inode *inode,
673 			const struct inode *dir,
674 			const struct dentry *dentry
675 		),
676 
677 		TP_ARGS(inode, dir, dentry),
678 
679 		TP_STRUCT__entry(
680 			__field(dev_t, dev)
681 			__field(u64, fileid)
682 			__field(u64, dir)
683 			__string(name, dentry->d_name.name)
684 		),
685 
686 		TP_fast_assign(
687 			__entry->dev = inode->i_sb->s_dev;
688 			__entry->fileid = NFS_FILEID(inode);
689 			__entry->dir = NFS_FILEID(dir);
690 			__assign_str(name, dentry->d_name.name);
691 		),
692 
693 		TP_printk(
694 			"fileid=%02x:%02x:%llu name=%02x:%02x:%llu/%s",
695 			MAJOR(__entry->dev), MINOR(__entry->dev),
696 			__entry->fileid,
697 			MAJOR(__entry->dev), MINOR(__entry->dev),
698 			(unsigned long long)__entry->dir,
699 			__get_str(name)
700 		)
701 );
702 
703 TRACE_EVENT(nfs_link_exit,
704 		TP_PROTO(
705 			const struct inode *inode,
706 			const struct inode *dir,
707 			const struct dentry *dentry,
708 			int error
709 		),
710 
711 		TP_ARGS(inode, dir, dentry, error),
712 
713 		TP_STRUCT__entry(
714 			__field(unsigned long, error)
715 			__field(dev_t, dev)
716 			__field(u64, fileid)
717 			__field(u64, dir)
718 			__string(name, dentry->d_name.name)
719 		),
720 
721 		TP_fast_assign(
722 			__entry->dev = inode->i_sb->s_dev;
723 			__entry->fileid = NFS_FILEID(inode);
724 			__entry->dir = NFS_FILEID(dir);
725 			__entry->error = error < 0 ? -error : 0;
726 			__assign_str(name, dentry->d_name.name);
727 		),
728 
729 		TP_printk(
730 			"error=%ld (%s) fileid=%02x:%02x:%llu name=%02x:%02x:%llu/%s",
731 			-__entry->error, nfs_show_status(__entry->error),
732 			MAJOR(__entry->dev), MINOR(__entry->dev),
733 			__entry->fileid,
734 			MAJOR(__entry->dev), MINOR(__entry->dev),
735 			(unsigned long long)__entry->dir,
736 			__get_str(name)
737 		)
738 );
739 
740 DECLARE_EVENT_CLASS(nfs_rename_event,
741 		TP_PROTO(
742 			const struct inode *old_dir,
743 			const struct dentry *old_dentry,
744 			const struct inode *new_dir,
745 			const struct dentry *new_dentry
746 		),
747 
748 		TP_ARGS(old_dir, old_dentry, new_dir, new_dentry),
749 
750 		TP_STRUCT__entry(
751 			__field(dev_t, dev)
752 			__field(u64, old_dir)
753 			__field(u64, new_dir)
754 			__string(old_name, old_dentry->d_name.name)
755 			__string(new_name, new_dentry->d_name.name)
756 		),
757 
758 		TP_fast_assign(
759 			__entry->dev = old_dir->i_sb->s_dev;
760 			__entry->old_dir = NFS_FILEID(old_dir);
761 			__entry->new_dir = NFS_FILEID(new_dir);
762 			__assign_str(old_name, old_dentry->d_name.name);
763 			__assign_str(new_name, new_dentry->d_name.name);
764 		),
765 
766 		TP_printk(
767 			"old_name=%02x:%02x:%llu/%s new_name=%02x:%02x:%llu/%s",
768 			MAJOR(__entry->dev), MINOR(__entry->dev),
769 			(unsigned long long)__entry->old_dir,
770 			__get_str(old_name),
771 			MAJOR(__entry->dev), MINOR(__entry->dev),
772 			(unsigned long long)__entry->new_dir,
773 			__get_str(new_name)
774 		)
775 );
776 #define DEFINE_NFS_RENAME_EVENT(name) \
777 	DEFINE_EVENT(nfs_rename_event, name, \
778 			TP_PROTO( \
779 				const struct inode *old_dir, \
780 				const struct dentry *old_dentry, \
781 				const struct inode *new_dir, \
782 				const struct dentry *new_dentry \
783 			), \
784 			TP_ARGS(old_dir, old_dentry, new_dir, new_dentry))
785 
786 DECLARE_EVENT_CLASS(nfs_rename_event_done,
787 		TP_PROTO(
788 			const struct inode *old_dir,
789 			const struct dentry *old_dentry,
790 			const struct inode *new_dir,
791 			const struct dentry *new_dentry,
792 			int error
793 		),
794 
795 		TP_ARGS(old_dir, old_dentry, new_dir, new_dentry, error),
796 
797 		TP_STRUCT__entry(
798 			__field(dev_t, dev)
799 			__field(unsigned long, error)
800 			__field(u64, old_dir)
801 			__string(old_name, old_dentry->d_name.name)
802 			__field(u64, new_dir)
803 			__string(new_name, new_dentry->d_name.name)
804 		),
805 
806 		TP_fast_assign(
807 			__entry->dev = old_dir->i_sb->s_dev;
808 			__entry->error = -error;
809 			__entry->old_dir = NFS_FILEID(old_dir);
810 			__entry->new_dir = NFS_FILEID(new_dir);
811 			__assign_str(old_name, old_dentry->d_name.name);
812 			__assign_str(new_name, new_dentry->d_name.name);
813 		),
814 
815 		TP_printk(
816 			"error=%ld (%s) old_name=%02x:%02x:%llu/%s "
817 			"new_name=%02x:%02x:%llu/%s",
818 			-__entry->error, nfs_show_status(__entry->error),
819 			MAJOR(__entry->dev), MINOR(__entry->dev),
820 			(unsigned long long)__entry->old_dir,
821 			__get_str(old_name),
822 			MAJOR(__entry->dev), MINOR(__entry->dev),
823 			(unsigned long long)__entry->new_dir,
824 			__get_str(new_name)
825 		)
826 );
827 #define DEFINE_NFS_RENAME_EVENT_DONE(name) \
828 	DEFINE_EVENT(nfs_rename_event_done, name, \
829 			TP_PROTO( \
830 				const struct inode *old_dir, \
831 				const struct dentry *old_dentry, \
832 				const struct inode *new_dir, \
833 				const struct dentry *new_dentry, \
834 				int error \
835 			), \
836 			TP_ARGS(old_dir, old_dentry, new_dir, \
837 				new_dentry, error))
838 
839 DEFINE_NFS_RENAME_EVENT(nfs_rename_enter);
840 DEFINE_NFS_RENAME_EVENT_DONE(nfs_rename_exit);
841 
842 DEFINE_NFS_RENAME_EVENT_DONE(nfs_sillyrename_rename);
843 
844 TRACE_EVENT(nfs_sillyrename_unlink,
845 		TP_PROTO(
846 			const struct nfs_unlinkdata *data,
847 			int error
848 		),
849 
850 		TP_ARGS(data, error),
851 
852 		TP_STRUCT__entry(
853 			__field(dev_t, dev)
854 			__field(unsigned long, error)
855 			__field(u64, dir)
856 			__dynamic_array(char, name, data->args.name.len + 1)
857 		),
858 
859 		TP_fast_assign(
860 			struct inode *dir = d_inode(data->dentry->d_parent);
861 			size_t len = data->args.name.len;
862 			__entry->dev = dir->i_sb->s_dev;
863 			__entry->dir = NFS_FILEID(dir);
864 			__entry->error = -error;
865 			memcpy(__get_str(name),
866 				data->args.name.name, len);
867 			__get_str(name)[len] = 0;
868 		),
869 
870 		TP_printk(
871 			"error=%ld (%s) name=%02x:%02x:%llu/%s",
872 			-__entry->error, nfs_show_status(__entry->error),
873 			MAJOR(__entry->dev), MINOR(__entry->dev),
874 			(unsigned long long)__entry->dir,
875 			__get_str(name)
876 		)
877 );
878 
879 TRACE_EVENT(nfs_initiate_read,
880 		TP_PROTO(
881 			const struct nfs_pgio_header *hdr
882 		),
883 
884 		TP_ARGS(hdr),
885 
886 		TP_STRUCT__entry(
887 			__field(dev_t, dev)
888 			__field(u32, fhandle)
889 			__field(u64, fileid)
890 			__field(loff_t, offset)
891 			__field(u32, count)
892 		),
893 
894 		TP_fast_assign(
895 			const struct inode *inode = hdr->inode;
896 			const struct nfs_inode *nfsi = NFS_I(inode);
897 			const struct nfs_fh *fh = hdr->args.fh ?
898 						  hdr->args.fh : &nfsi->fh;
899 
900 			__entry->offset = hdr->args.offset;
901 			__entry->count = hdr->args.count;
902 			__entry->dev = inode->i_sb->s_dev;
903 			__entry->fileid = nfsi->fileid;
904 			__entry->fhandle = nfs_fhandle_hash(fh);
905 		),
906 
907 		TP_printk(
908 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
909 			"offset=%lld count=%u",
910 			MAJOR(__entry->dev), MINOR(__entry->dev),
911 			(unsigned long long)__entry->fileid,
912 			__entry->fhandle,
913 			(long long)__entry->offset, __entry->count
914 		)
915 );
916 
917 TRACE_EVENT(nfs_readpage_done,
918 		TP_PROTO(
919 			const struct rpc_task *task,
920 			const struct nfs_pgio_header *hdr
921 		),
922 
923 		TP_ARGS(task, hdr),
924 
925 		TP_STRUCT__entry(
926 			__field(dev_t, dev)
927 			__field(u32, fhandle)
928 			__field(u64, fileid)
929 			__field(loff_t, offset)
930 			__field(u32, arg_count)
931 			__field(u32, res_count)
932 			__field(bool, eof)
933 			__field(int, status)
934 		),
935 
936 		TP_fast_assign(
937 			const struct inode *inode = hdr->inode;
938 			const struct nfs_inode *nfsi = NFS_I(inode);
939 			const struct nfs_fh *fh = hdr->args.fh ?
940 						  hdr->args.fh : &nfsi->fh;
941 
942 			__entry->status = task->tk_status;
943 			__entry->offset = hdr->args.offset;
944 			__entry->arg_count = hdr->args.count;
945 			__entry->res_count = hdr->res.count;
946 			__entry->eof = hdr->res.eof;
947 			__entry->dev = inode->i_sb->s_dev;
948 			__entry->fileid = nfsi->fileid;
949 			__entry->fhandle = nfs_fhandle_hash(fh);
950 		),
951 
952 		TP_printk(
953 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
954 			"offset=%lld count=%u res=%u status=%d%s",
955 			MAJOR(__entry->dev), MINOR(__entry->dev),
956 			(unsigned long long)__entry->fileid,
957 			__entry->fhandle,
958 			(long long)__entry->offset, __entry->arg_count,
959 			__entry->res_count, __entry->status,
960 			__entry->eof ? " eof" : ""
961 		)
962 );
963 
964 TRACE_EVENT(nfs_readpage_short,
965 		TP_PROTO(
966 			const struct rpc_task *task,
967 			const struct nfs_pgio_header *hdr
968 		),
969 
970 		TP_ARGS(task, hdr),
971 
972 		TP_STRUCT__entry(
973 			__field(dev_t, dev)
974 			__field(u32, fhandle)
975 			__field(u64, fileid)
976 			__field(loff_t, offset)
977 			__field(u32, arg_count)
978 			__field(u32, res_count)
979 			__field(bool, eof)
980 			__field(int, status)
981 		),
982 
983 		TP_fast_assign(
984 			const struct inode *inode = hdr->inode;
985 			const struct nfs_inode *nfsi = NFS_I(inode);
986 			const struct nfs_fh *fh = hdr->args.fh ?
987 						  hdr->args.fh : &nfsi->fh;
988 
989 			__entry->status = task->tk_status;
990 			__entry->offset = hdr->args.offset;
991 			__entry->arg_count = hdr->args.count;
992 			__entry->res_count = hdr->res.count;
993 			__entry->eof = hdr->res.eof;
994 			__entry->dev = inode->i_sb->s_dev;
995 			__entry->fileid = nfsi->fileid;
996 			__entry->fhandle = nfs_fhandle_hash(fh);
997 		),
998 
999 		TP_printk(
1000 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1001 			"offset=%lld count=%u res=%u status=%d%s",
1002 			MAJOR(__entry->dev), MINOR(__entry->dev),
1003 			(unsigned long long)__entry->fileid,
1004 			__entry->fhandle,
1005 			(long long)__entry->offset, __entry->arg_count,
1006 			__entry->res_count, __entry->status,
1007 			__entry->eof ? " eof" : ""
1008 		)
1009 );
1010 
1011 TRACE_EVENT(nfs_pgio_error,
1012 	TP_PROTO(
1013 		const struct nfs_pgio_header *hdr,
1014 		int error,
1015 		loff_t pos
1016 	),
1017 
1018 	TP_ARGS(hdr, error, pos),
1019 
1020 	TP_STRUCT__entry(
1021 		__field(dev_t, dev)
1022 		__field(u32, fhandle)
1023 		__field(u64, fileid)
1024 		__field(loff_t, offset)
1025 		__field(u32, arg_count)
1026 		__field(u32, res_count)
1027 		__field(loff_t, pos)
1028 		__field(int, status)
1029 	),
1030 
1031 	TP_fast_assign(
1032 		const struct inode *inode = hdr->inode;
1033 		const struct nfs_inode *nfsi = NFS_I(inode);
1034 		const struct nfs_fh *fh = hdr->args.fh ?
1035 					  hdr->args.fh : &nfsi->fh;
1036 
1037 		__entry->status = error;
1038 		__entry->offset = hdr->args.offset;
1039 		__entry->arg_count = hdr->args.count;
1040 		__entry->res_count = hdr->res.count;
1041 		__entry->dev = inode->i_sb->s_dev;
1042 		__entry->fileid = nfsi->fileid;
1043 		__entry->fhandle = nfs_fhandle_hash(fh);
1044 	),
1045 
1046 	TP_printk("fileid=%02x:%02x:%llu fhandle=0x%08x "
1047 		  "offset=%lld count=%u res=%u pos=%llu status=%d",
1048 		MAJOR(__entry->dev), MINOR(__entry->dev),
1049 		(unsigned long long)__entry->fileid, __entry->fhandle,
1050 		(long long)__entry->offset, __entry->arg_count, __entry->res_count,
1051 		__entry->pos, __entry->status
1052 	)
1053 );
1054 
1055 TRACE_DEFINE_ENUM(NFS_UNSTABLE);
1056 TRACE_DEFINE_ENUM(NFS_DATA_SYNC);
1057 TRACE_DEFINE_ENUM(NFS_FILE_SYNC);
1058 
1059 #define nfs_show_stable(stable) \
1060 	__print_symbolic(stable, \
1061 			{ NFS_UNSTABLE, "UNSTABLE" }, \
1062 			{ NFS_DATA_SYNC, "DATA_SYNC" }, \
1063 			{ NFS_FILE_SYNC, "FILE_SYNC" })
1064 
1065 TRACE_EVENT(nfs_initiate_write,
1066 		TP_PROTO(
1067 			const struct nfs_pgio_header *hdr
1068 		),
1069 
1070 		TP_ARGS(hdr),
1071 
1072 		TP_STRUCT__entry(
1073 			__field(dev_t, dev)
1074 			__field(u32, fhandle)
1075 			__field(u64, fileid)
1076 			__field(loff_t, offset)
1077 			__field(u32, count)
1078 			__field(enum nfs3_stable_how, stable)
1079 		),
1080 
1081 		TP_fast_assign(
1082 			const struct inode *inode = hdr->inode;
1083 			const struct nfs_inode *nfsi = NFS_I(inode);
1084 			const struct nfs_fh *fh = hdr->args.fh ?
1085 						  hdr->args.fh : &nfsi->fh;
1086 
1087 			__entry->offset = hdr->args.offset;
1088 			__entry->count = hdr->args.count;
1089 			__entry->stable = hdr->args.stable;
1090 			__entry->dev = inode->i_sb->s_dev;
1091 			__entry->fileid = nfsi->fileid;
1092 			__entry->fhandle = nfs_fhandle_hash(fh);
1093 		),
1094 
1095 		TP_printk(
1096 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1097 			"offset=%lld count=%u stable=%s",
1098 			MAJOR(__entry->dev), MINOR(__entry->dev),
1099 			(unsigned long long)__entry->fileid,
1100 			__entry->fhandle,
1101 			(long long)__entry->offset, __entry->count,
1102 			nfs_show_stable(__entry->stable)
1103 		)
1104 );
1105 
1106 TRACE_EVENT(nfs_writeback_done,
1107 		TP_PROTO(
1108 			const struct rpc_task *task,
1109 			const struct nfs_pgio_header *hdr
1110 		),
1111 
1112 		TP_ARGS(task, hdr),
1113 
1114 		TP_STRUCT__entry(
1115 			__field(dev_t, dev)
1116 			__field(u32, fhandle)
1117 			__field(u64, fileid)
1118 			__field(loff_t, offset)
1119 			__field(u32, arg_count)
1120 			__field(u32, res_count)
1121 			__field(int, status)
1122 			__field(enum nfs3_stable_how, stable)
1123 			__array(char, verifier, NFS4_VERIFIER_SIZE)
1124 		),
1125 
1126 		TP_fast_assign(
1127 			const struct inode *inode = hdr->inode;
1128 			const struct nfs_inode *nfsi = NFS_I(inode);
1129 			const struct nfs_fh *fh = hdr->args.fh ?
1130 						  hdr->args.fh : &nfsi->fh;
1131 			const struct nfs_writeverf *verf = hdr->res.verf;
1132 
1133 			__entry->status = task->tk_status;
1134 			__entry->offset = hdr->args.offset;
1135 			__entry->arg_count = hdr->args.count;
1136 			__entry->res_count = hdr->res.count;
1137 			__entry->stable = verf->committed;
1138 			memcpy(__entry->verifier,
1139 				&verf->verifier,
1140 				NFS4_VERIFIER_SIZE);
1141 			__entry->dev = inode->i_sb->s_dev;
1142 			__entry->fileid = nfsi->fileid;
1143 			__entry->fhandle = nfs_fhandle_hash(fh);
1144 		),
1145 
1146 		TP_printk(
1147 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1148 			"offset=%lld count=%u res=%u status=%d stable=%s "
1149 			"verifier=%s",
1150 			MAJOR(__entry->dev), MINOR(__entry->dev),
1151 			(unsigned long long)__entry->fileid,
1152 			__entry->fhandle,
1153 			(long long)__entry->offset, __entry->arg_count,
1154 			__entry->res_count, __entry->status,
1155 			nfs_show_stable(__entry->stable),
1156 			__print_hex_str(__entry->verifier, NFS4_VERIFIER_SIZE)
1157 		)
1158 );
1159 
1160 DECLARE_EVENT_CLASS(nfs_page_error_class,
1161 		TP_PROTO(
1162 			const struct nfs_page *req,
1163 			int error
1164 		),
1165 
1166 		TP_ARGS(req, error),
1167 
1168 		TP_STRUCT__entry(
1169 			__field(const void *, req)
1170 			__field(pgoff_t, index)
1171 			__field(unsigned int, offset)
1172 			__field(unsigned int, pgbase)
1173 			__field(unsigned int, bytes)
1174 			__field(int, error)
1175 		),
1176 
1177 		TP_fast_assign(
1178 			__entry->req = req;
1179 			__entry->index = req->wb_index;
1180 			__entry->offset = req->wb_offset;
1181 			__entry->pgbase = req->wb_pgbase;
1182 			__entry->bytes = req->wb_bytes;
1183 			__entry->error = error;
1184 		),
1185 
1186 		TP_printk(
1187 			"req=%p index=%lu offset=%u pgbase=%u bytes=%u error=%d",
1188 			__entry->req, __entry->index, __entry->offset,
1189 			__entry->pgbase, __entry->bytes, __entry->error
1190 		)
1191 );
1192 
1193 #define DEFINE_NFS_PAGEERR_EVENT(name) \
1194 	DEFINE_EVENT(nfs_page_error_class, name, \
1195 			TP_PROTO( \
1196 				const struct nfs_page *req, \
1197 				int error \
1198 			), \
1199 			TP_ARGS(req, error))
1200 
1201 DEFINE_NFS_PAGEERR_EVENT(nfs_write_error);
1202 DEFINE_NFS_PAGEERR_EVENT(nfs_comp_error);
1203 DEFINE_NFS_PAGEERR_EVENT(nfs_commit_error);
1204 
1205 TRACE_EVENT(nfs_initiate_commit,
1206 		TP_PROTO(
1207 			const struct nfs_commit_data *data
1208 		),
1209 
1210 		TP_ARGS(data),
1211 
1212 		TP_STRUCT__entry(
1213 			__field(dev_t, dev)
1214 			__field(u32, fhandle)
1215 			__field(u64, fileid)
1216 			__field(loff_t, offset)
1217 			__field(u32, count)
1218 		),
1219 
1220 		TP_fast_assign(
1221 			const struct inode *inode = data->inode;
1222 			const struct nfs_inode *nfsi = NFS_I(inode);
1223 			const struct nfs_fh *fh = data->args.fh ?
1224 						  data->args.fh : &nfsi->fh;
1225 
1226 			__entry->offset = data->args.offset;
1227 			__entry->count = data->args.count;
1228 			__entry->dev = inode->i_sb->s_dev;
1229 			__entry->fileid = nfsi->fileid;
1230 			__entry->fhandle = nfs_fhandle_hash(fh);
1231 		),
1232 
1233 		TP_printk(
1234 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1235 			"offset=%lld count=%u",
1236 			MAJOR(__entry->dev), MINOR(__entry->dev),
1237 			(unsigned long long)__entry->fileid,
1238 			__entry->fhandle,
1239 			(long long)__entry->offset, __entry->count
1240 		)
1241 );
1242 
1243 TRACE_EVENT(nfs_commit_done,
1244 		TP_PROTO(
1245 			const struct rpc_task *task,
1246 			const struct nfs_commit_data *data
1247 		),
1248 
1249 		TP_ARGS(task, data),
1250 
1251 		TP_STRUCT__entry(
1252 			__field(dev_t, dev)
1253 			__field(u32, fhandle)
1254 			__field(u64, fileid)
1255 			__field(loff_t, offset)
1256 			__field(int, status)
1257 			__field(enum nfs3_stable_how, stable)
1258 			__array(char, verifier, NFS4_VERIFIER_SIZE)
1259 		),
1260 
1261 		TP_fast_assign(
1262 			const struct inode *inode = data->inode;
1263 			const struct nfs_inode *nfsi = NFS_I(inode);
1264 			const struct nfs_fh *fh = data->args.fh ?
1265 						  data->args.fh : &nfsi->fh;
1266 			const struct nfs_writeverf *verf = data->res.verf;
1267 
1268 			__entry->status = task->tk_status;
1269 			__entry->offset = data->args.offset;
1270 			__entry->stable = verf->committed;
1271 			memcpy(__entry->verifier,
1272 				&verf->verifier,
1273 				NFS4_VERIFIER_SIZE);
1274 			__entry->dev = inode->i_sb->s_dev;
1275 			__entry->fileid = nfsi->fileid;
1276 			__entry->fhandle = nfs_fhandle_hash(fh);
1277 		),
1278 
1279 		TP_printk(
1280 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1281 			"offset=%lld status=%d stable=%s verifier=%s",
1282 			MAJOR(__entry->dev), MINOR(__entry->dev),
1283 			(unsigned long long)__entry->fileid,
1284 			__entry->fhandle,
1285 			(long long)__entry->offset, __entry->status,
1286 			nfs_show_stable(__entry->stable),
1287 			__print_hex_str(__entry->verifier, NFS4_VERIFIER_SIZE)
1288 		)
1289 );
1290 
1291 TRACE_EVENT(nfs_fh_to_dentry,
1292 		TP_PROTO(
1293 			const struct super_block *sb,
1294 			const struct nfs_fh *fh,
1295 			u64 fileid,
1296 			int error
1297 		),
1298 
1299 		TP_ARGS(sb, fh, fileid, error),
1300 
1301 		TP_STRUCT__entry(
1302 			__field(int, error)
1303 			__field(dev_t, dev)
1304 			__field(u32, fhandle)
1305 			__field(u64, fileid)
1306 		),
1307 
1308 		TP_fast_assign(
1309 			__entry->error = error;
1310 			__entry->dev = sb->s_dev;
1311 			__entry->fileid = fileid;
1312 			__entry->fhandle = nfs_fhandle_hash(fh);
1313 		),
1314 
1315 		TP_printk(
1316 			"error=%d fileid=%02x:%02x:%llu fhandle=0x%08x ",
1317 			__entry->error,
1318 			MAJOR(__entry->dev), MINOR(__entry->dev),
1319 			(unsigned long long)__entry->fileid,
1320 			__entry->fhandle
1321 		)
1322 );
1323 
1324 TRACE_DEFINE_ENUM(NFS_OK);
1325 TRACE_DEFINE_ENUM(NFSERR_PERM);
1326 TRACE_DEFINE_ENUM(NFSERR_NOENT);
1327 TRACE_DEFINE_ENUM(NFSERR_IO);
1328 TRACE_DEFINE_ENUM(NFSERR_NXIO);
1329 TRACE_DEFINE_ENUM(ECHILD);
1330 TRACE_DEFINE_ENUM(NFSERR_EAGAIN);
1331 TRACE_DEFINE_ENUM(NFSERR_ACCES);
1332 TRACE_DEFINE_ENUM(NFSERR_EXIST);
1333 TRACE_DEFINE_ENUM(NFSERR_XDEV);
1334 TRACE_DEFINE_ENUM(NFSERR_NODEV);
1335 TRACE_DEFINE_ENUM(NFSERR_NOTDIR);
1336 TRACE_DEFINE_ENUM(NFSERR_ISDIR);
1337 TRACE_DEFINE_ENUM(NFSERR_INVAL);
1338 TRACE_DEFINE_ENUM(NFSERR_FBIG);
1339 TRACE_DEFINE_ENUM(NFSERR_NOSPC);
1340 TRACE_DEFINE_ENUM(NFSERR_ROFS);
1341 TRACE_DEFINE_ENUM(NFSERR_MLINK);
1342 TRACE_DEFINE_ENUM(NFSERR_OPNOTSUPP);
1343 TRACE_DEFINE_ENUM(NFSERR_NAMETOOLONG);
1344 TRACE_DEFINE_ENUM(NFSERR_NOTEMPTY);
1345 TRACE_DEFINE_ENUM(NFSERR_DQUOT);
1346 TRACE_DEFINE_ENUM(NFSERR_STALE);
1347 TRACE_DEFINE_ENUM(NFSERR_REMOTE);
1348 TRACE_DEFINE_ENUM(NFSERR_WFLUSH);
1349 TRACE_DEFINE_ENUM(NFSERR_BADHANDLE);
1350 TRACE_DEFINE_ENUM(NFSERR_NOT_SYNC);
1351 TRACE_DEFINE_ENUM(NFSERR_BAD_COOKIE);
1352 TRACE_DEFINE_ENUM(NFSERR_NOTSUPP);
1353 TRACE_DEFINE_ENUM(NFSERR_TOOSMALL);
1354 TRACE_DEFINE_ENUM(NFSERR_SERVERFAULT);
1355 TRACE_DEFINE_ENUM(NFSERR_BADTYPE);
1356 TRACE_DEFINE_ENUM(NFSERR_JUKEBOX);
1357 
1358 #define nfs_show_status(x) \
1359 	__print_symbolic(x, \
1360 			{ NFS_OK, "OK" }, \
1361 			{ NFSERR_PERM, "PERM" }, \
1362 			{ NFSERR_NOENT, "NOENT" }, \
1363 			{ NFSERR_IO, "IO" }, \
1364 			{ NFSERR_NXIO, "NXIO" }, \
1365 			{ ECHILD, "CHILD" }, \
1366 			{ NFSERR_EAGAIN, "AGAIN" }, \
1367 			{ NFSERR_ACCES, "ACCES" }, \
1368 			{ NFSERR_EXIST, "EXIST" }, \
1369 			{ NFSERR_XDEV, "XDEV" }, \
1370 			{ NFSERR_NODEV, "NODEV" }, \
1371 			{ NFSERR_NOTDIR, "NOTDIR" }, \
1372 			{ NFSERR_ISDIR, "ISDIR" }, \
1373 			{ NFSERR_INVAL, "INVAL" }, \
1374 			{ NFSERR_FBIG, "FBIG" }, \
1375 			{ NFSERR_NOSPC, "NOSPC" }, \
1376 			{ NFSERR_ROFS, "ROFS" }, \
1377 			{ NFSERR_MLINK, "MLINK" }, \
1378 			{ NFSERR_OPNOTSUPP, "OPNOTSUPP" }, \
1379 			{ NFSERR_NAMETOOLONG, "NAMETOOLONG" }, \
1380 			{ NFSERR_NOTEMPTY, "NOTEMPTY" }, \
1381 			{ NFSERR_DQUOT, "DQUOT" }, \
1382 			{ NFSERR_STALE, "STALE" }, \
1383 			{ NFSERR_REMOTE, "REMOTE" }, \
1384 			{ NFSERR_WFLUSH, "WFLUSH" }, \
1385 			{ NFSERR_BADHANDLE, "BADHANDLE" }, \
1386 			{ NFSERR_NOT_SYNC, "NOTSYNC" }, \
1387 			{ NFSERR_BAD_COOKIE, "BADCOOKIE" }, \
1388 			{ NFSERR_NOTSUPP, "NOTSUPP" }, \
1389 			{ NFSERR_TOOSMALL, "TOOSMALL" }, \
1390 			{ NFSERR_SERVERFAULT, "REMOTEIO" }, \
1391 			{ NFSERR_BADTYPE, "BADTYPE" }, \
1392 			{ NFSERR_JUKEBOX, "JUKEBOX" })
1393 
1394 TRACE_EVENT(nfs_xdr_status,
1395 		TP_PROTO(
1396 			const struct xdr_stream *xdr,
1397 			int error
1398 		),
1399 
1400 		TP_ARGS(xdr, error),
1401 
1402 		TP_STRUCT__entry(
1403 			__field(unsigned int, task_id)
1404 			__field(unsigned int, client_id)
1405 			__field(u32, xid)
1406 			__field(int, version)
1407 			__field(unsigned long, error)
1408 			__string(program,
1409 				 xdr->rqst->rq_task->tk_client->cl_program->name)
1410 			__string(procedure,
1411 				 xdr->rqst->rq_task->tk_msg.rpc_proc->p_name)
1412 		),
1413 
1414 		TP_fast_assign(
1415 			const struct rpc_rqst *rqstp = xdr->rqst;
1416 			const struct rpc_task *task = rqstp->rq_task;
1417 
1418 			__entry->task_id = task->tk_pid;
1419 			__entry->client_id = task->tk_client->cl_clid;
1420 			__entry->xid = be32_to_cpu(rqstp->rq_xid);
1421 			__entry->version = task->tk_client->cl_vers;
1422 			__entry->error = error;
1423 			__assign_str(program,
1424 				     task->tk_client->cl_program->name)
1425 			__assign_str(procedure, task->tk_msg.rpc_proc->p_name)
1426 		),
1427 
1428 		TP_printk(
1429 			"task:%u@%d xid=0x%08x %sv%d %s error=%ld (%s)",
1430 			__entry->task_id, __entry->client_id, __entry->xid,
1431 			__get_str(program), __entry->version,
1432 			__get_str(procedure), -__entry->error,
1433 			nfs_show_status(__entry->error)
1434 		)
1435 );
1436 
1437 #endif /* _TRACE_NFS_H */
1438 
1439 #undef TRACE_INCLUDE_PATH
1440 #define TRACE_INCLUDE_PATH .
1441 #define TRACE_INCLUDE_FILE nfstrace
1442 /* This part must be outside protection */
1443 #include <trace/define_trace.h>
1444