Commit | Line | Data |
---|---|---|
1c8284eb MD |
1 | /* |
2 | * ltt/probes/fs-trace.c | |
3 | * | |
4 | * FS tracepoint probes. | |
5 | * | |
6 | * (C) Copyright 2009 - Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> | |
7 | * Dual LGPL v2.1/GPL v2 license. | |
8 | */ | |
9 | ||
10 | #include <linux/module.h> | |
11 | #include <linux/buffer_head.h> | |
12 | #include <trace/fs.h> | |
13 | ||
14 | #include "../ltt-type-serializer.h" | |
15 | ||
16 | void probe_fs_buffer_wait_start(void *_data, struct buffer_head *bh) | |
17 | { | |
18 | trace_mark_tp(fs, buffer_wait_start, fs_buffer_wait_start, | |
19 | probe_fs_buffer_wait_start, "bh %p", bh); | |
20 | } | |
21 | ||
22 | void probe_fs_buffer_wait_end(void *_data, struct buffer_head *bh) | |
23 | { | |
24 | trace_mark_tp(fs, buffer_wait_end, fs_buffer_wait_end, | |
25 | probe_fs_buffer_wait_end, "bh %p", bh); | |
26 | } | |
27 | ||
28 | void probe_fs_exec(void *_data, char *filename) | |
29 | { | |
30 | trace_mark_tp(fs, exec, fs_exec, probe_fs_exec, "filename %s", | |
31 | filename); | |
32 | } | |
33 | ||
34 | void probe_fs_ioctl(void *_data, unsigned int fd, unsigned int cmd, unsigned long arg) | |
35 | { | |
36 | trace_mark_tp(fs, ioctl, fs_ioctl, probe_fs_ioctl, | |
37 | "fd %u cmd %u arg %lu", fd, cmd, arg); | |
38 | } | |
39 | ||
40 | void probe_fs_open(void *_data, int fd, char *filename) | |
41 | { | |
42 | trace_mark_tp(fs, open, fs_open, probe_fs_open, | |
43 | "fd %d filename %s", fd, filename); | |
44 | } | |
45 | ||
46 | void probe_fs_close(void *_data, unsigned int fd) | |
47 | { | |
48 | trace_mark_tp(fs, close, fs_close, probe_fs_close, "fd %u", fd); | |
49 | } | |
50 | ||
51 | void probe_fs_lseek(void *_data, unsigned int fd, long offset, unsigned int origin) | |
52 | { | |
53 | trace_mark_tp(fs, lseek, fs_lseek, probe_fs_lseek, | |
54 | "fd %u offset %ld origin %u", fd, offset, origin); | |
55 | } | |
56 | ||
57 | void probe_fs_llseek(void *_data, unsigned int fd, loff_t offset, unsigned int origin) | |
58 | { | |
59 | trace_mark_tp(fs, llseek, fs_llseek, probe_fs_llseek, | |
60 | "fd %u offset %lld origin %u", fd, | |
61 | (long long)offset, origin); | |
62 | } | |
63 | ||
64 | void probe_fs_read(void *_data, unsigned int fd, char __user *buf, size_t count, | |
65 | ssize_t ret); | |
66 | ||
67 | DEFINE_MARKER_TP(fs, read, fs_read, probe_fs_read, | |
68 | "count %zu fd %u"); | |
69 | ||
70 | notrace void probe_fs_read(void *_data, unsigned int fd, char __user *buf, size_t count, | |
71 | ssize_t ret) | |
72 | { | |
73 | struct marker *marker; | |
74 | struct serialize_sizet_int data; | |
75 | ||
76 | data.f1 = count; | |
77 | data.f2 = fd; | |
78 | ||
79 | marker = &GET_MARKER(fs, read); | |
80 | ltt_specialized_trace(marker, marker->single.probe_private, | |
81 | &data, serialize_sizeof(data), sizeof(size_t)); | |
82 | } | |
83 | ||
84 | void probe_fs_write(void *_data, unsigned int fd, char __user *buf, size_t count, | |
85 | ssize_t ret); | |
86 | ||
87 | DEFINE_MARKER_TP(fs, write, fs_write, probe_fs_write, | |
88 | "count %zu fd %u"); | |
89 | ||
90 | notrace void probe_fs_write(void *_data, unsigned int fd, char __user *buf, size_t count, | |
91 | ssize_t ret) | |
92 | { | |
93 | struct marker *marker; | |
94 | struct serialize_sizet_int data; | |
95 | ||
96 | data.f1 = count; | |
97 | data.f2 = fd; | |
98 | ||
99 | marker = &GET_MARKER(fs, write); | |
100 | ltt_specialized_trace(marker, marker->single.probe_private, | |
101 | &data, serialize_sizeof(data), sizeof(size_t)); | |
102 | } | |
103 | ||
104 | void probe_fs_pread64(void *_data, unsigned int fd, char __user *buf, size_t count, | |
105 | loff_t pos, ssize_t ret) | |
106 | { | |
107 | trace_mark_tp(fs, pread64, fs_pread64, probe_fs_pread64, | |
108 | "fd %u count %zu pos %llu", | |
109 | fd, count, (unsigned long long)pos); | |
110 | } | |
111 | ||
112 | void probe_fs_pwrite64(void *_data, unsigned int fd, const char __user *buf, | |
113 | size_t count, loff_t pos, ssize_t ret) | |
114 | { | |
115 | trace_mark_tp(fs, pwrite64, fs_pwrite64, probe_fs_pwrite64, | |
116 | "fd %u count %zu pos %llu", | |
117 | fd, count, (unsigned long long)pos); | |
118 | } | |
119 | ||
120 | void probe_fs_readv(void *_data, unsigned long fd, const struct iovec __user *vec, | |
121 | unsigned long vlen, ssize_t ret) | |
122 | { | |
123 | trace_mark_tp(fs, readv, fs_readv, probe_fs_readv, | |
124 | "fd %lu vlen %lu", fd, vlen); | |
125 | } | |
126 | ||
127 | void probe_fs_writev(void *_data, unsigned long fd, const struct iovec __user *vec, | |
128 | unsigned long vlen, ssize_t ret) | |
129 | { | |
130 | trace_mark_tp(fs, writev, fs_writev, probe_fs_writev, | |
131 | "fd %lu vlen %lu", fd, vlen); | |
132 | } | |
133 | ||
134 | void probe_fs_select(void *_data, int fd, struct timespec *end_time) | |
135 | { | |
136 | struct timespec tmptime; | |
137 | ||
138 | if (end_time) { | |
139 | tmptime = *end_time; | |
140 | } else { | |
141 | tmptime.tv_sec = -1L; | |
142 | tmptime.tv_nsec = -1L; | |
143 | } | |
144 | ||
145 | trace_mark_tp(fs, select, fs_select, probe_fs_select, | |
146 | "fd %d end_time_sec %ld end_time_nsec %ld", fd, | |
147 | tmptime.tv_sec, tmptime.tv_nsec); | |
148 | } | |
149 | ||
150 | void probe_fs_poll(void *_data, int fd) | |
151 | { | |
152 | trace_mark_tp(fs, pollfd, fs_poll, probe_fs_poll, | |
153 | "fd %d", fd); | |
154 | } | |
155 | ||
156 | MODULE_LICENSE("GPL and additional rights"); | |
157 | MODULE_AUTHOR("Mathieu Desnoyers"); | |
158 | MODULE_DESCRIPTION("FS Tracepoint Probes"); |