Re: [PATCH] md/raid5-ppl: convert pending_flushes from atomic_t to refcount_t

From: Dan Carpenter

Date: Mon Jun 22 2026 - 06:57:39 EST


On Mon, Jun 22, 2026 at 03:58:58PM +0530, Sajal Gupta wrote:
> Hi Dan,
>
> > Have you tested this at all because it doesn't seem at all correct to
> > me...
>
> I have only done compile test, sorry, I forgot to mention that.
>
> > How I imagined this would work would be:
> > patch 1: add a break statement to fix the use after free
> > patch 2: s/atomic_t/recount_t/
>
> > The difference between atomic_t and refcount_t is that refount_t warns
> > about overflows and underflows.
>
> I did it like this because that is the pattern mostly used in the codebase.
> Simple s/atomic_t/recount_t/ would have
> refcount_set(&io->pending_flushes, 0) in init
> and then later refcount_set(&io->pending_flushes, raid_disks) in
> ppl_do_flush, which is not the usual way. I am treating it as a proper reference
> counter rather than a mechanical type swap.
>
> If that is too invasive, I’ll rework it into the break fix first, and do
> s/atomic_t/recount_t cleanup separately.

Heh. Yeah... There is not a chance I would merge a patch like this
without testing.

It also really feels like an AI patch and you're supposed to say when you
use AI to generate patches.

regards,
dan carpenter