Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

BUG_ON() Conversion in md/raid5.c

this changes if() BUG(); constructs to BUG_ON() which is
cleaner and can better optimized away

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
Signed-off-by: Adrian Bunk <bunk@stusta.de>

authored by

Eric Sesterhenn and committed by
Adrian Bunk
78bafebd 733f8969

+12 -22
+12 -22
drivers/md/raid5.c
··· 73 73 static void __release_stripe(raid5_conf_t *conf, struct stripe_head *sh) 74 74 { 75 75 if (atomic_dec_and_test(&sh->count)) { 76 - if (!list_empty(&sh->lru)) 77 - BUG(); 78 - if (atomic_read(&conf->active_stripes)==0) 79 - BUG(); 76 + BUG_ON(!list_empty(&sh->lru)); 77 + BUG_ON(atomic_read(&conf->active_stripes)==0); 80 78 if (test_bit(STRIPE_HANDLE, &sh->state)) { 81 79 if (test_bit(STRIPE_DELAYED, &sh->state)) 82 80 list_add_tail(&sh->lru, &conf->delayed_list); ··· 182 184 raid5_conf_t *conf = sh->raid_conf; 183 185 int i; 184 186 185 - if (atomic_read(&sh->count) != 0) 186 - BUG(); 187 - if (test_bit(STRIPE_HANDLE, &sh->state)) 188 - BUG(); 187 + BUG_ON(atomic_read(&sh->count) != 0); 188 + BUG_ON(test_bit(STRIPE_HANDLE, &sh->state)); 189 189 190 190 CHECK_DEVLOCK(); 191 191 PRINTK("init_stripe called, stripe %llu\n", ··· 265 269 init_stripe(sh, sector, pd_idx, disks); 266 270 } else { 267 271 if (atomic_read(&sh->count)) { 268 - if (!list_empty(&sh->lru)) 269 - BUG(); 272 + BUG_ON(!list_empty(&sh->lru)); 270 273 } else { 271 274 if (!test_bit(STRIPE_HANDLE, &sh->state)) 272 275 atomic_inc(&conf->active_stripes); ··· 460 465 spin_unlock_irq(&conf->device_lock); 461 466 if (!sh) 462 467 return 0; 463 - if (atomic_read(&sh->count)) 464 - BUG(); 468 + BUG_ON(atomic_read(&sh->count)); 465 469 shrink_buffers(sh, conf->pool_size); 466 470 kmem_cache_free(conf->slab_cache, sh); 467 471 atomic_dec(&conf->active_stripes); ··· 876 882 ptr[0] = page_address(sh->dev[pd_idx].page); 877 883 switch(method) { 878 884 case READ_MODIFY_WRITE: 879 - if (!test_bit(R5_UPTODATE, &sh->dev[pd_idx].flags)) 880 - BUG(); 885 + BUG_ON(!test_bit(R5_UPTODATE, &sh->dev[pd_idx].flags)); 881 886 for (i=disks ; i-- ;) { 882 887 if (i==pd_idx) 883 888 continue; ··· 889 896 if (test_and_clear_bit(R5_Overlap, &sh->dev[i].flags)) 890 897 wake_up(&conf->wait_for_overlap); 891 898 892 - if (sh->dev[i].written) BUG(); 899 + BUG_ON(sh->dev[i].written); 893 900 sh->dev[i].written = chosen; 894 901 check_xor(); 895 902 } ··· 905 912 if (test_and_clear_bit(R5_Overlap, &sh->dev[i].flags)) 906 913 wake_up(&conf->wait_for_overlap); 907 914 908 - if (sh->dev[i].written) BUG(); 915 + BUG_ON(sh->dev[i].written); 909 916 sh->dev[i].written = chosen; 910 917 } 911 918 break; ··· 988 995 if (*bip && (*bip)->bi_sector < bi->bi_sector + ((bi->bi_size)>>9)) 989 996 goto overlap; 990 997 991 - if (*bip && bi->bi_next && (*bip) != bi->bi_next) 992 - BUG(); 998 + BUG_ON(*bip && bi->bi_next && (*bip) != bi->bi_next); 993 999 if (*bip) 994 1000 bi->bi_next = *bip; 995 1001 *bip = bi; ··· 1422 1430 set_bit(STRIPE_HANDLE, &sh->state); 1423 1431 if (failed == 0) { 1424 1432 char *pagea; 1425 - if (uptodate != disks) 1426 - BUG(); 1433 + BUG_ON(uptodate != disks); 1427 1434 compute_parity(sh, CHECK_PARITY); 1428 1435 uptodate--; 1429 1436 pagea = page_address(sh->dev[sh->pd_idx].page); ··· 2087 2096 2088 2097 list_del_init(first); 2089 2098 atomic_inc(&sh->count); 2090 - if (atomic_read(&sh->count)!= 1) 2091 - BUG(); 2099 + BUG_ON(atomic_read(&sh->count)!= 1); 2092 2100 spin_unlock_irq(&conf->device_lock); 2093 2101 2094 2102 handled++;