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