Fix: changes to the vm_op fault cb prototype in libringbuffer
[lttng-modules.git] / instrumentation / events / lttng-module / block.h
CommitLineData
f62b389e
MD
1#undef TRACE_SYSTEM
2#define TRACE_SYSTEM block
3
3bc29f0a
MD
4#if !defined(LTTNG_TRACE_BLOCK_H) || defined(TRACE_HEADER_MULTI_READ)
5#define LTTNG_TRACE_BLOCK_H
f62b389e 6
6ec43db8 7#include <probes/lttng-tracepoint-event.h>
f62b389e
MD
8#include <linux/blktrace_api.h>
9#include <linux/blkdev.h>
f62b389e 10#include <linux/trace_seq.h>
7c68b363
AG
11#include <linux/version.h>
12
f62b389e
MD
13#ifndef _TRACE_BLOCK_DEF_
14#define _TRACE_BLOCK_DEF_
15
f62b389e
MD
16enum {
17 RWBS_FLAG_WRITE = (1 << 0),
18 RWBS_FLAG_DISCARD = (1 << 1),
19 RWBS_FLAG_READ = (1 << 2),
20 RWBS_FLAG_RAHEAD = (1 << 3),
7c68b363
AG
21 RWBS_FLAG_BARRIER = (1 << 4),
22 RWBS_FLAG_SYNC = (1 << 5),
23 RWBS_FLAG_META = (1 << 6),
24 RWBS_FLAG_SECURE = (1 << 7),
25 RWBS_FLAG_FLUSH = (1 << 8),
26 RWBS_FLAG_FUA = (1 << 9),
e6d2cc09 27 RWBS_FLAG_PREFLUSH = (1 << 10),
f62b389e
MD
28};
29
30#endif /* _TRACE_BLOCK_DEF_ */
31
e6d2cc09
MD
32#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,8,0))
33
34#define lttng_req_op(rq) req_op(rq)
35#define lttng_req_rw(rq) ((rq)->cmd_flags)
36#define lttng_bio_op(bio) bio_op(bio)
37#define lttng_bio_rw(bio) ((bio)->bi_opf)
38
39#define blk_rwbs_ctf_integer(type, rwbs, op, rw, bytes) \
40 ctf_integer(type, rwbs, \
41 (((op) == REQ_OP_WRITE || (op) == REQ_OP_WRITE_SAME) ? RWBS_FLAG_WRITE : \
42 ( (op) == REQ_OP_DISCARD ? RWBS_FLAG_DISCARD : \
43 ( (op) == REQ_OP_SECURE_ERASE ? (RWBS_FLAG_DISCARD | RWBS_FLAG_SECURE) : \
44 ( (op) == REQ_OP_FLUSH ? RWBS_FLAG_FLUSH : \
45 ( (op) == REQ_OP_READ ? RWBS_FLAG_READ : \
46 ( 0 )))))) \
47 | ((rw) & REQ_RAHEAD ? RWBS_FLAG_RAHEAD : 0) \
48 | ((rw) & REQ_SYNC ? RWBS_FLAG_SYNC : 0) \
49 | ((rw) & REQ_META ? RWBS_FLAG_META : 0) \
50 | ((rw) & REQ_PREFLUSH ? RWBS_FLAG_PREFLUSH : 0) \
51 | ((rw) & REQ_FUA ? RWBS_FLAG_FUA : 0))
52
53#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
7c68b363 54
e6d2cc09
MD
55#define lttng_req_op(rq)
56#define lttng_req_rw(rq) ((rq)->cmd_flags)
57#define lttng_bio_op(bio)
58#define lttng_bio_rw(bio) ((bio)->bi_rw)
59
60#define blk_rwbs_ctf_integer(type, rwbs, op, rw, bytes) \
f127e61e 61 ctf_integer(type, rwbs, ((rw) & WRITE ? RWBS_FLAG_WRITE : \
7c68b363
AG
62 ( (rw) & REQ_DISCARD ? RWBS_FLAG_DISCARD : \
63 ( (bytes) ? RWBS_FLAG_READ : \
64 ( 0 )))) \
65 | ((rw) & REQ_RAHEAD ? RWBS_FLAG_RAHEAD : 0) \
66 | ((rw) & REQ_SYNC ? RWBS_FLAG_SYNC : 0) \
67 | ((rw) & REQ_META ? RWBS_FLAG_META : 0) \
68 | ((rw) & REQ_SECURE ? RWBS_FLAG_SECURE : 0) \
69 | ((rw) & REQ_FLUSH ? RWBS_FLAG_FLUSH : 0) \
70 | ((rw) & REQ_FUA ? RWBS_FLAG_FUA : 0))
71
72#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
73
e6d2cc09
MD
74#define lttng_req_op(rq)
75#define lttng_req_rw(rq) ((rq)->cmd_flags)
76#define lttng_bio_op(bio)
77#define lttng_bio_rw(bio) ((bio)->bi_rw)
78
79#define blk_rwbs_ctf_integer(type, rwbs, op, rw, bytes) \
f127e61e 80 ctf_integer(type, rwbs, ((rw) & WRITE ? RWBS_FLAG_WRITE : \
f62b389e
MD
81 ( (rw) & REQ_DISCARD ? RWBS_FLAG_DISCARD : \
82 ( (bytes) ? RWBS_FLAG_READ : \
83 ( 0 )))) \
84 | ((rw) & REQ_RAHEAD ? RWBS_FLAG_RAHEAD : 0) \
85 | ((rw) & REQ_SYNC ? RWBS_FLAG_SYNC : 0) \
86 | ((rw) & REQ_META ? RWBS_FLAG_META : 0) \
87 | ((rw) & REQ_SECURE ? RWBS_FLAG_SECURE : 0))
88
7c68b363
AG
89#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
90
e6d2cc09
MD
91#define lttng_req_op(rq)
92#define lttng_req_rw(rq) ((rq)->cmd_flags)
93#define lttng_bio_op(bio)
94#define lttng_bio_rw(bio) ((bio)->bi_rw)
95
96#define blk_rwbs_ctf_integer(type, rwbs, op, rw, bytes) \
f127e61e 97 ctf_integer(type, rwbs, ((rw) & WRITE ? RWBS_FLAG_WRITE : \
7c68b363
AG
98 ( (rw) & REQ_DISCARD ? RWBS_FLAG_DISCARD : \
99 ( (bytes) ? RWBS_FLAG_READ : \
100 ( 0 )))) \
101 | ((rw) & REQ_RAHEAD ? RWBS_FLAG_RAHEAD : 0) \
102 | ((rw) & REQ_HARDBARRIER ? RWBS_FLAG_BARRIER : 0) \
103 | ((rw) & REQ_SYNC ? RWBS_FLAG_SYNC : 0) \
104 | ((rw) & REQ_META ? RWBS_FLAG_META : 0) \
105 | ((rw) & REQ_SECURE ? RWBS_FLAG_SECURE : 0))
106
107#else
108
e6d2cc09
MD
109#define lttng_req_op(rq)
110#define lttng_req_rw(rq) ((rq)->cmd_flags)
111#define lttng_bio_op(bio)
112#define lttng_bio_rw(bio) ((bio)->bi_rw)
113
114#define blk_rwbs_ctf_integer(type, rwbs, op, rw, bytes) \
f127e61e 115 ctf_integer(type, rwbs, ((rw) & WRITE ? RWBS_FLAG_WRITE : \
7c68b363
AG
116 ( (rw) & (1 << BIO_RW_DISCARD) ? RWBS_FLAG_DISCARD : \
117 ( (bytes) ? RWBS_FLAG_READ : \
118 ( 0 )))) \
119 | ((rw) & (1 << BIO_RW_AHEAD) ? RWBS_FLAG_RAHEAD : 0) \
120 | ((rw) & (1 << BIO_RW_SYNCIO) ? RWBS_FLAG_SYNC : 0) \
121 | ((rw) & (1 << BIO_RW_META) ? RWBS_FLAG_META : 0) \
122 | ((rw) & (1 << BIO_RW_BARRIER) ? RWBS_FLAG_BARRIER : 0))
123
124#endif
125
217f66c6 126#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
3bc29f0a 127LTTNG_TRACEPOINT_EVENT_CLASS(block_buffer,
217f66c6
MD
128
129 TP_PROTO(struct buffer_head *bh),
130
131 TP_ARGS(bh),
132
f127e61e
MD
133 TP_FIELDS (
134 ctf_integer(dev_t, dev, bh->b_bdev->bd_dev)
135 ctf_integer(sector_t, sector, bh->b_blocknr)
136 ctf_integer(size_t, size, bh->b_size)
217f66c6
MD
137 )
138)
139
140/**
141 * block_touch_buffer - mark a buffer accessed
142 * @bh: buffer_head being touched
143 *
144 * Called from touch_buffer().
145 */
3bc29f0a 146LTTNG_TRACEPOINT_EVENT_INSTANCE(block_buffer, block_touch_buffer,
217f66c6
MD
147
148 TP_PROTO(struct buffer_head *bh),
149
150 TP_ARGS(bh)
151)
152
153/**
154 * block_dirty_buffer - mark a buffer dirty
155 * @bh: buffer_head being dirtied
156 *
157 * Called from mark_buffer_dirty().
158 */
3bc29f0a 159LTTNG_TRACEPOINT_EVENT_INSTANCE(block_buffer, block_dirty_buffer,
217f66c6
MD
160
161 TP_PROTO(struct buffer_head *bh),
162
163 TP_ARGS(bh)
164)
165#endif
166
f127e61e 167LTTNG_TRACEPOINT_EVENT_CLASS_CODE(block_rq_with_error,
f62b389e
MD
168
169 TP_PROTO(struct request_queue *q, struct request *rq),
170
171 TP_ARGS(q, rq),
172
f127e61e
MD
173 TP_locvar(
174 sector_t sector;
175 unsigned int nr_sector;
176 unsigned char *cmd;
177 size_t cmd_len;
f62b389e
MD
178 ),
179
265822ae 180 TP_code_pre(
f127e61e
MD
181 if (rq->cmd_type == REQ_TYPE_BLOCK_PC) {
182 tp_locvar->sector = 0;
183 tp_locvar->nr_sector = 0;
184 tp_locvar->cmd = rq->cmd;
185 tp_locvar->cmd_len = rq->cmd_len;
186 } else {
187 tp_locvar->sector = blk_rq_pos(rq);
188 tp_locvar->nr_sector = blk_rq_sectors(rq);
189 tp_locvar->cmd = NULL;
190 tp_locvar->cmd_len = 0;
191 }
f62b389e
MD
192 ),
193
f127e61e
MD
194 TP_FIELDS(
195 ctf_integer(dev_t, dev,
196 rq->rq_disk ? disk_devt(rq->rq_disk) : 0)
197 ctf_integer(sector_t, sector, tp_locvar->sector)
198 ctf_integer(unsigned int, nr_sector, tp_locvar->nr_sector)
199 ctf_integer(int, errors, rq->errors)
200 blk_rwbs_ctf_integer(unsigned int, rwbs,
e6d2cc09 201 lttng_req_op(rq), lttng_req_rw(rq), blk_rq_bytes(rq))
f127e61e
MD
202 ctf_sequence_hex(unsigned char, cmd,
203 tp_locvar->cmd, size_t, tp_locvar->cmd_len)
265822ae
MD
204 ),
205
206 TP_code_post()
f62b389e
MD
207)
208
209/**
210 * block_rq_abort - abort block operation request
211 * @q: queue containing the block operation request
212 * @rq: block IO operation request
213 *
214 * Called immediately after pending block IO operation request @rq in
215 * queue @q is aborted. The fields in the operation request @rq
216 * can be examined to determine which device and sectors the pending
217 * operation would access.
218 */
3bc29f0a 219LTTNG_TRACEPOINT_EVENT_INSTANCE(block_rq_with_error, block_rq_abort,
f62b389e
MD
220
221 TP_PROTO(struct request_queue *q, struct request *rq),
222
223 TP_ARGS(q, rq)
224)
225
226/**
227 * block_rq_requeue - place block IO request back on a queue
228 * @q: queue holding operation
229 * @rq: block IO operation request
230 *
231 * The block operation request @rq is being placed back into queue
232 * @q. For some reason the request was not completed and needs to be
233 * put back in the queue.
234 */
3bc29f0a 235LTTNG_TRACEPOINT_EVENT_INSTANCE(block_rq_with_error, block_rq_requeue,
f62b389e
MD
236
237 TP_PROTO(struct request_queue *q, struct request *rq),
238
239 TP_ARGS(q, rq)
240)
241
bba0442a
AB
242#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,5) \
243 || LTTNG_KERNEL_RANGE(3,12,21, 3,13,0) \
244 || LTTNG_KERNEL_RANGE(3,10,41, 3,11,0) \
cc3b2f06 245 || LTTNG_KERNEL_RANGE(3,4,91, 3,5,0) \
f64d76a5 246 || LTTNG_KERNEL_RANGE(3,2,58, 3,3,0) \
ff45399f 247 || LTTNG_UBUNTU_KERNEL_RANGE(3,13,11,28, 3,14,0,0) \
c94ac1ac 248 || LTTNG_RHEL_KERNEL_RANGE(3,10,0,229,0,0, 3,11,0,0,0,0))
1c53e689
MD
249
250/**
251 * block_rq_complete - block IO operation completed by device driver
252 * @q: queue containing the block operation request
253 * @rq: block operations request
254 * @nr_bytes: number of completed bytes
255 *
256 * The block_rq_complete tracepoint event indicates that some portion
257 * of operation request has been completed by the device driver. If
258 * the @rq->bio is %NULL, then there is absolutely no additional work to
259 * do for the request. If @rq->bio is non-NULL then there is
260 * additional work required to complete the request.
261 */
f127e61e 262LTTNG_TRACEPOINT_EVENT_CODE(block_rq_complete,
1c53e689
MD
263
264 TP_PROTO(struct request_queue *q, struct request *rq,
265 unsigned int nr_bytes),
266
267 TP_ARGS(q, rq, nr_bytes),
268
f127e61e
MD
269 TP_locvar(
270 unsigned char *cmd;
271 size_t cmd_len;
1c53e689
MD
272 ),
273
265822ae 274 TP_code_pre(
f127e61e
MD
275 if (rq->cmd_type == REQ_TYPE_BLOCK_PC) {
276 tp_locvar->cmd = rq->cmd;
277 tp_locvar->cmd_len = rq->cmd_len;
278 } else {
279 tp_locvar->cmd = NULL;
280 tp_locvar->cmd_len = 0;
281 }
1c53e689
MD
282 ),
283
f127e61e
MD
284 TP_FIELDS(
285 ctf_integer(dev_t, dev,
286 rq->rq_disk ? disk_devt(rq->rq_disk) : 0)
287 ctf_integer(sector_t, sector, blk_rq_pos(rq))
288 ctf_integer(unsigned int, nr_sector, nr_bytes >> 9)
289 ctf_integer(int, errors, rq->errors)
290 blk_rwbs_ctf_integer(unsigned int, rwbs,
e6d2cc09 291 lttng_req_op(rq), lttng_req_rw(rq), nr_bytes)
f127e61e
MD
292 ctf_sequence_hex(unsigned char, cmd,
293 tp_locvar->cmd, size_t, tp_locvar->cmd_len)
265822ae
MD
294 ),
295
296 TP_code_post()
1c53e689
MD
297)
298
299#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) */
300
f62b389e
MD
301/**
302 * block_rq_complete - block IO operation completed by device driver
303 * @q: queue containing the block operation request
304 * @rq: block operations request
305 *
306 * The block_rq_complete tracepoint event indicates that some portion
307 * of operation request has been completed by the device driver. If
308 * the @rq->bio is %NULL, then there is absolutely no additional work to
309 * do for the request. If @rq->bio is non-NULL then there is
310 * additional work required to complete the request.
311 */
3bc29f0a 312LTTNG_TRACEPOINT_EVENT_INSTANCE(block_rq_with_error, block_rq_complete,
f62b389e
MD
313
314 TP_PROTO(struct request_queue *q, struct request *rq),
315
316 TP_ARGS(q, rq)
317)
318
1c53e689
MD
319#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) */
320
f127e61e 321LTTNG_TRACEPOINT_EVENT_CLASS_CODE(block_rq,
f62b389e
MD
322
323 TP_PROTO(struct request_queue *q, struct request *rq),
324
325 TP_ARGS(q, rq),
326
f127e61e
MD
327 TP_locvar(
328 sector_t sector;
329 unsigned int nr_sector;
330 unsigned int bytes;
331 unsigned char *cmd;
332 size_t cmd_len;
f62b389e
MD
333 ),
334
265822ae 335 TP_code_pre(
f127e61e
MD
336 if (rq->cmd_type == REQ_TYPE_BLOCK_PC) {
337 tp_locvar->sector = 0;
338 tp_locvar->nr_sector = 0;
339 tp_locvar->bytes = blk_rq_bytes(rq);
340 tp_locvar->cmd = rq->cmd;
341 tp_locvar->cmd_len = rq->cmd_len;
342 } else {
343 tp_locvar->sector = blk_rq_pos(rq);
344 tp_locvar->nr_sector = blk_rq_sectors(rq);
345 tp_locvar->bytes = 0;
346 tp_locvar->cmd = NULL;
347 tp_locvar->cmd_len = 0;
348 }
f62b389e
MD
349 ),
350
f127e61e
MD
351 TP_FIELDS(
352 ctf_integer(dev_t, dev,
353 rq->rq_disk ? disk_devt(rq->rq_disk) : 0)
354 ctf_integer(sector_t, sector, tp_locvar->sector)
355 ctf_integer(unsigned int, nr_sector, tp_locvar->nr_sector)
356 ctf_integer(unsigned int, bytes, tp_locvar->bytes)
357 ctf_integer(pid_t, tid, current->pid)
358 blk_rwbs_ctf_integer(unsigned int, rwbs,
e6d2cc09 359 lttng_req_op(rq), lttng_req_rw(rq), blk_rq_bytes(rq))
f127e61e
MD
360 ctf_sequence_hex(unsigned char, cmd,
361 tp_locvar->cmd, size_t, tp_locvar->cmd_len)
362 ctf_array_text(char, comm, current->comm, TASK_COMM_LEN)
265822ae
MD
363 ),
364
365 TP_code_post()
f62b389e
MD
366)
367
368/**
369 * block_rq_insert - insert block operation request into queue
370 * @q: target queue
371 * @rq: block IO operation request
372 *
373 * Called immediately before block operation request @rq is inserted
374 * into queue @q. The fields in the operation request @rq struct can
375 * be examined to determine which device and sectors the pending
376 * operation would access.
377 */
3bc29f0a 378LTTNG_TRACEPOINT_EVENT_INSTANCE(block_rq, block_rq_insert,
f62b389e
MD
379
380 TP_PROTO(struct request_queue *q, struct request *rq),
381
382 TP_ARGS(q, rq)
383)
384
385/**
386 * block_rq_issue - issue pending block IO request operation to device driver
387 * @q: queue holding operation
388 * @rq: block IO operation operation request
389 *
390 * Called when block operation request @rq from queue @q is sent to a
391 * device driver for processing.
392 */
3bc29f0a 393LTTNG_TRACEPOINT_EVENT_INSTANCE(block_rq, block_rq_issue,
f62b389e
MD
394
395 TP_PROTO(struct request_queue *q, struct request *rq),
396
397 TP_ARGS(q, rq)
398)
399
400/**
401 * block_bio_bounce - used bounce buffer when processing block operation
402 * @q: queue holding the block operation
403 * @bio: block operation
404 *
405 * A bounce buffer was used to handle the block operation @bio in @q.
406 * This occurs when hardware limitations prevent a direct transfer of
407 * data between the @bio data memory area and the IO device. Use of a
408 * bounce buffer requires extra copying of data and decreases
409 * performance.
410 */
3bc29f0a 411LTTNG_TRACEPOINT_EVENT(block_bio_bounce,
f62b389e
MD
412
413 TP_PROTO(struct request_queue *q, struct bio *bio),
414
415 TP_ARGS(q, bio),
416
f127e61e
MD
417 TP_FIELDS(
418 ctf_integer(dev_t, dev, bio->bi_bdev ? bio->bi_bdev->bd_dev : 0)
54c4c2e3 419#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
f127e61e
MD
420 ctf_integer(sector_t, sector, bio->bi_iter.bi_sector)
421 ctf_integer(unsigned int, nr_sector, bio_sectors(bio))
422 blk_rwbs_ctf_integer(unsigned int, rwbs,
e6d2cc09
MD
423 lttng_bio_op(bio), lttng_bio_rw(bio),
424 bio->bi_iter.bi_size)
54c4c2e3 425#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
f127e61e
MD
426 ctf_integer(sector_t, sector, bio->bi_sector)
427 ctf_integer(unsigned int, nr_sector, bio->bi_size >> 9)
428 blk_rwbs_ctf_integer(unsigned int, rwbs,
e6d2cc09
MD
429 lttng_bio_op(bio), lttng_bio_rw(bio),
430 bio->bi_size)
54c4c2e3 431#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
f127e61e
MD
432 ctf_integer(pid_t, tid, current->pid)
433 ctf_array_text(char, comm, current->comm, TASK_COMM_LEN)
434 )
f62b389e
MD
435)
436
437/**
438 * block_bio_complete - completed all work on the block operation
439 * @q: queue holding the block operation
440 * @bio: block operation completed
441 * @error: io error value
442 *
443 * This tracepoint indicates there is no further work to do on this
444 * block IO operation @bio.
445 */
3bc29f0a 446LTTNG_TRACEPOINT_EVENT(block_bio_complete,
f62b389e 447
1bc491fc 448#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
f62b389e
MD
449 TP_PROTO(struct request_queue *q, struct bio *bio, int error),
450
451 TP_ARGS(q, bio, error),
7c68b363
AG
452#else
453 TP_PROTO(struct request_queue *q, struct bio *bio),
454
455 TP_ARGS(q, bio),
456#endif
f62b389e 457
f127e61e
MD
458 TP_FIELDS(
459 ctf_integer(dev_t, dev, bio->bi_bdev->bd_dev)
54c4c2e3 460#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
f127e61e
MD
461 ctf_integer(sector_t, sector, bio->bi_iter.bi_sector)
462 ctf_integer(unsigned int, nr_sector, bio_sectors(bio))
463 ctf_integer(int, error, error)
464 blk_rwbs_ctf_integer(unsigned int, rwbs,
e6d2cc09
MD
465 lttng_bio_op(bio), lttng_bio_rw(bio),
466 bio->bi_iter.bi_size)
54c4c2e3 467#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
f127e61e
MD
468 ctf_integer(sector_t, sector, bio->bi_sector)
469 ctf_integer(unsigned int, nr_sector, bio->bi_size >> 9)
7c68b363 470#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
f127e61e 471 ctf_integer(int, error, error)
7c68b363 472#else
f127e61e 473 ctf_integer(int, error, 0)
7c68b363 474#endif
f127e61e 475 blk_rwbs_ctf_integer(unsigned int, rwbs,
e6d2cc09 476 lttng_bio_op(bio), lttng_bio_rw(bio), bio->bi_size)
54c4c2e3 477#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
f127e61e 478 )
f62b389e
MD
479)
480
217f66c6 481#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
3bc29f0a 482LTTNG_TRACEPOINT_EVENT_CLASS(block_bio_merge,
217f66c6
MD
483
484 TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio),
485
486 TP_ARGS(q, rq, bio),
487
f127e61e
MD
488 TP_FIELDS(
489 ctf_integer(dev_t, dev, bio->bi_bdev->bd_dev)
54c4c2e3 490#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
f127e61e
MD
491 ctf_integer(sector_t, sector, bio->bi_iter.bi_sector)
492 ctf_integer(unsigned int, nr_sector, bio_sectors(bio))
493 blk_rwbs_ctf_integer(unsigned int, rwbs,
e6d2cc09
MD
494 lttng_bio_op(bio), lttng_bio_rw(bio),
495 bio->bi_iter.bi_size)
54c4c2e3 496#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
f127e61e
MD
497 ctf_integer(sector_t, sector, bio->bi_sector)
498 ctf_integer(unsigned int, nr_sector, bio->bi_size >> 9)
499 blk_rwbs_ctf_integer(unsigned int, rwbs,
e6d2cc09 500 lttng_bio_op(bio), lttng_bio_rw(bio), bio->bi_size)
54c4c2e3 501#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
f127e61e
MD
502 ctf_integer(pid_t, tid, current->pid)
503 ctf_array_text(char, comm, current->comm, TASK_COMM_LEN)
504 )
217f66c6
MD
505)
506
507/**
508 * block_bio_backmerge - merging block operation to the end of an existing operation
509 * @q: queue holding operation
510 * @bio: new block operation to merge
511 *
512 * Merging block request @bio to the end of an existing block request
513 * in queue @q.
514 */
3bc29f0a 515LTTNG_TRACEPOINT_EVENT_INSTANCE(block_bio_merge, block_bio_backmerge,
217f66c6
MD
516
517 TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio),
518
519 TP_ARGS(q, rq, bio)
520)
521
522/**
523 * block_bio_frontmerge - merging block operation to the beginning of an existing operation
524 * @q: queue holding operation
525 * @bio: new block operation to merge
526 *
527 * Merging block IO operation @bio to the beginning of an existing block
528 * operation in queue @q.
529 */
3bc29f0a 530LTTNG_TRACEPOINT_EVENT_INSTANCE(block_bio_merge, block_bio_frontmerge,
217f66c6
MD
531
532 TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio),
533
534 TP_ARGS(q, rq, bio)
535)
536
537/**
538 * block_bio_queue - putting new block IO operation in queue
539 * @q: queue holding operation
540 * @bio: new block operation
541 *
542 * About to place the block IO operation @bio into queue @q.
543 */
3bc29f0a 544LTTNG_TRACEPOINT_EVENT(block_bio_queue,
217f66c6
MD
545
546 TP_PROTO(struct request_queue *q, struct bio *bio),
547
548 TP_ARGS(q, bio),
549
f127e61e
MD
550 TP_FIELDS(
551 ctf_integer(dev_t, dev, bio->bi_bdev->bd_dev)
54c4c2e3 552#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
f127e61e
MD
553 ctf_integer(sector_t, sector, bio->bi_iter.bi_sector)
554 ctf_integer(unsigned int, nr_sector, bio_sectors(bio))
555 blk_rwbs_ctf_integer(unsigned int, rwbs,
e6d2cc09
MD
556 lttng_bio_op(bio), lttng_bio_rw(bio),
557 bio->bi_iter.bi_size)
54c4c2e3 558#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
f127e61e
MD
559 ctf_integer(sector_t, sector, bio->bi_sector)
560 ctf_integer(unsigned int, nr_sector, bio->bi_size >> 9)
561 blk_rwbs_ctf_integer(unsigned int, rwbs,
e6d2cc09 562 lttng_bio_op(bio), lttng_bio_rw(bio), bio->bi_size)
54c4c2e3 563#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
f127e61e
MD
564 ctf_integer(pid_t, tid, current->pid)
565 ctf_array_text(char, comm, current->comm, TASK_COMM_LEN)
566 )
217f66c6 567)
f127e61e 568#else /* if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) */
3bc29f0a 569LTTNG_TRACEPOINT_EVENT_CLASS(block_bio,
f62b389e
MD
570
571 TP_PROTO(struct request_queue *q, struct bio *bio),
572
573 TP_ARGS(q, bio),
574
f127e61e
MD
575 TP_FIELDS(
576 ctf_integer(dev_t, dev, bio->bi_bdev ? bio->bi_bdev->bd_dev : 0)
577 ctf_integer(sector_t, sector, bio->bi_sector)
578 ctf_integer(unsigned int, nr_sector, bio->bi_size >> 9)
579 blk_rwbs_ctf_integer(unsigned int, rwbs,
e6d2cc09 580 lttng_bio_op(bio), lttng_bio_rw(bio), bio->bi_size)
f127e61e
MD
581 ctf_integer(pid_t, tid, current->pid)
582 ctf_array_text(char, comm, current->comm, TASK_COMM_LEN)
583 )
f62b389e
MD
584)
585
586/**
587 * block_bio_backmerge - merging block operation to the end of an existing operation
588 * @q: queue holding operation
589 * @bio: new block operation to merge
590 *
591 * Merging block request @bio to the end of an existing block request
592 * in queue @q.
593 */
3bc29f0a 594LTTNG_TRACEPOINT_EVENT_INSTANCE(block_bio, block_bio_backmerge,
f62b389e
MD
595
596 TP_PROTO(struct request_queue *q, struct bio *bio),
597
598 TP_ARGS(q, bio)
599)
600
601/**
602 * block_bio_frontmerge - merging block operation to the beginning of an existing operation
603 * @q: queue holding operation
604 * @bio: new block operation to merge
605 *
606 * Merging block IO operation @bio to the beginning of an existing block
607 * operation in queue @q.
608 */
3bc29f0a 609LTTNG_TRACEPOINT_EVENT_INSTANCE(block_bio, block_bio_frontmerge,
f62b389e
MD
610
611 TP_PROTO(struct request_queue *q, struct bio *bio),
612
613 TP_ARGS(q, bio)
614)
615
616/**
617 * block_bio_queue - putting new block IO operation in queue
618 * @q: queue holding operation
619 * @bio: new block operation
620 *
621 * About to place the block IO operation @bio into queue @q.
622 */
3bc29f0a 623LTTNG_TRACEPOINT_EVENT_INSTANCE(block_bio, block_bio_queue,
f62b389e
MD
624
625 TP_PROTO(struct request_queue *q, struct bio *bio),
626
627 TP_ARGS(q, bio)
628)
f127e61e 629#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) */
f62b389e 630
3bc29f0a 631LTTNG_TRACEPOINT_EVENT_CLASS(block_get_rq,
f62b389e
MD
632
633 TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
634
635 TP_ARGS(q, bio, rw),
636
f127e61e
MD
637 TP_FIELDS(
638 ctf_integer(dev_t, dev, bio ? bio->bi_bdev->bd_dev : 0)
54c4c2e3 639#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
f127e61e
MD
640 ctf_integer(sector_t, sector, bio ? bio->bi_iter.bi_sector : 0)
641 ctf_integer(unsigned int, nr_sector,
642 bio ? bio_sectors(bio) : 0)
643 blk_rwbs_ctf_integer(unsigned int, rwbs,
e6d2cc09
MD
644 bio ? lttng_bio_op(bio) : 0,
645 bio ? lttng_bio_rw(bio) : 0,
f127e61e 646 bio ? bio->bi_iter.bi_size : 0)
54c4c2e3 647#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
f127e61e
MD
648 ctf_integer(sector_t, sector, bio ? bio->bi_sector : 0)
649 ctf_integer(unsigned int, nr_sector,
650 bio ? bio->bi_size >> 9 : 0)
651 blk_rwbs_ctf_integer(unsigned int, rwbs,
e6d2cc09
MD
652 bio ? lttng_bio_op(bio) : 0,
653 bio ? lttng_bio_rw(bio) : 0,
f127e61e 654 bio ? bio->bi_size : 0)
54c4c2e3 655#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
f127e61e
MD
656 ctf_integer(pid_t, tid, current->pid)
657 ctf_array_text(char, comm, current->comm, TASK_COMM_LEN)
658 )
f62b389e
MD
659)
660
661/**
662 * block_getrq - get a free request entry in queue for block IO operations
663 * @q: queue for operations
664 * @bio: pending block IO operation
665 * @rw: low bit indicates a read (%0) or a write (%1)
666 *
667 * A request struct for queue @q has been allocated to handle the
668 * block IO operation @bio.
669 */
3bc29f0a 670LTTNG_TRACEPOINT_EVENT_INSTANCE(block_get_rq, block_getrq,
f62b389e
MD
671
672 TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
673
674 TP_ARGS(q, bio, rw)
675)
676
677/**
678 * block_sleeprq - waiting to get a free request entry in queue for block IO operation
679 * @q: queue for operation
680 * @bio: pending block IO operation
681 * @rw: low bit indicates a read (%0) or a write (%1)
682 *
683 * In the case where a request struct cannot be provided for queue @q
684 * the process needs to wait for an request struct to become
685 * available. This tracepoint event is generated each time the
686 * process goes to sleep waiting for request struct become available.
687 */
3bc29f0a 688LTTNG_TRACEPOINT_EVENT_INSTANCE(block_get_rq, block_sleeprq,
f62b389e
MD
689
690 TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
691
692 TP_ARGS(q, bio, rw)
693)
694
695/**
696 * block_plug - keep operations requests in request queue
697 * @q: request queue to plug
698 *
699 * Plug the request queue @q. Do not allow block operation requests
700 * to be sent to the device driver. Instead, accumulate requests in
701 * the queue to improve throughput performance of the block device.
702 */
3bc29f0a 703LTTNG_TRACEPOINT_EVENT(block_plug,
f62b389e
MD
704
705 TP_PROTO(struct request_queue *q),
706
707 TP_ARGS(q),
708
f127e61e
MD
709 TP_FIELDS(
710 ctf_integer(pid_t, tid, current->pid)
711 ctf_array_text(char, comm, current->comm, TASK_COMM_LEN)
712 )
f62b389e
MD
713)
714
3bc29f0a 715LTTNG_TRACEPOINT_EVENT_CLASS(block_unplug,
f62b389e 716
7c68b363 717#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
f62b389e
MD
718 TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit),
719
720 TP_ARGS(q, depth, explicit),
7c68b363
AG
721#else
722 TP_PROTO(struct request_queue *q),
723
724 TP_ARGS(q),
725#endif
f62b389e 726
f127e61e 727 TP_FIELDS(
7c68b363 728#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
f127e61e 729 ctf_integer(int, nr_rq, depth)
7c68b363 730#else
f127e61e 731 ctf_integer(int, nr_rq, q->rq.count[READ] + q->rq.count[WRITE])
7c68b363 732#endif
f127e61e
MD
733 ctf_integer(pid_t, tid, current->pid)
734 ctf_array_text(char, comm, current->comm, TASK_COMM_LEN)
735 )
f62b389e
MD
736)
737
7c68b363
AG
738#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39))
739/**
740 * block_unplug_timer - timed release of operations requests in queue to device driver
741 * @q: request queue to unplug
742 *
743 * Unplug the request queue @q because a timer expired and allow block
744 * operation requests to be sent to the device driver.
745 */
3bc29f0a 746LTTNG_TRACEPOINT_EVENT_INSTANCE(block_unplug, block_unplug_timer,
7c68b363
AG
747
748 TP_PROTO(struct request_queue *q),
749
750 TP_ARGS(q)
751)
752#endif
753
f62b389e
MD
754/**
755 * block_unplug - release of operations requests in request queue
756 * @q: request queue to unplug
757 * @depth: number of requests just added to the queue
758 * @explicit: whether this was an explicit unplug, or one from schedule()
759 *
760 * Unplug request queue @q because device driver is scheduled to work
761 * on elements in the request queue.
762 */
7c68b363 763#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
3bc29f0a 764LTTNG_TRACEPOINT_EVENT_INSTANCE(block_unplug, block_unplug,
7c68b363 765#else
3bc29f0a 766LTTNG_TRACEPOINT_EVENT_INSTANCE(block_unplug, block_unplug_io,
7c68b363 767#endif
f62b389e 768
7c68b363 769#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
f62b389e
MD
770 TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit),
771
772 TP_ARGS(q, depth, explicit)
7c68b363
AG
773#else
774 TP_PROTO(struct request_queue *q),
775
776 TP_ARGS(q)
777#endif
f62b389e
MD
778)
779
780/**
781 * block_split - split a single bio struct into two bio structs
782 * @q: queue containing the bio
783 * @bio: block operation being split
784 * @new_sector: The starting sector for the new bio
785 *
786 * The bio request @bio in request queue @q needs to be split into two
787 * bio requests. The newly created @bio request starts at
788 * @new_sector. This split may be required due to hardware limitation
789 * such as operation crossing device boundaries in a RAID system.
790 */
3bc29f0a 791LTTNG_TRACEPOINT_EVENT(block_split,
f62b389e
MD
792
793 TP_PROTO(struct request_queue *q, struct bio *bio,
794 unsigned int new_sector),
795
796 TP_ARGS(q, bio, new_sector),
797
f127e61e
MD
798 TP_FIELDS(
799 ctf_integer(dev_t, dev, bio->bi_bdev->bd_dev)
54c4c2e3 800#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
f127e61e
MD
801 ctf_integer(sector_t, sector, bio->bi_iter.bi_sector)
802 blk_rwbs_ctf_integer(unsigned int, rwbs,
e6d2cc09
MD
803 lttng_bio_op(bio), lttng_bio_rw(bio),
804 bio->bi_iter.bi_size)
54c4c2e3 805#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
f127e61e
MD
806 ctf_integer(sector_t, sector, bio->bi_sector)
807 blk_rwbs_ctf_integer(unsigned int, rwbs,
e6d2cc09 808 lttng_bio_op(bio), lttng_bio_rw(bio), bio->bi_size)
54c4c2e3 809#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
f127e61e
MD
810 ctf_integer(sector_t, new_sector, new_sector)
811 ctf_integer(pid_t, tid, current->pid)
812 ctf_array_text(char, comm, current->comm, TASK_COMM_LEN)
813 )
f62b389e
MD
814)
815
816/**
817 * block_bio_remap - map request for a logical device to the raw device
818 * @q: queue holding the operation
819 * @bio: revised operation
820 * @dev: device for the operation
821 * @from: original sector for the operation
822 *
823 * An operation for a logical device has been mapped to the
824 * raw block device.
825 */
7c68b363 826#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3bc29f0a 827LTTNG_TRACEPOINT_EVENT(block_bio_remap,
7c68b363 828#else
3bc29f0a 829LTTNG_TRACEPOINT_EVENT(block_remap,
7c68b363 830#endif
f62b389e
MD
831
832 TP_PROTO(struct request_queue *q, struct bio *bio, dev_t dev,
833 sector_t from),
834
835 TP_ARGS(q, bio, dev, from),
836
f127e61e
MD
837 TP_FIELDS(
838 ctf_integer(dev_t, dev, bio->bi_bdev->bd_dev)
54c4c2e3 839#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
f127e61e
MD
840 ctf_integer(sector_t, sector, bio->bi_iter.bi_sector)
841 ctf_integer(unsigned int, nr_sector, bio_sectors(bio))
842 blk_rwbs_ctf_integer(unsigned int, rwbs,
e6d2cc09
MD
843 lttng_bio_op(bio), lttng_bio_rw(bio),
844 bio->bi_iter.bi_size)
54c4c2e3 845#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
f127e61e
MD
846 ctf_integer(sector_t, sector, bio->bi_sector)
847 ctf_integer(unsigned int, nr_sector, bio->bi_size >> 9)
848 blk_rwbs_ctf_integer(unsigned int, rwbs,
e6d2cc09 849 lttng_bio_op(bio), lttng_bio_rw(bio), bio->bi_size)
54c4c2e3 850#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
f127e61e
MD
851 ctf_integer(dev_t, old_dev, dev)
852 ctf_integer(sector_t, old_sector, from)
853 )
f62b389e
MD
854)
855
7c68b363 856#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32))
f62b389e
MD
857/**
858 * block_rq_remap - map request for a block operation request
859 * @q: queue holding the operation
860 * @rq: block IO operation request
861 * @dev: device for the operation
862 * @from: original sector for the operation
863 *
864 * The block operation request @rq in @q has been remapped. The block
865 * operation request @rq holds the current information and @from hold
866 * the original sector.
867 */
3bc29f0a 868LTTNG_TRACEPOINT_EVENT(block_rq_remap,
f62b389e
MD
869
870 TP_PROTO(struct request_queue *q, struct request *rq, dev_t dev,
871 sector_t from),
872
873 TP_ARGS(q, rq, dev, from),
874
f127e61e
MD
875 TP_FIELDS(
876 ctf_integer(dev_t, dev, disk_devt(rq->rq_disk))
877 ctf_integer(sector_t, sector, blk_rq_pos(rq))
878 ctf_integer(unsigned int, nr_sector, blk_rq_sectors(rq))
879 ctf_integer(dev_t, old_dev, dev)
880 ctf_integer(sector_t, old_sector, from)
881 blk_rwbs_ctf_integer(unsigned int, rwbs,
e6d2cc09 882 lttng_req_op(rq), lttng_req_rw(rq), blk_rq_bytes(rq))
f127e61e 883 )
f62b389e 884)
7c68b363 885#endif
f62b389e
MD
886
887#undef __print_rwbs_flags
888#undef blk_fill_rwbs
889
3bc29f0a 890#endif /* LTTNG_TRACE_BLOCK_H */
f62b389e
MD
891
892/* This part must be outside protection */
6ec43db8 893#include <probes/define_trace.h>
This page took 0.073306 seconds and 4 git commands to generate.