diff options
author | NeilBrown <neilb@suse.de> | 2006-01-06 03:21:06 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-06 11:34:10 -0500 |
commit | 83303b613d00718b07ec0a4dee7c99aa66629d96 (patch) | |
tree | e2c7c113d2f2f69aa426c3a3a355d84089bb13ce | |
parent | 6961ece46c7d02de1bb83914900608e39633787d (diff) |
[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>
-rw-r--r-- | Documentation/md.txt | 7 | ||||
-rw-r--r-- | drivers/md/md.c | 25 |
2 files changed, 32 insertions, 0 deletions
diff --git a/Documentation/md.txt b/Documentation/md.txt index 866a1a887547..7b3d471bb9f0 100644 --- a/Documentation/md.txt +++ b/Documentation/md.txt | |||
@@ -250,6 +250,13 @@ Each directory contains: | |||
250 | the device before this offset us not touched, unless it is | 250 | the device before this offset us not touched, unless it is |
251 | used for storing metadata (Formats 1.1 and 1.2). | 251 | used for storing metadata (Formats 1.1 and 1.2). |
252 | 252 | ||
253 | size | ||
254 | The amount of the device, after the offset, that can be used | ||
255 | for storage of data. This will normally be the same as the | ||
256 | component_size. This can be written while assembling an | ||
257 | array. If a value less than the current component_size is | ||
258 | written, component_size will be reduced to this value. | ||
259 | |||
253 | 260 | ||
254 | An active md device will also contain and entry for each active device | 261 | An active md device will also contain and entry for each active device |
255 | in the array. These are named | 262 | in the array. These are named |
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) | |||
1686 | static struct rdev_sysfs_entry rdev_offset = | 1686 | static struct rdev_sysfs_entry rdev_offset = |
1687 | __ATTR(offset, 0644, offset_show, offset_store); | 1687 | __ATTR(offset, 0644, offset_show, offset_store); |
1688 | 1688 | ||
1689 | static ssize_t | ||
1690 | rdev_size_show(mdk_rdev_t *rdev, char *page) | ||
1691 | { | ||
1692 | return sprintf(page, "%llu\n", (unsigned long long)rdev->size); | ||
1693 | } | ||
1694 | |||
1695 | static ssize_t | ||
1696 | rdev_size_store(mdk_rdev_t *rdev, const char *buf, size_t len) | ||
1697 | { | ||
1698 | char *e; | ||
1699 | unsigned long long size = simple_strtoull(buf, &e, 10); | ||
1700 | if (e==buf || (*e && *e != '\n')) | ||
1701 | return -EINVAL; | ||
1702 | if (rdev->mddev->pers) | ||
1703 | return -EBUSY; | ||
1704 | rdev->size = size; | ||
1705 | if (size < rdev->mddev->size || rdev->mddev->size == 0) | ||
1706 | rdev->mddev->size = size; | ||
1707 | return len; | ||
1708 | } | ||
1709 | |||
1710 | static struct rdev_sysfs_entry rdev_size = | ||
1711 | __ATTR(size, 0644, rdev_size_show, rdev_size_store); | ||
1712 | |||
1689 | static struct attribute *rdev_default_attrs[] = { | 1713 | static struct attribute *rdev_default_attrs[] = { |
1690 | &rdev_state.attr, | 1714 | &rdev_state.attr, |
1691 | &rdev_super.attr, | 1715 | &rdev_super.attr, |
1692 | &rdev_errors.attr, | 1716 | &rdev_errors.attr, |
1693 | &rdev_slot.attr, | 1717 | &rdev_slot.attr, |
1694 | &rdev_offset.attr, | 1718 | &rdev_offset.attr, |
1719 | &rdev_size.attr, | ||
1695 | NULL, | 1720 | NULL, |
1696 | }; | 1721 | }; |
1697 | static ssize_t | 1722 | static ssize_t |