aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2006-01-06 03:20:55 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-06 11:34:09 -0500
commit014236d2b8ec6faea2a6134ab8e019d84d67b524 (patch)
tree80f655fe0631f56544b96f2b9750f93e327b23de
parent2bf071bf50580380a8c3afe5eef8152a66be96c7 (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>
-rw-r--r--Documentation/md.txt8
-rw-r--r--drivers/md/md.c35
2 files changed, 43 insertions, 0 deletions
diff --git a/Documentation/md.txt b/Documentation/md.txt
index 69f742dee00f..d525fffc873b 100644
--- a/Documentation/md.txt
+++ b/Documentation/md.txt
@@ -236,6 +236,14 @@ Each directory contains:
236 providing an ongoing count for arrays with metadata managed by 236 providing an ongoing count for arrays with metadata managed by
237 userspace. 237 userspace.
238 238
239 slot
240 This gives the role that the device has in the array. It will
241 either be 'none' if the device is not active in the array
242 (i.e. is a spare or has failed) or an integer less than the
243 'raid_disks' number for the array indicating which possition
244 it currently fills. This can only be set while assembling an
245 array. A device for which this is set is assumed to be working.
246
239 247
240An active md device will also contain and entry for each active device 248An active md device will also contain and entry for each active device
241in the array. These are named 249in the array. These are named
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