diff options
author | NeilBrown <neilb@suse.de> | 2006-01-06 03:20:55 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-06 11:34:09 -0500 |
commit | 014236d2b8ec6faea2a6134ab8e019d84d67b524 (patch) | |
tree | 80f655fe0631f56544b96f2b9750f93e327b23de /drivers/md | |
parent | 2bf071bf50580380a8c3afe5eef8152a66be96c7 (diff) |
[PATCH] md: expose device slot information via sysfs
This the role that a device has in an array can be viewed and set.
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 | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 27a9871f305..a8169564209 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -1630,10 +1630,45 @@ errors_store(mdk_rdev_t *rdev, const char *buf, size_t len) | |||
1630 | static struct rdev_sysfs_entry rdev_errors = | 1630 | static struct rdev_sysfs_entry rdev_errors = |
1631 | __ATTR(errors, 0644, errors_show, errors_store); | 1631 | __ATTR(errors, 0644, errors_show, errors_store); |
1632 | 1632 | ||
1633 | static ssize_t | ||
1634 | slot_show(mdk_rdev_t *rdev, char *page) | ||
1635 | { | ||
1636 | if (rdev->raid_disk < 0) | ||
1637 | return sprintf(page, "none\n"); | ||
1638 | else | ||
1639 | return sprintf(page, "%d\n", rdev->raid_disk); | ||
1640 | } | ||
1641 | |||
1642 | static ssize_t | ||
1643 | slot_store(mdk_rdev_t *rdev, const char *buf, size_t len) | ||
1644 | { | ||
1645 | char *e; | ||
1646 | int slot = simple_strtoul(buf, &e, 10); | ||
1647 | if (strncmp(buf, "none", 4)==0) | ||
1648 | slot = -1; | ||
1649 | else if (e==buf || (*e && *e!= '\n')) | ||
1650 | return -EINVAL; | ||
1651 | if (rdev->mddev->pers) | ||
1652 | /* Cannot set slot in active array (yet) */ | ||
1653 | return -EBUSY; | ||
1654 | if (slot >= rdev->mddev->raid_disks) | ||
1655 | return -ENOSPC; | ||
1656 | rdev->raid_disk = slot; | ||
1657 | /* assume it is working */ | ||
1658 | rdev->flags = 0; | ||
1659 | set_bit(In_sync, &rdev->flags); | ||
1660 | return len; | ||
1661 | } | ||
1662 | |||
1663 | |||
1664 | static struct rdev_sysfs_entry rdev_slot = | ||
1665 | __ATTR(slot, 0644, slot_show, slot_store); | ||
1666 | |||
1633 | static struct attribute *rdev_default_attrs[] = { | 1667 | static struct attribute *rdev_default_attrs[] = { |
1634 | &rdev_state.attr, | 1668 | &rdev_state.attr, |
1635 | &rdev_super.attr, | 1669 | &rdev_super.attr, |
1636 | &rdev_errors.attr, | 1670 | &rdev_errors.attr, |
1671 | &rdev_slot.attr, | ||
1637 | NULL, | 1672 | NULL, |
1638 | }; | 1673 | }; |
1639 | static ssize_t | 1674 | static ssize_t |