Re: [PATCH 1/3] md: call del_gendisk in control path

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

 



Hi,

在 2025/06/10 15:20, Xiao Ni 写道:
diff --git a/drivers/md/md.h b/drivers/md/md.h
index d45a9e6ead80..8cf71db12700 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -700,11 +700,26 @@ static inline bool reshape_interrupted(struct mddev *mddev)
static inline int __must_check mddev_lock(struct mddev *mddev)
  {
-	return mutex_lock_interruptible(&mddev->reconfig_mutex);
+	int ret = 0;

No need to initialize ret to 0.
+
+	ret = mutex_lock_interruptible(&mddev->reconfig_mutex);
+
+	/* MD_DELETED is set in do_md_stop with reconfig_mutex.
+	 * So check it here.
+	 */
+	if (!ret && test_bit(MD_DELETED, &mddev->flags)) {
+		ret = -ENODEV;
+		mutex_unlock(&mddev->reconfig_mutex);
+	}
+
+	return ret;
  }
/* Sometimes we need to take the lock in a situation where
   * failure due to interrupts is not acceptable.
+ * It doesn't need to check MD_DELETED here, the owner which
+ * holds the lock here can't be stopped. And all paths can't
+ * call this function after do_md_stop.
   */
  static inline void mddev_lock_nointr(struct mddev *mddev)
  {
@@ -713,7 +728,14 @@ static inline void mddev_lock_nointr(struct mddev *mddev)
static inline int mddev_trylock(struct mddev *mddev)
  {
-	return mutex_trylock(&mddev->reconfig_mutex);
+	int ret = 0;

Same here, otherwise LGTM, feel free to add

Reviewed-by: Yu Kuai <yukuai3@xxxxxxxxxx>





[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