From: Yunye Zhao <yunye.zhao@linux.alibaba.com>
To: linux-raid@vger.kernel.org
Cc: Yu Kuai <yukuai@fygo.io>, Song Liu <song@kernel.org>,
Li Nan <magiclinan@didiglobal.com>, Xiao Ni <xiao@kernel.org>,
Jan Kara <jack@suse.cz>, John Garry <john.g.garry@oracle.com>,
Joseph Qi <joseph.qi@linux.alibaba.com>,
YunyeZhao <yunye.zhao@linux.alibaba.com>
Subject: [PATCH 6.6.y] md/raid0: fix data corruption when chunk size is below PAGE_SIZE
Date: Tue, 13 Oct 2026 21:32:43 +0800 [thread overview]
Message-ID: <20261013133243.42145-1-yunye.zhao@linux.alibaba.com> (raw)
From: YunyeZhao <yunye.zhao@linux.alibaba.com>
Commit 319ff40a5427 ("md/raid0: Fix performance regression for large sequential writes")
assumes that bios reaching RAID0 are no larger than the chunk size.
However, blk_queue_max_hw_sectors() raises limits smaller than
PAGE_SIZE to one page. With 64 KiB pages and a 16 KiB RAID0 chunk, a
bio can therefore span several chunks. raid0_make_request() splits it
only once and maps the multi-chunk remainder to one member device,
causing silent data corruption.
Set the queue chunk boundary after stacking the member limits, combined
with any inherited boundary using gcd(). This makes the block layer
split bios at chunk boundaries before they reach RAID0. Only install a
boundary aligned to the logical block size so that bio splitting
always makes progress.
Setting the boundary after disk_stack_limits() is required because
stacking may clear or reduce a boundary installed earlier. This adapts
the mechanism introduced by upstream commit 4b8beba60d32
("md/raid0: set chunk_sectors limit") to the queue limits API used by
6.6.y.
The corruption was reproduced on arm64 with 64 KiB pages and a 16 KiB
chunk. A 64 KiB chunk configuration is unaffected.
Fixes: 319ff40a5427 ("md/raid0: Fix performance regression for large sequential writes")
Signed-off-by: YunyeZhao <yunye.zhao@linux.alibaba.com>
---
drivers/md/raid0.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index c50a7abda744..5a57e327c6ba 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -11,6 +11,7 @@
*/
#include <linux/blkdev.h>
+#include <linux/gcd.h>
#include <linux/seq_file.h>
#include <linux/module.h>
#include <linux/slab.h>
@@ -382,6 +383,7 @@ static void raid0_free(struct mddev *mddev, void *priv)
static int raid0_run(struct mddev *mddev)
{
struct r0conf *conf;
+ unsigned int chunk_limit;
int ret;
if (mddev->chunk_sectors == 0) {
@@ -413,6 +415,18 @@ static int raid0_run(struct mddev *mddev)
disk_stack_limits(mddev->gendisk, rdev->bdev,
rdev->data_offset << 9);
}
+
+ /*
+ * Set the chunk boundary after stacking member limits, which
+ * may clear or reduce it. Without it a bio may span several
+ * chunks when chunk size < PAGE_SIZE. Keep it a multiple of
+ * the logical block size so the block layer can split at it.
+ */
+ chunk_limit = gcd(mddev->queue->limits.chunk_sectors,
+ mddev->chunk_sectors);
+ if (!(chunk_limit %
+ (mddev->queue->limits.logical_block_size >> SECTOR_SHIFT)))
+ blk_queue_chunk_sectors(mddev->queue, chunk_limit);
}
/* calculate array device size */
--
2.19.1.6.gb485710b
next reply other threads:[~2026-10-13 13:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 13:32 Yunye Zhao [this message]
2026-10-13 13:44 ` [PATCH 6.6.y] md/raid0: fix data corruption when chunk size is below PAGE_SIZE 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=20261013133243.42145-1-yunye.zhao@linux.alibaba.com \
--to=yunye.zhao@linux.alibaba.com \
--cc=jack@suse.cz \
--cc=john.g.garry@oracle.com \
--cc=joseph.qi@linux.alibaba.com \
--cc=linux-raid@vger.kernel.org \
--cc=magiclinan@didiglobal.com \
--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