diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/md/md.c | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 0dc563d76b39..f173ace1f8fb 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -5770,26 +5770,47 @@ static int __init md_init(void) | |||
5770 | * Searches all registered partitions for autorun RAID arrays | 5770 | * Searches all registered partitions for autorun RAID arrays |
5771 | * at boot time. | 5771 | * at boot time. |
5772 | */ | 5772 | */ |
5773 | static dev_t detected_devices[128]; | 5773 | |
5774 | static int dev_cnt; | 5774 | static LIST_HEAD(all_detected_devices); |
5775 | struct detected_devices_node { | ||
5776 | struct list_head list; | ||
5777 | dev_t dev; | ||
5778 | }; | ||
5775 | 5779 | ||
5776 | void md_autodetect_dev(dev_t dev) | 5780 | void md_autodetect_dev(dev_t dev) |
5777 | { | 5781 | { |
5778 | if (dev_cnt >= 0 && dev_cnt < 127) | 5782 | struct detected_devices_node *node_detected_dev; |
5779 | detected_devices[dev_cnt++] = dev; | 5783 | |
5784 | node_detected_dev = kzalloc(sizeof(*node_detected_dev), GFP_KERNEL); | ||
5785 | if (node_detected_dev) { | ||
5786 | node_detected_dev->dev = dev; | ||
5787 | list_add_tail(&node_detected_dev->list, &all_detected_devices); | ||
5788 | } else { | ||
5789 | printk(KERN_CRIT "md: md_autodetect_dev: kzalloc failed" | ||
5790 | ", skipping dev(%d,%d)\n", MAJOR(dev), MINOR(dev)); | ||
5791 | } | ||
5780 | } | 5792 | } |
5781 | 5793 | ||
5782 | 5794 | ||
5783 | static void autostart_arrays(int part) | 5795 | static void autostart_arrays(int part) |
5784 | { | 5796 | { |
5785 | mdk_rdev_t *rdev; | 5797 | mdk_rdev_t *rdev; |
5786 | int i; | 5798 | struct detected_devices_node *node_detected_dev; |
5799 | dev_t dev; | ||
5800 | int i_scanned, i_passed; | ||
5787 | 5801 | ||
5788 | printk(KERN_INFO "md: Autodetecting RAID arrays.\n"); | 5802 | i_scanned = 0; |
5803 | i_passed = 0; | ||
5789 | 5804 | ||
5790 | for (i = 0; i < dev_cnt; i++) { | 5805 | printk(KERN_INFO "md: Autodetecting RAID arrays.\n"); |
5791 | dev_t dev = detected_devices[i]; | ||
5792 | 5806 | ||
5807 | while (!list_empty(&all_detected_devices) && i_scanned < INT_MAX) { | ||
5808 | i_scanned++; | ||
5809 | node_detected_dev = list_entry(all_detected_devices.next, | ||
5810 | struct detected_devices_node, list); | ||
5811 | list_del(&node_detected_dev->list); | ||
5812 | dev = node_detected_dev->dev; | ||
5813 | kfree(node_detected_dev); | ||
5793 | rdev = md_import_device(dev,0, 90); | 5814 | rdev = md_import_device(dev,0, 90); |
5794 | if (IS_ERR(rdev)) | 5815 | if (IS_ERR(rdev)) |
5795 | continue; | 5816 | continue; |
@@ -5799,8 +5820,11 @@ static void autostart_arrays(int part) | |||
5799 | continue; | 5820 | continue; |
5800 | } | 5821 | } |
5801 | list_add(&rdev->same_set, &pending_raid_disks); | 5822 | list_add(&rdev->same_set, &pending_raid_disks); |
5823 | i_passed++; | ||
5802 | } | 5824 | } |
5803 | dev_cnt = 0; | 5825 | |
5826 | printk(KERN_INFO "md: Scanned %d and added %d devices.\n", | ||
5827 | i_scanned, i_passed); | ||
5804 | 5828 | ||
5805 | autorun_devices(part); | 5829 | autorun_devices(part); |
5806 | } | 5830 | } |