xref: /openbmc/linux/fs/nfs/nfstrace.h (revision 48ca54e3)
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/events/fs.h>
15 #include <trace/events/nfs.h>
16 #include <trace/events/sunrpc_base.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, status)
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->status = 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 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1161 			"offset=%lld count=%u res=%u status=%d%s",
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->status,
1167 			__entry->eof ? " eof" : ""
1168 		)
1169 );
1170 
1171 TRACE_EVENT(nfs_readpage_short,
1172 		TP_PROTO(
1173 			const struct rpc_task *task,
1174 			const struct nfs_pgio_header *hdr
1175 		),
1176 
1177 		TP_ARGS(task, hdr),
1178 
1179 		TP_STRUCT__entry(
1180 			__field(dev_t, dev)
1181 			__field(u32, fhandle)
1182 			__field(u64, fileid)
1183 			__field(loff_t, offset)
1184 			__field(u32, arg_count)
1185 			__field(u32, res_count)
1186 			__field(bool, eof)
1187 			__field(int, status)
1188 		),
1189 
1190 		TP_fast_assign(
1191 			const struct inode *inode = hdr->inode;
1192 			const struct nfs_inode *nfsi = NFS_I(inode);
1193 			const struct nfs_fh *fh = hdr->args.fh ?
1194 						  hdr->args.fh : &nfsi->fh;
1195 
1196 			__entry->status = task->tk_status;
1197 			__entry->offset = hdr->args.offset;
1198 			__entry->arg_count = hdr->args.count;
1199 			__entry->res_count = hdr->res.count;
1200 			__entry->eof = hdr->res.eof;
1201 			__entry->dev = inode->i_sb->s_dev;
1202 			__entry->fileid = nfsi->fileid;
1203 			__entry->fhandle = nfs_fhandle_hash(fh);
1204 		),
1205 
1206 		TP_printk(
1207 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1208 			"offset=%lld count=%u res=%u status=%d%s",
1209 			MAJOR(__entry->dev), MINOR(__entry->dev),
1210 			(unsigned long long)__entry->fileid,
1211 			__entry->fhandle,
1212 			(long long)__entry->offset, __entry->arg_count,
1213 			__entry->res_count, __entry->status,
1214 			__entry->eof ? " eof" : ""
1215 		)
1216 );
1217 
1218 DECLARE_EVENT_CLASS(nfs_fscache_page_event,
1219 		TP_PROTO(
1220 			const struct inode *inode,
1221 			struct page *page
1222 		),
1223 
1224 		TP_ARGS(inode, page),
1225 
1226 		TP_STRUCT__entry(
1227 			__field(dev_t, dev)
1228 			__field(u32, fhandle)
1229 			__field(u64, fileid)
1230 			__field(loff_t, offset)
1231 		),
1232 
1233 		TP_fast_assign(
1234 			const struct nfs_inode *nfsi = NFS_I(inode);
1235 			const struct nfs_fh *fh = &nfsi->fh;
1236 
1237 			__entry->offset = page_index(page) << PAGE_SHIFT;
1238 			__entry->dev = inode->i_sb->s_dev;
1239 			__entry->fileid = nfsi->fileid;
1240 			__entry->fhandle = nfs_fhandle_hash(fh);
1241 		),
1242 
1243 		TP_printk(
1244 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1245 			"offset=%lld",
1246 			MAJOR(__entry->dev), MINOR(__entry->dev),
1247 			(unsigned long long)__entry->fileid,
1248 			__entry->fhandle,
1249 			(long long)__entry->offset
1250 		)
1251 );
1252 DECLARE_EVENT_CLASS(nfs_fscache_page_event_done,
1253 		TP_PROTO(
1254 			const struct inode *inode,
1255 			struct page *page,
1256 			int error
1257 		),
1258 
1259 		TP_ARGS(inode, page, error),
1260 
1261 		TP_STRUCT__entry(
1262 			__field(int, error)
1263 			__field(dev_t, dev)
1264 			__field(u32, fhandle)
1265 			__field(u64, fileid)
1266 			__field(loff_t, offset)
1267 		),
1268 
1269 		TP_fast_assign(
1270 			const struct nfs_inode *nfsi = NFS_I(inode);
1271 			const struct nfs_fh *fh = &nfsi->fh;
1272 
1273 			__entry->offset = page_index(page) << PAGE_SHIFT;
1274 			__entry->dev = inode->i_sb->s_dev;
1275 			__entry->fileid = nfsi->fileid;
1276 			__entry->fhandle = nfs_fhandle_hash(fh);
1277 			__entry->error = error;
1278 		),
1279 
1280 		TP_printk(
1281 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1282 			"offset=%lld error=%d",
1283 			MAJOR(__entry->dev), MINOR(__entry->dev),
1284 			(unsigned long long)__entry->fileid,
1285 			__entry->fhandle,
1286 			(long long)__entry->offset, __entry->error
1287 		)
1288 );
1289 #define DEFINE_NFS_FSCACHE_PAGE_EVENT(name) \
1290 	DEFINE_EVENT(nfs_fscache_page_event, name, \
1291 			TP_PROTO( \
1292 				const struct inode *inode, \
1293 				struct page *page \
1294 			), \
1295 			TP_ARGS(inode, page))
1296 #define DEFINE_NFS_FSCACHE_PAGE_EVENT_DONE(name) \
1297 	DEFINE_EVENT(nfs_fscache_page_event_done, name, \
1298 			TP_PROTO( \
1299 				const struct inode *inode, \
1300 				struct page *page, \
1301 				int error \
1302 			), \
1303 			TP_ARGS(inode, page, error))
1304 DEFINE_NFS_FSCACHE_PAGE_EVENT(nfs_fscache_read_page);
1305 DEFINE_NFS_FSCACHE_PAGE_EVENT_DONE(nfs_fscache_read_page_exit);
1306 DEFINE_NFS_FSCACHE_PAGE_EVENT(nfs_fscache_write_page);
1307 DEFINE_NFS_FSCACHE_PAGE_EVENT_DONE(nfs_fscache_write_page_exit);
1308 
1309 TRACE_EVENT(nfs_pgio_error,
1310 	TP_PROTO(
1311 		const struct nfs_pgio_header *hdr,
1312 		int error,
1313 		loff_t pos
1314 	),
1315 
1316 	TP_ARGS(hdr, error, pos),
1317 
1318 	TP_STRUCT__entry(
1319 		__field(dev_t, dev)
1320 		__field(u32, fhandle)
1321 		__field(u64, fileid)
1322 		__field(loff_t, offset)
1323 		__field(u32, arg_count)
1324 		__field(u32, res_count)
1325 		__field(loff_t, pos)
1326 		__field(int, status)
1327 	),
1328 
1329 	TP_fast_assign(
1330 		const struct inode *inode = hdr->inode;
1331 		const struct nfs_inode *nfsi = NFS_I(inode);
1332 		const struct nfs_fh *fh = hdr->args.fh ?
1333 					  hdr->args.fh : &nfsi->fh;
1334 
1335 		__entry->status = error;
1336 		__entry->offset = hdr->args.offset;
1337 		__entry->arg_count = hdr->args.count;
1338 		__entry->res_count = hdr->res.count;
1339 		__entry->dev = inode->i_sb->s_dev;
1340 		__entry->fileid = nfsi->fileid;
1341 		__entry->fhandle = nfs_fhandle_hash(fh);
1342 	),
1343 
1344 	TP_printk("fileid=%02x:%02x:%llu fhandle=0x%08x "
1345 		  "offset=%lld count=%u res=%u pos=%llu status=%d",
1346 		MAJOR(__entry->dev), MINOR(__entry->dev),
1347 		(unsigned long long)__entry->fileid, __entry->fhandle,
1348 		(long long)__entry->offset, __entry->arg_count, __entry->res_count,
1349 		__entry->pos, __entry->status
1350 	)
1351 );
1352 
1353 TRACE_EVENT(nfs_initiate_write,
1354 		TP_PROTO(
1355 			const struct nfs_pgio_header *hdr
1356 		),
1357 
1358 		TP_ARGS(hdr),
1359 
1360 		TP_STRUCT__entry(
1361 			__field(dev_t, dev)
1362 			__field(u32, fhandle)
1363 			__field(u64, fileid)
1364 			__field(loff_t, offset)
1365 			__field(u32, count)
1366 			__field(unsigned long, stable)
1367 		),
1368 
1369 		TP_fast_assign(
1370 			const struct inode *inode = hdr->inode;
1371 			const struct nfs_inode *nfsi = NFS_I(inode);
1372 			const struct nfs_fh *fh = hdr->args.fh ?
1373 						  hdr->args.fh : &nfsi->fh;
1374 
1375 			__entry->offset = hdr->args.offset;
1376 			__entry->count = hdr->args.count;
1377 			__entry->stable = hdr->args.stable;
1378 			__entry->dev = inode->i_sb->s_dev;
1379 			__entry->fileid = nfsi->fileid;
1380 			__entry->fhandle = nfs_fhandle_hash(fh);
1381 		),
1382 
1383 		TP_printk(
1384 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1385 			"offset=%lld count=%u stable=%s",
1386 			MAJOR(__entry->dev), MINOR(__entry->dev),
1387 			(unsigned long long)__entry->fileid,
1388 			__entry->fhandle,
1389 			(long long)__entry->offset, __entry->count,
1390 			show_nfs_stable_how(__entry->stable)
1391 		)
1392 );
1393 
1394 TRACE_EVENT(nfs_writeback_done,
1395 		TP_PROTO(
1396 			const struct rpc_task *task,
1397 			const struct nfs_pgio_header *hdr
1398 		),
1399 
1400 		TP_ARGS(task, hdr),
1401 
1402 		TP_STRUCT__entry(
1403 			__field(dev_t, dev)
1404 			__field(u32, fhandle)
1405 			__field(u64, fileid)
1406 			__field(loff_t, offset)
1407 			__field(u32, arg_count)
1408 			__field(u32, res_count)
1409 			__field(int, status)
1410 			__field(unsigned long, stable)
1411 			__array(char, verifier, NFS4_VERIFIER_SIZE)
1412 		),
1413 
1414 		TP_fast_assign(
1415 			const struct inode *inode = hdr->inode;
1416 			const struct nfs_inode *nfsi = NFS_I(inode);
1417 			const struct nfs_fh *fh = hdr->args.fh ?
1418 						  hdr->args.fh : &nfsi->fh;
1419 			const struct nfs_writeverf *verf = hdr->res.verf;
1420 
1421 			__entry->status = task->tk_status;
1422 			__entry->offset = hdr->args.offset;
1423 			__entry->arg_count = hdr->args.count;
1424 			__entry->res_count = hdr->res.count;
1425 			__entry->stable = verf->committed;
1426 			memcpy(__entry->verifier,
1427 				&verf->verifier,
1428 				NFS4_VERIFIER_SIZE);
1429 			__entry->dev = inode->i_sb->s_dev;
1430 			__entry->fileid = nfsi->fileid;
1431 			__entry->fhandle = nfs_fhandle_hash(fh);
1432 		),
1433 
1434 		TP_printk(
1435 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1436 			"offset=%lld count=%u res=%u status=%d stable=%s "
1437 			"verifier=%s",
1438 			MAJOR(__entry->dev), MINOR(__entry->dev),
1439 			(unsigned long long)__entry->fileid,
1440 			__entry->fhandle,
1441 			(long long)__entry->offset, __entry->arg_count,
1442 			__entry->res_count, __entry->status,
1443 			show_nfs_stable_how(__entry->stable),
1444 			show_nfs4_verifier(__entry->verifier)
1445 		)
1446 );
1447 
1448 DECLARE_EVENT_CLASS(nfs_page_error_class,
1449 		TP_PROTO(
1450 			const struct nfs_page *req,
1451 			int error
1452 		),
1453 
1454 		TP_ARGS(req, error),
1455 
1456 		TP_STRUCT__entry(
1457 			__field(const void *, req)
1458 			__field(pgoff_t, index)
1459 			__field(unsigned int, offset)
1460 			__field(unsigned int, pgbase)
1461 			__field(unsigned int, bytes)
1462 			__field(int, error)
1463 		),
1464 
1465 		TP_fast_assign(
1466 			__entry->req = req;
1467 			__entry->index = req->wb_index;
1468 			__entry->offset = req->wb_offset;
1469 			__entry->pgbase = req->wb_pgbase;
1470 			__entry->bytes = req->wb_bytes;
1471 			__entry->error = error;
1472 		),
1473 
1474 		TP_printk(
1475 			"req=%p index=%lu offset=%u pgbase=%u bytes=%u error=%d",
1476 			__entry->req, __entry->index, __entry->offset,
1477 			__entry->pgbase, __entry->bytes, __entry->error
1478 		)
1479 );
1480 
1481 #define DEFINE_NFS_PAGEERR_EVENT(name) \
1482 	DEFINE_EVENT(nfs_page_error_class, name, \
1483 			TP_PROTO( \
1484 				const struct nfs_page *req, \
1485 				int error \
1486 			), \
1487 			TP_ARGS(req, error))
1488 
1489 DEFINE_NFS_PAGEERR_EVENT(nfs_write_error);
1490 DEFINE_NFS_PAGEERR_EVENT(nfs_comp_error);
1491 DEFINE_NFS_PAGEERR_EVENT(nfs_commit_error);
1492 
1493 TRACE_EVENT(nfs_initiate_commit,
1494 		TP_PROTO(
1495 			const struct nfs_commit_data *data
1496 		),
1497 
1498 		TP_ARGS(data),
1499 
1500 		TP_STRUCT__entry(
1501 			__field(dev_t, dev)
1502 			__field(u32, fhandle)
1503 			__field(u64, fileid)
1504 			__field(loff_t, offset)
1505 			__field(u32, count)
1506 		),
1507 
1508 		TP_fast_assign(
1509 			const struct inode *inode = data->inode;
1510 			const struct nfs_inode *nfsi = NFS_I(inode);
1511 			const struct nfs_fh *fh = data->args.fh ?
1512 						  data->args.fh : &nfsi->fh;
1513 
1514 			__entry->offset = data->args.offset;
1515 			__entry->count = data->args.count;
1516 			__entry->dev = inode->i_sb->s_dev;
1517 			__entry->fileid = nfsi->fileid;
1518 			__entry->fhandle = nfs_fhandle_hash(fh);
1519 		),
1520 
1521 		TP_printk(
1522 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1523 			"offset=%lld count=%u",
1524 			MAJOR(__entry->dev), MINOR(__entry->dev),
1525 			(unsigned long long)__entry->fileid,
1526 			__entry->fhandle,
1527 			(long long)__entry->offset, __entry->count
1528 		)
1529 );
1530 
1531 TRACE_EVENT(nfs_commit_done,
1532 		TP_PROTO(
1533 			const struct rpc_task *task,
1534 			const struct nfs_commit_data *data
1535 		),
1536 
1537 		TP_ARGS(task, data),
1538 
1539 		TP_STRUCT__entry(
1540 			__field(dev_t, dev)
1541 			__field(u32, fhandle)
1542 			__field(u64, fileid)
1543 			__field(loff_t, offset)
1544 			__field(int, status)
1545 			__field(unsigned long, stable)
1546 			__array(char, verifier, NFS4_VERIFIER_SIZE)
1547 		),
1548 
1549 		TP_fast_assign(
1550 			const struct inode *inode = data->inode;
1551 			const struct nfs_inode *nfsi = NFS_I(inode);
1552 			const struct nfs_fh *fh = data->args.fh ?
1553 						  data->args.fh : &nfsi->fh;
1554 			const struct nfs_writeverf *verf = data->res.verf;
1555 
1556 			__entry->status = task->tk_status;
1557 			__entry->offset = data->args.offset;
1558 			__entry->stable = verf->committed;
1559 			memcpy(__entry->verifier,
1560 				&verf->verifier,
1561 				NFS4_VERIFIER_SIZE);
1562 			__entry->dev = inode->i_sb->s_dev;
1563 			__entry->fileid = nfsi->fileid;
1564 			__entry->fhandle = nfs_fhandle_hash(fh);
1565 		),
1566 
1567 		TP_printk(
1568 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1569 			"offset=%lld status=%d stable=%s verifier=%s",
1570 			MAJOR(__entry->dev), MINOR(__entry->dev),
1571 			(unsigned long long)__entry->fileid,
1572 			__entry->fhandle,
1573 			(long long)__entry->offset, __entry->status,
1574 			show_nfs_stable_how(__entry->stable),
1575 			show_nfs4_verifier(__entry->verifier)
1576 		)
1577 );
1578 
1579 TRACE_EVENT(nfs_fh_to_dentry,
1580 		TP_PROTO(
1581 			const struct super_block *sb,
1582 			const struct nfs_fh *fh,
1583 			u64 fileid,
1584 			int error
1585 		),
1586 
1587 		TP_ARGS(sb, fh, fileid, error),
1588 
1589 		TP_STRUCT__entry(
1590 			__field(int, error)
1591 			__field(dev_t, dev)
1592 			__field(u32, fhandle)
1593 			__field(u64, fileid)
1594 		),
1595 
1596 		TP_fast_assign(
1597 			__entry->error = error;
1598 			__entry->dev = sb->s_dev;
1599 			__entry->fileid = fileid;
1600 			__entry->fhandle = nfs_fhandle_hash(fh);
1601 		),
1602 
1603 		TP_printk(
1604 			"error=%d fileid=%02x:%02x:%llu fhandle=0x%08x ",
1605 			__entry->error,
1606 			MAJOR(__entry->dev), MINOR(__entry->dev),
1607 			(unsigned long long)__entry->fileid,
1608 			__entry->fhandle
1609 		)
1610 );
1611 
1612 DECLARE_EVENT_CLASS(nfs_xdr_event,
1613 		TP_PROTO(
1614 			const struct xdr_stream *xdr,
1615 			int error
1616 		),
1617 
1618 		TP_ARGS(xdr, error),
1619 
1620 		TP_STRUCT__entry(
1621 			__field(unsigned int, task_id)
1622 			__field(unsigned int, client_id)
1623 			__field(u32, xid)
1624 			__field(int, version)
1625 			__field(unsigned long, error)
1626 			__string(program,
1627 				 xdr->rqst->rq_task->tk_client->cl_program->name)
1628 			__string(procedure,
1629 				 xdr->rqst->rq_task->tk_msg.rpc_proc->p_name)
1630 		),
1631 
1632 		TP_fast_assign(
1633 			const struct rpc_rqst *rqstp = xdr->rqst;
1634 			const struct rpc_task *task = rqstp->rq_task;
1635 
1636 			__entry->task_id = task->tk_pid;
1637 			__entry->client_id = task->tk_client->cl_clid;
1638 			__entry->xid = be32_to_cpu(rqstp->rq_xid);
1639 			__entry->version = task->tk_client->cl_vers;
1640 			__entry->error = error;
1641 			__assign_str(program,
1642 				     task->tk_client->cl_program->name);
1643 			__assign_str(procedure, task->tk_msg.rpc_proc->p_name);
1644 		),
1645 
1646 		TP_printk(SUNRPC_TRACE_TASK_SPECIFIER
1647 			  " xid=0x%08x %sv%d %s error=%ld (%s)",
1648 			__entry->task_id, __entry->client_id, __entry->xid,
1649 			__get_str(program), __entry->version,
1650 			__get_str(procedure), -__entry->error,
1651 			show_nfs_status(__entry->error)
1652 		)
1653 );
1654 #define DEFINE_NFS_XDR_EVENT(name) \
1655 	DEFINE_EVENT(nfs_xdr_event, name, \
1656 			TP_PROTO( \
1657 				const struct xdr_stream *xdr, \
1658 				int error \
1659 			), \
1660 			TP_ARGS(xdr, error))
1661 DEFINE_NFS_XDR_EVENT(nfs_xdr_status);
1662 DEFINE_NFS_XDR_EVENT(nfs_xdr_bad_filehandle);
1663 
1664 #endif /* _TRACE_NFS_H */
1665 
1666 #undef TRACE_INCLUDE_PATH
1667 #define TRACE_INCLUDE_PATH .
1668 #define TRACE_INCLUDE_FILE nfstrace
1669 /* This part must be outside protection */
1670 #include <trace/define_trace.h>
1671