提交 83303b61 编写于 作者: N NeilBrown 提交者: Linus Torvalds

[PATCH] md: allow available size of component devices to be set via sysfs

Signed-off-by: NNeil Brown <neilb@suse.de>
Acked-by: NGreg KH <greg@kroah.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 6961ece4
...@@ -250,6 +250,13 @@ Each directory contains: ...@@ -250,6 +250,13 @@ Each directory contains:
the device before this offset us not touched, unless it is the device before this offset us not touched, unless it is
used for storing metadata (Formats 1.1 and 1.2). used for storing metadata (Formats 1.1 and 1.2).
size
The amount of the device, after the offset, that can be used
for storage of data. This will normally be the same as the
component_size. This can be written while assembling an
array. If a value less than the current component_size is
written, component_size will be reduced to this value.
An active md device will also contain and entry for each active device An active md device will also contain and entry for each active device
in the array. These are named in the array. These are named
......
...@@ -1686,12 +1686,37 @@ offset_store(mdk_rdev_t *rdev, const char *buf, size_t len) ...@@ -1686,12 +1686,37 @@ offset_store(mdk_rdev_t *rdev, const char *buf, size_t len)
static struct rdev_sysfs_entry rdev_offset = static struct rdev_sysfs_entry rdev_offset =
__ATTR(offset, 0644, offset_show, offset_store); __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[] = { static struct attribute *rdev_default_attrs[] = {
&rdev_state.attr, &rdev_state.attr,
&rdev_super.attr, &rdev_super.attr,
&rdev_errors.attr, &rdev_errors.attr,
&rdev_slot.attr, &rdev_slot.attr,
&rdev_offset.attr, &rdev_offset.attr,
&rdev_size.attr,
NULL, NULL,
}; };
static ssize_t static ssize_t
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册