summaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorYu Kuai <yukuai3@huawei.com>2023-05-12 09:56:07 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-08-11 11:45:25 +0200
commit8fede6cfbd0d08daf2eb52329c8592ae15d544b1 (patch)
treeee199f675a914877241397c46804a42440203a9a /drivers/md
parent9441968ea6a9fe2343a9cc953cf53f8eac6174e1 (diff)
downloadlinux-stable-8fede6cfbd0d08daf2eb52329c8592ae15d544b1.tar.gz
linux-stable-8fede6cfbd0d08daf2eb52329c8592ae15d544b1.tar.bz2
linux-stable-8fede6cfbd0d08daf2eb52329c8592ae15d544b1.zip
md: fix data corruption for raid456 when reshape restart while grow up
[ Upstream commit 873f50ece41aad5c4f788a340960c53774b5526e ] Currently, if reshape is interrupted, echo "reshape" to sync_action will restart reshape from scratch, for example: echo frozen > sync_action echo reshape > sync_action This will corrupt data before reshape_position if the array is growing, fix the problem by continue reshape from reshape_position. Reported-by: Peter Neuwirth <reddunur@online.de> Link: https://lore.kernel.org/linux-raid/e2f96772-bfbc-f43b-6da1-f520e5164536@online.de/ Signed-off-by: Yu Kuai <yukuai3@huawei.com> Signed-off-by: Song Liu <song@kernel.org> Link: https://lore.kernel.org/r/20230512015610.821290-3-yukuai1@huaweicloud.com Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/md.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 2e23a898fc97..6b074c2202d5 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -4639,11 +4639,21 @@ action_store(struct mddev *mddev, const char *page, size_t len)
return -EINVAL;
err = mddev_lock(mddev);
if (!err) {
- if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery))
+ if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery)) {
err = -EBUSY;
- else {
+ } else if (mddev->reshape_position == MaxSector ||
+ mddev->pers->check_reshape == NULL ||
+ mddev->pers->check_reshape(mddev)) {
clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery);
err = mddev->pers->start_reshape(mddev);
+ } else {
+ /*
+ * If reshape is still in progress, and
+ * md_check_recovery() can continue to reshape,
+ * don't restart reshape because data can be
+ * corrupted for raid456.
+ */
+ clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery);
}
mddev_unlock(mddev);
}