From: sashiko-bot@kernel.org
To: "Sasha Levin" <sashal@kernel.org>
Cc: yukuai@fygo.io, linux-raid@vger.kernel.org
Subject: Re: [PATCH AUTOSEL 6.18-5.10] md/raid5: let stripe batch bm_seq comparison wrap-safe
Date: Mon, 31 Aug 2026 17:28:52 +0000 [thread overview]
Message-ID: <20260831172853.362E51F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260831133314.4125787-624-sashal@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Lockless Read-Modify-Write (RMW) race on batch_head->bm_seq could result in a stale bitmap sequence number.
--
commit ec929cd222791eadb056199cc433123ca41575a6
Author: Chen Cheng <chencheng@fnnas.com>
md/raid5: let stripe batch bm_seq comparison wrap-safe
This commit fixes a sequence number comparison bug in
stripe_add_to_batch_list() by changing a direct greater-than comparison to a
wrap-safe subtraction to ensure proper bitmap batch sequencing.
Link: https://patch.msgid.link/20260618025735.915113-1-chencheng@fnnas.com
> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
> --- a/drivers/md/raid5.c
> +++ b/drivers/md/raid5.c
> @@ -992,7 +992,7 @@ static void stripe_add_to_batch_list(struct r5conf *conf,
> if (test_and_clear_bit(STRIPE_BIT_DELAY, &sh->state)) {
> int seq = sh->bm_seq;
> if (test_bit(STRIPE_BIT_DELAY, &sh->batch_head->state) &&
> - sh->batch_head->bm_seq > seq)
> + sh->batch_head->bm_seq - seq > 0)
> seq = sh->batch_head->bm_seq;
> set_bit(STRIPE_BIT_DELAY, &sh->batch_head->state);
> sh->batch_head->bm_seq = seq;
[Severity: Critical]
This is a pre-existing issue, but could this lockless read-modify-write of
batch_head->bm_seq result in a stale bitmap sequence number?
During concurrent additions to a RAID5 stripe batch, threads handling disjoint
subordinate stripes (for example, sh1 and sh3) hold different stripe locks.
Because they do not contend for the same stripe locks, they can execute this
block concurrently on the same batch_head.
Could this concurrent access cause one thread to overwrite another thread's
newer bm_seq with an older one?
If a data race results in the batch head storing an older sequence number,
could the batch be written to disk before all required bitmap flushes have
completed? If a power failure occurs under these conditions, it appears the
dirty bits for some stripes in the batch might not be recorded in the bitmap,
which might lead to data corruption during array recovery.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260831133314.4125787-624-sashal@kernel.org?part=1
next prev parent reply other threads:[~2026-08-31 17:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260831133314.4125787-1-sashal@kernel.org>
2026-08-31 13:25 ` [PATCH AUTOSEL 6.18] dm-raid: only requeue bios when dm is suspending Sasha Levin
2026-08-31 13:30 ` [PATCH AUTOSEL 6.18-5.10] md/raid5: let stripe batch bm_seq comparison wrap-safe Sasha Levin
2026-08-31 17:28 ` sashiko-bot [this message]
2026-08-31 13:31 ` [PATCH AUTOSEL 6.18-5.15] md/raid5: account discard IO Sasha Levin
2026-08-31 17:50 ` sashiko-bot
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=20260831172853.362E51F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=sashal@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--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