aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/md.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r--drivers/md/md.c35
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)
1630static struct rdev_sysfs_entry rdev_errors = 1630static struct rdev_sysfs_entry rdev_errors =
1631__ATTR(errors, 0644, errors_show, errors_store); 1631__ATTR(errors, 0644, errors_show, errors_store);
1632 1632
1633static ssize_t
1634slot_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
1642static ssize_t
1643slot_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
1664static struct rdev_sysfs_entry rdev_slot =
1665__ATTR(slot, 0644, slot_show, slot_store);
1666
1633static struct attribute *rdev_default_attrs[] = { 1667static 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};
1639static ssize_t 1674static ssize_t