diff options
-rw-r--r-- | Documentation/md.txt | 3 | ||||
-rw-r--r-- | drivers/md/md.c | 26 |
2 files changed, 28 insertions, 1 deletions
diff --git a/Documentation/md.txt b/Documentation/md.txt index df0b45515775..4cf5972821a9 100644 --- a/Documentation/md.txt +++ b/Documentation/md.txt | |||
@@ -302,6 +302,9 @@ Each directory contains: | |||
302 | This includes spares that are in the process | 302 | This includes spares that are in the process |
303 | of being recoverred to | 303 | of being recoverred to |
304 | This list make grow in future. | 304 | This list make grow in future. |
305 | This can be written to. | ||
306 | Writing "faulty" simulates a failure on the device. | ||
307 | Writing "remove" removes the device from the array. | ||
305 | 308 | ||
306 | errors | 309 | errors |
307 | An approximate count of read errors that have been detected on | 310 | An approximate count of read errors that have been detected on |
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) |