History

md: remove MD_BUG()

Most of the places that call this are doing so pointlessly. A couple of the others a best replaced with WARN_ON().

NeilBrown committed 12 years ago

Commit 403df471 parent 3adc28d1 file · +12 −46Browse files

Unified · Split

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