From: Li Nan <linan666@huaweicloud.com>
To: FengWei Shih <dannyshih@synology.com>, song@kernel.org, yukuai@fnnas.com
Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
"yangerkun@huawei.com" <yangerkun@huawei.com>
Subject: Re: [PATCH] md/raid5: fix race between reshape and chunk-aligned read
Date: Mon, 13 Apr 2026 15:19:02 +0800 [thread overview]
Message-ID: <f032ef85-8cd3-1615-3c42-e434011b0056@huaweicloud.com> (raw)
In-Reply-To: <20260409051722.2865321-1-dannyshih@synology.com>
在 2026/4/9 13:17, FengWei Shih 写道:
> raid5_make_request() checks mddev->reshape_position to decide whether
> to allow chunk-aligned reads. However in raid5_start_reshape(), the
> layout configuration (raid_disks, algorithm, etc.) is updated before
> mddev->reshape_position is set:
>
> reshape (raid5_start_reshape) read (raid5_make_request)
> ============================== ===========================
> write_seqcount_begin
> update raid_disks, algorithm...
> set conf->reshape_progress
> write_seqcount_end
> check mddev->reshape_position
> * still MaxSector, allow
> raid5_read_one_chunk()
> * use new layout
> raid5_quiesce()
> set mddev->reshape_position
>
> Since reshape_position is not yet updated, raid5_make_request()
> considers no reshape is in progress and proceeds with the
> chunk-aligned path, but the layout has already changed, causing
> raid5_compute_sector() to return an incorrect physical address.
>
> Fix this by reading conf->reshape_progress under gen_lock in
> raid5_read_one_chunk() and falling back to the stripe path if a
> reshape is in progress.
>
> Signed-off-by: FengWei Shih <dannyshih@synology.com>
> ---
> drivers/md/raid5.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
> index a8e8d431071b..bded2b86f0ef 100644
> --- a/drivers/md/raid5.c
> +++ b/drivers/md/raid5.c
> @@ -5421,6 +5421,11 @@ static int raid5_read_one_chunk(struct mddev *mddev, struct bio *raid_bio)
> sector_t sector, end_sector;
> int dd_idx;
> bool did_inc;
> + int seq;
> +
> + seq = read_seqcount_begin(&conf->gen_lock);
> + if (unlikely(conf->reshape_progress != MaxSector))
> + return 0;
>
> if (!in_chunk_boundary(mddev, raid_bio)) {
> pr_debug("%s: non aligned\n", __func__);
> @@ -5431,6 +5436,9 @@ static int raid5_read_one_chunk(struct mddev *mddev, struct bio *raid_bio)
> &dd_idx, NULL);
> end_sector = sector + bio_sectors(raid_bio);
>
> + if (read_seqcount_retry(&conf->gen_lock, seq))
> + return 0;
> +
> if (r5c_big_stripe_cached(conf, sector))
> return 0;
>
It seems that there might be race issues wherever raid5_compute_sector is
used? This fix only addresses one of the problems.
--
Thanks,
Nan
next prev parent reply other threads:[~2026-04-13 7:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-09 5:17 FengWei Shih
2026-04-13 7:19 ` Li Nan [this message]
2026-04-14 8:27 ` FengWei Shih
2026-04-19 5:14 ` Yu Kuai
2026-04-21 7:09 ` FengWei Shih
2026-04-28 8:29 ` Yu Kuai
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=f032ef85-8cd3-1615-3c42-e434011b0056@huaweicloud.com \
--to=linan666@huaweicloud.com \
--cc=dannyshih@synology.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=song@kernel.org \
--cc=yangerkun@huawei.com \
--cc=yukuai@fnnas.com \
/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®