Skip to content

Commit

Permalink
md: factor out a helper from mddev_put()
Browse files Browse the repository at this point in the history
There are no functional changes, prepare to simplify md_seq_ops in next
patch.

Signed-off-by: Yu Kuai <[email protected]>
Signed-off-by: Song Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
Yu Kuai authored and liu-song-6 committed Sep 27, 2023
1 parent ceb0416 commit 3d8d328
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -616,23 +616,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);
}

Expand Down

0 comments on commit 3d8d328

Please sign in to comment.