On Mon, Jul 18, 2022 at 12:17 AM Hannes Reinecke <hare@xxxxxxx> wrote: > > On 7/18/22 08:34, Christoph Hellwig wrote: > > This ensures device names don't get prematurely reused. Instead add a > > deleted flag to skip already deleted devices in mddev_get and other > > places that only want to see live mddevs. > > > > Reported-by; Logan Gunthorpe <logang@xxxxxxxxxxxx> > > Signed-off-by: Christoph Hellwig <hch@xxxxxx> > > --- > > drivers/md/md.c | 56 +++++++++++++++++++++++++++++++++---------------- > > drivers/md/md.h | 1 + > > 2 files changed, 39 insertions(+), 18 deletions(-) > > > > diff --git a/drivers/md/md.c b/drivers/md/md.c > > index 805f2b4ed9c0d..08cf21ad4c2d7 100644 > > --- a/drivers/md/md.c > > +++ b/drivers/md/md.c > > @@ -625,6 +625,10 @@ EXPORT_SYMBOL(md_flush_request); > > > > 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? Thanks Christoph for the set. And thanks Hannes for the quick review! I think atomic_inc_unless_zero() should work here. Alternatively, we can also grab a big from mddev->flags as MD_DELETED. Thanks, Song [...]