From: "Chen Cheng" <chencheng@fnnas.com>
To: "Doug V Johnson" <me@dougvj.me>, <linux-raid@vger.kernel.org>
Cc: <song@kernel.org>, <yukuai@fygo.io>, <magiclinan@didiglobal.com>,
<xiao@kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v4 1/3] md/raid5: freeze and interrupt reshape when handling failed reshape
Date: Thu, 22 Oct 2026 15:36:59 +0800 [thread overview]
Message-ID: <323c8d9f-319e-4f9e-a258-63a33a0e6200@fnnas.com> (raw)
In-Reply-To: <010101a142f57e37-cd14b78d-54cd-447b-9888-87f166a937ab-000000@us-west-2.amazonses.com>
On 2026/10/16 12:25, Doug V Johnson wrote:
> Set the reshape freeze flag to prevent automatic reshape resumption
> and interrupt the current reshape with md_sync_error() so that a
> reshape always stops no matter how the failed reshape is triggered.
>
> Previously, if there were no faulty or out of sync devices but there
> was an unrecoverable read, the reshape continued and was not cancelled
> after handle_failed_reshape(). This caused some data corruption as
> block writes were cancelled but the reshape nonetheless continued.
>
> Prior to Chen's fix, the kernel would deadlock with a failed stripe
> read. That case also caused some data corruption, so Chen's patch
> did not introduce corruption in this case.
>
> An example test case showing how this happened before this fix is
> demonstrated by the following:
>
> Simplified example (schematic logical sector numbers):
>
> 1. Before reshape, destination D contains data for logical 20-27.
> The new geometry will use D for logical 100-107.
>
> 2. Inject bad-block metadata on enough members that the old source
> stripe cannot be reconstructed. Logical sector 100 now returns
> a read error; sectors 101-107 are still readable.
>
> 3. Reshape tries to read the source block for logical 100-107.
> The bad-block records prevent a successful read/reconstruction.
> Failure cleanup cancels the destination write:
>
> Source: logical 100-107 --X--> destination D
> still contains data for 20-27
>
> 4. Without interruption, reshape continues and completes.
> The new mapping now sends reads of logical 100-107 to D.
>
> 5. Reading logical 100-107 succeeds, but returns data for 20-27.
> Previously readable sectors 101-107 now return wrong data.
>
> Code that injects bad blocks to demonstrate this problem before and
> after Chen's fix as well as after this patch can be found here:
>
> Link: https://github.com/dougvj/md-raid-reshape-badblock-corruption-test
>
> Fixes: 788e4139463f ("md/raid5: fix reshape deadlock while failed devices more than max degraded")
> Link: https://patch.msgid.link/20260624075824.2601110-1-chencheng@fnnas.com
> Assisted-by: LLM
> Signed-off-by: Doug V Johnson <me@dougvj.me>
> ---
> drivers/md/raid5.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
> index b91545ce090d..86ea65559576 100644
> --- a/drivers/md/raid5.c
> +++ b/drivers/md/raid5.c
> @@ -3773,6 +3773,10 @@ static void handle_failed_reshape(struct r5conf *conf, struct stripe_head *sh,
> bool was_expanding = test_and_clear_bit(STRIPE_EXPANDING, &sh->state);
> bool was_ready = test_and_clear_bit(STRIPE_EXPAND_READY, &sh->state);
>
> + /* Freeze reshaping to prevent data loss */
> + set_bit(MD_RECOVERY_FROZEN, &conf->mddev->recovery);
> + md_sync_error(conf->mddev);
> +
> if (was_expanding || was_ready) {
> atomic_dec(&conf->reshape_stripes);
> wake_up(&conf->wait_for_reshape);
Reviewed-by: Chen Cheng <chencheng@fnnas.com>
next prev parent reply other threads:[~2026-10-22 7:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261016042537.277516-1-me@dougvj.me>
2026-10-16 4:25 ` Doug V Johnson
2026-10-22 7:36 ` Chen Cheng [this message]
2026-10-16 4:25 ` [PATCH v4 3/3] md/raid5: warn when a read fails due in some part to bad-block metadata Doug V Johnson
2026-10-16 4:25 ` [PATCH v4 2/3] md/raid5: do not reshape if overlapping rdev bad block ranges prevent it Doug V Johnson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=323c8d9f-319e-4f9e-a258-63a33a0e6200@fnnas.com \
--to=chencheng@fnnas.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=magiclinan@didiglobal.com \
--cc=me@dougvj.me \
--cc=song@kernel.org \
--cc=xiao@kernel.org \
--cc=yukuai@fygo.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®