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