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 * @q: queue holding operation 68cee4b7ceSChristoph Hellwig * @rq: block IO operation request 69cee4b7ceSChristoph Hellwig * 70cee4b7ceSChristoph Hellwig * The block operation request @rq is being placed back into queue 71cee4b7ceSChristoph Hellwig * @q. For some reason the request was not completed and needs to be 72cee4b7ceSChristoph Hellwig * put back in the queue. 73cee4b7ceSChristoph Hellwig */ 74cee4b7ceSChristoph Hellwig TRACE_EVENT(block_rq_requeue, 7555782138SLi Zefan 7655782138SLi Zefan TP_PROTO(struct request_queue *q, struct request *rq), 7755782138SLi Zefan 7855782138SLi Zefan TP_ARGS(q, rq), 7955782138SLi Zefan 8055782138SLi Zefan TP_STRUCT__entry( 8155782138SLi Zefan __field( dev_t, dev ) 8255782138SLi Zefan __field( sector_t, sector ) 8355782138SLi Zefan __field( unsigned int, nr_sector ) 84c09c47caSNamhyung Kim __array( char, rwbs, RWBS_LEN ) 8548b77ad6SChristoph Hellwig __dynamic_array( char, cmd, 1 ) 8655782138SLi Zefan ), 8755782138SLi Zefan 8855782138SLi Zefan TP_fast_assign( 8955782138SLi Zefan __entry->dev = rq->rq_disk ? disk_devt(rq->rq_disk) : 0; 9048b77ad6SChristoph Hellwig __entry->sector = blk_rq_trace_sector(rq); 9148b77ad6SChristoph Hellwig __entry->nr_sector = blk_rq_trace_nr_sectors(rq); 9255782138SLi Zefan 93ef295ecfSChristoph Hellwig blk_fill_rwbs(__entry->rwbs, rq->cmd_flags, blk_rq_bytes(rq)); 9448b77ad6SChristoph Hellwig __get_str(cmd)[0] = '\0'; 9555782138SLi Zefan ), 9655782138SLi Zefan 9755782138SLi Zefan TP_printk("%d,%d %s (%s) %llu + %u [%d]", 9855782138SLi Zefan MAJOR(__entry->dev), MINOR(__entry->dev), 9955782138SLi Zefan __entry->rwbs, __get_str(cmd), 1006556d1dfSSteven Rostedt (unsigned long long)__entry->sector, 101caf7df12SChristoph Hellwig __entry->nr_sector, 0) 10255782138SLi Zefan ); 10355782138SLi Zefan 104881245dcSWilliam Cohen /** 105881245dcSWilliam Cohen * block_rq_complete - block IO operation completed by device driver 106881245dcSWilliam Cohen * @rq: block operations request 107caf7df12SChristoph Hellwig * @error: status code 108af5040daSRoman Pen * @nr_bytes: number of completed bytes 109881245dcSWilliam Cohen * 110881245dcSWilliam Cohen * The block_rq_complete tracepoint event indicates that some portion 111881245dcSWilliam Cohen * of operation request has been completed by the device driver. If 112881245dcSWilliam Cohen * the @rq->bio is %NULL, then there is absolutely no additional work to 113881245dcSWilliam Cohen * do for the request. If @rq->bio is non-NULL then there is 114881245dcSWilliam Cohen * additional work required to complete the request. 115881245dcSWilliam Cohen */ 116af5040daSRoman Pen TRACE_EVENT(block_rq_complete, 11777ca1e02SLi Zefan 118caf7df12SChristoph Hellwig TP_PROTO(struct request *rq, int error, unsigned int nr_bytes), 11977ca1e02SLi Zefan 120caf7df12SChristoph Hellwig TP_ARGS(rq, error, nr_bytes), 121af5040daSRoman Pen 122af5040daSRoman Pen TP_STRUCT__entry( 123af5040daSRoman Pen __field( dev_t, dev ) 124af5040daSRoman Pen __field( sector_t, sector ) 125af5040daSRoman Pen __field( unsigned int, nr_sector ) 126caf7df12SChristoph Hellwig __field( int, error ) 127af5040daSRoman Pen __array( char, rwbs, RWBS_LEN ) 12848b77ad6SChristoph Hellwig __dynamic_array( char, cmd, 1 ) 129af5040daSRoman Pen ), 130af5040daSRoman Pen 131af5040daSRoman Pen TP_fast_assign( 132af5040daSRoman Pen __entry->dev = rq->rq_disk ? disk_devt(rq->rq_disk) : 0; 133af5040daSRoman Pen __entry->sector = blk_rq_pos(rq); 134af5040daSRoman Pen __entry->nr_sector = nr_bytes >> 9; 135caf7df12SChristoph Hellwig __entry->error = error; 136af5040daSRoman Pen 137ef295ecfSChristoph Hellwig blk_fill_rwbs(__entry->rwbs, rq->cmd_flags, nr_bytes); 13848b77ad6SChristoph Hellwig __get_str(cmd)[0] = '\0'; 139af5040daSRoman Pen ), 140af5040daSRoman Pen 141af5040daSRoman Pen TP_printk("%d,%d %s (%s) %llu + %u [%d]", 142af5040daSRoman Pen MAJOR(__entry->dev), MINOR(__entry->dev), 143af5040daSRoman Pen __entry->rwbs, __get_str(cmd), 144af5040daSRoman Pen (unsigned long long)__entry->sector, 145caf7df12SChristoph Hellwig __entry->nr_sector, __entry->error) 14677ca1e02SLi Zefan ); 14777ca1e02SLi Zefan 14877ca1e02SLi Zefan DECLARE_EVENT_CLASS(block_rq, 14955782138SLi Zefan 15055782138SLi Zefan TP_PROTO(struct request_queue *q, struct request *rq), 15155782138SLi Zefan 15255782138SLi Zefan TP_ARGS(q, rq), 15355782138SLi Zefan 15455782138SLi Zefan TP_STRUCT__entry( 15555782138SLi Zefan __field( dev_t, dev ) 15655782138SLi Zefan __field( sector_t, sector ) 15755782138SLi Zefan __field( unsigned int, nr_sector ) 15855782138SLi Zefan __field( unsigned int, bytes ) 159c09c47caSNamhyung Kim __array( char, rwbs, RWBS_LEN ) 16055782138SLi Zefan __array( char, comm, TASK_COMM_LEN ) 16148b77ad6SChristoph Hellwig __dynamic_array( char, cmd, 1 ) 16255782138SLi Zefan ), 16355782138SLi Zefan 16455782138SLi Zefan TP_fast_assign( 16555782138SLi Zefan __entry->dev = rq->rq_disk ? disk_devt(rq->rq_disk) : 0; 16648b77ad6SChristoph Hellwig __entry->sector = blk_rq_trace_sector(rq); 16748b77ad6SChristoph Hellwig __entry->nr_sector = blk_rq_trace_nr_sectors(rq); 16848b77ad6SChristoph Hellwig __entry->bytes = blk_rq_bytes(rq); 16955782138SLi Zefan 170ef295ecfSChristoph Hellwig blk_fill_rwbs(__entry->rwbs, rq->cmd_flags, blk_rq_bytes(rq)); 17148b77ad6SChristoph Hellwig __get_str(cmd)[0] = '\0'; 17255782138SLi Zefan memcpy(__entry->comm, current->comm, TASK_COMM_LEN); 17355782138SLi Zefan ), 17455782138SLi Zefan 17555782138SLi Zefan TP_printk("%d,%d %s %u (%s) %llu + %u [%s]", 17655782138SLi Zefan MAJOR(__entry->dev), MINOR(__entry->dev), 17755782138SLi Zefan __entry->rwbs, __entry->bytes, __get_str(cmd), 1786556d1dfSSteven Rostedt (unsigned long long)__entry->sector, 1796556d1dfSSteven Rostedt __entry->nr_sector, __entry->comm) 18055782138SLi Zefan ); 18155782138SLi Zefan 182881245dcSWilliam Cohen /** 183881245dcSWilliam Cohen * block_rq_insert - insert block operation request into queue 184881245dcSWilliam Cohen * @q: target queue 185881245dcSWilliam Cohen * @rq: block IO operation request 186881245dcSWilliam Cohen * 187881245dcSWilliam Cohen * Called immediately before block operation request @rq is inserted 188881245dcSWilliam Cohen * into queue @q. The fields in the operation request @rq struct can 189881245dcSWilliam Cohen * be examined to determine which device and sectors the pending 190881245dcSWilliam Cohen * operation would access. 191881245dcSWilliam Cohen */ 19277ca1e02SLi Zefan DEFINE_EVENT(block_rq, block_rq_insert, 19355782138SLi Zefan 19455782138SLi Zefan TP_PROTO(struct request_queue *q, struct request *rq), 19555782138SLi Zefan 19677ca1e02SLi Zefan TP_ARGS(q, rq) 19755782138SLi Zefan ); 19855782138SLi Zefan 199881245dcSWilliam Cohen /** 200881245dcSWilliam Cohen * block_rq_issue - issue pending block IO request operation to device driver 201881245dcSWilliam Cohen * @q: queue holding operation 202881245dcSWilliam Cohen * @rq: block IO operation operation request 203881245dcSWilliam Cohen * 204881245dcSWilliam Cohen * Called when block operation request @rq from queue @q is sent to a 205881245dcSWilliam Cohen * device driver for processing. 206881245dcSWilliam Cohen */ 20777ca1e02SLi Zefan DEFINE_EVENT(block_rq, block_rq_issue, 20855782138SLi Zefan 20955782138SLi Zefan TP_PROTO(struct request_queue *q, struct request *rq), 21055782138SLi Zefan 21177ca1e02SLi Zefan TP_ARGS(q, rq) 21255782138SLi Zefan ); 213fe63b94aSCarsten Emde 214881245dcSWilliam Cohen /** 215881245dcSWilliam Cohen * block_bio_bounce - used bounce buffer when processing block operation 216881245dcSWilliam Cohen * @q: queue holding the block operation 217881245dcSWilliam Cohen * @bio: block operation 218881245dcSWilliam Cohen * 219881245dcSWilliam Cohen * A bounce buffer was used to handle the block operation @bio in @q. 220881245dcSWilliam Cohen * This occurs when hardware limitations prevent a direct transfer of 221881245dcSWilliam Cohen * data between the @bio data memory area and the IO device. Use of a 222881245dcSWilliam Cohen * bounce buffer requires extra copying of data and decreases 223881245dcSWilliam Cohen * performance. 224881245dcSWilliam Cohen */ 22555782138SLi Zefan TRACE_EVENT(block_bio_bounce, 22655782138SLi Zefan 22755782138SLi Zefan TP_PROTO(struct request_queue *q, struct bio *bio), 22855782138SLi Zefan 22955782138SLi Zefan TP_ARGS(q, bio), 23055782138SLi Zefan 23155782138SLi Zefan TP_STRUCT__entry( 23255782138SLi Zefan __field( dev_t, dev ) 23355782138SLi Zefan __field( sector_t, sector ) 23455782138SLi Zefan __field( unsigned int, nr_sector ) 235c09c47caSNamhyung Kim __array( char, rwbs, RWBS_LEN ) 23655782138SLi Zefan __array( char, comm, TASK_COMM_LEN ) 23755782138SLi Zefan ), 23855782138SLi Zefan 23955782138SLi Zefan TP_fast_assign( 24074d46992SChristoph Hellwig __entry->dev = bio_dev(bio); 2414f024f37SKent Overstreet __entry->sector = bio->bi_iter.bi_sector; 242aa8b57aaSKent Overstreet __entry->nr_sector = bio_sectors(bio); 243ef295ecfSChristoph Hellwig blk_fill_rwbs(__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size); 24455782138SLi Zefan memcpy(__entry->comm, current->comm, TASK_COMM_LEN); 24555782138SLi Zefan ), 24655782138SLi Zefan 24755782138SLi Zefan TP_printk("%d,%d %s %llu + %u [%s]", 24855782138SLi Zefan MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, 2496556d1dfSSteven Rostedt (unsigned long long)__entry->sector, 2506556d1dfSSteven Rostedt __entry->nr_sector, __entry->comm) 25155782138SLi Zefan ); 25255782138SLi Zefan 253881245dcSWilliam Cohen /** 254881245dcSWilliam Cohen * block_bio_complete - completed all work on the block operation 2550a82a8d1SLinus Torvalds * @q: queue holding the block operation 256881245dcSWilliam Cohen * @bio: block operation completed 257b7908c10SJeff Moyer * @error: io error value 258881245dcSWilliam Cohen * 259881245dcSWilliam Cohen * This tracepoint indicates there is no further work to do on this 260881245dcSWilliam Cohen * block IO operation @bio. 261881245dcSWilliam Cohen */ 26255782138SLi Zefan TRACE_EVENT(block_bio_complete, 26355782138SLi Zefan 264*d24de76aSChristoph Hellwig TP_PROTO(struct request_queue *q, struct bio *bio), 26555782138SLi Zefan 266*d24de76aSChristoph Hellwig TP_ARGS(q, bio), 26755782138SLi Zefan 26855782138SLi Zefan TP_STRUCT__entry( 26955782138SLi Zefan __field( dev_t, dev ) 27055782138SLi Zefan __field( sector_t, sector ) 27155782138SLi Zefan __field( unsigned, nr_sector ) 27255782138SLi Zefan __field( int, error ) 273c09c47caSNamhyung Kim __array( char, rwbs, RWBS_LEN) 27455782138SLi Zefan ), 27555782138SLi Zefan 27655782138SLi Zefan TP_fast_assign( 27774d46992SChristoph Hellwig __entry->dev = bio_dev(bio); 2784f024f37SKent Overstreet __entry->sector = bio->bi_iter.bi_sector; 279aa8b57aaSKent Overstreet __entry->nr_sector = bio_sectors(bio); 280*d24de76aSChristoph Hellwig __entry->error = blk_status_to_errno(bio->bi_status); 281ef295ecfSChristoph Hellwig blk_fill_rwbs(__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size); 28255782138SLi Zefan ), 28355782138SLi Zefan 28455782138SLi Zefan TP_printk("%d,%d %s %llu + %u [%d]", 28555782138SLi Zefan MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, 2866556d1dfSSteven Rostedt (unsigned long long)__entry->sector, 2876556d1dfSSteven Rostedt __entry->nr_sector, __entry->error) 28855782138SLi Zefan ); 28955782138SLi Zefan 2908c1cf6bbSTejun Heo DECLARE_EVENT_CLASS(block_bio_merge, 29155782138SLi Zefan 2928c1cf6bbSTejun Heo TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio), 29355782138SLi Zefan 2948c1cf6bbSTejun Heo TP_ARGS(q, rq, bio), 29555782138SLi Zefan 29655782138SLi Zefan TP_STRUCT__entry( 29755782138SLi Zefan __field( dev_t, dev ) 29855782138SLi Zefan __field( sector_t, sector ) 29955782138SLi Zefan __field( unsigned int, nr_sector ) 300c09c47caSNamhyung Kim __array( char, rwbs, RWBS_LEN ) 30155782138SLi Zefan __array( char, comm, TASK_COMM_LEN ) 30255782138SLi Zefan ), 30355782138SLi Zefan 30455782138SLi Zefan TP_fast_assign( 30574d46992SChristoph Hellwig __entry->dev = bio_dev(bio); 3064f024f37SKent Overstreet __entry->sector = bio->bi_iter.bi_sector; 307aa8b57aaSKent Overstreet __entry->nr_sector = bio_sectors(bio); 308ef295ecfSChristoph Hellwig blk_fill_rwbs(__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size); 30955782138SLi Zefan memcpy(__entry->comm, current->comm, TASK_COMM_LEN); 31055782138SLi Zefan ), 31155782138SLi Zefan 31255782138SLi Zefan TP_printk("%d,%d %s %llu + %u [%s]", 31355782138SLi Zefan MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, 3146556d1dfSSteven Rostedt (unsigned long long)__entry->sector, 3156556d1dfSSteven Rostedt __entry->nr_sector, __entry->comm) 31655782138SLi Zefan ); 31755782138SLi Zefan 318881245dcSWilliam Cohen /** 319881245dcSWilliam Cohen * block_bio_backmerge - merging block operation to the end of an existing operation 320881245dcSWilliam Cohen * @q: queue holding operation 3218c1cf6bbSTejun Heo * @rq: request bio is being merged into 322881245dcSWilliam Cohen * @bio: new block operation to merge 323881245dcSWilliam Cohen * 324881245dcSWilliam Cohen * Merging block request @bio to the end of an existing block request 325881245dcSWilliam Cohen * in queue @q. 326881245dcSWilliam Cohen */ 3278c1cf6bbSTejun Heo DEFINE_EVENT(block_bio_merge, block_bio_backmerge, 32855782138SLi Zefan 3298c1cf6bbSTejun Heo TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio), 33055782138SLi Zefan 3318c1cf6bbSTejun Heo TP_ARGS(q, rq, bio) 33255782138SLi Zefan ); 33355782138SLi Zefan 334881245dcSWilliam Cohen /** 335881245dcSWilliam Cohen * block_bio_frontmerge - merging block operation to the beginning of an existing operation 336881245dcSWilliam Cohen * @q: queue holding operation 3378c1cf6bbSTejun Heo * @rq: request bio is being merged into 338881245dcSWilliam Cohen * @bio: new block operation to merge 339881245dcSWilliam Cohen * 340881245dcSWilliam Cohen * Merging block IO operation @bio to the beginning of an existing block 341881245dcSWilliam Cohen * operation in queue @q. 342881245dcSWilliam Cohen */ 3438c1cf6bbSTejun Heo DEFINE_EVENT(block_bio_merge, block_bio_frontmerge, 34455782138SLi Zefan 3458c1cf6bbSTejun Heo TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio), 34655782138SLi Zefan 3478c1cf6bbSTejun Heo TP_ARGS(q, rq, bio) 34855782138SLi Zefan ); 34955782138SLi Zefan 350881245dcSWilliam Cohen /** 351881245dcSWilliam Cohen * block_bio_queue - putting new block IO operation in queue 352881245dcSWilliam Cohen * @q: queue holding operation 353881245dcSWilliam Cohen * @bio: new block operation 354881245dcSWilliam Cohen * 355881245dcSWilliam Cohen * About to place the block IO operation @bio into queue @q. 356881245dcSWilliam Cohen */ 3578c1cf6bbSTejun Heo TRACE_EVENT(block_bio_queue, 35877ca1e02SLi Zefan 35977ca1e02SLi Zefan TP_PROTO(struct request_queue *q, struct bio *bio), 36077ca1e02SLi Zefan 3618c1cf6bbSTejun Heo TP_ARGS(q, bio), 3628c1cf6bbSTejun Heo 3638c1cf6bbSTejun Heo TP_STRUCT__entry( 3648c1cf6bbSTejun Heo __field( dev_t, dev ) 3658c1cf6bbSTejun Heo __field( sector_t, sector ) 3668c1cf6bbSTejun Heo __field( unsigned int, nr_sector ) 3678c1cf6bbSTejun Heo __array( char, rwbs, RWBS_LEN ) 3688c1cf6bbSTejun Heo __array( char, comm, TASK_COMM_LEN ) 3698c1cf6bbSTejun Heo ), 3708c1cf6bbSTejun Heo 3718c1cf6bbSTejun Heo TP_fast_assign( 37274d46992SChristoph Hellwig __entry->dev = bio_dev(bio); 3734f024f37SKent Overstreet __entry->sector = bio->bi_iter.bi_sector; 374aa8b57aaSKent Overstreet __entry->nr_sector = bio_sectors(bio); 375ef295ecfSChristoph Hellwig blk_fill_rwbs(__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size); 3768c1cf6bbSTejun Heo memcpy(__entry->comm, current->comm, TASK_COMM_LEN); 3778c1cf6bbSTejun Heo ), 3788c1cf6bbSTejun Heo 3798c1cf6bbSTejun Heo TP_printk("%d,%d %s %llu + %u [%s]", 3808c1cf6bbSTejun Heo MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, 3818c1cf6bbSTejun Heo (unsigned long long)__entry->sector, 3828c1cf6bbSTejun Heo __entry->nr_sector, __entry->comm) 38377ca1e02SLi Zefan ); 38477ca1e02SLi Zefan 38577ca1e02SLi Zefan DECLARE_EVENT_CLASS(block_get_rq, 38655782138SLi Zefan 38755782138SLi Zefan TP_PROTO(struct request_queue *q, struct bio *bio, int rw), 38855782138SLi Zefan 38955782138SLi Zefan TP_ARGS(q, bio, rw), 39055782138SLi Zefan 39155782138SLi Zefan TP_STRUCT__entry( 39255782138SLi Zefan __field( dev_t, dev ) 39355782138SLi Zefan __field( sector_t, sector ) 39455782138SLi Zefan __field( unsigned int, nr_sector ) 395c09c47caSNamhyung Kim __array( char, rwbs, RWBS_LEN ) 39655782138SLi Zefan __array( char, comm, TASK_COMM_LEN ) 39755782138SLi Zefan ), 39855782138SLi Zefan 39955782138SLi Zefan TP_fast_assign( 40074d46992SChristoph Hellwig __entry->dev = bio ? bio_dev(bio) : 0; 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 417f8e9ec16SGreg Thelen * @bio: pending block IO operation (can be %NULL) 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 433f8e9ec16SGreg Thelen * @bio: pending block IO operation (can be %NULL) 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( 53574d46992SChristoph 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( 57674d46992SChristoph 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