diff options
author | NeilBrown <neilb@suse.de> | 2010-06-01 05:37:26 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2010-07-25 22:52:27 -0400 |
commit | e8bb9a839a26f076379e9cb9f46a879d210156f1 (patch) | |
tree | 4da184e861cc5fea4967089711dfdc4fbb175f43 /drivers/md/md.c | |
parent | 676e42d896ab6967859fabbb06f4e11b9615cbcf (diff) |
md: split out md_rdev_init
This functionality will be needed separately in a subsequent patch, so
split it into it's own exported function.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r-- | drivers/md/md.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index d636b0a40fac..3de623aceed0 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -2691,6 +2691,24 @@ static struct kobj_type rdev_ktype = { | |||
2691 | .default_attrs = rdev_default_attrs, | 2691 | .default_attrs = rdev_default_attrs, |
2692 | }; | 2692 | }; |
2693 | 2693 | ||
2694 | void md_rdev_init(mdk_rdev_t *rdev) | ||
2695 | { | ||
2696 | rdev->desc_nr = -1; | ||
2697 | rdev->saved_raid_disk = -1; | ||
2698 | rdev->raid_disk = -1; | ||
2699 | rdev->flags = 0; | ||
2700 | rdev->data_offset = 0; | ||
2701 | rdev->sb_events = 0; | ||
2702 | rdev->last_read_error.tv_sec = 0; | ||
2703 | rdev->last_read_error.tv_nsec = 0; | ||
2704 | atomic_set(&rdev->nr_pending, 0); | ||
2705 | atomic_set(&rdev->read_errors, 0); | ||
2706 | atomic_set(&rdev->corrected_errors, 0); | ||
2707 | |||
2708 | INIT_LIST_HEAD(&rdev->same_set); | ||
2709 | init_waitqueue_head(&rdev->blocked_wait); | ||
2710 | } | ||
2711 | EXPORT_SYMBOL_GPL(md_rdev_init); | ||
2694 | /* | 2712 | /* |
2695 | * Import a device. If 'super_format' >= 0, then sanity check the superblock | 2713 | * Import a device. If 'super_format' >= 0, then sanity check the superblock |
2696 | * | 2714 | * |
@@ -2714,6 +2732,7 @@ static mdk_rdev_t *md_import_device(dev_t newdev, int super_format, int super_mi | |||
2714 | return ERR_PTR(-ENOMEM); | 2732 | return ERR_PTR(-ENOMEM); |
2715 | } | 2733 | } |
2716 | 2734 | ||
2735 | md_rdev_init(rdev); | ||
2717 | if ((err = alloc_disk_sb(rdev))) | 2736 | if ((err = alloc_disk_sb(rdev))) |
2718 | goto abort_free; | 2737 | goto abort_free; |
2719 | 2738 | ||
@@ -2723,18 +2742,6 @@ static mdk_rdev_t *md_import_device(dev_t newdev, int super_format, int super_mi | |||
2723 | 2742 | ||
2724 | kobject_init(&rdev->kobj, &rdev_ktype); | 2743 | kobject_init(&rdev->kobj, &rdev_ktype); |
2725 | 2744 | ||
2726 | rdev->desc_nr = -1; | ||
2727 | rdev->saved_raid_disk = -1; | ||
2728 | rdev->raid_disk = -1; | ||
2729 | rdev->flags = 0; | ||
2730 | rdev->data_offset = 0; | ||
2731 | rdev->sb_events = 0; | ||
2732 | rdev->last_read_error.tv_sec = 0; | ||
2733 | rdev->last_read_error.tv_nsec = 0; | ||
2734 | atomic_set(&rdev->nr_pending, 0); | ||
2735 | atomic_set(&rdev->read_errors, 0); | ||
2736 | atomic_set(&rdev->corrected_errors, 0); | ||
2737 | |||
2738 | size = rdev->bdev->bd_inode->i_size >> BLOCK_SIZE_BITS; | 2745 | size = rdev->bdev->bd_inode->i_size >> BLOCK_SIZE_BITS; |
2739 | if (!size) { | 2746 | if (!size) { |
2740 | printk(KERN_WARNING | 2747 | printk(KERN_WARNING |
@@ -2763,9 +2770,6 @@ static mdk_rdev_t *md_import_device(dev_t newdev, int super_format, int super_mi | |||
2763 | } | 2770 | } |
2764 | } | 2771 | } |
2765 | 2772 | ||
2766 | INIT_LIST_HEAD(&rdev->same_set); | ||
2767 | init_waitqueue_head(&rdev->blocked_wait); | ||
2768 | |||
2769 | return rdev; | 2773 | return rdev; |
2770 | 2774 | ||
2771 | abort_free: | 2775 | abort_free: |