diff options
author | NeilBrown <neilb@suse.de> | 2010-04-01 00:55:30 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2010-05-18 01:27:55 -0400 |
commit | fafd7fb052182e087b5a3c6c408e4ac8c2b5fa14 (patch) | |
tree | 0071eab25a38b69a792fb25c3efffbd98609fc18 | |
parent | 21a52c6d05c15f862797736393915bfa8cd40ee9 (diff) |
md: factor out init code for an mddev
This is a simple factorisation that makes mddev_find easier to read.
Signed-off-by: NeilBrown <neilb@suse.de>
-rw-r--r-- | drivers/md/md.c | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 2e05b0c2515d..d3579fc9efed 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -416,6 +416,27 @@ static void mddev_put(mddev_t *mddev) | |||
416 | spin_unlock(&all_mddevs_lock); | 416 | spin_unlock(&all_mddevs_lock); |
417 | } | 417 | } |
418 | 418 | ||
419 | static void mddev_init(mddev_t *mddev) | ||
420 | { | ||
421 | mutex_init(&mddev->open_mutex); | ||
422 | mutex_init(&mddev->reconfig_mutex); | ||
423 | mutex_init(&mddev->bitmap_info.mutex); | ||
424 | INIT_LIST_HEAD(&mddev->disks); | ||
425 | INIT_LIST_HEAD(&mddev->all_mddevs); | ||
426 | init_timer(&mddev->safemode_timer); | ||
427 | atomic_set(&mddev->active, 1); | ||
428 | atomic_set(&mddev->openers, 0); | ||
429 | atomic_set(&mddev->active_io, 0); | ||
430 | spin_lock_init(&mddev->write_lock); | ||
431 | atomic_set(&mddev->flush_pending, 0); | ||
432 | init_waitqueue_head(&mddev->sb_wait); | ||
433 | init_waitqueue_head(&mddev->recovery_wait); | ||
434 | mddev->reshape_position = MaxSector; | ||
435 | mddev->resync_min = 0; | ||
436 | mddev->resync_max = MaxSector; | ||
437 | mddev->level = LEVEL_NONE; | ||
438 | } | ||
439 | |||
419 | static mddev_t * mddev_find(dev_t unit) | 440 | static mddev_t * mddev_find(dev_t unit) |
420 | { | 441 | { |
421 | mddev_t *mddev, *new = NULL; | 442 | mddev_t *mddev, *new = NULL; |
@@ -482,23 +503,7 @@ static mddev_t * mddev_find(dev_t unit) | |||
482 | else | 503 | else |
483 | new->md_minor = MINOR(unit) >> MdpMinorShift; | 504 | new->md_minor = MINOR(unit) >> MdpMinorShift; |
484 | 505 | ||
485 | mutex_init(&new->open_mutex); | 506 | mddev_init(new); |
486 | mutex_init(&new->reconfig_mutex); | ||
487 | mutex_init(&new->bitmap_info.mutex); | ||
488 | INIT_LIST_HEAD(&new->disks); | ||
489 | INIT_LIST_HEAD(&new->all_mddevs); | ||
490 | init_timer(&new->safemode_timer); | ||
491 | atomic_set(&new->active, 1); | ||
492 | atomic_set(&new->openers, 0); | ||
493 | atomic_set(&new->active_io, 0); | ||
494 | spin_lock_init(&new->write_lock); | ||
495 | atomic_set(&new->flush_pending, 0); | ||
496 | init_waitqueue_head(&new->sb_wait); | ||
497 | init_waitqueue_head(&new->recovery_wait); | ||
498 | new->reshape_position = MaxSector; | ||
499 | new->resync_min = 0; | ||
500 | new->resync_max = MaxSector; | ||
501 | new->level = LEVEL_NONE; | ||
502 | 507 | ||
503 | goto retry; | 508 | goto retry; |
504 | } | 509 | } |