diff options
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/md.c | 6 | ||||
-rw-r--r-- | drivers/md/raid5.c | 72 |
2 files changed, 15 insertions, 63 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 013f2f27589c..3db5c3513072 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -1683,12 +1683,6 @@ static void analyze_sbs(mddev_t * mddev) | |||
1683 | 1683 | ||
1684 | } | 1684 | } |
1685 | 1685 | ||
1686 | struct md_sysfs_entry { | ||
1687 | struct attribute attr; | ||
1688 | ssize_t (*show)(mddev_t *, char *); | ||
1689 | ssize_t (*store)(mddev_t *, const char *, size_t); | ||
1690 | }; | ||
1691 | |||
1692 | static ssize_t | 1686 | static ssize_t |
1693 | md_show_level(mddev_t *mddev, char *page) | 1687 | md_show_level(mddev_t *mddev, char *page) |
1694 | { | 1688 | { |
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 246c9b1cc4a3..08a1620b9f8c 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -1732,21 +1732,17 @@ static void raid5d (mddev_t *mddev) | |||
1732 | PRINTK("--- raid5d inactive\n"); | 1732 | PRINTK("--- raid5d inactive\n"); |
1733 | } | 1733 | } |
1734 | 1734 | ||
1735 | struct raid5_sysfs_entry { | ||
1736 | struct attribute attr; | ||
1737 | ssize_t (*show)(raid5_conf_t *, char *); | ||
1738 | ssize_t (*store)(raid5_conf_t *, const char *, ssize_t); | ||
1739 | }; | ||
1740 | |||
1741 | static ssize_t | 1735 | static ssize_t |
1742 | raid5_show_stripe_cache_size(raid5_conf_t *conf, char *page) | 1736 | raid5_show_stripe_cache_size(mddev_t *mddev, char *page) |
1743 | { | 1737 | { |
1738 | raid5_conf_t *conf = mddev_to_conf(mddev); | ||
1744 | return sprintf(page, "%d\n", conf->max_nr_stripes); | 1739 | return sprintf(page, "%d\n", conf->max_nr_stripes); |
1745 | } | 1740 | } |
1746 | 1741 | ||
1747 | static ssize_t | 1742 | static ssize_t |
1748 | raid5_store_stripe_cache_size(raid5_conf_t *conf, const char *page, ssize_t len) | 1743 | raid5_store_stripe_cache_size(mddev_t *mddev, const char *page, size_t len) |
1749 | { | 1744 | { |
1745 | raid5_conf_t *conf = mddev_to_conf(mddev); | ||
1750 | char *end; | 1746 | char *end; |
1751 | int new; | 1747 | int new; |
1752 | if (len >= PAGE_SIZE) | 1748 | if (len >= PAGE_SIZE) |
@@ -1770,68 +1766,33 @@ raid5_store_stripe_cache_size(raid5_conf_t *conf, const char *page, ssize_t len) | |||
1770 | } | 1766 | } |
1771 | return len; | 1767 | return len; |
1772 | } | 1768 | } |
1773 | static struct raid5_sysfs_entry raid5_stripecache_size = { | 1769 | |
1770 | static struct md_sysfs_entry raid5_stripecache_size = { | ||
1774 | .attr = {.name = "stripe_cache_size", .mode = S_IRUGO | S_IWUSR }, | 1771 | .attr = {.name = "stripe_cache_size", .mode = S_IRUGO | S_IWUSR }, |
1775 | .show = raid5_show_stripe_cache_size, | 1772 | .show = raid5_show_stripe_cache_size, |
1776 | .store = raid5_store_stripe_cache_size, | 1773 | .store = raid5_store_stripe_cache_size, |
1777 | }; | 1774 | }; |
1778 | 1775 | ||
1779 | static ssize_t | 1776 | static ssize_t |
1780 | raid5_show_stripe_cache_active(raid5_conf_t *conf, char *page) | 1777 | raid5_show_stripe_cache_active(mddev_t *mddev, char *page) |
1781 | { | 1778 | { |
1779 | raid5_conf_t *conf = mddev_to_conf(mddev); | ||
1782 | return sprintf(page, "%d\n", atomic_read(&conf->active_stripes)); | 1780 | return sprintf(page, "%d\n", atomic_read(&conf->active_stripes)); |
1783 | } | 1781 | } |
1784 | 1782 | ||
1785 | static struct raid5_sysfs_entry raid5_stripecache_active = { | 1783 | static struct md_sysfs_entry raid5_stripecache_active = { |
1786 | .attr = {.name = "stripe_cache_active", .mode = S_IRUGO}, | 1784 | .attr = {.name = "stripe_cache_active", .mode = S_IRUGO}, |
1787 | .show = raid5_show_stripe_cache_active, | 1785 | .show = raid5_show_stripe_cache_active, |
1788 | }; | 1786 | }; |
1789 | 1787 | ||
1790 | static struct attribute *raid5_default_attrs[] = { | 1788 | static struct attribute *raid5_attrs[] = { |
1791 | &raid5_stripecache_size.attr, | 1789 | &raid5_stripecache_size.attr, |
1792 | &raid5_stripecache_active.attr, | 1790 | &raid5_stripecache_active.attr, |
1793 | NULL, | 1791 | NULL, |
1794 | }; | 1792 | }; |
1795 | 1793 | static struct attribute_group raid5_attrs_group = { | |
1796 | static ssize_t | 1794 | .name = NULL, |
1797 | raid5_attr_show(struct kobject *kobj, struct attribute *attr, char *page) | 1795 | .attrs = raid5_attrs, |
1798 | { | ||
1799 | struct raid5_sysfs_entry *entry = container_of(attr, struct raid5_sysfs_entry, attr); | ||
1800 | raid5_conf_t *conf = container_of(kobj, raid5_conf_t, kobj); | ||
1801 | |||
1802 | if (!entry->show) | ||
1803 | return -EIO; | ||
1804 | return entry->show(conf, page); | ||
1805 | } | ||
1806 | |||
1807 | static ssize_t | ||
1808 | raid5_attr_store(struct kobject *kobj, struct attribute *attr, | ||
1809 | const char *page, size_t length) | ||
1810 | { | ||
1811 | struct raid5_sysfs_entry *entry = container_of(attr, struct raid5_sysfs_entry, attr); | ||
1812 | raid5_conf_t *conf = container_of(kobj, raid5_conf_t, kobj); | ||
1813 | |||
1814 | if (!entry->store) | ||
1815 | return -EIO; | ||
1816 | return entry->store(conf, page, length); | ||
1817 | } | ||
1818 | |||
1819 | static void raid5_free(struct kobject *ko) | ||
1820 | { | ||
1821 | raid5_conf_t *conf = container_of(ko, raid5_conf_t, kobj); | ||
1822 | kfree(conf); | ||
1823 | } | ||
1824 | |||
1825 | |||
1826 | static struct sysfs_ops raid5_sysfs_ops = { | ||
1827 | .show = raid5_attr_show, | ||
1828 | .store = raid5_attr_store, | ||
1829 | }; | ||
1830 | |||
1831 | static struct kobj_type raid5_ktype = { | ||
1832 | .release = raid5_free, | ||
1833 | .sysfs_ops = &raid5_sysfs_ops, | ||
1834 | .default_attrs = raid5_default_attrs, | ||
1835 | }; | 1796 | }; |
1836 | 1797 | ||
1837 | static int run(mddev_t *mddev) | 1798 | static int run(mddev_t *mddev) |
@@ -1975,10 +1936,7 @@ memory = conf->max_nr_stripes * (sizeof(struct stripe_head) + | |||
1975 | } | 1936 | } |
1976 | 1937 | ||
1977 | /* Ok, everything is just fine now */ | 1938 | /* Ok, everything is just fine now */ |
1978 | conf->kobj.parent = &mddev->kobj; | 1939 | sysfs_create_group(&mddev->kobj, &raid5_attrs_group); |
1979 | strcpy(conf->kobj.name, "raid5"); | ||
1980 | conf->kobj.ktype = &raid5_ktype; | ||
1981 | kobject_register(&conf->kobj); | ||
1982 | 1940 | ||
1983 | if (mddev->bitmap) | 1941 | if (mddev->bitmap) |
1984 | mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ; | 1942 | mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ; |
@@ -2012,7 +1970,7 @@ static int stop(mddev_t *mddev) | |||
2012 | shrink_stripes(conf); | 1970 | shrink_stripes(conf); |
2013 | free_pages((unsigned long) conf->stripe_hashtbl, HASH_PAGES_ORDER); | 1971 | free_pages((unsigned long) conf->stripe_hashtbl, HASH_PAGES_ORDER); |
2014 | blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/ | 1972 | blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/ |
2015 | kobject_unregister(&conf->kobj); | 1973 | sysfs_remove_group(&mddev->kobj, &raid5_attrs_group); |
2016 | mddev->private = NULL; | 1974 | mddev->private = NULL; |
2017 | return 0; | 1975 | return 0; |
2018 | } | 1976 | } |