diff options
author | NeilBrown <neilb@suse.de> | 2006-01-06 00:21:06 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-06 08:34:10 -0800 |
commit | 83303b613d00718b07ec0a4dee7c99aa66629d96 (patch) | |
tree | e2c7c113d2f2f69aa426c3a3a355d84089bb13ce /drivers/md | |
parent | 6961ece46c7d02de1bb83914900608e39633787d (diff) | |
download | linux-83303b613d00718b07ec0a4dee7c99aa66629d96.tar.gz linux-83303b613d00718b07ec0a4dee7c99aa66629d96.tar.bz2 linux-83303b613d00718b07ec0a4dee7c99aa66629d96.zip |
[PATCH] md: allow available size of component devices to be set via sysfs
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 | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 27db100d8b12..40ac7fbab61f 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -1686,12 +1686,37 @@ offset_store(mdk_rdev_t *rdev, const char *buf, size_t len) static struct rdev_sysfs_entry rdev_offset = __ATTR(offset, 0644, offset_show, offset_store); +static ssize_t +rdev_size_show(mdk_rdev_t *rdev, char *page) +{ + return sprintf(page, "%llu\n", (unsigned long long)rdev->size); +} + +static ssize_t +rdev_size_store(mdk_rdev_t *rdev, const char *buf, size_t len) +{ + char *e; + unsigned long long size = simple_strtoull(buf, &e, 10); + if (e==buf || (*e && *e != '\n')) + return -EINVAL; + if (rdev->mddev->pers) + return -EBUSY; + rdev->size = size; + if (size < rdev->mddev->size || rdev->mddev->size == 0) + rdev->mddev->size = size; + return len; +} + +static struct rdev_sysfs_entry rdev_size = +__ATTR(size, 0644, rdev_size_show, rdev_size_store); + static struct attribute *rdev_default_attrs[] = { &rdev_state.attr, &rdev_super.attr, &rdev_errors.attr, &rdev_slot.attr, &rdev_offset.attr, + &rdev_size.attr, NULL, }; static ssize_t |