xref: /openbmc/linux/fs/nfs/nfstrace.h (revision 71de0a05)
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 #include <trace/misc/fs.h>
15 #include <trace/misc/nfs.h>
16 #include <trace/misc/sunrpc.h>
17 
18 #define nfs_show_cache_validity(v) \
19 	__print_flags(v, "|", \
20 			{ NFS_INO_INVALID_DATA, "INVALID_DATA" }, \
21 			{ NFS_INO_INVALID_ATIME, "INVALID_ATIME" }, \
22 			{ NFS_INO_INVALID_ACCESS, "INVALID_ACCESS" }, \
23 			{ NFS_INO_INVALID_ACL, "INVALID_ACL" }, \
24 			{ NFS_INO_REVAL_FORCED, "REVAL_FORCED" }, \
25 			{ NFS_INO_INVALID_LABEL, "INVALID_LABEL" }, \
26 			{ NFS_INO_INVALID_CHANGE, "INVALID_CHANGE" }, \
27 			{ NFS_INO_INVALID_CTIME, "INVALID_CTIME" }, \
28 			{ NFS_INO_INVALID_MTIME, "INVALID_MTIME" }, \
29 			{ NFS_INO_INVALID_SIZE, "INVALID_SIZE" }, \
30 			{ NFS_INO_INVALID_OTHER, "INVALID_OTHER" }, \
31 			{ NFS_INO_DATA_INVAL_DEFER, "DATA_INVAL_DEFER" }, \
32 			{ NFS_INO_INVALID_BLOCKS, "INVALID_BLOCKS" }, \
33 			{ NFS_INO_INVALID_XATTR, "INVALID_XATTR" }, \
34 			{ NFS_INO_INVALID_NLINK, "INVALID_NLINK" }, \
35 			{ NFS_INO_INVALID_MODE, "INVALID_MODE" })
36 
37 #define nfs_show_nfsi_flags(v) \
38 	__print_flags(v, "|", \
39 			{ BIT(NFS_INO_STALE), "STALE" }, \
40 			{ BIT(NFS_INO_ACL_LRU_SET), "ACL_LRU_SET" }, \
41 			{ BIT(NFS_INO_INVALIDATING), "INVALIDATING" }, \
42 			{ BIT(NFS_INO_FSCACHE), "FSCACHE" }, \
43 			{ BIT(NFS_INO_LAYOUTCOMMIT), "NEED_LAYOUTCOMMIT" }, \
44 			{ BIT(NFS_INO_LAYOUTCOMMITTING), "LAYOUTCOMMIT" }, \
45 			{ BIT(NFS_INO_LAYOUTSTATS), "LAYOUTSTATS" }, \
46 			{ BIT(NFS_INO_ODIRECT), "ODIRECT" })
47 
48 DECLARE_EVENT_CLASS(nfs_inode_event,
49 		TP_PROTO(
50 			const struct inode *inode
51 		),
52 
53 		TP_ARGS(inode),
54 
55 		TP_STRUCT__entry(
56 			__field(dev_t, dev)
57 			__field(u32, fhandle)
58 			__field(u64, fileid)
59 			__field(u64, version)
60 		),
61 
62 		TP_fast_assign(
63 			const struct nfs_inode *nfsi = NFS_I(inode);
64 			__entry->dev = inode->i_sb->s_dev;
65 			__entry->fileid = nfsi->fileid;
66 			__entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
67 			__entry->version = inode_peek_iversion_raw(inode);
68 		),
69 
70 		TP_printk(
71 			"fileid=%02x:%02x:%llu fhandle=0x%08x version=%llu ",
72 			MAJOR(__entry->dev), MINOR(__entry->dev),
73 			(unsigned long long)__entry->fileid,
74 			__entry->fhandle,
75 			(unsigned long long)__entry->version
76 		)
77 );
78 
79 DECLARE_EVENT_CLASS(nfs_inode_event_done,
80 		TP_PROTO(
81 			const struct inode *inode,
82 			int error
83 		),
84 
85 		TP_ARGS(inode, error),
86 
87 		TP_STRUCT__entry(
88 			__field(unsigned long, error)
89 			__field(dev_t, dev)
90 			__field(u32, fhandle)
91 			__field(unsigned char, type)
92 			__field(u64, fileid)
93 			__field(u64, version)
94 			__field(loff_t, size)
95 			__field(unsigned long, nfsi_flags)
96 			__field(unsigned long, cache_validity)
97 		),
98 
99 		TP_fast_assign(
100 			const struct nfs_inode *nfsi = NFS_I(inode);
101 			__entry->error = error < 0 ? -error : 0;
102 			__entry->dev = inode->i_sb->s_dev;
103 			__entry->fileid = nfsi->fileid;
104 			__entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
105 			__entry->type = nfs_umode_to_dtype(inode->i_mode);
106 			__entry->version = inode_peek_iversion_raw(inode);
107 			__entry->size = i_size_read(inode);
108 			__entry->nfsi_flags = nfsi->flags;
109 			__entry->cache_validity = nfsi->cache_validity;
110 		),
111 
112 		TP_printk(
113 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
114 			"type=%u (%s) version=%llu size=%lld "
115 			"cache_validity=0x%lx (%s) nfs_flags=0x%lx (%s)",
116 			-__entry->error, show_nfs_status(__entry->error),
117 			MAJOR(__entry->dev), MINOR(__entry->dev),
118 			(unsigned long long)__entry->fileid,
119 			__entry->fhandle,
120 			__entry->type,
121 			show_fs_dirent_type(__entry->type),
122 			(unsigned long long)__entry->version,
123 			(long long)__entry->size,
124 			__entry->cache_validity,
125 			nfs_show_cache_validity(__entry->cache_validity),
126 			__entry->nfsi_flags,
127 			nfs_show_nfsi_flags(__entry->nfsi_flags)
128 		)
129 );
130 
131 #define DEFINE_NFS_INODE_EVENT(name) \
132 	DEFINE_EVENT(nfs_inode_event, name, \
133 			TP_PROTO( \
134 				const struct inode *inode \
135 			), \
136 			TP_ARGS(inode))
137 #define DEFINE_NFS_INODE_EVENT_DONE(name) \
138 	DEFINE_EVENT(nfs_inode_event_done, name, \
139 			TP_PROTO( \
140 				const struct inode *inode, \
141 				int error \
142 			), \
143 			TP_ARGS(inode, error))
144 DEFINE_NFS_INODE_EVENT(nfs_set_inode_stale);
145 DEFINE_NFS_INODE_EVENT(nfs_refresh_inode_enter);
146 DEFINE_NFS_INODE_EVENT_DONE(nfs_refresh_inode_exit);
147 DEFINE_NFS_INODE_EVENT(nfs_revalidate_inode_enter);
148 DEFINE_NFS_INODE_EVENT_DONE(nfs_revalidate_inode_exit);
149 DEFINE_NFS_INODE_EVENT(nfs_invalidate_mapping_enter);
150 DEFINE_NFS_INODE_EVENT_DONE(nfs_invalidate_mapping_exit);
151 DEFINE_NFS_INODE_EVENT(nfs_getattr_enter);
152 DEFINE_NFS_INODE_EVENT_DONE(nfs_getattr_exit);
153 DEFINE_NFS_INODE_EVENT(nfs_setattr_enter);
154 DEFINE_NFS_INODE_EVENT_DONE(nfs_setattr_exit);
155 DEFINE_NFS_INODE_EVENT(nfs_writeback_inode_enter);
156 DEFINE_NFS_INODE_EVENT_DONE(nfs_writeback_inode_exit);
157 DEFINE_NFS_INODE_EVENT(nfs_fsync_enter);
158 DEFINE_NFS_INODE_EVENT_DONE(nfs_fsync_exit);
159 DEFINE_NFS_INODE_EVENT(nfs_access_enter);
160 DEFINE_NFS_INODE_EVENT_DONE(nfs_set_cache_invalid);
161 DEFINE_NFS_INODE_EVENT(nfs_readdir_force_readdirplus);
162 DEFINE_NFS_INODE_EVENT_DONE(nfs_readdir_cache_fill_done);
163 DEFINE_NFS_INODE_EVENT_DONE(nfs_readdir_uncached_done);
164 
165 TRACE_EVENT(nfs_access_exit,
166 		TP_PROTO(
167 			const struct inode *inode,
168 			unsigned int mask,
169 			unsigned int permitted,
170 			int error
171 		),
172 
173 		TP_ARGS(inode, mask, permitted, error),
174 
175 		TP_STRUCT__entry(
176 			__field(unsigned long, error)
177 			__field(dev_t, dev)
178 			__field(u32, fhandle)
179 			__field(unsigned char, type)
180 			__field(u64, fileid)
181 			__field(u64, version)
182 			__field(loff_t, size)
183 			__field(unsigned long, nfsi_flags)
184 			__field(unsigned long, cache_validity)
185 			__field(unsigned int, mask)
186 			__field(unsigned int, permitted)
187 		),
188 
189 		TP_fast_assign(
190 			const struct nfs_inode *nfsi = NFS_I(inode);
191 			__entry->error = error < 0 ? -error : 0;
192 			__entry->dev = inode->i_sb->s_dev;
193 			__entry->fileid = nfsi->fileid;
194 			__entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
195 			__entry->type = nfs_umode_to_dtype(inode->i_mode);
196 			__entry->version = inode_peek_iversion_raw(inode);
197 			__entry->size = i_size_read(inode);
198 			__entry->nfsi_flags = nfsi->flags;
199 			__entry->cache_validity = nfsi->cache_validity;
200 			__entry->mask = mask;
201 			__entry->permitted = permitted;
202 		),
203 
204 		TP_printk(
205 			"error=%ld (%s) fileid=%02x:%02x:%llu fhandle=0x%08x "
206 			"type=%u (%s) version=%llu size=%lld "
207 			"cache_validity=0x%lx (%s) nfs_flags=0x%lx (%s) "
208 			"mask=0x%x permitted=0x%x",
209 			-__entry->error, show_nfs_status(__entry->error),
210 			MAJOR(__entry->dev), MINOR(__entry->dev),
211 			(unsigned long long)__entry->fileid,
212 			__entry->fhandle,
213 			__entry->type,
214 			show_fs_dirent_type(__entry->type),
215 			(unsigned long long)__entry->version,
216 			(long long)__entry->size,
217 			__entry->cache_validity,
218 			nfs_show_cache_validity(__entry->cache_validity),
219 			__entry->nfsi_flags,
220 			nfs_show_nfsi_flags(__entry->nfsi_flags),
221 			__entry->mask, __entry->permitted
222 		)
223 );
224 
225 DECLARE_EVENT_CLASS(nfs_update_size_class,
226 		TP_PROTO(
227 			const struct inode *inode,
228 			loff_t new_size
229 		),
230 
231 		TP_ARGS(inode, new_size),
232 
233 		TP_STRUCT__entry(
234 			__field(dev_t, dev)
235 			__field(u32, fhandle)
236 			__field(u64, fileid)
237 			__field(u64, version)
238 			__field(loff_t, cur_size)
239 			__field(loff_t, new_size)
240 		),
241 
242 		TP_fast_assign(
243 			const struct nfs_inode *nfsi = NFS_I(inode);
244 
245 			__entry->dev = inode->i_sb->s_dev;
246 			__entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
247 			__entry->fileid = nfsi->fileid;
248 			__entry->version = inode_peek_iversion_raw(inode);
249 			__entry->cur_size = i_size_read(inode);
250 			__entry->new_size = new_size;
251 		),
252 
253 		TP_printk(
254 			"fileid=%02x:%02x:%llu fhandle=0x%08x version=%llu cursize=%lld newsize=%lld",
255 			MAJOR(__entry->dev), MINOR(__entry->dev),
256 			(unsigned long long)__entry->fileid,
257 			__entry->fhandle, __entry->version,
258 			__entry->cur_size, __entry->new_size
259 		)
260 );
261 
262 #define DEFINE_NFS_UPDATE_SIZE_EVENT(name) \
263 	DEFINE_EVENT(nfs_update_size_class, nfs_size_##name, \
264 			TP_PROTO( \
265 				const struct inode *inode, \
266 				loff_t new_size \
267 			), \
268 			TP_ARGS(inode, new_size))
269 
270 DEFINE_NFS_UPDATE_SIZE_EVENT(truncate);
271 DEFINE_NFS_UPDATE_SIZE_EVENT(wcc);
272 DEFINE_NFS_UPDATE_SIZE_EVENT(update);
273 DEFINE_NFS_UPDATE_SIZE_EVENT(grow);
274 
275 DECLARE_EVENT_CLASS(nfs_inode_range_event,
276 		TP_PROTO(
277 			const struct inode *inode,
278 			loff_t range_start,
279 			loff_t range_end
280 		),
281 
282 		TP_ARGS(inode, range_start, range_end),
283 
284 		TP_STRUCT__entry(
285 			__field(dev_t, dev)
286 			__field(u32, fhandle)
287 			__field(u64, fileid)
288 			__field(u64, version)
289 			__field(loff_t, range_start)
290 			__field(loff_t, range_end)
291 		),
292 
293 		TP_fast_assign(
294 			const struct nfs_inode *nfsi = NFS_I(inode);
295 
296 			__entry->dev = inode->i_sb->s_dev;
297 			__entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
298 			__entry->fileid = nfsi->fileid;
299 			__entry->version = inode_peek_iversion_raw(inode);
300 			__entry->range_start = range_start;
301 			__entry->range_end = range_end;
302 		),
303 
304 		TP_printk(
305 			"fileid=%02x:%02x:%llu fhandle=0x%08x version=%llu "
306 			"range=[%lld, %lld]",
307 			MAJOR(__entry->dev), MINOR(__entry->dev),
308 			(unsigned long long)__entry->fileid,
309 			__entry->fhandle, __entry->version,
310 			__entry->range_start, __entry->range_end
311 		)
312 );
313 
314 #define DEFINE_NFS_INODE_RANGE_EVENT(name) \
315 	DEFINE_EVENT(nfs_inode_range_event, name, \
316 			TP_PROTO( \
317 				const struct inode *inode, \
318 				loff_t range_start, \
319 				loff_t range_end \
320 			), \
321 			TP_ARGS(inode, range_start, range_end))
322 
323 DEFINE_NFS_INODE_RANGE_EVENT(nfs_readdir_invalidate_cache_range);
324 
325 DECLARE_EVENT_CLASS(nfs_readdir_event,
326 		TP_PROTO(
327 			const struct file *file,
328 			const __be32 *verifier,
329 			u64 cookie,
330 			pgoff_t page_index,
331 			unsigned int dtsize
332 		),
333 
334 		TP_ARGS(file, verifier, cookie, page_index, dtsize),
335 
336 		TP_STRUCT__entry(
337 			__field(dev_t, dev)
338 			__field(u32, fhandle)
339 			__field(u64, fileid)
340 			__field(u64, version)
341 			__array(char, verifier, NFS4_VERIFIER_SIZE)
342 			__field(u64, cookie)
343 			__field(pgoff_t, index)
344 			__field(unsigned int, dtsize)
345 		),
346 
347 		TP_fast_assign(
348 			const struct inode *dir = file_inode(file);
349 			const struct nfs_inode *nfsi = NFS_I(dir);
350 
351 			__entry->dev = dir->i_sb->s_dev;
352 			__entry->fileid = nfsi->fileid;
353 			__entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
354 			__entry->version = inode_peek_iversion_raw(dir);
355 			if (cookie != 0)
356 				memcpy(__entry->verifier, verifier,
357 				       NFS4_VERIFIER_SIZE);
358 			else
359 				memset(__entry->verifier, 0,
360 				       NFS4_VERIFIER_SIZE);
361 			__entry->cookie = cookie;
362 			__entry->index = page_index;
363 			__entry->dtsize = dtsize;
364 		),
365 
366 		TP_printk(
367 			"fileid=%02x:%02x:%llu fhandle=0x%08x version=%llu "
368 			"cookie=%s:0x%llx cache_index=%lu dtsize=%u",
369 			MAJOR(__entry->dev), MINOR(__entry->dev),
370 			(unsigned long long)__entry->fileid, __entry->fhandle,
371 			__entry->version, show_nfs4_verifier(__entry->verifier),
372 			(unsigned long long)__entry->cookie, __entry->index,
373 			__entry->dtsize
374 		)
375 );
376 
377 #define DEFINE_NFS_READDIR_EVENT(name) \
378 	DEFINE_EVENT(nfs_readdir_event, name, \
379 			TP_PROTO( \
380 				const struct file *file, \
381 				const __be32 *verifier, \
382 				u64 cookie, \
383 				pgoff_t page_index, \
384 				unsigned int dtsize \
385 				), \
386 			TP_ARGS(file, verifier, cookie, page_index, dtsize))
387 
388 DEFINE_NFS_READDIR_EVENT(nfs_readdir_cache_fill);
389 DEFINE_NFS_READDIR_EVENT(nfs_readdir_uncached);
390 
391 DECLARE_EVENT_CLASS(nfs_lookup_event,
392 		TP_PROTO(
393 			const struct inode *dir,
394 			const struct dentry *dentry,
395 			unsigned int flags
396 		),
397 
398 		TP_ARGS(dir, dentry, flags),
399 
400 		TP_STRUCT__entry(
401 			__field(unsigned long, flags)
402 			__field(dev_t, dev)
403 			__field(u64, dir)
404 			__string(name, dentry->d_name.name)
405 		),
406 
407 		TP_fast_assign(
408 			__entry->dev = dir->i_sb->s_dev;
409 			__entry->dir = NFS_FILEID(dir);
410 			__entry->flags = flags;
411 			__assign_str(name, dentry->d_name.name);
412 		),
413 
414 		TP_printk(
415 			"flags=0x%lx (%s) name=%02x:%02x:%llu/%s",
416 			__entry->flags,
417 			show_fs_lookup_flags(__entry->flags),
418 			MAJOR(__entry->dev), MINOR(__entry->dev),
419 			(unsigned long long)__entry->dir,
420 			__get_str(name)
421 		)
422 );
423 
424 #define DEFINE_NFS_LOOKUP_EVENT(name) \
425 	DEFINE_EVENT(nfs_lookup_event, name, \
426 			TP_PROTO( \
427 				const struct inode *dir, \
428 				const struct dentry *dentry, \
429 				unsigned int flags \
430 			), \
431 			TP_ARGS(dir, dentry, flags))
432 
433 DECLARE_EVENT_CLASS(nfs_lookup_event_done,
434 		TP_PROTO(
435 			const struct inode *dir,
436 			const struct dentry *dentry,
437 			unsigned int flags,
438 			int error
439 		),
440 
441 		TP_ARGS(dir, dentry, flags, error),
442 
443 		TP_STRUCT__entry(
444 			__field(unsigned long, error)
445 			__field(unsigned long, flags)
446 			__field(dev_t, dev)
447 			__field(u64, dir)
448 			__string(name, 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->error = error < 0 ? -error : 0;
455 			__entry->flags = flags;
456 			__assign_str(name, dentry->d_name.name);
457 		),
458 
459 		TP_printk(
460 			"error=%ld (%s) flags=0x%lx (%s) name=%02x:%02x:%llu/%s",
461 			-__entry->error, show_nfs_status(__entry->error),
462 			__entry->flags,
463 			show_fs_lookup_flags(__entry->flags),
464 			MAJOR(__entry->dev), MINOR(__entry->dev),
465 			(unsigned long long)__entry->dir,
466 			__get_str(name)
467 		)
468 );
469 
470 #define DEFINE_NFS_LOOKUP_EVENT_DONE(name) \
471 	DEFINE_EVENT(nfs_lookup_event_done, name, \
472 			TP_PROTO( \
473 				const struct inode *dir, \
474 				const struct dentry *dentry, \
475 				unsigned int flags, \
476 				int error \
477 			), \
478 			TP_ARGS(dir, dentry, flags, error))
479 
480 DEFINE_NFS_LOOKUP_EVENT(nfs_lookup_enter);
481 DEFINE_NFS_LOOKUP_EVENT_DONE(nfs_lookup_exit);
482 DEFINE_NFS_LOOKUP_EVENT(nfs_lookup_revalidate_enter);
483 DEFINE_NFS_LOOKUP_EVENT_DONE(nfs_lookup_revalidate_exit);
484 DEFINE_NFS_LOOKUP_EVENT(nfs_readdir_lookup);
485 DEFINE_NFS_LOOKUP_EVENT(nfs_readdir_lookup_revalidate_failed);
486 DEFINE_NFS_LOOKUP_EVENT_DONE(nfs_readdir_lookup_revalidate);
487 
488 TRACE_EVENT(nfs_atomic_open_enter,
489 		TP_PROTO(
490 			const struct inode *dir,
491 			const struct nfs_open_context *ctx,
492 			unsigned int flags
493 		),
494 
495 		TP_ARGS(dir, ctx, flags),
496 
497 		TP_STRUCT__entry(
498 			__field(unsigned long, flags)
499 			__field(unsigned long, fmode)
500 			__field(dev_t, dev)
501 			__field(u64, dir)
502 			__string(name, ctx->dentry->d_name.name)
503 		),
504 
505 		TP_fast_assign(
506 			__entry->dev = dir->i_sb->s_dev;
507 			__entry->dir = NFS_FILEID(dir);
508 			__entry->flags = flags;
509 			__entry->fmode = (__force unsigned long)ctx->mode;
510 			__assign_str(name, ctx->dentry->d_name.name);
511 		),
512 
513 		TP_printk(
514 			"flags=0x%lx (%s) fmode=%s name=%02x:%02x:%llu/%s",
515 			__entry->flags,
516 			show_fs_fcntl_open_flags(__entry->flags),
517 			show_fs_fmode_flags(__entry->fmode),
518 			MAJOR(__entry->dev), MINOR(__entry->dev),
519 			(unsigned long long)__entry->dir,
520 			__get_str(name)
521 		)
522 );
523 
524 TRACE_EVENT(nfs_atomic_open_exit,
525 		TP_PROTO(
526 			const struct inode *dir,
527 			const struct nfs_open_context *ctx,
528 			unsigned int flags,
529 			int error
530 		),
531 
532 		TP_ARGS(dir, ctx, flags, error),
533 
534 		TP_STRUCT__entry(
535 			__field(unsigned long, error)
536 			__field(unsigned long, flags)
537 			__field(unsigned long, fmode)
538 			__field(dev_t, dev)
539 			__field(u64, dir)
540 			__string(name, ctx->dentry->d_name.name)
541 		),
542 
543 		TP_fast_assign(
544 			__entry->error = -error;
545 			__entry->dev = dir->i_sb->s_dev;
546 			__entry->dir = NFS_FILEID(dir);
547 			__entry->flags = flags;
548 			__entry->fmode = (__force unsigned long)ctx->mode;
549 			__assign_str(name, ctx->dentry->d_name.name);
550 		),
551 
552 		TP_printk(
553 			"error=%ld (%s) flags=0x%lx (%s) fmode=%s "
554 			"name=%02x:%02x:%llu/%s",
555 			-__entry->error, show_nfs_status(__entry->error),
556 			__entry->flags,
557 			show_fs_fcntl_open_flags(__entry->flags),
558 			show_fs_fmode_flags(__entry->fmode),
559 			MAJOR(__entry->dev), MINOR(__entry->dev),
560 			(unsigned long long)__entry->dir,
561 			__get_str(name)
562 		)
563 );
564 
565 TRACE_EVENT(nfs_create_enter,
566 		TP_PROTO(
567 			const struct inode *dir,
568 			const struct dentry *dentry,
569 			unsigned int flags
570 		),
571 
572 		TP_ARGS(dir, dentry, flags),
573 
574 		TP_STRUCT__entry(
575 			__field(unsigned long, flags)
576 			__field(dev_t, dev)
577 			__field(u64, dir)
578 			__string(name, dentry->d_name.name)
579 		),
580 
581 		TP_fast_assign(
582 			__entry->dev = dir->i_sb->s_dev;
583 			__entry->dir = NFS_FILEID(dir);
584 			__entry->flags = flags;
585 			__assign_str(name, dentry->d_name.name);
586 		),
587 
588 		TP_printk(
589 			"flags=0x%lx (%s) name=%02x:%02x:%llu/%s",
590 			__entry->flags,
591 			show_fs_fcntl_open_flags(__entry->flags),
592 			MAJOR(__entry->dev), MINOR(__entry->dev),
593 			(unsigned long long)__entry->dir,
594 			__get_str(name)
595 		)
596 );
597 
598 TRACE_EVENT(nfs_create_exit,
599 		TP_PROTO(
600 			const struct inode *dir,
601 			const struct dentry *dentry,
602 			unsigned int flags,
603 			int error
604 		),
605 
606 		TP_ARGS(dir, dentry, flags, error),
607 
608 		TP_STRUCT__entry(
609 			__field(unsigned long, error)
610 			__field(unsigned long, flags)
611 			__field(dev_t, dev)
612 			__field(u64, dir)
613 			__string(name, dentry->d_name.name)
614 		),
615 
616 		TP_fast_assign(
617 			__entry->error = -error;
618 			__entry->dev = dir->i_sb->s_dev;
619 			__entry->dir = NFS_FILEID(dir);
620 			__entry->flags = flags;
621 			__assign_str(name, dentry->d_name.name);
622 		),
623 
624 		TP_printk(
625 			"error=%ld (%s) flags=0x%lx (%s) name=%02x:%02x:%llu/%s",
626 			-__entry->error, show_nfs_status(__entry->error),
627 			__entry->flags,
628 			show_fs_fcntl_open_flags(__entry->flags),
629 			MAJOR(__entry->dev), MINOR(__entry->dev),
630 			(unsigned long long)__entry->dir,
631 			__get_str(name)
632 		)
633 );
634 
635 DECLARE_EVENT_CLASS(nfs_directory_event,
636 		TP_PROTO(
637 			const struct inode *dir,
638 			const struct dentry *dentry
639 		),
640 
641 		TP_ARGS(dir, dentry),
642 
643 		TP_STRUCT__entry(
644 			__field(dev_t, dev)
645 			__field(u64, dir)
646 			__string(name, dentry->d_name.name)
647 		),
648 
649 		TP_fast_assign(
650 			__entry->dev = dir->i_sb->s_dev;
651 			__entry->dir = NFS_FILEID(dir);
652 			__assign_str(name, dentry->d_name.name);
653 		),
654 
655 		TP_printk(
656 			"name=%02x:%02x:%llu/%s",
657 			MAJOR(__entry->dev), MINOR(__entry->dev),
658 			(unsigned long long)__entry->dir,
659 			__get_str(name)
660 		)
661 );
662 
663 #define DEFINE_NFS_DIRECTORY_EVENT(name) \
664 	DEFINE_EVENT(nfs_directory_event, name, \
665 			TP_PROTO( \
666 				const struct inode *dir, \
667 				const struct dentry *dentry \
668 			), \
669 			TP_ARGS(dir, dentry))
670 
671 DECLARE_EVENT_CLASS(nfs_directory_event_done,
672 		TP_PROTO(
673 			const struct inode *dir,
674 			const struct dentry *dentry,
675 			int error
676 		),
677 
678 		TP_ARGS(dir, dentry, error),
679 
680 		TP_STRUCT__entry(
681 			__field(unsigned long, error)
682 			__field(dev_t, dev)
683 			__field(u64, dir)
684 			__string(name, dentry->d_name.name)
685 		),
686 
687 		TP_fast_assign(
688 			__entry->dev = dir->i_sb->s_dev;
689 			__entry->dir = NFS_FILEID(dir);
690 			__entry->error = error < 0 ? -error : 0;
691 			__assign_str(name, dentry->d_name.name);
692 		),
693 
694 		TP_printk(
695 			"error=%ld (%s) name=%02x:%02x:%llu/%s",
696 			-__entry->error, show_nfs_status(__entry->error),
697 			MAJOR(__entry->dev), MINOR(__entry->dev),
698 			(unsigned long long)__entry->dir,
699 			__get_str(name)
700 		)
701 );
702 
703 #define DEFINE_NFS_DIRECTORY_EVENT_DONE(name) \
704 	DEFINE_EVENT(nfs_directory_event_done, name, \
705 			TP_PROTO( \
706 				const struct inode *dir, \
707 				const struct dentry *dentry, \
708 				int error \
709 			), \
710 			TP_ARGS(dir, dentry, error))
711 
712 DEFINE_NFS_DIRECTORY_EVENT(nfs_mknod_enter);
713 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_mknod_exit);
714 DEFINE_NFS_DIRECTORY_EVENT(nfs_mkdir_enter);
715 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_mkdir_exit);
716 DEFINE_NFS_DIRECTORY_EVENT(nfs_rmdir_enter);
717 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_rmdir_exit);
718 DEFINE_NFS_DIRECTORY_EVENT(nfs_remove_enter);
719 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_remove_exit);
720 DEFINE_NFS_DIRECTORY_EVENT(nfs_unlink_enter);
721 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_unlink_exit);
722 DEFINE_NFS_DIRECTORY_EVENT(nfs_symlink_enter);
723 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_symlink_exit);
724 
725 TRACE_EVENT(nfs_link_enter,
726 		TP_PROTO(
727 			const struct inode *inode,
728 			const struct inode *dir,
729 			const struct dentry *dentry
730 		),
731 
732 		TP_ARGS(inode, dir, dentry),
733 
734 		TP_STRUCT__entry(
735 			__field(dev_t, dev)
736 			__field(u64, fileid)
737 			__field(u64, dir)
738 			__string(name, dentry->d_name.name)
739 		),
740 
741 		TP_fast_assign(
742 			__entry->dev = inode->i_sb->s_dev;
743 			__entry->fileid = NFS_FILEID(inode);
744 			__entry->dir = NFS_FILEID(dir);
745 			__assign_str(name, dentry->d_name.name);
746 		),
747 
748 		TP_printk(
749 			"fileid=%02x:%02x:%llu name=%02x:%02x:%llu/%s",
750 			MAJOR(__entry->dev), MINOR(__entry->dev),
751 			__entry->fileid,
752 			MAJOR(__entry->dev), MINOR(__entry->dev),
753 			(unsigned long long)__entry->dir,
754 			__get_str(name)
755 		)
756 );
757 
758 TRACE_EVENT(nfs_link_exit,
759 		TP_PROTO(
760 			const struct inode *inode,
761 			const struct inode *dir,
762 			const struct dentry *dentry,
763 			int error
764 		),
765 
766 		TP_ARGS(inode, dir, dentry, error),
767 
768 		TP_STRUCT__entry(
769 			__field(unsigned long, error)
770 			__field(dev_t, dev)
771 			__field(u64, fileid)
772 			__field(u64, dir)
773 			__string(name, dentry->d_name.name)
774 		),
775 
776 		TP_fast_assign(
777 			__entry->dev = inode->i_sb->s_dev;
778 			__entry->fileid = NFS_FILEID(inode);
779 			__entry->dir = NFS_FILEID(dir);
780 			__entry->error = error < 0 ? -error : 0;
781 			__assign_str(name, dentry->d_name.name);
782 		),
783 
784 		TP_printk(
785 			"error=%ld (%s) fileid=%02x:%02x:%llu name=%02x:%02x:%llu/%s",
786 			-__entry->error, show_nfs_status(__entry->error),
787 			MAJOR(__entry->dev), MINOR(__entry->dev),
788 			__entry->fileid,
789 			MAJOR(__entry->dev), MINOR(__entry->dev),
790 			(unsigned long long)__entry->dir,
791 			__get_str(name)
792 		)
793 );
794 
795 DECLARE_EVENT_CLASS(nfs_rename_event,
796 		TP_PROTO(
797 			const struct inode *old_dir,
798 			const struct dentry *old_dentry,
799 			const struct inode *new_dir,
800 			const struct dentry *new_dentry
801 		),
802 
803 		TP_ARGS(old_dir, old_dentry, new_dir, new_dentry),
804 
805 		TP_STRUCT__entry(
806 			__field(dev_t, dev)
807 			__field(u64, old_dir)
808 			__field(u64, new_dir)
809 			__string(old_name, old_dentry->d_name.name)
810 			__string(new_name, new_dentry->d_name.name)
811 		),
812 
813 		TP_fast_assign(
814 			__entry->dev = old_dir->i_sb->s_dev;
815 			__entry->old_dir = NFS_FILEID(old_dir);
816 			__entry->new_dir = NFS_FILEID(new_dir);
817 			__assign_str(old_name, old_dentry->d_name.name);
818 			__assign_str(new_name, new_dentry->d_name.name);
819 		),
820 
821 		TP_printk(
822 			"old_name=%02x:%02x:%llu/%s new_name=%02x:%02x:%llu/%s",
823 			MAJOR(__entry->dev), MINOR(__entry->dev),
824 			(unsigned long long)__entry->old_dir,
825 			__get_str(old_name),
826 			MAJOR(__entry->dev), MINOR(__entry->dev),
827 			(unsigned long long)__entry->new_dir,
828 			__get_str(new_name)
829 		)
830 );
831 #define DEFINE_NFS_RENAME_EVENT(name) \
832 	DEFINE_EVENT(nfs_rename_event, name, \
833 			TP_PROTO( \
834 				const struct inode *old_dir, \
835 				const struct dentry *old_dentry, \
836 				const struct inode *new_dir, \
837 				const struct dentry *new_dentry \
838 			), \
839 			TP_ARGS(old_dir, old_dentry, new_dir, new_dentry))
840 
841 DECLARE_EVENT_CLASS(nfs_rename_event_done,
842 		TP_PROTO(
843 			const struct inode *old_dir,
844 			const struct dentry *old_dentry,
845 			const struct inode *new_dir,
846 			const struct dentry *new_dentry,
847 			int error
848 		),
849 
850 		TP_ARGS(old_dir, old_dentry, new_dir, new_dentry, error),
851 
852 		TP_STRUCT__entry(
853 			__field(dev_t, dev)
854 			__field(unsigned long, error)
855 			__field(u64, old_dir)
856 			__string(old_name, old_dentry->d_name.name)
857 			__field(u64, new_dir)
858 			__string(new_name, new_dentry->d_name.name)
859 		),
860 
861 		TP_fast_assign(
862 			__entry->dev = old_dir->i_sb->s_dev;
863 			__entry->error = -error;
864 			__entry->old_dir = NFS_FILEID(old_dir);
865 			__entry->new_dir = NFS_FILEID(new_dir);
866 			__assign_str(old_name, old_dentry->d_name.name);
867 			__assign_str(new_name, new_dentry->d_name.name);
868 		),
869 
870 		TP_printk(
871 			"error=%ld (%s) old_name=%02x:%02x:%llu/%s "
872 			"new_name=%02x:%02x:%llu/%s",
873 			-__entry->error, show_nfs_status(__entry->error),
874 			MAJOR(__entry->dev), MINOR(__entry->dev),
875 			(unsigned long long)__entry->old_dir,
876 			__get_str(old_name),
877 			MAJOR(__entry->dev), MINOR(__entry->dev),
878 			(unsigned long long)__entry->new_dir,
879 			__get_str(new_name)
880 		)
881 );
882 #define DEFINE_NFS_RENAME_EVENT_DONE(name) \
883 	DEFINE_EVENT(nfs_rename_event_done, name, \
884 			TP_PROTO( \
885 				const struct inode *old_dir, \
886 				const struct dentry *old_dentry, \
887 				const struct inode *new_dir, \
888 				const struct dentry *new_dentry, \
889 				int error \
890 			), \
891 			TP_ARGS(old_dir, old_dentry, new_dir, \
892 				new_dentry, error))
893 
894 DEFINE_NFS_RENAME_EVENT(nfs_rename_enter);
895 DEFINE_NFS_RENAME_EVENT_DONE(nfs_rename_exit);
896 
897 DEFINE_NFS_RENAME_EVENT_DONE(nfs_sillyrename_rename);
898 
899 TRACE_EVENT(nfs_sillyrename_unlink,
900 		TP_PROTO(
901 			const struct nfs_unlinkdata *data,
902 			int error
903 		),
904 
905 		TP_ARGS(data, error),
906 
907 		TP_STRUCT__entry(
908 			__field(dev_t, dev)
909 			__field(unsigned long, error)
910 			__field(u64, dir)
911 			__dynamic_array(char, name, data->args.name.len + 1)
912 		),
913 
914 		TP_fast_assign(
915 			struct inode *dir = d_inode(data->dentry->d_parent);
916 			size_t len = data->args.name.len;
917 			__entry->dev = dir->i_sb->s_dev;
918 			__entry->dir = NFS_FILEID(dir);
919 			__entry->error = -error;
920 			memcpy(__get_str(name),
921 				data->args.name.name, len);
922 			__get_str(name)[len] = 0;
923 		),
924 
925 		TP_printk(
926 			"error=%ld (%s) name=%02x:%02x:%llu/%s",
927 			-__entry->error, show_nfs_status(__entry->error),
928 			MAJOR(__entry->dev), MINOR(__entry->dev),
929 			(unsigned long long)__entry->dir,
930 			__get_str(name)
931 		)
932 );
933 
934 DECLARE_EVENT_CLASS(nfs_folio_event,
935 		TP_PROTO(
936 			const struct inode *inode,
937 			struct folio *folio
938 		),
939 
940 		TP_ARGS(inode, folio),
941 
942 		TP_STRUCT__entry(
943 			__field(dev_t, dev)
944 			__field(u32, fhandle)
945 			__field(u64, fileid)
946 			__field(u64, version)
947 			__field(loff_t, offset)
948 			__field(u32, count)
949 		),
950 
951 		TP_fast_assign(
952 			const struct nfs_inode *nfsi = NFS_I(inode);
953 
954 			__entry->dev = inode->i_sb->s_dev;
955 			__entry->fileid = nfsi->fileid;
956 			__entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
957 			__entry->version = inode_peek_iversion_raw(inode);
958 			__entry->offset = folio_file_pos(folio);
959 			__entry->count = nfs_folio_length(folio);
960 		),
961 
962 		TP_printk(
963 			"fileid=%02x:%02x:%llu fhandle=0x%08x version=%llu "
964 			"offset=%lld count=%u",
965 			MAJOR(__entry->dev), MINOR(__entry->dev),
966 			(unsigned long long)__entry->fileid,
967 			__entry->fhandle, __entry->version,
968 			__entry->offset, __entry->count
969 		)
970 );
971 
972 #define DEFINE_NFS_FOLIO_EVENT(name) \
973 	DEFINE_EVENT(nfs_folio_event, name, \
974 			TP_PROTO( \
975 				const struct inode *inode, \
976 				struct folio *folio \
977 			), \
978 			TP_ARGS(inode, folio))
979 
980 DECLARE_EVENT_CLASS(nfs_folio_event_done,
981 		TP_PROTO(
982 			const struct inode *inode,
983 			struct folio *folio,
984 			int ret
985 		),
986 
987 		TP_ARGS(inode, folio, ret),
988 
989 		TP_STRUCT__entry(
990 			__field(dev_t, dev)
991 			__field(u32, fhandle)
992 			__field(int, ret)
993 			__field(u64, fileid)
994 			__field(u64, version)
995 			__field(loff_t, offset)
996 			__field(u32, count)
997 		),
998 
999 		TP_fast_assign(
1000 			const struct nfs_inode *nfsi = NFS_I(inode);
1001 
1002 			__entry->dev = inode->i_sb->s_dev;
1003 			__entry->fileid = nfsi->fileid;
1004 			__entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
1005 			__entry->version = inode_peek_iversion_raw(inode);
1006 			__entry->offset = folio_file_pos(folio);
1007 			__entry->count = nfs_folio_length(folio);
1008 			__entry->ret = ret;
1009 		),
1010 
1011 		TP_printk(
1012 			"fileid=%02x:%02x:%llu fhandle=0x%08x version=%llu "
1013 			"offset=%lld count=%u ret=%d",
1014 			MAJOR(__entry->dev), MINOR(__entry->dev),
1015 			(unsigned long long)__entry->fileid,
1016 			__entry->fhandle, __entry->version,
1017 			__entry->offset, __entry->count, __entry->ret
1018 		)
1019 );
1020 
1021 #define DEFINE_NFS_FOLIO_EVENT_DONE(name) \
1022 	DEFINE_EVENT(nfs_folio_event_done, name, \
1023 			TP_PROTO( \
1024 				const struct inode *inode, \
1025 				struct folio *folio, \
1026 				int ret \
1027 			), \
1028 			TP_ARGS(inode, folio, ret))
1029 
1030 DEFINE_NFS_FOLIO_EVENT(nfs_aop_readpage);
1031 DEFINE_NFS_FOLIO_EVENT_DONE(nfs_aop_readpage_done);
1032 
1033 DEFINE_NFS_FOLIO_EVENT(nfs_writeback_folio);
1034 DEFINE_NFS_FOLIO_EVENT_DONE(nfs_writeback_folio_done);
1035 
1036 DEFINE_NFS_FOLIO_EVENT(nfs_invalidate_folio);
1037 DEFINE_NFS_FOLIO_EVENT_DONE(nfs_launder_folio_done);
1038 
1039 TRACE_EVENT(nfs_aop_readahead,
1040 		TP_PROTO(
1041 			const struct inode *inode,
1042 			loff_t pos,
1043 			unsigned int nr_pages
1044 		),
1045 
1046 		TP_ARGS(inode, pos, nr_pages),
1047 
1048 		TP_STRUCT__entry(
1049 			__field(dev_t, dev)
1050 			__field(u32, fhandle)
1051 			__field(u64, fileid)
1052 			__field(u64, version)
1053 			__field(loff_t, offset)
1054 			__field(unsigned int, nr_pages)
1055 		),
1056 
1057 		TP_fast_assign(
1058 			const struct nfs_inode *nfsi = NFS_I(inode);
1059 
1060 			__entry->dev = inode->i_sb->s_dev;
1061 			__entry->fileid = nfsi->fileid;
1062 			__entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
1063 			__entry->version = inode_peek_iversion_raw(inode);
1064 			__entry->offset = pos;
1065 			__entry->nr_pages = nr_pages;
1066 		),
1067 
1068 		TP_printk(
1069 			"fileid=%02x:%02x:%llu fhandle=0x%08x version=%llu offset=%lld nr_pages=%u",
1070 			MAJOR(__entry->dev), MINOR(__entry->dev),
1071 			(unsigned long long)__entry->fileid,
1072 			__entry->fhandle, __entry->version,
1073 			__entry->offset, __entry->nr_pages
1074 		)
1075 );
1076 
1077 TRACE_EVENT(nfs_aop_readahead_done,
1078 		TP_PROTO(
1079 			const struct inode *inode,
1080 			unsigned int nr_pages,
1081 			int ret
1082 		),
1083 
1084 		TP_ARGS(inode, nr_pages, ret),
1085 
1086 		TP_STRUCT__entry(
1087 			__field(dev_t, dev)
1088 			__field(u32, fhandle)
1089 			__field(int, ret)
1090 			__field(u64, fileid)
1091 			__field(u64, version)
1092 			__field(loff_t, offset)
1093 			__field(unsigned int, nr_pages)
1094 		),
1095 
1096 		TP_fast_assign(
1097 			const struct nfs_inode *nfsi = NFS_I(inode);
1098 
1099 			__entry->dev = inode->i_sb->s_dev;
1100 			__entry->fileid = nfsi->fileid;
1101 			__entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
1102 			__entry->version = inode_peek_iversion_raw(inode);
1103 			__entry->nr_pages = nr_pages;
1104 			__entry->ret = ret;
1105 		),
1106 
1107 		TP_printk(
1108 			"fileid=%02x:%02x:%llu fhandle=0x%08x version=%llu nr_pages=%u ret=%d",
1109 			MAJOR(__entry->dev), MINOR(__entry->dev),
1110 			(unsigned long long)__entry->fileid,
1111 			__entry->fhandle, __entry->version,
1112 			__entry->nr_pages, __entry->ret
1113 		)
1114 );
1115 
1116 TRACE_EVENT(nfs_initiate_read,
1117 		TP_PROTO(
1118 			const struct nfs_pgio_header *hdr
1119 		),
1120 
1121 		TP_ARGS(hdr),
1122 
1123 		TP_STRUCT__entry(
1124 			__field(dev_t, dev)
1125 			__field(u32, fhandle)
1126 			__field(u64, fileid)
1127 			__field(loff_t, offset)
1128 			__field(u32, count)
1129 		),
1130 
1131 		TP_fast_assign(
1132 			const struct inode *inode = hdr->inode;
1133 			const struct nfs_inode *nfsi = NFS_I(inode);
1134 			const struct nfs_fh *fh = hdr->args.fh ?
1135 						  hdr->args.fh : &nfsi->fh;
1136 
1137 			__entry->offset = hdr->args.offset;
1138 			__entry->count = hdr->args.count;
1139 			__entry->dev = inode->i_sb->s_dev;
1140 			__entry->fileid = nfsi->fileid;
1141 			__entry->fhandle = nfs_fhandle_hash(fh);
1142 		),
1143 
1144 		TP_printk(
1145 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1146 			"offset=%lld count=%u",
1147 			MAJOR(__entry->dev), MINOR(__entry->dev),
1148 			(unsigned long long)__entry->fileid,
1149 			__entry->fhandle,
1150 			(long long)__entry->offset, __entry->count
1151 		)
1152 );
1153 
1154 TRACE_EVENT(nfs_readpage_done,
1155 		TP_PROTO(
1156 			const struct rpc_task *task,
1157 			const struct nfs_pgio_header *hdr
1158 		),
1159 
1160 		TP_ARGS(task, hdr),
1161 
1162 		TP_STRUCT__entry(
1163 			__field(dev_t, dev)
1164 			__field(u32, fhandle)
1165 			__field(u64, fileid)
1166 			__field(loff_t, offset)
1167 			__field(u32, arg_count)
1168 			__field(u32, res_count)
1169 			__field(bool, eof)
1170 			__field(int, error)
1171 		),
1172 
1173 		TP_fast_assign(
1174 			const struct inode *inode = hdr->inode;
1175 			const struct nfs_inode *nfsi = NFS_I(inode);
1176 			const struct nfs_fh *fh = hdr->args.fh ?
1177 						  hdr->args.fh : &nfsi->fh;
1178 
1179 			__entry->error = task->tk_status;
1180 			__entry->offset = hdr->args.offset;
1181 			__entry->arg_count = hdr->args.count;
1182 			__entry->res_count = hdr->res.count;
1183 			__entry->eof = hdr->res.eof;
1184 			__entry->dev = inode->i_sb->s_dev;
1185 			__entry->fileid = nfsi->fileid;
1186 			__entry->fhandle = nfs_fhandle_hash(fh);
1187 		),
1188 
1189 		TP_printk(
1190 			"error=%d fileid=%02x:%02x:%llu fhandle=0x%08x "
1191 			"offset=%lld count=%u res=%u%s", __entry->error,
1192 			MAJOR(__entry->dev), MINOR(__entry->dev),
1193 			(unsigned long long)__entry->fileid,
1194 			__entry->fhandle,
1195 			(long long)__entry->offset, __entry->arg_count,
1196 			__entry->res_count, __entry->eof ? " eof" : ""
1197 		)
1198 );
1199 
1200 TRACE_EVENT(nfs_readpage_short,
1201 		TP_PROTO(
1202 			const struct rpc_task *task,
1203 			const struct nfs_pgio_header *hdr
1204 		),
1205 
1206 		TP_ARGS(task, hdr),
1207 
1208 		TP_STRUCT__entry(
1209 			__field(dev_t, dev)
1210 			__field(u32, fhandle)
1211 			__field(u64, fileid)
1212 			__field(loff_t, offset)
1213 			__field(u32, arg_count)
1214 			__field(u32, res_count)
1215 			__field(bool, eof)
1216 			__field(int, error)
1217 		),
1218 
1219 		TP_fast_assign(
1220 			const struct inode *inode = hdr->inode;
1221 			const struct nfs_inode *nfsi = NFS_I(inode);
1222 			const struct nfs_fh *fh = hdr->args.fh ?
1223 						  hdr->args.fh : &nfsi->fh;
1224 
1225 			__entry->error = task->tk_status;
1226 			__entry->offset = hdr->args.offset;
1227 			__entry->arg_count = hdr->args.count;
1228 			__entry->res_count = hdr->res.count;
1229 			__entry->eof = hdr->res.eof;
1230 			__entry->dev = inode->i_sb->s_dev;
1231 			__entry->fileid = nfsi->fileid;
1232 			__entry->fhandle = nfs_fhandle_hash(fh);
1233 		),
1234 
1235 		TP_printk(
1236 			"error=%d fileid=%02x:%02x:%llu fhandle=0x%08x "
1237 			"offset=%lld count=%u res=%u%s", __entry->error,
1238 			MAJOR(__entry->dev), MINOR(__entry->dev),
1239 			(unsigned long long)__entry->fileid,
1240 			__entry->fhandle,
1241 			(long long)__entry->offset, __entry->arg_count,
1242 			__entry->res_count, __entry->eof ? " eof" : ""
1243 		)
1244 );
1245 
1246 DECLARE_EVENT_CLASS(nfs_fscache_page_event,
1247 		TP_PROTO(
1248 			const struct inode *inode,
1249 			struct page *page
1250 		),
1251 
1252 		TP_ARGS(inode, page),
1253 
1254 		TP_STRUCT__entry(
1255 			__field(dev_t, dev)
1256 			__field(u32, fhandle)
1257 			__field(u64, fileid)
1258 			__field(loff_t, offset)
1259 		),
1260 
1261 		TP_fast_assign(
1262 			const struct nfs_inode *nfsi = NFS_I(inode);
1263 			const struct nfs_fh *fh = &nfsi->fh;
1264 
1265 			__entry->offset = page_index(page) << PAGE_SHIFT;
1266 			__entry->dev = inode->i_sb->s_dev;
1267 			__entry->fileid = nfsi->fileid;
1268 			__entry->fhandle = nfs_fhandle_hash(fh);
1269 		),
1270 
1271 		TP_printk(
1272 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1273 			"offset=%lld",
1274 			MAJOR(__entry->dev), MINOR(__entry->dev),
1275 			(unsigned long long)__entry->fileid,
1276 			__entry->fhandle,
1277 			(long long)__entry->offset
1278 		)
1279 );
1280 DECLARE_EVENT_CLASS(nfs_fscache_page_event_done,
1281 		TP_PROTO(
1282 			const struct inode *inode,
1283 			struct page *page,
1284 			int error
1285 		),
1286 
1287 		TP_ARGS(inode, page, error),
1288 
1289 		TP_STRUCT__entry(
1290 			__field(int, error)
1291 			__field(dev_t, dev)
1292 			__field(u32, fhandle)
1293 			__field(u64, fileid)
1294 			__field(loff_t, offset)
1295 		),
1296 
1297 		TP_fast_assign(
1298 			const struct nfs_inode *nfsi = NFS_I(inode);
1299 			const struct nfs_fh *fh = &nfsi->fh;
1300 
1301 			__entry->offset = page_index(page) << PAGE_SHIFT;
1302 			__entry->dev = inode->i_sb->s_dev;
1303 			__entry->fileid = nfsi->fileid;
1304 			__entry->fhandle = nfs_fhandle_hash(fh);
1305 			__entry->error = error;
1306 		),
1307 
1308 		TP_printk(
1309 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1310 			"offset=%lld error=%d",
1311 			MAJOR(__entry->dev), MINOR(__entry->dev),
1312 			(unsigned long long)__entry->fileid,
1313 			__entry->fhandle,
1314 			(long long)__entry->offset, __entry->error
1315 		)
1316 );
1317 #define DEFINE_NFS_FSCACHE_PAGE_EVENT(name) \
1318 	DEFINE_EVENT(nfs_fscache_page_event, name, \
1319 			TP_PROTO( \
1320 				const struct inode *inode, \
1321 				struct page *page \
1322 			), \
1323 			TP_ARGS(inode, page))
1324 #define DEFINE_NFS_FSCACHE_PAGE_EVENT_DONE(name) \
1325 	DEFINE_EVENT(nfs_fscache_page_event_done, name, \
1326 			TP_PROTO( \
1327 				const struct inode *inode, \
1328 				struct page *page, \
1329 				int error \
1330 			), \
1331 			TP_ARGS(inode, page, error))
1332 DEFINE_NFS_FSCACHE_PAGE_EVENT(nfs_fscache_read_page);
1333 DEFINE_NFS_FSCACHE_PAGE_EVENT_DONE(nfs_fscache_read_page_exit);
1334 DEFINE_NFS_FSCACHE_PAGE_EVENT(nfs_fscache_write_page);
1335 DEFINE_NFS_FSCACHE_PAGE_EVENT_DONE(nfs_fscache_write_page_exit);
1336 
1337 TRACE_EVENT(nfs_pgio_error,
1338 	TP_PROTO(
1339 		const struct nfs_pgio_header *hdr,
1340 		int error,
1341 		loff_t pos
1342 	),
1343 
1344 	TP_ARGS(hdr, error, pos),
1345 
1346 	TP_STRUCT__entry(
1347 		__field(dev_t, dev)
1348 		__field(u32, fhandle)
1349 		__field(u64, fileid)
1350 		__field(loff_t, offset)
1351 		__field(u32, arg_count)
1352 		__field(u32, res_count)
1353 		__field(loff_t, pos)
1354 		__field(int, error)
1355 	),
1356 
1357 	TP_fast_assign(
1358 		const struct inode *inode = hdr->inode;
1359 		const struct nfs_inode *nfsi = NFS_I(inode);
1360 		const struct nfs_fh *fh = hdr->args.fh ?
1361 					  hdr->args.fh : &nfsi->fh;
1362 
1363 		__entry->error = error;
1364 		__entry->offset = hdr->args.offset;
1365 		__entry->arg_count = hdr->args.count;
1366 		__entry->res_count = hdr->res.count;
1367 		__entry->dev = inode->i_sb->s_dev;
1368 		__entry->fileid = nfsi->fileid;
1369 		__entry->fhandle = nfs_fhandle_hash(fh);
1370 	),
1371 
1372 	TP_printk("error=%d fileid=%02x:%02x:%llu fhandle=0x%08x "
1373 		  "offset=%lld count=%u res=%u pos=%llu", __entry->error,
1374 		MAJOR(__entry->dev), MINOR(__entry->dev),
1375 		(unsigned long long)__entry->fileid, __entry->fhandle,
1376 		(long long)__entry->offset, __entry->arg_count, __entry->res_count,
1377 		__entry->pos
1378 	)
1379 );
1380 
1381 TRACE_EVENT(nfs_initiate_write,
1382 		TP_PROTO(
1383 			const struct nfs_pgio_header *hdr
1384 		),
1385 
1386 		TP_ARGS(hdr),
1387 
1388 		TP_STRUCT__entry(
1389 			__field(dev_t, dev)
1390 			__field(u32, fhandle)
1391 			__field(u64, fileid)
1392 			__field(loff_t, offset)
1393 			__field(u32, count)
1394 			__field(unsigned long, stable)
1395 		),
1396 
1397 		TP_fast_assign(
1398 			const struct inode *inode = hdr->inode;
1399 			const struct nfs_inode *nfsi = NFS_I(inode);
1400 			const struct nfs_fh *fh = hdr->args.fh ?
1401 						  hdr->args.fh : &nfsi->fh;
1402 
1403 			__entry->offset = hdr->args.offset;
1404 			__entry->count = hdr->args.count;
1405 			__entry->stable = hdr->args.stable;
1406 			__entry->dev = inode->i_sb->s_dev;
1407 			__entry->fileid = nfsi->fileid;
1408 			__entry->fhandle = nfs_fhandle_hash(fh);
1409 		),
1410 
1411 		TP_printk(
1412 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1413 			"offset=%lld count=%u stable=%s",
1414 			MAJOR(__entry->dev), MINOR(__entry->dev),
1415 			(unsigned long long)__entry->fileid,
1416 			__entry->fhandle,
1417 			(long long)__entry->offset, __entry->count,
1418 			show_nfs_stable_how(__entry->stable)
1419 		)
1420 );
1421 
1422 TRACE_EVENT(nfs_writeback_done,
1423 		TP_PROTO(
1424 			const struct rpc_task *task,
1425 			const struct nfs_pgio_header *hdr
1426 		),
1427 
1428 		TP_ARGS(task, hdr),
1429 
1430 		TP_STRUCT__entry(
1431 			__field(dev_t, dev)
1432 			__field(u32, fhandle)
1433 			__field(u64, fileid)
1434 			__field(loff_t, offset)
1435 			__field(u32, arg_count)
1436 			__field(u32, res_count)
1437 			__field(int, error)
1438 			__field(unsigned long, stable)
1439 			__array(char, verifier, NFS4_VERIFIER_SIZE)
1440 		),
1441 
1442 		TP_fast_assign(
1443 			const struct inode *inode = hdr->inode;
1444 			const struct nfs_inode *nfsi = NFS_I(inode);
1445 			const struct nfs_fh *fh = hdr->args.fh ?
1446 						  hdr->args.fh : &nfsi->fh;
1447 			const struct nfs_writeverf *verf = hdr->res.verf;
1448 
1449 			__entry->error = task->tk_status;
1450 			__entry->offset = hdr->args.offset;
1451 			__entry->arg_count = hdr->args.count;
1452 			__entry->res_count = hdr->res.count;
1453 			__entry->stable = verf->committed;
1454 			memcpy(__entry->verifier,
1455 				&verf->verifier,
1456 				NFS4_VERIFIER_SIZE);
1457 			__entry->dev = inode->i_sb->s_dev;
1458 			__entry->fileid = nfsi->fileid;
1459 			__entry->fhandle = nfs_fhandle_hash(fh);
1460 		),
1461 
1462 		TP_printk(
1463 			"error=%d fileid=%02x:%02x:%llu fhandle=0x%08x "
1464 			"offset=%lld count=%u res=%u stable=%s "
1465 			"verifier=%s", __entry->error,
1466 			MAJOR(__entry->dev), MINOR(__entry->dev),
1467 			(unsigned long long)__entry->fileid,
1468 			__entry->fhandle,
1469 			(long long)__entry->offset, __entry->arg_count,
1470 			__entry->res_count,
1471 			show_nfs_stable_how(__entry->stable),
1472 			show_nfs4_verifier(__entry->verifier)
1473 		)
1474 );
1475 
1476 DECLARE_EVENT_CLASS(nfs_page_error_class,
1477 		TP_PROTO(
1478 			const struct inode *inode,
1479 			const struct nfs_page *req,
1480 			int error
1481 		),
1482 
1483 		TP_ARGS(inode, req, error),
1484 
1485 		TP_STRUCT__entry(
1486 			__field(dev_t, dev)
1487 			__field(u32, fhandle)
1488 			__field(u64, fileid)
1489 			__field(loff_t, offset)
1490 			__field(unsigned int, count)
1491 			__field(int, error)
1492 		),
1493 
1494 		TP_fast_assign(
1495 			const struct nfs_inode *nfsi = NFS_I(inode);
1496 			__entry->dev = inode->i_sb->s_dev;
1497 			__entry->fileid = nfsi->fileid;
1498 			__entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
1499 			__entry->offset = req_offset(req);
1500 			__entry->count = req->wb_bytes;
1501 			__entry->error = error;
1502 		),
1503 
1504 		TP_printk(
1505 			"error=%d fileid=%02x:%02x:%llu fhandle=0x%08x "
1506 			"offset=%lld count=%u", __entry->error,
1507 			MAJOR(__entry->dev), MINOR(__entry->dev),
1508 			(unsigned long long)__entry->fileid,
1509 			__entry->fhandle, __entry->offset,
1510 			__entry->count
1511 		)
1512 );
1513 
1514 #define DEFINE_NFS_PAGEERR_EVENT(name) \
1515 	DEFINE_EVENT(nfs_page_error_class, name, \
1516 			TP_PROTO( \
1517 				const struct inode *inode, \
1518 				const struct nfs_page *req, \
1519 				int error \
1520 			), \
1521 			TP_ARGS(inode, req, error))
1522 
1523 DEFINE_NFS_PAGEERR_EVENT(nfs_write_error);
1524 DEFINE_NFS_PAGEERR_EVENT(nfs_comp_error);
1525 DEFINE_NFS_PAGEERR_EVENT(nfs_commit_error);
1526 
1527 TRACE_EVENT(nfs_initiate_commit,
1528 		TP_PROTO(
1529 			const struct nfs_commit_data *data
1530 		),
1531 
1532 		TP_ARGS(data),
1533 
1534 		TP_STRUCT__entry(
1535 			__field(dev_t, dev)
1536 			__field(u32, fhandle)
1537 			__field(u64, fileid)
1538 			__field(loff_t, offset)
1539 			__field(u32, count)
1540 		),
1541 
1542 		TP_fast_assign(
1543 			const struct inode *inode = data->inode;
1544 			const struct nfs_inode *nfsi = NFS_I(inode);
1545 			const struct nfs_fh *fh = data->args.fh ?
1546 						  data->args.fh : &nfsi->fh;
1547 
1548 			__entry->offset = data->args.offset;
1549 			__entry->count = data->args.count;
1550 			__entry->dev = inode->i_sb->s_dev;
1551 			__entry->fileid = nfsi->fileid;
1552 			__entry->fhandle = nfs_fhandle_hash(fh);
1553 		),
1554 
1555 		TP_printk(
1556 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1557 			"offset=%lld count=%u",
1558 			MAJOR(__entry->dev), MINOR(__entry->dev),
1559 			(unsigned long long)__entry->fileid,
1560 			__entry->fhandle,
1561 			(long long)__entry->offset, __entry->count
1562 		)
1563 );
1564 
1565 TRACE_EVENT(nfs_commit_done,
1566 		TP_PROTO(
1567 			const struct rpc_task *task,
1568 			const struct nfs_commit_data *data
1569 		),
1570 
1571 		TP_ARGS(task, data),
1572 
1573 		TP_STRUCT__entry(
1574 			__field(dev_t, dev)
1575 			__field(u32, fhandle)
1576 			__field(u64, fileid)
1577 			__field(loff_t, offset)
1578 			__field(int, error)
1579 			__field(unsigned long, stable)
1580 			__array(char, verifier, NFS4_VERIFIER_SIZE)
1581 		),
1582 
1583 		TP_fast_assign(
1584 			const struct inode *inode = data->inode;
1585 			const struct nfs_inode *nfsi = NFS_I(inode);
1586 			const struct nfs_fh *fh = data->args.fh ?
1587 						  data->args.fh : &nfsi->fh;
1588 			const struct nfs_writeverf *verf = data->res.verf;
1589 
1590 			__entry->error = task->tk_status;
1591 			__entry->offset = data->args.offset;
1592 			__entry->stable = verf->committed;
1593 			memcpy(__entry->verifier,
1594 				&verf->verifier,
1595 				NFS4_VERIFIER_SIZE);
1596 			__entry->dev = inode->i_sb->s_dev;
1597 			__entry->fileid = nfsi->fileid;
1598 			__entry->fhandle = nfs_fhandle_hash(fh);
1599 		),
1600 
1601 		TP_printk(
1602 			"error=%d fileid=%02x:%02x:%llu fhandle=0x%08x "
1603 			"offset=%lld stable=%s verifier=%s", __entry->error,
1604 			MAJOR(__entry->dev), MINOR(__entry->dev),
1605 			(unsigned long long)__entry->fileid,
1606 			__entry->fhandle,
1607 			(long long)__entry->offset,
1608 			show_nfs_stable_how(__entry->stable),
1609 			show_nfs4_verifier(__entry->verifier)
1610 		)
1611 );
1612 
1613 #define nfs_show_direct_req_flags(v) \
1614 	__print_flags(v, "|", \
1615 			{ NFS_ODIRECT_DO_COMMIT, "DO_COMMIT" }, \
1616 			{ NFS_ODIRECT_RESCHED_WRITES, "RESCHED_WRITES" }, \
1617 			{ NFS_ODIRECT_SHOULD_DIRTY, "SHOULD DIRTY" }, \
1618 			{ NFS_ODIRECT_DONE, "DONE" } )
1619 
1620 DECLARE_EVENT_CLASS(nfs_direct_req_class,
1621 		TP_PROTO(
1622 			const struct nfs_direct_req *dreq
1623 		),
1624 
1625 		TP_ARGS(dreq),
1626 
1627 		TP_STRUCT__entry(
1628 			__field(dev_t, dev)
1629 			__field(u64, fileid)
1630 			__field(u32, fhandle)
1631 			__field(loff_t, offset)
1632 			__field(ssize_t, count)
1633 			__field(ssize_t, bytes_left)
1634 			__field(ssize_t, error)
1635 			__field(int, flags)
1636 		),
1637 
1638 		TP_fast_assign(
1639 			const struct inode *inode = dreq->inode;
1640 			const struct nfs_inode *nfsi = NFS_I(inode);
1641 			const struct nfs_fh *fh = &nfsi->fh;
1642 
1643 			__entry->dev = inode->i_sb->s_dev;
1644 			__entry->fileid = nfsi->fileid;
1645 			__entry->fhandle = nfs_fhandle_hash(fh);
1646 			__entry->offset = dreq->io_start;
1647 			__entry->count = dreq->count;
1648 			__entry->bytes_left = dreq->bytes_left;
1649 			__entry->error = dreq->error;
1650 			__entry->flags = dreq->flags;
1651 		),
1652 
1653 		TP_printk(
1654 			"error=%zd fileid=%02x:%02x:%llu fhandle=0x%08x "
1655 			"offset=%lld count=%zd bytes_left=%zd flags=%s",
1656 			__entry->error, MAJOR(__entry->dev),
1657 			MINOR(__entry->dev),
1658 			(unsigned long long)__entry->fileid,
1659 			__entry->fhandle, __entry->offset,
1660 			__entry->count, __entry->bytes_left,
1661 			nfs_show_direct_req_flags(__entry->flags)
1662 		)
1663 );
1664 
1665 #define DEFINE_NFS_DIRECT_REQ_EVENT(name) \
1666 	DEFINE_EVENT(nfs_direct_req_class, name, \
1667 			TP_PROTO( \
1668 				const struct nfs_direct_req *dreq \
1669 			), \
1670 			TP_ARGS(dreq))
1671 
1672 DEFINE_NFS_DIRECT_REQ_EVENT(nfs_direct_commit_complete);
1673 DEFINE_NFS_DIRECT_REQ_EVENT(nfs_direct_resched_write);
1674 DEFINE_NFS_DIRECT_REQ_EVENT(nfs_direct_write_complete);
1675 DEFINE_NFS_DIRECT_REQ_EVENT(nfs_direct_write_completion);
1676 DEFINE_NFS_DIRECT_REQ_EVENT(nfs_direct_write_schedule_iovec);
1677 DEFINE_NFS_DIRECT_REQ_EVENT(nfs_direct_write_reschedule_io);
1678 
1679 TRACE_EVENT(nfs_fh_to_dentry,
1680 		TP_PROTO(
1681 			const struct super_block *sb,
1682 			const struct nfs_fh *fh,
1683 			u64 fileid,
1684 			int error
1685 		),
1686 
1687 		TP_ARGS(sb, fh, fileid, error),
1688 
1689 		TP_STRUCT__entry(
1690 			__field(int, error)
1691 			__field(dev_t, dev)
1692 			__field(u32, fhandle)
1693 			__field(u64, fileid)
1694 		),
1695 
1696 		TP_fast_assign(
1697 			__entry->error = error;
1698 			__entry->dev = sb->s_dev;
1699 			__entry->fileid = fileid;
1700 			__entry->fhandle = nfs_fhandle_hash(fh);
1701 		),
1702 
1703 		TP_printk(
1704 			"error=%d fileid=%02x:%02x:%llu fhandle=0x%08x ",
1705 			__entry->error,
1706 			MAJOR(__entry->dev), MINOR(__entry->dev),
1707 			(unsigned long long)__entry->fileid,
1708 			__entry->fhandle
1709 		)
1710 );
1711 
1712 TRACE_EVENT(nfs_mount_assign,
1713 	TP_PROTO(
1714 		const char *option,
1715 		const char *value
1716 	),
1717 
1718 	TP_ARGS(option, value),
1719 
1720 	TP_STRUCT__entry(
1721 		__string(option, option)
1722 		__string(value, value)
1723 	),
1724 
1725 	TP_fast_assign(
1726 		__assign_str(option, option);
1727 		__assign_str(value, value);
1728 	),
1729 
1730 	TP_printk("option %s=%s",
1731 		__get_str(option), __get_str(value)
1732 	)
1733 );
1734 
1735 TRACE_EVENT(nfs_mount_option,
1736 	TP_PROTO(
1737 		const struct fs_parameter *param
1738 	),
1739 
1740 	TP_ARGS(param),
1741 
1742 	TP_STRUCT__entry(
1743 		__string(option, param->key)
1744 	),
1745 
1746 	TP_fast_assign(
1747 		__assign_str(option, param->key);
1748 	),
1749 
1750 	TP_printk("option %s", __get_str(option))
1751 );
1752 
1753 TRACE_EVENT(nfs_mount_path,
1754 	TP_PROTO(
1755 		const char *path
1756 	),
1757 
1758 	TP_ARGS(path),
1759 
1760 	TP_STRUCT__entry(
1761 		__string(path, path)
1762 	),
1763 
1764 	TP_fast_assign(
1765 		__assign_str(path, path);
1766 	),
1767 
1768 	TP_printk("path='%s'", __get_str(path))
1769 );
1770 
1771 DECLARE_EVENT_CLASS(nfs_xdr_event,
1772 		TP_PROTO(
1773 			const struct xdr_stream *xdr,
1774 			int error
1775 		),
1776 
1777 		TP_ARGS(xdr, error),
1778 
1779 		TP_STRUCT__entry(
1780 			__field(unsigned int, task_id)
1781 			__field(unsigned int, client_id)
1782 			__field(u32, xid)
1783 			__field(int, version)
1784 			__field(unsigned long, error)
1785 			__string(program,
1786 				 xdr->rqst->rq_task->tk_client->cl_program->name)
1787 			__string(procedure,
1788 				 xdr->rqst->rq_task->tk_msg.rpc_proc->p_name)
1789 		),
1790 
1791 		TP_fast_assign(
1792 			const struct rpc_rqst *rqstp = xdr->rqst;
1793 			const struct rpc_task *task = rqstp->rq_task;
1794 
1795 			__entry->task_id = task->tk_pid;
1796 			__entry->client_id = task->tk_client->cl_clid;
1797 			__entry->xid = be32_to_cpu(rqstp->rq_xid);
1798 			__entry->version = task->tk_client->cl_vers;
1799 			__entry->error = error;
1800 			__assign_str(program,
1801 				     task->tk_client->cl_program->name);
1802 			__assign_str(procedure, task->tk_msg.rpc_proc->p_name);
1803 		),
1804 
1805 		TP_printk(SUNRPC_TRACE_TASK_SPECIFIER
1806 			  " xid=0x%08x %sv%d %s error=%ld (%s)",
1807 			__entry->task_id, __entry->client_id, __entry->xid,
1808 			__get_str(program), __entry->version,
1809 			__get_str(procedure), -__entry->error,
1810 			show_nfs_status(__entry->error)
1811 		)
1812 );
1813 #define DEFINE_NFS_XDR_EVENT(name) \
1814 	DEFINE_EVENT(nfs_xdr_event, name, \
1815 			TP_PROTO( \
1816 				const struct xdr_stream *xdr, \
1817 				int error \
1818 			), \
1819 			TP_ARGS(xdr, error))
1820 DEFINE_NFS_XDR_EVENT(nfs_xdr_status);
1821 DEFINE_NFS_XDR_EVENT(nfs_xdr_bad_filehandle);
1822 
1823 #endif /* _TRACE_NFS_H */
1824 
1825 #undef TRACE_INCLUDE_PATH
1826 #define TRACE_INCLUDE_PATH .
1827 #define TRACE_INCLUDE_FILE nfstrace
1828 /* This part must be outside protection */
1829 #include <trace/define_trace.h>
1830