blob: 6331cd29880d64e447d73be8dc73d7797b7c1912 [file] [log] [blame]
David Howells77443f62021-11-26 14:32:29 +00001/* SPDX-License-Identifier: GPL-2.0-or-later */
2/* CacheFiles tracepoints
3 *
4 * Copyright (C) 2021 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
6 */
7#undef TRACE_SYSTEM
8#define TRACE_SYSTEM cachefiles
9
10#if !defined(_TRACE_CACHEFILES_H) || defined(TRACE_HEADER_MULTI_READ)
11#define _TRACE_CACHEFILES_H
12
13#include <linux/tracepoint.h>
14
15/*
16 * Define enums for tracing information.
17 */
18#ifndef __CACHEFILES_DECLARE_TRACE_ENUMS_ONCE_ONLY
19#define __CACHEFILES_DECLARE_TRACE_ENUMS_ONCE_ONLY
20
David Howellsecf5a6c2021-10-21 08:42:18 +010021enum cachefiles_error_trace {
22 cachefiles_trace_fallocate_error,
23 cachefiles_trace_getxattr_error,
24 cachefiles_trace_link_error,
25 cachefiles_trace_lookup_error,
26 cachefiles_trace_mkdir_error,
27 cachefiles_trace_notify_change_error,
28 cachefiles_trace_open_error,
29 cachefiles_trace_read_error,
30 cachefiles_trace_remxattr_error,
31 cachefiles_trace_rename_error,
32 cachefiles_trace_seek_error,
33 cachefiles_trace_setxattr_error,
34 cachefiles_trace_statfs_error,
35 cachefiles_trace_tmpfile_error,
36 cachefiles_trace_trunc_error,
37 cachefiles_trace_unlink_error,
38 cachefiles_trace_write_error,
39};
40
David Howells77443f62021-11-26 14:32:29 +000041#endif
42
43/*
44 * Define enum -> string mappings for display.
45 */
David Howellsecf5a6c2021-10-21 08:42:18 +010046#define cachefiles_error_traces \
47 EM(cachefiles_trace_fallocate_error, "fallocate") \
48 EM(cachefiles_trace_getxattr_error, "getxattr") \
49 EM(cachefiles_trace_link_error, "link") \
50 EM(cachefiles_trace_lookup_error, "lookup") \
51 EM(cachefiles_trace_mkdir_error, "mkdir") \
52 EM(cachefiles_trace_notify_change_error, "notify_change") \
53 EM(cachefiles_trace_open_error, "open") \
54 EM(cachefiles_trace_read_error, "read") \
55 EM(cachefiles_trace_remxattr_error, "remxattr") \
56 EM(cachefiles_trace_rename_error, "rename") \
57 EM(cachefiles_trace_seek_error, "seek") \
58 EM(cachefiles_trace_setxattr_error, "setxattr") \
59 EM(cachefiles_trace_statfs_error, "statfs") \
60 EM(cachefiles_trace_tmpfile_error, "tmpfile") \
61 EM(cachefiles_trace_trunc_error, "trunc") \
62 EM(cachefiles_trace_unlink_error, "unlink") \
63 E_(cachefiles_trace_write_error, "write")
David Howells77443f62021-11-26 14:32:29 +000064
65
66/*
67 * Export enum symbols via userspace.
68 */
69#undef EM
70#undef E_
71#define EM(a, b) TRACE_DEFINE_ENUM(a);
72#define E_(a, b) TRACE_DEFINE_ENUM(a);
73
David Howellsecf5a6c2021-10-21 08:42:18 +010074cachefiles_error_traces;
75
David Howells77443f62021-11-26 14:32:29 +000076/*
77 * Now redefine the EM() and E_() macros to map the enums to the strings that
78 * will be printed in the output.
79 */
80#undef EM
81#undef E_
82#define EM(a, b) { a, b },
83#define E_(a, b) { a, b }
84
85
David Howells1bd9c4e2021-11-18 08:58:08 +000086TRACE_EVENT(cachefiles_mark_active,
87 TP_PROTO(struct cachefiles_object *obj,
88 struct inode *inode),
89
90 TP_ARGS(obj, inode),
91
92 /* Note that obj may be NULL */
93 TP_STRUCT__entry(
94 __field(unsigned int, obj )
95 __field(ino_t, inode )
96 ),
97
98 TP_fast_assign(
99 __entry->obj = obj ? obj->debug_id : 0;
100 __entry->inode = inode->i_ino;
101 ),
102
103 TP_printk("o=%08x i=%lx",
104 __entry->obj, __entry->inode)
105 );
106
107TRACE_EVENT(cachefiles_mark_inactive,
108 TP_PROTO(struct cachefiles_object *obj,
109 struct inode *inode),
110
111 TP_ARGS(obj, inode),
112
113 /* Note that obj may be NULL */
114 TP_STRUCT__entry(
115 __field(unsigned int, obj )
116 __field(ino_t, inode )
117 ),
118
119 TP_fast_assign(
120 __entry->obj = obj ? obj->debug_id : 0;
121 __entry->inode = inode->i_ino;
122 ),
123
124 TP_printk("o=%08x i=%lx",
125 __entry->obj, __entry->inode)
126 );
127
David Howellsecf5a6c2021-10-21 08:42:18 +0100128TRACE_EVENT(cachefiles_vfs_error,
129 TP_PROTO(struct cachefiles_object *obj, struct inode *backer,
130 int error, enum cachefiles_error_trace where),
131
132 TP_ARGS(obj, backer, error, where),
133
134 TP_STRUCT__entry(
135 __field(unsigned int, obj )
136 __field(unsigned int, backer )
137 __field(enum cachefiles_error_trace, where )
138 __field(short, error )
139 ),
140
141 TP_fast_assign(
142 __entry->obj = obj ? obj->debug_id : 0;
143 __entry->backer = backer->i_ino;
144 __entry->error = error;
145 __entry->where = where;
146 ),
147
148 TP_printk("o=%08x b=%08x %s e=%d",
149 __entry->obj,
150 __entry->backer,
151 __print_symbolic(__entry->where, cachefiles_error_traces),
152 __entry->error)
153 );
154
155TRACE_EVENT(cachefiles_io_error,
156 TP_PROTO(struct cachefiles_object *obj, struct inode *backer,
157 int error, enum cachefiles_error_trace where),
158
159 TP_ARGS(obj, backer, error, where),
160
161 TP_STRUCT__entry(
162 __field(unsigned int, obj )
163 __field(unsigned int, backer )
164 __field(enum cachefiles_error_trace, where )
165 __field(short, error )
166 ),
167
168 TP_fast_assign(
169 __entry->obj = obj ? obj->debug_id : 0;
170 __entry->backer = backer->i_ino;
171 __entry->error = error;
172 __entry->where = where;
173 ),
174
175 TP_printk("o=%08x b=%08x %s e=%d",
176 __entry->obj,
177 __entry->backer,
178 __print_symbolic(__entry->where, cachefiles_error_traces),
179 __entry->error)
180 );
181
David Howells77443f62021-11-26 14:32:29 +0000182#endif /* _TRACE_CACHEFILES_H */
183
184/* This part must be outside protection */
185#include <trace/define_trace.h>