c43d747110e21b908bdb17d26b9502daf75a0f36
[lttng-modules.git] / instrumentation / events / lttng-module / block.h
1 #undef TRACE_SYSTEM
2 #define TRACE_SYSTEM block
3
4 #if !defined(LTTNG_TRACE_BLOCK_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define LTTNG_TRACE_BLOCK_H
6
7 #include <probes/lttng-tracepoint-event.h>
8 #include <linux/blktrace_api.h>
9 #include <linux/blkdev.h>
10 #include <linux/trace_seq.h>
11 #include <linux/version.h>
12
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
17 #ifndef _TRACE_BLOCK_DEF_
18 #define _TRACE_BLOCK_DEF_
19
20 enum {
21 RWBS_FLAG_WRITE = (1 << 0),
22 RWBS_FLAG_DISCARD = (1 << 1),
23 RWBS_FLAG_READ = (1 << 2),
24 RWBS_FLAG_RAHEAD = (1 << 3),
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),
31 RWBS_FLAG_PREFLUSH = (1 << 10),
32 };
33
34 #endif /* _TRACE_BLOCK_DEF_ */
35
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))
58
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) \
65 ctf_integer(type, rwbs, ((rw) & WRITE ? RWBS_FLAG_WRITE : \
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
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) \
84 ctf_integer(type, rwbs, ((rw) & WRITE ? RWBS_FLAG_WRITE : \
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
93 #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
94
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) \
101 ctf_integer(type, rwbs, ((rw) & WRITE ? RWBS_FLAG_WRITE : \
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
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) \
119 ctf_integer(type, rwbs, ((rw) & WRITE ? RWBS_FLAG_WRITE : \
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
130 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
131 LTTNG_TRACEPOINT_EVENT_CLASS(block_buffer,
132
133 TP_PROTO(struct buffer_head *bh),
134
135 TP_ARGS(bh),
136
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)
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 */
150 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_buffer, block_touch_buffer,
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 */
163 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_buffer, block_dirty_buffer,
164
165 TP_PROTO(struct buffer_head *bh),
166
167 TP_ARGS(bh)
168 )
169 #endif
170
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))
174 LTTNG_TRACEPOINT_EVENT_CLASS_CODE(block_rq_with_error,
175
176 TP_PROTO(struct request_queue *q, struct request *rq),
177
178 TP_ARGS(q, rq),
179
180 TP_locvar(
181 sector_t sector;
182 unsigned int nr_sector;
183 unsigned char *cmd;
184 size_t cmd_len;
185 ),
186
187 TP_code_pre(
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)) */
217 LTTNG_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
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 }
243 ),
244
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,
252 lttng_req_op(rq), lttng_req_rw(rq), blk_rq_bytes(rq))
253 ctf_sequence_hex(unsigned char, cmd,
254 tp_locvar->cmd, size_t, tp_locvar->cmd_len)
255 ),
256
257 TP_code_post()
258 )
259 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
260
261 #if (LINUX_VERSION_CODE < KERNEL_VERSION(4,12,0))
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 */
272 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_rq_with_error, block_rq_abort,
273
274 TP_PROTO(struct request_queue *q, struct request *rq),
275
276 TP_ARGS(q, rq)
277 )
278 #endif
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 */
289 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0))
290 LTTNG_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
306 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_rq_with_error, block_rq_requeue,
307
308 TP_PROTO(struct request_queue *q, struct request *rq),
309
310 TP_ARGS(q, rq)
311 )
312 #endif
313
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 */
326 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0))
327 LTTNG_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))
344 LTTNG_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
389 LTTNG_TRACEPOINT_EVENT_CODE(block_rq_complete,
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
396 TP_locvar(
397 unsigned char *cmd;
398 size_t cmd_len;
399 ),
400
401 TP_code_pre(
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 }
409 ),
410
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,
418 lttng_req_op(rq), lttng_req_rw(rq), nr_bytes)
419 ctf_sequence_hex(unsigned char, cmd,
420 tp_locvar->cmd, size_t, tp_locvar->cmd_len)
421 ),
422
423 TP_code_post()
424 )
425
426 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) */
427
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 */
439 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_rq_with_error, block_rq_complete,
440
441 TP_PROTO(struct request_queue *q, struct request *rq),
442
443 TP_ARGS(q, rq)
444 )
445
446 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0)) */
447
448 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0))
449 LTTNG_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))
468 LTTNG_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)) */
516 LTTNG_TRACEPOINT_EVENT_CLASS_CODE(block_rq,
517
518 TP_PROTO(struct request_queue *q, struct request *rq),
519
520 TP_ARGS(q, rq),
521
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;
528 ),
529
530 TP_code_pre(
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 }
544 ),
545
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,
554 lttng_req_op(rq), lttng_req_rw(rq), blk_rq_bytes(rq))
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)
558 ),
559
560 TP_code_post()
561 )
562 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) */
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 */
574 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_rq, block_rq_insert,
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 */
589 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_rq, block_rq_issue,
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 */
607 LTTNG_TRACEPOINT_EVENT(block_bio_bounce,
608
609 TP_PROTO(struct request_queue *q, struct bio *bio),
610
611 TP_ARGS(q, bio),
612
613 TP_FIELDS(
614 ctf_integer(dev_t, dev, bio->bi_bdev ? bio->bi_bdev->bd_dev : 0)
615 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
616 ctf_integer(sector_t, sector, bio->bi_iter.bi_sector)
617 ctf_integer(unsigned int, nr_sector, bio_sectors(bio))
618 blk_rwbs_ctf_integer(unsigned int, rwbs,
619 lttng_bio_op(bio), lttng_bio_rw(bio),
620 bio->bi_iter.bi_size)
621 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
622 ctf_integer(sector_t, sector, bio->bi_sector)
623 ctf_integer(unsigned int, nr_sector, bio->bi_size >> 9)
624 blk_rwbs_ctf_integer(unsigned int, rwbs,
625 lttng_bio_op(bio), lttng_bio_rw(bio),
626 bio->bi_size)
627 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
628 ctf_integer(pid_t, tid, current->pid)
629 ctf_array_text(char, comm, current->comm, TASK_COMM_LEN)
630 )
631 )
632
633 /**
634 * block_bio_complete - completed all work on the block operation
635 * @q: queue holding the block operation
636 * @bio: block operation completed
637 * @error: io error value
638 *
639 * This tracepoint indicates there is no further work to do on this
640 * block IO operation @bio.
641 */
642 LTTNG_TRACEPOINT_EVENT(block_bio_complete,
643
644 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
645 TP_PROTO(struct request_queue *q, struct bio *bio, int error),
646
647 TP_ARGS(q, bio, error),
648 #else
649 TP_PROTO(struct request_queue *q, struct bio *bio),
650
651 TP_ARGS(q, bio),
652 #endif
653
654 TP_FIELDS(
655 ctf_integer(dev_t, dev, bio->bi_bdev->bd_dev)
656 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
657 ctf_integer(sector_t, sector, bio->bi_iter.bi_sector)
658 ctf_integer(unsigned int, nr_sector, bio_sectors(bio))
659 ctf_integer(int, error, error)
660 blk_rwbs_ctf_integer(unsigned int, rwbs,
661 lttng_bio_op(bio), lttng_bio_rw(bio),
662 bio->bi_iter.bi_size)
663 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
664 ctf_integer(sector_t, sector, bio->bi_sector)
665 ctf_integer(unsigned int, nr_sector, bio->bi_size >> 9)
666 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
667 ctf_integer(int, error, error)
668 #else
669 ctf_integer(int, error, 0)
670 #endif
671 blk_rwbs_ctf_integer(unsigned int, rwbs,
672 lttng_bio_op(bio), lttng_bio_rw(bio), bio->bi_size)
673 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
674 )
675 )
676
677 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
678 LTTNG_TRACEPOINT_EVENT_CLASS(block_bio_merge,
679
680 TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio),
681
682 TP_ARGS(q, rq, bio),
683
684 TP_FIELDS(
685 ctf_integer(dev_t, dev, bio->bi_bdev->bd_dev)
686 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
687 ctf_integer(sector_t, sector, bio->bi_iter.bi_sector)
688 ctf_integer(unsigned int, nr_sector, bio_sectors(bio))
689 blk_rwbs_ctf_integer(unsigned int, rwbs,
690 lttng_bio_op(bio), lttng_bio_rw(bio),
691 bio->bi_iter.bi_size)
692 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
693 ctf_integer(sector_t, sector, bio->bi_sector)
694 ctf_integer(unsigned int, nr_sector, bio->bi_size >> 9)
695 blk_rwbs_ctf_integer(unsigned int, rwbs,
696 lttng_bio_op(bio), lttng_bio_rw(bio), bio->bi_size)
697 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
698 ctf_integer(pid_t, tid, current->pid)
699 ctf_array_text(char, comm, current->comm, TASK_COMM_LEN)
700 )
701 )
702
703 /**
704 * block_bio_backmerge - merging block operation to the end of an existing operation
705 * @q: queue holding operation
706 * @bio: new block operation to merge
707 *
708 * Merging block request @bio to the end of an existing block request
709 * in queue @q.
710 */
711 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_bio_merge, block_bio_backmerge,
712
713 TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio),
714
715 TP_ARGS(q, rq, bio)
716 )
717
718 /**
719 * block_bio_frontmerge - merging block operation to the beginning of an existing operation
720 * @q: queue holding operation
721 * @bio: new block operation to merge
722 *
723 * Merging block IO operation @bio to the beginning of an existing block
724 * operation in queue @q.
725 */
726 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_bio_merge, block_bio_frontmerge,
727
728 TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio),
729
730 TP_ARGS(q, rq, bio)
731 )
732
733 /**
734 * block_bio_queue - putting new block IO operation in queue
735 * @q: queue holding operation
736 * @bio: new block operation
737 *
738 * About to place the block IO operation @bio into queue @q.
739 */
740 LTTNG_TRACEPOINT_EVENT(block_bio_queue,
741
742 TP_PROTO(struct request_queue *q, struct bio *bio),
743
744 TP_ARGS(q, bio),
745
746 TP_FIELDS(
747 ctf_integer(dev_t, dev, bio->bi_bdev->bd_dev)
748 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
749 ctf_integer(sector_t, sector, bio->bi_iter.bi_sector)
750 ctf_integer(unsigned int, nr_sector, bio_sectors(bio))
751 blk_rwbs_ctf_integer(unsigned int, rwbs,
752 lttng_bio_op(bio), lttng_bio_rw(bio),
753 bio->bi_iter.bi_size)
754 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
755 ctf_integer(sector_t, sector, bio->bi_sector)
756 ctf_integer(unsigned int, nr_sector, bio->bi_size >> 9)
757 blk_rwbs_ctf_integer(unsigned int, rwbs,
758 lttng_bio_op(bio), lttng_bio_rw(bio), bio->bi_size)
759 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
760 ctf_integer(pid_t, tid, current->pid)
761 ctf_array_text(char, comm, current->comm, TASK_COMM_LEN)
762 )
763 )
764 #else /* if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) */
765 LTTNG_TRACEPOINT_EVENT_CLASS(block_bio,
766
767 TP_PROTO(struct request_queue *q, struct bio *bio),
768
769 TP_ARGS(q, bio),
770
771 TP_FIELDS(
772 ctf_integer(dev_t, dev, bio->bi_bdev ? bio->bi_bdev->bd_dev : 0)
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,
776 lttng_bio_op(bio), lttng_bio_rw(bio), bio->bi_size)
777 ctf_integer(pid_t, tid, current->pid)
778 ctf_array_text(char, comm, current->comm, TASK_COMM_LEN)
779 )
780 )
781
782 /**
783 * block_bio_backmerge - merging block operation to the end of an existing operation
784 * @q: queue holding operation
785 * @bio: new block operation to merge
786 *
787 * Merging block request @bio to the end of an existing block request
788 * in queue @q.
789 */
790 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_bio, block_bio_backmerge,
791
792 TP_PROTO(struct request_queue *q, struct bio *bio),
793
794 TP_ARGS(q, bio)
795 )
796
797 /**
798 * block_bio_frontmerge - merging block operation to the beginning of an existing operation
799 * @q: queue holding operation
800 * @bio: new block operation to merge
801 *
802 * Merging block IO operation @bio to the beginning of an existing block
803 * operation in queue @q.
804 */
805 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_bio, block_bio_frontmerge,
806
807 TP_PROTO(struct request_queue *q, struct bio *bio),
808
809 TP_ARGS(q, bio)
810 )
811
812 /**
813 * block_bio_queue - putting new block IO operation in queue
814 * @q: queue holding operation
815 * @bio: new block operation
816 *
817 * About to place the block IO operation @bio into queue @q.
818 */
819 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_bio, block_bio_queue,
820
821 TP_PROTO(struct request_queue *q, struct bio *bio),
822
823 TP_ARGS(q, bio)
824 )
825 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)) */
826
827 LTTNG_TRACEPOINT_EVENT_CLASS(block_get_rq,
828
829 TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
830
831 TP_ARGS(q, bio, rw),
832
833 TP_FIELDS(
834 ctf_integer(dev_t, dev, bio ? bio->bi_bdev->bd_dev : 0)
835 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
836 ctf_integer(sector_t, sector, bio ? bio->bi_iter.bi_sector : 0)
837 ctf_integer(unsigned int, nr_sector,
838 bio ? bio_sectors(bio) : 0)
839 blk_rwbs_ctf_integer(unsigned int, rwbs,
840 bio ? lttng_bio_op(bio) : 0,
841 bio ? lttng_bio_rw(bio) : 0,
842 bio ? bio->bi_iter.bi_size : 0)
843 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
844 ctf_integer(sector_t, sector, bio ? bio->bi_sector : 0)
845 ctf_integer(unsigned int, nr_sector,
846 bio ? bio->bi_size >> 9 : 0)
847 blk_rwbs_ctf_integer(unsigned int, rwbs,
848 bio ? lttng_bio_op(bio) : 0,
849 bio ? lttng_bio_rw(bio) : 0,
850 bio ? bio->bi_size : 0)
851 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
852 ctf_integer(pid_t, tid, current->pid)
853 ctf_array_text(char, comm, current->comm, TASK_COMM_LEN)
854 )
855 )
856
857 /**
858 * block_getrq - get a free request entry in queue for block IO operations
859 * @q: queue for operations
860 * @bio: pending block IO operation
861 * @rw: low bit indicates a read (%0) or a write (%1)
862 *
863 * A request struct for queue @q has been allocated to handle the
864 * block IO operation @bio.
865 */
866 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_get_rq, block_getrq,
867
868 TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
869
870 TP_ARGS(q, bio, rw)
871 )
872
873 /**
874 * block_sleeprq - waiting to get a free request entry in queue for block IO operation
875 * @q: queue for operation
876 * @bio: pending block IO operation
877 * @rw: low bit indicates a read (%0) or a write (%1)
878 *
879 * In the case where a request struct cannot be provided for queue @q
880 * the process needs to wait for an request struct to become
881 * available. This tracepoint event is generated each time the
882 * process goes to sleep waiting for request struct become available.
883 */
884 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_get_rq, block_sleeprq,
885
886 TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
887
888 TP_ARGS(q, bio, rw)
889 )
890
891 /**
892 * block_plug - keep operations requests in request queue
893 * @q: request queue to plug
894 *
895 * Plug the request queue @q. Do not allow block operation requests
896 * to be sent to the device driver. Instead, accumulate requests in
897 * the queue to improve throughput performance of the block device.
898 */
899 LTTNG_TRACEPOINT_EVENT(block_plug,
900
901 TP_PROTO(struct request_queue *q),
902
903 TP_ARGS(q),
904
905 TP_FIELDS(
906 ctf_integer(pid_t, tid, current->pid)
907 ctf_array_text(char, comm, current->comm, TASK_COMM_LEN)
908 )
909 )
910
911 LTTNG_TRACEPOINT_EVENT_CLASS(block_unplug,
912
913 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
914 TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit),
915
916 TP_ARGS(q, depth, explicit),
917 #else
918 TP_PROTO(struct request_queue *q),
919
920 TP_ARGS(q),
921 #endif
922
923 TP_FIELDS(
924 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
925 ctf_integer(int, nr_rq, depth)
926 #else
927 ctf_integer(int, nr_rq, q->rq.count[READ] + q->rq.count[WRITE])
928 #endif
929 ctf_integer(pid_t, tid, current->pid)
930 ctf_array_text(char, comm, current->comm, TASK_COMM_LEN)
931 )
932 )
933
934 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39))
935 /**
936 * block_unplug_timer - timed release of operations requests in queue to device driver
937 * @q: request queue to unplug
938 *
939 * Unplug the request queue @q because a timer expired and allow block
940 * operation requests to be sent to the device driver.
941 */
942 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_unplug, block_unplug_timer,
943
944 TP_PROTO(struct request_queue *q),
945
946 TP_ARGS(q)
947 )
948 #endif
949
950 /**
951 * block_unplug - release of operations requests in request queue
952 * @q: request queue to unplug
953 * @depth: number of requests just added to the queue
954 * @explicit: whether this was an explicit unplug, or one from schedule()
955 *
956 * Unplug request queue @q because device driver is scheduled to work
957 * on elements in the request queue.
958 */
959 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
960 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_unplug, block_unplug,
961 #else
962 LTTNG_TRACEPOINT_EVENT_INSTANCE(block_unplug, block_unplug_io,
963 #endif
964
965 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
966 TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit),
967
968 TP_ARGS(q, depth, explicit)
969 #else
970 TP_PROTO(struct request_queue *q),
971
972 TP_ARGS(q)
973 #endif
974 )
975
976 /**
977 * block_split - split a single bio struct into two bio structs
978 * @q: queue containing the bio
979 * @bio: block operation being split
980 * @new_sector: The starting sector for the new bio
981 *
982 * The bio request @bio in request queue @q needs to be split into two
983 * bio requests. The newly created @bio request starts at
984 * @new_sector. This split may be required due to hardware limitation
985 * such as operation crossing device boundaries in a RAID system.
986 */
987 LTTNG_TRACEPOINT_EVENT(block_split,
988
989 TP_PROTO(struct request_queue *q, struct bio *bio,
990 unsigned int new_sector),
991
992 TP_ARGS(q, bio, new_sector),
993
994 TP_FIELDS(
995 ctf_integer(dev_t, dev, bio->bi_bdev->bd_dev)
996 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
997 ctf_integer(sector_t, sector, bio->bi_iter.bi_sector)
998 blk_rwbs_ctf_integer(unsigned int, rwbs,
999 lttng_bio_op(bio), lttng_bio_rw(bio),
1000 bio->bi_iter.bi_size)
1001 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
1002 ctf_integer(sector_t, sector, bio->bi_sector)
1003 blk_rwbs_ctf_integer(unsigned int, rwbs,
1004 lttng_bio_op(bio), lttng_bio_rw(bio), bio->bi_size)
1005 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
1006 ctf_integer(sector_t, new_sector, new_sector)
1007 ctf_integer(pid_t, tid, current->pid)
1008 ctf_array_text(char, comm, current->comm, TASK_COMM_LEN)
1009 )
1010 )
1011
1012 /**
1013 * block_bio_remap - map request for a logical device to the raw device
1014 * @q: queue holding the operation
1015 * @bio: revised operation
1016 * @dev: device for the operation
1017 * @from: original sector for the operation
1018 *
1019 * An operation for a logical device has been mapped to the
1020 * raw block device.
1021 */
1022 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
1023 LTTNG_TRACEPOINT_EVENT(block_bio_remap,
1024 #else
1025 LTTNG_TRACEPOINT_EVENT(block_remap,
1026 #endif
1027
1028 TP_PROTO(struct request_queue *q, struct bio *bio, dev_t dev,
1029 sector_t from),
1030
1031 TP_ARGS(q, bio, dev, from),
1032
1033 TP_FIELDS(
1034 ctf_integer(dev_t, dev, bio->bi_bdev->bd_dev)
1035 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0))
1036 ctf_integer(sector_t, sector, bio->bi_iter.bi_sector)
1037 ctf_integer(unsigned int, nr_sector, bio_sectors(bio))
1038 blk_rwbs_ctf_integer(unsigned int, rwbs,
1039 lttng_bio_op(bio), lttng_bio_rw(bio),
1040 bio->bi_iter.bi_size)
1041 #else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
1042 ctf_integer(sector_t, sector, bio->bi_sector)
1043 ctf_integer(unsigned int, nr_sector, bio->bi_size >> 9)
1044 blk_rwbs_ctf_integer(unsigned int, rwbs,
1045 lttng_bio_op(bio), lttng_bio_rw(bio), bio->bi_size)
1046 #endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) */
1047 ctf_integer(dev_t, old_dev, dev)
1048 ctf_integer(sector_t, old_sector, from)
1049 )
1050 )
1051
1052 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32))
1053 /**
1054 * block_rq_remap - map request for a block operation request
1055 * @q: queue holding the operation
1056 * @rq: block IO operation request
1057 * @dev: device for the operation
1058 * @from: original sector for the operation
1059 *
1060 * The block operation request @rq in @q has been remapped. The block
1061 * operation request @rq holds the current information and @from hold
1062 * the original sector.
1063 */
1064 LTTNG_TRACEPOINT_EVENT(block_rq_remap,
1065
1066 TP_PROTO(struct request_queue *q, struct request *rq, dev_t dev,
1067 sector_t from),
1068
1069 TP_ARGS(q, rq, dev, from),
1070
1071 TP_FIELDS(
1072 ctf_integer(dev_t, dev, disk_devt(rq->rq_disk))
1073 ctf_integer(sector_t, sector, blk_rq_pos(rq))
1074 ctf_integer(unsigned int, nr_sector, blk_rq_sectors(rq))
1075 ctf_integer(dev_t, old_dev, dev)
1076 ctf_integer(sector_t, old_sector, from)
1077 blk_rwbs_ctf_integer(unsigned int, rwbs,
1078 lttng_req_op(rq), lttng_req_rw(rq), blk_rq_bytes(rq))
1079 )
1080 )
1081 #endif
1082
1083 #undef __print_rwbs_flags
1084 #undef blk_fill_rwbs
1085
1086 #endif /* LTTNG_TRACE_BLOCK_H */
1087
1088 /* This part must be outside protection */
1089 #include <probes/define_trace.h>
This page took 0.079363 seconds and 3 git commands to generate.