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
7575 static int remove_and_add_spares(struct mddev *mddev,
7676 struct md_rdev *this);
7777
78−#define MD_BUG(x...) { printk("md: bug in file %s, line %d\n", __FILE__, __LINE__); md_print_devices(); }
79−
8078 /*
8179 * Default number of read corrections we'll attempt on an rdev
8280 * 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
682680
683681 static int alloc_disk_sb(struct md_rdev *rdev)
684682 {
685− if (rdev->sb_page)
686− MD_BUG();
687−
688683 rdev->sb_page = alloc_page(GFP_KERNEL);
689684 if (!rdev->sb_page) {
690685 printk(KERN_ALERT "md: out of memory.\n");
@@ -784,10 +779,7 @@ EXPORT_SYMBOL_GPL(sync_page_io); · 93 unmodified lines
784779 static int read_disk_sb(struct md_rdev *rdev, int size)
785780 {
786781 char b[BDEVNAME_SIZE];
787− if (!rdev->sb_page) {
788− MD_BUG();
789− return -EINVAL;
790− }
782+
791783 if (rdev->sb_loaded)
792784 return 0;
793785
@@ -2014,11 +2006,6 @@ static int bind_rdev_to_array(struct md_rdev *rdev, struct mddev *mddev) · 1220 unmodified lines
20142006 char *s;
20152007 int err;
20162008
2017− if (rdev->mddev) {
2018− MD_BUG();
2019− return -EINVAL;
2020− }
2021−
20222009 /* prevent duplicates */
20232010 if (find_rdev(mddev, rdev->bdev->bd_dev))
20242011 return -EEXIST;
@@ -2100,10 +2087,7 @@ static void md_delayed_delete(struct work_struct *ws) · 75 unmodified lines
21002087 static void unbind_rdev_from_array(struct md_rdev *rdev)
21012088 {
21022089 char b[BDEVNAME_SIZE];
2103− if (!rdev->mddev) {
2104− MD_BUG();
2105− return;
2106− }
2090+
21072091 bd_unlink_disk_holder(rdev->bdev, rdev->mddev->gendisk);
21082092 list_del_rcu(&rdev->same_set);
21092093 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
21482132 {
21492133 struct block_device *bdev = rdev->bdev;
21502134 rdev->bdev = NULL;
2151− if (!bdev)
2152− MD_BUG();
21532135 blkdev_put(bdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL);
21542136 }
21552137
@@ -2158,10 +2140,9 @@ void md_autodetect_dev(dev_t dev); · 2 unmodified lines
21582140 static void export_rdev(struct md_rdev *rdev)
21592141 {
21602142 char b[BDEVNAME_SIZE];
2143+
21612144 printk(KERN_INFO "md: export_rdev(%s)\n",
21622145 bdevname(rdev->bdev,b));
2163− if (rdev->mddev)
2164− MD_BUG();
21652146 md_rdev_clear(rdev);
21662147 #ifndef MODULE
21672148 if (test_bit(AutoDetected, &rdev->flags))
@@ -2427,15 +2408,12 @@ repeat: · 259 unmodified lines
24272408 mddev->can_decrease_events = nospares;
24282409 }
24292410
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);
24392417
24402418 rdev_for_each(rdev, mddev) {
24412419 if (rdev->badblocks.changed)
@@ -6806,11 +6784,6 @@ void md_unregister_thread(struct md_thread **threadp) · 4364 unmodified lines
68066784
68076785 void md_error(struct mddev *mddev, struct md_rdev *rdev)
68086786 {
6809− if (!mddev) {
6810− MD_BUG();
6811− return;
6812− }
6813−
68146787 if (!rdev || test_bit(Faulty, &rdev->flags))
68156788 return;
68166789
@@ -6869,13 +6842,7 @@ static void status_resync(struct seq_file *seq, struct mddev *mddev) · 52 unmodified lines
68696842 else
68706843 max_sectors = mddev->dev_sectors;
68716844
6872− /*
6873− * Should not happen.
6874− */
6875− if (!max_sectors) {
6876− MD_BUG();
6877− return;
6878− }
6845+ WARN_ON(max_sectors == 0);
68796846 /* Pick 'scale' such that (resync>>scale)*1000 will fit
68806847 * in a sector_t, and (max_sectors>>scale) will fit in a
68816848 * u32, as those are the requirements for sector_div.
@@ -8627,10 +8594,9 @@ static void autostart_arrays(int part) · 1745 unmodified lines
86278594 if (IS_ERR(rdev))
86288595 continue;
86298596
8630− if (test_bit(Faulty, &rdev->flags)) {
8631− MD_BUG();
8597+ if (test_bit(Faulty, &rdev->flags))
86328598 continue;
8633− }
8599+
86348600 set_bit(AutoDetected, &rdev->flags);
86358601 list_add(&rdev->same_set, &pending_raid_disks);
86368602 i_passed++;