Re: [PATCH] raid1: fix nr_pending leak in REQ_ATOMIC bad-block error path
From: Abd-Alrhman Masalkhi
Date: Mon Jun 01 2026 - 05:13:21 EST
hi,
On Mon, Jun 01, 2026 at 10:05 +0100, John Garry wrote:
> On 01/06/2026 10:03, Abd-Alrhman Masalkhi wrote:
>>>> +++ b/drivers/md/raid1.c
>>>> @@ -1580,8 +1580,10 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
>>>> * complexity of supporting that is not worth
>>>> * the benefit.
>>>> */
>>>> - if (bio->bi_opf & REQ_ATOMIC)
>>>> + if (bio->bi_opf & REQ_ATOMIC) {
>>>> + rdev_dec_pending(rdev, mddev);
>>> It's not so nice that we have 2x locations that does the
>>> rdev_dec_pending work
>>>
>> Are you suggesting deferring atomic_inc(&rdev->nr_pending) until after
>> the if (test_bit(WriteErrorSeen, &rdev->flags)) {..} block? The patch
>> is already in md-7.2; should I send a separate cleanup patch?
>
> I'm not suggesting any further change. I am just mentioning that it is
> unfortunate that we have 2x locations which does the decrement, which
> makes error handling harder to follow.
You are absolutely right. Having two decrement paths makes the error
handling harder to follow. Thanks for pointing that out.
--
Best Regards,
Abd-Alrhman