Re: [PATCH 8/9] md: only delete entries from all_mddevs when the disk is freed
From: Guoqing Jiang <hidden>
Date: 2022-07-15 09:04:04
Also in:
linux-block
On 7/13/22 7:31 PM, 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.
The patch actually adds a deleted member to struct mddev , so the "Instead" here is at least confusing to me.
quoted hunk ↗ jump to hunk
Reported-by; Logan Gunthorpe[off-list ref] Signed-off-by: Christoph Hellwig<hch@lst.de> --- 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 df99a16892bce..f3ff61e540ee0 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);
...
quoted hunk ↗ jump to hunk
diff --git a/drivers/md/md.h b/drivers/md/md.h index 1a85dbe78a71c..bc870e1f1e8c2 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h@@ -503,6 +503,7 @@ struct mddev { atomic_t max_corr_read_errors; /* max read retries */ struct list_head all_mddevs; + bool deleted; const struct attribute_group *to_remove;
Thanks, Guoqing