xref: /freebsd/sys/contrib/openzfs/include/os/linux/zfs/sys/trace_acl.h (revision 61145dc2b94f12f6a47344fb9aac702321880e43)
1 // SPDX-License-Identifier: CDDL-1.0
2 /*
3  * CDDL HEADER START
4  *
5  * The contents of this file are subject to the terms of the
6  * Common Development and Distribution License (the "License").
7  * You may not use this file except in compliance with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or https://opensource.org/licenses/CDDL-1.0.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 
23 #if defined(_KERNEL)
24 #if defined(HAVE_DECLARE_EVENT_CLASS)
25 
26 #undef TRACE_SYSTEM
27 #define	TRACE_SYSTEM zfs
28 
29 #undef TRACE_SYSTEM_VAR
30 #define	TRACE_SYSTEM_VAR zfs_acl
31 
32 #if !defined(_TRACE_ACL_H) || defined(TRACE_HEADER_MULTI_READ)
33 #define	_TRACE_ACL_H
34 
35 #include <linux/tracepoint.h>
36 #include <linux/vfs_compat.h>
37 #include <sys/types.h>
38 
39 /*
40  * Generic support for three argument tracepoints of the form:
41  *
42  * DTRACE_PROBE3(...,
43  *     znode_t *, ...,
44  *     zfs_ace_hdr_t *, ...,
45  *     uint32_t, ...);
46  */
47 /* BEGIN CSTYLED */
48 DECLARE_EVENT_CLASS(zfs_ace_class,
49 	TP_PROTO(znode_t *zn, zfs_ace_hdr_t *ace, uint32_t mask_matched),
50 	TP_ARGS(zn, ace, mask_matched),
51 	TP_STRUCT__entry(
52 	    __field(uint64_t,		z_id)
53 	    __field(uint8_t,		z_unlinked)
54 	    __field(uint8_t,		z_atime_dirty)
55 	    __field(uint8_t,		z_zn_prefetch)
56 	    __field(uint_t,		z_blksz)
57 	    __field(uint_t,		z_seq)
58 	    __field(uint64_t,		z_mapcnt)
59 	    __field(uint64_t,		z_size)
60 	    __field(uint64_t,		z_pflags)
61 	    __field(uint32_t,		z_sync_cnt)
62 	    __field(uint32_t,		z_sync_writes_cnt)
63 	    __field(uint32_t,		z_async_writes_cnt)
64 	    __field(mode_t,		z_mode)
65 	    __field(boolean_t,		z_is_sa)
66 	    __field(boolean_t,		z_is_ctldir)
67 
68 	    __field(uint32_t,		i_uid)
69 	    __field(uint32_t,		i_gid)
70 	    __field(unsigned long,	i_ino)
71 	    __field(unsigned int,	i_nlink)
72 	    __field(loff_t,		i_size)
73 	    __field(unsigned int,	i_blkbits)
74 	    __field(unsigned short,	i_bytes)
75 	    __field(umode_t,		i_mode)
76 	    __field(__u32,		i_generation)
77 
78 	    __field(uint16_t,		z_type)
79 	    __field(uint16_t,		z_flags)
80 	    __field(uint32_t,		z_access_mask)
81 
82 	    __field(uint32_t,		mask_matched)
83 	),
84 	TP_fast_assign(
85 	    __entry->z_id		= zn->z_id;
86 	    __entry->z_unlinked		= zn->z_unlinked;
87 	    __entry->z_atime_dirty	= zn->z_atime_dirty;
88 	    __entry->z_zn_prefetch	= zn->z_zn_prefetch;
89 	    __entry->z_blksz		= zn->z_blksz;
90 	    __entry->z_seq		= zn->z_seq;
91 	    __entry->z_mapcnt		= zn->z_mapcnt;
92 	    __entry->z_size		= zn->z_size;
93 	    __entry->z_pflags		= zn->z_pflags;
94 	    __entry->z_sync_cnt		= zn->z_sync_cnt;
95 	    __entry->z_sync_writes_cnt	= zn->z_sync_writes_cnt;
96 	    __entry->z_async_writes_cnt	= zn->z_async_writes_cnt;
97 	    __entry->z_mode		= zn->z_mode;
98 	    __entry->z_is_sa		= zn->z_is_sa;
99 	    __entry->z_is_ctldir	= zn->z_is_ctldir;
100 
101 	    __entry->i_uid		= KUID_TO_SUID(ZTOI(zn)->i_uid);
102 	    __entry->i_gid		= KGID_TO_SGID(ZTOI(zn)->i_gid);
103 	    __entry->i_ino		= zn->z_inode.i_ino;
104 	    __entry->i_nlink		= zn->z_inode.i_nlink;
105 	    __entry->i_size		= zn->z_inode.i_size;
106 	    __entry->i_blkbits		= zn->z_inode.i_blkbits;
107 	    __entry->i_bytes		= zn->z_inode.i_bytes;
108 	    __entry->i_mode		= zn->z_inode.i_mode;
109 	    __entry->i_generation	= zn->z_inode.i_generation;
110 
111 	    __entry->z_type		= ace->z_type;
112 	    __entry->z_flags		= ace->z_flags;
113 	    __entry->z_access_mask	= ace->z_access_mask;
114 
115 	    __entry->mask_matched	= mask_matched;
116 	),
117 	TP_printk("zn { id %llu unlinked %u atime_dirty %u "
118 	    "zn_prefetch %u blksz %u seq %u "
119 	    "mapcnt %llu size %llu pflags %llu "
120 	    "sync_cnt %u sync_writes_cnt %u async_writes_cnt %u "
121 	    "mode 0x%x is_sa %d is_ctldir %d "
122 	    "inode { uid %u gid %u ino %lu nlink %u size %lli "
123 	    "blkbits %u bytes %u mode 0x%x generation %x } } "
124 	    "ace { type %u flags %u access_mask %u } mask_matched %u",
125 	    __entry->z_id, __entry->z_unlinked, __entry->z_atime_dirty,
126 	    __entry->z_zn_prefetch, __entry->z_blksz,
127 	    __entry->z_seq, __entry->z_mapcnt, __entry->z_size,
128 	    __entry->z_pflags, __entry->z_sync_cnt,
129 	    __entry->z_sync_writes_cnt, __entry->z_async_writes_cnt,
130 	    __entry->z_mode, __entry->z_is_sa, __entry->z_is_ctldir,
131 	    __entry->i_uid, __entry->i_gid, __entry->i_ino, __entry->i_nlink,
132 	    __entry->i_size, __entry->i_blkbits,
133 	    __entry->i_bytes, __entry->i_mode, __entry->i_generation,
134 	    __entry->z_type, __entry->z_flags, __entry->z_access_mask,
135 	    __entry->mask_matched)
136 );
137 /* END CSTYLED */
138 
139 #define	DEFINE_ACE_EVENT(name) \
140 DEFINE_EVENT(zfs_ace_class, name, \
141     TP_PROTO(znode_t *zn, zfs_ace_hdr_t *ace, uint32_t mask_matched), \
142     TP_ARGS(zn, ace, mask_matched))
143 DEFINE_ACE_EVENT(zfs_zfs__ace__denies);
144 DEFINE_ACE_EVENT(zfs_zfs__ace__allows);
145 
146 #endif /* _TRACE_ACL_H */
147 
148 #undef TRACE_INCLUDE_PATH
149 #undef TRACE_INCLUDE_FILE
150 #define	TRACE_INCLUDE_PATH sys
151 #define	TRACE_INCLUDE_FILE trace_acl
152 #include <trace/define_trace.h>
153 
154 #else
155 
156 DEFINE_DTRACE_PROBE3(zfs__ace__denies);
157 DEFINE_DTRACE_PROBE3(zfs__ace__allows);
158 DEFINE_DTRACE_PROBE(zfs__fastpath__execute__access__miss);
159 
160 #endif /* HAVE_DECLARE_EVENT_CLASS */
161 #endif /* _KERNEL */
162