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 15*925c86a1SChristoph Hellwig #ifdef CONFIG_BUFFER_HEAD 165305cb83STejun Heo DECLARE_EVENT_CLASS(block_buffer, 175305cb83STejun Heo 185305cb83STejun Heo TP_PROTO(struct buffer_head *bh), 195305cb83STejun Heo 205305cb83STejun Heo TP_ARGS(bh), 215305cb83STejun Heo 225305cb83STejun Heo TP_STRUCT__entry ( 235305cb83STejun Heo __field( dev_t, dev ) 245305cb83STejun Heo __field( sector_t, sector ) 255305cb83STejun Heo __field( size_t, size ) 265305cb83STejun Heo ), 275305cb83STejun Heo 285305cb83STejun Heo TP_fast_assign( 295305cb83STejun Heo __entry->dev = bh->b_bdev->bd_dev; 305305cb83STejun Heo __entry->sector = bh->b_blocknr; 315305cb83STejun Heo __entry->size = bh->b_size; 325305cb83STejun Heo ), 335305cb83STejun Heo 345305cb83STejun Heo TP_printk("%d,%d sector=%llu size=%zu", 355305cb83STejun Heo MAJOR(__entry->dev), MINOR(__entry->dev), 365305cb83STejun Heo (unsigned long long)__entry->sector, __entry->size 375305cb83STejun Heo ) 385305cb83STejun Heo ); 395305cb83STejun Heo 405305cb83STejun Heo /** 415305cb83STejun Heo * block_touch_buffer - mark a buffer accessed 425305cb83STejun Heo * @bh: buffer_head being touched 435305cb83STejun Heo * 445305cb83STejun Heo * Called from touch_buffer(). 455305cb83STejun Heo */ 465305cb83STejun Heo DEFINE_EVENT(block_buffer, block_touch_buffer, 475305cb83STejun Heo 485305cb83STejun Heo TP_PROTO(struct buffer_head *bh), 495305cb83STejun Heo 505305cb83STejun Heo TP_ARGS(bh) 515305cb83STejun Heo ); 525305cb83STejun Heo 535305cb83STejun Heo /** 545305cb83STejun Heo * block_dirty_buffer - mark a buffer dirty 555305cb83STejun Heo * @bh: buffer_head being dirtied 565305cb83STejun Heo * 575305cb83STejun Heo * Called from mark_buffer_dirty(). 585305cb83STejun Heo */ 595305cb83STejun Heo DEFINE_EVENT(block_buffer, block_dirty_buffer, 605305cb83STejun Heo 615305cb83STejun Heo TP_PROTO(struct buffer_head *bh), 625305cb83STejun Heo 635305cb83STejun Heo TP_ARGS(bh) 645305cb83STejun Heo ); 65*925c86a1SChristoph Hellwig #endif /* CONFIG_BUFFER_HEAD */ 665305cb83STejun Heo 67cee4b7ceSChristoph Hellwig /** 68cee4b7ceSChristoph Hellwig * block_rq_requeue - place block IO request back on a queue 69cee4b7ceSChristoph Hellwig * @rq: block IO operation request 70cee4b7ceSChristoph Hellwig * 71cee4b7ceSChristoph Hellwig * The block operation request @rq is being placed back into queue 72cee4b7ceSChristoph Hellwig * @q. For some reason the request was not completed and needs to be 73cee4b7ceSChristoph Hellwig * put back in the queue. 74cee4b7ceSChristoph Hellwig */ 75cee4b7ceSChristoph Hellwig TRACE_EVENT(block_rq_requeue, 7655782138SLi Zefan 77a54895faSChristoph Hellwig TP_PROTO(struct request *rq), 7855782138SLi Zefan 79a54895faSChristoph Hellwig TP_ARGS(rq), 8055782138SLi Zefan 8155782138SLi Zefan TP_STRUCT__entry( 8255782138SLi Zefan __field( dev_t, dev ) 8355782138SLi Zefan __field( sector_t, sector ) 8455782138SLi Zefan __field( unsigned int, nr_sector ) 85c09c47caSNamhyung Kim __array( char, rwbs, RWBS_LEN ) 8648b77ad6SChristoph Hellwig __dynamic_array( char, cmd, 1 ) 8755782138SLi Zefan ), 8855782138SLi Zefan 8955782138SLi Zefan TP_fast_assign( 90f3fa33acSChristoph Hellwig __entry->dev = rq->q->disk ? disk_devt(rq->q->disk) : 0; 9148b77ad6SChristoph Hellwig __entry->sector = blk_rq_trace_sector(rq); 9248b77ad6SChristoph Hellwig __entry->nr_sector = blk_rq_trace_nr_sectors(rq); 9355782138SLi Zefan 94179d1600SChaitanya Kulkarni blk_fill_rwbs(__entry->rwbs, rq->cmd_flags); 9548b77ad6SChristoph Hellwig __get_str(cmd)[0] = '\0'; 9655782138SLi Zefan ), 9755782138SLi Zefan 9855782138SLi Zefan TP_printk("%d,%d %s (%s) %llu + %u [%d]", 9955782138SLi Zefan MAJOR(__entry->dev), MINOR(__entry->dev), 10055782138SLi Zefan __entry->rwbs, __get_str(cmd), 1016556d1dfSSteven Rostedt (unsigned long long)__entry->sector, 102caf7df12SChristoph Hellwig __entry->nr_sector, 0) 10355782138SLi Zefan ); 10455782138SLi Zefan 105d5869fdcSYang Shi DECLARE_EVENT_CLASS(block_rq_completion, 10677ca1e02SLi Zefan 1078a7d267bSChristoph Hellwig TP_PROTO(struct request *rq, blk_status_t error, unsigned int nr_bytes), 10877ca1e02SLi Zefan 109caf7df12SChristoph Hellwig TP_ARGS(rq, error, nr_bytes), 110af5040daSRoman Pen 111af5040daSRoman Pen TP_STRUCT__entry( 112af5040daSRoman Pen __field( dev_t, dev ) 113af5040daSRoman Pen __field( sector_t, sector ) 114af5040daSRoman Pen __field( unsigned int, nr_sector ) 115caf7df12SChristoph Hellwig __field( int , error ) 116af5040daSRoman Pen __array( char, rwbs, RWBS_LEN ) 11748b77ad6SChristoph Hellwig __dynamic_array( char, cmd, 1 ) 118af5040daSRoman Pen ), 119af5040daSRoman Pen 120af5040daSRoman Pen TP_fast_assign( 121f3fa33acSChristoph Hellwig __entry->dev = rq->q->disk ? disk_devt(rq->q->disk) : 0; 122af5040daSRoman Pen __entry->sector = blk_rq_pos(rq); 123af5040daSRoman Pen __entry->nr_sector = nr_bytes >> 9; 1248a7d267bSChristoph Hellwig __entry->error = blk_status_to_errno(error); 125af5040daSRoman Pen 126179d1600SChaitanya Kulkarni blk_fill_rwbs(__entry->rwbs, rq->cmd_flags); 12748b77ad6SChristoph Hellwig __get_str(cmd)[0] = '\0'; 128af5040daSRoman Pen ), 129af5040daSRoman Pen 130af5040daSRoman Pen TP_printk("%d,%d %s (%s) %llu + %u [%d]", 131af5040daSRoman Pen MAJOR(__entry->dev), MINOR(__entry->dev), 132af5040daSRoman Pen __entry->rwbs, __get_str(cmd), 133af5040daSRoman Pen (unsigned long long)__entry->sector, 134caf7df12SChristoph Hellwig __entry->nr_sector, __entry->error) 13577ca1e02SLi Zefan ); 13677ca1e02SLi Zefan 137d5869fdcSYang Shi /** 138d5869fdcSYang Shi * block_rq_complete - block IO operation completed by device driver 139d5869fdcSYang Shi * @rq: block operations request 140d5869fdcSYang Shi * @error: status code 141d5869fdcSYang Shi * @nr_bytes: number of completed bytes 142d5869fdcSYang Shi * 143d5869fdcSYang Shi * The block_rq_complete tracepoint event indicates that some portion 144d5869fdcSYang Shi * of operation request has been completed by the device driver. If 145d5869fdcSYang Shi * the @rq->bio is %NULL, then there is absolutely no additional work to 146d5869fdcSYang Shi * do for the request. If @rq->bio is non-NULL then there is 147d5869fdcSYang Shi * additional work required to complete the request. 148d5869fdcSYang Shi */ 149d5869fdcSYang Shi DEFINE_EVENT(block_rq_completion, block_rq_complete, 150d5869fdcSYang Shi 151d5869fdcSYang Shi TP_PROTO(struct request *rq, blk_status_t error, unsigned int nr_bytes), 152d5869fdcSYang Shi 153d5869fdcSYang Shi TP_ARGS(rq, error, nr_bytes) 154d5869fdcSYang Shi ); 155d5869fdcSYang Shi 156d5869fdcSYang Shi /** 157d5869fdcSYang Shi * block_rq_error - block IO operation error reported by device driver 158d5869fdcSYang Shi * @rq: block operations request 159d5869fdcSYang Shi * @error: status code 160d5869fdcSYang Shi * @nr_bytes: number of completed bytes 161d5869fdcSYang Shi * 162d5869fdcSYang Shi * The block_rq_error tracepoint event indicates that some portion 163d5869fdcSYang Shi * of operation request has failed as reported by the device driver. 164d5869fdcSYang Shi */ 165d5869fdcSYang Shi DEFINE_EVENT(block_rq_completion, block_rq_error, 166d5869fdcSYang Shi 167d5869fdcSYang Shi TP_PROTO(struct request *rq, blk_status_t error, unsigned int nr_bytes), 168d5869fdcSYang Shi 169d5869fdcSYang Shi TP_ARGS(rq, error, nr_bytes) 170d5869fdcSYang Shi ); 171d5869fdcSYang Shi 17277ca1e02SLi Zefan DECLARE_EVENT_CLASS(block_rq, 17355782138SLi Zefan 174a54895faSChristoph Hellwig TP_PROTO(struct request *rq), 17555782138SLi Zefan 176a54895faSChristoph Hellwig TP_ARGS(rq), 17755782138SLi Zefan 17855782138SLi Zefan TP_STRUCT__entry( 17955782138SLi Zefan __field( dev_t, dev ) 18055782138SLi Zefan __field( sector_t, sector ) 18155782138SLi Zefan __field( unsigned int, nr_sector ) 18255782138SLi Zefan __field( unsigned int, bytes ) 183c09c47caSNamhyung Kim __array( char, rwbs, RWBS_LEN ) 18455782138SLi Zefan __array( char, comm, TASK_COMM_LEN ) 18548b77ad6SChristoph Hellwig __dynamic_array( char, cmd, 1 ) 18655782138SLi Zefan ), 18755782138SLi Zefan 18855782138SLi Zefan TP_fast_assign( 189f3fa33acSChristoph Hellwig __entry->dev = rq->q->disk ? disk_devt(rq->q->disk) : 0; 19048b77ad6SChristoph Hellwig __entry->sector = blk_rq_trace_sector(rq); 19148b77ad6SChristoph Hellwig __entry->nr_sector = blk_rq_trace_nr_sectors(rq); 19248b77ad6SChristoph Hellwig __entry->bytes = blk_rq_bytes(rq); 19355782138SLi Zefan 194179d1600SChaitanya Kulkarni blk_fill_rwbs(__entry->rwbs, rq->cmd_flags); 19548b77ad6SChristoph Hellwig __get_str(cmd)[0] = '\0'; 19655782138SLi Zefan memcpy(__entry->comm, current->comm, TASK_COMM_LEN); 19755782138SLi Zefan ), 19855782138SLi Zefan 19955782138SLi Zefan TP_printk("%d,%d %s %u (%s) %llu + %u [%s]", 20055782138SLi Zefan MAJOR(__entry->dev), MINOR(__entry->dev), 20155782138SLi Zefan __entry->rwbs, __entry->bytes, __get_str(cmd), 2026556d1dfSSteven Rostedt (unsigned long long)__entry->sector, 2036556d1dfSSteven Rostedt __entry->nr_sector, __entry->comm) 20455782138SLi Zefan ); 20555782138SLi Zefan 206881245dcSWilliam Cohen /** 207881245dcSWilliam Cohen * block_rq_insert - insert block operation request into queue 208881245dcSWilliam Cohen * @rq: block IO operation request 209881245dcSWilliam Cohen * 210881245dcSWilliam Cohen * Called immediately before block operation request @rq is inserted 211881245dcSWilliam Cohen * into queue @q. The fields in the operation request @rq struct can 212881245dcSWilliam Cohen * be examined to determine which device and sectors the pending 213881245dcSWilliam Cohen * operation would access. 214881245dcSWilliam Cohen */ 21577ca1e02SLi Zefan DEFINE_EVENT(block_rq, block_rq_insert, 21655782138SLi Zefan 217a54895faSChristoph Hellwig TP_PROTO(struct request *rq), 21855782138SLi Zefan 219a54895faSChristoph Hellwig TP_ARGS(rq) 22055782138SLi Zefan ); 22155782138SLi Zefan 222881245dcSWilliam Cohen /** 223881245dcSWilliam Cohen * block_rq_issue - issue pending block IO request operation to device driver 224c7ff6519SChaitanya Kulkarni * @rq: block IO operation request 225881245dcSWilliam Cohen * 226881245dcSWilliam Cohen * Called when block operation request @rq from queue @q is sent to a 227881245dcSWilliam Cohen * device driver for processing. 228881245dcSWilliam Cohen */ 22977ca1e02SLi Zefan DEFINE_EVENT(block_rq, block_rq_issue, 23055782138SLi Zefan 231a54895faSChristoph Hellwig TP_PROTO(struct request *rq), 23255782138SLi Zefan 233a54895faSChristoph Hellwig TP_ARGS(rq) 23455782138SLi Zefan ); 235fe63b94aSCarsten Emde 236881245dcSWilliam Cohen /** 237f3bdc62fSJan Kara * block_rq_merge - merge request with another one in the elevator 238b0719245SChaitanya Kulkarni * @rq: block IO operation request 239f3bdc62fSJan Kara * 240f3bdc62fSJan Kara * Called when block operation request @rq from queue @q is merged to another 241f3bdc62fSJan Kara * request queued in the elevator. 242f3bdc62fSJan Kara */ 243f3bdc62fSJan Kara DEFINE_EVENT(block_rq, block_rq_merge, 244f3bdc62fSJan Kara 245a54895faSChristoph Hellwig TP_PROTO(struct request *rq), 246f3bdc62fSJan Kara 247a54895faSChristoph Hellwig TP_ARGS(rq) 248f3bdc62fSJan Kara ); 249f3bdc62fSJan Kara 250f3bdc62fSJan Kara /** 2515a80bd07SHengqi Chen * block_io_start - insert a request for execution 2525a80bd07SHengqi Chen * @rq: block IO operation request 2535a80bd07SHengqi Chen * 2545a80bd07SHengqi Chen * Called when block operation request @rq is queued for execution 2555a80bd07SHengqi Chen */ 2565a80bd07SHengqi Chen DEFINE_EVENT(block_rq, block_io_start, 2575a80bd07SHengqi Chen 2585a80bd07SHengqi Chen TP_PROTO(struct request *rq), 2595a80bd07SHengqi Chen 2605a80bd07SHengqi Chen TP_ARGS(rq) 2615a80bd07SHengqi Chen ); 2625a80bd07SHengqi Chen 2635a80bd07SHengqi Chen /** 2645a80bd07SHengqi Chen * block_io_done - block IO operation request completed 2655a80bd07SHengqi Chen * @rq: block IO operation request 2665a80bd07SHengqi Chen * 2675a80bd07SHengqi Chen * Called when block operation request @rq is completed 2685a80bd07SHengqi Chen */ 2695a80bd07SHengqi Chen DEFINE_EVENT(block_rq, block_io_done, 2705a80bd07SHengqi Chen 2715a80bd07SHengqi Chen TP_PROTO(struct request *rq), 2725a80bd07SHengqi Chen 2735a80bd07SHengqi Chen TP_ARGS(rq) 2745a80bd07SHengqi Chen ); 2755a80bd07SHengqi Chen 2765a80bd07SHengqi Chen /** 277881245dcSWilliam Cohen * block_bio_complete - completed all work on the block operation 2780a82a8d1SLinus Torvalds * @q: queue holding the block operation 279881245dcSWilliam Cohen * @bio: block operation completed 280881245dcSWilliam Cohen * 281881245dcSWilliam Cohen * This tracepoint indicates there is no further work to do on this 282881245dcSWilliam Cohen * block IO operation @bio. 283881245dcSWilliam Cohen */ 28455782138SLi Zefan TRACE_EVENT(block_bio_complete, 28555782138SLi Zefan 286d24de76aSChristoph Hellwig TP_PROTO(struct request_queue *q, struct bio *bio), 28755782138SLi Zefan 288d24de76aSChristoph Hellwig TP_ARGS(q, bio), 28955782138SLi Zefan 29055782138SLi Zefan TP_STRUCT__entry( 29155782138SLi Zefan __field( dev_t, dev ) 29255782138SLi Zefan __field( sector_t, sector ) 29355782138SLi Zefan __field( unsigned, nr_sector ) 29455782138SLi Zefan __field( int, error ) 295c09c47caSNamhyung Kim __array( char, rwbs, RWBS_LEN) 29655782138SLi Zefan ), 29755782138SLi Zefan 29855782138SLi Zefan TP_fast_assign( 29974d46992SChristoph Hellwig __entry->dev = bio_dev(bio); 3004f024f37SKent Overstreet __entry->sector = bio->bi_iter.bi_sector; 301aa8b57aaSKent Overstreet __entry->nr_sector = bio_sectors(bio); 302d24de76aSChristoph Hellwig __entry->error = blk_status_to_errno(bio->bi_status); 303179d1600SChaitanya Kulkarni blk_fill_rwbs(__entry->rwbs, bio->bi_opf); 30455782138SLi Zefan ), 30555782138SLi Zefan 30655782138SLi Zefan TP_printk("%d,%d %s %llu + %u [%d]", 30755782138SLi Zefan MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, 3086556d1dfSSteven Rostedt (unsigned long long)__entry->sector, 3096556d1dfSSteven Rostedt __entry->nr_sector, __entry->error) 31055782138SLi Zefan ); 31155782138SLi Zefan 312e8a676d6SChristoph Hellwig DECLARE_EVENT_CLASS(block_bio, 31355782138SLi Zefan 314e8a676d6SChristoph Hellwig TP_PROTO(struct bio *bio), 31555782138SLi Zefan 316e8a676d6SChristoph Hellwig TP_ARGS(bio), 31755782138SLi Zefan 31855782138SLi Zefan TP_STRUCT__entry( 31955782138SLi Zefan __field( dev_t, dev ) 32055782138SLi Zefan __field( sector_t, sector ) 32155782138SLi Zefan __field( unsigned int, nr_sector ) 322c09c47caSNamhyung Kim __array( char, rwbs, RWBS_LEN ) 32355782138SLi Zefan __array( char, comm, TASK_COMM_LEN ) 32455782138SLi Zefan ), 32555782138SLi Zefan 32655782138SLi Zefan TP_fast_assign( 32774d46992SChristoph Hellwig __entry->dev = bio_dev(bio); 3284f024f37SKent Overstreet __entry->sector = bio->bi_iter.bi_sector; 329aa8b57aaSKent Overstreet __entry->nr_sector = bio_sectors(bio); 330179d1600SChaitanya Kulkarni blk_fill_rwbs(__entry->rwbs, bio->bi_opf); 33155782138SLi Zefan memcpy(__entry->comm, current->comm, TASK_COMM_LEN); 33255782138SLi Zefan ), 33355782138SLi Zefan 33455782138SLi Zefan TP_printk("%d,%d %s %llu + %u [%s]", 33555782138SLi Zefan MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, 3366556d1dfSSteven Rostedt (unsigned long long)__entry->sector, 3376556d1dfSSteven Rostedt __entry->nr_sector, __entry->comm) 33855782138SLi Zefan ); 33955782138SLi Zefan 340881245dcSWilliam Cohen /** 341e8a676d6SChristoph Hellwig * block_bio_bounce - used bounce buffer when processing block operation 342e8a676d6SChristoph Hellwig * @bio: block operation 343e8a676d6SChristoph Hellwig * 344e8a676d6SChristoph Hellwig * A bounce buffer was used to handle the block operation @bio in @q. 345e8a676d6SChristoph Hellwig * This occurs when hardware limitations prevent a direct transfer of 346e8a676d6SChristoph Hellwig * data between the @bio data memory area and the IO device. Use of a 347e8a676d6SChristoph Hellwig * bounce buffer requires extra copying of data and decreases 348e8a676d6SChristoph Hellwig * performance. 349e8a676d6SChristoph Hellwig */ 350e8a676d6SChristoph Hellwig DEFINE_EVENT(block_bio, block_bio_bounce, 351e8a676d6SChristoph Hellwig TP_PROTO(struct bio *bio), 352e8a676d6SChristoph Hellwig TP_ARGS(bio) 353e8a676d6SChristoph Hellwig ); 354e8a676d6SChristoph Hellwig 355e8a676d6SChristoph Hellwig /** 356881245dcSWilliam Cohen * block_bio_backmerge - merging block operation to the end of an existing operation 357881245dcSWilliam Cohen * @bio: new block operation to merge 358881245dcSWilliam Cohen * 359e8a676d6SChristoph Hellwig * Merging block request @bio to the end of an existing block request. 360881245dcSWilliam Cohen */ 361e8a676d6SChristoph Hellwig DEFINE_EVENT(block_bio, block_bio_backmerge, 362e8a676d6SChristoph Hellwig TP_PROTO(struct bio *bio), 363e8a676d6SChristoph Hellwig TP_ARGS(bio) 36455782138SLi Zefan ); 36555782138SLi Zefan 366881245dcSWilliam Cohen /** 367881245dcSWilliam Cohen * block_bio_frontmerge - merging block operation to the beginning of an existing operation 368881245dcSWilliam Cohen * @bio: new block operation to merge 369881245dcSWilliam Cohen * 370e8a676d6SChristoph Hellwig * Merging block IO operation @bio to the beginning of an existing block request. 371881245dcSWilliam Cohen */ 372e8a676d6SChristoph Hellwig DEFINE_EVENT(block_bio, block_bio_frontmerge, 373e8a676d6SChristoph Hellwig TP_PROTO(struct bio *bio), 374e8a676d6SChristoph Hellwig TP_ARGS(bio) 37555782138SLi Zefan ); 37655782138SLi Zefan 377881245dcSWilliam Cohen /** 378881245dcSWilliam Cohen * block_bio_queue - putting new block IO operation in queue 379881245dcSWilliam Cohen * @bio: new block operation 380881245dcSWilliam Cohen * 381881245dcSWilliam Cohen * About to place the block IO operation @bio into queue @q. 382881245dcSWilliam Cohen */ 383e8a676d6SChristoph Hellwig DEFINE_EVENT(block_bio, block_bio_queue, 384e8a676d6SChristoph Hellwig TP_PROTO(struct bio *bio), 385e8a676d6SChristoph Hellwig TP_ARGS(bio) 38655782138SLi Zefan ); 38755782138SLi Zefan 388881245dcSWilliam Cohen /** 389881245dcSWilliam Cohen * block_getrq - get a free request entry in queue for block IO operations 390f8e9ec16SGreg Thelen * @bio: pending block IO operation (can be %NULL) 391881245dcSWilliam Cohen * 392e8a676d6SChristoph Hellwig * A request struct has been allocated to handle the block IO operation @bio. 393881245dcSWilliam Cohen */ 394e8a676d6SChristoph Hellwig DEFINE_EVENT(block_bio, block_getrq, 395e8a676d6SChristoph Hellwig TP_PROTO(struct bio *bio), 396e8a676d6SChristoph Hellwig TP_ARGS(bio) 39777ca1e02SLi Zefan ); 39855782138SLi Zefan 399881245dcSWilliam Cohen /** 400881245dcSWilliam Cohen * block_plug - keep operations requests in request queue 401881245dcSWilliam Cohen * @q: request queue to plug 402881245dcSWilliam Cohen * 403881245dcSWilliam Cohen * Plug the request queue @q. Do not allow block operation requests 404881245dcSWilliam Cohen * to be sent to the device driver. Instead, accumulate requests in 405881245dcSWilliam Cohen * the queue to improve throughput performance of the block device. 406881245dcSWilliam Cohen */ 40755782138SLi Zefan TRACE_EVENT(block_plug, 40855782138SLi Zefan 40955782138SLi Zefan TP_PROTO(struct request_queue *q), 41055782138SLi Zefan 41155782138SLi Zefan TP_ARGS(q), 41255782138SLi Zefan 41355782138SLi Zefan TP_STRUCT__entry( 41455782138SLi Zefan __array( char, comm, TASK_COMM_LEN ) 41555782138SLi Zefan ), 41655782138SLi Zefan 41755782138SLi Zefan TP_fast_assign( 41855782138SLi Zefan memcpy(__entry->comm, current->comm, TASK_COMM_LEN); 41955782138SLi Zefan ), 42055782138SLi Zefan 42155782138SLi Zefan TP_printk("[%s]", __entry->comm) 42255782138SLi Zefan ); 42355782138SLi Zefan 42477ca1e02SLi Zefan DECLARE_EVENT_CLASS(block_unplug, 42555782138SLi Zefan 42649cac01eSJens Axboe TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit), 42755782138SLi Zefan 42849cac01eSJens Axboe TP_ARGS(q, depth, explicit), 42955782138SLi Zefan 43055782138SLi Zefan TP_STRUCT__entry( 43155782138SLi Zefan __field( int, nr_rq ) 43255782138SLi Zefan __array( char, comm, TASK_COMM_LEN ) 43355782138SLi Zefan ), 43455782138SLi Zefan 43555782138SLi Zefan TP_fast_assign( 43694b5eb28SJens Axboe __entry->nr_rq = depth; 43755782138SLi Zefan memcpy(__entry->comm, current->comm, TASK_COMM_LEN); 43855782138SLi Zefan ), 43955782138SLi Zefan 44055782138SLi Zefan TP_printk("[%s] %d", __entry->comm, __entry->nr_rq) 44155782138SLi Zefan ); 44255782138SLi Zefan 443881245dcSWilliam Cohen /** 44449cac01eSJens Axboe * block_unplug - release of operations requests in request queue 445881245dcSWilliam Cohen * @q: request queue to unplug 44694b5eb28SJens Axboe * @depth: number of requests just added to the queue 44749cac01eSJens Axboe * @explicit: whether this was an explicit unplug, or one from schedule() 448881245dcSWilliam Cohen * 449881245dcSWilliam Cohen * Unplug request queue @q because device driver is scheduled to work 450881245dcSWilliam Cohen * on elements in the request queue. 451881245dcSWilliam Cohen */ 45249cac01eSJens Axboe DEFINE_EVENT(block_unplug, block_unplug, 45355782138SLi Zefan 45449cac01eSJens Axboe TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit), 45555782138SLi Zefan 45649cac01eSJens Axboe TP_ARGS(q, depth, explicit) 45755782138SLi Zefan ); 45855782138SLi Zefan 459881245dcSWilliam Cohen /** 460881245dcSWilliam Cohen * block_split - split a single bio struct into two bio structs 461881245dcSWilliam Cohen * @bio: block operation being split 462881245dcSWilliam Cohen * @new_sector: The starting sector for the new bio 463881245dcSWilliam Cohen * 464eb6f7f7cSChristoph Hellwig * The bio request @bio needs to be split into two bio requests. The newly 465eb6f7f7cSChristoph Hellwig * created @bio request starts at @new_sector. This split may be required due to 466eb6f7f7cSChristoph Hellwig * hardware limitations such as operation crossing device boundaries in a RAID 467eb6f7f7cSChristoph Hellwig * system. 468881245dcSWilliam Cohen */ 46955782138SLi Zefan TRACE_EVENT(block_split, 47055782138SLi Zefan 471eb6f7f7cSChristoph Hellwig TP_PROTO(struct bio *bio, unsigned int new_sector), 47255782138SLi Zefan 473eb6f7f7cSChristoph Hellwig TP_ARGS(bio, new_sector), 47455782138SLi Zefan 47555782138SLi Zefan TP_STRUCT__entry( 47655782138SLi Zefan __field( dev_t, dev ) 47755782138SLi Zefan __field( sector_t, sector ) 47855782138SLi Zefan __field( sector_t, new_sector ) 479c09c47caSNamhyung Kim __array( char, rwbs, RWBS_LEN ) 48055782138SLi Zefan __array( char, comm, TASK_COMM_LEN ) 48155782138SLi Zefan ), 48255782138SLi Zefan 48355782138SLi Zefan TP_fast_assign( 48474d46992SChristoph Hellwig __entry->dev = bio_dev(bio); 4854f024f37SKent Overstreet __entry->sector = bio->bi_iter.bi_sector; 48655782138SLi Zefan __entry->new_sector = new_sector; 487179d1600SChaitanya Kulkarni blk_fill_rwbs(__entry->rwbs, bio->bi_opf); 48855782138SLi Zefan memcpy(__entry->comm, current->comm, TASK_COMM_LEN); 48955782138SLi Zefan ), 49055782138SLi Zefan 49155782138SLi Zefan TP_printk("%d,%d %s %llu / %llu [%s]", 49255782138SLi Zefan MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, 4936556d1dfSSteven Rostedt (unsigned long long)__entry->sector, 4946556d1dfSSteven Rostedt (unsigned long long)__entry->new_sector, 4956556d1dfSSteven Rostedt __entry->comm) 49655782138SLi Zefan ); 49755782138SLi Zefan 498881245dcSWilliam Cohen /** 499d07335e5SMike Snitzer * block_bio_remap - map request for a logical device to the raw device 500881245dcSWilliam Cohen * @bio: revised operation 5011c02fca6SChristoph Hellwig * @dev: original device for the operation 502881245dcSWilliam Cohen * @from: original sector for the operation 503881245dcSWilliam Cohen * 504d07335e5SMike Snitzer * An operation for a logical device has been mapped to the 505881245dcSWilliam Cohen * raw block device. 506881245dcSWilliam Cohen */ 507d07335e5SMike Snitzer TRACE_EVENT(block_bio_remap, 50855782138SLi Zefan 5091c02fca6SChristoph Hellwig TP_PROTO(struct bio *bio, dev_t dev, sector_t from), 51055782138SLi Zefan 5111c02fca6SChristoph Hellwig TP_ARGS(bio, dev, from), 51255782138SLi Zefan 51355782138SLi Zefan TP_STRUCT__entry( 51455782138SLi Zefan __field( dev_t, dev ) 51555782138SLi Zefan __field( sector_t, sector ) 51655782138SLi Zefan __field( unsigned int, nr_sector ) 51755782138SLi Zefan __field( dev_t, old_dev ) 51855782138SLi Zefan __field( sector_t, old_sector ) 519c09c47caSNamhyung Kim __array( char, rwbs, RWBS_LEN) 52055782138SLi Zefan ), 52155782138SLi Zefan 52255782138SLi Zefan TP_fast_assign( 52374d46992SChristoph Hellwig __entry->dev = bio_dev(bio); 5244f024f37SKent Overstreet __entry->sector = bio->bi_iter.bi_sector; 525aa8b57aaSKent Overstreet __entry->nr_sector = bio_sectors(bio); 52655782138SLi Zefan __entry->old_dev = dev; 52755782138SLi Zefan __entry->old_sector = from; 528179d1600SChaitanya Kulkarni blk_fill_rwbs(__entry->rwbs, bio->bi_opf); 52955782138SLi Zefan ), 53055782138SLi Zefan 53155782138SLi Zefan TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu", 53255782138SLi Zefan MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, 5336556d1dfSSteven Rostedt (unsigned long long)__entry->sector, 5346556d1dfSSteven Rostedt __entry->nr_sector, 53555782138SLi Zefan MAJOR(__entry->old_dev), MINOR(__entry->old_dev), 5366556d1dfSSteven Rostedt (unsigned long long)__entry->old_sector) 53755782138SLi Zefan ); 53855782138SLi Zefan 539881245dcSWilliam Cohen /** 540881245dcSWilliam Cohen * block_rq_remap - map request for a block operation request 541881245dcSWilliam Cohen * @rq: block IO operation request 542881245dcSWilliam Cohen * @dev: device for the operation 543881245dcSWilliam Cohen * @from: original sector for the operation 544881245dcSWilliam Cohen * 545881245dcSWilliam Cohen * The block operation request @rq in @q has been remapped. The block 546881245dcSWilliam Cohen * operation request @rq holds the current information and @from hold 547881245dcSWilliam Cohen * the original sector. 548881245dcSWilliam Cohen */ 549b0da3f0dSJun'ichi Nomura TRACE_EVENT(block_rq_remap, 550b0da3f0dSJun'ichi Nomura 551a54895faSChristoph Hellwig TP_PROTO(struct request *rq, dev_t dev, sector_t from), 552b0da3f0dSJun'ichi Nomura 553a54895faSChristoph Hellwig TP_ARGS(rq, dev, from), 554b0da3f0dSJun'ichi Nomura 555b0da3f0dSJun'ichi Nomura TP_STRUCT__entry( 556b0da3f0dSJun'ichi Nomura __field( dev_t, dev ) 557b0da3f0dSJun'ichi Nomura __field( sector_t, sector ) 558b0da3f0dSJun'ichi Nomura __field( unsigned int, nr_sector ) 559b0da3f0dSJun'ichi Nomura __field( dev_t, old_dev ) 560b0da3f0dSJun'ichi Nomura __field( sector_t, old_sector ) 56175afb352SJun'ichi Nomura __field( unsigned int, nr_bios ) 562c09c47caSNamhyung Kim __array( char, rwbs, RWBS_LEN) 563b0da3f0dSJun'ichi Nomura ), 564b0da3f0dSJun'ichi Nomura 565b0da3f0dSJun'ichi Nomura TP_fast_assign( 566f3fa33acSChristoph Hellwig __entry->dev = disk_devt(rq->q->disk); 567b0da3f0dSJun'ichi Nomura __entry->sector = blk_rq_pos(rq); 568b0da3f0dSJun'ichi Nomura __entry->nr_sector = blk_rq_sectors(rq); 569b0da3f0dSJun'ichi Nomura __entry->old_dev = dev; 570b0da3f0dSJun'ichi Nomura __entry->old_sector = from; 57175afb352SJun'ichi Nomura __entry->nr_bios = blk_rq_count_bios(rq); 572179d1600SChaitanya Kulkarni blk_fill_rwbs(__entry->rwbs, rq->cmd_flags); 573b0da3f0dSJun'ichi Nomura ), 574b0da3f0dSJun'ichi Nomura 57575afb352SJun'ichi Nomura TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu %u", 576b0da3f0dSJun'ichi Nomura MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, 577b0da3f0dSJun'ichi Nomura (unsigned long long)__entry->sector, 578b0da3f0dSJun'ichi Nomura __entry->nr_sector, 579b0da3f0dSJun'ichi Nomura MAJOR(__entry->old_dev), MINOR(__entry->old_dev), 58075afb352SJun'ichi Nomura (unsigned long long)__entry->old_sector, __entry->nr_bios) 581b0da3f0dSJun'ichi Nomura ); 582b0da3f0dSJun'ichi Nomura 58355782138SLi Zefan #endif /* _TRACE_BLOCK_H */ 58455782138SLi Zefan 58555782138SLi Zefan /* This part must be outside protection */ 58655782138SLi Zefan #include <trace/define_trace.h> 58755782138SLi Zefan 588