diff options
Diffstat (limited to 'kernel/trace/blktrace.c')
-rw-r--r-- | kernel/trace/blktrace.c | 78 |
1 files changed, 77 insertions, 1 deletions
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index e3abf55bc8e5..7bd6a9893c24 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c | |||
@@ -23,10 +23,14 @@ | |||
23 | #include <linux/mutex.h> | 23 | #include <linux/mutex.h> |
24 | #include <linux/debugfs.h> | 24 | #include <linux/debugfs.h> |
25 | #include <linux/time.h> | 25 | #include <linux/time.h> |
26 | #include <trace/block.h> | ||
27 | #include <linux/uaccess.h> | 26 | #include <linux/uaccess.h> |
27 | |||
28 | #include <trace/events/block.h> | ||
29 | |||
28 | #include "trace_output.h" | 30 | #include "trace_output.h" |
29 | 31 | ||
32 | #ifdef CONFIG_BLK_DEV_IO_TRACE | ||
33 | |||
30 | static unsigned int blktrace_seq __read_mostly = 1; | 34 | static unsigned int blktrace_seq __read_mostly = 1; |
31 | 35 | ||
32 | static struct trace_array *blk_tr; | 36 | static struct trace_array *blk_tr; |
@@ -1658,3 +1662,75 @@ int blk_trace_init_sysfs(struct device *dev) | |||
1658 | return sysfs_create_group(&dev->kobj, &blk_trace_attr_group); | 1662 | return sysfs_create_group(&dev->kobj, &blk_trace_attr_group); |
1659 | } | 1663 | } |
1660 | 1664 | ||
1665 | #endif /* CONFIG_BLK_DEV_IO_TRACE */ | ||
1666 | |||
1667 | #ifdef CONFIG_EVENT_TRACING | ||
1668 | |||
1669 | void blk_dump_cmd(char *buf, struct request *rq) | ||
1670 | { | ||
1671 | int i, end; | ||
1672 | int len = rq->cmd_len; | ||
1673 | unsigned char *cmd = rq->cmd; | ||
1674 | |||
1675 | if (!blk_pc_request(rq)) { | ||
1676 | buf[0] = '\0'; | ||
1677 | return; | ||
1678 | } | ||
1679 | |||
1680 | for (end = len - 1; end >= 0; end--) | ||
1681 | if (cmd[end]) | ||
1682 | break; | ||
1683 | end++; | ||
1684 | |||
1685 | for (i = 0; i < len; i++) { | ||
1686 | buf += sprintf(buf, "%s%02x", i == 0 ? "" : " ", cmd[i]); | ||
1687 | if (i == end && end != len - 1) { | ||
1688 | sprintf(buf, " .."); | ||
1689 | break; | ||
1690 | } | ||
1691 | } | ||
1692 | } | ||
1693 | |||
1694 | void blk_fill_rwbs(char *rwbs, u32 rw, int bytes) | ||
1695 | { | ||
1696 | int i = 0; | ||
1697 | |||
1698 | if (rw & WRITE) | ||
1699 | rwbs[i++] = 'W'; | ||
1700 | else if (rw & 1 << BIO_RW_DISCARD) | ||
1701 | rwbs[i++] = 'D'; | ||
1702 | else if (bytes) | ||
1703 | rwbs[i++] = 'R'; | ||
1704 | else | ||
1705 | rwbs[i++] = 'N'; | ||
1706 | |||
1707 | if (rw & 1 << BIO_RW_AHEAD) | ||
1708 | rwbs[i++] = 'A'; | ||
1709 | if (rw & 1 << BIO_RW_BARRIER) | ||
1710 | rwbs[i++] = 'B'; | ||
1711 | if (rw & 1 << BIO_RW_SYNCIO) | ||
1712 | rwbs[i++] = 'S'; | ||
1713 | if (rw & 1 << BIO_RW_META) | ||
1714 | rwbs[i++] = 'M'; | ||
1715 | |||
1716 | rwbs[i] = '\0'; | ||
1717 | } | ||
1718 | |||
1719 | void blk_fill_rwbs_rq(char *rwbs, struct request *rq) | ||
1720 | { | ||
1721 | int rw = rq->cmd_flags & 0x03; | ||
1722 | int bytes; | ||
1723 | |||
1724 | if (blk_discard_rq(rq)) | ||
1725 | rw |= (1 << BIO_RW_DISCARD); | ||
1726 | |||
1727 | if (blk_pc_request(rq)) | ||
1728 | bytes = rq->data_len; | ||
1729 | else | ||
1730 | bytes = rq->hard_nr_sectors << 9; | ||
1731 | |||
1732 | blk_fill_rwbs(rwbs, rw, bytes); | ||
1733 | } | ||
1734 | |||
1735 | #endif /* CONFIG_EVENT_TRACING */ | ||
1736 | |||