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