diff options
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/md.c | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 097ae1b5484b..023aecd0295e 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -1746,9 +1746,9 @@ raid_disks_show(mddev_t *mddev, char *page) | |||
1746 | static struct md_sysfs_entry md_raid_disks = __ATTR_RO(raid_disks); | 1746 | static struct md_sysfs_entry md_raid_disks = __ATTR_RO(raid_disks); |
1747 | 1747 | ||
1748 | static ssize_t | 1748 | static ssize_t |
1749 | md_show_scan(mddev_t *mddev, char *page) | 1749 | action_show(mddev_t *mddev, char *page) |
1750 | { | 1750 | { |
1751 | char *type = "none"; | 1751 | char *type = "idle"; |
1752 | if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) || | 1752 | if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) || |
1753 | test_bit(MD_RECOVERY_NEEDED, &mddev->recovery)) { | 1753 | test_bit(MD_RECOVERY_NEEDED, &mddev->recovery)) { |
1754 | if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) { | 1754 | if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) { |
@@ -1765,27 +1765,36 @@ md_show_scan(mddev_t *mddev, char *page) | |||
1765 | } | 1765 | } |
1766 | 1766 | ||
1767 | static ssize_t | 1767 | static ssize_t |
1768 | md_store_scan(mddev_t *mddev, const char *page, size_t len) | 1768 | action_store(mddev_t *mddev, const char *page, size_t len) |
1769 | { | 1769 | { |
1770 | int canscan=0; | 1770 | if (!mddev->pers || !mddev->pers->sync_request) |
1771 | return -EINVAL; | ||
1772 | |||
1773 | if (strcmp(page, "idle")==0 || strcmp(page, "idle\n")==0) { | ||
1774 | if (mddev->sync_thread) { | ||
1775 | set_bit(MD_RECOVERY_INTR, &mddev->recovery); | ||
1776 | md_unregister_thread(mddev->sync_thread); | ||
1777 | mddev->sync_thread = NULL; | ||
1778 | mddev->recovery = 0; | ||
1779 | } | ||
1780 | return len; | ||
1781 | } | ||
1771 | 1782 | ||
1772 | if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) || | 1783 | if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) || |
1773 | test_bit(MD_RECOVERY_NEEDED, &mddev->recovery)) | 1784 | test_bit(MD_RECOVERY_NEEDED, &mddev->recovery)) |
1774 | return -EBUSY; | 1785 | return -EBUSY; |
1775 | 1786 | if (strcmp(page, "resync")==0 || strcmp(page, "resync\n")==0 || | |
1776 | if (mddev->pers && mddev->pers->sync_request) | 1787 | strcmp(page, "recover")==0 || strcmp(page, "recover\n")==0) |
1777 | canscan=1; | 1788 | set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); |
1778 | 1789 | else { | |
1779 | if (!canscan) | 1790 | if (strcmp(page, "check")==0 || strcmp(page, "check\n")==0) |
1780 | return -EINVAL; | 1791 | set_bit(MD_RECOVERY_CHECK, &mddev->recovery); |
1781 | 1792 | else if (strcmp(page, "repair")!=0 && strcmp(page, "repair\n")!=0) | |
1782 | if (strcmp(page, "check")==0 || strcmp(page, "check\n")==0) | 1793 | return -EINVAL; |
1783 | set_bit(MD_RECOVERY_CHECK, &mddev->recovery); | 1794 | set_bit(MD_RECOVERY_REQUESTED, &mddev->recovery); |
1784 | else if (strcmp(page, "repair")!=0 && strcmp(page, "repair\n")!=0) | 1795 | set_bit(MD_RECOVERY_SYNC, &mddev->recovery); |
1785 | return -EINVAL; | 1796 | set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); |
1786 | set_bit(MD_RECOVERY_REQUESTED, &mddev->recovery); | 1797 | } |
1787 | set_bit(MD_RECOVERY_SYNC, &mddev->recovery); | ||
1788 | set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); | ||
1789 | md_wakeup_thread(mddev->thread); | 1798 | md_wakeup_thread(mddev->thread); |
1790 | return len; | 1799 | return len; |
1791 | } | 1800 | } |
@@ -1798,7 +1807,7 @@ mismatch_cnt_show(mddev_t *mddev, char *page) | |||
1798 | } | 1807 | } |
1799 | 1808 | ||
1800 | static struct md_sysfs_entry | 1809 | static struct md_sysfs_entry |
1801 | md_scan_mode = __ATTR(scan_mode, S_IRUGO|S_IWUSR, md_show_scan, md_store_scan); | 1810 | md_scan_mode = __ATTR(sync_action, S_IRUGO|S_IWUSR, action_show, action_store); |
1802 | 1811 | ||
1803 | 1812 | ||
1804 | static struct md_sysfs_entry | 1813 | static struct md_sysfs_entry |