aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2005-11-09 00:39:30 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-09 10:56:38 -0500
commit007583c9253fed363a0bd71b039e9b40a0f6855e (patch)
treef47d3fd94830ae2c09d7d821e8a57ba46ecb13bc /drivers
parent31399d9e56abeec4d819f07eefc97f30b5d5ed75 (diff)
[PATCH] md: change raid5 sysfs attribute to not create a new directory
There isn't really a need for raid5 attributes to be an a subdirectory, so this patch moves them from /sys/block/mdX/md/raid5/attribute to /sys/block/mdX/md/attribute This suggests that all md personalities should co-operate about namespace usage, but that shouldn't be a problem. Signed-off-by: Neil Brown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/md.c6
-rw-r--r--drivers/md/raid5.c72
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
1686struct 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
1692static ssize_t 1686static ssize_t
1693md_show_level(mddev_t *mddev, char *page) 1687md_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
1735struct 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
1741static ssize_t 1735static ssize_t
1742raid5_show_stripe_cache_size(raid5_conf_t *conf, char *page) 1736raid5_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
1747static ssize_t 1742static ssize_t
1748raid5_store_stripe_cache_size(raid5_conf_t *conf, const char *page, ssize_t len) 1743raid5_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}
1773static struct raid5_sysfs_entry raid5_stripecache_size = { 1769
1770static 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
1779static ssize_t 1776static ssize_t
1780raid5_show_stripe_cache_active(raid5_conf_t *conf, char *page) 1777raid5_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
1785static struct raid5_sysfs_entry raid5_stripecache_active = { 1783static 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
1790static struct attribute *raid5_default_attrs[] = { 1788static 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 1793static struct attribute_group raid5_attrs_group = {
1796static ssize_t 1794 .name = NULL,
1797raid5_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
1807static ssize_t
1808raid5_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
1819static 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
1826static struct sysfs_ops raid5_sysfs_ops = {
1827 .show = raid5_attr_show,
1828 .store = raid5_attr_store,
1829};
1830
1831static 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
1837static int run(mddev_t *mddev) 1798static 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}