Re: [PATCH 09/10] md: only delete entries from all_mddevs when the disk is freed
From: Hannes Reinecke <hare@suse.de>
Date: 2022-07-19 07:00:57
Also in:
linux-block
From: Hannes Reinecke <hare@suse.de>
Date: 2022-07-19 07:00:57
Also in:
linux-block
On 7/19/22 07:06, Christoph Hellwig wrote:
On Mon, Jul 18, 2022 at 11:20:39AM -0700, Song Liu wrote:quoted
quoted
quoted
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?quoted
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