Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2488635lqp; Sun, 24 Mar 2024 23:12:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXayQ7r5k+x/4Qjp0fdEWsb2T/o18UWd8KBDtiMo9tb4tGbJdeBNfMjSIYPX/mlamuHRcenNwxfdE3P/mQp9t5th7J8AoKzlBO8uW8DdQ== X-Google-Smtp-Source: AGHT+IFkndaBpejD2agPQEVXpv91ARzFKbX7S4P0tGxzRwUVKxd9fEgfBLKBQpJMU4u7xNH3Yd/p X-Received: by 2002:a19:4344:0:b0:513:1a38:2406 with SMTP id m4-20020a194344000000b005131a382406mr3668114lfj.13.1711347159844; Sun, 24 Mar 2024 23:12:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711347159; cv=pass; d=google.com; s=arc-20160816; b=EPxjzVdHCoMjmBB783a5ScFZyKWFi79C5LPvbWMQrx15QOfRg3no8h8LjJFnGHXC96 8QjAQsbDUj2Ttlu0k92GD1LU1Bdop/dRYFXdQS6QWAGn0Gnb25QDMAoNNGxheYmfUmqz xc+2mQP1AJbJvgTrC48PP4AK0Byn51MQ7KWxpjCZq9+/7Aw3k8JaOqMvrDdtShbkIeXG VYnUi6moTfQ5bH1GcKODsgzOvE6ODFi1n+ydTkVUGHEge20dujtMZ8rA1oZdDaI/XPJT 2teBstVKIWnx0D0KQclamcCkVuJZS4QgS4XgkgroiSg30ap5aYNDYa4qhIk4qj4ED4At TlIg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=P6tk+/YMPAeFpJYV5D3r4xc+qXmOyNdX3hOCMivt8R8=; fh=eWAVD20ZRJ3bugUwnx9wl7mNnrK9UmqVi76h57Uk9/c=; b=LUH/7DsGXAIZ9ZRsol2DJjJh+NQKWh+BfM3IyzIxTGZspYq+aIKBB3CtcVYMWJaqTM EFlW7vXgW0WPMkWvc7y+nkCvt168SuFT7lLDIcuG0DWuR7jUQmVsv1BKcrONobScIhaV rBWYMyhljT7OANUfCNmQirX96ZJsC4sLgvBelrlpofoRG8UOfw4/Mnd2gc3cRCb/W9Df uhaPiywvAqGR6DYcozGUQsQZW8Q9oCSAZNNNCI4He2IT+70JFWbU93Cys7rNCDSRrCBc owr2k3NMfs/wLkL+AIjyR8hQjjzsBBrcwU3pd9eI3d/+nIa1STk+z5Ch0gvCkGSw7tSm qkBQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=L09UI7Ss; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-114485-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-114485-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id t26-20020a508d5a000000b0056ba017fd08si2339489edt.598.2024.03.24.23.12.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 23:12:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-114485-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=L09UI7Ss; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-114485-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-114485-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 2B6DA1F2B6E9 for ; Mon, 25 Mar 2024 06:12:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 631921782F3; Sun, 24 Mar 2024 23:46:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="L09UI7Ss" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33488224A28; Sun, 24 Mar 2024 23:12:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711321932; cv=none; b=vEf6qyqLouxntZEFrojjCfAPnDK5ynnro9hQepbUAERuCkXws2VQfW3zO61vMss5g9HLhJfAQplVvRj4QMLPbOZFi1w8qCzWTKB7zfN2bOkXvl4SWNoaZV1ntgAYWQ4AE2G9z1FSAALrKK4fULUOLzSEkc3xVcyR1ud/9wJW2yM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711321932; c=relaxed/simple; bh=kWQta+JWW20WsDBpivL+3NRiXgc7IA9O36H5ZYgfLfA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TRZ4Q2W/wvVzVmrrSnaQSgddtbQjlHZsuFro7+2Itj/h5o7BVdtP90j/wWF/rKWl+hejaxyXOS4xS/YdrKLAFojOpbC306NBOFeYwm+UPHBRBEdy6izdt8H7NNcRGzhQFMN8E+0CEY+zWI3H3/EdYSR8Aiep9MTT+DIEguWVIks= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=L09UI7Ss; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E860C43399; Sun, 24 Mar 2024 23:12:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711321931; bh=kWQta+JWW20WsDBpivL+3NRiXgc7IA9O36H5ZYgfLfA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L09UI7SsGw+WhUGGz0sOOJMlo1sbJXLudPVAVIoFUSR5Bq964XPff9sdg6D8aLDY3 +Jr1xpcDyjV64sumFocolX4cdt8MYy4jiIUVNR0D+Fiy6oL5W7TM99S9IVfxVqneZ/ 490bbhQjRSxjqAQ0vFms83d0Y5jbYUGoir6XCAfLYu/0p24KE1ERZLFYBniJf60kSn zLRle0I/yPnVRRkNMrj9RPjqT+Tf3CA/CHUKb0BOogxNsZQqRTD+MFgZwhWtgn273j tjXiJJJWfcWJoMZfpI2hhUBUXjnW5mJrxNhcT4hqp1oKOIPV4ghv/YiPPVZBKBgtgy 3xtite3p2uJKA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Yu Kuai , Peter Neuwirth , Song Liu , Sasha Levin Subject: [PATCH 6.1 001/451] md: fix data corruption for raid456 when reshape restart while grow up Date: Sun, 24 Mar 2024 19:04:37 -0400 Message-ID: <20240324231207.1351418-2-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324231207.1351418-1-sashal@kernel.org> References: <20240324231207.1351418-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Yu Kuai [ 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 Link: https://lore.kernel.org/linux-raid/e2f96772-bfbc-f43b-6da1-f520e5164536@online.de/ Signed-off-by: Yu Kuai Signed-off-by: Song Liu Link: https://lore.kernel.org/r/20230512015610.821290-3-yukuai1@huaweicloud.com Signed-off-by: Sasha Levin --- drivers/md/md.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 846bdee4daa0e..1c87f3e708094 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -4903,11 +4903,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); } -- 2.43.0