aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--block/blk-core.c2
-rw-r--r--block/blk-mq.c2
-rw-r--r--include/trace/events/block.h33
-rw-r--r--kernel/trace/blktrace.c20
4 files changed, 43 insertions, 14 deletions
diff --git a/block/blk-core.c b/block/blk-core.c
index 853f92749202..99e20cca37e1 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -2354,7 +2354,7 @@ bool blk_update_request(struct request *req, int error, unsigned int nr_bytes)
2354 if (!req->bio) 2354 if (!req->bio)
2355 return false; 2355 return false;
2356 2356
2357 trace_block_rq_complete(req->q, req); 2357 trace_block_rq_complete(req->q, req, nr_bytes);
2358 2358
2359 /* 2359 /*
2360 * For fs requests, rq is just carrier of independent bio's 2360 * For fs requests, rq is just carrier of independent bio's
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 6468a715a0e4..01d8735db8d3 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -309,7 +309,7 @@ void blk_mq_end_io(struct request *rq, int error)
309 struct bio *bio = rq->bio; 309 struct bio *bio = rq->bio;
310 unsigned int bytes = 0; 310 unsigned int bytes = 0;
311 311
312 trace_block_rq_complete(rq->q, rq); 312 trace_block_rq_complete(rq->q, rq, blk_rq_bytes(rq));
313 313
314 while (bio) { 314 while (bio) {
315 struct bio *next = bio->bi_next; 315 struct bio *next = bio->bi_next;
diff --git a/include/trace/events/block.h b/include/trace/events/block.h
index e76ae19a8d6f..e8a5eca1dbe5 100644
--- a/include/trace/events/block.h
+++ b/include/trace/events/block.h
@@ -132,6 +132,7 @@ DEFINE_EVENT(block_rq_with_error, block_rq_requeue,
132 * block_rq_complete - block IO operation completed by device driver 132 * block_rq_complete - block IO operation completed by device driver
133 * @q: queue containing the block operation request 133 * @q: queue containing the block operation request
134 * @rq: block operations request 134 * @rq: block operations request
135 * @nr_bytes: number of completed bytes
135 * 136 *
136 * The block_rq_complete tracepoint event indicates that some portion 137 * The block_rq_complete tracepoint event indicates that some portion
137 * of operation request has been completed by the device driver. If 138 * of operation request has been completed by the device driver. If
@@ -139,11 +140,37 @@ DEFINE_EVENT(block_rq_with_error, block_rq_requeue,
139 * do for the request. If @rq->bio is non-NULL then there is 140 * do for the request. If @rq->bio is non-NULL then there is
140 * additional work required to complete the request. 141 * additional work required to complete the request.
141 */ 142 */
142DEFINE_EVENT(block_rq_with_error, block_rq_complete, 143TRACE_EVENT(block_rq_complete,
143 144
144 TP_PROTO(struct request_queue *q, struct request *rq), 145 TP_PROTO(struct request_queue *q, struct request *rq,
146 unsigned int nr_bytes),
145 147
146 TP_ARGS(q, rq) 148 TP_ARGS(q, rq, nr_bytes),
149
150 TP_STRUCT__entry(
151 __field( dev_t, dev )
152 __field( sector_t, sector )
153 __field( unsigned int, nr_sector )
154 __field( int, errors )
155 __array( char, rwbs, RWBS_LEN )
156 __dynamic_array( char, cmd, blk_cmd_buf_len(rq) )
157 ),
158
159 TP_fast_assign(
160 __entry->dev = rq->rq_disk ? disk_devt(rq->rq_disk) : 0;
161 __entry->sector = blk_rq_pos(rq);
162 __entry->nr_sector = nr_bytes >> 9;
163 __entry->errors = rq->errors;
164
165 blk_fill_rwbs(__entry->rwbs, rq->cmd_flags, nr_bytes);
166 blk_dump_cmd(__get_str(cmd), rq);
167 ),
168
169 TP_printk("%d,%d %s (%s) %llu + %u [%d]",
170 MAJOR(__entry->dev), MINOR(__entry->dev),
171 __entry->rwbs, __get_str(cmd),
172 (unsigned long long)__entry->sector,
173 __entry->nr_sector, __entry->errors)
147); 174);
148 175
149DECLARE_EVENT_CLASS(block_rq, 176DECLARE_EVENT_CLASS(block_rq,
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index b418cb0d7242..4f3a3c03eadb 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -702,6 +702,7 @@ void blk_trace_shutdown(struct request_queue *q)
702 * blk_add_trace_rq - Add a trace for a request oriented action 702 * blk_add_trace_rq - Add a trace for a request oriented action
703 * @q: queue the io is for 703 * @q: queue the io is for
704 * @rq: the source request 704 * @rq: the source request
705 * @nr_bytes: number of completed bytes
705 * @what: the action 706 * @what: the action
706 * 707 *
707 * Description: 708 * Description:
@@ -709,7 +710,7 @@ void blk_trace_shutdown(struct request_queue *q)
709 * 710 *
710 **/ 711 **/
711static void blk_add_trace_rq(struct request_queue *q, struct request *rq, 712static void blk_add_trace_rq(struct request_queue *q, struct request *rq,
712 u32 what) 713 unsigned int nr_bytes, u32 what)
713{ 714{
714 struct blk_trace *bt = q->blk_trace; 715 struct blk_trace *bt = q->blk_trace;
715 716
@@ -718,11 +719,11 @@ static void blk_add_trace_rq(struct request_queue *q, struct request *rq,
718 719
719 if (rq->cmd_type == REQ_TYPE_BLOCK_PC) { 720 if (rq->cmd_type == REQ_TYPE_BLOCK_PC) {
720 what |= BLK_TC_ACT(BLK_TC_PC); 721 what |= BLK_TC_ACT(BLK_TC_PC);
721 __blk_add_trace(bt, 0, blk_rq_bytes(rq), rq->cmd_flags, 722 __blk_add_trace(bt, 0, nr_bytes, rq->cmd_flags,
722 what, rq->errors, rq->cmd_len, rq->cmd); 723 what, rq->errors, rq->cmd_len, rq->cmd);
723 } else { 724 } else {
724 what |= BLK_TC_ACT(BLK_TC_FS); 725 what |= BLK_TC_ACT(BLK_TC_FS);
725 __blk_add_trace(bt, blk_rq_pos(rq), blk_rq_bytes(rq), 726 __blk_add_trace(bt, blk_rq_pos(rq), nr_bytes,
726 rq->cmd_flags, what, rq->errors, 0, NULL); 727 rq->cmd_flags, what, rq->errors, 0, NULL);
727 } 728 }
728} 729}
@@ -730,33 +731,34 @@ static void blk_add_trace_rq(struct request_queue *q, struct request *rq,
730static void blk_add_trace_rq_abort(void *ignore, 731static void blk_add_trace_rq_abort(void *ignore,
731 struct request_queue *q, struct request *rq) 732 struct request_queue *q, struct request *rq)
732{ 733{
733 blk_add_trace_rq(q, rq, BLK_TA_ABORT); 734 blk_add_trace_rq(q, rq, blk_rq_bytes(rq), BLK_TA_ABORT);
734} 735}
735 736
736static void blk_add_trace_rq_insert(void *ignore, 737static void blk_add_trace_rq_insert(void *ignore,
737 struct request_queue *q, struct request *rq) 738 struct request_queue *q, struct request *rq)
738{ 739{
739 blk_add_trace_rq(q, rq, BLK_TA_INSERT); 740 blk_add_trace_rq(q, rq, blk_rq_bytes(rq), BLK_TA_INSERT);
740} 741}
741 742
742static void blk_add_trace_rq_issue(void *ignore, 743static void blk_add_trace_rq_issue(void *ignore,
743 struct request_queue *q, struct request *rq) 744 struct request_queue *q, struct request *rq)
744{ 745{
745 blk_add_trace_rq(q, rq, BLK_TA_ISSUE); 746 blk_add_trace_rq(q, rq, blk_rq_bytes(rq), BLK_TA_ISSUE);
746} 747}
747 748
748static void blk_add_trace_rq_requeue(void *ignore, 749static void blk_add_trace_rq_requeue(void *ignore,
749 struct request_queue *q, 750 struct request_queue *q,
750 struct request *rq) 751 struct request *rq)
751{ 752{
752 blk_add_trace_rq(q, rq, BLK_TA_REQUEUE); 753 blk_add_trace_rq(q, rq, blk_rq_bytes(rq), BLK_TA_REQUEUE);
753} 754}
754 755
755static void blk_add_trace_rq_complete(void *ignore, 756static void blk_add_trace_rq_complete(void *ignore,
756 struct request_queue *q, 757 struct request_queue *q,
757 struct request *rq) 758 struct request *rq,
759 unsigned int nr_bytes)
758{ 760{
759 blk_add_trace_rq(q, rq, BLK_TA_COMPLETE); 761 blk_add_trace_rq(q, rq, nr_bytes, BLK_TA_COMPLETE);
760} 762}
761 763
762/** 764/**