]> git.ipfire.org Git - thirdparty/linux.git/commit
md/raid1: fix writes_pending and barrier reference leaks on write failures
authorAbd-Alrhman Masalkhi <abd.masalkhi@gmail.com>
Sat, 13 Jun 2026 18:28:07 +0000 (18:28 +0000)
committerYu Kuai <yukuai@fygo.io>
Sat, 20 Jun 2026 18:14:44 +0000 (02:14 +0800)
commit8e065a1602511282fc0da2dc89445e0eb71a681c
treea01b29f8b1da39a62b7f143e6c6e059c2cbb6594
parentd5b58fbb2fd7ac25fcd7e1c14730f998a90b0322
md/raid1: fix writes_pending and barrier reference leaks on write failures

raid1_make_request() acquires a writes_pending reference with
md_write_start() before calling raid1_write_request(). Several failure
paths in raid1_write_request() complete the bio and return without
reaching the normal write completion path, causing the corresponding
md_write_end() to be skipped.

Make raid1_write_request() return a status indicating whether the write
request was successfully queued. This allows raid1_make_request() to
call md_write_end() when raid1_write_request() fails.

Additionally, if wait_blocked_rdev() fails after wait_barrier()
succeeds, the associated barrier reference is not released.

Call allow_barrier() before returning from that path to keep the barrier
accounting balanced.

Fixes: b1a7ad8b5c4f ("md/raid1: Handle bio_split() errors")
Fixes: f2a38abf5f1c ("md/raid1: Atomic write support")
Fixes: 5aa705039c4f ("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
Closes: https://sashiko.dev/#/patchset/20260611132500.763528-1-abd.masalkhi@gmail.com?part=1
Signed-off-by: Abd-Alrhman Masalkhi <abd.masalkhi@gmail.com>
Link: https://patch.msgid.link/20260613182810.1317258-2-abd.masalkhi@gmail.com
Signed-off-by: Yu Kuai <yukuai@fygo.io>
drivers/md/raid1.c