Commit | Line | Data |
---|---|---|
9f36eaed | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
f62b389e MD |
2 | #undef TRACE_SYSTEM |
3 | #define TRACE_SYSTEM block | |
4 | ||
3bc29f0a MD |
5 | #if !defined(LTTNG_TRACE_BLOCK_H) || defined(TRACE_HEADER_MULTI_READ) |
6 | #define LTTNG_TRACE_BLOCK_H | |
f62b389e | 7 | |
6ec43db8 | 8 | #include <probes/lttng-tracepoint-event.h> |
f62b389e MD |
9 | #include <linux/blktrace_api.h> |
10 | #include <linux/blkdev.h> | |
f62b389e | 11 | #include <linux/trace_seq.h> |
7c68b363 AG |
12 | #include <linux/version.h> |
13 | ||
8a9f549f FD |
14 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) |
15 | #include <scsi/scsi_request.h> | |
16 | #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */ | |
17 | ||
f62b389e MD |
18 | #ifndef _TRACE_BLOCK_DEF_ |
19 | #define _TRACE_BLOCK_DEF_ | |
20 | ||
f62b389e MD |
21 | enum { |
22 | RWBS_FLAG_WRITE = (1 << 0), | |
23 | RWBS_FLAG_DISCARD = (1 << 1), | |
24 | RWBS_FLAG_READ = (1 << 2), | |
25 | RWBS_FLAG_RAHEAD = (1 << 3), | |
7c68b363 AG |
26 | RWBS_FLAG_BARRIER = (1 << 4), |
27 | RWBS_FLAG_SYNC = (1 << 5), | |
28 | RWBS_FLAG_META = (1 << 6), | |
29 | RWBS_FLAG_SECURE = (1 << 7), | |
30 | RWBS_FLAG_FLUSH = (1 << 8), | |
31 | RWBS_FLAG_FUA = (1 << 9), | |
e6d2cc09 | 32 | RWBS_FLAG_PREFLUSH = (1 << 10), |
f62b389e MD |
33 | }; |
34 | ||
35 | #endif /* _TRACE_BLOCK_DEF_ */ | |
36 | ||
d5e97fbf | 37 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,8,0) || \ |
0badc02f MJ |
38 | LTTNG_SLE_KERNEL_RANGE(4,4,73,5,0,0, 4,4,73,6,0,0) || \ |
39 | LTTNG_SLE_KERNEL_RANGE(4,4,82,6,0,0, 4,4,82,7,0,0) || \ | |
40 | LTTNG_SLE_KERNEL_RANGE(4,4,92,6,0,0, 4,4,92,7,0,0) || \ | |
41 | LTTNG_SLE_KERNEL_RANGE(4,4,103,6,0,0, 4,4,103,7,0,0) || \ | |
42 | LTTNG_SLE_KERNEL_RANGE(4,4,114,94,0,0, 4,4,114,95,0,0) || \ | |
43 | LTTNG_SLE_KERNEL_RANGE(4,4,120,94,0,0, 4,4,120,95,0,0) || \ | |
44 | LTTNG_SLE_KERNEL_RANGE(4,4,126,94,0,0, 4,5,0,0,0,0)) | |
e6d2cc09 MD |
45 | |
46 | #define lttng_req_op(rq) req_op(rq) | |
47 | #define lttng_req_rw(rq) ((rq)->cmd_flags) | |
48 | #define lttng_bio_op(bio) bio_op(bio) | |
49 | #define lttng_bio_rw(bio) ((bio)->bi_opf) | |
50 | ||
51 | #define blk_rwbs_ctf_integer(type, rwbs, op, rw, bytes) \ | |
52 | ctf_integer(type, rwbs, \ | |
53 | (((op) == REQ_OP_WRITE || (op) == REQ_OP_WRITE_SAME) ? RWBS_FLAG_WRITE : \ | |
54 | ( (op) == REQ_OP_DISCARD ? RWBS_FLAG_DISCARD : \ | |
55 | ( (op) == REQ_OP_SECURE_ERASE ? (RWBS_FLAG_DISCARD | RWBS_FLAG_SECURE) : \ | |
56 | ( (op) == REQ_OP_FLUSH ? RWBS_FLAG_FLUSH : \ | |
57 | ( (op) == REQ_OP_READ ? RWBS_FLAG_READ : \ | |
58 | ( 0 )))))) \ | |
59 | | ((rw) & REQ_RAHEAD ? RWBS_FLAG_RAHEAD : 0) \ | |
60 | | ((rw) & REQ_SYNC ? RWBS_FLAG_SYNC : 0) \ | |
61 | | ((rw) & REQ_META ? RWBS_FLAG_META : 0) \ | |
62 | | ((rw) & REQ_PREFLUSH ? RWBS_FLAG_PREFLUSH : 0) \ | |
63 | | ((rw) & REQ_FUA ? RWBS_FLAG_FUA : 0)) | |
64 | ||
65 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)) | |
7c68b363 | 66 | |
e6d2cc09 MD |
67 | #define lttng_req_op(rq) |
68 | #define lttng_req_rw(rq) ((rq)->cmd_flags) | |
69 | #define lttng_bio_op(bio) | |
70 | #define lttng_bio_rw(bio) ((bio)->bi_rw) | |
71 | ||
72 | #define blk_rwbs_ctf_integer(type, rwbs, op, rw, bytes) \ | |
f127e61e | 73 | ctf_integer(type, rwbs, ((rw) & WRITE ? RWBS_FLAG_WRITE : \ |
7c68b363 AG |
74 | ( (rw) & REQ_DISCARD ? RWBS_FLAG_DISCARD : \ |
75 | ( (bytes) ? RWBS_FLAG_READ : \ | |
76 | ( 0 )))) \ | |
77 | | ((rw) & REQ_RAHEAD ? RWBS_FLAG_RAHEAD : 0) \ | |
78 | | ((rw) & REQ_SYNC ? RWBS_FLAG_SYNC : 0) \ | |
79 | | ((rw) & REQ_META ? RWBS_FLAG_META : 0) \ | |
80 | | ((rw) & REQ_SECURE ? RWBS_FLAG_SECURE : 0) \ | |
81 | | ((rw) & REQ_FLUSH ? RWBS_FLAG_FLUSH : 0) \ | |
82 | | ((rw) & REQ_FUA ? RWBS_FLAG_FUA : 0)) | |
83 | ||
84 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) | |
85 | ||
e6d2cc09 MD |
86 | #define lttng_req_op(rq) |
87 | #define lttng_req_rw(rq) ((rq)->cmd_flags) | |
88 | #define lttng_bio_op(bio) | |
89 | #define lttng_bio_rw(bio) ((bio)->bi_rw) | |
90 | ||
91 | #define blk_rwbs_ctf_integer(type, rwbs, op, rw, bytes) \ | |
f127e61e | 92 | ctf_integer(type, rwbs, ((rw) & WRITE ? RWBS_FLAG_WRITE : \ |
f62b389e MD |
93 | ( (rw) & REQ_DISCARD ? RWBS_FLAG_DISCARD : \ |
94 | ( (bytes) ? RWBS_FLAG_READ : \ | |
95 | ( 0 )))) \ | |
96 | | ((rw) & REQ_RAHEAD ? RWBS_FLAG_RAHEAD : 0) \ | |
97 | | ((rw) & REQ_SYNC ? RWBS_FLAG_SYNC : 0) \ | |
98 | | ((rw) & REQ_META ? RWBS_FLAG_META : 0) \ | |
99 | | ((rw) & REQ_SECURE ? RWBS_FLAG_SECURE : 0)) | |
100 | ||
7c68b363 AG |
101 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) |
102 | ||
e6d2cc09 MD |
103 | #define lttng_req_op(rq) |
104 | #define lttng_req_rw(rq) ((rq)->cmd_flags) | |
105 | #define lttng_bio_op(bio) | |
106 | #define lttng_bio_rw(bio) ((bio)->bi_rw) | |
107 | ||
108 | #define blk_rwbs_ctf_integer(type, rwbs, op, rw, bytes) \ | |
f127e61e | 109 | ctf_integer(type, rwbs, ((rw) & WRITE ? RWBS_FLAG_WRITE : \ |
7c68b363 AG |
110 | ( (rw) & REQ_DISCARD ? RWBS_FLAG_DISCARD : \ |
111 | ( (bytes) ? RWBS_FLAG_READ : \ | |
112 | ( 0 )))) \ | |
113 | | ((rw) & REQ_RAHEAD ? RWBS_FLAG_RAHEAD : 0) \ | |
114 | | ((rw) & REQ_HARDBARRIER ? RWBS_FLAG_BARRIER : 0) \ | |
115 | | ((rw) & REQ_SYNC ? RWBS_FLAG_SYNC : 0) \ | |
116 | | ((rw) & REQ_META ? RWBS_FLAG_META : 0) \ | |
117 | | ((rw) & REQ_SECURE ? RWBS_FLAG_SECURE : 0)) | |
118 | ||
119 | #else | |
120 | ||
e6d2cc09 MD |
121 | #define lttng_req_op(rq) |
122 | #define lttng_req_rw(rq) ((rq)->cmd_flags) | |
123 | #define lttng_bio_op(bio) | |
124 | #define lttng_bio_rw(bio) ((bio)->bi_rw) | |
125 | ||
126 | #define blk_rwbs_ctf_integer(type, rwbs, op, rw, bytes) \ | |
f127e61e | 127 | ctf_integer(type, rwbs, ((rw) & WRITE ? RWBS_FLAG_WRITE : \ |
7c68b363 AG |
128 | ( (rw) & (1 << BIO_RW_DISCARD) ? RWBS_FLAG_DISCARD : \ |
129 | ( (bytes) ? RWBS_FLAG_READ : \ | |
130 | ( 0 )))) \ | |
131 | | ((rw) & (1 << BIO_RW_AHEAD) ? RWBS_FLAG_RAHEAD : 0) \ | |
132 | | ((rw) & (1 << BIO_RW_SYNCIO) ? RWBS_FLAG_SYNC : 0) \ | |
133 | | ((rw) & (1 << BIO_RW_META) ? RWBS_FLAG_META : 0) \ | |
134 | | ((rw) & (1 << BIO_RW_BARRIER) ? RWBS_FLAG_BARRIER : 0)) | |
135 | ||
136 | #endif | |
137 | ||
217f66c6 | 138 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) |
3bc29f0a | 139 | LTTNG_TRACEPOINT_EVENT_CLASS(block_buffer, |
217f66c6 MD |
140 | |
141 | TP_PROTO(struct buffer_head *bh), | |
142 | ||
143 | TP_ARGS(bh), | |
144 | ||
f127e61e MD |
145 | TP_FIELDS ( |
146 | ctf_integer(dev_t, dev, bh->b_bdev->bd_dev) | |
147 | ctf_integer(sector_t, sector, bh->b_blocknr) | |
148 | ctf_integer(size_t, size, bh->b_size) | |
217f66c6 MD |
149 | ) |
150 | ) | |
151 | ||
152 | /** | |
153 | * block_touch_buffer - mark a buffer accessed | |
154 | * @bh: buffer_head being touched | |
155 | * | |
156 | * Called from touch_buffer(). | |
157 | */ | |
3bc29f0a | 158 | LTTNG_TRACEPOINT_EVENT_INSTANCE(block_buffer, block_touch_buffer, |
217f66c6 MD |
159 | |
160 | TP_PROTO(struct buffer_head *bh), | |
161 | ||
162 | TP_ARGS(bh) | |
163 | ) | |
164 | ||
165 | /** | |
166 | * block_dirty_buffer - mark a buffer dirty | |
167 | * @bh: buffer_head being dirtied | |
168 | * | |
169 | * Called from mark_buffer_dirty(). | |
170 | */ | |
3bc29f0a | 171 | LTTNG_TRACEPOINT_EVENT_INSTANCE(block_buffer, block_dirty_buffer, |
217f66c6 MD |
172 | |
173 | TP_PROTO(struct buffer_head *bh), | |
174 | ||
175 | TP_ARGS(bh) | |
176 | ) | |
177 | #endif | |
178 | ||
d2457078 MJ |
179 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0)) |
180 | /* block_rq_with_error event class removed in kernel 4.12 */ | |
181 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) | |
f127e61e | 182 | LTTNG_TRACEPOINT_EVENT_CLASS_CODE(block_rq_with_error, |
f62b389e MD |
183 | |
184 | TP_PROTO(struct request_queue *q, struct request *rq), | |
185 | ||
186 | TP_ARGS(q, rq), | |
187 | ||
f127e61e MD |
188 | TP_locvar( |
189 | sector_t sector; | |
190 | unsigned int nr_sector; | |
191 | unsigned char *cmd; | |
192 | size_t cmd_len; | |
f62b389e MD |
193 | ), |
194 | ||
265822ae | 195 | TP_code_pre( |
8a9f549f FD |
196 | if (blk_rq_is_scsi(rq)) { |
197 | struct scsi_request *scsi_rq = scsi_req(rq); | |
198 | tp_locvar->sector = 0; | |
199 | tp_locvar->nr_sector = 0; | |
200 | tp_locvar->cmd = scsi_rq->cmd; | |
201 | tp_locvar->cmd_len = scsi_rq->cmd_len; | |
202 | } else { | |
203 | tp_locvar->sector = blk_rq_pos(rq); | |
204 | tp_locvar->nr_sector = blk_rq_sectors(rq); | |
205 | tp_locvar->cmd = NULL; | |
206 | tp_locvar->cmd_len = 0; | |
207 | } | |
208 | ), | |
209 | ||
210 | TP_FIELDS( | |
211 | ctf_integer(dev_t, dev, | |
212 | rq->rq_disk ? disk_devt(rq->rq_disk) : 0) | |
213 | ctf_integer(sector_t, sector, tp_locvar->sector) | |
214 | ctf_integer(unsigned int, nr_sector, tp_locvar->nr_sector) | |
215 | ctf_integer(int, errors, rq->errors) | |
216 | blk_rwbs_ctf_integer(unsigned int, rwbs, | |
217 | lttng_req_op(rq), lttng_req_rw(rq), blk_rq_bytes(rq)) | |
218 | ctf_sequence_hex(unsigned char, cmd, | |
219 | tp_locvar->cmd, size_t, tp_locvar->cmd_len) | |
220 | ), | |
221 | ||
222 | TP_code_post() | |
223 | ) | |
224 | #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */ | |
225 | LTTNG_TRACEPOINT_EVENT_CLASS_CODE(block_rq_with_error, | |
226 | ||
227 | TP_PROTO(struct request_queue *q, struct request *rq), | |
228 | ||
229 | TP_ARGS(q, rq), | |
230 | ||
231 | TP_locvar( | |
232 | sector_t sector; | |
233 | unsigned int nr_sector; | |
234 | unsigned char *cmd; | |
235 | size_t cmd_len; | |
236 | ), | |
237 | ||
238 | TP_code_pre( | |
239 | ||
f127e61e MD |
240 | if (rq->cmd_type == REQ_TYPE_BLOCK_PC) { |
241 | tp_locvar->sector = 0; | |
242 | tp_locvar->nr_sector = 0; | |
243 | tp_locvar->cmd = rq->cmd; | |
244 | tp_locvar->cmd_len = rq->cmd_len; | |
245 | } else { | |
246 | tp_locvar->sector = blk_rq_pos(rq); | |
247 | tp_locvar->nr_sector = blk_rq_sectors(rq); | |
248 | tp_locvar->cmd = NULL; | |
249 | tp_locvar->cmd_len = 0; | |
250 | } | |
f62b389e MD |
251 | ), |
252 | ||
f127e61e MD |
253 | TP_FIELDS( |
254 | ctf_integer(dev_t, dev, | |
255 | rq->rq_disk ? disk_devt(rq->rq_disk) : 0) | |
256 | ctf_integer(sector_t, sector, tp_locvar->sector) | |
257 | ctf_integer(unsigned int, nr_sector, tp_locvar->nr_sector) | |
258 | ctf_integer(int, errors, rq->errors) | |
259 | blk_rwbs_ctf_integer(unsigned int, rwbs, | |
e6d2cc09 | 260 | lttng_req_op(rq), lttng_req_rw(rq), blk_rq_bytes(rq)) |
f127e61e MD |
261 | ctf_sequence_hex(unsigned char, cmd, |
262 | tp_locvar->cmd, size_t, tp_locvar->cmd_len) | |
265822ae MD |
263 | ), |
264 | ||
265 | TP_code_post() | |
f62b389e | 266 | ) |
8a9f549f | 267 | #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */ |
f62b389e | 268 | |
d2457078 | 269 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4,12,0)) |
f62b389e MD |
270 | /** |
271 | * block_rq_abort - abort block operation request | |
272 | * @q: queue containing the block operation request | |
273 | * @rq: block IO operation request | |
274 | * | |
275 | * Called immediately after pending block IO operation request @rq in | |
276 | * queue @q is aborted. The fields in the operation request @rq | |
277 | * can be examined to determine which device and sectors the pending | |
278 | * operation would access. | |
279 | */ | |
3bc29f0a | 280 | LTTNG_TRACEPOINT_EVENT_INSTANCE(block_rq_with_error, block_rq_abort, |
f62b389e MD |
281 | |
282 | TP_PROTO(struct request_queue *q, struct request *rq), | |
283 | ||
284 | TP_ARGS(q, rq) | |
285 | ) | |
d2457078 | 286 | #endif |
f62b389e MD |
287 | |
288 | /** | |
289 | * block_rq_requeue - place block IO request back on a queue | |
290 | * @q: queue holding operation | |
291 | * @rq: block IO operation request | |
292 | * | |
293 | * The block operation request @rq is being placed back into queue | |
294 | * @q. For some reason the request was not completed and needs to be | |
295 | * put back in the queue. | |
296 | */ | |
d2457078 MJ |
297 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0)) |
298 | LTTNG_TRACEPOINT_EVENT(block_rq_requeue, | |
299 | ||
300 | TP_PROTO(struct request_queue *q, struct request *rq), | |
301 | ||
302 | TP_ARGS(q, rq), | |
303 | ||
304 | TP_FIELDS( | |
305 | ctf_integer(dev_t, dev, | |
306 | rq->rq_disk ? disk_devt(rq->rq_disk) : 0) | |
307 | ctf_integer(sector_t, sector, blk_rq_trace_sector(rq)) | |
308 | ctf_integer(unsigned int, nr_sector, blk_rq_trace_nr_sectors(rq)) | |
309 | blk_rwbs_ctf_integer(unsigned int, rwbs, | |
310 | lttng_req_op(rq), lttng_req_rw(rq), blk_rq_bytes(rq)) | |
311 | ) | |
312 | ) | |
313 | #else | |
3bc29f0a | 314 | LTTNG_TRACEPOINT_EVENT_INSTANCE(block_rq_with_error, block_rq_requeue, |
f62b389e MD |
315 | |
316 | TP_PROTO(struct request_queue *q, struct request *rq), | |
317 | ||
318 | TP_ARGS(q, rq) | |
319 | ) | |
d2457078 | 320 | #endif |
f62b389e | 321 | |
1c53e689 MD |
322 | /** |
323 | * block_rq_complete - block IO operation completed by device driver | |
324 | * @q: queue containing the block operation request | |
325 | * @rq: block operations request | |
326 | * @nr_bytes: number of completed bytes | |
327 | * | |
328 | * The block_rq_complete tracepoint event indicates that some portion | |
329 | * of operation request has been completed by the device driver. If | |
330 | * the @rq->bio is %NULL, then there is absolutely no additional work to | |
331 | * do for the request. If @rq->bio is non-NULL then there is | |
332 | * additional work required to complete the request. | |
333 | */ | |
d2457078 MJ |
334 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0)) |
335 | LTTNG_TRACEPOINT_EVENT(block_rq_complete, | |
336 | ||
337 | TP_PROTO(struct request *rq, int error, unsigned int nr_bytes), | |
338 | ||
339 | TP_ARGS(rq, error, nr_bytes), | |
340 | ||
341 | TP_FIELDS( | |
342 | ctf_integer(dev_t, dev, | |
343 | rq->rq_disk ? disk_devt(rq->rq_disk) : 0) | |
344 | ctf_integer(sector_t, sector, blk_rq_pos(rq)) | |
345 | ctf_integer(unsigned int, nr_sector, nr_bytes >> 9) | |
346 | ctf_integer(int, error, error) | |
347 | blk_rwbs_ctf_integer(unsigned int, rwbs, | |
348 | lttng_req_op(rq), lttng_req_rw(rq), nr_bytes) | |
349 | ) | |
350 | ) | |
351 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) | |
8a9f549f FD |
352 | LTTNG_TRACEPOINT_EVENT_CODE(block_rq_complete, |
353 | ||
354 | TP_PROTO(struct request_queue *q, struct request *rq, | |
355 | unsigned int nr_bytes), | |
356 | ||
357 | TP_ARGS(q, rq, nr_bytes), | |
358 | ||
359 | TP_locvar( | |
360 | unsigned char *cmd; | |
361 | size_t cmd_len; | |
362 | ), | |
363 | ||
364 | TP_code_pre( | |
365 | if (blk_rq_is_scsi(rq)) { | |
366 | struct scsi_request *scsi_rq = scsi_req(rq); | |
367 | tp_locvar->cmd = scsi_rq->cmd; | |
368 | tp_locvar->cmd_len = scsi_rq->cmd_len; | |
369 | } else { | |
370 | tp_locvar->cmd = NULL; | |
371 | tp_locvar->cmd_len = 0; | |
372 | } | |
373 | ), | |
374 | ||
375 | TP_FIELDS( | |
376 | ctf_integer(dev_t, dev, | |
377 | rq->rq_disk ? disk_devt(rq->rq_disk) : 0) | |
378 | ctf_integer(sector_t, sector, blk_rq_pos(rq)) | |
379 | ctf_integer(unsigned int, nr_sector, nr_bytes >> 9) | |
380 | ctf_integer(int, errors, rq->errors) | |
381 | blk_rwbs_ctf_integer(unsigned int, rwbs, | |
382 | lttng_req_op(rq), lttng_req_rw(rq), nr_bytes) | |
383 | ctf_sequence_hex(unsigned char, cmd, | |
384 | tp_locvar->cmd, size_t, tp_locvar->cmd_len) | |
385 | ), | |
386 | ||
387 | TP_code_post() | |
388 | ) | |
389 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,5) \ | |
390 | || LTTNG_KERNEL_RANGE(3,12,21, 3,13,0) \ | |
391 | || LTTNG_KERNEL_RANGE(3,10,41, 3,11,0) \ | |
392 | || LTTNG_KERNEL_RANGE(3,4,91, 3,5,0) \ | |
393 | || LTTNG_KERNEL_RANGE(3,2,58, 3,3,0) \ | |
394 | || LTTNG_UBUNTU_KERNEL_RANGE(3,13,11,28, 3,14,0,0) \ | |
395 | || LTTNG_RHEL_KERNEL_RANGE(3,10,0,229,0,0, 3,11,0,0,0,0)) | |
396 | ||
f127e61e | 397 | LTTNG_TRACEPOINT_EVENT_CODE(block_rq_complete, |
1c53e689 MD |
398 | |
399 | TP_PROTO(struct request_queue *q, struct request *rq, | |
400 | unsigned int nr_bytes), | |
401 | ||
402 | TP_ARGS(q, rq, nr_bytes), | |
403 | ||
f127e61e MD |
404 | TP_locvar( |
405 | unsigned char *cmd; | |
406 | size_t cmd_len; | |
1c53e689 MD |
407 | ), |
408 | ||
265822ae | 409 | TP_code_pre( |
f127e61e MD |
410 | if (rq->cmd_type == REQ_TYPE_BLOCK_PC) { |
411 | tp_locvar->cmd = rq->cmd; | |
412 | tp_locvar->cmd_len = rq->cmd_len; | |
413 | } else { | |
414 | tp_locvar->cmd = NULL; | |
415 | tp_locvar->cmd_len = 0; | |
416 | } | |
1c53e689 MD |
417 | ), |
418 | ||
f127e61e MD |
419 | TP_FIELDS( |
420 | ctf_integer(dev_t, dev, | |
421 | rq->rq_disk ? disk_devt(rq->rq_disk) : 0) | |
422 | ctf_integer(sector_t, sector, blk_rq_pos(rq)) | |
423 | ctf_integer(unsigned int, nr_sector, nr_bytes >> 9) | |
424 | ctf_integer(int, errors, rq->errors) | |
425 | blk_rwbs_ctf_integer(unsigned int, rwbs, | |
e6d2cc09 | 426 | lttng_req_op(rq), lttng_req_rw(rq), nr_bytes) |
f127e61e MD |
427 | ctf_sequence_hex(unsigned char, cmd, |
428 | tp_locvar->cmd, size_t, tp_locvar->cmd_len) | |
265822ae MD |
429 | ), |
430 | ||
431 | TP_code_post() | |
1c53e689 MD |
432 | ) |
433 | ||
434 | #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) */ | |
435 | ||
f62b389e MD |
436 | /** |
437 | * block_rq_complete - block IO operation completed by device driver | |
438 | * @q: queue containing the block operation request | |
439 | * @rq: block operations request | |
440 | * | |
441 | * The block_rq_complete tracepoint event indicates that some portion | |
442 | * of operation request has been completed by the device driver. If | |
443 | * the @rq->bio is %NULL, then there is absolutely no additional work to | |
444 | * do for the request. If @rq->bio is non-NULL then there is | |
445 | * additional work required to complete the request. | |
446 | */ | |
3bc29f0a | 447 | LTTNG_TRACEPOINT_EVENT_INSTANCE(block_rq_with_error, block_rq_complete, |
f62b389e MD |
448 | |
449 | TP_PROTO(struct request_queue *q, struct request *rq), | |
450 | ||
451 | TP_ARGS(q, rq) | |
452 | ) | |
453 | ||
1c53e689 MD |
454 | #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) */ |
455 | ||
d2457078 MJ |
456 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0)) |
457 | LTTNG_TRACEPOINT_EVENT_CLASS(block_rq, | |
458 | ||
459 | TP_PROTO(struct request_queue *q, struct request *rq), | |
460 | ||
461 | TP_ARGS(q, rq), | |
462 | ||
463 | TP_FIELDS( | |
464 | ctf_integer(dev_t, dev, | |
465 | rq->rq_disk ? disk_devt(rq->rq_disk) : 0) | |
466 | ctf_integer(sector_t, sector, blk_rq_trace_sector(rq)) | |
467 | ctf_integer(unsigned int, nr_sector, blk_rq_trace_nr_sectors(rq)) | |
468 | ctf_integer(unsigned int, bytes, blk_rq_bytes(rq)) | |
469 | ctf_integer(pid_t, tid, current->pid) | |
470 | blk_rwbs_ctf_integer(unsigned int, rwbs, | |
471 | lttng_req_op(rq), lttng_req_rw(rq), blk_rq_bytes(rq)) | |
472 | ctf_array_text(char, comm, current->comm, TASK_COMM_LEN) | |
473 | ) | |
474 | ) | |
475 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) | |
8a9f549f FD |
476 | LTTNG_TRACEPOINT_EVENT_CLASS_CODE(block_rq, |
477 | ||
478 | TP_PROTO(struct request_queue *q, struct request *rq), | |
479 | ||
480 | TP_ARGS(q, rq), | |
481 | ||
482 | TP_locvar( | |
483 | sector_t sector; | |
484 | unsigned int nr_sector; | |
485 | unsigned int bytes; | |
486 | unsigned char *cmd; | |
487 | size_t cmd_len; | |
488 | ), | |
489 | ||
490 | TP_code_pre( | |
491 | if (blk_rq_is_scsi(rq)) { | |
492 | struct scsi_request *scsi_rq = scsi_req(rq); | |
493 | tp_locvar->sector = 0; | |
494 | tp_locvar->nr_sector = 0; | |
495 | tp_locvar->bytes = scsi_rq->resid_len; | |
496 | tp_locvar->cmd = scsi_rq->cmd; | |
497 | tp_locvar->cmd_len = scsi_rq->cmd_len; | |
498 | } else { | |
499 | tp_locvar->sector = blk_rq_pos(rq); | |
500 | tp_locvar->nr_sector = blk_rq_sectors(rq); | |
501 | tp_locvar->bytes = 0; | |
502 | tp_locvar->cmd = NULL; | |
503 | tp_locvar->cmd_len = 0; | |
504 | } | |
505 | ), | |
506 | ||
507 | TP_FIELDS( | |
508 | ctf_integer(dev_t, dev, | |
509 | rq->rq_disk ? disk_devt(rq->rq_disk) : 0) | |
510 | ctf_integer(sector_t, sector, tp_locvar->sector) | |
511 | ctf_integer(unsigned int, nr_sector, tp_locvar->nr_sector) | |
512 | ctf_integer(unsigned int, bytes, tp_locvar->bytes) | |
513 | ctf_integer(pid_t, tid, current->pid) | |
514 | blk_rwbs_ctf_integer(unsigned int, rwbs, | |
515 | lttng_req_op(rq), lttng_req_rw(rq), blk_rq_bytes(rq)) | |
516 | ctf_sequence_hex(unsigned char, cmd, | |
517 | tp_locvar->cmd, size_t, tp_locvar->cmd_len) | |
518 | ctf_array_text(char, comm, current->comm, TASK_COMM_LEN) | |
519 | ), | |
520 | ||
521 | TP_code_post() | |
522 | ) | |
523 | #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */ | |
f127e61e | 524 | LTTNG_TRACEPOINT_EVENT_CLASS_CODE(block_rq, |
f62b389e MD |
525 | |
526 | TP_PROTO(struct request_queue *q, struct request *rq), | |
527 | ||
528 | TP_ARGS(q, rq), | |
529 | ||
f127e61e MD |
530 | TP_locvar( |
531 | sector_t sector; | |
532 | unsigned int nr_sector; | |
533 | unsigned int bytes; | |
534 | unsigned char *cmd; | |
535 | size_t cmd_len; | |
f62b389e MD |
536 | ), |
537 | ||
265822ae | 538 | TP_code_pre( |
f127e61e MD |
539 | if (rq->cmd_type == REQ_TYPE_BLOCK_PC) { |
540 | tp_locvar->sector = 0; | |
541 | tp_locvar->nr_sector = 0; | |
542 | tp_locvar->bytes = blk_rq_bytes(rq); | |
543 | tp_locvar->cmd = rq->cmd; | |
544 | tp_locvar->cmd_len = rq->cmd_len; | |
545 | } else { | |
546 | tp_locvar->sector = blk_rq_pos(rq); | |
547 | tp_locvar->nr_sector = blk_rq_sectors(rq); | |
548 | tp_locvar->bytes = 0; | |
549 | tp_locvar->cmd = NULL; | |
550 | tp_locvar->cmd_len = 0; | |
551 | } | |
f62b389e MD |
552 | ), |
553 | ||
f127e61e MD |
554 | TP_FIELDS( |
555 | ctf_integer(dev_t, dev, | |
556 | rq->rq_disk ? disk_devt(rq->rq_disk) : 0) | |
557 | ctf_integer(sector_t, sector, tp_locvar->sector) | |
558 | ctf_integer(unsigned int, nr_sector, tp_locvar->nr_sector) | |
559 | ctf_integer(unsigned int, bytes, tp_locvar->bytes) | |
560 | ctf_integer(pid_t, tid, current->pid) | |
561 | blk_rwbs_ctf_integer(unsigned int, rwbs, | |
e6d2cc09 | 562 | lttng_req_op(rq), lttng_req_rw(rq), blk_rq_bytes(rq)) |
f127e61e MD |
563 | ctf_sequence_hex(unsigned char, cmd, |
564 | tp_locvar->cmd, size_t, tp_locvar->cmd_len) | |
565 | ctf_array_text(char, comm, current->comm, TASK_COMM_LEN) | |
265822ae MD |
566 | ), |
567 | ||
568 | TP_code_post() | |
f62b389e | 569 | ) |
8a9f549f | 570 | #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */ |
f62b389e MD |
571 | |
572 | /** | |
573 | * block_rq_insert - insert block operation request into queue | |
574 | * @q: target queue | |
575 | * @rq: block IO operation request | |
576 | * | |
577 | * Called immediately before block operation request @rq is inserted | |
578 | * into queue @q. The fields in the operation request @rq struct can | |
579 | * be examined to determine which device and sectors the pending | |
580 | * operation would access. | |
581 | */ | |
3bc29f0a | 582 | LTTNG_TRACEPOINT_EVENT_INSTANCE(block_rq, block_rq_insert, |
f62b389e MD |
583 | |
584 | TP_PROTO(struct request_queue *q, struct request *rq), | |
585 | ||
586 | TP_ARGS(q, rq) | |
587 | ) | |
588 | ||
589 | /** | |
590 | * block_rq_issue - issue pending block IO request operation to device driver | |
591 | * @q: queue holding operation | |
592 | * @rq: block IO operation operation request | |
593 | * | |
594 | * Called when block operation request @rq from queue @q is sent to a | |
595 | * device driver for processing. | |
596 | */ | |
3bc29f0a | 597 | LTTNG_TRACEPOINT_EVENT_INSTANCE(block_rq, block_rq_issue, |
f62b389e MD |
598 | |
599 | TP_PROTO(struct request_queue *q, struct request *rq), | |
600 | ||
601 | TP_ARGS(q, rq) | |
602 | ) | |
603 | ||
604 | /** | |
605 | * block_bio_bounce - used bounce buffer when processing block operation | |
606 | * @q: queue holding the block operation | |
607 | * @bio: block operation | |
608 | * | |
609 | * A bounce buffer was used to handle the block operation @bio in @q. | |
610 | * This occurs when hardware limitations prevent a direct transfer of | |
611 | * data between the @bio data memory area and the IO device. Use of a | |
612 | * bounce buffer requires extra copying of data and decreases | |
613 | * performance. | |
614 | */ | |
3bc29f0a | 615 | LTTNG_TRACEPOINT_EVENT(block_bio_bounce, |
f62b389e MD |
616 | |
617 | TP_PROTO(struct request_queue *q, struct bio *bio), | |
618 | ||
619 | TP_ARGS(q, bio), | |
620 | ||
f127e61e | 621 | TP_FIELDS( |
7feabe53 MD |
622 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0)) |
623 | ctf_integer(dev_t, dev, bio_dev(bio)) | |
624 | #else | |
959fe42a | 625 | ctf_integer(dev_t, dev, bio->bi_bdev ? bio->bi_bdev->bd_dev : 0) |
7feabe53 | 626 | #endif |
54c4c2e3 | 627 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) |
f127e61e MD |
628 | ctf_integer(sector_t, sector, bio->bi_iter.bi_sector) |
629 | ctf_integer(unsigned int, nr_sector, bio_sectors(bio)) | |
630 | blk_rwbs_ctf_integer(unsigned int, rwbs, | |
e6d2cc09 MD |
631 | lttng_bio_op(bio), lttng_bio_rw(bio), |
632 | bio->bi_iter.bi_size) | |
54c4c2e3 | 633 | #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */ |
f127e61e MD |
634 | ctf_integer(sector_t, sector, bio->bi_sector) |
635 | ctf_integer(unsigned int, nr_sector, bio->bi_size >> 9) | |
636 | blk_rwbs_ctf_integer(unsigned int, rwbs, | |
e6d2cc09 MD |
637 | lttng_bio_op(bio), lttng_bio_rw(bio), |
638 | bio->bi_size) | |
54c4c2e3 | 639 | #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */ |
f127e61e MD |
640 | ctf_integer(pid_t, tid, current->pid) |
641 | ctf_array_text(char, comm, current->comm, TASK_COMM_LEN) | |
642 | ) | |
f62b389e MD |
643 | ) |
644 | ||
c6afb465 MJ |
645 | |
646 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,8,0)) | |
647 | /** | |
648 | * block_bio_complete - completed all work on the block operation | |
649 | * @q: queue holding the block operation | |
650 | * @bio: block operation completed | |
651 | * @error: io error value | |
652 | * | |
653 | * This tracepoint indicates there is no further work to do on this | |
654 | * block IO operation @bio. | |
655 | */ | |
656 | LTTNG_TRACEPOINT_EVENT(block_bio_complete, | |
657 | ||
658 | TP_PROTO(struct request_queue *q, struct bio *bio), | |
659 | ||
660 | TP_ARGS(q, bio), | |
661 | ||
662 | TP_FIELDS( | |
663 | ctf_integer(dev_t, dev, bio_dev(bio)) | |
664 | ctf_integer(sector_t, sector, bio->bi_iter.bi_sector) | |
665 | ctf_integer(unsigned int, nr_sector, bio_sectors(bio)) | |
666 | ctf_integer(int, error, blk_status_to_errno(bio->bi_status)) | |
667 | blk_rwbs_ctf_integer(unsigned int, rwbs, | |
668 | lttng_bio_op(bio), lttng_bio_rw(bio), | |
669 | bio->bi_iter.bi_size) | |
670 | ) | |
671 | ) | |
672 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0)) | |
f62b389e MD |
673 | /** |
674 | * block_bio_complete - completed all work on the block operation | |
675 | * @q: queue holding the block operation | |
676 | * @bio: block operation completed | |
677 | * @error: io error value | |
678 | * | |
679 | * This tracepoint indicates there is no further work to do on this | |
680 | * block IO operation @bio. | |
681 | */ | |
3bc29f0a | 682 | LTTNG_TRACEPOINT_EVENT(block_bio_complete, |
f62b389e MD |
683 | |
684 | TP_PROTO(struct request_queue *q, struct bio *bio, int error), | |
685 | ||
686 | TP_ARGS(q, bio, error), | |
687 | ||
f127e61e | 688 | TP_FIELDS( |
7feabe53 | 689 | ctf_integer(dev_t, dev, bio_dev(bio)) |
c6afb465 MJ |
690 | ctf_integer(sector_t, sector, bio->bi_iter.bi_sector) |
691 | ctf_integer(unsigned int, nr_sector, bio_sectors(bio)) | |
692 | ctf_integer(int, error, error) | |
693 | blk_rwbs_ctf_integer(unsigned int, rwbs, | |
694 | lttng_bio_op(bio), lttng_bio_rw(bio), | |
695 | bio->bi_iter.bi_size) | |
696 | ) | |
697 | ) | |
698 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) | |
699 | /** | |
700 | * block_bio_complete - completed all work on the block operation | |
701 | * @q: queue holding the block operation | |
702 | * @bio: block operation completed | |
703 | * @error: io error value | |
704 | * | |
705 | * This tracepoint indicates there is no further work to do on this | |
706 | * block IO operation @bio. | |
707 | */ | |
708 | LTTNG_TRACEPOINT_EVENT(block_bio_complete, | |
709 | ||
710 | TP_PROTO(struct request_queue *q, struct bio *bio, int error), | |
711 | ||
712 | TP_ARGS(q, bio, error), | |
713 | ||
714 | TP_FIELDS( | |
959fe42a | 715 | ctf_integer(dev_t, dev, bio->bi_bdev->bd_dev) |
f127e61e MD |
716 | ctf_integer(sector_t, sector, bio->bi_iter.bi_sector) |
717 | ctf_integer(unsigned int, nr_sector, bio_sectors(bio)) | |
718 | ctf_integer(int, error, error) | |
719 | blk_rwbs_ctf_integer(unsigned int, rwbs, | |
e6d2cc09 MD |
720 | lttng_bio_op(bio), lttng_bio_rw(bio), |
721 | bio->bi_iter.bi_size) | |
c6afb465 MJ |
722 | ) |
723 | ) | |
bb415fbf | 724 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
c6afb465 MJ |
725 | /** |
726 | * block_bio_complete - completed all work on the block operation | |
727 | * @q: queue holding the block operation | |
728 | * @bio: block operation completed | |
729 | * @error: io error value | |
730 | * | |
731 | * This tracepoint indicates there is no further work to do on this | |
732 | * block IO operation @bio. | |
733 | */ | |
734 | LTTNG_TRACEPOINT_EVENT(block_bio_complete, | |
735 | ||
736 | TP_PROTO(struct request_queue *q, struct bio *bio, int error), | |
737 | ||
738 | TP_ARGS(q, bio, error), | |
739 | ||
740 | TP_FIELDS( | |
741 | ctf_integer(dev_t, dev, bio->bi_bdev->bd_dev) | |
f127e61e MD |
742 | ctf_integer(sector_t, sector, bio->bi_sector) |
743 | ctf_integer(unsigned int, nr_sector, bio->bi_size >> 9) | |
f127e61e | 744 | ctf_integer(int, error, error) |
bb415fbf MJ |
745 | blk_rwbs_ctf_integer(unsigned int, rwbs, |
746 | lttng_bio_op(bio), lttng_bio_rw(bio), bio->bi_size) | |
747 | ) | |
748 | ) | |
7c68b363 | 749 | #else |
bb415fbf MJ |
750 | /** |
751 | * block_bio_complete - completed all work on the block operation | |
752 | * @q: queue holding the block operation | |
753 | * @bio: block operation completed | |
754 | * @error: io error value | |
755 | * | |
756 | * This tracepoint indicates there is no further work to do on this | |
757 | * block IO operation @bio. | |
758 | */ | |
759 | LTTNG_TRACEPOINT_EVENT(block_bio_complete, | |
760 | ||
761 | TP_PROTO(struct request_queue *q, struct bio *bio), | |
762 | ||
763 | TP_ARGS(q, bio), | |
764 | ||
765 | TP_FIELDS( | |
766 | ctf_integer(dev_t, dev, bio->bi_bdev->bd_dev) | |
767 | ctf_integer(sector_t, sector, bio->bi_sector) | |
768 | ctf_integer(unsigned int, nr_sector, bio->bi_size >> 9) | |
f127e61e | 769 | ctf_integer(int, error, 0) |
f127e61e | 770 | blk_rwbs_ctf_integer(unsigned int, rwbs, |
e6d2cc09 | 771 | lttng_bio_op(bio), lttng_bio_rw(bio), bio->bi_size) |
f127e61e | 772 | ) |
f62b389e | 773 | ) |
c6afb465 | 774 | #endif |
f62b389e | 775 | |
217f66c6 | 776 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) |
3bc29f0a | 777 | LTTNG_TRACEPOINT_EVENT_CLASS(block_bio_merge, |
217f66c6 MD |
778 | |
779 | TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio), | |
780 | ||
781 | TP_ARGS(q, rq, bio), | |
782 | ||
f127e61e | 783 | TP_FIELDS( |
7feabe53 MD |
784 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0)) |
785 | ctf_integer(dev_t, dev, bio_dev(bio)) | |
786 | #else | |
959fe42a | 787 | ctf_integer(dev_t, dev, bio->bi_bdev->bd_dev) |
7feabe53 | 788 | #endif |
54c4c2e3 | 789 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) |
f127e61e MD |
790 | ctf_integer(sector_t, sector, bio->bi_iter.bi_sector) |
791 | ctf_integer(unsigned int, nr_sector, bio_sectors(bio)) | |
792 | blk_rwbs_ctf_integer(unsigned int, rwbs, | |
e6d2cc09 MD |
793 | lttng_bio_op(bio), lttng_bio_rw(bio), |
794 | bio->bi_iter.bi_size) | |
54c4c2e3 | 795 | #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */ |
f127e61e MD |
796 | ctf_integer(sector_t, sector, bio->bi_sector) |
797 | ctf_integer(unsigned int, nr_sector, bio->bi_size >> 9) | |
798 | blk_rwbs_ctf_integer(unsigned int, rwbs, | |
e6d2cc09 | 799 | lttng_bio_op(bio), lttng_bio_rw(bio), bio->bi_size) |
54c4c2e3 | 800 | #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */ |
f127e61e MD |
801 | ctf_integer(pid_t, tid, current->pid) |
802 | ctf_array_text(char, comm, current->comm, TASK_COMM_LEN) | |
803 | ) | |
217f66c6 MD |
804 | ) |
805 | ||
806 | /** | |
807 | * block_bio_backmerge - merging block operation to the end of an existing operation | |
808 | * @q: queue holding operation | |
809 | * @bio: new block operation to merge | |
810 | * | |
811 | * Merging block request @bio to the end of an existing block request | |
812 | * in queue @q. | |
813 | */ | |
3bc29f0a | 814 | LTTNG_TRACEPOINT_EVENT_INSTANCE(block_bio_merge, block_bio_backmerge, |
217f66c6 MD |
815 | |
816 | TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio), | |
817 | ||
818 | TP_ARGS(q, rq, bio) | |
819 | ) | |
820 | ||
821 | /** | |
822 | * block_bio_frontmerge - merging block operation to the beginning of an existing operation | |
823 | * @q: queue holding operation | |
824 | * @bio: new block operation to merge | |
825 | * | |
826 | * Merging block IO operation @bio to the beginning of an existing block | |
827 | * operation in queue @q. | |
828 | */ | |
3bc29f0a | 829 | LTTNG_TRACEPOINT_EVENT_INSTANCE(block_bio_merge, block_bio_frontmerge, |
217f66c6 MD |
830 | |
831 | TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio), | |
832 | ||
833 | TP_ARGS(q, rq, bio) | |
834 | ) | |
835 | ||
836 | /** | |
837 | * block_bio_queue - putting new block IO operation in queue | |
838 | * @q: queue holding operation | |
839 | * @bio: new block operation | |
840 | * | |
841 | * About to place the block IO operation @bio into queue @q. | |
842 | */ | |
3bc29f0a | 843 | LTTNG_TRACEPOINT_EVENT(block_bio_queue, |
217f66c6 MD |
844 | |
845 | TP_PROTO(struct request_queue *q, struct bio *bio), | |
846 | ||
847 | TP_ARGS(q, bio), | |
848 | ||
f127e61e | 849 | TP_FIELDS( |
7feabe53 MD |
850 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0)) |
851 | ctf_integer(dev_t, dev, bio_dev(bio)) | |
852 | #else | |
959fe42a | 853 | ctf_integer(dev_t, dev, bio->bi_bdev->bd_dev) |
7feabe53 | 854 | #endif |
54c4c2e3 | 855 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) |
f127e61e MD |
856 | ctf_integer(sector_t, sector, bio->bi_iter.bi_sector) |
857 | ctf_integer(unsigned int, nr_sector, bio_sectors(bio)) | |
858 | blk_rwbs_ctf_integer(unsigned int, rwbs, | |
e6d2cc09 MD |
859 | lttng_bio_op(bio), lttng_bio_rw(bio), |
860 | bio->bi_iter.bi_size) | |
54c4c2e3 | 861 | #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */ |
f127e61e MD |
862 | ctf_integer(sector_t, sector, bio->bi_sector) |
863 | ctf_integer(unsigned int, nr_sector, bio->bi_size >> 9) | |
864 | blk_rwbs_ctf_integer(unsigned int, rwbs, | |
e6d2cc09 | 865 | lttng_bio_op(bio), lttng_bio_rw(bio), bio->bi_size) |
54c4c2e3 | 866 | #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */ |
f127e61e MD |
867 | ctf_integer(pid_t, tid, current->pid) |
868 | ctf_array_text(char, comm, current->comm, TASK_COMM_LEN) | |
869 | ) | |
217f66c6 | 870 | ) |
f127e61e | 871 | #else /* if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) */ |
3bc29f0a | 872 | LTTNG_TRACEPOINT_EVENT_CLASS(block_bio, |
f62b389e MD |
873 | |
874 | TP_PROTO(struct request_queue *q, struct bio *bio), | |
875 | ||
876 | TP_ARGS(q, bio), | |
877 | ||
f127e61e | 878 | TP_FIELDS( |
959fe42a | 879 | ctf_integer(dev_t, dev, bio->bi_bdev ? bio->bi_bdev->bd_dev : 0) |
f127e61e MD |
880 | ctf_integer(sector_t, sector, bio->bi_sector) |
881 | ctf_integer(unsigned int, nr_sector, bio->bi_size >> 9) | |
882 | blk_rwbs_ctf_integer(unsigned int, rwbs, | |
e6d2cc09 | 883 | lttng_bio_op(bio), lttng_bio_rw(bio), bio->bi_size) |
f127e61e MD |
884 | ctf_integer(pid_t, tid, current->pid) |
885 | ctf_array_text(char, comm, current->comm, TASK_COMM_LEN) | |
886 | ) | |
f62b389e MD |
887 | ) |
888 | ||
889 | /** | |
890 | * block_bio_backmerge - merging block operation to the end of an existing operation | |
891 | * @q: queue holding operation | |
892 | * @bio: new block operation to merge | |
893 | * | |
894 | * Merging block request @bio to the end of an existing block request | |
895 | * in queue @q. | |
896 | */ | |
3bc29f0a | 897 | LTTNG_TRACEPOINT_EVENT_INSTANCE(block_bio, block_bio_backmerge, |
f62b389e MD |
898 | |
899 | TP_PROTO(struct request_queue *q, struct bio *bio), | |
900 | ||
901 | TP_ARGS(q, bio) | |
902 | ) | |
903 | ||
904 | /** | |
905 | * block_bio_frontmerge - merging block operation to the beginning of an existing operation | |
906 | * @q: queue holding operation | |
907 | * @bio: new block operation to merge | |
908 | * | |
909 | * Merging block IO operation @bio to the beginning of an existing block | |
910 | * operation in queue @q. | |
911 | */ | |
3bc29f0a | 912 | LTTNG_TRACEPOINT_EVENT_INSTANCE(block_bio, block_bio_frontmerge, |
f62b389e MD |
913 | |
914 | TP_PROTO(struct request_queue *q, struct bio *bio), | |
915 | ||
916 | TP_ARGS(q, bio) | |
917 | ) | |
918 | ||
919 | /** | |
920 | * block_bio_queue - putting new block IO operation in queue | |
921 | * @q: queue holding operation | |
922 | * @bio: new block operation | |
923 | * | |
924 | * About to place the block IO operation @bio into queue @q. | |
925 | */ | |
3bc29f0a | 926 | LTTNG_TRACEPOINT_EVENT_INSTANCE(block_bio, block_bio_queue, |
f62b389e MD |
927 | |
928 | TP_PROTO(struct request_queue *q, struct bio *bio), | |
929 | ||
930 | TP_ARGS(q, bio) | |
931 | ) | |
f127e61e | 932 | #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) */ |
f62b389e | 933 | |
3bc29f0a | 934 | LTTNG_TRACEPOINT_EVENT_CLASS(block_get_rq, |
f62b389e MD |
935 | |
936 | TP_PROTO(struct request_queue *q, struct bio *bio, int rw), | |
937 | ||
938 | TP_ARGS(q, bio, rw), | |
939 | ||
f127e61e | 940 | TP_FIELDS( |
7feabe53 | 941 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0)) |
6417cda6 | 942 | ctf_integer(dev_t, dev, bio ? bio_dev(bio) : 0) |
7feabe53 | 943 | #else |
959fe42a | 944 | ctf_integer(dev_t, dev, bio ? bio->bi_bdev->bd_dev : 0) |
7feabe53 | 945 | #endif |
54c4c2e3 | 946 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) |
f127e61e MD |
947 | ctf_integer(sector_t, sector, bio ? bio->bi_iter.bi_sector : 0) |
948 | ctf_integer(unsigned int, nr_sector, | |
949 | bio ? bio_sectors(bio) : 0) | |
950 | blk_rwbs_ctf_integer(unsigned int, rwbs, | |
e6d2cc09 MD |
951 | bio ? lttng_bio_op(bio) : 0, |
952 | bio ? lttng_bio_rw(bio) : 0, | |
f127e61e | 953 | bio ? bio->bi_iter.bi_size : 0) |
54c4c2e3 | 954 | #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */ |
f127e61e MD |
955 | ctf_integer(sector_t, sector, bio ? bio->bi_sector : 0) |
956 | ctf_integer(unsigned int, nr_sector, | |
957 | bio ? bio->bi_size >> 9 : 0) | |
958 | blk_rwbs_ctf_integer(unsigned int, rwbs, | |
e6d2cc09 MD |
959 | bio ? lttng_bio_op(bio) : 0, |
960 | bio ? lttng_bio_rw(bio) : 0, | |
f127e61e | 961 | bio ? bio->bi_size : 0) |
54c4c2e3 | 962 | #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */ |
f127e61e MD |
963 | ctf_integer(pid_t, tid, current->pid) |
964 | ctf_array_text(char, comm, current->comm, TASK_COMM_LEN) | |
965 | ) | |
f62b389e MD |
966 | ) |
967 | ||
968 | /** | |
969 | * block_getrq - get a free request entry in queue for block IO operations | |
970 | * @q: queue for operations | |
6417cda6 | 971 | * @bio: pending block IO operation (can be %NULL) |
f62b389e MD |
972 | * @rw: low bit indicates a read (%0) or a write (%1) |
973 | * | |
974 | * A request struct for queue @q has been allocated to handle the | |
975 | * block IO operation @bio. | |
976 | */ | |
3bc29f0a | 977 | LTTNG_TRACEPOINT_EVENT_INSTANCE(block_get_rq, block_getrq, |
f62b389e MD |
978 | |
979 | TP_PROTO(struct request_queue *q, struct bio *bio, int rw), | |
980 | ||
981 | TP_ARGS(q, bio, rw) | |
982 | ) | |
983 | ||
984 | /** | |
985 | * block_sleeprq - waiting to get a free request entry in queue for block IO operation | |
986 | * @q: queue for operation | |
6417cda6 | 987 | * @bio: pending block IO operation (can be %NULL) |
f62b389e MD |
988 | * @rw: low bit indicates a read (%0) or a write (%1) |
989 | * | |
990 | * In the case where a request struct cannot be provided for queue @q | |
991 | * the process needs to wait for an request struct to become | |
992 | * available. This tracepoint event is generated each time the | |
993 | * process goes to sleep waiting for request struct become available. | |
994 | */ | |
3bc29f0a | 995 | LTTNG_TRACEPOINT_EVENT_INSTANCE(block_get_rq, block_sleeprq, |
f62b389e MD |
996 | |
997 | TP_PROTO(struct request_queue *q, struct bio *bio, int rw), | |
998 | ||
999 | TP_ARGS(q, bio, rw) | |
1000 | ) | |
1001 | ||
1002 | /** | |
1003 | * block_plug - keep operations requests in request queue | |
1004 | * @q: request queue to plug | |
1005 | * | |
1006 | * Plug the request queue @q. Do not allow block operation requests | |
1007 | * to be sent to the device driver. Instead, accumulate requests in | |
1008 | * the queue to improve throughput performance of the block device. | |
1009 | */ | |
3bc29f0a | 1010 | LTTNG_TRACEPOINT_EVENT(block_plug, |
f62b389e MD |
1011 | |
1012 | TP_PROTO(struct request_queue *q), | |
1013 | ||
1014 | TP_ARGS(q), | |
1015 | ||
f127e61e MD |
1016 | TP_FIELDS( |
1017 | ctf_integer(pid_t, tid, current->pid) | |
1018 | ctf_array_text(char, comm, current->comm, TASK_COMM_LEN) | |
1019 | ) | |
f62b389e MD |
1020 | ) |
1021 | ||
3bc29f0a | 1022 | LTTNG_TRACEPOINT_EVENT_CLASS(block_unplug, |
f62b389e | 1023 | |
7c68b363 | 1024 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) |
f62b389e MD |
1025 | TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit), |
1026 | ||
1027 | TP_ARGS(q, depth, explicit), | |
7c68b363 AG |
1028 | #else |
1029 | TP_PROTO(struct request_queue *q), | |
1030 | ||
1031 | TP_ARGS(q), | |
1032 | #endif | |
f62b389e | 1033 | |
f127e61e | 1034 | TP_FIELDS( |
7c68b363 | 1035 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) |
f127e61e | 1036 | ctf_integer(int, nr_rq, depth) |
7c68b363 | 1037 | #else |
f127e61e | 1038 | ctf_integer(int, nr_rq, q->rq.count[READ] + q->rq.count[WRITE]) |
7c68b363 | 1039 | #endif |
f127e61e MD |
1040 | ctf_integer(pid_t, tid, current->pid) |
1041 | ctf_array_text(char, comm, current->comm, TASK_COMM_LEN) | |
1042 | ) | |
f62b389e MD |
1043 | ) |
1044 | ||
7c68b363 AG |
1045 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) |
1046 | /** | |
1047 | * block_unplug_timer - timed release of operations requests in queue to device driver | |
1048 | * @q: request queue to unplug | |
1049 | * | |
1050 | * Unplug the request queue @q because a timer expired and allow block | |
1051 | * operation requests to be sent to the device driver. | |
1052 | */ | |
3bc29f0a | 1053 | LTTNG_TRACEPOINT_EVENT_INSTANCE(block_unplug, block_unplug_timer, |
7c68b363 AG |
1054 | |
1055 | TP_PROTO(struct request_queue *q), | |
1056 | ||
1057 | TP_ARGS(q) | |
1058 | ) | |
1059 | #endif | |
1060 | ||
f62b389e MD |
1061 | /** |
1062 | * block_unplug - release of operations requests in request queue | |
1063 | * @q: request queue to unplug | |
1064 | * @depth: number of requests just added to the queue | |
1065 | * @explicit: whether this was an explicit unplug, or one from schedule() | |
1066 | * | |
1067 | * Unplug request queue @q because device driver is scheduled to work | |
1068 | * on elements in the request queue. | |
1069 | */ | |
7c68b363 | 1070 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) |
3bc29f0a | 1071 | LTTNG_TRACEPOINT_EVENT_INSTANCE(block_unplug, block_unplug, |
7c68b363 | 1072 | #else |
3bc29f0a | 1073 | LTTNG_TRACEPOINT_EVENT_INSTANCE(block_unplug, block_unplug_io, |
7c68b363 | 1074 | #endif |
f62b389e | 1075 | |
7c68b363 | 1076 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) |
f62b389e MD |
1077 | TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit), |
1078 | ||
1079 | TP_ARGS(q, depth, explicit) | |
7c68b363 AG |
1080 | #else |
1081 | TP_PROTO(struct request_queue *q), | |
1082 | ||
1083 | TP_ARGS(q) | |
1084 | #endif | |
f62b389e MD |
1085 | ) |
1086 | ||
1087 | /** | |
1088 | * block_split - split a single bio struct into two bio structs | |
1089 | * @q: queue containing the bio | |
1090 | * @bio: block operation being split | |
1091 | * @new_sector: The starting sector for the new bio | |
1092 | * | |
1093 | * The bio request @bio in request queue @q needs to be split into two | |
1094 | * bio requests. The newly created @bio request starts at | |
1095 | * @new_sector. This split may be required due to hardware limitation | |
1096 | * such as operation crossing device boundaries in a RAID system. | |
1097 | */ | |
3bc29f0a | 1098 | LTTNG_TRACEPOINT_EVENT(block_split, |
f62b389e MD |
1099 | |
1100 | TP_PROTO(struct request_queue *q, struct bio *bio, | |
1101 | unsigned int new_sector), | |
1102 | ||
1103 | TP_ARGS(q, bio, new_sector), | |
1104 | ||
f127e61e | 1105 | TP_FIELDS( |
7feabe53 MD |
1106 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0)) |
1107 | ctf_integer(dev_t, dev, bio_dev(bio)) | |
1108 | #else | |
959fe42a | 1109 | ctf_integer(dev_t, dev, bio->bi_bdev->bd_dev) |
7feabe53 | 1110 | #endif |
54c4c2e3 | 1111 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) |
f127e61e MD |
1112 | ctf_integer(sector_t, sector, bio->bi_iter.bi_sector) |
1113 | blk_rwbs_ctf_integer(unsigned int, rwbs, | |
e6d2cc09 MD |
1114 | lttng_bio_op(bio), lttng_bio_rw(bio), |
1115 | bio->bi_iter.bi_size) | |
54c4c2e3 | 1116 | #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */ |
f127e61e MD |
1117 | ctf_integer(sector_t, sector, bio->bi_sector) |
1118 | blk_rwbs_ctf_integer(unsigned int, rwbs, | |
e6d2cc09 | 1119 | lttng_bio_op(bio), lttng_bio_rw(bio), bio->bi_size) |
54c4c2e3 | 1120 | #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */ |
f127e61e MD |
1121 | ctf_integer(sector_t, new_sector, new_sector) |
1122 | ctf_integer(pid_t, tid, current->pid) | |
1123 | ctf_array_text(char, comm, current->comm, TASK_COMM_LEN) | |
1124 | ) | |
f62b389e MD |
1125 | ) |
1126 | ||
1127 | /** | |
1128 | * block_bio_remap - map request for a logical device to the raw device | |
1129 | * @q: queue holding the operation | |
1130 | * @bio: revised operation | |
1131 | * @dev: device for the operation | |
1132 | * @from: original sector for the operation | |
1133 | * | |
1134 | * An operation for a logical device has been mapped to the | |
1135 | * raw block device. | |
1136 | */ | |
7c68b363 | 1137 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) |
3bc29f0a | 1138 | LTTNG_TRACEPOINT_EVENT(block_bio_remap, |
7c68b363 | 1139 | #else |
3bc29f0a | 1140 | LTTNG_TRACEPOINT_EVENT(block_remap, |
7c68b363 | 1141 | #endif |
f62b389e MD |
1142 | |
1143 | TP_PROTO(struct request_queue *q, struct bio *bio, dev_t dev, | |
1144 | sector_t from), | |
1145 | ||
1146 | TP_ARGS(q, bio, dev, from), | |
1147 | ||
f127e61e | 1148 | TP_FIELDS( |
7feabe53 MD |
1149 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0)) |
1150 | ctf_integer(dev_t, dev, bio_dev(bio)) | |
1151 | #else | |
959fe42a | 1152 | ctf_integer(dev_t, dev, bio->bi_bdev->bd_dev) |
7feabe53 | 1153 | #endif |
54c4c2e3 | 1154 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) |
f127e61e MD |
1155 | ctf_integer(sector_t, sector, bio->bi_iter.bi_sector) |
1156 | ctf_integer(unsigned int, nr_sector, bio_sectors(bio)) | |
1157 | blk_rwbs_ctf_integer(unsigned int, rwbs, | |
e6d2cc09 MD |
1158 | lttng_bio_op(bio), lttng_bio_rw(bio), |
1159 | bio->bi_iter.bi_size) | |
54c4c2e3 | 1160 | #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */ |
f127e61e MD |
1161 | ctf_integer(sector_t, sector, bio->bi_sector) |
1162 | ctf_integer(unsigned int, nr_sector, bio->bi_size >> 9) | |
1163 | blk_rwbs_ctf_integer(unsigned int, rwbs, | |
e6d2cc09 | 1164 | lttng_bio_op(bio), lttng_bio_rw(bio), bio->bi_size) |
54c4c2e3 | 1165 | #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */ |
f127e61e MD |
1166 | ctf_integer(dev_t, old_dev, dev) |
1167 | ctf_integer(sector_t, old_sector, from) | |
1168 | ) | |
f62b389e MD |
1169 | ) |
1170 | ||
7c68b363 | 1171 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)) |
f62b389e MD |
1172 | /** |
1173 | * block_rq_remap - map request for a block operation request | |
1174 | * @q: queue holding the operation | |
1175 | * @rq: block IO operation request | |
1176 | * @dev: device for the operation | |
1177 | * @from: original sector for the operation | |
1178 | * | |
1179 | * The block operation request @rq in @q has been remapped. The block | |
1180 | * operation request @rq holds the current information and @from hold | |
1181 | * the original sector. | |
1182 | */ | |
3bc29f0a | 1183 | LTTNG_TRACEPOINT_EVENT(block_rq_remap, |
f62b389e MD |
1184 | |
1185 | TP_PROTO(struct request_queue *q, struct request *rq, dev_t dev, | |
1186 | sector_t from), | |
1187 | ||
1188 | TP_ARGS(q, rq, dev, from), | |
1189 | ||
f127e61e MD |
1190 | TP_FIELDS( |
1191 | ctf_integer(dev_t, dev, disk_devt(rq->rq_disk)) | |
1192 | ctf_integer(sector_t, sector, blk_rq_pos(rq)) | |
1193 | ctf_integer(unsigned int, nr_sector, blk_rq_sectors(rq)) | |
1194 | ctf_integer(dev_t, old_dev, dev) | |
1195 | ctf_integer(sector_t, old_sector, from) | |
1196 | blk_rwbs_ctf_integer(unsigned int, rwbs, | |
e6d2cc09 | 1197 | lttng_req_op(rq), lttng_req_rw(rq), blk_rq_bytes(rq)) |
f127e61e | 1198 | ) |
f62b389e | 1199 | ) |
7c68b363 | 1200 | #endif |
f62b389e MD |
1201 | |
1202 | #undef __print_rwbs_flags | |
1203 | #undef blk_fill_rwbs | |
1204 | ||
3bc29f0a | 1205 | #endif /* LTTNG_TRACE_BLOCK_H */ |
f62b389e MD |
1206 | |
1207 | /* This part must be outside protection */ | |
6ec43db8 | 1208 | #include <probes/define_trace.h> |