Most of the places that call this are doing so pointlessly. A couple of the others a best replaced with WARN_ON().
Unified · Split
| @@ -75,8 +75,6 @@ static struct workqueue_struct *md_misc_wq; · 74 unmodified lines | ||
| 75 | 75 | static int remove_and_add_spares(struct mddev *mddev, |
| 76 | 76 | struct md_rdev *this); |
| 77 | 77 | |
| 78 | −#define MD_BUG(x...) { printk("md: bug in file %s, line %d\n", __FILE__, __LINE__); md_print_devices(); } | |
| 79 | − | |
| 80 | 78 | /* |
| 81 | 79 | * Default number of read corrections we'll attempt on an rdev |
| 82 | 80 | * before ejecting it from the array. We divide the read error |
| @@ -682,9 +680,6 @@ static inline sector_t calc_dev_sboffset(struct md_rdev *rdev) · 599 unmodified lines | ||
| 682 | 680 | |
| 683 | 681 | static int alloc_disk_sb(struct md_rdev *rdev) |
| 684 | 682 | { |
| 685 | − if (rdev->sb_page) | |
| 686 | − MD_BUG(); | |
| 687 | − | |
| 688 | 683 | rdev->sb_page = alloc_page(GFP_KERNEL); |
| 689 | 684 | if (!rdev->sb_page) { |
| 690 | 685 | printk(KERN_ALERT "md: out of memory.\n"); |
| @@ -784,10 +779,7 @@ EXPORT_SYMBOL_GPL(sync_page_io); · 93 unmodified lines | ||
| 784 | 779 | static int read_disk_sb(struct md_rdev *rdev, int size) |
| 785 | 780 | { |
| 786 | 781 | char b[BDEVNAME_SIZE]; |
| 787 | − if (!rdev->sb_page) { | |
| 788 | − MD_BUG(); | |
| 789 | − return -EINVAL; | |
| 790 | − } | |
| 782 | + | |
| 791 | 783 | if (rdev->sb_loaded) |
| 792 | 784 | return 0; |
| 793 | 785 | |
| @@ -2014,11 +2006,6 @@ static int bind_rdev_to_array(struct md_rdev *rdev, struct mddev *mddev) · 1220 unmodified lines | ||
| 2014 | 2006 | char *s; |
| 2015 | 2007 | int err; |
| 2016 | 2008 | |
| 2017 | − if (rdev->mddev) { | |
| 2018 | − MD_BUG(); | |
| 2019 | − return -EINVAL; | |
| 2020 | − } | |
| 2021 | − | |
| 2022 | 2009 | /* prevent duplicates */ |
| 2023 | 2010 | if (find_rdev(mddev, rdev->bdev->bd_dev)) |
| 2024 | 2011 | return -EEXIST; |
| @@ -2100,10 +2087,7 @@ static void md_delayed_delete(struct work_struct *ws) · 75 unmodified lines | ||
| 2100 | 2087 | static void unbind_rdev_from_array(struct md_rdev *rdev) |
| 2101 | 2088 | { |
| 2102 | 2089 | char b[BDEVNAME_SIZE]; |
| 2103 | − if (!rdev->mddev) { | |
| 2104 | − MD_BUG(); | |
| 2105 | − return; | |
| 2106 | − } | |
| 2090 | + | |
| 2107 | 2091 | bd_unlink_disk_holder(rdev->bdev, rdev->mddev->gendisk); |
| 2108 | 2092 | list_del_rcu(&rdev->same_set); |
| 2109 | 2093 | printk(KERN_INFO "md: unbind<%s>\n", bdevname(rdev->bdev,b)); |
| @@ -2148,8 +2132,6 @@ static void unlock_rdev(struct md_rdev *rdev) · 38 unmodified lines | ||
| 2148 | 2132 | { |
| 2149 | 2133 | struct block_device *bdev = rdev->bdev; |
| 2150 | 2134 | rdev->bdev = NULL; |
| 2151 | − if (!bdev) | |
| 2152 | − MD_BUG(); | |
| 2153 | 2135 | blkdev_put(bdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL); |
| 2154 | 2136 | } |
| 2155 | 2137 | |
| @@ -2158,10 +2140,9 @@ void md_autodetect_dev(dev_t dev); · 2 unmodified lines | ||
| 2158 | 2140 | static void export_rdev(struct md_rdev *rdev) |
| 2159 | 2141 | { |
| 2160 | 2142 | char b[BDEVNAME_SIZE]; |
| 2143 | + | |
| 2161 | 2144 | printk(KERN_INFO "md: export_rdev(%s)\n", |
| 2162 | 2145 | bdevname(rdev->bdev,b)); |
| 2163 | − if (rdev->mddev) | |
| 2164 | − MD_BUG(); | |
| 2165 | 2146 | md_rdev_clear(rdev); |
| 2166 | 2147 | #ifndef MODULE |
| 2167 | 2148 | if (test_bit(AutoDetected, &rdev->flags)) |
| @@ -2427,15 +2408,12 @@ repeat: · 259 unmodified lines | ||
| 2427 | 2408 | mddev->can_decrease_events = nospares; |
| 2428 | 2409 | } |
| 2429 | 2410 | |
| 2430 | − if (!mddev->events) { | |
| 2431 | − /* | |
| 2432 | − * oops, this 64-bit counter should never wrap. | |
| 2433 | − * Either we are in around ~1 trillion A.C., assuming | |
| 2434 | − * 1 reboot per second, or we have a bug: | |
| 2435 | − */ | |
| 2436 | − MD_BUG(); | |
| 2437 | − mddev->events --; | |
| 2438 | − } | |
| 2411 | + /* | |
| 2412 | + * This 64-bit counter should never wrap. | |
| 2413 | + * Either we are in around ~1 trillion A.C., assuming | |
| 2414 | + * 1 reboot per second, or we have a bug... | |
| 2415 | + */ | |
| 2416 | + WARN_ON(mddev->events == 0); | |
| 2439 | 2417 | |
| 2440 | 2418 | rdev_for_each(rdev, mddev) { |
| 2441 | 2419 | if (rdev->badblocks.changed) |
| @@ -6806,11 +6784,6 @@ void md_unregister_thread(struct md_thread **threadp) · 4364 unmodified lines | ||
| 6806 | 6784 | |
| 6807 | 6785 | void md_error(struct mddev *mddev, struct md_rdev *rdev) |
| 6808 | 6786 | { |
| 6809 | − if (!mddev) { | |
| 6810 | − MD_BUG(); | |
| 6811 | − return; | |
| 6812 | − } | |
| 6813 | − | |
| 6814 | 6787 | if (!rdev || test_bit(Faulty, &rdev->flags)) |
| 6815 | 6788 | return; |
| 6816 | 6789 | |
| @@ -6869,13 +6842,7 @@ static void status_resync(struct seq_file *seq, struct mddev *mddev) · 52 unmodified lines | ||
| 6869 | 6842 | else |
| 6870 | 6843 | max_sectors = mddev->dev_sectors; |
| 6871 | 6844 | |
| 6872 | − /* | |
| 6873 | − * Should not happen. | |
| 6874 | − */ | |
| 6875 | − if (!max_sectors) { | |
| 6876 | − MD_BUG(); | |
| 6877 | − return; | |
| 6878 | − } | |
| 6845 | + WARN_ON(max_sectors == 0); | |
| 6879 | 6846 | /* Pick 'scale' such that (resync>>scale)*1000 will fit |
| 6880 | 6847 | * in a sector_t, and (max_sectors>>scale) will fit in a |
| 6881 | 6848 | * u32, as those are the requirements for sector_div. |
| @@ -8627,10 +8594,9 @@ static void autostart_arrays(int part) · 1745 unmodified lines | ||
| 8627 | 8594 | if (IS_ERR(rdev)) |
| 8628 | 8595 | continue; |
| 8629 | 8596 | |
| 8630 | − if (test_bit(Faulty, &rdev->flags)) { | |
| 8631 | − MD_BUG(); | |
| 8597 | + if (test_bit(Faulty, &rdev->flags)) | |
| 8632 | 8598 | continue; |
| 8633 | − } | |
| 8599 | + | |
| 8634 | 8600 | set_bit(AutoDetected, &rdev->flags); |
| 8635 | 8601 | list_add(&rdev->same_set, &pending_raid_disks); |
| 8636 | 8602 | i_passed++; |