On 7/19/22 07:06, Christoph Hellwig wrote:
On Mon, Jul 18, 2022 at 11:20:39AM -0700, Song Liu wrote:
static inline struct mddev *mddev_get(struct mddev *mddev)
{
+ lockdep_assert_held(&all_mddevs_lock);
+
+ if (mddev->deleted)
+ return NULL;
atomic_inc(&mddev->active);
return mddev;
}
Why can't we use 'atomic_inc_unless_zero' here and do away with the
additional 'deleted' flag?
I think atomic_inc_unless_zero() should work here. Alternatively, we can
also grab a big from mddev->flags as MD_DELETED.
s/big/bit/ ?
Yes, this could use mddev->flags. I don't think atomic_inc_unless_zero
would work, as an array can have a refcount of 0 but we still allow
to take new references to it, the deletion only happens if the other
conditions in mddev_put are met.
Do you want me to repin the series using a flag?
I would vote for it.
Cheers,
Hannes