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