aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2006-01-06 03:20:50 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-06 11:34:08 -0500
commit8bb93aaca2062cd54cc2c58c76ee8409cae209a7 (patch)
tree12efef0262795f4d4462c8ac8e0fd6e2117ee81a /drivers
parenta35b0d695d44410eb1734c9abb632725a3138628 (diff)
[PATCH] md: expose md metadata format in sysfs
Allow it to be set to a particular version, or 'none'. Signed-off-by: Neil Brown <neilb@suse.de> Acked-by: Greg KH <greg@kroah.com> 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.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index d568ab4a487f..ecc0166ba779 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1857,6 +1857,54 @@ size_store(mddev_t *mddev, const char *buf, size_t len)
1857static struct md_sysfs_entry md_size = 1857static struct md_sysfs_entry md_size =
1858__ATTR(component_size, 0644, size_show, size_store); 1858__ATTR(component_size, 0644, size_show, size_store);
1859 1859
1860
1861/* Metdata version.
1862 * This is either 'none' for arrays with externally managed metadata,
1863 * or N.M for internally known formats
1864 */
1865static ssize_t
1866metadata_show(mddev_t *mddev, char *page)
1867{
1868 if (mddev->persistent)
1869 return sprintf(page, "%d.%d\n",
1870 mddev->major_version, mddev->minor_version);
1871 else
1872 return sprintf(page, "none\n");
1873}
1874
1875static ssize_t
1876metadata_store(mddev_t *mddev, const char *buf, size_t len)
1877{
1878 int major, minor;
1879 char *e;
1880 if (!list_empty(&mddev->disks))
1881 return -EBUSY;
1882
1883 if (cmd_match(buf, "none")) {
1884 mddev->persistent = 0;
1885 mddev->major_version = 0;
1886 mddev->minor_version = 90;
1887 return len;
1888 }
1889 major = simple_strtoul(buf, &e, 10);
1890 if (e==buf || *e != '.')
1891 return -EINVAL;
1892 buf = e+1;
1893 minor = simple_strtoul(buf, &e, 10);
1894 if (e==buf || *e != '\n')
1895 return -EINVAL;
1896 if (major >= sizeof(super_types)/sizeof(super_types[0]) ||
1897 super_types[major].name == NULL)
1898 return -ENOENT;
1899 mddev->major_version = major;
1900 mddev->minor_version = minor;
1901 mddev->persistent = 1;
1902 return len;
1903}
1904
1905static struct md_sysfs_entry md_metadata =
1906__ATTR(metadata_version, 0644, metadata_show, metadata_store);
1907
1860static ssize_t 1908static ssize_t
1861action_show(mddev_t *mddev, char *page) 1909action_show(mddev_t *mddev, char *page)
1862{ 1910{
@@ -1926,6 +1974,7 @@ static struct attribute *md_default_attrs[] = {
1926 &md_raid_disks.attr, 1974 &md_raid_disks.attr,
1927 &md_chunk_size.attr, 1975 &md_chunk_size.attr,
1928 &md_size.attr, 1976 &md_size.attr,
1977 &md_metadata.attr,
1929 NULL, 1978 NULL,
1930}; 1979};
1931 1980