Re: [PATCH] md/raid10: free r10_bio on write NOWAIT exits

From: yu kuai

Date: Thu Jul 30 2026 - 07:27:20 EST


Hi,

在 2026/7/8 16:47, Guangshuo Li 写道:
> The change referenced by the Fixes tag made a NOWAIT early exit in
> raid10_write_request() free the r10_bio directly instead of using
> raid_end_bio_io(), avoiding an unmatched allow_barrier() while still
> returning the r10_bio object to the mempool.
>
> The same function has two other NOWAIT early exits. One is before
> regular_request_wait(), where the request has not taken a barrier
> reference. The other is in the reshape metadata path, where the barrier
> reference is released explicitly with allow_barrier(). Both paths end the
> bio and return false, but neither returns the r10_bio object to the
> mempool.
>
> Free the r10_bio on both NOWAIT exits. Keep the existing barrier handling
> unchanged, since only the reshape path has taken a barrier reference.
>
> Fixes: 7d96f3120a7f ("md/raid10: fix deadlock with check operation and nowait requests")
> Signed-off-by: Guangshuo Li <lgs201920130244@xxxxxxxxx>
> ---
> drivers/md/raid10.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index 0a3cfdd3f5df..d480344c5b8f 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -1364,6 +1364,7 @@ static bool raid10_write_request(struct mddev *mddev, struct bio *bio,
> DEFINE_WAIT(w);
> /* Bail out if REQ_NOWAIT is set for the bio */
> if (bio->bi_opf & REQ_NOWAIT) {
> + free_r10bio(r10_bio);
> bio_wouldblock_error(bio);
> return false;
> }
> @@ -1397,6 +1398,7 @@ static bool raid10_write_request(struct mddev *mddev, struct bio *bio,
> md_wakeup_thread(mddev->thread);
> if (bio->bi_opf & REQ_NOWAIT) {
> allow_barrier(conf);
> + free_r10bio(r10_bio);
> bio_wouldblock_error(bio);
> return false;
> }
This patch is not needed as nowait will be removed for raid10.

--
Thanks,
Kuai