xref: /linux/fs/nfs/nfstrace.h (revision bdd1a21b52557ea8f61d0a5dc2f77151b576eb70)
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_EMPTY);
284 TRACE_DEFINE_ENUM(LOOKUP_DOWN);
285 
286 #define show_lookup_flags(flags) \
287 	__print_flags(flags, "|", \
288 			{ LOOKUP_FOLLOW, "FOLLOW" }, \
289 			{ LOOKUP_DIRECTORY, "DIRECTORY" }, \
290 			{ LOOKUP_AUTOMOUNT, "AUTOMOUNT" }, \
291 			{ LOOKUP_PARENT, "PARENT" }, \
292 			{ LOOKUP_REVAL, "REVAL" }, \
293 			{ LOOKUP_RCU, "RCU" }, \
294 			{ LOOKUP_OPEN, "OPEN" }, \
295 			{ LOOKUP_CREATE, "CREATE" }, \
296 			{ LOOKUP_EXCL, "EXCL" }, \
297 			{ LOOKUP_RENAME_TARGET, "RENAME_TARGET" }, \
298 			{ LOOKUP_EMPTY, "EMPTY" }, \
299 			{ LOOKUP_DOWN, "DOWN" })
300 
301 DECLARE_EVENT_CLASS(nfs_lookup_event,
302 		TP_PROTO(
303 			const struct inode *dir,
304 			const struct dentry *dentry,
305 			unsigned int flags
306 		),
307 
308 		TP_ARGS(dir, dentry, flags),
309 
310 		TP_STRUCT__entry(
311 			__field(unsigned long, flags)
312 			__field(dev_t, dev)
313 			__field(u64, dir)
314 			__string(name, dentry->d_name.name)
315 		),
316 
317 		TP_fast_assign(
318 			__entry->dev = dir->i_sb->s_dev;
319 			__entry->dir = NFS_FILEID(dir);
320 			__entry->flags = flags;
321 			__assign_str(name, dentry->d_name.name);
322 		),
323 
324 		TP_printk(
325 			"flags=0x%lx (%s) name=%02x:%02x:%llu/%s",
326 			__entry->flags,
327 			show_lookup_flags(__entry->flags),
328 			MAJOR(__entry->dev), MINOR(__entry->dev),
329 			(unsigned long long)__entry->dir,
330 			__get_str(name)
331 		)
332 );
333 
334 #define DEFINE_NFS_LOOKUP_EVENT(name) \
335 	DEFINE_EVENT(nfs_lookup_event, name, \
336 			TP_PROTO( \
337 				const struct inode *dir, \
338 				const struct dentry *dentry, \
339 				unsigned int flags \
340 			), \
341 			TP_ARGS(dir, dentry, flags))
342 
343 DECLARE_EVENT_CLASS(nfs_lookup_event_done,
344 		TP_PROTO(
345 			const struct inode *dir,
346 			const struct dentry *dentry,
347 			unsigned int flags,
348 			int error
349 		),
350 
351 		TP_ARGS(dir, dentry, flags, error),
352 
353 		TP_STRUCT__entry(
354 			__field(unsigned long, error)
355 			__field(unsigned long, flags)
356 			__field(dev_t, dev)
357 			__field(u64, dir)
358 			__string(name, dentry->d_name.name)
359 		),
360 
361 		TP_fast_assign(
362 			__entry->dev = dir->i_sb->s_dev;
363 			__entry->dir = NFS_FILEID(dir);
364 			__entry->error = error < 0 ? -error : 0;
365 			__entry->flags = flags;
366 			__assign_str(name, dentry->d_name.name);
367 		),
368 
369 		TP_printk(
370 			"error=%ld (%s) flags=0x%lx (%s) name=%02x:%02x:%llu/%s",
371 			-__entry->error, nfs_show_status(__entry->error),
372 			__entry->flags,
373 			show_lookup_flags(__entry->flags),
374 			MAJOR(__entry->dev), MINOR(__entry->dev),
375 			(unsigned long long)__entry->dir,
376 			__get_str(name)
377 		)
378 );
379 
380 #define DEFINE_NFS_LOOKUP_EVENT_DONE(name) \
381 	DEFINE_EVENT(nfs_lookup_event_done, name, \
382 			TP_PROTO( \
383 				const struct inode *dir, \
384 				const struct dentry *dentry, \
385 				unsigned int flags, \
386 				int error \
387 			), \
388 			TP_ARGS(dir, dentry, flags, error))
389 
390 DEFINE_NFS_LOOKUP_EVENT(nfs_lookup_enter);
391 DEFINE_NFS_LOOKUP_EVENT_DONE(nfs_lookup_exit);
392 DEFINE_NFS_LOOKUP_EVENT(nfs_lookup_revalidate_enter);
393 DEFINE_NFS_LOOKUP_EVENT_DONE(nfs_lookup_revalidate_exit);
394 
395 TRACE_DEFINE_ENUM(O_WRONLY);
396 TRACE_DEFINE_ENUM(O_RDWR);
397 TRACE_DEFINE_ENUM(O_CREAT);
398 TRACE_DEFINE_ENUM(O_EXCL);
399 TRACE_DEFINE_ENUM(O_NOCTTY);
400 TRACE_DEFINE_ENUM(O_TRUNC);
401 TRACE_DEFINE_ENUM(O_APPEND);
402 TRACE_DEFINE_ENUM(O_NONBLOCK);
403 TRACE_DEFINE_ENUM(O_DSYNC);
404 TRACE_DEFINE_ENUM(O_DIRECT);
405 TRACE_DEFINE_ENUM(O_LARGEFILE);
406 TRACE_DEFINE_ENUM(O_DIRECTORY);
407 TRACE_DEFINE_ENUM(O_NOFOLLOW);
408 TRACE_DEFINE_ENUM(O_NOATIME);
409 TRACE_DEFINE_ENUM(O_CLOEXEC);
410 
411 #define show_open_flags(flags) \
412 	__print_flags(flags, "|", \
413 		{ O_WRONLY, "O_WRONLY" }, \
414 		{ O_RDWR, "O_RDWR" }, \
415 		{ O_CREAT, "O_CREAT" }, \
416 		{ O_EXCL, "O_EXCL" }, \
417 		{ O_NOCTTY, "O_NOCTTY" }, \
418 		{ O_TRUNC, "O_TRUNC" }, \
419 		{ O_APPEND, "O_APPEND" }, \
420 		{ O_NONBLOCK, "O_NONBLOCK" }, \
421 		{ O_DSYNC, "O_DSYNC" }, \
422 		{ O_DIRECT, "O_DIRECT" }, \
423 		{ O_LARGEFILE, "O_LARGEFILE" }, \
424 		{ O_DIRECTORY, "O_DIRECTORY" }, \
425 		{ O_NOFOLLOW, "O_NOFOLLOW" }, \
426 		{ O_NOATIME, "O_NOATIME" }, \
427 		{ O_CLOEXEC, "O_CLOEXEC" })
428 
429 #define show_fmode_flags(mode) \
430 	__print_flags(mode, "|", \
431 		{ ((__force unsigned long)FMODE_READ), "READ" }, \
432 		{ ((__force unsigned long)FMODE_WRITE), "WRITE" }, \
433 		{ ((__force unsigned long)FMODE_EXEC), "EXEC" })
434 
435 TRACE_EVENT(nfs_atomic_open_enter,
436 		TP_PROTO(
437 			const struct inode *dir,
438 			const struct nfs_open_context *ctx,
439 			unsigned int flags
440 		),
441 
442 		TP_ARGS(dir, ctx, flags),
443 
444 		TP_STRUCT__entry(
445 			__field(unsigned long, flags)
446 			__field(unsigned int, fmode)
447 			__field(dev_t, dev)
448 			__field(u64, dir)
449 			__string(name, ctx->dentry->d_name.name)
450 		),
451 
452 		TP_fast_assign(
453 			__entry->dev = dir->i_sb->s_dev;
454 			__entry->dir = NFS_FILEID(dir);
455 			__entry->flags = flags;
456 			__entry->fmode = (__force unsigned int)ctx->mode;
457 			__assign_str(name, ctx->dentry->d_name.name);
458 		),
459 
460 		TP_printk(
461 			"flags=0x%lx (%s) fmode=%s name=%02x:%02x:%llu/%s",
462 			__entry->flags,
463 			show_open_flags(__entry->flags),
464 			show_fmode_flags(__entry->fmode),
465 			MAJOR(__entry->dev), MINOR(__entry->dev),
466 			(unsigned long long)__entry->dir,
467 			__get_str(name)
468 		)
469 );
470 
471 TRACE_EVENT(nfs_atomic_open_exit,
472 		TP_PROTO(
473 			const struct inode *dir,
474 			const struct nfs_open_context *ctx,
475 			unsigned int flags,
476 			int error
477 		),
478 
479 		TP_ARGS(dir, ctx, flags, error),
480 
481 		TP_STRUCT__entry(
482 			__field(unsigned long, error)
483 			__field(unsigned long, flags)
484 			__field(unsigned int, fmode)
485 			__field(dev_t, dev)
486 			__field(u64, dir)
487 			__string(name, ctx->dentry->d_name.name)
488 		),
489 
490 		TP_fast_assign(
491 			__entry->error = -error;
492 			__entry->dev = dir->i_sb->s_dev;
493 			__entry->dir = NFS_FILEID(dir);
494 			__entry->flags = flags;
495 			__entry->fmode = (__force unsigned int)ctx->mode;
496 			__assign_str(name, ctx->dentry->d_name.name);
497 		),
498 
499 		TP_printk(
500 			"error=%ld (%s) flags=0x%lx (%s) fmode=%s "
501 			"name=%02x:%02x:%llu/%s",
502 			-__entry->error, nfs_show_status(__entry->error),
503 			__entry->flags,
504 			show_open_flags(__entry->flags),
505 			show_fmode_flags(__entry->fmode),
506 			MAJOR(__entry->dev), MINOR(__entry->dev),
507 			(unsigned long long)__entry->dir,
508 			__get_str(name)
509 		)
510 );
511 
512 TRACE_EVENT(nfs_create_enter,
513 		TP_PROTO(
514 			const struct inode *dir,
515 			const struct dentry *dentry,
516 			unsigned int flags
517 		),
518 
519 		TP_ARGS(dir, dentry, flags),
520 
521 		TP_STRUCT__entry(
522 			__field(unsigned long, flags)
523 			__field(dev_t, dev)
524 			__field(u64, dir)
525 			__string(name, dentry->d_name.name)
526 		),
527 
528 		TP_fast_assign(
529 			__entry->dev = dir->i_sb->s_dev;
530 			__entry->dir = NFS_FILEID(dir);
531 			__entry->flags = flags;
532 			__assign_str(name, dentry->d_name.name);
533 		),
534 
535 		TP_printk(
536 			"flags=0x%lx (%s) name=%02x:%02x:%llu/%s",
537 			__entry->flags,
538 			show_open_flags(__entry->flags),
539 			MAJOR(__entry->dev), MINOR(__entry->dev),
540 			(unsigned long long)__entry->dir,
541 			__get_str(name)
542 		)
543 );
544 
545 TRACE_EVENT(nfs_create_exit,
546 		TP_PROTO(
547 			const struct inode *dir,
548 			const struct dentry *dentry,
549 			unsigned int flags,
550 			int error
551 		),
552 
553 		TP_ARGS(dir, dentry, flags, error),
554 
555 		TP_STRUCT__entry(
556 			__field(unsigned long, error)
557 			__field(unsigned long, flags)
558 			__field(dev_t, dev)
559 			__field(u64, dir)
560 			__string(name, dentry->d_name.name)
561 		),
562 
563 		TP_fast_assign(
564 			__entry->error = -error;
565 			__entry->dev = dir->i_sb->s_dev;
566 			__entry->dir = NFS_FILEID(dir);
567 			__entry->flags = flags;
568 			__assign_str(name, dentry->d_name.name);
569 		),
570 
571 		TP_printk(
572 			"error=%ld (%s) flags=0x%lx (%s) name=%02x:%02x:%llu/%s",
573 			-__entry->error, nfs_show_status(__entry->error),
574 			__entry->flags,
575 			show_open_flags(__entry->flags),
576 			MAJOR(__entry->dev), MINOR(__entry->dev),
577 			(unsigned long long)__entry->dir,
578 			__get_str(name)
579 		)
580 );
581 
582 DECLARE_EVENT_CLASS(nfs_directory_event,
583 		TP_PROTO(
584 			const struct inode *dir,
585 			const struct dentry *dentry
586 		),
587 
588 		TP_ARGS(dir, dentry),
589 
590 		TP_STRUCT__entry(
591 			__field(dev_t, dev)
592 			__field(u64, dir)
593 			__string(name, dentry->d_name.name)
594 		),
595 
596 		TP_fast_assign(
597 			__entry->dev = dir->i_sb->s_dev;
598 			__entry->dir = NFS_FILEID(dir);
599 			__assign_str(name, dentry->d_name.name);
600 		),
601 
602 		TP_printk(
603 			"name=%02x:%02x:%llu/%s",
604 			MAJOR(__entry->dev), MINOR(__entry->dev),
605 			(unsigned long long)__entry->dir,
606 			__get_str(name)
607 		)
608 );
609 
610 #define DEFINE_NFS_DIRECTORY_EVENT(name) \
611 	DEFINE_EVENT(nfs_directory_event, name, \
612 			TP_PROTO( \
613 				const struct inode *dir, \
614 				const struct dentry *dentry \
615 			), \
616 			TP_ARGS(dir, dentry))
617 
618 DECLARE_EVENT_CLASS(nfs_directory_event_done,
619 		TP_PROTO(
620 			const struct inode *dir,
621 			const struct dentry *dentry,
622 			int error
623 		),
624 
625 		TP_ARGS(dir, dentry, error),
626 
627 		TP_STRUCT__entry(
628 			__field(unsigned long, error)
629 			__field(dev_t, dev)
630 			__field(u64, dir)
631 			__string(name, dentry->d_name.name)
632 		),
633 
634 		TP_fast_assign(
635 			__entry->dev = dir->i_sb->s_dev;
636 			__entry->dir = NFS_FILEID(dir);
637 			__entry->error = error < 0 ? -error : 0;
638 			__assign_str(name, dentry->d_name.name);
639 		),
640 
641 		TP_printk(
642 			"error=%ld (%s) name=%02x:%02x:%llu/%s",
643 			-__entry->error, nfs_show_status(__entry->error),
644 			MAJOR(__entry->dev), MINOR(__entry->dev),
645 			(unsigned long long)__entry->dir,
646 			__get_str(name)
647 		)
648 );
649 
650 #define DEFINE_NFS_DIRECTORY_EVENT_DONE(name) \
651 	DEFINE_EVENT(nfs_directory_event_done, name, \
652 			TP_PROTO( \
653 				const struct inode *dir, \
654 				const struct dentry *dentry, \
655 				int error \
656 			), \
657 			TP_ARGS(dir, dentry, error))
658 
659 DEFINE_NFS_DIRECTORY_EVENT(nfs_mknod_enter);
660 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_mknod_exit);
661 DEFINE_NFS_DIRECTORY_EVENT(nfs_mkdir_enter);
662 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_mkdir_exit);
663 DEFINE_NFS_DIRECTORY_EVENT(nfs_rmdir_enter);
664 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_rmdir_exit);
665 DEFINE_NFS_DIRECTORY_EVENT(nfs_remove_enter);
666 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_remove_exit);
667 DEFINE_NFS_DIRECTORY_EVENT(nfs_unlink_enter);
668 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_unlink_exit);
669 DEFINE_NFS_DIRECTORY_EVENT(nfs_symlink_enter);
670 DEFINE_NFS_DIRECTORY_EVENT_DONE(nfs_symlink_exit);
671 
672 TRACE_EVENT(nfs_link_enter,
673 		TP_PROTO(
674 			const struct inode *inode,
675 			const struct inode *dir,
676 			const struct dentry *dentry
677 		),
678 
679 		TP_ARGS(inode, dir, dentry),
680 
681 		TP_STRUCT__entry(
682 			__field(dev_t, dev)
683 			__field(u64, fileid)
684 			__field(u64, dir)
685 			__string(name, dentry->d_name.name)
686 		),
687 
688 		TP_fast_assign(
689 			__entry->dev = inode->i_sb->s_dev;
690 			__entry->fileid = NFS_FILEID(inode);
691 			__entry->dir = NFS_FILEID(dir);
692 			__assign_str(name, dentry->d_name.name);
693 		),
694 
695 		TP_printk(
696 			"fileid=%02x:%02x:%llu name=%02x:%02x:%llu/%s",
697 			MAJOR(__entry->dev), MINOR(__entry->dev),
698 			__entry->fileid,
699 			MAJOR(__entry->dev), MINOR(__entry->dev),
700 			(unsigned long long)__entry->dir,
701 			__get_str(name)
702 		)
703 );
704 
705 TRACE_EVENT(nfs_link_exit,
706 		TP_PROTO(
707 			const struct inode *inode,
708 			const struct inode *dir,
709 			const struct dentry *dentry,
710 			int error
711 		),
712 
713 		TP_ARGS(inode, dir, dentry, error),
714 
715 		TP_STRUCT__entry(
716 			__field(unsigned long, error)
717 			__field(dev_t, dev)
718 			__field(u64, fileid)
719 			__field(u64, dir)
720 			__string(name, dentry->d_name.name)
721 		),
722 
723 		TP_fast_assign(
724 			__entry->dev = inode->i_sb->s_dev;
725 			__entry->fileid = NFS_FILEID(inode);
726 			__entry->dir = NFS_FILEID(dir);
727 			__entry->error = error < 0 ? -error : 0;
728 			__assign_str(name, dentry->d_name.name);
729 		),
730 
731 		TP_printk(
732 			"error=%ld (%s) fileid=%02x:%02x:%llu name=%02x:%02x:%llu/%s",
733 			-__entry->error, nfs_show_status(__entry->error),
734 			MAJOR(__entry->dev), MINOR(__entry->dev),
735 			__entry->fileid,
736 			MAJOR(__entry->dev), MINOR(__entry->dev),
737 			(unsigned long long)__entry->dir,
738 			__get_str(name)
739 		)
740 );
741 
742 DECLARE_EVENT_CLASS(nfs_rename_event,
743 		TP_PROTO(
744 			const struct inode *old_dir,
745 			const struct dentry *old_dentry,
746 			const struct inode *new_dir,
747 			const struct dentry *new_dentry
748 		),
749 
750 		TP_ARGS(old_dir, old_dentry, new_dir, new_dentry),
751 
752 		TP_STRUCT__entry(
753 			__field(dev_t, dev)
754 			__field(u64, old_dir)
755 			__field(u64, new_dir)
756 			__string(old_name, old_dentry->d_name.name)
757 			__string(new_name, new_dentry->d_name.name)
758 		),
759 
760 		TP_fast_assign(
761 			__entry->dev = old_dir->i_sb->s_dev;
762 			__entry->old_dir = NFS_FILEID(old_dir);
763 			__entry->new_dir = NFS_FILEID(new_dir);
764 			__assign_str(old_name, old_dentry->d_name.name);
765 			__assign_str(new_name, new_dentry->d_name.name);
766 		),
767 
768 		TP_printk(
769 			"old_name=%02x:%02x:%llu/%s new_name=%02x:%02x:%llu/%s",
770 			MAJOR(__entry->dev), MINOR(__entry->dev),
771 			(unsigned long long)__entry->old_dir,
772 			__get_str(old_name),
773 			MAJOR(__entry->dev), MINOR(__entry->dev),
774 			(unsigned long long)__entry->new_dir,
775 			__get_str(new_name)
776 		)
777 );
778 #define DEFINE_NFS_RENAME_EVENT(name) \
779 	DEFINE_EVENT(nfs_rename_event, name, \
780 			TP_PROTO( \
781 				const struct inode *old_dir, \
782 				const struct dentry *old_dentry, \
783 				const struct inode *new_dir, \
784 				const struct dentry *new_dentry \
785 			), \
786 			TP_ARGS(old_dir, old_dentry, new_dir, new_dentry))
787 
788 DECLARE_EVENT_CLASS(nfs_rename_event_done,
789 		TP_PROTO(
790 			const struct inode *old_dir,
791 			const struct dentry *old_dentry,
792 			const struct inode *new_dir,
793 			const struct dentry *new_dentry,
794 			int error
795 		),
796 
797 		TP_ARGS(old_dir, old_dentry, new_dir, new_dentry, error),
798 
799 		TP_STRUCT__entry(
800 			__field(dev_t, dev)
801 			__field(unsigned long, error)
802 			__field(u64, old_dir)
803 			__string(old_name, old_dentry->d_name.name)
804 			__field(u64, new_dir)
805 			__string(new_name, new_dentry->d_name.name)
806 		),
807 
808 		TP_fast_assign(
809 			__entry->dev = old_dir->i_sb->s_dev;
810 			__entry->error = -error;
811 			__entry->old_dir = NFS_FILEID(old_dir);
812 			__entry->new_dir = NFS_FILEID(new_dir);
813 			__assign_str(old_name, old_dentry->d_name.name);
814 			__assign_str(new_name, new_dentry->d_name.name);
815 		),
816 
817 		TP_printk(
818 			"error=%ld (%s) old_name=%02x:%02x:%llu/%s "
819 			"new_name=%02x:%02x:%llu/%s",
820 			-__entry->error, nfs_show_status(__entry->error),
821 			MAJOR(__entry->dev), MINOR(__entry->dev),
822 			(unsigned long long)__entry->old_dir,
823 			__get_str(old_name),
824 			MAJOR(__entry->dev), MINOR(__entry->dev),
825 			(unsigned long long)__entry->new_dir,
826 			__get_str(new_name)
827 		)
828 );
829 #define DEFINE_NFS_RENAME_EVENT_DONE(name) \
830 	DEFINE_EVENT(nfs_rename_event_done, name, \
831 			TP_PROTO( \
832 				const struct inode *old_dir, \
833 				const struct dentry *old_dentry, \
834 				const struct inode *new_dir, \
835 				const struct dentry *new_dentry, \
836 				int error \
837 			), \
838 			TP_ARGS(old_dir, old_dentry, new_dir, \
839 				new_dentry, error))
840 
841 DEFINE_NFS_RENAME_EVENT(nfs_rename_enter);
842 DEFINE_NFS_RENAME_EVENT_DONE(nfs_rename_exit);
843 
844 DEFINE_NFS_RENAME_EVENT_DONE(nfs_sillyrename_rename);
845 
846 TRACE_EVENT(nfs_sillyrename_unlink,
847 		TP_PROTO(
848 			const struct nfs_unlinkdata *data,
849 			int error
850 		),
851 
852 		TP_ARGS(data, error),
853 
854 		TP_STRUCT__entry(
855 			__field(dev_t, dev)
856 			__field(unsigned long, error)
857 			__field(u64, dir)
858 			__dynamic_array(char, name, data->args.name.len + 1)
859 		),
860 
861 		TP_fast_assign(
862 			struct inode *dir = d_inode(data->dentry->d_parent);
863 			size_t len = data->args.name.len;
864 			__entry->dev = dir->i_sb->s_dev;
865 			__entry->dir = NFS_FILEID(dir);
866 			__entry->error = -error;
867 			memcpy(__get_str(name),
868 				data->args.name.name, len);
869 			__get_str(name)[len] = 0;
870 		),
871 
872 		TP_printk(
873 			"error=%ld (%s) name=%02x:%02x:%llu/%s",
874 			-__entry->error, nfs_show_status(__entry->error),
875 			MAJOR(__entry->dev), MINOR(__entry->dev),
876 			(unsigned long long)__entry->dir,
877 			__get_str(name)
878 		)
879 );
880 
881 TRACE_EVENT(nfs_initiate_read,
882 		TP_PROTO(
883 			const struct nfs_pgio_header *hdr
884 		),
885 
886 		TP_ARGS(hdr),
887 
888 		TP_STRUCT__entry(
889 			__field(dev_t, dev)
890 			__field(u32, fhandle)
891 			__field(u64, fileid)
892 			__field(loff_t, offset)
893 			__field(u32, count)
894 		),
895 
896 		TP_fast_assign(
897 			const struct inode *inode = hdr->inode;
898 			const struct nfs_inode *nfsi = NFS_I(inode);
899 			const struct nfs_fh *fh = hdr->args.fh ?
900 						  hdr->args.fh : &nfsi->fh;
901 
902 			__entry->offset = hdr->args.offset;
903 			__entry->count = hdr->args.count;
904 			__entry->dev = inode->i_sb->s_dev;
905 			__entry->fileid = nfsi->fileid;
906 			__entry->fhandle = nfs_fhandle_hash(fh);
907 		),
908 
909 		TP_printk(
910 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
911 			"offset=%lld count=%u",
912 			MAJOR(__entry->dev), MINOR(__entry->dev),
913 			(unsigned long long)__entry->fileid,
914 			__entry->fhandle,
915 			(long long)__entry->offset, __entry->count
916 		)
917 );
918 
919 TRACE_EVENT(nfs_readpage_done,
920 		TP_PROTO(
921 			const struct rpc_task *task,
922 			const struct nfs_pgio_header *hdr
923 		),
924 
925 		TP_ARGS(task, hdr),
926 
927 		TP_STRUCT__entry(
928 			__field(dev_t, dev)
929 			__field(u32, fhandle)
930 			__field(u64, fileid)
931 			__field(loff_t, offset)
932 			__field(u32, arg_count)
933 			__field(u32, res_count)
934 			__field(bool, eof)
935 			__field(int, status)
936 		),
937 
938 		TP_fast_assign(
939 			const struct inode *inode = hdr->inode;
940 			const struct nfs_inode *nfsi = NFS_I(inode);
941 			const struct nfs_fh *fh = hdr->args.fh ?
942 						  hdr->args.fh : &nfsi->fh;
943 
944 			__entry->status = task->tk_status;
945 			__entry->offset = hdr->args.offset;
946 			__entry->arg_count = hdr->args.count;
947 			__entry->res_count = hdr->res.count;
948 			__entry->eof = hdr->res.eof;
949 			__entry->dev = inode->i_sb->s_dev;
950 			__entry->fileid = nfsi->fileid;
951 			__entry->fhandle = nfs_fhandle_hash(fh);
952 		),
953 
954 		TP_printk(
955 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
956 			"offset=%lld count=%u res=%u status=%d%s",
957 			MAJOR(__entry->dev), MINOR(__entry->dev),
958 			(unsigned long long)__entry->fileid,
959 			__entry->fhandle,
960 			(long long)__entry->offset, __entry->arg_count,
961 			__entry->res_count, __entry->status,
962 			__entry->eof ? " eof" : ""
963 		)
964 );
965 
966 TRACE_EVENT(nfs_readpage_short,
967 		TP_PROTO(
968 			const struct rpc_task *task,
969 			const struct nfs_pgio_header *hdr
970 		),
971 
972 		TP_ARGS(task, hdr),
973 
974 		TP_STRUCT__entry(
975 			__field(dev_t, dev)
976 			__field(u32, fhandle)
977 			__field(u64, fileid)
978 			__field(loff_t, offset)
979 			__field(u32, arg_count)
980 			__field(u32, res_count)
981 			__field(bool, eof)
982 			__field(int, status)
983 		),
984 
985 		TP_fast_assign(
986 			const struct inode *inode = hdr->inode;
987 			const struct nfs_inode *nfsi = NFS_I(inode);
988 			const struct nfs_fh *fh = hdr->args.fh ?
989 						  hdr->args.fh : &nfsi->fh;
990 
991 			__entry->status = task->tk_status;
992 			__entry->offset = hdr->args.offset;
993 			__entry->arg_count = hdr->args.count;
994 			__entry->res_count = hdr->res.count;
995 			__entry->eof = hdr->res.eof;
996 			__entry->dev = inode->i_sb->s_dev;
997 			__entry->fileid = nfsi->fileid;
998 			__entry->fhandle = nfs_fhandle_hash(fh);
999 		),
1000 
1001 		TP_printk(
1002 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1003 			"offset=%lld count=%u res=%u status=%d%s",
1004 			MAJOR(__entry->dev), MINOR(__entry->dev),
1005 			(unsigned long long)__entry->fileid,
1006 			__entry->fhandle,
1007 			(long long)__entry->offset, __entry->arg_count,
1008 			__entry->res_count, __entry->status,
1009 			__entry->eof ? " eof" : ""
1010 		)
1011 );
1012 
1013 TRACE_EVENT(nfs_pgio_error,
1014 	TP_PROTO(
1015 		const struct nfs_pgio_header *hdr,
1016 		int error,
1017 		loff_t pos
1018 	),
1019 
1020 	TP_ARGS(hdr, error, pos),
1021 
1022 	TP_STRUCT__entry(
1023 		__field(dev_t, dev)
1024 		__field(u32, fhandle)
1025 		__field(u64, fileid)
1026 		__field(loff_t, offset)
1027 		__field(u32, arg_count)
1028 		__field(u32, res_count)
1029 		__field(loff_t, pos)
1030 		__field(int, status)
1031 	),
1032 
1033 	TP_fast_assign(
1034 		const struct inode *inode = hdr->inode;
1035 		const struct nfs_inode *nfsi = NFS_I(inode);
1036 		const struct nfs_fh *fh = hdr->args.fh ?
1037 					  hdr->args.fh : &nfsi->fh;
1038 
1039 		__entry->status = error;
1040 		__entry->offset = hdr->args.offset;
1041 		__entry->arg_count = hdr->args.count;
1042 		__entry->res_count = hdr->res.count;
1043 		__entry->dev = inode->i_sb->s_dev;
1044 		__entry->fileid = nfsi->fileid;
1045 		__entry->fhandle = nfs_fhandle_hash(fh);
1046 	),
1047 
1048 	TP_printk("fileid=%02x:%02x:%llu fhandle=0x%08x "
1049 		  "offset=%lld count=%u res=%u pos=%llu status=%d",
1050 		MAJOR(__entry->dev), MINOR(__entry->dev),
1051 		(unsigned long long)__entry->fileid, __entry->fhandle,
1052 		(long long)__entry->offset, __entry->arg_count, __entry->res_count,
1053 		__entry->pos, __entry->status
1054 	)
1055 );
1056 
1057 TRACE_DEFINE_ENUM(NFS_UNSTABLE);
1058 TRACE_DEFINE_ENUM(NFS_DATA_SYNC);
1059 TRACE_DEFINE_ENUM(NFS_FILE_SYNC);
1060 
1061 #define nfs_show_stable(stable) \
1062 	__print_symbolic(stable, \
1063 			{ NFS_UNSTABLE, "UNSTABLE" }, \
1064 			{ NFS_DATA_SYNC, "DATA_SYNC" }, \
1065 			{ NFS_FILE_SYNC, "FILE_SYNC" })
1066 
1067 TRACE_EVENT(nfs_initiate_write,
1068 		TP_PROTO(
1069 			const struct nfs_pgio_header *hdr
1070 		),
1071 
1072 		TP_ARGS(hdr),
1073 
1074 		TP_STRUCT__entry(
1075 			__field(dev_t, dev)
1076 			__field(u32, fhandle)
1077 			__field(u64, fileid)
1078 			__field(loff_t, offset)
1079 			__field(u32, count)
1080 			__field(enum nfs3_stable_how, stable)
1081 		),
1082 
1083 		TP_fast_assign(
1084 			const struct inode *inode = hdr->inode;
1085 			const struct nfs_inode *nfsi = NFS_I(inode);
1086 			const struct nfs_fh *fh = hdr->args.fh ?
1087 						  hdr->args.fh : &nfsi->fh;
1088 
1089 			__entry->offset = hdr->args.offset;
1090 			__entry->count = hdr->args.count;
1091 			__entry->stable = hdr->args.stable;
1092 			__entry->dev = inode->i_sb->s_dev;
1093 			__entry->fileid = nfsi->fileid;
1094 			__entry->fhandle = nfs_fhandle_hash(fh);
1095 		),
1096 
1097 		TP_printk(
1098 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1099 			"offset=%lld count=%u stable=%s",
1100 			MAJOR(__entry->dev), MINOR(__entry->dev),
1101 			(unsigned long long)__entry->fileid,
1102 			__entry->fhandle,
1103 			(long long)__entry->offset, __entry->count,
1104 			nfs_show_stable(__entry->stable)
1105 		)
1106 );
1107 
1108 TRACE_EVENT(nfs_writeback_done,
1109 		TP_PROTO(
1110 			const struct rpc_task *task,
1111 			const struct nfs_pgio_header *hdr
1112 		),
1113 
1114 		TP_ARGS(task, hdr),
1115 
1116 		TP_STRUCT__entry(
1117 			__field(dev_t, dev)
1118 			__field(u32, fhandle)
1119 			__field(u64, fileid)
1120 			__field(loff_t, offset)
1121 			__field(u32, arg_count)
1122 			__field(u32, res_count)
1123 			__field(int, status)
1124 			__field(enum nfs3_stable_how, stable)
1125 			__array(char, verifier, NFS4_VERIFIER_SIZE)
1126 		),
1127 
1128 		TP_fast_assign(
1129 			const struct inode *inode = hdr->inode;
1130 			const struct nfs_inode *nfsi = NFS_I(inode);
1131 			const struct nfs_fh *fh = hdr->args.fh ?
1132 						  hdr->args.fh : &nfsi->fh;
1133 			const struct nfs_writeverf *verf = hdr->res.verf;
1134 
1135 			__entry->status = task->tk_status;
1136 			__entry->offset = hdr->args.offset;
1137 			__entry->arg_count = hdr->args.count;
1138 			__entry->res_count = hdr->res.count;
1139 			__entry->stable = verf->committed;
1140 			memcpy(__entry->verifier,
1141 				&verf->verifier,
1142 				NFS4_VERIFIER_SIZE);
1143 			__entry->dev = inode->i_sb->s_dev;
1144 			__entry->fileid = nfsi->fileid;
1145 			__entry->fhandle = nfs_fhandle_hash(fh);
1146 		),
1147 
1148 		TP_printk(
1149 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1150 			"offset=%lld count=%u res=%u status=%d stable=%s "
1151 			"verifier=%s",
1152 			MAJOR(__entry->dev), MINOR(__entry->dev),
1153 			(unsigned long long)__entry->fileid,
1154 			__entry->fhandle,
1155 			(long long)__entry->offset, __entry->arg_count,
1156 			__entry->res_count, __entry->status,
1157 			nfs_show_stable(__entry->stable),
1158 			__print_hex_str(__entry->verifier, NFS4_VERIFIER_SIZE)
1159 		)
1160 );
1161 
1162 DECLARE_EVENT_CLASS(nfs_page_error_class,
1163 		TP_PROTO(
1164 			const struct nfs_page *req,
1165 			int error
1166 		),
1167 
1168 		TP_ARGS(req, error),
1169 
1170 		TP_STRUCT__entry(
1171 			__field(const void *, req)
1172 			__field(pgoff_t, index)
1173 			__field(unsigned int, offset)
1174 			__field(unsigned int, pgbase)
1175 			__field(unsigned int, bytes)
1176 			__field(int, error)
1177 		),
1178 
1179 		TP_fast_assign(
1180 			__entry->req = req;
1181 			__entry->index = req->wb_index;
1182 			__entry->offset = req->wb_offset;
1183 			__entry->pgbase = req->wb_pgbase;
1184 			__entry->bytes = req->wb_bytes;
1185 			__entry->error = error;
1186 		),
1187 
1188 		TP_printk(
1189 			"req=%p index=%lu offset=%u pgbase=%u bytes=%u error=%d",
1190 			__entry->req, __entry->index, __entry->offset,
1191 			__entry->pgbase, __entry->bytes, __entry->error
1192 		)
1193 );
1194 
1195 #define DEFINE_NFS_PAGEERR_EVENT(name) \
1196 	DEFINE_EVENT(nfs_page_error_class, name, \
1197 			TP_PROTO( \
1198 				const struct nfs_page *req, \
1199 				int error \
1200 			), \
1201 			TP_ARGS(req, error))
1202 
1203 DEFINE_NFS_PAGEERR_EVENT(nfs_write_error);
1204 DEFINE_NFS_PAGEERR_EVENT(nfs_comp_error);
1205 DEFINE_NFS_PAGEERR_EVENT(nfs_commit_error);
1206 
1207 TRACE_EVENT(nfs_initiate_commit,
1208 		TP_PROTO(
1209 			const struct nfs_commit_data *data
1210 		),
1211 
1212 		TP_ARGS(data),
1213 
1214 		TP_STRUCT__entry(
1215 			__field(dev_t, dev)
1216 			__field(u32, fhandle)
1217 			__field(u64, fileid)
1218 			__field(loff_t, offset)
1219 			__field(u32, count)
1220 		),
1221 
1222 		TP_fast_assign(
1223 			const struct inode *inode = data->inode;
1224 			const struct nfs_inode *nfsi = NFS_I(inode);
1225 			const struct nfs_fh *fh = data->args.fh ?
1226 						  data->args.fh : &nfsi->fh;
1227 
1228 			__entry->offset = data->args.offset;
1229 			__entry->count = data->args.count;
1230 			__entry->dev = inode->i_sb->s_dev;
1231 			__entry->fileid = nfsi->fileid;
1232 			__entry->fhandle = nfs_fhandle_hash(fh);
1233 		),
1234 
1235 		TP_printk(
1236 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1237 			"offset=%lld count=%u",
1238 			MAJOR(__entry->dev), MINOR(__entry->dev),
1239 			(unsigned long long)__entry->fileid,
1240 			__entry->fhandle,
1241 			(long long)__entry->offset, __entry->count
1242 		)
1243 );
1244 
1245 TRACE_EVENT(nfs_commit_done,
1246 		TP_PROTO(
1247 			const struct rpc_task *task,
1248 			const struct nfs_commit_data *data
1249 		),
1250 
1251 		TP_ARGS(task, data),
1252 
1253 		TP_STRUCT__entry(
1254 			__field(dev_t, dev)
1255 			__field(u32, fhandle)
1256 			__field(u64, fileid)
1257 			__field(loff_t, offset)
1258 			__field(int, status)
1259 			__field(enum nfs3_stable_how, stable)
1260 			__array(char, verifier, NFS4_VERIFIER_SIZE)
1261 		),
1262 
1263 		TP_fast_assign(
1264 			const struct inode *inode = data->inode;
1265 			const struct nfs_inode *nfsi = NFS_I(inode);
1266 			const struct nfs_fh *fh = data->args.fh ?
1267 						  data->args.fh : &nfsi->fh;
1268 			const struct nfs_writeverf *verf = data->res.verf;
1269 
1270 			__entry->status = task->tk_status;
1271 			__entry->offset = data->args.offset;
1272 			__entry->stable = verf->committed;
1273 			memcpy(__entry->verifier,
1274 				&verf->verifier,
1275 				NFS4_VERIFIER_SIZE);
1276 			__entry->dev = inode->i_sb->s_dev;
1277 			__entry->fileid = nfsi->fileid;
1278 			__entry->fhandle = nfs_fhandle_hash(fh);
1279 		),
1280 
1281 		TP_printk(
1282 			"fileid=%02x:%02x:%llu fhandle=0x%08x "
1283 			"offset=%lld status=%d stable=%s verifier=%s",
1284 			MAJOR(__entry->dev), MINOR(__entry->dev),
1285 			(unsigned long long)__entry->fileid,
1286 			__entry->fhandle,
1287 			(long long)__entry->offset, __entry->status,
1288 			nfs_show_stable(__entry->stable),
1289 			__print_hex_str(__entry->verifier, NFS4_VERIFIER_SIZE)
1290 		)
1291 );
1292 
1293 TRACE_EVENT(nfs_fh_to_dentry,
1294 		TP_PROTO(
1295 			const struct super_block *sb,
1296 			const struct nfs_fh *fh,
1297 			u64 fileid,
1298 			int error
1299 		),
1300 
1301 		TP_ARGS(sb, fh, fileid, error),
1302 
1303 		TP_STRUCT__entry(
1304 			__field(int, error)
1305 			__field(dev_t, dev)
1306 			__field(u32, fhandle)
1307 			__field(u64, fileid)
1308 		),
1309 
1310 		TP_fast_assign(
1311 			__entry->error = error;
1312 			__entry->dev = sb->s_dev;
1313 			__entry->fileid = fileid;
1314 			__entry->fhandle = nfs_fhandle_hash(fh);
1315 		),
1316 
1317 		TP_printk(
1318 			"error=%d fileid=%02x:%02x:%llu fhandle=0x%08x ",
1319 			__entry->error,
1320 			MAJOR(__entry->dev), MINOR(__entry->dev),
1321 			(unsigned long long)__entry->fileid,
1322 			__entry->fhandle
1323 		)
1324 );
1325 
1326 TRACE_DEFINE_ENUM(NFS_OK);
1327 TRACE_DEFINE_ENUM(NFSERR_PERM);
1328 TRACE_DEFINE_ENUM(NFSERR_NOENT);
1329 TRACE_DEFINE_ENUM(NFSERR_IO);
1330 TRACE_DEFINE_ENUM(NFSERR_NXIO);
1331 TRACE_DEFINE_ENUM(ECHILD);
1332 TRACE_DEFINE_ENUM(NFSERR_EAGAIN);
1333 TRACE_DEFINE_ENUM(NFSERR_ACCES);
1334 TRACE_DEFINE_ENUM(NFSERR_EXIST);
1335 TRACE_DEFINE_ENUM(NFSERR_XDEV);
1336 TRACE_DEFINE_ENUM(NFSERR_NODEV);
1337 TRACE_DEFINE_ENUM(NFSERR_NOTDIR);
1338 TRACE_DEFINE_ENUM(NFSERR_ISDIR);
1339 TRACE_DEFINE_ENUM(NFSERR_INVAL);
1340 TRACE_DEFINE_ENUM(NFSERR_FBIG);
1341 TRACE_DEFINE_ENUM(NFSERR_NOSPC);
1342 TRACE_DEFINE_ENUM(NFSERR_ROFS);
1343 TRACE_DEFINE_ENUM(NFSERR_MLINK);
1344 TRACE_DEFINE_ENUM(NFSERR_OPNOTSUPP);
1345 TRACE_DEFINE_ENUM(NFSERR_NAMETOOLONG);
1346 TRACE_DEFINE_ENUM(NFSERR_NOTEMPTY);
1347 TRACE_DEFINE_ENUM(NFSERR_DQUOT);
1348 TRACE_DEFINE_ENUM(NFSERR_STALE);
1349 TRACE_DEFINE_ENUM(NFSERR_REMOTE);
1350 TRACE_DEFINE_ENUM(NFSERR_WFLUSH);
1351 TRACE_DEFINE_ENUM(NFSERR_BADHANDLE);
1352 TRACE_DEFINE_ENUM(NFSERR_NOT_SYNC);
1353 TRACE_DEFINE_ENUM(NFSERR_BAD_COOKIE);
1354 TRACE_DEFINE_ENUM(NFSERR_NOTSUPP);
1355 TRACE_DEFINE_ENUM(NFSERR_TOOSMALL);
1356 TRACE_DEFINE_ENUM(NFSERR_SERVERFAULT);
1357 TRACE_DEFINE_ENUM(NFSERR_BADTYPE);
1358 TRACE_DEFINE_ENUM(NFSERR_JUKEBOX);
1359 
1360 #define nfs_show_status(x) \
1361 	__print_symbolic(x, \
1362 			{ NFS_OK, "OK" }, \
1363 			{ NFSERR_PERM, "PERM" }, \
1364 			{ NFSERR_NOENT, "NOENT" }, \
1365 			{ NFSERR_IO, "IO" }, \
1366 			{ NFSERR_NXIO, "NXIO" }, \
1367 			{ ECHILD, "CHILD" }, \
1368 			{ NFSERR_EAGAIN, "AGAIN" }, \
1369 			{ NFSERR_ACCES, "ACCES" }, \
1370 			{ NFSERR_EXIST, "EXIST" }, \
1371 			{ NFSERR_XDEV, "XDEV" }, \
1372 			{ NFSERR_NODEV, "NODEV" }, \
1373 			{ NFSERR_NOTDIR, "NOTDIR" }, \
1374 			{ NFSERR_ISDIR, "ISDIR" }, \
1375 			{ NFSERR_INVAL, "INVAL" }, \
1376 			{ NFSERR_FBIG, "FBIG" }, \
1377 			{ NFSERR_NOSPC, "NOSPC" }, \
1378 			{ NFSERR_ROFS, "ROFS" }, \
1379 			{ NFSERR_MLINK, "MLINK" }, \
1380 			{ NFSERR_OPNOTSUPP, "OPNOTSUPP" }, \
1381 			{ NFSERR_NAMETOOLONG, "NAMETOOLONG" }, \
1382 			{ NFSERR_NOTEMPTY, "NOTEMPTY" }, \
1383 			{ NFSERR_DQUOT, "DQUOT" }, \
1384 			{ NFSERR_STALE, "STALE" }, \
1385 			{ NFSERR_REMOTE, "REMOTE" }, \
1386 			{ NFSERR_WFLUSH, "WFLUSH" }, \
1387 			{ NFSERR_BADHANDLE, "BADHANDLE" }, \
1388 			{ NFSERR_NOT_SYNC, "NOTSYNC" }, \
1389 			{ NFSERR_BAD_COOKIE, "BADCOOKIE" }, \
1390 			{ NFSERR_NOTSUPP, "NOTSUPP" }, \
1391 			{ NFSERR_TOOSMALL, "TOOSMALL" }, \
1392 			{ NFSERR_SERVERFAULT, "REMOTEIO" }, \
1393 			{ NFSERR_BADTYPE, "BADTYPE" }, \
1394 			{ NFSERR_JUKEBOX, "JUKEBOX" })
1395 
1396 DECLARE_EVENT_CLASS(nfs_xdr_event,
1397 		TP_PROTO(
1398 			const struct xdr_stream *xdr,
1399 			int error
1400 		),
1401 
1402 		TP_ARGS(xdr, error),
1403 
1404 		TP_STRUCT__entry(
1405 			__field(unsigned int, task_id)
1406 			__field(unsigned int, client_id)
1407 			__field(u32, xid)
1408 			__field(int, version)
1409 			__field(unsigned long, error)
1410 			__string(program,
1411 				 xdr->rqst->rq_task->tk_client->cl_program->name)
1412 			__string(procedure,
1413 				 xdr->rqst->rq_task->tk_msg.rpc_proc->p_name)
1414 		),
1415 
1416 		TP_fast_assign(
1417 			const struct rpc_rqst *rqstp = xdr->rqst;
1418 			const struct rpc_task *task = rqstp->rq_task;
1419 
1420 			__entry->task_id = task->tk_pid;
1421 			__entry->client_id = task->tk_client->cl_clid;
1422 			__entry->xid = be32_to_cpu(rqstp->rq_xid);
1423 			__entry->version = task->tk_client->cl_vers;
1424 			__entry->error = error;
1425 			__assign_str(program,
1426 				     task->tk_client->cl_program->name);
1427 			__assign_str(procedure, task->tk_msg.rpc_proc->p_name);
1428 		),
1429 
1430 		TP_printk(
1431 			"task:%u@%d xid=0x%08x %sv%d %s error=%ld (%s)",
1432 			__entry->task_id, __entry->client_id, __entry->xid,
1433 			__get_str(program), __entry->version,
1434 			__get_str(procedure), -__entry->error,
1435 			nfs_show_status(__entry->error)
1436 		)
1437 );
1438 #define DEFINE_NFS_XDR_EVENT(name) \
1439 	DEFINE_EVENT(nfs_xdr_event, name, \
1440 			TP_PROTO( \
1441 				const struct xdr_stream *xdr, \
1442 				int error \
1443 			), \
1444 			TP_ARGS(xdr, error))
1445 DEFINE_NFS_XDR_EVENT(nfs_xdr_status);
1446 DEFINE_NFS_XDR_EVENT(nfs_xdr_bad_filehandle);
1447 
1448 #endif /* _TRACE_NFS_H */
1449 
1450 #undef TRACE_INCLUDE_PATH
1451 #define TRACE_INCLUDE_PATH .
1452 #define TRACE_INCLUDE_FILE nfstrace
1453 /* This part must be outside protection */
1454 #include <trace/define_trace.h>
1455