aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2006-06-26 03:27:58 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-26 12:58:39 -0400
commit45dc2de1e53a29f898b81326b8a16e6192d52e4e (patch)
treea1076950eef59cbe525435522d83757390f23c42 /drivers
parent9e653b6342c94016f5cc9937061ef99e9c4b4045 (diff)
[PATCH] md: Allow rdev state to be set via sysfs
The md/dev-XXX/state file can now be written: "faulty" simulates an error on the device "remove" removes the device from the array (if it is not busy) Signed-off-by: Neil Brown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/md.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index f6562ee4c6fc..4b74c77213c3 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1745,8 +1745,32 @@ state_show(mdk_rdev_t *rdev, char *page)
1745 return len+sprintf(page+len, "\n"); 1745 return len+sprintf(page+len, "\n");
1746} 1746}
1747 1747
1748static ssize_t
1749state_store(mdk_rdev_t *rdev, const char *buf, size_t len)
1750{
1751 /* can write
1752 * faulty - simulates and error
1753 * remove - disconnects the device
1754 */
1755 int err = -EINVAL;
1756 if (cmd_match(buf, "faulty") && rdev->mddev->pers) {
1757 md_error(rdev->mddev, rdev);
1758 err = 0;
1759 } else if (cmd_match(buf, "remove")) {
1760 if (rdev->raid_disk >= 0)
1761 err = -EBUSY;
1762 else {
1763 mddev_t *mddev = rdev->mddev;
1764 kick_rdev_from_array(rdev);
1765 md_update_sb(mddev);
1766 md_new_event(mddev);
1767 err = 0;
1768 }
1769 }
1770 return err ? err : len;
1771}
1748static struct rdev_sysfs_entry 1772static struct rdev_sysfs_entry
1749rdev_state = __ATTR_RO(state); 1773rdev_state = __ATTR(state, 0644, state_show, state_store);
1750 1774
1751static ssize_t 1775static ssize_t
1752super_show(mdk_rdev_t *rdev, char *page) 1776super_show(mdk_rdev_t *rdev, char *page)