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 /** 215f3bdc62fSJan Kara * block_rq_merge - merge request with another one in the elevator 216f3bdc62fSJan Kara * @q: queue holding operation 217f3bdc62fSJan Kara * @rq: block IO operation operation request 218f3bdc62fSJan Kara * 219f3bdc62fSJan Kara * Called when block operation request @rq from queue @q is merged to another 220f3bdc62fSJan Kara * request queued in the elevator. 221f3bdc62fSJan Kara */ 222f3bdc62fSJan Kara DEFINE_EVENT(block_rq, block_rq_merge, 223f3bdc62fSJan Kara 224f3bdc62fSJan Kara TP_PROTO(struct request_queue *q, struct request *rq), 225f3bdc62fSJan Kara 226f3bdc62fSJan Kara TP_ARGS(q, rq) 227f3bdc62fSJan Kara ); 228f3bdc62fSJan Kara 229f3bdc62fSJan Kara /** 230881245dcSWilliam Cohen * block_bio_complete - completed all work on the block operation 2310a82a8d1SLinus Torvalds * @q: queue holding the block operation 232881245dcSWilliam Cohen * @bio: block operation completed 233881245dcSWilliam Cohen * 234881245dcSWilliam Cohen * This tracepoint indicates there is no further work to do on this 235881245dcSWilliam Cohen * block IO operation @bio. 236881245dcSWilliam Cohen */ 23755782138SLi Zefan TRACE_EVENT(block_bio_complete, 23855782138SLi Zefan 239d24de76aSChristoph Hellwig TP_PROTO(struct request_queue *q, struct bio *bio), 24055782138SLi Zefan 241d24de76aSChristoph Hellwig TP_ARGS(q, bio), 24255782138SLi Zefan 24355782138SLi Zefan TP_STRUCT__entry( 24455782138SLi Zefan __field( dev_t, dev ) 24555782138SLi Zefan __field( sector_t, sector ) 24655782138SLi Zefan __field( unsigned, nr_sector ) 24755782138SLi Zefan __field( int, error ) 248c09c47caSNamhyung Kim __array( char, rwbs, RWBS_LEN) 24955782138SLi Zefan ), 25055782138SLi Zefan 25155782138SLi Zefan TP_fast_assign( 25274d46992SChristoph Hellwig __entry->dev = bio_dev(bio); 2534f024f37SKent Overstreet __entry->sector = bio->bi_iter.bi_sector; 254aa8b57aaSKent Overstreet __entry->nr_sector = bio_sectors(bio); 255d24de76aSChristoph Hellwig __entry->error = blk_status_to_errno(bio->bi_status); 256ef295ecfSChristoph Hellwig blk_fill_rwbs(__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size); 25755782138SLi Zefan ), 25855782138SLi Zefan 25955782138SLi Zefan TP_printk("%d,%d %s %llu + %u [%d]", 26055782138SLi Zefan MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, 2616556d1dfSSteven Rostedt (unsigned long long)__entry->sector, 2626556d1dfSSteven Rostedt __entry->nr_sector, __entry->error) 26355782138SLi Zefan ); 26455782138SLi Zefan 265e8a676d6SChristoph Hellwig DECLARE_EVENT_CLASS(block_bio, 26655782138SLi Zefan 267e8a676d6SChristoph Hellwig TP_PROTO(struct bio *bio), 26855782138SLi Zefan 269e8a676d6SChristoph Hellwig TP_ARGS(bio), 27055782138SLi Zefan 27155782138SLi Zefan TP_STRUCT__entry( 27255782138SLi Zefan __field( dev_t, dev ) 27355782138SLi Zefan __field( sector_t, sector ) 27455782138SLi Zefan __field( unsigned int, nr_sector ) 275c09c47caSNamhyung Kim __array( char, rwbs, RWBS_LEN ) 27655782138SLi Zefan __array( char, comm, TASK_COMM_LEN ) 27755782138SLi Zefan ), 27855782138SLi Zefan 27955782138SLi Zefan TP_fast_assign( 28074d46992SChristoph Hellwig __entry->dev = bio_dev(bio); 2814f024f37SKent Overstreet __entry->sector = bio->bi_iter.bi_sector; 282aa8b57aaSKent Overstreet __entry->nr_sector = bio_sectors(bio); 283ef295ecfSChristoph Hellwig blk_fill_rwbs(__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size); 28455782138SLi Zefan memcpy(__entry->comm, current->comm, TASK_COMM_LEN); 28555782138SLi Zefan ), 28655782138SLi Zefan 28755782138SLi Zefan TP_printk("%d,%d %s %llu + %u [%s]", 28855782138SLi Zefan MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, 2896556d1dfSSteven Rostedt (unsigned long long)__entry->sector, 2906556d1dfSSteven Rostedt __entry->nr_sector, __entry->comm) 29155782138SLi Zefan ); 29255782138SLi Zefan 293881245dcSWilliam Cohen /** 294e8a676d6SChristoph Hellwig * block_bio_bounce - used bounce buffer when processing block operation 295e8a676d6SChristoph Hellwig * @bio: block operation 296e8a676d6SChristoph Hellwig * 297e8a676d6SChristoph Hellwig * A bounce buffer was used to handle the block operation @bio in @q. 298e8a676d6SChristoph Hellwig * This occurs when hardware limitations prevent a direct transfer of 299e8a676d6SChristoph Hellwig * data between the @bio data memory area and the IO device. Use of a 300e8a676d6SChristoph Hellwig * bounce buffer requires extra copying of data and decreases 301e8a676d6SChristoph Hellwig * performance. 302e8a676d6SChristoph Hellwig */ 303e8a676d6SChristoph Hellwig DEFINE_EVENT(block_bio, block_bio_bounce, 304e8a676d6SChristoph Hellwig TP_PROTO(struct bio *bio), 305e8a676d6SChristoph Hellwig TP_ARGS(bio) 306e8a676d6SChristoph Hellwig ); 307e8a676d6SChristoph Hellwig 308e8a676d6SChristoph Hellwig /** 309881245dcSWilliam Cohen * block_bio_backmerge - merging block operation to the end of an existing operation 310881245dcSWilliam Cohen * @bio: new block operation to merge 311881245dcSWilliam Cohen * 312e8a676d6SChristoph Hellwig * Merging block request @bio to the end of an existing block request. 313881245dcSWilliam Cohen */ 314e8a676d6SChristoph Hellwig DEFINE_EVENT(block_bio, block_bio_backmerge, 315e8a676d6SChristoph Hellwig TP_PROTO(struct bio *bio), 316e8a676d6SChristoph Hellwig TP_ARGS(bio) 31755782138SLi Zefan ); 31855782138SLi Zefan 319881245dcSWilliam Cohen /** 320881245dcSWilliam Cohen * block_bio_frontmerge - merging block operation to the beginning of an existing operation 321881245dcSWilliam Cohen * @bio: new block operation to merge 322881245dcSWilliam Cohen * 323e8a676d6SChristoph Hellwig * Merging block IO operation @bio to the beginning of an existing block request. 324881245dcSWilliam Cohen */ 325e8a676d6SChristoph Hellwig DEFINE_EVENT(block_bio, block_bio_frontmerge, 326e8a676d6SChristoph Hellwig TP_PROTO(struct bio *bio), 327e8a676d6SChristoph Hellwig TP_ARGS(bio) 32855782138SLi Zefan ); 32955782138SLi Zefan 330881245dcSWilliam Cohen /** 331881245dcSWilliam Cohen * block_bio_queue - putting new block IO operation in queue 332881245dcSWilliam Cohen * @bio: new block operation 333881245dcSWilliam Cohen * 334881245dcSWilliam Cohen * About to place the block IO operation @bio into queue @q. 335881245dcSWilliam Cohen */ 336e8a676d6SChristoph Hellwig DEFINE_EVENT(block_bio, block_bio_queue, 337e8a676d6SChristoph Hellwig TP_PROTO(struct bio *bio), 338e8a676d6SChristoph Hellwig TP_ARGS(bio) 33955782138SLi Zefan ); 34055782138SLi Zefan 341881245dcSWilliam Cohen /** 342881245dcSWilliam Cohen * block_getrq - get a free request entry in queue for block IO operations 343f8e9ec16SGreg Thelen * @bio: pending block IO operation (can be %NULL) 344881245dcSWilliam Cohen * 345e8a676d6SChristoph Hellwig * A request struct has been allocated to handle the block IO operation @bio. 346881245dcSWilliam Cohen */ 347e8a676d6SChristoph Hellwig DEFINE_EVENT(block_bio, block_getrq, 348e8a676d6SChristoph Hellwig TP_PROTO(struct bio *bio), 349e8a676d6SChristoph Hellwig TP_ARGS(bio) 35077ca1e02SLi Zefan ); 35155782138SLi Zefan 352881245dcSWilliam Cohen /** 353881245dcSWilliam Cohen * block_plug - keep operations requests in request queue 354881245dcSWilliam Cohen * @q: request queue to plug 355881245dcSWilliam Cohen * 356881245dcSWilliam Cohen * Plug the request queue @q. Do not allow block operation requests 357881245dcSWilliam Cohen * to be sent to the device driver. Instead, accumulate requests in 358881245dcSWilliam Cohen * the queue to improve throughput performance of the block device. 359881245dcSWilliam Cohen */ 36055782138SLi Zefan TRACE_EVENT(block_plug, 36155782138SLi Zefan 36255782138SLi Zefan TP_PROTO(struct request_queue *q), 36355782138SLi Zefan 36455782138SLi Zefan TP_ARGS(q), 36555782138SLi Zefan 36655782138SLi Zefan TP_STRUCT__entry( 36755782138SLi Zefan __array( char, comm, TASK_COMM_LEN ) 36855782138SLi Zefan ), 36955782138SLi Zefan 37055782138SLi Zefan TP_fast_assign( 37155782138SLi Zefan memcpy(__entry->comm, current->comm, TASK_COMM_LEN); 37255782138SLi Zefan ), 37355782138SLi Zefan 37455782138SLi Zefan TP_printk("[%s]", __entry->comm) 37555782138SLi Zefan ); 37655782138SLi Zefan 37777ca1e02SLi Zefan DECLARE_EVENT_CLASS(block_unplug, 37855782138SLi Zefan 37949cac01eSJens Axboe TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit), 38055782138SLi Zefan 38149cac01eSJens Axboe TP_ARGS(q, depth, explicit), 38255782138SLi Zefan 38355782138SLi Zefan TP_STRUCT__entry( 38455782138SLi Zefan __field( int, nr_rq ) 38555782138SLi Zefan __array( char, comm, TASK_COMM_LEN ) 38655782138SLi Zefan ), 38755782138SLi Zefan 38855782138SLi Zefan TP_fast_assign( 38994b5eb28SJens Axboe __entry->nr_rq = depth; 39055782138SLi Zefan memcpy(__entry->comm, current->comm, TASK_COMM_LEN); 39155782138SLi Zefan ), 39255782138SLi Zefan 39355782138SLi Zefan TP_printk("[%s] %d", __entry->comm, __entry->nr_rq) 39455782138SLi Zefan ); 39555782138SLi Zefan 396881245dcSWilliam Cohen /** 39749cac01eSJens Axboe * block_unplug - release of operations requests in request queue 398881245dcSWilliam Cohen * @q: request queue to unplug 39994b5eb28SJens Axboe * @depth: number of requests just added to the queue 40049cac01eSJens Axboe * @explicit: whether this was an explicit unplug, or one from schedule() 401881245dcSWilliam Cohen * 402881245dcSWilliam Cohen * Unplug request queue @q because device driver is scheduled to work 403881245dcSWilliam Cohen * on elements in the request queue. 404881245dcSWilliam Cohen */ 40549cac01eSJens Axboe DEFINE_EVENT(block_unplug, block_unplug, 40655782138SLi Zefan 40749cac01eSJens Axboe TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit), 40855782138SLi Zefan 40949cac01eSJens Axboe TP_ARGS(q, depth, explicit) 41055782138SLi Zefan ); 41155782138SLi Zefan 412881245dcSWilliam Cohen /** 413881245dcSWilliam Cohen * block_split - split a single bio struct into two bio structs 414881245dcSWilliam Cohen * @bio: block operation being split 415881245dcSWilliam Cohen * @new_sector: The starting sector for the new bio 416881245dcSWilliam Cohen * 417*eb6f7f7cSChristoph Hellwig * The bio request @bio needs to be split into two bio requests. The newly 418*eb6f7f7cSChristoph Hellwig * created @bio request starts at @new_sector. This split may be required due to 419*eb6f7f7cSChristoph Hellwig * hardware limitations such as operation crossing device boundaries in a RAID 420*eb6f7f7cSChristoph Hellwig * system. 421881245dcSWilliam Cohen */ 42255782138SLi Zefan TRACE_EVENT(block_split, 42355782138SLi Zefan 424*eb6f7f7cSChristoph Hellwig TP_PROTO(struct bio *bio, unsigned int new_sector), 42555782138SLi Zefan 426*eb6f7f7cSChristoph Hellwig TP_ARGS(bio, new_sector), 42755782138SLi Zefan 42855782138SLi Zefan TP_STRUCT__entry( 42955782138SLi Zefan __field( dev_t, dev ) 43055782138SLi Zefan __field( sector_t, sector ) 43155782138SLi Zefan __field( sector_t, new_sector ) 432c09c47caSNamhyung Kim __array( char, rwbs, RWBS_LEN ) 43355782138SLi Zefan __array( char, comm, TASK_COMM_LEN ) 43455782138SLi Zefan ), 43555782138SLi Zefan 43655782138SLi Zefan TP_fast_assign( 43774d46992SChristoph Hellwig __entry->dev = bio_dev(bio); 4384f024f37SKent Overstreet __entry->sector = bio->bi_iter.bi_sector; 43955782138SLi Zefan __entry->new_sector = new_sector; 440ef295ecfSChristoph Hellwig blk_fill_rwbs(__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size); 44155782138SLi Zefan memcpy(__entry->comm, current->comm, TASK_COMM_LEN); 44255782138SLi Zefan ), 44355782138SLi Zefan 44455782138SLi Zefan TP_printk("%d,%d %s %llu / %llu [%s]", 44555782138SLi Zefan MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, 4466556d1dfSSteven Rostedt (unsigned long long)__entry->sector, 4476556d1dfSSteven Rostedt (unsigned long long)__entry->new_sector, 4486556d1dfSSteven Rostedt __entry->comm) 44955782138SLi Zefan ); 45055782138SLi Zefan 451881245dcSWilliam Cohen /** 452d07335e5SMike Snitzer * block_bio_remap - map request for a logical device to the raw device 453881245dcSWilliam Cohen * @q: queue holding the operation 454881245dcSWilliam Cohen * @bio: revised operation 455881245dcSWilliam Cohen * @dev: device for the operation 456881245dcSWilliam Cohen * @from: original sector for the operation 457881245dcSWilliam Cohen * 458d07335e5SMike Snitzer * An operation for a logical device has been mapped to the 459881245dcSWilliam Cohen * raw block device. 460881245dcSWilliam Cohen */ 461d07335e5SMike Snitzer TRACE_EVENT(block_bio_remap, 46255782138SLi Zefan 46355782138SLi Zefan TP_PROTO(struct request_queue *q, struct bio *bio, dev_t dev, 46455782138SLi Zefan sector_t from), 46555782138SLi Zefan 46655782138SLi Zefan TP_ARGS(q, bio, dev, from), 46755782138SLi Zefan 46855782138SLi Zefan TP_STRUCT__entry( 46955782138SLi Zefan __field( dev_t, dev ) 47055782138SLi Zefan __field( sector_t, sector ) 47155782138SLi Zefan __field( unsigned int, nr_sector ) 47255782138SLi Zefan __field( dev_t, old_dev ) 47355782138SLi Zefan __field( sector_t, old_sector ) 474c09c47caSNamhyung Kim __array( char, rwbs, RWBS_LEN) 47555782138SLi Zefan ), 47655782138SLi Zefan 47755782138SLi Zefan TP_fast_assign( 47874d46992SChristoph Hellwig __entry->dev = bio_dev(bio); 4794f024f37SKent Overstreet __entry->sector = bio->bi_iter.bi_sector; 480aa8b57aaSKent Overstreet __entry->nr_sector = bio_sectors(bio); 48155782138SLi Zefan __entry->old_dev = dev; 48255782138SLi Zefan __entry->old_sector = from; 483ef295ecfSChristoph Hellwig blk_fill_rwbs(__entry->rwbs, bio->bi_opf, bio->bi_iter.bi_size); 48455782138SLi Zefan ), 48555782138SLi Zefan 48655782138SLi Zefan TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu", 48755782138SLi Zefan MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, 4886556d1dfSSteven Rostedt (unsigned long long)__entry->sector, 4896556d1dfSSteven Rostedt __entry->nr_sector, 49055782138SLi Zefan MAJOR(__entry->old_dev), MINOR(__entry->old_dev), 4916556d1dfSSteven Rostedt (unsigned long long)__entry->old_sector) 49255782138SLi Zefan ); 49355782138SLi Zefan 494881245dcSWilliam Cohen /** 495881245dcSWilliam Cohen * block_rq_remap - map request for a block operation request 496881245dcSWilliam Cohen * @q: queue holding the operation 497881245dcSWilliam Cohen * @rq: block IO operation request 498881245dcSWilliam Cohen * @dev: device for the operation 499881245dcSWilliam Cohen * @from: original sector for the operation 500881245dcSWilliam Cohen * 501881245dcSWilliam Cohen * The block operation request @rq in @q has been remapped. The block 502881245dcSWilliam Cohen * operation request @rq holds the current information and @from hold 503881245dcSWilliam Cohen * the original sector. 504881245dcSWilliam Cohen */ 505b0da3f0dSJun'ichi Nomura TRACE_EVENT(block_rq_remap, 506b0da3f0dSJun'ichi Nomura 507b0da3f0dSJun'ichi Nomura TP_PROTO(struct request_queue *q, struct request *rq, dev_t dev, 508b0da3f0dSJun'ichi Nomura sector_t from), 509b0da3f0dSJun'ichi Nomura 510b0da3f0dSJun'ichi Nomura TP_ARGS(q, rq, dev, from), 511b0da3f0dSJun'ichi Nomura 512b0da3f0dSJun'ichi Nomura TP_STRUCT__entry( 513b0da3f0dSJun'ichi Nomura __field( dev_t, dev ) 514b0da3f0dSJun'ichi Nomura __field( sector_t, sector ) 515b0da3f0dSJun'ichi Nomura __field( unsigned int, nr_sector ) 516b0da3f0dSJun'ichi Nomura __field( dev_t, old_dev ) 517b0da3f0dSJun'ichi Nomura __field( sector_t, old_sector ) 51875afb352SJun'ichi Nomura __field( unsigned int, nr_bios ) 519c09c47caSNamhyung Kim __array( char, rwbs, RWBS_LEN) 520b0da3f0dSJun'ichi Nomura ), 521b0da3f0dSJun'ichi Nomura 522b0da3f0dSJun'ichi Nomura TP_fast_assign( 523b0da3f0dSJun'ichi Nomura __entry->dev = disk_devt(rq->rq_disk); 524b0da3f0dSJun'ichi Nomura __entry->sector = blk_rq_pos(rq); 525b0da3f0dSJun'ichi Nomura __entry->nr_sector = blk_rq_sectors(rq); 526b0da3f0dSJun'ichi Nomura __entry->old_dev = dev; 527b0da3f0dSJun'ichi Nomura __entry->old_sector = from; 52875afb352SJun'ichi Nomura __entry->nr_bios = blk_rq_count_bios(rq); 529ef295ecfSChristoph Hellwig blk_fill_rwbs(__entry->rwbs, rq->cmd_flags, blk_rq_bytes(rq)); 530b0da3f0dSJun'ichi Nomura ), 531b0da3f0dSJun'ichi Nomura 53275afb352SJun'ichi Nomura TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu %u", 533b0da3f0dSJun'ichi Nomura MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, 534b0da3f0dSJun'ichi Nomura (unsigned long long)__entry->sector, 535b0da3f0dSJun'ichi Nomura __entry->nr_sector, 536b0da3f0dSJun'ichi Nomura MAJOR(__entry->old_dev), MINOR(__entry->old_dev), 53775afb352SJun'ichi Nomura (unsigned long long)__entry->old_sector, __entry->nr_bios) 538b0da3f0dSJun'ichi Nomura ); 539b0da3f0dSJun'ichi Nomura 54055782138SLi Zefan #endif /* _TRACE_BLOCK_H */ 54155782138SLi Zefan 54255782138SLi Zefan /* This part must be outside protection */ 54355782138SLi Zefan #include <trace/define_trace.h> 54455782138SLi Zefan 545