diff options
Diffstat (limited to 'kernel/trace/blktrace.c')
-rw-r--r-- | kernel/trace/blktrace.c | 98 |
1 files changed, 71 insertions, 27 deletions
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index 638711c17504..7b8ec0281548 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c | |||
@@ -23,7 +23,6 @@ | |||
23 | #include <linux/mutex.h> | 23 | #include <linux/mutex.h> |
24 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
25 | #include <linux/debugfs.h> | 25 | #include <linux/debugfs.h> |
26 | #include <linux/smp_lock.h> | ||
27 | #include <linux/time.h> | 26 | #include <linux/time.h> |
28 | #include <linux/uaccess.h> | 27 | #include <linux/uaccess.h> |
29 | 28 | ||
@@ -169,9 +168,11 @@ static int act_log_check(struct blk_trace *bt, u32 what, sector_t sector, | |||
169 | static const u32 ddir_act[2] = { BLK_TC_ACT(BLK_TC_READ), | 168 | static const u32 ddir_act[2] = { BLK_TC_ACT(BLK_TC_READ), |
170 | BLK_TC_ACT(BLK_TC_WRITE) }; | 169 | BLK_TC_ACT(BLK_TC_WRITE) }; |
171 | 170 | ||
171 | #define BLK_TC_RAHEAD BLK_TC_AHEAD | ||
172 | |||
172 | /* The ilog2() calls fall out because they're constant */ | 173 | /* The ilog2() calls fall out because they're constant */ |
173 | #define MASK_TC_BIT(rw, __name) ((rw & (1 << BIO_RW_ ## __name)) << \ | 174 | #define MASK_TC_BIT(rw, __name) ((rw & REQ_ ## __name) << \ |
174 | (ilog2(BLK_TC_ ## __name) + BLK_TC_SHIFT - BIO_RW_ ## __name)) | 175 | (ilog2(BLK_TC_ ## __name) + BLK_TC_SHIFT - __REQ_ ## __name)) |
175 | 176 | ||
176 | /* | 177 | /* |
177 | * The worker for the various blk_add_trace*() types. Fills out a | 178 | * The worker for the various blk_add_trace*() types. Fills out a |
@@ -194,9 +195,8 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes, | |||
194 | return; | 195 | return; |
195 | 196 | ||
196 | what |= ddir_act[rw & WRITE]; | 197 | what |= ddir_act[rw & WRITE]; |
197 | what |= MASK_TC_BIT(rw, BARRIER); | 198 | what |= MASK_TC_BIT(rw, SYNC); |
198 | what |= MASK_TC_BIT(rw, SYNCIO); | 199 | what |= MASK_TC_BIT(rw, RAHEAD); |
199 | what |= MASK_TC_BIT(rw, AHEAD); | ||
200 | what |= MASK_TC_BIT(rw, META); | 200 | what |= MASK_TC_BIT(rw, META); |
201 | what |= MASK_TC_BIT(rw, DISCARD); | 201 | what |= MASK_TC_BIT(rw, DISCARD); |
202 | 202 | ||
@@ -323,6 +323,7 @@ static const struct file_operations blk_dropped_fops = { | |||
323 | .owner = THIS_MODULE, | 323 | .owner = THIS_MODULE, |
324 | .open = blk_dropped_open, | 324 | .open = blk_dropped_open, |
325 | .read = blk_dropped_read, | 325 | .read = blk_dropped_read, |
326 | .llseek = default_llseek, | ||
326 | }; | 327 | }; |
327 | 328 | ||
328 | static int blk_msg_open(struct inode *inode, struct file *filp) | 329 | static int blk_msg_open(struct inode *inode, struct file *filp) |
@@ -362,6 +363,7 @@ static const struct file_operations blk_msg_fops = { | |||
362 | .owner = THIS_MODULE, | 363 | .owner = THIS_MODULE, |
363 | .open = blk_msg_open, | 364 | .open = blk_msg_open, |
364 | .write = blk_msg_write, | 365 | .write = blk_msg_write, |
366 | .llseek = noop_llseek, | ||
365 | }; | 367 | }; |
366 | 368 | ||
367 | /* | 369 | /* |
@@ -549,6 +551,41 @@ int blk_trace_setup(struct request_queue *q, char *name, dev_t dev, | |||
549 | } | 551 | } |
550 | EXPORT_SYMBOL_GPL(blk_trace_setup); | 552 | EXPORT_SYMBOL_GPL(blk_trace_setup); |
551 | 553 | ||
554 | #if defined(CONFIG_COMPAT) && defined(CONFIG_X86_64) | ||
555 | static int compat_blk_trace_setup(struct request_queue *q, char *name, | ||
556 | dev_t dev, struct block_device *bdev, | ||
557 | char __user *arg) | ||
558 | { | ||
559 | struct blk_user_trace_setup buts; | ||
560 | struct compat_blk_user_trace_setup cbuts; | ||
561 | int ret; | ||
562 | |||
563 | if (copy_from_user(&cbuts, arg, sizeof(cbuts))) | ||
564 | return -EFAULT; | ||
565 | |||
566 | buts = (struct blk_user_trace_setup) { | ||
567 | .act_mask = cbuts.act_mask, | ||
568 | .buf_size = cbuts.buf_size, | ||
569 | .buf_nr = cbuts.buf_nr, | ||
570 | .start_lba = cbuts.start_lba, | ||
571 | .end_lba = cbuts.end_lba, | ||
572 | .pid = cbuts.pid, | ||
573 | }; | ||
574 | memcpy(&buts.name, &cbuts.name, 32); | ||
575 | |||
576 | ret = do_blk_trace_setup(q, name, dev, bdev, &buts); | ||
577 | if (ret) | ||
578 | return ret; | ||
579 | |||
580 | if (copy_to_user(arg, &buts.name, 32)) { | ||
581 | blk_trace_remove(q); | ||
582 | return -EFAULT; | ||
583 | } | ||
584 | |||
585 | return 0; | ||
586 | } | ||
587 | #endif | ||
588 | |||
552 | int blk_trace_startstop(struct request_queue *q, int start) | 589 | int blk_trace_startstop(struct request_queue *q, int start) |
553 | { | 590 | { |
554 | int ret; | 591 | int ret; |
@@ -608,6 +645,12 @@ int blk_trace_ioctl(struct block_device *bdev, unsigned cmd, char __user *arg) | |||
608 | bdevname(bdev, b); | 645 | bdevname(bdev, b); |
609 | ret = blk_trace_setup(q, b, bdev->bd_dev, bdev, arg); | 646 | ret = blk_trace_setup(q, b, bdev->bd_dev, bdev, arg); |
610 | break; | 647 | break; |
648 | #if defined(CONFIG_COMPAT) && defined(CONFIG_X86_64) | ||
649 | case BLKTRACESETUP32: | ||
650 | bdevname(bdev, b); | ||
651 | ret = compat_blk_trace_setup(q, b, bdev->bd_dev, bdev, arg); | ||
652 | break; | ||
653 | #endif | ||
611 | case BLKTRACESTART: | 654 | case BLKTRACESTART: |
612 | start = 1; | 655 | start = 1; |
613 | case BLKTRACESTOP: | 656 | case BLKTRACESTOP: |
@@ -661,10 +704,13 @@ static void blk_add_trace_rq(struct request_queue *q, struct request *rq, | |||
661 | if (likely(!bt)) | 704 | if (likely(!bt)) |
662 | return; | 705 | return; |
663 | 706 | ||
664 | if (blk_discard_rq(rq)) | 707 | if (rq->cmd_flags & REQ_DISCARD) |
665 | rw |= (1 << BIO_RW_DISCARD); | 708 | rw |= REQ_DISCARD; |
709 | |||
710 | if (rq->cmd_flags & REQ_SECURE) | ||
711 | rw |= REQ_SECURE; | ||
666 | 712 | ||
667 | if (blk_pc_request(rq)) { | 713 | if (rq->cmd_type == REQ_TYPE_BLOCK_PC) { |
668 | what |= BLK_TC_ACT(BLK_TC_PC); | 714 | what |= BLK_TC_ACT(BLK_TC_PC); |
669 | __blk_add_trace(bt, 0, blk_rq_bytes(rq), rw, | 715 | __blk_add_trace(bt, 0, blk_rq_bytes(rq), rw, |
670 | what, rq->errors, rq->cmd_len, rq->cmd); | 716 | what, rq->errors, rq->cmd_len, rq->cmd); |
@@ -925,7 +971,7 @@ void blk_add_driver_data(struct request_queue *q, | |||
925 | if (likely(!bt)) | 971 | if (likely(!bt)) |
926 | return; | 972 | return; |
927 | 973 | ||
928 | if (blk_pc_request(rq)) | 974 | if (rq->cmd_type == REQ_TYPE_BLOCK_PC) |
929 | __blk_add_trace(bt, 0, blk_rq_bytes(rq), 0, | 975 | __blk_add_trace(bt, 0, blk_rq_bytes(rq), 0, |
930 | BLK_TA_DRV_DATA, rq->errors, len, data); | 976 | BLK_TA_DRV_DATA, rq->errors, len, data); |
931 | else | 977 | else |
@@ -1603,10 +1649,9 @@ static ssize_t sysfs_blk_trace_attr_show(struct device *dev, | |||
1603 | struct block_device *bdev; | 1649 | struct block_device *bdev; |
1604 | ssize_t ret = -ENXIO; | 1650 | ssize_t ret = -ENXIO; |
1605 | 1651 | ||
1606 | lock_kernel(); | ||
1607 | bdev = bdget(part_devt(p)); | 1652 | bdev = bdget(part_devt(p)); |
1608 | if (bdev == NULL) | 1653 | if (bdev == NULL) |
1609 | goto out_unlock_kernel; | 1654 | goto out; |
1610 | 1655 | ||
1611 | q = blk_trace_get_queue(bdev); | 1656 | q = blk_trace_get_queue(bdev); |
1612 | if (q == NULL) | 1657 | if (q == NULL) |
@@ -1634,8 +1679,7 @@ out_unlock_bdev: | |||
1634 | mutex_unlock(&bdev->bd_mutex); | 1679 | mutex_unlock(&bdev->bd_mutex); |
1635 | out_bdput: | 1680 | out_bdput: |
1636 | bdput(bdev); | 1681 | bdput(bdev); |
1637 | out_unlock_kernel: | 1682 | out: |
1638 | unlock_kernel(); | ||
1639 | return ret; | 1683 | return ret; |
1640 | } | 1684 | } |
1641 | 1685 | ||
@@ -1665,11 +1709,10 @@ static ssize_t sysfs_blk_trace_attr_store(struct device *dev, | |||
1665 | 1709 | ||
1666 | ret = -ENXIO; | 1710 | ret = -ENXIO; |
1667 | 1711 | ||
1668 | lock_kernel(); | ||
1669 | p = dev_to_part(dev); | 1712 | p = dev_to_part(dev); |
1670 | bdev = bdget(part_devt(p)); | 1713 | bdev = bdget(part_devt(p)); |
1671 | if (bdev == NULL) | 1714 | if (bdev == NULL) |
1672 | goto out_unlock_kernel; | 1715 | goto out; |
1673 | 1716 | ||
1674 | q = blk_trace_get_queue(bdev); | 1717 | q = blk_trace_get_queue(bdev); |
1675 | if (q == NULL) | 1718 | if (q == NULL) |
@@ -1704,8 +1747,6 @@ out_unlock_bdev: | |||
1704 | mutex_unlock(&bdev->bd_mutex); | 1747 | mutex_unlock(&bdev->bd_mutex); |
1705 | out_bdput: | 1748 | out_bdput: |
1706 | bdput(bdev); | 1749 | bdput(bdev); |
1707 | out_unlock_kernel: | ||
1708 | unlock_kernel(); | ||
1709 | out: | 1750 | out: |
1710 | return ret ? ret : count; | 1751 | return ret ? ret : count; |
1711 | } | 1752 | } |
@@ -1730,7 +1771,7 @@ void blk_dump_cmd(char *buf, struct request *rq) | |||
1730 | int len = rq->cmd_len; | 1771 | int len = rq->cmd_len; |
1731 | unsigned char *cmd = rq->cmd; | 1772 | unsigned char *cmd = rq->cmd; |
1732 | 1773 | ||
1733 | if (!blk_pc_request(rq)) { | 1774 | if (rq->cmd_type != REQ_TYPE_BLOCK_PC) { |
1734 | buf[0] = '\0'; | 1775 | buf[0] = '\0'; |
1735 | return; | 1776 | return; |
1736 | } | 1777 | } |
@@ -1755,21 +1796,21 @@ void blk_fill_rwbs(char *rwbs, u32 rw, int bytes) | |||
1755 | 1796 | ||
1756 | if (rw & WRITE) | 1797 | if (rw & WRITE) |
1757 | rwbs[i++] = 'W'; | 1798 | rwbs[i++] = 'W'; |
1758 | else if (rw & 1 << BIO_RW_DISCARD) | 1799 | else if (rw & REQ_DISCARD) |
1759 | rwbs[i++] = 'D'; | 1800 | rwbs[i++] = 'D'; |
1760 | else if (bytes) | 1801 | else if (bytes) |
1761 | rwbs[i++] = 'R'; | 1802 | rwbs[i++] = 'R'; |
1762 | else | 1803 | else |
1763 | rwbs[i++] = 'N'; | 1804 | rwbs[i++] = 'N'; |
1764 | 1805 | ||
1765 | if (rw & 1 << BIO_RW_AHEAD) | 1806 | if (rw & REQ_RAHEAD) |
1766 | rwbs[i++] = 'A'; | 1807 | rwbs[i++] = 'A'; |
1767 | if (rw & 1 << BIO_RW_BARRIER) | 1808 | if (rw & REQ_SYNC) |
1768 | rwbs[i++] = 'B'; | ||
1769 | if (rw & 1 << BIO_RW_SYNCIO) | ||
1770 | rwbs[i++] = 'S'; | 1809 | rwbs[i++] = 'S'; |
1771 | if (rw & 1 << BIO_RW_META) | 1810 | if (rw & REQ_META) |
1772 | rwbs[i++] = 'M'; | 1811 | rwbs[i++] = 'M'; |
1812 | if (rw & REQ_SECURE) | ||
1813 | rwbs[i++] = 'E'; | ||
1773 | 1814 | ||
1774 | rwbs[i] = '\0'; | 1815 | rwbs[i] = '\0'; |
1775 | } | 1816 | } |
@@ -1779,8 +1820,11 @@ void blk_fill_rwbs_rq(char *rwbs, struct request *rq) | |||
1779 | int rw = rq->cmd_flags & 0x03; | 1820 | int rw = rq->cmd_flags & 0x03; |
1780 | int bytes; | 1821 | int bytes; |
1781 | 1822 | ||
1782 | if (blk_discard_rq(rq)) | 1823 | if (rq->cmd_flags & REQ_DISCARD) |
1783 | rw |= (1 << BIO_RW_DISCARD); | 1824 | rw |= REQ_DISCARD; |
1825 | |||
1826 | if (rq->cmd_flags & REQ_SECURE) | ||
1827 | rw |= REQ_SECURE; | ||
1784 | 1828 | ||
1785 | bytes = blk_rq_bytes(rq); | 1829 | bytes = blk_rq_bytes(rq); |
1786 | 1830 | ||