md/raid1: simplify raid1_write_request() error handling
authorAbd-Alrhman Masalkhi <abd.masalkhi@gmail.com>
Sat, 13 Jun 2026 18:28:10 +0000 (18:28 +0000)
committerYu Kuai <yukuai@fygo.io>
Sat, 20 Jun 2026 18:14:44 +0000 (02:14 +0800)
commita4c55c902670f2784d3001652183aafa17712cfe
tree54d9441c85b57c3c39b0fed32aaa95878719eb02
parent393d687131d8aa8c7e4de2cb494438e145d20fc2
md/raid1: simplify raid1_write_request() error handling

raid1_write_request() increments rdev->nr_pending before checking the
badblocks and then immediately decrements it again when a device is
skipped. Move the increment until after the checks succeed so the
reference accounting is easier to follow.

Consolidate the failure paths so that each error label releases exactly
the resources acquired up to that point. err_dec_pending drops pending
references and frees the r1bio, while err_allow_barrier handles the
barrier release before returning.

When a REQ_ATOMIC write cannot be satisfied due to a badblock range,
complete the bio with BLK_STS_NOTSUPP rather than reporting an I/O
error, since the operation is unsupported rather than having failed
during I/O.

Rename max_write_sectors to max_sectors and remove the redundant local
copy.

Signed-off-by: Abd-Alrhman Masalkhi <abd.masalkhi@gmail.com>
Link: https://patch.msgid.link/20260613182810.1317258-5-abd.masalkhi@gmail.com
Signed-off-by: Yu Kuai <yukuai@fygo.io>
drivers/md/raid1.c