nfs_kdtrace.h revision 258666
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: head/sys/fs/nfsclient/nfs_kdtrace.h 258666 2013-11-26 20:27:57Z glebius $
30 */
31
32#ifndef _NFSCL_NFS_KDTRACE_H_
33#define	_NFSCL_NFS_KDTRACE_H_
34
35/*
36 * Definitions for NFS access cache probes.
37 */
38extern uint32_t	nfscl_accesscache_flush_done_id;
39extern uint32_t	nfscl_accesscache_get_hit_id;
40extern uint32_t	nfscl_accesscache_get_miss_id;
41extern uint32_t	nfscl_accesscache_load_done_id;
42/*
43 * Definitions for NFS attribute cache probes.
44 */
45extern uint32_t nfscl_attrcache_flush_done_id;
46extern uint32_t nfscl_attrcache_get_hit_id;
47extern uint32_t nfscl_attrcache_get_miss_id;
48extern uint32_t nfscl_attrcache_load_done_id;
49
50#ifdef KDTRACE_HOOKS
51#include <sys/dtrace_bsd.h>
52
53#define	KDTRACE_NFS_ACCESSCACHE_FLUSH_DONE(vp)	do {			\
54	if (dtrace_nfscl_accesscache_flush_done_probe != NULL)		\
55		(dtrace_nfscl_accesscache_flush_done_probe)(		\
56		    nfscl_accesscache_flush_done_id, (vp));		\
57} while (0)
58
59#define	KDTRACE_NFS_ACCESSCACHE_GET_HIT(vp, uid, mode)	do {		\
60	if (dtrace_nfscl_accesscache_get_hit_probe != NULL)		\
61		(dtrace_nfscl_accesscache_get_hit_probe)(		\
62		    nfscl_accesscache_get_hit_id, (vp), (uid),		\
63		    (mode));						\
64} while (0)
65
66#define	KDTRACE_NFS_ACCESSCACHE_GET_MISS(vp, uid, mode)	do {		\
67	if (dtrace_nfscl_accesscache_get_miss_probe != NULL)		\
68		(dtrace_nfscl_accesscache_get_miss_probe)(		\
69		    nfscl_accesscache_get_miss_id, (vp), (uid),		\
70		    (mode));						\
71} while (0)
72
73#define	KDTRACE_NFS_ACCESSCACHE_LOAD_DONE(vp, uid, rmode, error) do {	\
74	if (dtrace_nfscl_accesscache_load_done_probe != NULL)		\
75		(dtrace_nfscl_accesscache_load_done_probe)(		\
76		    nfscl_accesscache_load_done_id, (vp), (uid),	\
77		    (rmode), (error));					\
78} while (0)
79
80/*
81 * Definitions for NFS attribute cache probes.
82 */
83extern uint32_t	nfscl_attrcache_flush_done_id;
84extern uint32_t	nfscl_attrcache_get_hit_id;
85extern uint32_t	nfscl_attrcache_get_miss_id;
86extern uint32_t	nfscl_attrcache_load_done_id;
87
88#define	KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(vp)	do {			\
89	if (dtrace_nfscl_attrcache_flush_done_probe != NULL)		\
90		(dtrace_nfscl_attrcache_flush_done_probe)(		\
91		    nfscl_attrcache_flush_done_id, (vp));		\
92} while (0)
93
94#define	KDTRACE_NFS_ATTRCACHE_GET_HIT(vp, vap)	do {			\
95	if (dtrace_nfscl_attrcache_get_hit_probe != NULL)		\
96		(dtrace_nfscl_attrcache_get_hit_probe)(			\
97		    nfscl_attrcache_get_hit_id, (vp), (vap));		\
98} while (0)
99
100#define	KDTRACE_NFS_ATTRCACHE_GET_MISS(vp)	do {			\
101	if (dtrace_nfscl_attrcache_get_miss_probe != NULL)		\
102		(dtrace_nfscl_attrcache_get_miss_probe)(		\
103			    nfscl_attrcache_get_miss_id, (vp));		\
104} while (0)
105
106#define	KDTRACE_NFS_ATTRCACHE_LOAD_DONE(vp, vap, error)	do {		\
107	if (dtrace_nfscl_attrcache_load_done_probe != NULL)		\
108		(dtrace_nfscl_attrcache_load_done_probe)(		\
109		    nfscl_attrcache_load_done_id, (vp), (vap),		\
110		    (error));						\
111} while (0)
112
113#else /* !KDTRACE_HOOKS */
114
115#define	KDTRACE_NFS_ACCESSCACHE_FLUSH_DONE(vp)
116#define	KDTRACE_NFS_ACCESSCACHE_GET_HIT(vp, uid, mode)
117#define	KDTRACE_NFS_ACCESSCACHE_GET_MISS(vp, uid, mode)
118#define	KDTRACE_NFS_ACCESSCACHE_LOAD_DONE(vp, uid, rmode, error)
119
120#define	KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(vp)
121#define	KDTRACE_NFS_ATTRCACHE_GET_HIT(vp, vap)
122#define	KDTRACE_NFS_ATTRCACHE_GET_MISS(vp)
123#define	KDTRACE_NFS_ATTRCACHE_LOAD_DONE(vp, vap, error)
124
125#endif /* KDTRACE_HOOKS */
126
127#endif /* !_NFSCL_NFS_KDTRACE_H_ */
128