Re: [PATCH 8/9] md: only delete entries from all_mddevs when the disk is freed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





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.

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 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);

...

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



[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux