Re: [PATCH 3/8] md: raid5: use refcount_t for reference counting instead atomic_t

From: Peter Zijlstra
Date: Wed May 23 2018 - 07:42:57 EST


> Most changes are 1:1 replacements except for
> BUG_ON(atomic_inc_return(&sh->count) != 1);

That doesn't look right, 'inc_return == 1' implies inc-from-zero, which
is not allowed by refcount.

> which has been turned into
> refcount_inc(&sh->count);
> BUG_ON(refcount_read(&sh->count) != 1);

And that is racy, you can have additional increments in between.