xref: /openbmc/linux/include/trace/events/block.h (revision 74d46992e0d9dee7f1f376de0d56d31614c8a17a)
1d0b6e04aSLi Zefan #undef TRACE_SYSTEM
2d0b6e04aSLi Zefan #define TRACE_SYSTEM block
3d0b6e04aSLi Zefan 
455782138SLi Zefan #if !defined(_TRACE_BLOCK_H) || defined(TRACE_HEADER_MULTI_READ)
555782138SLi Zefan #define _TRACE_BLOCK_H
655782138SLi Zefan 
755782138SLi Zefan #include <linux/blktrace_api.h>
855782138SLi Zefan #include <linux/blkdev.h>
95305cb83STejun Heo #include <linux/buffer_head.h>
1055782138SLi Zefan #include <linux/tracepoint.h>
1155782138SLi Zefan 
12c09c47caSNamhyung Kim #define RWBS_LEN	8
13c09c47caSNamhyung Kim 
145305cb83STejun Heo DECLARE_EVENT_CLASS(block_buffer,
155305cb83STejun Heo 
165305cb83STejun Heo 	TP_PROTO(struct buffer_head *bh),
175305cb83STejun Heo 
185305cb83STejun Heo 	TP_ARGS(bh),
195305cb83STejun Heo 
205305cb83STejun Heo 	TP_STRUCT__entry (
215305cb83STejun Heo 		__field(  dev_t,	dev			)
225305cb83STejun Heo 		__field(  sector_t,	sector			)
235305cb83STejun Heo 		__field(  size_t,	size			)
245305cb83STejun Heo 	),
255305cb83STejun Heo 
265305cb83STejun Heo 	TP_fast_assign(
275305cb83STejun Heo 		__entry->dev		= bh->b_bdev->bd_dev;
285305cb83STejun Heo 		__entry->sector		= bh->b_blocknr;
295305cb83STejun Heo 		__entry->size		= bh->b_size;
305305cb83STejun Heo 	),
315305cb83STejun Heo 
325305cb83STejun Heo 	TP_printk("%d,%d sector=%llu size=%zu",
335305cb83STejun Heo 		MAJOR(__entry->dev), MINOR(__entry->dev),
345305cb83STejun Heo 		(unsigned long long)__entry->sector, __entry->size
355305cb83STejun Heo 	)
365305cb83STejun Heo );
375305cb83STejun Heo 
385305cb83STejun Heo /**
395305cb83STejun Heo  * block_touch_buffer - mark a buffer accessed
405305cb83STejun Heo  * @bh: buffer_head being touched
415305cb83STejun Heo  *
425305cb83STejun Heo  * Called from touch_buffer().
435305cb83STejun Heo  */
445305cb83STejun Heo DEFINE_EVENT(block_buffer, block_touch_buffer,
455305cb83STejun Heo 
465305cb83STejun Heo 	TP_PROTO(struct buffer_head *bh),
475305cb83STejun Heo 
485305cb83STejun Heo 	TP_ARGS(bh)
495305cb83STejun Heo );
505305cb83STejun Heo 
515305cb83STejun Heo /**
525305cb83STejun Heo  * block_dirty_buffer - mark a buffer dirty
535305cb83STejun Heo  * @bh: buffer_head being dirtied
545305cb83STejun Heo  *
555305cb83STejun Heo  * Called from mark_buffer_dirty().
565305cb83STejun Heo  */
575305cb83STejun Heo DEFINE_EVENT(block_buffer, block_dirty_buffer,
585305cb83STejun Heo 
595305cb83STejun Heo 	TP_PROTO(struct buffer_head *bh),
605305cb83STejun Heo 
615305cb83STejun Heo 	TP_ARGS(bh)
625305cb83STejun Heo );
635305cb83STejun Heo 
64cee4b7ceSChristoph Hellwig /**
65cee4b7ceSChristoph Hellwig  * block_rq_requeue - place block IO request back on a queue
66cee4b7ceSChristoph Hellwig  * @q: queue holding operation
67cee4b7ceSChristoph Hellwig  * @rq: block IO operation request
68cee4b7ceSChristoph Hellwig  *
69cee4b7ceSChristoph Hellwig  * The block operation request @rq is being placed back into queue
70cee4b7ceSChristoph Hellwig  * @q.  For some reason the request was not completed and needs to be
71cee4b7ceSChristoph Hellwig  * put back in the queue.
72cee4b7ceSChristoph Hellwig  */
73cee4b7ceSChristoph Hellwig TRACE_EVENT(block_rq_requeue,
7455782138SLi Zefan 
7555782138SLi Zefan 	TP_PROTO(struct request_queue *q, struct request *rq),
7655782138SLi Zefan 
7755782138SLi Zefan 	TP_ARGS(q, rq),
7855782138SLi Zefan 
7955782138SLi Zefan 	TP_STRUCT__entry(
8055782138SLi Zefan 		__field(  dev_t,	dev			)
8155782138SLi Zefan 		__field(  sector_t,	sector			)
8255782138SLi Zefan 		__field(  unsigned int,	nr_sector		)
83c09c47caSNamhyung Kim 		__array(  char,		rwbs,	RWBS_LEN	)
8448b77ad6SChristoph Hellwig 		__dynamic_array( char,	cmd,	1		)
8555782138SLi Zefan 	),
8655782138SLi Zefan 
8755782138SLi Zefan 	TP_fast_assign(
8855782138SLi Zefan 		__entry->dev	   = rq->rq_disk ? disk_devt(rq->rq_disk) : 0;
8948b77ad6SChristoph Hellwig 		__entry->sector    = blk_rq_trace_sector(rq);
9048b77ad6SChristoph Hellwig 		__entry->nr_sector = blk_rq_trace_nr_sectors(rq);
9155782138SLi Zefan 
92ef295ecfSChristoph Hellwig 		blk_fill_rwbs(__entry->rwbs, rq->cmd_flags, blk_rq_bytes(rq));
9348b77ad6SChristoph Hellwig 		__get_str(cmd)[0] = '\0';
9455782138SLi Zefan 	),
9555782138SLi Zefan 
9655782138SLi Zefan 	TP_printk("%d,%d %s (%s) %llu + %u [%d]",
9755782138SLi Zefan 		  MAJOR(__entry->dev), MINOR(__entry->dev),
9855782138SLi Zefan 		  __entry->rwbs, __get_str(cmd),
996556d1dfSSteven Rostedt 		  (unsigned long long)__entry->sector,
100caf7df12SChristoph Hellwig 		  __entry->nr_sector, 0)
10155782138SLi Zefan );
10255782138SLi Zefan 
103881245dcSWilliam Cohen /**
104881245dcSWilliam Cohen  * block_rq_complete - block IO operation completed by device driver
105881245dcSWilliam Cohen  * @rq: block operations request
106caf7df12SChristoph Hellwig  * @error: status code
107af5040daSRoman Pen  * @nr_bytes: number of completed bytes
108881245dcSWilliam Cohen  *
109881245dcSWilliam Cohen  * The block_rq_complete tracepoint event indicates that some portion
110881245dcSWilliam Cohen  * of operation request has been completed by the device driver.  If
111881245dcSWilliam Cohen  * the @rq->bio is %NULL, then there is absolutely no additional work to
112881245dcSWilliam Cohen  * do for the request. If @rq->bio is non-NULL then there is
113881245dcSWilliam Cohen  * additional work required to complete the request.
114881245dcSWilliam Cohen  */
115af5040daSRoman Pen TRACE_EVENT(block_rq_complete,
11677ca1e02SLi Zefan 
117caf7df12SChristoph Hellwig 	TP_PROTO(struct request *rq, int error, unsigned int nr_bytes),
11877ca1e02SLi Zefan 
119caf7df12SChristoph Hellwig 	TP_ARGS(rq, error, nr_bytes),
120af5040daSRoman Pen 
121af5040daSRoman Pen 	TP_STRUCT__entry(
122af5040daSRoman Pen 		__field(  dev_t,	dev			)
123af5040daSRoman Pen 		__field(  sector_t,	sector			)
124af5040daSRoman Pen 		__field(  unsigned int,	nr_sector		)
125caf7df12SChristoph Hellwig 		__field(  int,		error			)
126af5040daSRoman Pen 		__array(  char,		rwbs,	RWBS_LEN	)
12748b77ad6SChristoph Hellwig 		__dynamic_array( char,	cmd,	1		)
128af5040daSRoman Pen 	),
129af5040daSRoman Pen 
130af5040daSRoman Pen 	TP_fast_assign(
131af5040daSRoman Pen 		__entry->dev	   = rq->rq_disk ? disk_devt(rq->rq_disk) : 0;
132af5040daSRoman Pen 		__entry->sector    = blk_rq_pos(rq);
133af5040daSRoman Pen 		__entry->nr_sector = nr_bytes >> 9;
134caf7df12SChristoph Hellwig 		__entry->error     = error;
135af5040daSRoman Pen 
136ef295ecfSChristoph Hellwig 		blk_fill_rwbs(__entry->rwbs, rq->cmd_flags, nr_bytes);
13748b77ad6SChristoph Hellwig 		__get_str(cmd)[0] = '\0';
138af5040daSRoman Pen 	),
139af5040daSRoman Pen 
140af5040daSRoman Pen 	TP_printk("%d,%d %s (%s) %llu + %u [%d]",
141af5040daSRoman Pen 		  MAJOR(__entry->dev), MINOR(__entry->dev),
142af5040daSRoman Pen 		  __entry->rwbs, __get_str(cmd),
143af5040daSRoman Pen 		  (unsigned long long)__entry->sector,
144caf7df12SChristoph Hellwig 		  __entry->nr_sector, __entry->error)
14577ca1e02SLi Zefan );
14677ca1e02SLi Zefan 
14777ca1e02SLi Zefan DECLARE_EVENT_CLASS(block_rq,
14855782138SLi Zefan 
14955782138SLi Zefan 	TP_PROTO(struct request_queue *q, struct request *rq),
15055782138SLi Zefan 
15155782138SLi Zefan 	TP_ARGS(q, rq),
15255782138SLi Zefan 
15355782138SLi Zefan 	TP_STRUCT__entry(
15455782138SLi Zefan 		__field(  dev_t,	dev			)
15555782138SLi Zefan 		__field(  sector_t,	sector			)
15655782138SLi Zefan 		__field(  unsigned int,	nr_sector		)
15755782138SLi Zefan 		__field(  unsigned int,	bytes			)
158c09c47caSNamhyung Kim 		__array(  char,		rwbs,	RWBS_LEN	)
15955782138SLi Zefan 		__array(  char,         comm,   TASK_COMM_LEN   )
16048b77ad6SChristoph Hellwig 		__dynamic_array( char,	cmd,	1		)
16155782138SLi Zefan 	),
16255782138SLi Zefan 
16355782138SLi Zefan 	TP_fast_assign(
16455782138SLi Zefan 		__entry->dev	   = rq->rq_disk ? disk_devt(rq->rq_disk) : 0;
16548b77ad6SChristoph Hellwig 		__entry->sector    = blk_rq_trace_sector(rq);
16648b77ad6SChristoph Hellwig 		__entry->nr_sector = blk_rq_trace_nr_sectors(rq);
16748b77ad6SChristoph Hellwig 		__entry->bytes     = blk_rq_bytes(rq);
16855782138SLi Zefan 
169ef295ecfSChristoph Hellwig 		blk_fill_rwbs(__entry->rwbs, rq->cmd_flags, blk_rq_bytes(rq));
17048b77ad6SChristoph Hellwig 		__get_str(cmd)[0] = '\0';
17155782138SLi Zefan 		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
17255782138SLi Zefan 	),
17355782138SLi Zefan 
17455782138SLi Zefan 	TP_printk("%d,%d %s %u (%s) %llu + %u [%s]",
17555782138SLi Zefan 		  MAJOR(__entry->dev), MINOR(__entry->dev),
17655782138SLi Zefan 		  __entry->rwbs, __entry->bytes, __get_str(cmd),
1776556d1dfSSteven Rostedt 		  (unsigned long long)__entry->sector,
1786556d1dfSSteven Rostedt 		  __entry->nr_sector, __entry->comm)
17955782138SLi Zefan );
18055782138SLi Zefan 
181881245dcSWilliam Cohen /**
182881245dcSWilliam Cohen  * block_rq_insert - insert block operation request into queue
183881245dcSWilliam Cohen  * @q: target queue
184881245dcSWilliam Cohen  * @rq: block IO operation request
185881245dcSWilliam Cohen  *
186881245dcSWilliam Cohen  * Called immediately before block operation request @rq is inserted
187881245dcSWilliam Cohen  * into queue @q.  The fields in the operation request @rq struct can
188881245dcSWilliam Cohen  * be examined to determine which device and sectors the pending
189881245dcSWilliam Cohen  * operation would access.
190881245dcSWilliam Cohen  */
19177ca1e02SLi Zefan DEFINE_EVENT(block_rq, block_rq_insert,
19255782138SLi Zefan 
19355782138SLi Zefan 	TP_PROTO(struct request_queue *q, struct request *rq),
19455782138SLi Zefan 
19577ca1e02SLi Zefan 	TP_ARGS(q, rq)
19655782138SLi Zefan );
19755782138SLi Zefan 
198881245dcSWilliam Cohen /**
199881245dcSWilliam Cohen  * block_rq_issue - issue pending block IO request operation to device driver
200881245dcSWilliam Cohen  * @q: queue holding operation
201881245dcSWilliam Cohen  * @rq: block IO operation operation request
202881245dcSWilliam Cohen  *
203881245dcSWilliam Cohen  * Called when block operation request @rq from queue @q is sent to a
204881245dcSWilliam Cohen  * device driver for processing.
205881245dcSWilliam Cohen  */
20677ca1e02SLi Zefan DEFINE_EVENT(block_rq, block_rq_issue,
20755782138SLi Zefan 
20855782138SLi Zefan 	TP_PROTO(struct request_queue *q, struct request *rq),
20955782138SLi Zefan 
21077ca1e02SLi Zefan 	TP_ARGS(q, rq)
21155782138SLi Zefan );
212fe63b94aSCarsten Emde 
213881245dcSWilliam Cohen /**
214881245dcSWilliam Cohen  * block_bio_bounce - used bounce buffer when processing block operation
215881245dcSWilliam Cohen  * @q: queue holding the block operation
216881245dcSWilliam Cohen  * @bio: block operation
217881245dcSWilliam Cohen  *
218881245dcSWilliam Cohen  * A bounce buffer was used to handle the block operation @bio in @q.
219881245dcSWilliam Cohen  * This occurs when hardware limitations prevent a direct transfer of
220881245dcSWilliam Cohen  * data between the @bio data memory area and the IO device.  Use of a
221881245dcSWilliam Cohen  * bounce buffer requires extra copying of data and decreases
222881245dcSWilliam Cohen  * performance.
223881245dcSWilliam Cohen  */
22455782138SLi Zefan TRACE_EVENT(block_bio_bounce,
22555782138SLi Zefan 
22655782138SLi Zefan 	TP_PROTO(struct request_queue *q, struct bio *bio),
22755782138SLi Zefan 
22855782138SLi Zefan 	TP_ARGS(q, bio),
22955782138SLi Zefan 
23055782138SLi Zefan 	TP_STRUCT__entry(
23155782138SLi Zefan 		__field( dev_t,		dev			)
23255782138SLi Zefan 		__field( sector_t,	sector			)
23355782138SLi Zefan 		__field( unsigned int,	nr_sector		)
234c09c47caSNamhyung Kim 		__array( char,		rwbs,	RWBS_LEN	)
23555782138SLi Zefan 		__array( char,		comm,	TASK_COMM_LEN	)
23655782138SLi Zefan 	),
23755782138SLi Zefan 
23855782138SLi Zefan 	TP_fast_assign(
239*74d46992SChristoph Hellwig 		__entry->dev		= bio_dev(bio);
2404f024f37SKent Overstreet 		__entry->sector		= bio->bi_iter.bi_sector;
241aa8b57aaSKent Overstreet 		__entry->nr_sector	= bio_sectors(bio);
242ef295ecfSChristoph Hellwig 		blk_fill_rwbs(__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size);
24355782138SLi Zefan 		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
24455782138SLi Zefan 	),
24555782138SLi Zefan 
24655782138SLi Zefan 	TP_printk("%d,%d %s %llu + %u [%s]",
24755782138SLi Zefan 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
2486556d1dfSSteven Rostedt 		  (unsigned long long)__entry->sector,
2496556d1dfSSteven Rostedt 		  __entry->nr_sector, __entry->comm)
25055782138SLi Zefan );
25155782138SLi Zefan 
252881245dcSWilliam Cohen /**
253881245dcSWilliam Cohen  * block_bio_complete - completed all work on the block operation
2540a82a8d1SLinus Torvalds  * @q: queue holding the block operation
255881245dcSWilliam Cohen  * @bio: block operation completed
256b7908c10SJeff Moyer  * @error: io error value
257881245dcSWilliam Cohen  *
258881245dcSWilliam Cohen  * This tracepoint indicates there is no further work to do on this
259881245dcSWilliam Cohen  * block IO operation @bio.
260881245dcSWilliam Cohen  */
26155782138SLi Zefan TRACE_EVENT(block_bio_complete,
26255782138SLi Zefan 
2630a82a8d1SLinus Torvalds 	TP_PROTO(struct request_queue *q, struct bio *bio, int error),
26455782138SLi Zefan 
2650a82a8d1SLinus Torvalds 	TP_ARGS(q, bio, error),
26655782138SLi Zefan 
26755782138SLi Zefan 	TP_STRUCT__entry(
26855782138SLi Zefan 		__field( dev_t,		dev		)
26955782138SLi Zefan 		__field( sector_t,	sector		)
27055782138SLi Zefan 		__field( unsigned,	nr_sector	)
27155782138SLi Zefan 		__field( int,		error		)
272c09c47caSNamhyung Kim 		__array( char,		rwbs,	RWBS_LEN)
27355782138SLi Zefan 	),
27455782138SLi Zefan 
27555782138SLi Zefan 	TP_fast_assign(
276*74d46992SChristoph Hellwig 		__entry->dev		= bio_dev(bio);
2774f024f37SKent Overstreet 		__entry->sector		= bio->bi_iter.bi_sector;
278aa8b57aaSKent Overstreet 		__entry->nr_sector	= bio_sectors(bio);
279b7908c10SJeff Moyer 		__entry->error		= error;
280ef295ecfSChristoph Hellwig 		blk_fill_rwbs(__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size);
28155782138SLi Zefan 	),
28255782138SLi Zefan 
28355782138SLi Zefan 	TP_printk("%d,%d %s %llu + %u [%d]",
28455782138SLi Zefan 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
2856556d1dfSSteven Rostedt 		  (unsigned long long)__entry->sector,
2866556d1dfSSteven Rostedt 		  __entry->nr_sector, __entry->error)
28755782138SLi Zefan );
28855782138SLi Zefan 
2898c1cf6bbSTejun Heo DECLARE_EVENT_CLASS(block_bio_merge,
29055782138SLi Zefan 
2918c1cf6bbSTejun Heo 	TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio),
29255782138SLi Zefan 
2938c1cf6bbSTejun Heo 	TP_ARGS(q, rq, bio),
29455782138SLi Zefan 
29555782138SLi Zefan 	TP_STRUCT__entry(
29655782138SLi Zefan 		__field( dev_t,		dev			)
29755782138SLi Zefan 		__field( sector_t,	sector			)
29855782138SLi Zefan 		__field( unsigned int,	nr_sector		)
299c09c47caSNamhyung Kim 		__array( char,		rwbs,	RWBS_LEN	)
30055782138SLi Zefan 		__array( char,		comm,	TASK_COMM_LEN	)
30155782138SLi Zefan 	),
30255782138SLi Zefan 
30355782138SLi Zefan 	TP_fast_assign(
304*74d46992SChristoph Hellwig 		__entry->dev		= bio_dev(bio);
3054f024f37SKent Overstreet 		__entry->sector		= bio->bi_iter.bi_sector;
306aa8b57aaSKent Overstreet 		__entry->nr_sector	= bio_sectors(bio);
307ef295ecfSChristoph Hellwig 		blk_fill_rwbs(__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size);
30855782138SLi Zefan 		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
30955782138SLi Zefan 	),
31055782138SLi Zefan 
31155782138SLi Zefan 	TP_printk("%d,%d %s %llu + %u [%s]",
31255782138SLi Zefan 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
3136556d1dfSSteven Rostedt 		  (unsigned long long)__entry->sector,
3146556d1dfSSteven Rostedt 		  __entry->nr_sector, __entry->comm)
31555782138SLi Zefan );
31655782138SLi Zefan 
317881245dcSWilliam Cohen /**
318881245dcSWilliam Cohen  * block_bio_backmerge - merging block operation to the end of an existing operation
319881245dcSWilliam Cohen  * @q: queue holding operation
3208c1cf6bbSTejun Heo  * @rq: request bio is being merged into
321881245dcSWilliam Cohen  * @bio: new block operation to merge
322881245dcSWilliam Cohen  *
323881245dcSWilliam Cohen  * Merging block request @bio to the end of an existing block request
324881245dcSWilliam Cohen  * in queue @q.
325881245dcSWilliam Cohen  */
3268c1cf6bbSTejun Heo DEFINE_EVENT(block_bio_merge, block_bio_backmerge,
32755782138SLi Zefan 
3288c1cf6bbSTejun Heo 	TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio),
32955782138SLi Zefan 
3308c1cf6bbSTejun Heo 	TP_ARGS(q, rq, bio)
33155782138SLi Zefan );
33255782138SLi Zefan 
333881245dcSWilliam Cohen /**
334881245dcSWilliam Cohen  * block_bio_frontmerge - merging block operation to the beginning of an existing operation
335881245dcSWilliam Cohen  * @q: queue holding operation
3368c1cf6bbSTejun Heo  * @rq: request bio is being merged into
337881245dcSWilliam Cohen  * @bio: new block operation to merge
338881245dcSWilliam Cohen  *
339881245dcSWilliam Cohen  * Merging block IO operation @bio to the beginning of an existing block
340881245dcSWilliam Cohen  * operation in queue @q.
341881245dcSWilliam Cohen  */
3428c1cf6bbSTejun Heo DEFINE_EVENT(block_bio_merge, block_bio_frontmerge,
34355782138SLi Zefan 
3448c1cf6bbSTejun Heo 	TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio),
34555782138SLi Zefan 
3468c1cf6bbSTejun Heo 	TP_ARGS(q, rq, bio)
34755782138SLi Zefan );
34855782138SLi Zefan 
349881245dcSWilliam Cohen /**
350881245dcSWilliam Cohen  * block_bio_queue - putting new block IO operation in queue
351881245dcSWilliam Cohen  * @q: queue holding operation
352881245dcSWilliam Cohen  * @bio: new block operation
353881245dcSWilliam Cohen  *
354881245dcSWilliam Cohen  * About to place the block IO operation @bio into queue @q.
355881245dcSWilliam Cohen  */
3568c1cf6bbSTejun Heo TRACE_EVENT(block_bio_queue,
35777ca1e02SLi Zefan 
35877ca1e02SLi Zefan 	TP_PROTO(struct request_queue *q, struct bio *bio),
35977ca1e02SLi Zefan 
3608c1cf6bbSTejun Heo 	TP_ARGS(q, bio),
3618c1cf6bbSTejun Heo 
3628c1cf6bbSTejun Heo 	TP_STRUCT__entry(
3638c1cf6bbSTejun Heo 		__field( dev_t,		dev			)
3648c1cf6bbSTejun Heo 		__field( sector_t,	sector			)
3658c1cf6bbSTejun Heo 		__field( unsigned int,	nr_sector		)
3668c1cf6bbSTejun Heo 		__array( char,		rwbs,	RWBS_LEN	)
3678c1cf6bbSTejun Heo 		__array( char,		comm,	TASK_COMM_LEN	)
3688c1cf6bbSTejun Heo 	),
3698c1cf6bbSTejun Heo 
3708c1cf6bbSTejun Heo 	TP_fast_assign(
371*74d46992SChristoph Hellwig 		__entry->dev		= bio_dev(bio);
3724f024f37SKent Overstreet 		__entry->sector		= bio->bi_iter.bi_sector;
373aa8b57aaSKent Overstreet 		__entry->nr_sector	= bio_sectors(bio);
374ef295ecfSChristoph Hellwig 		blk_fill_rwbs(__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size);
3758c1cf6bbSTejun Heo 		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
3768c1cf6bbSTejun Heo 	),
3778c1cf6bbSTejun Heo 
3788c1cf6bbSTejun Heo 	TP_printk("%d,%d %s %llu + %u [%s]",
3798c1cf6bbSTejun Heo 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
3808c1cf6bbSTejun Heo 		  (unsigned long long)__entry->sector,
3818c1cf6bbSTejun Heo 		  __entry->nr_sector, __entry->comm)
38277ca1e02SLi Zefan );
38377ca1e02SLi Zefan 
38477ca1e02SLi Zefan DECLARE_EVENT_CLASS(block_get_rq,
38555782138SLi Zefan 
38655782138SLi Zefan 	TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
38755782138SLi Zefan 
38855782138SLi Zefan 	TP_ARGS(q, bio, rw),
38955782138SLi Zefan 
39055782138SLi Zefan 	TP_STRUCT__entry(
39155782138SLi Zefan 		__field( dev_t,		dev			)
39255782138SLi Zefan 		__field( sector_t,	sector			)
39355782138SLi Zefan 		__field( unsigned int,	nr_sector		)
394c09c47caSNamhyung Kim 		__array( char,		rwbs,	RWBS_LEN	)
39555782138SLi Zefan 		__array( char,		comm,	TASK_COMM_LEN	)
39655782138SLi Zefan         ),
39755782138SLi Zefan 
39855782138SLi Zefan 	TP_fast_assign(
399*74d46992SChristoph Hellwig 		__entry->dev		= bio ? bio_dev(bio) : 0;
400*74d46992SChristoph Hellwig 		__entry->dev		= bio_dev(bio);
4014f024f37SKent Overstreet 		__entry->sector		= bio ? bio->bi_iter.bi_sector : 0;
402aa8b57aaSKent Overstreet 		__entry->nr_sector	= bio ? bio_sectors(bio) : 0;
403ef295ecfSChristoph Hellwig 		blk_fill_rwbs(__entry->rwbs,
4041eff9d32SJens Axboe 			      bio ? bio->bi_opf : 0, __entry->nr_sector);
40555782138SLi Zefan 		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
40655782138SLi Zefan         ),
40755782138SLi Zefan 
40855782138SLi Zefan 	TP_printk("%d,%d %s %llu + %u [%s]",
40955782138SLi Zefan 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
4106556d1dfSSteven Rostedt 		  (unsigned long long)__entry->sector,
4116556d1dfSSteven Rostedt 		  __entry->nr_sector, __entry->comm)
41255782138SLi Zefan );
41355782138SLi Zefan 
414881245dcSWilliam Cohen /**
415881245dcSWilliam Cohen  * block_getrq - get a free request entry in queue for block IO operations
416881245dcSWilliam Cohen  * @q: queue for operations
417881245dcSWilliam Cohen  * @bio: pending block IO operation
418881245dcSWilliam Cohen  * @rw: low bit indicates a read (%0) or a write (%1)
419881245dcSWilliam Cohen  *
420881245dcSWilliam Cohen  * A request struct for queue @q has been allocated to handle the
421881245dcSWilliam Cohen  * block IO operation @bio.
422881245dcSWilliam Cohen  */
42377ca1e02SLi Zefan DEFINE_EVENT(block_get_rq, block_getrq,
42455782138SLi Zefan 
42555782138SLi Zefan 	TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
42655782138SLi Zefan 
42777ca1e02SLi Zefan 	TP_ARGS(q, bio, rw)
42877ca1e02SLi Zefan );
42955782138SLi Zefan 
430881245dcSWilliam Cohen /**
431881245dcSWilliam Cohen  * block_sleeprq - waiting to get a free request entry in queue for block IO operation
432881245dcSWilliam Cohen  * @q: queue for operation
433881245dcSWilliam Cohen  * @bio: pending block IO operation
434881245dcSWilliam Cohen  * @rw: low bit indicates a read (%0) or a write (%1)
435881245dcSWilliam Cohen  *
436881245dcSWilliam Cohen  * In the case where a request struct cannot be provided for queue @q
437881245dcSWilliam Cohen  * the process needs to wait for an request struct to become
438881245dcSWilliam Cohen  * available.  This tracepoint event is generated each time the
439881245dcSWilliam Cohen  * process goes to sleep waiting for request struct become available.
440881245dcSWilliam Cohen  */
44177ca1e02SLi Zefan DEFINE_EVENT(block_get_rq, block_sleeprq,
44255782138SLi Zefan 
44377ca1e02SLi Zefan 	TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
44455782138SLi Zefan 
44577ca1e02SLi Zefan 	TP_ARGS(q, bio, rw)
44655782138SLi Zefan );
44755782138SLi Zefan 
448881245dcSWilliam Cohen /**
449881245dcSWilliam Cohen  * block_plug - keep operations requests in request queue
450881245dcSWilliam Cohen  * @q: request queue to plug
451881245dcSWilliam Cohen  *
452881245dcSWilliam Cohen  * Plug the request queue @q.  Do not allow block operation requests
453881245dcSWilliam Cohen  * to be sent to the device driver. Instead, accumulate requests in
454881245dcSWilliam Cohen  * the queue to improve throughput performance of the block device.
455881245dcSWilliam Cohen  */
45655782138SLi Zefan TRACE_EVENT(block_plug,
45755782138SLi Zefan 
45855782138SLi Zefan 	TP_PROTO(struct request_queue *q),
45955782138SLi Zefan 
46055782138SLi Zefan 	TP_ARGS(q),
46155782138SLi Zefan 
46255782138SLi Zefan 	TP_STRUCT__entry(
46355782138SLi Zefan 		__array( char,		comm,	TASK_COMM_LEN	)
46455782138SLi Zefan 	),
46555782138SLi Zefan 
46655782138SLi Zefan 	TP_fast_assign(
46755782138SLi Zefan 		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
46855782138SLi Zefan 	),
46955782138SLi Zefan 
47055782138SLi Zefan 	TP_printk("[%s]", __entry->comm)
47155782138SLi Zefan );
47255782138SLi Zefan 
47377ca1e02SLi Zefan DECLARE_EVENT_CLASS(block_unplug,
47455782138SLi Zefan 
47549cac01eSJens Axboe 	TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit),
47655782138SLi Zefan 
47749cac01eSJens Axboe 	TP_ARGS(q, depth, explicit),
47855782138SLi Zefan 
47955782138SLi Zefan 	TP_STRUCT__entry(
48055782138SLi Zefan 		__field( int,		nr_rq			)
48155782138SLi Zefan 		__array( char,		comm,	TASK_COMM_LEN	)
48255782138SLi Zefan 	),
48355782138SLi Zefan 
48455782138SLi Zefan 	TP_fast_assign(
48594b5eb28SJens Axboe 		__entry->nr_rq = depth;
48655782138SLi Zefan 		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
48755782138SLi Zefan 	),
48855782138SLi Zefan 
48955782138SLi Zefan 	TP_printk("[%s] %d", __entry->comm, __entry->nr_rq)
49055782138SLi Zefan );
49155782138SLi Zefan 
492881245dcSWilliam Cohen /**
49349cac01eSJens Axboe  * block_unplug - release of operations requests in request queue
494881245dcSWilliam Cohen  * @q: request queue to unplug
49594b5eb28SJens Axboe  * @depth: number of requests just added to the queue
49649cac01eSJens Axboe  * @explicit: whether this was an explicit unplug, or one from schedule()
497881245dcSWilliam Cohen  *
498881245dcSWilliam Cohen  * Unplug request queue @q because device driver is scheduled to work
499881245dcSWilliam Cohen  * on elements in the request queue.
500881245dcSWilliam Cohen  */
50149cac01eSJens Axboe DEFINE_EVENT(block_unplug, block_unplug,
50255782138SLi Zefan 
50349cac01eSJens Axboe 	TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit),
50455782138SLi Zefan 
50549cac01eSJens Axboe 	TP_ARGS(q, depth, explicit)
50655782138SLi Zefan );
50755782138SLi Zefan 
508881245dcSWilliam Cohen /**
509881245dcSWilliam Cohen  * block_split - split a single bio struct into two bio structs
510881245dcSWilliam Cohen  * @q: queue containing the bio
511881245dcSWilliam Cohen  * @bio: block operation being split
512881245dcSWilliam Cohen  * @new_sector: The starting sector for the new bio
513881245dcSWilliam Cohen  *
514881245dcSWilliam Cohen  * The bio request @bio in request queue @q needs to be split into two
515881245dcSWilliam Cohen  * bio requests. The newly created @bio request starts at
516881245dcSWilliam Cohen  * @new_sector. This split may be required due to hardware limitation
517881245dcSWilliam Cohen  * such as operation crossing device boundaries in a RAID system.
518881245dcSWilliam Cohen  */
51955782138SLi Zefan TRACE_EVENT(block_split,
52055782138SLi Zefan 
52155782138SLi Zefan 	TP_PROTO(struct request_queue *q, struct bio *bio,
52255782138SLi Zefan 		 unsigned int new_sector),
52355782138SLi Zefan 
52455782138SLi Zefan 	TP_ARGS(q, bio, new_sector),
52555782138SLi Zefan 
52655782138SLi Zefan 	TP_STRUCT__entry(
52755782138SLi Zefan 		__field( dev_t,		dev				)
52855782138SLi Zefan 		__field( sector_t,	sector				)
52955782138SLi Zefan 		__field( sector_t,	new_sector			)
530c09c47caSNamhyung Kim 		__array( char,		rwbs,		RWBS_LEN	)
53155782138SLi Zefan 		__array( char,		comm,		TASK_COMM_LEN	)
53255782138SLi Zefan 	),
53355782138SLi Zefan 
53455782138SLi Zefan 	TP_fast_assign(
535*74d46992SChristoph Hellwig 		__entry->dev		= bio_dev(bio);
5364f024f37SKent Overstreet 		__entry->sector		= bio->bi_iter.bi_sector;
53755782138SLi Zefan 		__entry->new_sector	= new_sector;
538ef295ecfSChristoph Hellwig 		blk_fill_rwbs(__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size);
53955782138SLi Zefan 		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
54055782138SLi Zefan 	),
54155782138SLi Zefan 
54255782138SLi Zefan 	TP_printk("%d,%d %s %llu / %llu [%s]",
54355782138SLi Zefan 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
5446556d1dfSSteven Rostedt 		  (unsigned long long)__entry->sector,
5456556d1dfSSteven Rostedt 		  (unsigned long long)__entry->new_sector,
5466556d1dfSSteven Rostedt 		  __entry->comm)
54755782138SLi Zefan );
54855782138SLi Zefan 
549881245dcSWilliam Cohen /**
550d07335e5SMike Snitzer  * block_bio_remap - map request for a logical device to the raw device
551881245dcSWilliam Cohen  * @q: queue holding the operation
552881245dcSWilliam Cohen  * @bio: revised operation
553881245dcSWilliam Cohen  * @dev: device for the operation
554881245dcSWilliam Cohen  * @from: original sector for the operation
555881245dcSWilliam Cohen  *
556d07335e5SMike Snitzer  * An operation for a logical device has been mapped to the
557881245dcSWilliam Cohen  * raw block device.
558881245dcSWilliam Cohen  */
559d07335e5SMike Snitzer TRACE_EVENT(block_bio_remap,
56055782138SLi Zefan 
56155782138SLi Zefan 	TP_PROTO(struct request_queue *q, struct bio *bio, dev_t dev,
56255782138SLi Zefan 		 sector_t from),
56355782138SLi Zefan 
56455782138SLi Zefan 	TP_ARGS(q, bio, dev, from),
56555782138SLi Zefan 
56655782138SLi Zefan 	TP_STRUCT__entry(
56755782138SLi Zefan 		__field( dev_t,		dev		)
56855782138SLi Zefan 		__field( sector_t,	sector		)
56955782138SLi Zefan 		__field( unsigned int,	nr_sector	)
57055782138SLi Zefan 		__field( dev_t,		old_dev		)
57155782138SLi Zefan 		__field( sector_t,	old_sector	)
572c09c47caSNamhyung Kim 		__array( char,		rwbs,	RWBS_LEN)
57355782138SLi Zefan 	),
57455782138SLi Zefan 
57555782138SLi Zefan 	TP_fast_assign(
576*74d46992SChristoph Hellwig 		__entry->dev		= bio_dev(bio);
5774f024f37SKent Overstreet 		__entry->sector		= bio->bi_iter.bi_sector;
578aa8b57aaSKent Overstreet 		__entry->nr_sector	= bio_sectors(bio);
57955782138SLi Zefan 		__entry->old_dev	= dev;
58055782138SLi Zefan 		__entry->old_sector	= from;
581ef295ecfSChristoph Hellwig 		blk_fill_rwbs(__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size);
58255782138SLi Zefan 	),
58355782138SLi Zefan 
58455782138SLi Zefan 	TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
58555782138SLi Zefan 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
5866556d1dfSSteven Rostedt 		  (unsigned long long)__entry->sector,
5876556d1dfSSteven Rostedt 		  __entry->nr_sector,
58855782138SLi Zefan 		  MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
5896556d1dfSSteven Rostedt 		  (unsigned long long)__entry->old_sector)
59055782138SLi Zefan );
59155782138SLi Zefan 
592881245dcSWilliam Cohen /**
593881245dcSWilliam Cohen  * block_rq_remap - map request for a block operation request
594881245dcSWilliam Cohen  * @q: queue holding the operation
595881245dcSWilliam Cohen  * @rq: block IO operation request
596881245dcSWilliam Cohen  * @dev: device for the operation
597881245dcSWilliam Cohen  * @from: original sector for the operation
598881245dcSWilliam Cohen  *
599881245dcSWilliam Cohen  * The block operation request @rq in @q has been remapped.  The block
600881245dcSWilliam Cohen  * operation request @rq holds the current information and @from hold
601881245dcSWilliam Cohen  * the original sector.
602881245dcSWilliam Cohen  */
603b0da3f0dSJun'ichi Nomura TRACE_EVENT(block_rq_remap,
604b0da3f0dSJun'ichi Nomura 
605b0da3f0dSJun'ichi Nomura 	TP_PROTO(struct request_queue *q, struct request *rq, dev_t dev,
606b0da3f0dSJun'ichi Nomura 		 sector_t from),
607b0da3f0dSJun'ichi Nomura 
608b0da3f0dSJun'ichi Nomura 	TP_ARGS(q, rq, dev, from),
609b0da3f0dSJun'ichi Nomura 
610b0da3f0dSJun'ichi Nomura 	TP_STRUCT__entry(
611b0da3f0dSJun'ichi Nomura 		__field( dev_t,		dev		)
612b0da3f0dSJun'ichi Nomura 		__field( sector_t,	sector		)
613b0da3f0dSJun'ichi Nomura 		__field( unsigned int,	nr_sector	)
614b0da3f0dSJun'ichi Nomura 		__field( dev_t,		old_dev		)
615b0da3f0dSJun'ichi Nomura 		__field( sector_t,	old_sector	)
61675afb352SJun'ichi Nomura 		__field( unsigned int,	nr_bios		)
617c09c47caSNamhyung Kim 		__array( char,		rwbs,	RWBS_LEN)
618b0da3f0dSJun'ichi Nomura 	),
619b0da3f0dSJun'ichi Nomura 
620b0da3f0dSJun'ichi Nomura 	TP_fast_assign(
621b0da3f0dSJun'ichi Nomura 		__entry->dev		= disk_devt(rq->rq_disk);
622b0da3f0dSJun'ichi Nomura 		__entry->sector		= blk_rq_pos(rq);
623b0da3f0dSJun'ichi Nomura 		__entry->nr_sector	= blk_rq_sectors(rq);
624b0da3f0dSJun'ichi Nomura 		__entry->old_dev	= dev;
625b0da3f0dSJun'ichi Nomura 		__entry->old_sector	= from;
62675afb352SJun'ichi Nomura 		__entry->nr_bios	= blk_rq_count_bios(rq);
627ef295ecfSChristoph Hellwig 		blk_fill_rwbs(__entry->rwbs, rq->cmd_flags, blk_rq_bytes(rq));
628b0da3f0dSJun'ichi Nomura 	),
629b0da3f0dSJun'ichi Nomura 
63075afb352SJun'ichi Nomura 	TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu %u",
631b0da3f0dSJun'ichi Nomura 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
632b0da3f0dSJun'ichi Nomura 		  (unsigned long long)__entry->sector,
633b0da3f0dSJun'ichi Nomura 		  __entry->nr_sector,
634b0da3f0dSJun'ichi Nomura 		  MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
63575afb352SJun'ichi Nomura 		  (unsigned long long)__entry->old_sector, __entry->nr_bios)
636b0da3f0dSJun'ichi Nomura );
637b0da3f0dSJun'ichi Nomura 
63855782138SLi Zefan #endif /* _TRACE_BLOCK_H */
63955782138SLi Zefan 
64055782138SLi Zefan /* This part must be outside protection */
64155782138SLi Zefan #include <trace/define_trace.h>
64255782138SLi Zefan 
643