diff options
Diffstat (limited to 'drivers/md/md.c')
-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 27a9871f3057..a8169564209d 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 |