Skip to content

Commit d1eda52

Browse files
masalkhigregkh
authored andcommitted
md/raid1: free r1_bio when REQ_NOWAIT is set and read would block on retry
[ Upstream commit 69ad6ce ] When a read is retried, raid1_read_request() may be called with a pre-allocated r1_bio. If wait_read_barrier() fails for a REQ_NOWAIT read, the bio is completed and the function returns immediately. In this case the existing r1_bio is leaked. This fixes a leak of pre-allocated r1_bio structures for retried reads. Fixes: 5aa7050 ("md: raid1 add nowait support") Reported-by: sashiko-bot <sashiko-bot@kernel.org> Closes: https://sashiko.dev/#/patchset/20260611083514.754922-1-abd.masalkhi@gmail.com?part=1 Signed-off-by: Abd-Alrhman Masalkhi <abd.masalkhi@gmail.com> Link: https://patch.msgid.link/20260611101350.759154-1-abd.masalkhi@gmail.com Signed-off-by: Yu Kuai <yukuai@fygo.io> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent c88e687 commit d1eda52

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

drivers/md/raid1.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,6 +1244,12 @@ static void raid1_read_request(struct mddev *mddev, struct bio *bio,
12441244
if (!wait_read_barrier(conf, bio->bi_iter.bi_sector,
12451245
bio->bi_opf & REQ_NOWAIT)) {
12461246
bio_wouldblock_error(bio);
1247+
1248+
if (r1bio_existed) {
1249+
set_bit(R1BIO_Returned, &r1_bio->state);
1250+
raid_end_bio_io(r1_bio);
1251+
}
1252+
12471253
return;
12481254
}
12491255

0 commit comments

Comments
 (0)