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