diff options
author | NeilBrown <neilb@suse.de> | 2006-01-06 09:20:50 +0100 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-06 17:34:08 +0100 |
commit | 8bb93aaca2062cd54cc2c58c76ee8409cae209a7 (patch) | |
tree | 12efef0262795f4d4462c8ac8e0fd6e2117ee81a /drivers/md | |
parent | [PATCH] md: allow md array component size to be accessed and set via sysfs (diff) | |
download | linux-8bb93aaca2062cd54cc2c58c76ee8409cae209a7.tar.xz linux-8bb93aaca2062cd54cc2c58c76ee8409cae209a7.zip |
[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/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) static struct md_sysfs_entry md_size = __ATTR(component_size, 0644, size_show, size_store); + +/* Metdata version. + * This is either 'none' for arrays with externally managed metadata, + * or N.M for internally known formats + */ +static ssize_t +metadata_show(mddev_t *mddev, char *page) +{ + if (mddev->persistent) + return sprintf(page, "%d.%d\n", + mddev->major_version, mddev->minor_version); + else + return sprintf(page, "none\n"); +} + +static ssize_t +metadata_store(mddev_t *mddev, const char *buf, size_t len) +{ + int major, minor; + char *e; + if (!list_empty(&mddev->disks)) + return -EBUSY; + + if (cmd_match(buf, "none")) { + mddev->persistent = 0; + mddev->major_version = 0; + mddev->minor_version = 90; + return len; + } + major = simple_strtoul(buf, &e, 10); + if (e==buf || *e != '.') + return -EINVAL; + buf = e+1; + minor = simple_strtoul(buf, &e, 10); + if (e==buf || *e != '\n') + return -EINVAL; + if (major >= sizeof(super_types)/sizeof(super_types[0]) || + super_types[major].name == NULL) + return -ENOENT; + mddev->major_version = major; + mddev->minor_version = minor; + mddev->persistent = 1; + return len; +} + +static struct md_sysfs_entry md_metadata = +__ATTR(metadata_version, 0644, metadata_show, metadata_store); + static ssize_t action_show(mddev_t *mddev, char *page) { @@ -1926,6 +1974,7 @@ static struct attribute *md_default_attrs[] = { &md_raid_disks.attr, &md_chunk_size.attr, &md_size.attr, + &md_metadata.attr, NULL, }; |