xref: /openbmc/linux/include/trace/events/block.h (revision 5a80bd075f3bce24793ae1aeb06066895ec5aef0)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2d0b6e04aSLi Zefan #undef TRACE_SYSTEM
3d0b6e04aSLi Zefan #define TRACE_SYSTEM block
4d0b6e04aSLi Zefan 
555782138SLi Zefan #if !defined(_TRACE_BLOCK_H) || defined(TRACE_HEADER_MULTI_READ)
655782138SLi Zefan #define _TRACE_BLOCK_H
755782138SLi Zefan 
855782138SLi Zefan #include <linux/blktrace_api.h>
955782138SLi Zefan #include <linux/blkdev.h>
105305cb83STejun Heo #include <linux/buffer_head.h>
1155782138SLi Zefan #include <linux/tracepoint.h>
1255782138SLi Zefan 
13c09c47caSNamhyung Kim #define RWBS_LEN	8
14c09c47caSNamhyung Kim 
155305cb83STejun Heo DECLARE_EVENT_CLASS(block_buffer,
165305cb83STejun Heo 
175305cb83STejun Heo 	TP_PROTO(struct buffer_head *bh),
185305cb83STejun Heo 
195305cb83STejun Heo 	TP_ARGS(bh),
205305cb83STejun Heo 
215305cb83STejun Heo 	TP_STRUCT__entry (
225305cb83STejun Heo 		__field(  dev_t,	dev			)
235305cb83STejun Heo 		__field(  sector_t,	sector			)
245305cb83STejun Heo 		__field(  size_t,	size			)
255305cb83STejun Heo 	),
265305cb83STejun Heo 
275305cb83STejun Heo 	TP_fast_assign(
285305cb83STejun Heo 		__entry->dev		= bh->b_bdev->bd_dev;
295305cb83STejun Heo 		__entry->sector		= bh->b_blocknr;
305305cb83STejun Heo 		__entry->size		= bh->b_size;
315305cb83STejun Heo 	),
325305cb83STejun Heo 
335305cb83STejun Heo 	TP_printk("%d,%d sector=%llu size=%zu",
345305cb83STejun Heo 		MAJOR(__entry->dev), MINOR(__entry->dev),
355305cb83STejun Heo 		(unsigned long long)__entry->sector, __entry->size
365305cb83STejun Heo 	)
375305cb83STejun Heo );
385305cb83STejun Heo 
395305cb83STejun Heo /**
405305cb83STejun Heo  * block_touch_buffer - mark a buffer accessed
415305cb83STejun Heo  * @bh: buffer_head being touched
425305cb83STejun Heo  *
435305cb83STejun Heo  * Called from touch_buffer().
445305cb83STejun Heo  */
455305cb83STejun Heo DEFINE_EVENT(block_buffer, block_touch_buffer,
465305cb83STejun Heo 
475305cb83STejun Heo 	TP_PROTO(struct buffer_head *bh),
485305cb83STejun Heo 
495305cb83STejun Heo 	TP_ARGS(bh)
505305cb83STejun Heo );
515305cb83STejun Heo 
525305cb83STejun Heo /**
535305cb83STejun Heo  * block_dirty_buffer - mark a buffer dirty
545305cb83STejun Heo  * @bh: buffer_head being dirtied
555305cb83STejun Heo  *
565305cb83STejun Heo  * Called from mark_buffer_dirty().
575305cb83STejun Heo  */
585305cb83STejun Heo DEFINE_EVENT(block_buffer, block_dirty_buffer,
595305cb83STejun Heo 
605305cb83STejun Heo 	TP_PROTO(struct buffer_head *bh),
615305cb83STejun Heo 
625305cb83STejun Heo 	TP_ARGS(bh)
635305cb83STejun Heo );
645305cb83STejun Heo 
65cee4b7ceSChristoph Hellwig /**
66cee4b7ceSChristoph Hellwig  * block_rq_requeue - place block IO request back on a queue
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 
75a54895faSChristoph Hellwig 	TP_PROTO(struct request *rq),
7655782138SLi Zefan 
77a54895faSChristoph Hellwig 	TP_ARGS(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(
88f3fa33acSChristoph Hellwig 		__entry->dev	   = rq->q->disk ? disk_devt(rq->q->disk) : 0;
8948b77ad6SChristoph Hellwig 		__entry->sector    = blk_rq_trace_sector(rq);
9048b77ad6SChristoph Hellwig 		__entry->nr_sector = blk_rq_trace_nr_sectors(rq);
9155782138SLi Zefan 
92179d1600SChaitanya Kulkarni 		blk_fill_rwbs(__entry->rwbs, rq->cmd_flags);
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 
103d5869fdcSYang Shi DECLARE_EVENT_CLASS(block_rq_completion,
10477ca1e02SLi Zefan 
1058a7d267bSChristoph Hellwig 	TP_PROTO(struct request *rq, blk_status_t error, unsigned int nr_bytes),
10677ca1e02SLi Zefan 
107caf7df12SChristoph Hellwig 	TP_ARGS(rq, error, nr_bytes),
108af5040daSRoman Pen 
109af5040daSRoman Pen 	TP_STRUCT__entry(
110af5040daSRoman Pen 		__field(  dev_t,	dev			)
111af5040daSRoman Pen 		__field(  sector_t,	sector			)
112af5040daSRoman Pen 		__field(  unsigned int,	nr_sector		)
113caf7df12SChristoph Hellwig 		__field(  int	,	error			)
114af5040daSRoman Pen 		__array(  char,		rwbs,	RWBS_LEN	)
11548b77ad6SChristoph Hellwig 		__dynamic_array( char,	cmd,	1		)
116af5040daSRoman Pen 	),
117af5040daSRoman Pen 
118af5040daSRoman Pen 	TP_fast_assign(
119f3fa33acSChristoph Hellwig 		__entry->dev	   = rq->q->disk ? disk_devt(rq->q->disk) : 0;
120af5040daSRoman Pen 		__entry->sector    = blk_rq_pos(rq);
121af5040daSRoman Pen 		__entry->nr_sector = nr_bytes >> 9;
1228a7d267bSChristoph Hellwig 		__entry->error     = blk_status_to_errno(error);
123af5040daSRoman Pen 
124179d1600SChaitanya Kulkarni 		blk_fill_rwbs(__entry->rwbs, rq->cmd_flags);
12548b77ad6SChristoph Hellwig 		__get_str(cmd)[0] = '\0';
126af5040daSRoman Pen 	),
127af5040daSRoman Pen 
128af5040daSRoman Pen 	TP_printk("%d,%d %s (%s) %llu + %u [%d]",
129af5040daSRoman Pen 		  MAJOR(__entry->dev), MINOR(__entry->dev),
130af5040daSRoman Pen 		  __entry->rwbs, __get_str(cmd),
131af5040daSRoman Pen 		  (unsigned long long)__entry->sector,
132caf7df12SChristoph Hellwig 		  __entry->nr_sector, __entry->error)
13377ca1e02SLi Zefan );
13477ca1e02SLi Zefan 
135d5869fdcSYang Shi /**
136d5869fdcSYang Shi  * block_rq_complete - block IO operation completed by device driver
137d5869fdcSYang Shi  * @rq: block operations request
138d5869fdcSYang Shi  * @error: status code
139d5869fdcSYang Shi  * @nr_bytes: number of completed bytes
140d5869fdcSYang Shi  *
141d5869fdcSYang Shi  * The block_rq_complete tracepoint event indicates that some portion
142d5869fdcSYang Shi  * of operation request has been completed by the device driver.  If
143d5869fdcSYang Shi  * the @rq->bio is %NULL, then there is absolutely no additional work to
144d5869fdcSYang Shi  * do for the request. If @rq->bio is non-NULL then there is
145d5869fdcSYang Shi  * additional work required to complete the request.
146d5869fdcSYang Shi  */
147d5869fdcSYang Shi DEFINE_EVENT(block_rq_completion, block_rq_complete,
148d5869fdcSYang Shi 
149d5869fdcSYang Shi 	TP_PROTO(struct request *rq, blk_status_t error, unsigned int nr_bytes),
150d5869fdcSYang Shi 
151d5869fdcSYang Shi 	TP_ARGS(rq, error, nr_bytes)
152d5869fdcSYang Shi );
153d5869fdcSYang Shi 
154d5869fdcSYang Shi /**
155d5869fdcSYang Shi  * block_rq_error - block IO operation error reported by device driver
156d5869fdcSYang Shi  * @rq: block operations request
157d5869fdcSYang Shi  * @error: status code
158d5869fdcSYang Shi  * @nr_bytes: number of completed bytes
159d5869fdcSYang Shi  *
160d5869fdcSYang Shi  * The block_rq_error tracepoint event indicates that some portion
161d5869fdcSYang Shi  * of operation request has failed as reported by the device driver.
162d5869fdcSYang Shi  */
163d5869fdcSYang Shi DEFINE_EVENT(block_rq_completion, block_rq_error,
164d5869fdcSYang Shi 
165d5869fdcSYang Shi 	TP_PROTO(struct request *rq, blk_status_t error, unsigned int nr_bytes),
166d5869fdcSYang Shi 
167d5869fdcSYang Shi 	TP_ARGS(rq, error, nr_bytes)
168d5869fdcSYang Shi );
169d5869fdcSYang Shi 
17077ca1e02SLi Zefan DECLARE_EVENT_CLASS(block_rq,
17155782138SLi Zefan 
172a54895faSChristoph Hellwig 	TP_PROTO(struct request *rq),
17355782138SLi Zefan 
174a54895faSChristoph Hellwig 	TP_ARGS(rq),
17555782138SLi Zefan 
17655782138SLi Zefan 	TP_STRUCT__entry(
17755782138SLi Zefan 		__field(  dev_t,	dev			)
17855782138SLi Zefan 		__field(  sector_t,	sector			)
17955782138SLi Zefan 		__field(  unsigned int,	nr_sector		)
18055782138SLi Zefan 		__field(  unsigned int,	bytes			)
181c09c47caSNamhyung Kim 		__array(  char,		rwbs,	RWBS_LEN	)
18255782138SLi Zefan 		__array(  char,         comm,   TASK_COMM_LEN   )
18348b77ad6SChristoph Hellwig 		__dynamic_array( char,	cmd,	1		)
18455782138SLi Zefan 	),
18555782138SLi Zefan 
18655782138SLi Zefan 	TP_fast_assign(
187f3fa33acSChristoph Hellwig 		__entry->dev	   = rq->q->disk ? disk_devt(rq->q->disk) : 0;
18848b77ad6SChristoph Hellwig 		__entry->sector    = blk_rq_trace_sector(rq);
18948b77ad6SChristoph Hellwig 		__entry->nr_sector = blk_rq_trace_nr_sectors(rq);
19048b77ad6SChristoph Hellwig 		__entry->bytes     = blk_rq_bytes(rq);
19155782138SLi Zefan 
192179d1600SChaitanya Kulkarni 		blk_fill_rwbs(__entry->rwbs, rq->cmd_flags);
19348b77ad6SChristoph Hellwig 		__get_str(cmd)[0] = '\0';
19455782138SLi Zefan 		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
19555782138SLi Zefan 	),
19655782138SLi Zefan 
19755782138SLi Zefan 	TP_printk("%d,%d %s %u (%s) %llu + %u [%s]",
19855782138SLi Zefan 		  MAJOR(__entry->dev), MINOR(__entry->dev),
19955782138SLi Zefan 		  __entry->rwbs, __entry->bytes, __get_str(cmd),
2006556d1dfSSteven Rostedt 		  (unsigned long long)__entry->sector,
2016556d1dfSSteven Rostedt 		  __entry->nr_sector, __entry->comm)
20255782138SLi Zefan );
20355782138SLi Zefan 
204881245dcSWilliam Cohen /**
205881245dcSWilliam Cohen  * block_rq_insert - insert block operation request into queue
206881245dcSWilliam Cohen  * @rq: block IO operation request
207881245dcSWilliam Cohen  *
208881245dcSWilliam Cohen  * Called immediately before block operation request @rq is inserted
209881245dcSWilliam Cohen  * into queue @q.  The fields in the operation request @rq struct can
210881245dcSWilliam Cohen  * be examined to determine which device and sectors the pending
211881245dcSWilliam Cohen  * operation would access.
212881245dcSWilliam Cohen  */
21377ca1e02SLi Zefan DEFINE_EVENT(block_rq, block_rq_insert,
21455782138SLi Zefan 
215a54895faSChristoph Hellwig 	TP_PROTO(struct request *rq),
21655782138SLi Zefan 
217a54895faSChristoph Hellwig 	TP_ARGS(rq)
21855782138SLi Zefan );
21955782138SLi Zefan 
220881245dcSWilliam Cohen /**
221881245dcSWilliam Cohen  * block_rq_issue - issue pending block IO request operation to device driver
222c7ff6519SChaitanya Kulkarni  * @rq: block IO operation request
223881245dcSWilliam Cohen  *
224881245dcSWilliam Cohen  * Called when block operation request @rq from queue @q is sent to a
225881245dcSWilliam Cohen  * device driver for processing.
226881245dcSWilliam Cohen  */
22777ca1e02SLi Zefan DEFINE_EVENT(block_rq, block_rq_issue,
22855782138SLi Zefan 
229a54895faSChristoph Hellwig 	TP_PROTO(struct request *rq),
23055782138SLi Zefan 
231a54895faSChristoph Hellwig 	TP_ARGS(rq)
23255782138SLi Zefan );
233fe63b94aSCarsten Emde 
234881245dcSWilliam Cohen /**
235f3bdc62fSJan Kara  * block_rq_merge - merge request with another one in the elevator
236b0719245SChaitanya Kulkarni  * @rq: block IO operation request
237f3bdc62fSJan Kara  *
238f3bdc62fSJan Kara  * Called when block operation request @rq from queue @q is merged to another
239f3bdc62fSJan Kara  * request queued in the elevator.
240f3bdc62fSJan Kara  */
241f3bdc62fSJan Kara DEFINE_EVENT(block_rq, block_rq_merge,
242f3bdc62fSJan Kara 
243a54895faSChristoph Hellwig 	TP_PROTO(struct request *rq),
244f3bdc62fSJan Kara 
245a54895faSChristoph Hellwig 	TP_ARGS(rq)
246f3bdc62fSJan Kara );
247f3bdc62fSJan Kara 
248f3bdc62fSJan Kara /**
249*5a80bd07SHengqi Chen  * block_io_start - insert a request for execution
250*5a80bd07SHengqi Chen  * @rq: block IO operation request
251*5a80bd07SHengqi Chen  *
252*5a80bd07SHengqi Chen  * Called when block operation request @rq is queued for execution
253*5a80bd07SHengqi Chen  */
254*5a80bd07SHengqi Chen DEFINE_EVENT(block_rq, block_io_start,
255*5a80bd07SHengqi Chen 
256*5a80bd07SHengqi Chen 	TP_PROTO(struct request *rq),
257*5a80bd07SHengqi Chen 
258*5a80bd07SHengqi Chen 	TP_ARGS(rq)
259*5a80bd07SHengqi Chen );
260*5a80bd07SHengqi Chen 
261*5a80bd07SHengqi Chen /**
262*5a80bd07SHengqi Chen  * block_io_done - block IO operation request completed
263*5a80bd07SHengqi Chen  * @rq: block IO operation request
264*5a80bd07SHengqi Chen  *
265*5a80bd07SHengqi Chen  * Called when block operation request @rq is completed
266*5a80bd07SHengqi Chen  */
267*5a80bd07SHengqi Chen DEFINE_EVENT(block_rq, block_io_done,
268*5a80bd07SHengqi Chen 
269*5a80bd07SHengqi Chen 	TP_PROTO(struct request *rq),
270*5a80bd07SHengqi Chen 
271*5a80bd07SHengqi Chen 	TP_ARGS(rq)
272*5a80bd07SHengqi Chen );
273*5a80bd07SHengqi Chen 
274*5a80bd07SHengqi Chen /**
275881245dcSWilliam Cohen  * block_bio_complete - completed all work on the block operation
2760a82a8d1SLinus Torvalds  * @q: queue holding the block operation
277881245dcSWilliam Cohen  * @bio: block operation completed
278881245dcSWilliam Cohen  *
279881245dcSWilliam Cohen  * This tracepoint indicates there is no further work to do on this
280881245dcSWilliam Cohen  * block IO operation @bio.
281881245dcSWilliam Cohen  */
28255782138SLi Zefan TRACE_EVENT(block_bio_complete,
28355782138SLi Zefan 
284d24de76aSChristoph Hellwig 	TP_PROTO(struct request_queue *q, struct bio *bio),
28555782138SLi Zefan 
286d24de76aSChristoph Hellwig 	TP_ARGS(q, bio),
28755782138SLi Zefan 
28855782138SLi Zefan 	TP_STRUCT__entry(
28955782138SLi Zefan 		__field( dev_t,		dev		)
29055782138SLi Zefan 		__field( sector_t,	sector		)
29155782138SLi Zefan 		__field( unsigned,	nr_sector	)
29255782138SLi Zefan 		__field( int,		error		)
293c09c47caSNamhyung Kim 		__array( char,		rwbs,	RWBS_LEN)
29455782138SLi Zefan 	),
29555782138SLi Zefan 
29655782138SLi Zefan 	TP_fast_assign(
29774d46992SChristoph Hellwig 		__entry->dev		= bio_dev(bio);
2984f024f37SKent Overstreet 		__entry->sector		= bio->bi_iter.bi_sector;
299aa8b57aaSKent Overstreet 		__entry->nr_sector	= bio_sectors(bio);
300d24de76aSChristoph Hellwig 		__entry->error		= blk_status_to_errno(bio->bi_status);
301179d1600SChaitanya Kulkarni 		blk_fill_rwbs(__entry->rwbs, bio->bi_opf);
30255782138SLi Zefan 	),
30355782138SLi Zefan 
30455782138SLi Zefan 	TP_printk("%d,%d %s %llu + %u [%d]",
30555782138SLi Zefan 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
3066556d1dfSSteven Rostedt 		  (unsigned long long)__entry->sector,
3076556d1dfSSteven Rostedt 		  __entry->nr_sector, __entry->error)
30855782138SLi Zefan );
30955782138SLi Zefan 
310e8a676d6SChristoph Hellwig DECLARE_EVENT_CLASS(block_bio,
31155782138SLi Zefan 
312e8a676d6SChristoph Hellwig 	TP_PROTO(struct bio *bio),
31355782138SLi Zefan 
314e8a676d6SChristoph Hellwig 	TP_ARGS(bio),
31555782138SLi Zefan 
31655782138SLi Zefan 	TP_STRUCT__entry(
31755782138SLi Zefan 		__field( dev_t,		dev			)
31855782138SLi Zefan 		__field( sector_t,	sector			)
31955782138SLi Zefan 		__field( unsigned int,	nr_sector		)
320c09c47caSNamhyung Kim 		__array( char,		rwbs,	RWBS_LEN	)
32155782138SLi Zefan 		__array( char,		comm,	TASK_COMM_LEN	)
32255782138SLi Zefan 	),
32355782138SLi Zefan 
32455782138SLi Zefan 	TP_fast_assign(
32574d46992SChristoph Hellwig 		__entry->dev		= bio_dev(bio);
3264f024f37SKent Overstreet 		__entry->sector		= bio->bi_iter.bi_sector;
327aa8b57aaSKent Overstreet 		__entry->nr_sector	= bio_sectors(bio);
328179d1600SChaitanya Kulkarni 		blk_fill_rwbs(__entry->rwbs, bio->bi_opf);
32955782138SLi Zefan 		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
33055782138SLi Zefan 	),
33155782138SLi Zefan 
33255782138SLi Zefan 	TP_printk("%d,%d %s %llu + %u [%s]",
33355782138SLi Zefan 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
3346556d1dfSSteven Rostedt 		  (unsigned long long)__entry->sector,
3356556d1dfSSteven Rostedt 		  __entry->nr_sector, __entry->comm)
33655782138SLi Zefan );
33755782138SLi Zefan 
338881245dcSWilliam Cohen /**
339e8a676d6SChristoph Hellwig  * block_bio_bounce - used bounce buffer when processing block operation
340e8a676d6SChristoph Hellwig  * @bio: block operation
341e8a676d6SChristoph Hellwig  *
342e8a676d6SChristoph Hellwig  * A bounce buffer was used to handle the block operation @bio in @q.
343e8a676d6SChristoph Hellwig  * This occurs when hardware limitations prevent a direct transfer of
344e8a676d6SChristoph Hellwig  * data between the @bio data memory area and the IO device.  Use of a
345e8a676d6SChristoph Hellwig  * bounce buffer requires extra copying of data and decreases
346e8a676d6SChristoph Hellwig  * performance.
347e8a676d6SChristoph Hellwig  */
348e8a676d6SChristoph Hellwig DEFINE_EVENT(block_bio, block_bio_bounce,
349e8a676d6SChristoph Hellwig 	TP_PROTO(struct bio *bio),
350e8a676d6SChristoph Hellwig 	TP_ARGS(bio)
351e8a676d6SChristoph Hellwig );
352e8a676d6SChristoph Hellwig 
353e8a676d6SChristoph Hellwig /**
354881245dcSWilliam Cohen  * block_bio_backmerge - merging block operation to the end of an existing operation
355881245dcSWilliam Cohen  * @bio: new block operation to merge
356881245dcSWilliam Cohen  *
357e8a676d6SChristoph Hellwig  * Merging block request @bio to the end of an existing block request.
358881245dcSWilliam Cohen  */
359e8a676d6SChristoph Hellwig DEFINE_EVENT(block_bio, block_bio_backmerge,
360e8a676d6SChristoph Hellwig 	TP_PROTO(struct bio *bio),
361e8a676d6SChristoph Hellwig 	TP_ARGS(bio)
36255782138SLi Zefan );
36355782138SLi Zefan 
364881245dcSWilliam Cohen /**
365881245dcSWilliam Cohen  * block_bio_frontmerge - merging block operation to the beginning of an existing operation
366881245dcSWilliam Cohen  * @bio: new block operation to merge
367881245dcSWilliam Cohen  *
368e8a676d6SChristoph Hellwig  * Merging block IO operation @bio to the beginning of an existing block request.
369881245dcSWilliam Cohen  */
370e8a676d6SChristoph Hellwig DEFINE_EVENT(block_bio, block_bio_frontmerge,
371e8a676d6SChristoph Hellwig 	TP_PROTO(struct bio *bio),
372e8a676d6SChristoph Hellwig 	TP_ARGS(bio)
37355782138SLi Zefan );
37455782138SLi Zefan 
375881245dcSWilliam Cohen /**
376881245dcSWilliam Cohen  * block_bio_queue - putting new block IO operation in queue
377881245dcSWilliam Cohen  * @bio: new block operation
378881245dcSWilliam Cohen  *
379881245dcSWilliam Cohen  * About to place the block IO operation @bio into queue @q.
380881245dcSWilliam Cohen  */
381e8a676d6SChristoph Hellwig DEFINE_EVENT(block_bio, block_bio_queue,
382e8a676d6SChristoph Hellwig 	TP_PROTO(struct bio *bio),
383e8a676d6SChristoph Hellwig 	TP_ARGS(bio)
38455782138SLi Zefan );
38555782138SLi Zefan 
386881245dcSWilliam Cohen /**
387881245dcSWilliam Cohen  * block_getrq - get a free request entry in queue for block IO operations
388f8e9ec16SGreg Thelen  * @bio: pending block IO operation (can be %NULL)
389881245dcSWilliam Cohen  *
390e8a676d6SChristoph Hellwig  * A request struct has been allocated to handle the block IO operation @bio.
391881245dcSWilliam Cohen  */
392e8a676d6SChristoph Hellwig DEFINE_EVENT(block_bio, block_getrq,
393e8a676d6SChristoph Hellwig 	TP_PROTO(struct bio *bio),
394e8a676d6SChristoph Hellwig 	TP_ARGS(bio)
39577ca1e02SLi Zefan );
39655782138SLi Zefan 
397881245dcSWilliam Cohen /**
398881245dcSWilliam Cohen  * block_plug - keep operations requests in request queue
399881245dcSWilliam Cohen  * @q: request queue to plug
400881245dcSWilliam Cohen  *
401881245dcSWilliam Cohen  * Plug the request queue @q.  Do not allow block operation requests
402881245dcSWilliam Cohen  * to be sent to the device driver. Instead, accumulate requests in
403881245dcSWilliam Cohen  * the queue to improve throughput performance of the block device.
404881245dcSWilliam Cohen  */
40555782138SLi Zefan TRACE_EVENT(block_plug,
40655782138SLi Zefan 
40755782138SLi Zefan 	TP_PROTO(struct request_queue *q),
40855782138SLi Zefan 
40955782138SLi Zefan 	TP_ARGS(q),
41055782138SLi Zefan 
41155782138SLi Zefan 	TP_STRUCT__entry(
41255782138SLi Zefan 		__array( char,		comm,	TASK_COMM_LEN	)
41355782138SLi Zefan 	),
41455782138SLi Zefan 
41555782138SLi Zefan 	TP_fast_assign(
41655782138SLi Zefan 		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
41755782138SLi Zefan 	),
41855782138SLi Zefan 
41955782138SLi Zefan 	TP_printk("[%s]", __entry->comm)
42055782138SLi Zefan );
42155782138SLi Zefan 
42277ca1e02SLi Zefan DECLARE_EVENT_CLASS(block_unplug,
42355782138SLi Zefan 
42449cac01eSJens Axboe 	TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit),
42555782138SLi Zefan 
42649cac01eSJens Axboe 	TP_ARGS(q, depth, explicit),
42755782138SLi Zefan 
42855782138SLi Zefan 	TP_STRUCT__entry(
42955782138SLi Zefan 		__field( int,		nr_rq			)
43055782138SLi Zefan 		__array( char,		comm,	TASK_COMM_LEN	)
43155782138SLi Zefan 	),
43255782138SLi Zefan 
43355782138SLi Zefan 	TP_fast_assign(
43494b5eb28SJens Axboe 		__entry->nr_rq = depth;
43555782138SLi Zefan 		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
43655782138SLi Zefan 	),
43755782138SLi Zefan 
43855782138SLi Zefan 	TP_printk("[%s] %d", __entry->comm, __entry->nr_rq)
43955782138SLi Zefan );
44055782138SLi Zefan 
441881245dcSWilliam Cohen /**
44249cac01eSJens Axboe  * block_unplug - release of operations requests in request queue
443881245dcSWilliam Cohen  * @q: request queue to unplug
44494b5eb28SJens Axboe  * @depth: number of requests just added to the queue
44549cac01eSJens Axboe  * @explicit: whether this was an explicit unplug, or one from schedule()
446881245dcSWilliam Cohen  *
447881245dcSWilliam Cohen  * Unplug request queue @q because device driver is scheduled to work
448881245dcSWilliam Cohen  * on elements in the request queue.
449881245dcSWilliam Cohen  */
45049cac01eSJens Axboe DEFINE_EVENT(block_unplug, block_unplug,
45155782138SLi Zefan 
45249cac01eSJens Axboe 	TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit),
45355782138SLi Zefan 
45449cac01eSJens Axboe 	TP_ARGS(q, depth, explicit)
45555782138SLi Zefan );
45655782138SLi Zefan 
457881245dcSWilliam Cohen /**
458881245dcSWilliam Cohen  * block_split - split a single bio struct into two bio structs
459881245dcSWilliam Cohen  * @bio: block operation being split
460881245dcSWilliam Cohen  * @new_sector: The starting sector for the new bio
461881245dcSWilliam Cohen  *
462eb6f7f7cSChristoph Hellwig  * The bio request @bio needs to be split into two bio requests.  The newly
463eb6f7f7cSChristoph Hellwig  * created @bio request starts at @new_sector. This split may be required due to
464eb6f7f7cSChristoph Hellwig  * hardware limitations such as operation crossing device boundaries in a RAID
465eb6f7f7cSChristoph Hellwig  * system.
466881245dcSWilliam Cohen  */
46755782138SLi Zefan TRACE_EVENT(block_split,
46855782138SLi Zefan 
469eb6f7f7cSChristoph Hellwig 	TP_PROTO(struct bio *bio, unsigned int new_sector),
47055782138SLi Zefan 
471eb6f7f7cSChristoph Hellwig 	TP_ARGS(bio, new_sector),
47255782138SLi Zefan 
47355782138SLi Zefan 	TP_STRUCT__entry(
47455782138SLi Zefan 		__field( dev_t,		dev				)
47555782138SLi Zefan 		__field( sector_t,	sector				)
47655782138SLi Zefan 		__field( sector_t,	new_sector			)
477c09c47caSNamhyung Kim 		__array( char,		rwbs,		RWBS_LEN	)
47855782138SLi Zefan 		__array( char,		comm,		TASK_COMM_LEN	)
47955782138SLi Zefan 	),
48055782138SLi Zefan 
48155782138SLi Zefan 	TP_fast_assign(
48274d46992SChristoph Hellwig 		__entry->dev		= bio_dev(bio);
4834f024f37SKent Overstreet 		__entry->sector		= bio->bi_iter.bi_sector;
48455782138SLi Zefan 		__entry->new_sector	= new_sector;
485179d1600SChaitanya Kulkarni 		blk_fill_rwbs(__entry->rwbs, bio->bi_opf);
48655782138SLi Zefan 		memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
48755782138SLi Zefan 	),
48855782138SLi Zefan 
48955782138SLi Zefan 	TP_printk("%d,%d %s %llu / %llu [%s]",
49055782138SLi Zefan 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
4916556d1dfSSteven Rostedt 		  (unsigned long long)__entry->sector,
4926556d1dfSSteven Rostedt 		  (unsigned long long)__entry->new_sector,
4936556d1dfSSteven Rostedt 		  __entry->comm)
49455782138SLi Zefan );
49555782138SLi Zefan 
496881245dcSWilliam Cohen /**
497d07335e5SMike Snitzer  * block_bio_remap - map request for a logical device to the raw device
498881245dcSWilliam Cohen  * @bio: revised operation
4991c02fca6SChristoph Hellwig  * @dev: original device for the operation
500881245dcSWilliam Cohen  * @from: original sector for the operation
501881245dcSWilliam Cohen  *
502d07335e5SMike Snitzer  * An operation for a logical device has been mapped to the
503881245dcSWilliam Cohen  * raw block device.
504881245dcSWilliam Cohen  */
505d07335e5SMike Snitzer TRACE_EVENT(block_bio_remap,
50655782138SLi Zefan 
5071c02fca6SChristoph Hellwig 	TP_PROTO(struct bio *bio, dev_t dev, sector_t from),
50855782138SLi Zefan 
5091c02fca6SChristoph Hellwig 	TP_ARGS(bio, dev, from),
51055782138SLi Zefan 
51155782138SLi Zefan 	TP_STRUCT__entry(
51255782138SLi Zefan 		__field( dev_t,		dev		)
51355782138SLi Zefan 		__field( sector_t,	sector		)
51455782138SLi Zefan 		__field( unsigned int,	nr_sector	)
51555782138SLi Zefan 		__field( dev_t,		old_dev		)
51655782138SLi Zefan 		__field( sector_t,	old_sector	)
517c09c47caSNamhyung Kim 		__array( char,		rwbs,	RWBS_LEN)
51855782138SLi Zefan 	),
51955782138SLi Zefan 
52055782138SLi Zefan 	TP_fast_assign(
52174d46992SChristoph Hellwig 		__entry->dev		= bio_dev(bio);
5224f024f37SKent Overstreet 		__entry->sector		= bio->bi_iter.bi_sector;
523aa8b57aaSKent Overstreet 		__entry->nr_sector	= bio_sectors(bio);
52455782138SLi Zefan 		__entry->old_dev	= dev;
52555782138SLi Zefan 		__entry->old_sector	= from;
526179d1600SChaitanya Kulkarni 		blk_fill_rwbs(__entry->rwbs, bio->bi_opf);
52755782138SLi Zefan 	),
52855782138SLi Zefan 
52955782138SLi Zefan 	TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
53055782138SLi Zefan 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
5316556d1dfSSteven Rostedt 		  (unsigned long long)__entry->sector,
5326556d1dfSSteven Rostedt 		  __entry->nr_sector,
53355782138SLi Zefan 		  MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
5346556d1dfSSteven Rostedt 		  (unsigned long long)__entry->old_sector)
53555782138SLi Zefan );
53655782138SLi Zefan 
537881245dcSWilliam Cohen /**
538881245dcSWilliam Cohen  * block_rq_remap - map request for a block operation request
539881245dcSWilliam Cohen  * @rq: block IO operation request
540881245dcSWilliam Cohen  * @dev: device for the operation
541881245dcSWilliam Cohen  * @from: original sector for the operation
542881245dcSWilliam Cohen  *
543881245dcSWilliam Cohen  * The block operation request @rq in @q has been remapped.  The block
544881245dcSWilliam Cohen  * operation request @rq holds the current information and @from hold
545881245dcSWilliam Cohen  * the original sector.
546881245dcSWilliam Cohen  */
547b0da3f0dSJun'ichi Nomura TRACE_EVENT(block_rq_remap,
548b0da3f0dSJun'ichi Nomura 
549a54895faSChristoph Hellwig 	TP_PROTO(struct request *rq, dev_t dev, sector_t from),
550b0da3f0dSJun'ichi Nomura 
551a54895faSChristoph Hellwig 	TP_ARGS(rq, dev, from),
552b0da3f0dSJun'ichi Nomura 
553b0da3f0dSJun'ichi Nomura 	TP_STRUCT__entry(
554b0da3f0dSJun'ichi Nomura 		__field( dev_t,		dev		)
555b0da3f0dSJun'ichi Nomura 		__field( sector_t,	sector		)
556b0da3f0dSJun'ichi Nomura 		__field( unsigned int,	nr_sector	)
557b0da3f0dSJun'ichi Nomura 		__field( dev_t,		old_dev		)
558b0da3f0dSJun'ichi Nomura 		__field( sector_t,	old_sector	)
55975afb352SJun'ichi Nomura 		__field( unsigned int,	nr_bios		)
560c09c47caSNamhyung Kim 		__array( char,		rwbs,	RWBS_LEN)
561b0da3f0dSJun'ichi Nomura 	),
562b0da3f0dSJun'ichi Nomura 
563b0da3f0dSJun'ichi Nomura 	TP_fast_assign(
564f3fa33acSChristoph Hellwig 		__entry->dev		= disk_devt(rq->q->disk);
565b0da3f0dSJun'ichi Nomura 		__entry->sector		= blk_rq_pos(rq);
566b0da3f0dSJun'ichi Nomura 		__entry->nr_sector	= blk_rq_sectors(rq);
567b0da3f0dSJun'ichi Nomura 		__entry->old_dev	= dev;
568b0da3f0dSJun'ichi Nomura 		__entry->old_sector	= from;
56975afb352SJun'ichi Nomura 		__entry->nr_bios	= blk_rq_count_bios(rq);
570179d1600SChaitanya Kulkarni 		blk_fill_rwbs(__entry->rwbs, rq->cmd_flags);
571b0da3f0dSJun'ichi Nomura 	),
572b0da3f0dSJun'ichi Nomura 
57375afb352SJun'ichi Nomura 	TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu %u",
574b0da3f0dSJun'ichi Nomura 		  MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
575b0da3f0dSJun'ichi Nomura 		  (unsigned long long)__entry->sector,
576b0da3f0dSJun'ichi Nomura 		  __entry->nr_sector,
577b0da3f0dSJun'ichi Nomura 		  MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
57875afb352SJun'ichi Nomura 		  (unsigned long long)__entry->old_sector, __entry->nr_bios)
579b0da3f0dSJun'ichi Nomura );
580b0da3f0dSJun'ichi Nomura 
58155782138SLi Zefan #endif /* _TRACE_BLOCK_H */
58255782138SLi Zefan 
58355782138SLi Zefan /* This part must be outside protection */
58455782138SLi Zefan #include <trace/define_trace.h>
58555782138SLi Zefan 
586