diff options
author | Jun'ichi Nomura <j-nomura@ce.jp.nec.com> | 2009-10-01 15:16:13 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2009-10-01 15:19:34 -0400 |
commit | b0da3f0dada78832c9da03ad2152ae76bd9a2496 (patch) | |
tree | 58380f5d8f3c313fbb9fd0310509a408b38a0399 | |
parent | 67efc9258010da35b27b3854d0880c7e193004ed (diff) |
Add a tracepoint for block request remapping
Since 2.6.31 now has request-based device-mapper, it's useful to have
a tracepoint for request-remapping as well as bio-remapping.
This patch adds a tracepoint for request-remapping, trace_block_rq_remap().
Signed-off-by: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>
Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Cc: Alasdair G Kergon <agk@redhat.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-rw-r--r-- | block/blk-core.c | 1 | ||||
-rw-r--r-- | include/linux/blktrace_api.h | 2 | ||||
-rw-r--r-- | include/trace/events/block.h | 33 | ||||
-rw-r--r-- | kernel/trace/blktrace.c | 34 |
4 files changed, 69 insertions, 1 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index 34504f309728..ddaaea4fdffc 100644 --- a/block/blk-core.c +++ b/block/blk-core.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include "blk.h" | 34 | #include "blk.h" |
35 | 35 | ||
36 | EXPORT_TRACEPOINT_SYMBOL_GPL(block_remap); | 36 | EXPORT_TRACEPOINT_SYMBOL_GPL(block_remap); |
37 | EXPORT_TRACEPOINT_SYMBOL_GPL(block_rq_remap); | ||
37 | EXPORT_TRACEPOINT_SYMBOL_GPL(block_bio_complete); | 38 | EXPORT_TRACEPOINT_SYMBOL_GPL(block_bio_complete); |
38 | 39 | ||
39 | static int __make_request(struct request_queue *q, struct bio *bio); | 40 | static int __make_request(struct request_queue *q, struct bio *bio); |
diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h index 622939a23299..3b73b9992b26 100644 --- a/include/linux/blktrace_api.h +++ b/include/linux/blktrace_api.h | |||
@@ -212,7 +212,7 @@ extern struct attribute_group blk_trace_attr_group; | |||
212 | # define blk_trace_startstop(q, start) (-ENOTTY) | 212 | # define blk_trace_startstop(q, start) (-ENOTTY) |
213 | # define blk_trace_remove(q) (-ENOTTY) | 213 | # define blk_trace_remove(q) (-ENOTTY) |
214 | # define blk_add_trace_msg(q, fmt, ...) do { } while (0) | 214 | # define blk_add_trace_msg(q, fmt, ...) do { } while (0) |
215 | # define blk_trace_remove_sysfs(struct device *dev) do { } while (0) | 215 | # define blk_trace_remove_sysfs(dev) do { } while (0) |
216 | static inline int blk_trace_init_sysfs(struct device *dev) | 216 | static inline int blk_trace_init_sysfs(struct device *dev) |
217 | { | 217 | { |
218 | return 0; | 218 | return 0; |
diff --git a/include/trace/events/block.h b/include/trace/events/block.h index d86af94691c2..00405b5f624a 100644 --- a/include/trace/events/block.h +++ b/include/trace/events/block.h | |||
@@ -488,6 +488,39 @@ TRACE_EVENT(block_remap, | |||
488 | (unsigned long long)__entry->old_sector) | 488 | (unsigned long long)__entry->old_sector) |
489 | ); | 489 | ); |
490 | 490 | ||
491 | TRACE_EVENT(block_rq_remap, | ||
492 | |||
493 | TP_PROTO(struct request_queue *q, struct request *rq, dev_t dev, | ||
494 | sector_t from), | ||
495 | |||
496 | TP_ARGS(q, rq, dev, from), | ||
497 | |||
498 | TP_STRUCT__entry( | ||
499 | __field( dev_t, dev ) | ||
500 | __field( sector_t, sector ) | ||
501 | __field( unsigned int, nr_sector ) | ||
502 | __field( dev_t, old_dev ) | ||
503 | __field( sector_t, old_sector ) | ||
504 | __array( char, rwbs, 6 ) | ||
505 | ), | ||
506 | |||
507 | TP_fast_assign( | ||
508 | __entry->dev = disk_devt(rq->rq_disk); | ||
509 | __entry->sector = blk_rq_pos(rq); | ||
510 | __entry->nr_sector = blk_rq_sectors(rq); | ||
511 | __entry->old_dev = dev; | ||
512 | __entry->old_sector = from; | ||
513 | blk_fill_rwbs_rq(__entry->rwbs, rq); | ||
514 | ), | ||
515 | |||
516 | TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu", | ||
517 | MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs, | ||
518 | (unsigned long long)__entry->sector, | ||
519 | __entry->nr_sector, | ||
520 | MAJOR(__entry->old_dev), MINOR(__entry->old_dev), | ||
521 | (unsigned long long)__entry->old_sector) | ||
522 | ); | ||
523 | |||
491 | #endif /* _TRACE_BLOCK_H */ | 524 | #endif /* _TRACE_BLOCK_H */ |
492 | 525 | ||
493 | /* This part must be outside protection */ | 526 | /* This part must be outside protection */ |
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index 60b5c5a3d4b4..d9d6206e0b14 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c | |||
@@ -856,6 +856,37 @@ static void blk_add_trace_remap(struct request_queue *q, struct bio *bio, | |||
856 | } | 856 | } |
857 | 857 | ||
858 | /** | 858 | /** |
859 | * blk_add_trace_rq_remap - Add a trace for a request-remap operation | ||
860 | * @q: queue the io is for | ||
861 | * @rq: the source request | ||
862 | * @dev: target device | ||
863 | * @from: source sector | ||
864 | * | ||
865 | * Description: | ||
866 | * Device mapper remaps request to other devices. | ||
867 | * Add a trace for that action. | ||
868 | * | ||
869 | **/ | ||
870 | static void blk_add_trace_rq_remap(struct request_queue *q, | ||
871 | struct request *rq, dev_t dev, | ||
872 | sector_t from) | ||
873 | { | ||
874 | struct blk_trace *bt = q->blk_trace; | ||
875 | struct blk_io_trace_remap r; | ||
876 | |||
877 | if (likely(!bt)) | ||
878 | return; | ||
879 | |||
880 | r.device_from = cpu_to_be32(dev); | ||
881 | r.device_to = cpu_to_be32(disk_devt(rq->rq_disk)); | ||
882 | r.sector_from = cpu_to_be64(from); | ||
883 | |||
884 | __blk_add_trace(bt, blk_rq_pos(rq), blk_rq_bytes(rq), | ||
885 | rq_data_dir(rq), BLK_TA_REMAP, !!rq->errors, | ||
886 | sizeof(r), &r); | ||
887 | } | ||
888 | |||
889 | /** | ||
859 | * blk_add_driver_data - Add binary message with driver-specific data | 890 | * blk_add_driver_data - Add binary message with driver-specific data |
860 | * @q: queue the io is for | 891 | * @q: queue the io is for |
861 | * @rq: io request | 892 | * @rq: io request |
@@ -922,10 +953,13 @@ static void blk_register_tracepoints(void) | |||
922 | WARN_ON(ret); | 953 | WARN_ON(ret); |
923 | ret = register_trace_block_remap(blk_add_trace_remap); | 954 | ret = register_trace_block_remap(blk_add_trace_remap); |
924 | WARN_ON(ret); | 955 | WARN_ON(ret); |
956 | ret = register_trace_block_rq_remap(blk_add_trace_rq_remap); | ||
957 | WARN_ON(ret); | ||
925 | } | 958 | } |
926 | 959 | ||
927 | static void blk_unregister_tracepoints(void) | 960 | static void blk_unregister_tracepoints(void) |
928 | { | 961 | { |
962 | unregister_trace_block_rq_remap(blk_add_trace_rq_remap); | ||
929 | unregister_trace_block_remap(blk_add_trace_remap); | 963 | unregister_trace_block_remap(blk_add_trace_remap); |
930 | unregister_trace_block_split(blk_add_trace_split); | 964 | unregister_trace_block_split(blk_add_trace_split); |
931 | unregister_trace_block_unplug_io(blk_add_trace_unplug_io); | 965 | unregister_trace_block_unplug_io(blk_add_trace_unplug_io); |