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