1d0b6e04aSLi Zefan #undef TRACE_SYSTEM 2d0b6e04aSLi Zefan #define TRACE_SYSTEM block 3d0b6e04aSLi Zefan 455782138SLi Zefan #if !defined(_TRACE_BLOCK_H) || defined(TRACE_HEADER_MULTI_READ) 555782138SLi Zefan #define _TRACE_BLOCK_H 655782138SLi Zefan 755782138SLi Zefan #include <linux/blktrace_api.h> 855782138SLi Zefan #include <linux/blkdev.h> 955782138SLi Zefan #include <linux/tracepoint.h> 1055782138SLi Zefan 1177ca1e02SLi Zefan DECLARE_EVENT_CLASS(block_rq_with_error, 1255782138SLi Zefan 1355782138SLi Zefan TP_PROTO(struct request_queue *q, struct request *rq), 1455782138SLi Zefan 1555782138SLi Zefan TP_ARGS(q, rq), 1655782138SLi Zefan 1755782138SLi Zefan TP_STRUCT__entry( 1855782138SLi Zefan __field( dev_t, dev ) 1955782138SLi Zefan __field( sector_t, sector ) 2055782138SLi Zefan __field( unsigned int, nr_sector ) 2155782138SLi Zefan __field( int, errors ) 2255782138SLi Zefan __array( char, rwbs, 6 ) 2355782138SLi Zefan __dynamic_array( char, cmd, blk_cmd_buf_len(rq) ) 2455782138SLi Zefan ), 2555782138SLi Zefan 2655782138SLi Zefan TP_fast_assign( 2755782138SLi Zefan __entry->dev = rq->rq_disk ? disk_devt(rq->rq_disk) : 0; 2833659ebbSChristoph Hellwig __entry->sector = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ? 2933659ebbSChristoph Hellwig 0 : blk_rq_pos(rq); 3033659ebbSChristoph Hellwig __entry->nr_sector = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ? 3133659ebbSChristoph Hellwig 0 : blk_rq_sectors(rq); 3255782138SLi Zefan __entry->errors = rq->errors; 3355782138SLi Zefan 3455782138SLi Zefan blk_fill_rwbs_rq(__entry->rwbs, rq); 3555782138SLi Zefan blk_dump_cmd(__get_str(cmd), rq); 3655782138SLi Zefan ), 3755782138SLi Zefan 3855782138SLi Zefan TP_printk("%d,%d %s (%s) %llu + %u [%d]", 3955782138SLi Zefan MAJOR(__entry->dev), MINOR(__entry->dev), 4055782138SLi Zefan __entry->rwbs, __get_str(cmd), 416556d1dfSSteven Rostedt (unsigned long long)__entry->sector, 426556d1dfSSteven Rostedt __entry->nr_sector, __entry->errors) 4355782138SLi Zefan ); 4455782138SLi Zefan 45881245dcSWilliam Cohen /** 46881245dcSWilliam Cohen * block_rq_abort - abort block operation request 47881245dcSWilliam Cohen * @q: queue containing the block operation request 48881245dcSWilliam Cohen * @rq: block IO operation request 49881245dcSWilliam Cohen * 50881245dcSWilliam Cohen * Called immediately after pending block IO operation request @rq in 51881245dcSWilliam Cohen * queue @q is aborted. The fields in the operation request @rq 52881245dcSWilliam Cohen * can be examined to determine which device and sectors the pending 53881245dcSWilliam Cohen * operation would access. 54881245dcSWilliam Cohen */ 5577ca1e02SLi Zefan DEFINE_EVENT(block_rq_with_error, block_rq_abort, 5677ca1e02SLi Zefan 5777ca1e02SLi Zefan TP_PROTO(struct request_queue *q, struct request *rq), 5877ca1e02SLi Zefan 5977ca1e02SLi Zefan TP_ARGS(q, rq) 6077ca1e02SLi Zefan ); 6177ca1e02SLi Zefan 62881245dcSWilliam Cohen /** 63881245dcSWilliam Cohen * block_rq_requeue - place block IO request back on a queue 64881245dcSWilliam Cohen * @q: queue holding operation 65881245dcSWilliam Cohen * @rq: block IO operation request 66881245dcSWilliam Cohen * 67881245dcSWilliam Cohen * The block operation request @rq is being placed back into queue 68881245dcSWilliam Cohen * @q. For some reason the request was not completed and needs to be 69881245dcSWilliam Cohen * put back in the queue. 70881245dcSWilliam Cohen */ 7177ca1e02SLi Zefan DEFINE_EVENT(block_rq_with_error, block_rq_requeue, 7277ca1e02SLi Zefan 7377ca1e02SLi Zefan TP_PROTO(struct request_queue *q, struct request *rq), 7477ca1e02SLi Zefan 7577ca1e02SLi Zefan TP_ARGS(q, rq) 7677ca1e02SLi Zefan ); 7777ca1e02SLi Zefan 78881245dcSWilliam Cohen /** 79881245dcSWilliam Cohen * block_rq_complete - block IO operation completed by device driver 80881245dcSWilliam Cohen * @q: queue containing the block operation request 81881245dcSWilliam Cohen * @rq: block operations request 82881245dcSWilliam Cohen * 83881245dcSWilliam Cohen * The block_rq_complete tracepoint event indicates that some portion 84881245dcSWilliam Cohen * of operation request has been completed by the device driver. If 85881245dcSWilliam Cohen * the @rq->bio is %NULL, then there is absolutely no additional work to 86881245dcSWilliam Cohen * do for the request. If @rq->bio is non-NULL then there is 87881245dcSWilliam Cohen * additional work required to complete the request. 88881245dcSWilliam Cohen */ 8977ca1e02SLi Zefan DEFINE_EVENT(block_rq_with_error, block_rq_complete, 9077ca1e02SLi Zefan 9177ca1e02SLi Zefan TP_PROTO(struct request_queue *q, struct request *rq), 9277ca1e02SLi Zefan 9377ca1e02SLi Zefan TP_ARGS(q, rq) 9477ca1e02SLi Zefan ); 9577ca1e02SLi Zefan 9677ca1e02SLi Zefan DECLARE_EVENT_CLASS(block_rq, 9755782138SLi Zefan 9855782138SLi Zefan TP_PROTO(struct request_queue *q, struct request *rq), 9955782138SLi Zefan 10055782138SLi Zefan TP_ARGS(q, rq), 10155782138SLi Zefan 10255782138SLi Zefan TP_STRUCT__entry( 10355782138SLi Zefan __field( dev_t, dev ) 10455782138SLi Zefan __field( sector_t, sector ) 10555782138SLi Zefan __field( unsigned int, nr_sector ) 10655782138SLi Zefan __field( unsigned int, bytes ) 10755782138SLi Zefan __array( char, rwbs, 6 ) 10855782138SLi Zefan __array( char, comm, TASK_COMM_LEN ) 10955782138SLi Zefan __dynamic_array( char, cmd, blk_cmd_buf_len(rq) ) 11055782138SLi Zefan ), 11155782138SLi Zefan 11255782138SLi Zefan TP_fast_assign( 11355782138SLi Zefan __entry->dev = rq->rq_disk ? disk_devt(rq->rq_disk) : 0; 11433659ebbSChristoph Hellwig __entry->sector = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ? 11533659ebbSChristoph Hellwig 0 : blk_rq_pos(rq); 11633659ebbSChristoph Hellwig __entry->nr_sector = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ? 11733659ebbSChristoph Hellwig 0 : blk_rq_sectors(rq); 11833659ebbSChristoph Hellwig __entry->bytes = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ? 11933659ebbSChristoph Hellwig blk_rq_bytes(rq) : 0; 12055782138SLi Zefan 12155782138SLi Zefan blk_fill_rwbs_rq(__entry->rwbs, rq); 12255782138SLi Zefan blk_dump_cmd(__get_str(cmd), rq); 12355782138SLi Zefan memcpy(__entry->comm, current->comm, TASK_COMM_LEN); 12455782138SLi Zefan ), 12555782138SLi Zefan 12655782138SLi Zefan TP_printk("%d,%d %s %u (%s) %llu + %u [%s]", 12755782138SLi Zefan MAJOR(__entry->dev), MINOR(__entry->dev), 12855782138SLi Zefan __entry->rwbs, __entry->bytes, __get_str(cmd), 1296556d1dfSSteven Rostedt (unsigned long long)__entry->sector, 1306556d1dfSSteven Rostedt __entry->nr_sector, __entry->comm) 13155782138SLi Zefan ); 13255782138SLi Zefan 133881245dcSWilliam Cohen /** 134881245dcSWilliam Cohen * block_rq_insert - insert block operation request into queue 135881245dcSWilliam Cohen * @q: target queue 136881245dcSWilliam Cohen * @rq: block IO operation request 137881245dcSWilliam Cohen * 138881245dcSWilliam Cohen * Called immediately before block operation request @rq is inserted 139881245dcSWilliam Cohen * into queue @q. The fields in the operation request @rq struct can 140881245dcSWilliam Cohen * be examined to determine which device and sectors the pending 141881245dcSWilliam Cohen * operation would access. 142881245dcSWilliam Cohen */ 14377ca1e02SLi Zefan DEFINE_EVENT(block_rq, block_rq_insert, 14455782138SLi Zefan 14555782138SLi Zefan TP_PROTO(struct request_queue *q, struct request *rq), 14655782138SLi Zefan 14777ca1e02SLi Zefan TP_ARGS(q, rq) 14855782138SLi Zefan ); 14955782138SLi Zefan 150881245dcSWilliam Cohen /** 151881245dcSWilliam Cohen * block_rq_issue - issue pending block IO request operation to device driver 152881245dcSWilliam Cohen * @q: queue holding operation 153881245dcSWilliam Cohen * @rq: block IO operation operation request 154881245dcSWilliam Cohen * 155881245dcSWilliam Cohen * Called when block operation request @rq from queue @q is sent to a 156881245dcSWilliam Cohen * device driver for processing. 157881245dcSWilliam Cohen */ 15877ca1e02SLi Zefan DEFINE_EVENT(block_rq, block_rq_issue, 15955782138SLi Zefan 16055782138SLi Zefan TP_PROTO(struct request_queue *q, struct request *rq), 16155782138SLi Zefan 16277ca1e02SLi Zefan TP_ARGS(q, rq) 16355782138SLi Zefan ); 164fe63b94aSCarsten Emde 165881245dcSWilliam Cohen /** 166881245dcSWilliam Cohen * block_bio_bounce - used bounce buffer when processing block operation 167881245dcSWilliam Cohen * @q: queue holding the block operation 168881245dcSWilliam Cohen * @bio: block operation 169881245dcSWilliam Cohen * 170881245dcSWilliam Cohen * A bounce buffer was used to handle the block operation @bio in @q. 171881245dcSWilliam Cohen * This occurs when hardware limitations prevent a direct transfer of 172881245dcSWilliam Cohen * data between the @bio data memory area and the IO device. Use of a 173881245dcSWilliam Cohen * bounce buffer requires extra copying of data and decreases 174881245dcSWilliam Cohen * performance. 175881245dcSWilliam Cohen */ 17655782138SLi Zefan TRACE_EVENT(block_bio_bounce, 17755782138SLi Zefan 17855782138SLi Zefan TP_PROTO(struct request_queue *q, struct bio *bio), 17955782138SLi Zefan 18055782138SLi Zefan TP_ARGS(q, bio), 18155782138SLi Zefan 18255782138SLi Zefan TP_STRUCT__entry( 18355782138SLi Zefan __field( dev_t, dev ) 18455782138SLi Zefan __field( sector_t, sector ) 18555782138SLi Zefan __field( unsigned int, nr_sector ) 18655782138SLi Zefan __array( char, rwbs, 6 ) 18755782138SLi Zefan __array( char, comm, TASK_COMM_LEN ) 18855782138SLi Zefan ), 18955782138SLi Zefan 19055782138SLi Zefan TP_fast_assign( 191fe63b94aSCarsten Emde __entry->dev = bio->bi_bdev ? 192fe63b94aSCarsten Emde bio->bi_bdev->bd_dev : 0; 19355782138SLi Zefan __entry->sector = bio->bi_sector; 19455782138SLi Zefan __entry->nr_sector = bio->bi_size >> 9; 19555782138SLi Zefan blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size); 19655782138SLi Zefan memcpy(__entry->comm, current->comm, TASK_COMM_LEN); 19755782138SLi Zefan ), 19855782138SLi Zefan 19955782138SLi Zefan TP_printk("%d,%d %s %llu + %u [%s]", 20055782138SLi Zefan MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, 2016556d1dfSSteven Rostedt (unsigned long long)__entry->sector, 2026556d1dfSSteven Rostedt __entry->nr_sector, __entry->comm) 20355782138SLi Zefan ); 20455782138SLi Zefan 205881245dcSWilliam Cohen /** 206881245dcSWilliam Cohen * block_bio_complete - completed all work on the block operation 207881245dcSWilliam Cohen * @q: queue holding the block operation 208881245dcSWilliam Cohen * @bio: block operation completed 209881245dcSWilliam Cohen * 210881245dcSWilliam Cohen * This tracepoint indicates there is no further work to do on this 211881245dcSWilliam Cohen * block IO operation @bio. 212881245dcSWilliam Cohen */ 21355782138SLi Zefan TRACE_EVENT(block_bio_complete, 21455782138SLi Zefan 21555782138SLi Zefan TP_PROTO(struct request_queue *q, struct bio *bio), 21655782138SLi Zefan 21755782138SLi Zefan TP_ARGS(q, bio), 21855782138SLi Zefan 21955782138SLi Zefan TP_STRUCT__entry( 22055782138SLi Zefan __field( dev_t, dev ) 22155782138SLi Zefan __field( sector_t, sector ) 22255782138SLi Zefan __field( unsigned, nr_sector ) 22355782138SLi Zefan __field( int, error ) 22455782138SLi Zefan __array( char, rwbs, 6 ) 22555782138SLi Zefan ), 22655782138SLi Zefan 22755782138SLi Zefan TP_fast_assign( 22855782138SLi Zefan __entry->dev = bio->bi_bdev->bd_dev; 22955782138SLi Zefan __entry->sector = bio->bi_sector; 23055782138SLi Zefan __entry->nr_sector = bio->bi_size >> 9; 23155782138SLi Zefan blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size); 23255782138SLi Zefan ), 23355782138SLi Zefan 23455782138SLi Zefan TP_printk("%d,%d %s %llu + %u [%d]", 23555782138SLi Zefan MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, 2366556d1dfSSteven Rostedt (unsigned long long)__entry->sector, 2376556d1dfSSteven Rostedt __entry->nr_sector, __entry->error) 23855782138SLi Zefan ); 23955782138SLi Zefan 24077ca1e02SLi Zefan DECLARE_EVENT_CLASS(block_bio, 24155782138SLi Zefan 24255782138SLi Zefan TP_PROTO(struct request_queue *q, struct bio *bio), 24355782138SLi Zefan 24455782138SLi Zefan TP_ARGS(q, bio), 24555782138SLi Zefan 24655782138SLi Zefan TP_STRUCT__entry( 24755782138SLi Zefan __field( dev_t, dev ) 24855782138SLi Zefan __field( sector_t, sector ) 24955782138SLi Zefan __field( unsigned int, nr_sector ) 25055782138SLi Zefan __array( char, rwbs, 6 ) 25155782138SLi Zefan __array( char, comm, TASK_COMM_LEN ) 25255782138SLi Zefan ), 25355782138SLi Zefan 25455782138SLi Zefan TP_fast_assign( 25555782138SLi Zefan __entry->dev = bio->bi_bdev->bd_dev; 25655782138SLi Zefan __entry->sector = bio->bi_sector; 25755782138SLi Zefan __entry->nr_sector = bio->bi_size >> 9; 25855782138SLi Zefan blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size); 25955782138SLi Zefan memcpy(__entry->comm, current->comm, TASK_COMM_LEN); 26055782138SLi Zefan ), 26155782138SLi Zefan 26255782138SLi Zefan TP_printk("%d,%d %s %llu + %u [%s]", 26355782138SLi Zefan MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, 2646556d1dfSSteven Rostedt (unsigned long long)__entry->sector, 2656556d1dfSSteven Rostedt __entry->nr_sector, __entry->comm) 26655782138SLi Zefan ); 26755782138SLi Zefan 268881245dcSWilliam Cohen /** 269881245dcSWilliam Cohen * block_bio_backmerge - merging block operation to the end of an existing operation 270881245dcSWilliam Cohen * @q: queue holding operation 271881245dcSWilliam Cohen * @bio: new block operation to merge 272881245dcSWilliam Cohen * 273881245dcSWilliam Cohen * Merging block request @bio to the end of an existing block request 274881245dcSWilliam Cohen * in queue @q. 275881245dcSWilliam Cohen */ 27677ca1e02SLi Zefan DEFINE_EVENT(block_bio, block_bio_backmerge, 27755782138SLi Zefan 27855782138SLi Zefan TP_PROTO(struct request_queue *q, struct bio *bio), 27955782138SLi Zefan 28077ca1e02SLi Zefan TP_ARGS(q, bio) 28155782138SLi Zefan ); 28255782138SLi Zefan 283881245dcSWilliam Cohen /** 284881245dcSWilliam Cohen * block_bio_frontmerge - merging block operation to the beginning of an existing operation 285881245dcSWilliam Cohen * @q: queue holding operation 286881245dcSWilliam Cohen * @bio: new block operation to merge 287881245dcSWilliam Cohen * 288881245dcSWilliam Cohen * Merging block IO operation @bio to the beginning of an existing block 289881245dcSWilliam Cohen * operation in queue @q. 290881245dcSWilliam Cohen */ 29177ca1e02SLi Zefan DEFINE_EVENT(block_bio, block_bio_frontmerge, 29255782138SLi Zefan 29355782138SLi Zefan TP_PROTO(struct request_queue *q, struct bio *bio), 29455782138SLi Zefan 29577ca1e02SLi Zefan TP_ARGS(q, bio) 29655782138SLi Zefan ); 29755782138SLi Zefan 298881245dcSWilliam Cohen /** 299881245dcSWilliam Cohen * block_bio_queue - putting new block IO operation in queue 300881245dcSWilliam Cohen * @q: queue holding operation 301881245dcSWilliam Cohen * @bio: new block operation 302881245dcSWilliam Cohen * 303881245dcSWilliam Cohen * About to place the block IO operation @bio into queue @q. 304881245dcSWilliam Cohen */ 30577ca1e02SLi Zefan DEFINE_EVENT(block_bio, block_bio_queue, 30677ca1e02SLi Zefan 30777ca1e02SLi Zefan TP_PROTO(struct request_queue *q, struct bio *bio), 30877ca1e02SLi Zefan 30977ca1e02SLi Zefan TP_ARGS(q, bio) 31077ca1e02SLi Zefan ); 31177ca1e02SLi Zefan 31277ca1e02SLi Zefan DECLARE_EVENT_CLASS(block_get_rq, 31355782138SLi Zefan 31455782138SLi Zefan TP_PROTO(struct request_queue *q, struct bio *bio, int rw), 31555782138SLi Zefan 31655782138SLi Zefan TP_ARGS(q, bio, rw), 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 ) 32255782138SLi Zefan __array( char, rwbs, 6 ) 32355782138SLi Zefan __array( char, comm, TASK_COMM_LEN ) 32455782138SLi Zefan ), 32555782138SLi Zefan 32655782138SLi Zefan TP_fast_assign( 32755782138SLi Zefan __entry->dev = bio ? bio->bi_bdev->bd_dev : 0; 32855782138SLi Zefan __entry->sector = bio ? bio->bi_sector : 0; 32955782138SLi Zefan __entry->nr_sector = bio ? bio->bi_size >> 9 : 0; 33055782138SLi Zefan blk_fill_rwbs(__entry->rwbs, 33155782138SLi Zefan bio ? bio->bi_rw : 0, __entry->nr_sector); 33255782138SLi Zefan memcpy(__entry->comm, current->comm, TASK_COMM_LEN); 33355782138SLi Zefan ), 33455782138SLi Zefan 33555782138SLi Zefan TP_printk("%d,%d %s %llu + %u [%s]", 33655782138SLi Zefan MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, 3376556d1dfSSteven Rostedt (unsigned long long)__entry->sector, 3386556d1dfSSteven Rostedt __entry->nr_sector, __entry->comm) 33955782138SLi Zefan ); 34055782138SLi Zefan 341881245dcSWilliam Cohen /** 342881245dcSWilliam Cohen * block_getrq - get a free request entry in queue for block IO operations 343881245dcSWilliam Cohen * @q: queue for operations 344881245dcSWilliam Cohen * @bio: pending block IO operation 345881245dcSWilliam Cohen * @rw: low bit indicates a read (%0) or a write (%1) 346881245dcSWilliam Cohen * 347881245dcSWilliam Cohen * A request struct for queue @q has been allocated to handle the 348881245dcSWilliam Cohen * block IO operation @bio. 349881245dcSWilliam Cohen */ 35077ca1e02SLi Zefan DEFINE_EVENT(block_get_rq, block_getrq, 35155782138SLi Zefan 35255782138SLi Zefan TP_PROTO(struct request_queue *q, struct bio *bio, int rw), 35355782138SLi Zefan 35477ca1e02SLi Zefan TP_ARGS(q, bio, rw) 35577ca1e02SLi Zefan ); 35655782138SLi Zefan 357881245dcSWilliam Cohen /** 358881245dcSWilliam Cohen * block_sleeprq - waiting to get a free request entry in queue for block IO operation 359881245dcSWilliam Cohen * @q: queue for operation 360881245dcSWilliam Cohen * @bio: pending block IO operation 361881245dcSWilliam Cohen * @rw: low bit indicates a read (%0) or a write (%1) 362881245dcSWilliam Cohen * 363881245dcSWilliam Cohen * In the case where a request struct cannot be provided for queue @q 364881245dcSWilliam Cohen * the process needs to wait for an request struct to become 365881245dcSWilliam Cohen * available. This tracepoint event is generated each time the 366881245dcSWilliam Cohen * process goes to sleep waiting for request struct become available. 367881245dcSWilliam Cohen */ 36877ca1e02SLi Zefan DEFINE_EVENT(block_get_rq, block_sleeprq, 36955782138SLi Zefan 37077ca1e02SLi Zefan TP_PROTO(struct request_queue *q, struct bio *bio, int rw), 37155782138SLi Zefan 37277ca1e02SLi Zefan TP_ARGS(q, bio, rw) 37355782138SLi Zefan ); 37455782138SLi Zefan 375881245dcSWilliam Cohen /** 376881245dcSWilliam Cohen * block_plug - keep operations requests in request queue 377881245dcSWilliam Cohen * @q: request queue to plug 378881245dcSWilliam Cohen * 379881245dcSWilliam Cohen * Plug the request queue @q. Do not allow block operation requests 380881245dcSWilliam Cohen * to be sent to the device driver. Instead, accumulate requests in 381881245dcSWilliam Cohen * the queue to improve throughput performance of the block device. 382881245dcSWilliam Cohen */ 38355782138SLi Zefan TRACE_EVENT(block_plug, 38455782138SLi Zefan 38555782138SLi Zefan TP_PROTO(struct request_queue *q), 38655782138SLi Zefan 38755782138SLi Zefan TP_ARGS(q), 38855782138SLi Zefan 38955782138SLi Zefan TP_STRUCT__entry( 39055782138SLi Zefan __array( char, comm, TASK_COMM_LEN ) 39155782138SLi Zefan ), 39255782138SLi Zefan 39355782138SLi Zefan TP_fast_assign( 39455782138SLi Zefan memcpy(__entry->comm, current->comm, TASK_COMM_LEN); 39555782138SLi Zefan ), 39655782138SLi Zefan 39755782138SLi Zefan TP_printk("[%s]", __entry->comm) 39855782138SLi Zefan ); 39955782138SLi Zefan 40077ca1e02SLi Zefan DECLARE_EVENT_CLASS(block_unplug, 40155782138SLi Zefan 40255782138SLi Zefan TP_PROTO(struct request_queue *q), 40355782138SLi Zefan 40455782138SLi Zefan TP_ARGS(q), 40555782138SLi Zefan 40655782138SLi Zefan TP_STRUCT__entry( 40755782138SLi Zefan __field( int, nr_rq ) 40855782138SLi Zefan __array( char, comm, TASK_COMM_LEN ) 40955782138SLi Zefan ), 41055782138SLi Zefan 41155782138SLi Zefan TP_fast_assign( 41255782138SLi Zefan __entry->nr_rq = q->rq.count[READ] + q->rq.count[WRITE]; 41355782138SLi Zefan memcpy(__entry->comm, current->comm, TASK_COMM_LEN); 41455782138SLi Zefan ), 41555782138SLi Zefan 41655782138SLi Zefan TP_printk("[%s] %d", __entry->comm, __entry->nr_rq) 41755782138SLi Zefan ); 41855782138SLi Zefan 419881245dcSWilliam Cohen /** 420881245dcSWilliam Cohen * block_unplug_timer - timed release of operations requests in queue to device driver 421881245dcSWilliam Cohen * @q: request queue to unplug 422881245dcSWilliam Cohen * 423881245dcSWilliam Cohen * Unplug the request queue @q because a timer expired and allow block 424881245dcSWilliam Cohen * operation requests to be sent to the device driver. 425881245dcSWilliam Cohen */ 42677ca1e02SLi Zefan DEFINE_EVENT(block_unplug, block_unplug_timer, 42755782138SLi Zefan 42855782138SLi Zefan TP_PROTO(struct request_queue *q), 42955782138SLi Zefan 43077ca1e02SLi Zefan TP_ARGS(q) 43177ca1e02SLi Zefan ); 43255782138SLi Zefan 433881245dcSWilliam Cohen /** 434881245dcSWilliam Cohen * block_unplug_io - release of operations requests in request queue 435881245dcSWilliam Cohen * @q: request queue to unplug 436881245dcSWilliam Cohen * 437881245dcSWilliam Cohen * Unplug request queue @q because device driver is scheduled to work 438881245dcSWilliam Cohen * on elements in the request queue. 439881245dcSWilliam Cohen */ 44077ca1e02SLi Zefan DEFINE_EVENT(block_unplug, block_unplug_io, 44155782138SLi Zefan 44277ca1e02SLi Zefan TP_PROTO(struct request_queue *q), 44355782138SLi Zefan 44477ca1e02SLi Zefan TP_ARGS(q) 44555782138SLi Zefan ); 44655782138SLi Zefan 447881245dcSWilliam Cohen /** 448881245dcSWilliam Cohen * block_split - split a single bio struct into two bio structs 449881245dcSWilliam Cohen * @q: queue containing the bio 450881245dcSWilliam Cohen * @bio: block operation being split 451881245dcSWilliam Cohen * @new_sector: The starting sector for the new bio 452881245dcSWilliam Cohen * 453881245dcSWilliam Cohen * The bio request @bio in request queue @q needs to be split into two 454881245dcSWilliam Cohen * bio requests. The newly created @bio request starts at 455881245dcSWilliam Cohen * @new_sector. This split may be required due to hardware limitation 456881245dcSWilliam Cohen * such as operation crossing device boundaries in a RAID system. 457881245dcSWilliam Cohen */ 45855782138SLi Zefan TRACE_EVENT(block_split, 45955782138SLi Zefan 46055782138SLi Zefan TP_PROTO(struct request_queue *q, struct bio *bio, 46155782138SLi Zefan unsigned int new_sector), 46255782138SLi Zefan 46355782138SLi Zefan TP_ARGS(q, bio, new_sector), 46455782138SLi Zefan 46555782138SLi Zefan TP_STRUCT__entry( 46655782138SLi Zefan __field( dev_t, dev ) 46755782138SLi Zefan __field( sector_t, sector ) 46855782138SLi Zefan __field( sector_t, new_sector ) 46955782138SLi Zefan __array( char, rwbs, 6 ) 47055782138SLi Zefan __array( char, comm, TASK_COMM_LEN ) 47155782138SLi Zefan ), 47255782138SLi Zefan 47355782138SLi Zefan TP_fast_assign( 47455782138SLi Zefan __entry->dev = bio->bi_bdev->bd_dev; 47555782138SLi Zefan __entry->sector = bio->bi_sector; 47655782138SLi Zefan __entry->new_sector = new_sector; 47755782138SLi Zefan blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size); 47855782138SLi Zefan memcpy(__entry->comm, current->comm, TASK_COMM_LEN); 47955782138SLi Zefan ), 48055782138SLi Zefan 48155782138SLi Zefan TP_printk("%d,%d %s %llu / %llu [%s]", 48255782138SLi Zefan MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, 4836556d1dfSSteven Rostedt (unsigned long long)__entry->sector, 4846556d1dfSSteven Rostedt (unsigned long long)__entry->new_sector, 4856556d1dfSSteven Rostedt __entry->comm) 48655782138SLi Zefan ); 48755782138SLi Zefan 488881245dcSWilliam Cohen /** 489*d07335e5SMike Snitzer * block_bio_remap - map request for a logical device to the raw device 490881245dcSWilliam Cohen * @q: queue holding the operation 491881245dcSWilliam Cohen * @bio: revised operation 492881245dcSWilliam Cohen * @dev: device for the operation 493881245dcSWilliam Cohen * @from: original sector for the operation 494881245dcSWilliam Cohen * 495*d07335e5SMike Snitzer * An operation for a logical device has been mapped to the 496881245dcSWilliam Cohen * raw block device. 497881245dcSWilliam Cohen */ 498*d07335e5SMike Snitzer TRACE_EVENT(block_bio_remap, 49955782138SLi Zefan 50055782138SLi Zefan TP_PROTO(struct request_queue *q, struct bio *bio, dev_t dev, 50155782138SLi Zefan sector_t from), 50255782138SLi Zefan 50355782138SLi Zefan TP_ARGS(q, bio, dev, from), 50455782138SLi Zefan 50555782138SLi Zefan TP_STRUCT__entry( 50655782138SLi Zefan __field( dev_t, dev ) 50755782138SLi Zefan __field( sector_t, sector ) 50855782138SLi Zefan __field( unsigned int, nr_sector ) 50955782138SLi Zefan __field( dev_t, old_dev ) 51055782138SLi Zefan __field( sector_t, old_sector ) 51155782138SLi Zefan __array( char, rwbs, 6 ) 51255782138SLi Zefan ), 51355782138SLi Zefan 51455782138SLi Zefan TP_fast_assign( 51555782138SLi Zefan __entry->dev = bio->bi_bdev->bd_dev; 51655782138SLi Zefan __entry->sector = bio->bi_sector; 51755782138SLi Zefan __entry->nr_sector = bio->bi_size >> 9; 51855782138SLi Zefan __entry->old_dev = dev; 51955782138SLi Zefan __entry->old_sector = from; 52055782138SLi Zefan blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size); 52155782138SLi Zefan ), 52255782138SLi Zefan 52355782138SLi Zefan TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu", 52455782138SLi Zefan MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, 5256556d1dfSSteven Rostedt (unsigned long long)__entry->sector, 5266556d1dfSSteven Rostedt __entry->nr_sector, 52755782138SLi Zefan MAJOR(__entry->old_dev), MINOR(__entry->old_dev), 5286556d1dfSSteven Rostedt (unsigned long long)__entry->old_sector) 52955782138SLi Zefan ); 53055782138SLi Zefan 531881245dcSWilliam Cohen /** 532881245dcSWilliam Cohen * block_rq_remap - map request for a block operation request 533881245dcSWilliam Cohen * @q: queue holding the operation 534881245dcSWilliam Cohen * @rq: block IO operation request 535881245dcSWilliam Cohen * @dev: device for the operation 536881245dcSWilliam Cohen * @from: original sector for the operation 537881245dcSWilliam Cohen * 538881245dcSWilliam Cohen * The block operation request @rq in @q has been remapped. The block 539881245dcSWilliam Cohen * operation request @rq holds the current information and @from hold 540881245dcSWilliam Cohen * the original sector. 541881245dcSWilliam Cohen */ 542b0da3f0dSJun'ichi Nomura TRACE_EVENT(block_rq_remap, 543b0da3f0dSJun'ichi Nomura 544b0da3f0dSJun'ichi Nomura TP_PROTO(struct request_queue *q, struct request *rq, dev_t dev, 545b0da3f0dSJun'ichi Nomura sector_t from), 546b0da3f0dSJun'ichi Nomura 547b0da3f0dSJun'ichi Nomura TP_ARGS(q, rq, dev, from), 548b0da3f0dSJun'ichi Nomura 549b0da3f0dSJun'ichi Nomura TP_STRUCT__entry( 550b0da3f0dSJun'ichi Nomura __field( dev_t, dev ) 551b0da3f0dSJun'ichi Nomura __field( sector_t, sector ) 552b0da3f0dSJun'ichi Nomura __field( unsigned int, nr_sector ) 553b0da3f0dSJun'ichi Nomura __field( dev_t, old_dev ) 554b0da3f0dSJun'ichi Nomura __field( sector_t, old_sector ) 555b0da3f0dSJun'ichi Nomura __array( char, rwbs, 6 ) 556b0da3f0dSJun'ichi Nomura ), 557b0da3f0dSJun'ichi Nomura 558b0da3f0dSJun'ichi Nomura TP_fast_assign( 559b0da3f0dSJun'ichi Nomura __entry->dev = disk_devt(rq->rq_disk); 560b0da3f0dSJun'ichi Nomura __entry->sector = blk_rq_pos(rq); 561b0da3f0dSJun'ichi Nomura __entry->nr_sector = blk_rq_sectors(rq); 562b0da3f0dSJun'ichi Nomura __entry->old_dev = dev; 563b0da3f0dSJun'ichi Nomura __entry->old_sector = from; 564b0da3f0dSJun'ichi Nomura blk_fill_rwbs_rq(__entry->rwbs, rq); 565b0da3f0dSJun'ichi Nomura ), 566b0da3f0dSJun'ichi Nomura 567b0da3f0dSJun'ichi Nomura TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu", 568b0da3f0dSJun'ichi Nomura MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, 569b0da3f0dSJun'ichi Nomura (unsigned long long)__entry->sector, 570b0da3f0dSJun'ichi Nomura __entry->nr_sector, 571b0da3f0dSJun'ichi Nomura MAJOR(__entry->old_dev), MINOR(__entry->old_dev), 572b0da3f0dSJun'ichi Nomura (unsigned long long)__entry->old_sector) 573b0da3f0dSJun'ichi Nomura ); 574b0da3f0dSJun'ichi Nomura 57555782138SLi Zefan #endif /* _TRACE_BLOCK_H */ 57655782138SLi Zefan 57755782138SLi Zefan /* This part must be outside protection */ 57855782138SLi Zefan #include <trace/define_trace.h> 57955782138SLi Zefan 580