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