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