xref: /freebsd/sys/fs/nfsclient/nfs_kdtrace.h (revision 6ae1554a5d9b318f8ad53ccc39fa5a961403da73)
1 /*-
2  * Copyright (c) 2009 Robert N. M. Watson
3  * All rights reserved.
4  *
5  * This software was developed at the University of Cambridge Computer
6  * Laboratory with support from a grant from Google, Inc.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * $FreeBSD$
30  */
31 
32 #ifndef _NFSCL_NFS_KDTRACE_H_
33 #define	_NFSCL_NFS_KDTRACE_H_
34 
35 /*
36  * Definitions for NFS access cache probes.
37  */
38 extern uint32_t	nfscl_accesscache_flush_done_id;
39 extern uint32_t	nfscl_accesscache_get_hit_id;
40 extern uint32_t	nfscl_accesscache_get_miss_id;
41 extern uint32_t	nfscl_accesscache_load_done_id;
42 
43 /*
44  * Definitions for NFS attribute cache probes.
45  */
46 extern uint32_t	nfscl_attrcache_flush_done_id;
47 extern uint32_t	nfscl_attrcache_get_hit_id;
48 extern uint32_t	nfscl_attrcache_get_miss_id;
49 extern uint32_t	nfscl_attrcache_load_done_id;
50 
51 #ifdef KDTRACE_HOOKS
52 #include <sys/dtrace_bsd.h>
53 
54 #define	KDTRACE_NFS_ACCESSCACHE_FLUSH_DONE(vp)	do {			\
55 	if (dtrace_nfscl_accesscache_flush_done_probe != NULL)		\
56 		(dtrace_nfscl_accesscache_flush_done_probe)(		\
57 		    nfscl_accesscache_flush_done_id, (vp));		\
58 } while (0)
59 
60 #define	KDTRACE_NFS_ACCESSCACHE_GET_HIT(vp, uid, mode)	do {		\
61 	if (dtrace_nfscl_accesscache_get_hit_probe != NULL)		\
62 		(dtrace_nfscl_accesscache_get_hit_probe)(		\
63 		    nfscl_accesscache_get_hit_id, (vp), (uid),		\
64 		    (mode));						\
65 } while (0)
66 
67 #define	KDTRACE_NFS_ACCESSCACHE_GET_MISS(vp, uid, mode)	do {		\
68 	if (dtrace_nfscl_accesscache_get_miss_probe != NULL)		\
69 		(dtrace_nfscl_accesscache_get_miss_probe)(		\
70 		    nfscl_accesscache_get_miss_id, (vp), (uid),		\
71 		    (mode));						\
72 } while (0)
73 
74 #define	KDTRACE_NFS_ACCESSCACHE_LOAD_DONE(vp, uid, rmode, error) do {	\
75 	if (dtrace_nfscl_accesscache_load_done_probe != NULL)		\
76 		(dtrace_nfscl_accesscache_load_done_probe)(		\
77 		    nfscl_accesscache_load_done_id, (vp), (uid),	\
78 		    (rmode), (error));					\
79 } while (0)
80 
81 #define	KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(vp)	do {			\
82 	if (dtrace_nfscl_attrcache_flush_done_probe != NULL)		\
83 		(dtrace_nfscl_attrcache_flush_done_probe)(		\
84 		    nfscl_attrcache_flush_done_id, (vp));		\
85 } while (0)
86 
87 #define	KDTRACE_NFS_ATTRCACHE_GET_HIT(vp, vap)	do {			\
88 	if (dtrace_nfscl_attrcache_get_hit_probe != NULL)		\
89 		(dtrace_nfscl_attrcache_get_hit_probe)(			\
90 		    nfscl_attrcache_get_hit_id, (vp), (vap));		\
91 } while (0)
92 
93 #define	KDTRACE_NFS_ATTRCACHE_GET_MISS(vp)	do {			\
94 	if (dtrace_nfscl_attrcache_get_miss_probe != NULL)		\
95 		(dtrace_nfscl_attrcache_get_miss_probe)(		\
96 			    nfscl_attrcache_get_miss_id, (vp));		\
97 } while (0)
98 
99 #define	KDTRACE_NFS_ATTRCACHE_LOAD_DONE(vp, vap, error)	do {		\
100 	if (dtrace_nfscl_attrcache_load_done_probe != NULL)		\
101 		(dtrace_nfscl_attrcache_load_done_probe)(		\
102 		    nfscl_attrcache_load_done_id, (vp), (vap),		\
103 		    (error));						\
104 } while (0)
105 
106 #else /* !KDTRACE_HOOKS */
107 
108 #define	KDTRACE_NFS_ACCESSCACHE_FLUSH_DONE(vp)
109 #define	KDTRACE_NFS_ACCESSCACHE_GET_HIT(vp, uid, mode)
110 #define	KDTRACE_NFS_ACCESSCACHE_GET_MISS(vp, uid, mode)
111 #define	KDTRACE_NFS_ACCESSCACHE_LOAD_DONE(vp, uid, rmode, error)
112 
113 #define	KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(vp)
114 #define	KDTRACE_NFS_ATTRCACHE_GET_HIT(vp, vap)
115 #define	KDTRACE_NFS_ATTRCACHE_GET_MISS(vp)
116 #define	KDTRACE_NFS_ATTRCACHE_LOAD_DONE(vp, vap, error)
117 
118 #endif /* KDTRACE_HOOKS */
119 
120 #endif /* !_NFSCL_NFS_KDTRACE_H_ */
121