blob: 8f3a163b8166dadb0f7e1c5f7080acd757013a3f [file] [log] [blame]
Li Zefand0b6e042009-07-13 10:33:21 +08001#undef TRACE_SYSTEM
2#define TRACE_SYSTEM block
3
Li Zefan55782132009-06-09 13:43:05 +08004#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>
Tejun Heo5305cb82013-01-11 13:06:36 -08009#include <linux/buffer_head.h>
Li Zefan55782132009-06-09 13:43:05 +080010#include <linux/tracepoint.h>
11
Namhyung Kimc09c47c2011-08-11 10:36:05 +020012#define RWBS_LEN 8
13
Tejun Heo5305cb82013-01-11 13:06:36 -080014DECLARE_EVENT_CLASS(block_buffer,
15
16 TP_PROTO(struct buffer_head *bh),
17
18 TP_ARGS(bh),
19
20 TP_STRUCT__entry (
21 __field( dev_t, dev )
22 __field( sector_t, sector )
23 __field( size_t, size )
24 ),
25
26 TP_fast_assign(
27 __entry->dev = bh->b_bdev->bd_dev;
28 __entry->sector = bh->b_blocknr;
29 __entry->size = bh->b_size;
30 ),
31
32 TP_printk("%d,%d sector=%llu size=%zu",
33 MAJOR(__entry->dev), MINOR(__entry->dev),
34 (unsigned long long)__entry->sector, __entry->size
35 )
36);
37
38/**
39 * block_touch_buffer - mark a buffer accessed
40 * @bh: buffer_head being touched
41 *
42 * Called from touch_buffer().
43 */
44DEFINE_EVENT(block_buffer, block_touch_buffer,
45
46 TP_PROTO(struct buffer_head *bh),
47
48 TP_ARGS(bh)
49);
50
51/**
52 * block_dirty_buffer - mark a buffer dirty
53 * @bh: buffer_head being dirtied
54 *
55 * Called from mark_buffer_dirty().
56 */
57DEFINE_EVENT(block_buffer, block_dirty_buffer,
58
59 TP_PROTO(struct buffer_head *bh),
60
61 TP_ARGS(bh)
62);
63
Li Zefan77ca1e02009-11-26 15:06:14 +080064DECLARE_EVENT_CLASS(block_rq_with_error,
Li Zefan55782132009-06-09 13:43:05 +080065
66 TP_PROTO(struct request_queue *q, struct request *rq),
67
68 TP_ARGS(q, rq),
69
70 TP_STRUCT__entry(
71 __field( dev_t, dev )
72 __field( sector_t, sector )
73 __field( unsigned int, nr_sector )
74 __field( int, errors )
Namhyung Kimc09c47c2011-08-11 10:36:05 +020075 __array( char, rwbs, RWBS_LEN )
Li Zefan55782132009-06-09 13:43:05 +080076 __dynamic_array( char, cmd, blk_cmd_buf_len(rq) )
77 ),
78
79 TP_fast_assign(
80 __entry->dev = rq->rq_disk ? disk_devt(rq->rq_disk) : 0;
Christoph Hellwig33659eb2010-08-07 18:17:56 +020081 __entry->sector = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
82 0 : blk_rq_pos(rq);
83 __entry->nr_sector = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
84 0 : blk_rq_sectors(rq);
Li Zefan55782132009-06-09 13:43:05 +080085 __entry->errors = rq->errors;
86
Mike Christie1b9a9ab2016-06-05 14:32:18 -050087 blk_fill_rwbs(__entry->rwbs, req_op(rq), rq->cmd_flags,
88 blk_rq_bytes(rq));
Li Zefan55782132009-06-09 13:43:05 +080089 blk_dump_cmd(__get_str(cmd), rq);
90 ),
91
92 TP_printk("%d,%d %s (%s) %llu + %u [%d]",
93 MAJOR(__entry->dev), MINOR(__entry->dev),
94 __entry->rwbs, __get_str(cmd),
Steven Rostedt6556d1d2009-06-09 14:04:26 -040095 (unsigned long long)__entry->sector,
96 __entry->nr_sector, __entry->errors)
Li Zefan55782132009-06-09 13:43:05 +080097);
98
William Cohen881245d2010-03-09 09:26:04 +010099/**
100 * block_rq_abort - abort block operation request
101 * @q: queue containing the block operation request
102 * @rq: block IO operation request
103 *
104 * Called immediately after pending block IO operation request @rq in
105 * queue @q is aborted. The fields in the operation request @rq
106 * can be examined to determine which device and sectors the pending
107 * operation would access.
108 */
Li Zefan77ca1e02009-11-26 15:06:14 +0800109DEFINE_EVENT(block_rq_with_error, block_rq_abort,
110
111 TP_PROTO(struct request_queue *q, struct request *rq),
112
113 TP_ARGS(q, rq)
114);
115
William Cohen881245d2010-03-09 09:26:04 +0100116/**
117 * block_rq_requeue - place block IO request back on a queue
118 * @q: queue holding operation
119 * @rq: block IO operation request
120 *
121 * The block operation request @rq is being placed back into queue
122 * @q. For some reason the request was not completed and needs to be
123 * put back in the queue.
124 */
Li Zefan77ca1e02009-11-26 15:06:14 +0800125DEFINE_EVENT(block_rq_with_error, block_rq_requeue,
126
127 TP_PROTO(struct request_queue *q, struct request *rq),
128
129 TP_ARGS(q, rq)
130);
131
William Cohen881245d2010-03-09 09:26:04 +0100132/**
133 * block_rq_complete - block IO operation completed by device driver
134 * @q: queue containing the block operation request
135 * @rq: block operations request
Roman Penaf5040d2014-03-04 23:13:10 +0900136 * @nr_bytes: number of completed bytes
William Cohen881245d2010-03-09 09:26:04 +0100137 *
138 * The block_rq_complete tracepoint event indicates that some portion
139 * of operation request has been completed by the device driver. If
140 * the @rq->bio is %NULL, then there is absolutely no additional work to
141 * do for the request. If @rq->bio is non-NULL then there is
142 * additional work required to complete the request.
143 */
Roman Penaf5040d2014-03-04 23:13:10 +0900144TRACE_EVENT(block_rq_complete,
Li Zefan77ca1e02009-11-26 15:06:14 +0800145
Roman Penaf5040d2014-03-04 23:13:10 +0900146 TP_PROTO(struct request_queue *q, struct request *rq,
147 unsigned int nr_bytes),
Li Zefan77ca1e02009-11-26 15:06:14 +0800148
Roman Penaf5040d2014-03-04 23:13:10 +0900149 TP_ARGS(q, rq, nr_bytes),
150
151 TP_STRUCT__entry(
152 __field( dev_t, dev )
153 __field( sector_t, sector )
154 __field( unsigned int, nr_sector )
155 __field( int, errors )
156 __array( char, rwbs, RWBS_LEN )
157 __dynamic_array( char, cmd, blk_cmd_buf_len(rq) )
158 ),
159
160 TP_fast_assign(
161 __entry->dev = rq->rq_disk ? disk_devt(rq->rq_disk) : 0;
162 __entry->sector = blk_rq_pos(rq);
163 __entry->nr_sector = nr_bytes >> 9;
164 __entry->errors = rq->errors;
165
Mike Christie1b9a9ab2016-06-05 14:32:18 -0500166 blk_fill_rwbs(__entry->rwbs, req_op(rq), rq->cmd_flags, nr_bytes);
Roman Penaf5040d2014-03-04 23:13:10 +0900167 blk_dump_cmd(__get_str(cmd), rq);
168 ),
169
170 TP_printk("%d,%d %s (%s) %llu + %u [%d]",
171 MAJOR(__entry->dev), MINOR(__entry->dev),
172 __entry->rwbs, __get_str(cmd),
173 (unsigned long long)__entry->sector,
174 __entry->nr_sector, __entry->errors)
Li Zefan77ca1e02009-11-26 15:06:14 +0800175);
176
177DECLARE_EVENT_CLASS(block_rq,
Li Zefan55782132009-06-09 13:43:05 +0800178
179 TP_PROTO(struct request_queue *q, struct request *rq),
180
181 TP_ARGS(q, rq),
182
183 TP_STRUCT__entry(
184 __field( dev_t, dev )
185 __field( sector_t, sector )
186 __field( unsigned int, nr_sector )
187 __field( unsigned int, bytes )
Namhyung Kimc09c47c2011-08-11 10:36:05 +0200188 __array( char, rwbs, RWBS_LEN )
Li Zefan55782132009-06-09 13:43:05 +0800189 __array( char, comm, TASK_COMM_LEN )
190 __dynamic_array( char, cmd, blk_cmd_buf_len(rq) )
191 ),
192
193 TP_fast_assign(
194 __entry->dev = rq->rq_disk ? disk_devt(rq->rq_disk) : 0;
Christoph Hellwig33659eb2010-08-07 18:17:56 +0200195 __entry->sector = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
196 0 : blk_rq_pos(rq);
197 __entry->nr_sector = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
198 0 : blk_rq_sectors(rq);
199 __entry->bytes = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
200 blk_rq_bytes(rq) : 0;
Li Zefan55782132009-06-09 13:43:05 +0800201
Mike Christie1b9a9ab2016-06-05 14:32:18 -0500202 blk_fill_rwbs(__entry->rwbs, req_op(rq), rq->cmd_flags,
203 blk_rq_bytes(rq));
Li Zefan55782132009-06-09 13:43:05 +0800204 blk_dump_cmd(__get_str(cmd), rq);
205 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
206 ),
207
208 TP_printk("%d,%d %s %u (%s) %llu + %u [%s]",
209 MAJOR(__entry->dev), MINOR(__entry->dev),
210 __entry->rwbs, __entry->bytes, __get_str(cmd),
Steven Rostedt6556d1d2009-06-09 14:04:26 -0400211 (unsigned long long)__entry->sector,
212 __entry->nr_sector, __entry->comm)
Li Zefan55782132009-06-09 13:43:05 +0800213);
214
William Cohen881245d2010-03-09 09:26:04 +0100215/**
216 * block_rq_insert - insert block operation request into queue
217 * @q: target queue
218 * @rq: block IO operation request
219 *
220 * Called immediately before block operation request @rq is inserted
221 * into queue @q. The fields in the operation request @rq struct can
222 * be examined to determine which device and sectors the pending
223 * operation would access.
224 */
Li Zefan77ca1e02009-11-26 15:06:14 +0800225DEFINE_EVENT(block_rq, block_rq_insert,
Li Zefan55782132009-06-09 13:43:05 +0800226
227 TP_PROTO(struct request_queue *q, struct request *rq),
228
Li Zefan77ca1e02009-11-26 15:06:14 +0800229 TP_ARGS(q, rq)
Li Zefan55782132009-06-09 13:43:05 +0800230);
231
William Cohen881245d2010-03-09 09:26:04 +0100232/**
233 * block_rq_issue - issue pending block IO request operation to device driver
234 * @q: queue holding operation
235 * @rq: block IO operation operation request
236 *
237 * Called when block operation request @rq from queue @q is sent to a
238 * device driver for processing.
239 */
Li Zefan77ca1e02009-11-26 15:06:14 +0800240DEFINE_EVENT(block_rq, block_rq_issue,
Li Zefan55782132009-06-09 13:43:05 +0800241
242 TP_PROTO(struct request_queue *q, struct request *rq),
243
Li Zefan77ca1e02009-11-26 15:06:14 +0800244 TP_ARGS(q, rq)
Li Zefan55782132009-06-09 13:43:05 +0800245);
Carsten Emdefe63b942009-09-12 00:05:37 +0200246
William Cohen881245d2010-03-09 09:26:04 +0100247/**
248 * block_bio_bounce - used bounce buffer when processing block operation
249 * @q: queue holding the block operation
250 * @bio: block operation
251 *
252 * A bounce buffer was used to handle the block operation @bio in @q.
253 * This occurs when hardware limitations prevent a direct transfer of
254 * data between the @bio data memory area and the IO device. Use of a
255 * bounce buffer requires extra copying of data and decreases
256 * performance.
257 */
Li Zefan55782132009-06-09 13:43:05 +0800258TRACE_EVENT(block_bio_bounce,
259
260 TP_PROTO(struct request_queue *q, struct bio *bio),
261
262 TP_ARGS(q, bio),
263
264 TP_STRUCT__entry(
265 __field( dev_t, dev )
266 __field( sector_t, sector )
267 __field( unsigned int, nr_sector )
Namhyung Kimc09c47c2011-08-11 10:36:05 +0200268 __array( char, rwbs, RWBS_LEN )
Li Zefan55782132009-06-09 13:43:05 +0800269 __array( char, comm, TASK_COMM_LEN )
270 ),
271
272 TP_fast_assign(
Carsten Emdefe63b942009-09-12 00:05:37 +0200273 __entry->dev = bio->bi_bdev ?
274 bio->bi_bdev->bd_dev : 0;
Kent Overstreet4f024f32013-10-11 15:44:27 -0700275 __entry->sector = bio->bi_iter.bi_sector;
Kent Overstreetaa8b57a2013-02-05 15:19:29 -0800276 __entry->nr_sector = bio_sectors(bio);
Jens Axboe1eff9d32016-08-05 15:35:16 -0600277 blk_fill_rwbs(__entry->rwbs, bio_op(bio), bio->bi_opf,
Mike Christie1b9a9ab2016-06-05 14:32:18 -0500278 bio->bi_iter.bi_size);
Li Zefan55782132009-06-09 13:43:05 +0800279 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
280 ),
281
282 TP_printk("%d,%d %s %llu + %u [%s]",
283 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
Steven Rostedt6556d1d2009-06-09 14:04:26 -0400284 (unsigned long long)__entry->sector,
285 __entry->nr_sector, __entry->comm)
Li Zefan55782132009-06-09 13:43:05 +0800286);
287
William Cohen881245d2010-03-09 09:26:04 +0100288/**
289 * block_bio_complete - completed all work on the block operation
Linus Torvalds0a82a8d2013-04-18 09:00:26 -0700290 * @q: queue holding the block operation
William Cohen881245d2010-03-09 09:26:04 +0100291 * @bio: block operation completed
Jeff Moyerb7908c12011-01-06 20:41:42 +0100292 * @error: io error value
William Cohen881245d2010-03-09 09:26:04 +0100293 *
294 * This tracepoint indicates there is no further work to do on this
295 * block IO operation @bio.
296 */
Li Zefan55782132009-06-09 13:43:05 +0800297TRACE_EVENT(block_bio_complete,
298
Linus Torvalds0a82a8d2013-04-18 09:00:26 -0700299 TP_PROTO(struct request_queue *q, struct bio *bio, int error),
Li Zefan55782132009-06-09 13:43:05 +0800300
Linus Torvalds0a82a8d2013-04-18 09:00:26 -0700301 TP_ARGS(q, bio, error),
Li Zefan55782132009-06-09 13:43:05 +0800302
303 TP_STRUCT__entry(
304 __field( dev_t, dev )
305 __field( sector_t, sector )
306 __field( unsigned, nr_sector )
307 __field( int, error )
Namhyung Kimc09c47c2011-08-11 10:36:05 +0200308 __array( char, rwbs, RWBS_LEN)
Li Zefan55782132009-06-09 13:43:05 +0800309 ),
310
311 TP_fast_assign(
Linus Torvalds0a82a8d2013-04-18 09:00:26 -0700312 __entry->dev = bio->bi_bdev->bd_dev;
Kent Overstreet4f024f32013-10-11 15:44:27 -0700313 __entry->sector = bio->bi_iter.bi_sector;
Kent Overstreetaa8b57a2013-02-05 15:19:29 -0800314 __entry->nr_sector = bio_sectors(bio);
Jeff Moyerb7908c12011-01-06 20:41:42 +0100315 __entry->error = error;
Jens Axboe1eff9d32016-08-05 15:35:16 -0600316 blk_fill_rwbs(__entry->rwbs, bio_op(bio), bio->bi_opf,
Mike Christie1b9a9ab2016-06-05 14:32:18 -0500317 bio->bi_iter.bi_size);
Li Zefan55782132009-06-09 13:43:05 +0800318 ),
319
320 TP_printk("%d,%d %s %llu + %u [%d]",
321 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
Steven Rostedt6556d1d2009-06-09 14:04:26 -0400322 (unsigned long long)__entry->sector,
323 __entry->nr_sector, __entry->error)
Li Zefan55782132009-06-09 13:43:05 +0800324);
325
Tejun Heo8c1cf6b2013-01-11 13:06:34 -0800326DECLARE_EVENT_CLASS(block_bio_merge,
Li Zefan55782132009-06-09 13:43:05 +0800327
Tejun Heo8c1cf6b2013-01-11 13:06:34 -0800328 TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio),
Li Zefan55782132009-06-09 13:43:05 +0800329
Tejun Heo8c1cf6b2013-01-11 13:06:34 -0800330 TP_ARGS(q, rq, bio),
Li Zefan55782132009-06-09 13:43:05 +0800331
332 TP_STRUCT__entry(
333 __field( dev_t, dev )
334 __field( sector_t, sector )
335 __field( unsigned int, nr_sector )
Namhyung Kimc09c47c2011-08-11 10:36:05 +0200336 __array( char, rwbs, RWBS_LEN )
Li Zefan55782132009-06-09 13:43:05 +0800337 __array( char, comm, TASK_COMM_LEN )
338 ),
339
340 TP_fast_assign(
341 __entry->dev = bio->bi_bdev->bd_dev;
Kent Overstreet4f024f32013-10-11 15:44:27 -0700342 __entry->sector = bio->bi_iter.bi_sector;
Kent Overstreetaa8b57a2013-02-05 15:19:29 -0800343 __entry->nr_sector = bio_sectors(bio);
Jens Axboe1eff9d32016-08-05 15:35:16 -0600344 blk_fill_rwbs(__entry->rwbs, bio_op(bio), bio->bi_opf,
Mike Christie1b9a9ab2016-06-05 14:32:18 -0500345 bio->bi_iter.bi_size);
Li Zefan55782132009-06-09 13:43:05 +0800346 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
347 ),
348
349 TP_printk("%d,%d %s %llu + %u [%s]",
350 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
Steven Rostedt6556d1d2009-06-09 14:04:26 -0400351 (unsigned long long)__entry->sector,
352 __entry->nr_sector, __entry->comm)
Li Zefan55782132009-06-09 13:43:05 +0800353);
354
William Cohen881245d2010-03-09 09:26:04 +0100355/**
356 * block_bio_backmerge - merging block operation to the end of an existing operation
357 * @q: queue holding operation
Tejun Heo8c1cf6b2013-01-11 13:06:34 -0800358 * @rq: request bio is being merged into
William Cohen881245d2010-03-09 09:26:04 +0100359 * @bio: new block operation to merge
360 *
361 * Merging block request @bio to the end of an existing block request
362 * in queue @q.
363 */
Tejun Heo8c1cf6b2013-01-11 13:06:34 -0800364DEFINE_EVENT(block_bio_merge, block_bio_backmerge,
Li Zefan55782132009-06-09 13:43:05 +0800365
Tejun Heo8c1cf6b2013-01-11 13:06:34 -0800366 TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio),
Li Zefan55782132009-06-09 13:43:05 +0800367
Tejun Heo8c1cf6b2013-01-11 13:06:34 -0800368 TP_ARGS(q, rq, bio)
Li Zefan55782132009-06-09 13:43:05 +0800369);
370
William Cohen881245d2010-03-09 09:26:04 +0100371/**
372 * block_bio_frontmerge - merging block operation to the beginning of an existing operation
373 * @q: queue holding operation
Tejun Heo8c1cf6b2013-01-11 13:06:34 -0800374 * @rq: request bio is being merged into
William Cohen881245d2010-03-09 09:26:04 +0100375 * @bio: new block operation to merge
376 *
377 * Merging block IO operation @bio to the beginning of an existing block
378 * operation in queue @q.
379 */
Tejun Heo8c1cf6b2013-01-11 13:06:34 -0800380DEFINE_EVENT(block_bio_merge, block_bio_frontmerge,
Li Zefan55782132009-06-09 13:43:05 +0800381
Tejun Heo8c1cf6b2013-01-11 13:06:34 -0800382 TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio),
Li Zefan55782132009-06-09 13:43:05 +0800383
Tejun Heo8c1cf6b2013-01-11 13:06:34 -0800384 TP_ARGS(q, rq, bio)
Li Zefan55782132009-06-09 13:43:05 +0800385);
386
William Cohen881245d2010-03-09 09:26:04 +0100387/**
388 * block_bio_queue - putting new block IO operation in queue
389 * @q: queue holding operation
390 * @bio: new block operation
391 *
392 * About to place the block IO operation @bio into queue @q.
393 */
Tejun Heo8c1cf6b2013-01-11 13:06:34 -0800394TRACE_EVENT(block_bio_queue,
Li Zefan77ca1e02009-11-26 15:06:14 +0800395
396 TP_PROTO(struct request_queue *q, struct bio *bio),
397
Tejun Heo8c1cf6b2013-01-11 13:06:34 -0800398 TP_ARGS(q, bio),
399
400 TP_STRUCT__entry(
401 __field( dev_t, dev )
402 __field( sector_t, sector )
403 __field( unsigned int, nr_sector )
404 __array( char, rwbs, RWBS_LEN )
405 __array( char, comm, TASK_COMM_LEN )
406 ),
407
408 TP_fast_assign(
409 __entry->dev = bio->bi_bdev->bd_dev;
Kent Overstreet4f024f32013-10-11 15:44:27 -0700410 __entry->sector = bio->bi_iter.bi_sector;
Kent Overstreetaa8b57a2013-02-05 15:19:29 -0800411 __entry->nr_sector = bio_sectors(bio);
Jens Axboe1eff9d32016-08-05 15:35:16 -0600412 blk_fill_rwbs(__entry->rwbs, bio_op(bio), bio->bi_opf,
Mike Christie1b9a9ab2016-06-05 14:32:18 -0500413 bio->bi_iter.bi_size);
Tejun Heo8c1cf6b2013-01-11 13:06:34 -0800414 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
415 ),
416
417 TP_printk("%d,%d %s %llu + %u [%s]",
418 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
419 (unsigned long long)__entry->sector,
420 __entry->nr_sector, __entry->comm)
Li Zefan77ca1e02009-11-26 15:06:14 +0800421);
422
423DECLARE_EVENT_CLASS(block_get_rq,
Li Zefan55782132009-06-09 13:43:05 +0800424
425 TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
426
427 TP_ARGS(q, bio, rw),
428
429 TP_STRUCT__entry(
430 __field( dev_t, dev )
431 __field( sector_t, sector )
432 __field( unsigned int, nr_sector )
Namhyung Kimc09c47c2011-08-11 10:36:05 +0200433 __array( char, rwbs, RWBS_LEN )
Li Zefan55782132009-06-09 13:43:05 +0800434 __array( char, comm, TASK_COMM_LEN )
435 ),
436
437 TP_fast_assign(
438 __entry->dev = bio ? bio->bi_bdev->bd_dev : 0;
Kent Overstreet4f024f32013-10-11 15:44:27 -0700439 __entry->sector = bio ? bio->bi_iter.bi_sector : 0;
Kent Overstreetaa8b57a2013-02-05 15:19:29 -0800440 __entry->nr_sector = bio ? bio_sectors(bio) : 0;
Mike Christie1b9a9ab2016-06-05 14:32:18 -0500441 blk_fill_rwbs(__entry->rwbs, bio ? bio_op(bio) : 0,
Jens Axboe1eff9d32016-08-05 15:35:16 -0600442 bio ? bio->bi_opf : 0, __entry->nr_sector);
Li Zefan55782132009-06-09 13:43:05 +0800443 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
444 ),
445
446 TP_printk("%d,%d %s %llu + %u [%s]",
447 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
Steven Rostedt6556d1d2009-06-09 14:04:26 -0400448 (unsigned long long)__entry->sector,
449 __entry->nr_sector, __entry->comm)
Li Zefan55782132009-06-09 13:43:05 +0800450);
451
William Cohen881245d2010-03-09 09:26:04 +0100452/**
453 * block_getrq - get a free request entry in queue for block IO operations
454 * @q: queue for operations
455 * @bio: pending block IO operation
456 * @rw: low bit indicates a read (%0) or a write (%1)
457 *
458 * A request struct for queue @q has been allocated to handle the
459 * block IO operation @bio.
460 */
Li Zefan77ca1e02009-11-26 15:06:14 +0800461DEFINE_EVENT(block_get_rq, block_getrq,
Li Zefan55782132009-06-09 13:43:05 +0800462
463 TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
464
Li Zefan77ca1e02009-11-26 15:06:14 +0800465 TP_ARGS(q, bio, rw)
466);
Li Zefan55782132009-06-09 13:43:05 +0800467
William Cohen881245d2010-03-09 09:26:04 +0100468/**
469 * block_sleeprq - waiting to get a free request entry in queue for block IO operation
470 * @q: queue for operation
471 * @bio: pending block IO operation
472 * @rw: low bit indicates a read (%0) or a write (%1)
473 *
474 * In the case where a request struct cannot be provided for queue @q
475 * the process needs to wait for an request struct to become
476 * available. This tracepoint event is generated each time the
477 * process goes to sleep waiting for request struct become available.
478 */
Li Zefan77ca1e02009-11-26 15:06:14 +0800479DEFINE_EVENT(block_get_rq, block_sleeprq,
Li Zefan55782132009-06-09 13:43:05 +0800480
Li Zefan77ca1e02009-11-26 15:06:14 +0800481 TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
Li Zefan55782132009-06-09 13:43:05 +0800482
Li Zefan77ca1e02009-11-26 15:06:14 +0800483 TP_ARGS(q, bio, rw)
Li Zefan55782132009-06-09 13:43:05 +0800484);
485
William Cohen881245d2010-03-09 09:26:04 +0100486/**
487 * block_plug - keep operations requests in request queue
488 * @q: request queue to plug
489 *
490 * Plug the request queue @q. Do not allow block operation requests
491 * to be sent to the device driver. Instead, accumulate requests in
492 * the queue to improve throughput performance of the block device.
493 */
Li Zefan55782132009-06-09 13:43:05 +0800494TRACE_EVENT(block_plug,
495
496 TP_PROTO(struct request_queue *q),
497
498 TP_ARGS(q),
499
500 TP_STRUCT__entry(
501 __array( char, comm, TASK_COMM_LEN )
502 ),
503
504 TP_fast_assign(
505 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
506 ),
507
508 TP_printk("[%s]", __entry->comm)
509);
510
Li Zefan77ca1e02009-11-26 15:06:14 +0800511DECLARE_EVENT_CLASS(block_unplug,
Li Zefan55782132009-06-09 13:43:05 +0800512
Jens Axboe49cac012011-04-16 13:51:05 +0200513 TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit),
Li Zefan55782132009-06-09 13:43:05 +0800514
Jens Axboe49cac012011-04-16 13:51:05 +0200515 TP_ARGS(q, depth, explicit),
Li Zefan55782132009-06-09 13:43:05 +0800516
517 TP_STRUCT__entry(
518 __field( int, nr_rq )
519 __array( char, comm, TASK_COMM_LEN )
520 ),
521
522 TP_fast_assign(
Jens Axboe94b5eb22011-04-12 10:12:19 +0200523 __entry->nr_rq = depth;
Li Zefan55782132009-06-09 13:43:05 +0800524 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
525 ),
526
527 TP_printk("[%s] %d", __entry->comm, __entry->nr_rq)
528);
529
William Cohen881245d2010-03-09 09:26:04 +0100530/**
Jens Axboe49cac012011-04-16 13:51:05 +0200531 * block_unplug - release of operations requests in request queue
William Cohen881245d2010-03-09 09:26:04 +0100532 * @q: request queue to unplug
Jens Axboe94b5eb22011-04-12 10:12:19 +0200533 * @depth: number of requests just added to the queue
Jens Axboe49cac012011-04-16 13:51:05 +0200534 * @explicit: whether this was an explicit unplug, or one from schedule()
William Cohen881245d2010-03-09 09:26:04 +0100535 *
536 * Unplug request queue @q because device driver is scheduled to work
537 * on elements in the request queue.
538 */
Jens Axboe49cac012011-04-16 13:51:05 +0200539DEFINE_EVENT(block_unplug, block_unplug,
Li Zefan55782132009-06-09 13:43:05 +0800540
Jens Axboe49cac012011-04-16 13:51:05 +0200541 TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit),
Li Zefan55782132009-06-09 13:43:05 +0800542
Jens Axboe49cac012011-04-16 13:51:05 +0200543 TP_ARGS(q, depth, explicit)
Li Zefan55782132009-06-09 13:43:05 +0800544);
545
William Cohen881245d2010-03-09 09:26:04 +0100546/**
547 * block_split - split a single bio struct into two bio structs
548 * @q: queue containing the bio
549 * @bio: block operation being split
550 * @new_sector: The starting sector for the new bio
551 *
552 * The bio request @bio in request queue @q needs to be split into two
553 * bio requests. The newly created @bio request starts at
554 * @new_sector. This split may be required due to hardware limitation
555 * such as operation crossing device boundaries in a RAID system.
556 */
Li Zefan55782132009-06-09 13:43:05 +0800557TRACE_EVENT(block_split,
558
559 TP_PROTO(struct request_queue *q, struct bio *bio,
560 unsigned int new_sector),
561
562 TP_ARGS(q, bio, new_sector),
563
564 TP_STRUCT__entry(
565 __field( dev_t, dev )
566 __field( sector_t, sector )
567 __field( sector_t, new_sector )
Namhyung Kimc09c47c2011-08-11 10:36:05 +0200568 __array( char, rwbs, RWBS_LEN )
Li Zefan55782132009-06-09 13:43:05 +0800569 __array( char, comm, TASK_COMM_LEN )
570 ),
571
572 TP_fast_assign(
573 __entry->dev = bio->bi_bdev->bd_dev;
Kent Overstreet4f024f32013-10-11 15:44:27 -0700574 __entry->sector = bio->bi_iter.bi_sector;
Li Zefan55782132009-06-09 13:43:05 +0800575 __entry->new_sector = new_sector;
Jens Axboe1eff9d32016-08-05 15:35:16 -0600576 blk_fill_rwbs(__entry->rwbs, bio_op(bio), bio->bi_opf,
Mike Christie1b9a9ab2016-06-05 14:32:18 -0500577 bio->bi_iter.bi_size);
Li Zefan55782132009-06-09 13:43:05 +0800578 memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
579 ),
580
581 TP_printk("%d,%d %s %llu / %llu [%s]",
582 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
Steven Rostedt6556d1d2009-06-09 14:04:26 -0400583 (unsigned long long)__entry->sector,
584 (unsigned long long)__entry->new_sector,
585 __entry->comm)
Li Zefan55782132009-06-09 13:43:05 +0800586);
587
William Cohen881245d2010-03-09 09:26:04 +0100588/**
Mike Snitzerd07335e2010-11-16 12:52:38 +0100589 * block_bio_remap - map request for a logical device to the raw device
William Cohen881245d2010-03-09 09:26:04 +0100590 * @q: queue holding the operation
591 * @bio: revised operation
592 * @dev: device for the operation
593 * @from: original sector for the operation
594 *
Mike Snitzerd07335e2010-11-16 12:52:38 +0100595 * An operation for a logical device has been mapped to the
William Cohen881245d2010-03-09 09:26:04 +0100596 * raw block device.
597 */
Mike Snitzerd07335e2010-11-16 12:52:38 +0100598TRACE_EVENT(block_bio_remap,
Li Zefan55782132009-06-09 13:43:05 +0800599
600 TP_PROTO(struct request_queue *q, struct bio *bio, dev_t dev,
601 sector_t from),
602
603 TP_ARGS(q, bio, dev, from),
604
605 TP_STRUCT__entry(
606 __field( dev_t, dev )
607 __field( sector_t, sector )
608 __field( unsigned int, nr_sector )
609 __field( dev_t, old_dev )
610 __field( sector_t, old_sector )
Namhyung Kimc09c47c2011-08-11 10:36:05 +0200611 __array( char, rwbs, RWBS_LEN)
Li Zefan55782132009-06-09 13:43:05 +0800612 ),
613
614 TP_fast_assign(
615 __entry->dev = bio->bi_bdev->bd_dev;
Kent Overstreet4f024f32013-10-11 15:44:27 -0700616 __entry->sector = bio->bi_iter.bi_sector;
Kent Overstreetaa8b57a2013-02-05 15:19:29 -0800617 __entry->nr_sector = bio_sectors(bio);
Li Zefan55782132009-06-09 13:43:05 +0800618 __entry->old_dev = dev;
619 __entry->old_sector = from;
Jens Axboe1eff9d32016-08-05 15:35:16 -0600620 blk_fill_rwbs(__entry->rwbs, bio_op(bio), bio->bi_opf,
Mike Christie1b9a9ab2016-06-05 14:32:18 -0500621 bio->bi_iter.bi_size);
Li Zefan55782132009-06-09 13:43:05 +0800622 ),
623
624 TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
625 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
Steven Rostedt6556d1d2009-06-09 14:04:26 -0400626 (unsigned long long)__entry->sector,
627 __entry->nr_sector,
Li Zefan55782132009-06-09 13:43:05 +0800628 MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
Steven Rostedt6556d1d2009-06-09 14:04:26 -0400629 (unsigned long long)__entry->old_sector)
Li Zefan55782132009-06-09 13:43:05 +0800630);
631
William Cohen881245d2010-03-09 09:26:04 +0100632/**
633 * block_rq_remap - map request for a block operation request
634 * @q: queue holding the operation
635 * @rq: block IO operation request
636 * @dev: device for the operation
637 * @from: original sector for the operation
638 *
639 * The block operation request @rq in @q has been remapped. The block
640 * operation request @rq holds the current information and @from hold
641 * the original sector.
642 */
Jun'ichi Nomurab0da3f02009-10-01 21:16:13 +0200643TRACE_EVENT(block_rq_remap,
644
645 TP_PROTO(struct request_queue *q, struct request *rq, dev_t dev,
646 sector_t from),
647
648 TP_ARGS(q, rq, dev, from),
649
650 TP_STRUCT__entry(
651 __field( dev_t, dev )
652 __field( sector_t, sector )
653 __field( unsigned int, nr_sector )
654 __field( dev_t, old_dev )
655 __field( sector_t, old_sector )
Jun'ichi Nomura75afb352013-09-21 13:57:47 -0600656 __field( unsigned int, nr_bios )
Namhyung Kimc09c47c2011-08-11 10:36:05 +0200657 __array( char, rwbs, RWBS_LEN)
Jun'ichi Nomurab0da3f02009-10-01 21:16:13 +0200658 ),
659
660 TP_fast_assign(
661 __entry->dev = disk_devt(rq->rq_disk);
662 __entry->sector = blk_rq_pos(rq);
663 __entry->nr_sector = blk_rq_sectors(rq);
664 __entry->old_dev = dev;
665 __entry->old_sector = from;
Jun'ichi Nomura75afb352013-09-21 13:57:47 -0600666 __entry->nr_bios = blk_rq_count_bios(rq);
Mike Christie1b9a9ab2016-06-05 14:32:18 -0500667 blk_fill_rwbs(__entry->rwbs, req_op(rq), rq->cmd_flags,
668 blk_rq_bytes(rq));
Jun'ichi Nomurab0da3f02009-10-01 21:16:13 +0200669 ),
670
Jun'ichi Nomura75afb352013-09-21 13:57:47 -0600671 TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu %u",
Jun'ichi Nomurab0da3f02009-10-01 21:16:13 +0200672 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
673 (unsigned long long)__entry->sector,
674 __entry->nr_sector,
675 MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
Jun'ichi Nomura75afb352013-09-21 13:57:47 -0600676 (unsigned long long)__entry->old_sector, __entry->nr_bios)
Jun'ichi Nomurab0da3f02009-10-01 21:16:13 +0200677);
678
Li Zefan55782132009-06-09 13:43:05 +0800679#endif /* _TRACE_BLOCK_H */
680
681/* This part must be outside protection */
682#include <trace/define_trace.h>
683