提交 fd3b6975 编写于 作者: G Guoqing Jiang 提交者: Jens Axboe

md/raid1: only allocate write behind bio for WriteMostly device

Commit 6607cd31 ("raid1: ensure write
behind bio has less than BIO_MAX_VECS sectors") tried to guarantee the
size of behind bio is not bigger than BIO_MAX_VECS sectors.

Unfortunately the same calltrace still could happen since an array could
enable write-behind without write mostly device.

To match the manpage of mdadm (which says "write-behind is only attempted
on drives marked as write-mostly"), we need to check WriteMostly flag to
avoid such unexpected behavior.

[1]. https://bugzilla.kernel.org/show_bug.cgi?id=213181#c25

Cc: stable@vger.kernel.org # v5.12+
Cc: Jens Stutte <jens@chianterastutte.eu>
Reported-by: NJens Stutte <jens@chianterastutte.eu>
Signed-off-by: NGuoqing Jiang <guoqing.jiang@linux.dev>
Signed-off-by: NSong Liu <songliubraving@fb.com>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
上级 7ad10691
...@@ -1496,7 +1496,7 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio, ...@@ -1496,7 +1496,7 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
if (!r1_bio->bios[i]) if (!r1_bio->bios[i])
continue; continue;
if (first_clone) { if (first_clone && test_bit(WriteMostly, &rdev->flags)) {
/* do behind I/O ? /* do behind I/O ?
* Not if there are too many, or cannot * Not if there are too many, or cannot
* allocate memory, or a reader on WriteMostly * allocate memory, or a reader on WriteMostly
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册