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