diff options
Diffstat (limited to 'fs/btrfs/compression.c')
| -rw-r--r-- | fs/btrfs/compression.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index 43d1c5a3a030..94ab2f80e7e3 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c | |||
| @@ -577,6 +577,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, | |||
| 577 | u64 em_start; | 577 | u64 em_start; |
| 578 | struct extent_map *em; | 578 | struct extent_map *em; |
| 579 | int ret = -ENOMEM; | 579 | int ret = -ENOMEM; |
| 580 | int faili = 0; | ||
| 580 | u32 *sums; | 581 | u32 *sums; |
| 581 | 582 | ||
| 582 | tree = &BTRFS_I(inode)->io_tree; | 583 | tree = &BTRFS_I(inode)->io_tree; |
| @@ -626,9 +627,13 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, | |||
| 626 | for (pg_index = 0; pg_index < nr_pages; pg_index++) { | 627 | for (pg_index = 0; pg_index < nr_pages; pg_index++) { |
| 627 | cb->compressed_pages[pg_index] = alloc_page(GFP_NOFS | | 628 | cb->compressed_pages[pg_index] = alloc_page(GFP_NOFS | |
| 628 | __GFP_HIGHMEM); | 629 | __GFP_HIGHMEM); |
| 629 | if (!cb->compressed_pages[pg_index]) | 630 | if (!cb->compressed_pages[pg_index]) { |
| 631 | faili = pg_index - 1; | ||
| 632 | ret = -ENOMEM; | ||
| 630 | goto fail2; | 633 | goto fail2; |
| 634 | } | ||
| 631 | } | 635 | } |
| 636 | faili = nr_pages - 1; | ||
| 632 | cb->nr_pages = nr_pages; | 637 | cb->nr_pages = nr_pages; |
| 633 | 638 | ||
| 634 | add_ra_bio_pages(inode, em_start + em_len, cb); | 639 | add_ra_bio_pages(inode, em_start + em_len, cb); |
| @@ -682,7 +687,8 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, | |||
| 682 | 687 | ||
| 683 | ret = btrfs_map_bio(root, READ, comp_bio, | 688 | ret = btrfs_map_bio(root, READ, comp_bio, |
| 684 | mirror_num, 0); | 689 | mirror_num, 0); |
| 685 | BUG_ON(ret); /* -ENOMEM */ | 690 | if (ret) |
| 691 | bio_endio(comp_bio, ret); | ||
| 686 | 692 | ||
| 687 | bio_put(comp_bio); | 693 | bio_put(comp_bio); |
| 688 | 694 | ||
| @@ -707,14 +713,17 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, | |||
| 707 | } | 713 | } |
| 708 | 714 | ||
| 709 | ret = btrfs_map_bio(root, READ, comp_bio, mirror_num, 0); | 715 | ret = btrfs_map_bio(root, READ, comp_bio, mirror_num, 0); |
| 710 | BUG_ON(ret); /* -ENOMEM */ | 716 | if (ret) |
| 717 | bio_endio(comp_bio, ret); | ||
| 711 | 718 | ||
| 712 | bio_put(comp_bio); | 719 | bio_put(comp_bio); |
| 713 | return 0; | 720 | return 0; |
| 714 | 721 | ||
| 715 | fail2: | 722 | fail2: |
| 716 | for (pg_index = 0; pg_index < nr_pages; pg_index++) | 723 | while (faili >= 0) { |
| 717 | free_page((unsigned long)cb->compressed_pages[pg_index]); | 724 | __free_page(cb->compressed_pages[faili]); |
| 725 | faili--; | ||
| 726 | } | ||
| 718 | 727 | ||
| 719 | kfree(cb->compressed_pages); | 728 | kfree(cb->compressed_pages); |
| 720 | fail1: | 729 | fail1: |
