aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMichael J. Evans <mjevans1983@gmail.com>2007-10-17 02:30:52 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-17 11:43:03 -0400
commit4d936ec1fdc1541cd6d59d21ddb8b9386e2fcc4c (patch)
tree14670d1b900b7fa21488e4809c287cbf7a7ab358 /drivers
parenta686cd898bd999fd026a51e90fb0a3410d258ddb (diff)
md: software Raid autodetect dev list not array
In current release kernels the md module (Software RAID) uses a static array (dev_t[128]) to store partition/device info temporarily for autostart. I discovered this (and that the devices are added as disks/partitions are discovered at boot) while I was debugging why only one of my MD arrays would come up whole, while all the others were short a disk. I eventually discovered that it was enumerating through all of 9 of my 11 hds (2 had only 4 partitions apiece) while the other 9 have 15 partitions (I wanted 64 per drive...). The last partition of the 8th drive in my 9 drive raid 5 sets wasn't added, thus making the final md array short both a parity and data disk, and it was started later, elsewhere. This patch replaces that static array with a list. [akpm@linux-foundation.org: removed unused var] Signed-off-by: Michael J. Evans <mjevans1983@gmail.com> Cc: Neil Brown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/md.c42
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 */
5773static dev_t detected_devices[128]; 5773
5774static int dev_cnt; 5774static LIST_HEAD(all_detected_devices);
5775struct detected_devices_node {
5776 struct list_head list;
5777 dev_t dev;
5778};
5775 5779
5776void md_autodetect_dev(dev_t dev) 5780void 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
5783static void autostart_arrays(int part) 5795static 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}