From: Chen Cheng Date: Fri, 15 May 2026 09:30:19 +0000 (+0800) Subject: md/raid10: reset read_slot when reusing r10bio for discard X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=6b8a26af065ddc93de2aa5c9f0df98dce9723442;p=thirdparty%2Flinux.git md/raid10: reset read_slot when reusing r10bio for discard put_all_bios() always drops devs[i].bio, but it only drops devs[i].repl_bio when r10_bio->read_slot < 0. If discard reuses an r10bio that was previously used for a read, read_slot can still be non-negative, and discard cleanup can skip bio_put() on repl_bio. Reset read_slot to -1 when preparing an r10bio for discard so the replacement bio is always released correctly. Fixes: d30588b2731f ("md/raid10: improve raid10 discard request") Signed-off-by: Chen Cheng Reviewed-by: Xiao Ni Link: https://patch.msgid.link/20260515093019.3436882-1-chencheng@fnnas.com Signed-off-by: Yu Kuai --- diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 39085e7dd6d26..7dc2a5a127e89 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -1727,6 +1727,7 @@ retry_discard: r10_bio->mddev = mddev; r10_bio->state = 0; r10_bio->sectors = 0; + r10_bio->read_slot = -1; memset(r10_bio->devs, 0, sizeof(r10_bio->devs[0]) * geo->raid_disks); wait_blocked_dev(mddev, r10_bio);