Commit fafd7fb0 authored by NeilBrown's avatar NeilBrown

md: factor out init code for an mddev

This is a simple factorisation that makes mddev_find easier to read.
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
parent 21a52c6d
...@@ -416,6 +416,27 @@ static void mddev_put(mddev_t *mddev) ...@@ -416,6 +416,27 @@ static void mddev_put(mddev_t *mddev)
spin_unlock(&all_mddevs_lock); spin_unlock(&all_mddevs_lock);
} }
static void mddev_init(mddev_t *mddev)
{
mutex_init(&mddev->open_mutex);
mutex_init(&mddev->reconfig_mutex);
mutex_init(&mddev->bitmap_info.mutex);
INIT_LIST_HEAD(&mddev->disks);
INIT_LIST_HEAD(&mddev->all_mddevs);
init_timer(&mddev->safemode_timer);
atomic_set(&mddev->active, 1);
atomic_set(&mddev->openers, 0);
atomic_set(&mddev->active_io, 0);
spin_lock_init(&mddev->write_lock);
atomic_set(&mddev->flush_pending, 0);
init_waitqueue_head(&mddev->sb_wait);
init_waitqueue_head(&mddev->recovery_wait);
mddev->reshape_position = MaxSector;
mddev->resync_min = 0;
mddev->resync_max = MaxSector;
mddev->level = LEVEL_NONE;
}
static mddev_t * mddev_find(dev_t unit) static mddev_t * mddev_find(dev_t unit)
{ {
mddev_t *mddev, *new = NULL; mddev_t *mddev, *new = NULL;
...@@ -482,23 +503,7 @@ static mddev_t * mddev_find(dev_t unit) ...@@ -482,23 +503,7 @@ static mddev_t * mddev_find(dev_t unit)
else else
new->md_minor = MINOR(unit) >> MdpMinorShift; new->md_minor = MINOR(unit) >> MdpMinorShift;
mutex_init(&new->open_mutex); mddev_init(new);
mutex_init(&new->reconfig_mutex);
mutex_init(&new->bitmap_info.mutex);
INIT_LIST_HEAD(&new->disks);
INIT_LIST_HEAD(&new->all_mddevs);
init_timer(&new->safemode_timer);
atomic_set(&new->active, 1);
atomic_set(&new->openers, 0);
atomic_set(&new->active_io, 0);
spin_lock_init(&new->write_lock);
atomic_set(&new->flush_pending, 0);
init_waitqueue_head(&new->sb_wait);
init_waitqueue_head(&new->recovery_wait);
new->reshape_position = MaxSector;
new->resync_min = 0;
new->resync_max = MaxSector;
new->level = LEVEL_NONE;
goto retry; goto retry;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment