summaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2022-07-19 11:18:21 +0200
committerJens Axboe <axboe@kernel.dk>2022-08-02 17:22:44 -0600
commitf26514342255855f4ca3c0a92cb1cdea01c33004 (patch)
tree6c83718c7dd3303b33bd5aee4cd11d51aa5246a6 /drivers/md
parentb0e706a1ba84e50eaa714486e06e1d0027411658 (diff)
downloadlinux-stable-f26514342255855f4ca3c0a92cb1cdea01c33004.tar.gz
linux-stable-f26514342255855f4ca3c0a92cb1cdea01c33004.tar.bz2
linux-stable-f26514342255855f4ca3c0a92cb1cdea01c33004.zip
md: stop using for_each_mddev in md_notify_reboot
Just do a simple list_for_each_entry_safe on all_mddevs, and only grab a reference when we drop the lock. Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Logan Gunthorpe <logang@deltatee.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Song Liu <song@kernel.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/md.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index f7d5865880f2..f5d46694a506 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -9585,11 +9585,13 @@ EXPORT_SYMBOL_GPL(rdev_clear_badblocks);
static int md_notify_reboot(struct notifier_block *this,
unsigned long code, void *x)
{
- struct list_head *tmp;
- struct mddev *mddev;
+ struct mddev *mddev, *n;
int need_delay = 0;
- for_each_mddev(mddev, tmp) {
+ spin_lock(&all_mddevs_lock);
+ list_for_each_entry_safe(mddev, n, &all_mddevs, all_mddevs) {
+ mddev_get(mddev);
+ spin_unlock(&all_mddevs_lock);
if (mddev_trylock(mddev)) {
if (mddev->pers)
__md_stop_writes(mddev);
@@ -9598,7 +9600,11 @@ static int md_notify_reboot(struct notifier_block *this,
mddev_unlock(mddev);
}
need_delay = 1;
+ mddev_put(mddev);
+ spin_lock(&all_mddevs_lock);
}
+ spin_unlock(&all_mddevs_lock);
+
/*
* certain more exotic SCSI devices are known to be
* volatile wrt too early system reboots. While the