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