diff options
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/md.c | 49 |
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) | |||
1857 | static struct md_sysfs_entry md_size = | 1857 | static 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 | */ | ||
1865 | static ssize_t | ||
1866 | metadata_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 | |||
1875 | static ssize_t | ||
1876 | metadata_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 | |||
1905 | static struct md_sysfs_entry md_metadata = | ||
1906 | __ATTR(metadata_version, 0644, metadata_show, metadata_store); | ||
1907 | |||
1860 | static ssize_t | 1908 | static ssize_t |
1861 | action_show(mddev_t *mddev, char *page) | 1909 | action_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 | ||