aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/compression.c
diff options
context:
space:
mode:
authorJeff Mahoney <jeffm@suse.com>2012-03-12 11:03:00 -0400
committerDavid Sterba <dsterba@suse.cz>2012-03-22 06:52:54 -0400
commit79787eaab46121d4713ed03c8fc63b9ec3eaec76 (patch)
treeee6b17d0811ee54ab74a03aa4e0bb92769d2f12a /fs/btrfs/compression.c
parent49b25e0540904be0bf558b84475c69d72e4de66e (diff)
btrfs: replace many BUG_ONs with proper error handling
btrfs currently handles most errors with BUG_ON. This patch is a work-in- progress but aims to handle most errors other than internal logic errors and ENOMEM more gracefully. This iteration prevents most crashes but can run into lockups with the page lock on occasion when the timing "works out." Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Diffstat (limited to 'fs/btrfs/compression.c')
-rw-r--r--fs/btrfs/compression.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index cfd158dccdec..d11afa67c7d8 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -391,16 +391,16 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
391 */ 391 */
392 atomic_inc(&cb->pending_bios); 392 atomic_inc(&cb->pending_bios);
393 ret = btrfs_bio_wq_end_io(root->fs_info, bio, 0); 393 ret = btrfs_bio_wq_end_io(root->fs_info, bio, 0);
394 BUG_ON(ret); 394 BUG_ON(ret); /* -ENOMEM */
395 395
396 if (!skip_sum) { 396 if (!skip_sum) {
397 ret = btrfs_csum_one_bio(root, inode, bio, 397 ret = btrfs_csum_one_bio(root, inode, bio,
398 start, 1); 398 start, 1);
399 BUG_ON(ret); 399 BUG_ON(ret); /* -ENOMEM */
400 } 400 }
401 401
402 ret = btrfs_map_bio(root, WRITE, bio, 0, 1); 402 ret = btrfs_map_bio(root, WRITE, bio, 0, 1);
403 BUG_ON(ret); 403 BUG_ON(ret); /* -ENOMEM */
404 404
405 bio_put(bio); 405 bio_put(bio);
406 406
@@ -420,15 +420,15 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
420 bio_get(bio); 420 bio_get(bio);
421 421
422 ret = btrfs_bio_wq_end_io(root->fs_info, bio, 0); 422 ret = btrfs_bio_wq_end_io(root->fs_info, bio, 0);
423 BUG_ON(ret); 423 BUG_ON(ret); /* -ENOMEM */
424 424
425 if (!skip_sum) { 425 if (!skip_sum) {
426 ret = btrfs_csum_one_bio(root, inode, bio, start, 1); 426 ret = btrfs_csum_one_bio(root, inode, bio, start, 1);
427 BUG_ON(ret); 427 BUG_ON(ret); /* -ENOMEM */
428 } 428 }
429 429
430 ret = btrfs_map_bio(root, WRITE, bio, 0, 1); 430 ret = btrfs_map_bio(root, WRITE, bio, 0, 1);
431 BUG_ON(ret); 431 BUG_ON(ret); /* -ENOMEM */
432 432
433 bio_put(bio); 433 bio_put(bio);
434 return 0; 434 return 0;
@@ -661,7 +661,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
661 bio_get(comp_bio); 661 bio_get(comp_bio);
662 662
663 ret = btrfs_bio_wq_end_io(root->fs_info, comp_bio, 0); 663 ret = btrfs_bio_wq_end_io(root->fs_info, comp_bio, 0);
664 BUG_ON(ret); 664 BUG_ON(ret); /* -ENOMEM */
665 665
666 /* 666 /*
667 * inc the count before we submit the bio so 667 * inc the count before we submit the bio so
@@ -674,14 +674,14 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
674 if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)) { 674 if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)) {
675 ret = btrfs_lookup_bio_sums(root, inode, 675 ret = btrfs_lookup_bio_sums(root, inode,
676 comp_bio, sums); 676 comp_bio, sums);
677 BUG_ON(ret); 677 BUG_ON(ret); /* -ENOMEM */
678 } 678 }
679 sums += (comp_bio->bi_size + root->sectorsize - 1) / 679 sums += (comp_bio->bi_size + root->sectorsize - 1) /
680 root->sectorsize; 680 root->sectorsize;
681 681
682 ret = btrfs_map_bio(root, READ, comp_bio, 682 ret = btrfs_map_bio(root, READ, comp_bio,
683 mirror_num, 0); 683 mirror_num, 0);
684 BUG_ON(ret); 684 BUG_ON(ret); /* -ENOMEM */
685 685
686 bio_put(comp_bio); 686 bio_put(comp_bio);
687 687
@@ -697,15 +697,15 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
697 bio_get(comp_bio); 697 bio_get(comp_bio);
698 698
699 ret = btrfs_bio_wq_end_io(root->fs_info, comp_bio, 0); 699 ret = btrfs_bio_wq_end_io(root->fs_info, comp_bio, 0);
700 BUG_ON(ret); 700 BUG_ON(ret); /* -ENOMEM */
701 701
702 if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)) { 702 if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)) {
703 ret = btrfs_lookup_bio_sums(root, inode, comp_bio, sums); 703 ret = btrfs_lookup_bio_sums(root, inode, comp_bio, sums);
704 BUG_ON(ret); 704 BUG_ON(ret); /* -ENOMEM */
705 } 705 }
706 706
707 ret = btrfs_map_bio(root, READ, comp_bio, mirror_num, 0); 707 ret = btrfs_map_bio(root, READ, comp_bio, mirror_num, 0);
708 BUG_ON(ret); 708 BUG_ON(ret); /* -ENOMEM */
709 709
710 bio_put(comp_bio); 710 bio_put(comp_bio);
711 return 0; 711 return 0;