diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/md/md.c | 26 |
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 | ||
1748 | static ssize_t | ||
1749 | state_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 | } | ||
1748 | static struct rdev_sysfs_entry | 1772 | static struct rdev_sysfs_entry |
1749 | rdev_state = __ATTR_RO(state); | 1773 | rdev_state = __ATTR(state, 0644, state_show, state_store); |
1750 | 1774 | ||
1751 | static ssize_t | 1775 | static ssize_t |
1752 | super_show(mdk_rdev_t *rdev, char *page) | 1776 | super_show(mdk_rdev_t *rdev, char *page) |