diff options
| author | Yu Kuai <yukuai3@huawei.com> | 2023-09-27 14:12:40 +0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-02-27 04:10:44 -0800 |
| commit | 452f50807917cfcbf79b5e5671c1812cf6b84c1a (patch) | |
| tree | 662a138663ba341b9e02b93d55e88a452108aebe | |
| parent | 13231893fb7af29a33b5ae1de1aacbfd30e6639d (diff) | |
| download | linux-452f50807917cfcbf79b5e5671c1812cf6b84c1a.tar.gz linux-452f50807917cfcbf79b5e5671c1812cf6b84c1a.tar.bz2 linux-452f50807917cfcbf79b5e5671c1812cf6b84c1a.zip | |
md: factor out a helper from mddev_put()
[ Upstream commit 3d8d32873c7b6d9cec5b40c2ddb8c7c55961694f ]
There are no functional changes, prepare to simplify md_seq_ops in next
patch.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20230927061241.1552837-2-yukuai1@huaweicloud.com
Stable-dep-of: 8d28d0ddb986 ("md/md-bitmap: Synchronize bitmap_get_stats() with bitmap lifetime")
Signed-off-by: Sasha Levin <sashal@kernel.org>
| -rw-r--r-- | drivers/md/md.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 342407ea87d8..836e8ed58c8a 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -633,23 +633,28 @@ static inline struct mddev *mddev_get(struct mddev *mddev) static void mddev_delayed_delete(struct work_struct *ws); +static void __mddev_put(struct mddev *mddev) +{ + if (mddev->raid_disks || !list_empty(&mddev->disks) || + mddev->ctime || mddev->hold_active) + return; + + /* Array is not configured at all, and not held active, so destroy it */ + set_bit(MD_DELETED, &mddev->flags); + + /* + * Call queue_work inside the spinlock so that flush_workqueue() after + * mddev_find will succeed in waiting for the work to be done. + */ + queue_work(md_misc_wq, &mddev->del_work); +} + void mddev_put(struct mddev *mddev) { if (!atomic_dec_and_lock(&mddev->active, &all_mddevs_lock)) return; - if (!mddev->raid_disks && list_empty(&mddev->disks) && - mddev->ctime == 0 && !mddev->hold_active) { - /* Array is not configured at all, and not held active, - * so destroy it */ - set_bit(MD_DELETED, &mddev->flags); - /* - * Call queue_work inside the spinlock so that - * flush_workqueue() after mddev_find will succeed in waiting - * for the work to be done. - */ - queue_work(md_misc_wq, &mddev->del_work); - } + __mddev_put(mddev); spin_unlock(&all_mddevs_lock); } |
