diff options
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/compression.c | 2 | ||||
-rw-r--r-- | fs/btrfs/ctree.h | 2 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 11 | ||||
-rw-r--r-- | fs/btrfs/extent_io.c | 6 | ||||
-rw-r--r-- | fs/btrfs/free-space-cache.c | 9 | ||||
-rw-r--r-- | fs/btrfs/scrub.c | 4 | ||||
-rw-r--r-- | fs/btrfs/transaction.c | 9 | ||||
-rw-r--r-- | fs/btrfs/volumes.c | 20 |
8 files changed, 41 insertions, 22 deletions
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index d286b40a5671..86eff48dab78 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c | |||
@@ -405,6 +405,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start, | |||
405 | bio_put(bio); | 405 | bio_put(bio); |
406 | 406 | ||
407 | bio = compressed_bio_alloc(bdev, first_byte, GFP_NOFS); | 407 | bio = compressed_bio_alloc(bdev, first_byte, GFP_NOFS); |
408 | BUG_ON(!bio); | ||
408 | bio->bi_private = cb; | 409 | bio->bi_private = cb; |
409 | bio->bi_end_io = end_compressed_bio_write; | 410 | bio->bi_end_io = end_compressed_bio_write; |
410 | bio_add_page(bio, page, PAGE_CACHE_SIZE, 0); | 411 | bio_add_page(bio, page, PAGE_CACHE_SIZE, 0); |
@@ -687,6 +688,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, | |||
687 | 688 | ||
688 | comp_bio = compressed_bio_alloc(bdev, cur_disk_byte, | 689 | comp_bio = compressed_bio_alloc(bdev, cur_disk_byte, |
689 | GFP_NOFS); | 690 | GFP_NOFS); |
691 | BUG_ON(!comp_bio); | ||
690 | comp_bio->bi_private = cb; | 692 | comp_bio->bi_private = cb; |
691 | comp_bio->bi_end_io = end_compressed_bio_read; | 693 | comp_bio->bi_end_io = end_compressed_bio_read; |
692 | 694 | ||
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 5b8ef8eb3521..3f65a812e282 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -2166,7 +2166,7 @@ BTRFS_SETGET_STACK_FUNCS(root_last_snapshot, struct btrfs_root_item, | |||
2166 | 2166 | ||
2167 | static inline bool btrfs_root_readonly(struct btrfs_root *root) | 2167 | static inline bool btrfs_root_readonly(struct btrfs_root *root) |
2168 | { | 2168 | { |
2169 | return root->root_item.flags & BTRFS_ROOT_SUBVOL_RDONLY; | 2169 | return (root->root_item.flags & cpu_to_le64(BTRFS_ROOT_SUBVOL_RDONLY)) != 0; |
2170 | } | 2170 | } |
2171 | 2171 | ||
2172 | /* struct btrfs_root_backup */ | 2172 | /* struct btrfs_root_backup */ |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index a84420491c11..2b35f8d14bb9 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -529,9 +529,7 @@ static int cache_block_group(struct btrfs_block_group_cache *cache, | |||
529 | * allocate blocks for the tree root we can't do the fast caching since | 529 | * allocate blocks for the tree root we can't do the fast caching since |
530 | * we likely hold important locks. | 530 | * we likely hold important locks. |
531 | */ | 531 | */ |
532 | if (trans && (!trans->transaction->in_commit) && | 532 | if (fs_info->mount_opt & BTRFS_MOUNT_SPACE_CACHE) { |
533 | (root && root != root->fs_info->tree_root) && | ||
534 | btrfs_test_opt(root, SPACE_CACHE)) { | ||
535 | ret = load_free_space_cache(fs_info, cache); | 533 | ret = load_free_space_cache(fs_info, cache); |
536 | 534 | ||
537 | spin_lock(&cache->lock); | 535 | spin_lock(&cache->lock); |
@@ -3152,15 +3150,14 @@ static void set_avail_alloc_bits(struct btrfs_fs_info *fs_info, u64 flags) | |||
3152 | /* | 3150 | /* |
3153 | * returns target flags in extended format or 0 if restripe for this | 3151 | * returns target flags in extended format or 0 if restripe for this |
3154 | * chunk_type is not in progress | 3152 | * chunk_type is not in progress |
3153 | * | ||
3154 | * should be called with either volume_mutex or balance_lock held | ||
3155 | */ | 3155 | */ |
3156 | static u64 get_restripe_target(struct btrfs_fs_info *fs_info, u64 flags) | 3156 | static u64 get_restripe_target(struct btrfs_fs_info *fs_info, u64 flags) |
3157 | { | 3157 | { |
3158 | struct btrfs_balance_control *bctl = fs_info->balance_ctl; | 3158 | struct btrfs_balance_control *bctl = fs_info->balance_ctl; |
3159 | u64 target = 0; | 3159 | u64 target = 0; |
3160 | 3160 | ||
3161 | BUG_ON(!mutex_is_locked(&fs_info->volume_mutex) && | ||
3162 | !spin_is_locked(&fs_info->balance_lock)); | ||
3163 | |||
3164 | if (!bctl) | 3161 | if (!bctl) |
3165 | return 0; | 3162 | return 0; |
3166 | 3163 | ||
@@ -4205,7 +4202,7 @@ static u64 calc_global_metadata_size(struct btrfs_fs_info *fs_info) | |||
4205 | num_bytes += div64_u64(data_used + meta_used, 50); | 4202 | num_bytes += div64_u64(data_used + meta_used, 50); |
4206 | 4203 | ||
4207 | if (num_bytes * 3 > meta_used) | 4204 | if (num_bytes * 3 > meta_used) |
4208 | num_bytes = div64_u64(meta_used, 3) * 2; | 4205 | num_bytes = div64_u64(meta_used, 3); |
4209 | 4206 | ||
4210 | return ALIGN(num_bytes, fs_info->extent_root->leafsize << 10); | 4207 | return ALIGN(num_bytes, fs_info->extent_root->leafsize << 10); |
4211 | } | 4208 | } |
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 8d904dd7ea9f..cd4b5e400221 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c | |||
@@ -1937,7 +1937,7 @@ int repair_eb_io_failure(struct btrfs_root *root, struct extent_buffer *eb, | |||
1937 | struct btrfs_mapping_tree *map_tree = &root->fs_info->mapping_tree; | 1937 | struct btrfs_mapping_tree *map_tree = &root->fs_info->mapping_tree; |
1938 | u64 start = eb->start; | 1938 | u64 start = eb->start; |
1939 | unsigned long i, num_pages = num_extent_pages(eb->start, eb->len); | 1939 | unsigned long i, num_pages = num_extent_pages(eb->start, eb->len); |
1940 | int ret; | 1940 | int ret = 0; |
1941 | 1941 | ||
1942 | for (i = 0; i < num_pages; i++) { | 1942 | for (i = 0; i < num_pages; i++) { |
1943 | struct page *p = extent_buffer_page(eb, i); | 1943 | struct page *p = extent_buffer_page(eb, i); |
@@ -2180,6 +2180,10 @@ static int bio_readpage_error(struct bio *failed_bio, struct page *page, | |||
2180 | } | 2180 | } |
2181 | 2181 | ||
2182 | bio = bio_alloc(GFP_NOFS, 1); | 2182 | bio = bio_alloc(GFP_NOFS, 1); |
2183 | if (!bio) { | ||
2184 | free_io_failure(inode, failrec, 0); | ||
2185 | return -EIO; | ||
2186 | } | ||
2183 | bio->bi_private = state; | 2187 | bio->bi_private = state; |
2184 | bio->bi_end_io = failed_bio->bi_end_io; | 2188 | bio->bi_end_io = failed_bio->bi_end_io; |
2185 | bio->bi_sector = failrec->logical >> 9; | 2189 | bio->bi_sector = failrec->logical >> 9; |
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index e88330d3df52..202008ec367d 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c | |||
@@ -748,13 +748,6 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info, | |||
748 | u64 used = btrfs_block_group_used(&block_group->item); | 748 | u64 used = btrfs_block_group_used(&block_group->item); |
749 | 749 | ||
750 | /* | 750 | /* |
751 | * If we're unmounting then just return, since this does a search on the | ||
752 | * normal root and not the commit root and we could deadlock. | ||
753 | */ | ||
754 | if (btrfs_fs_closing(fs_info)) | ||
755 | return 0; | ||
756 | |||
757 | /* | ||
758 | * If this block group has been marked to be cleared for one reason or | 751 | * If this block group has been marked to be cleared for one reason or |
759 | * another then we can't trust the on disk cache, so just return. | 752 | * another then we can't trust the on disk cache, so just return. |
760 | */ | 753 | */ |
@@ -768,6 +761,8 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info, | |||
768 | path = btrfs_alloc_path(); | 761 | path = btrfs_alloc_path(); |
769 | if (!path) | 762 | if (!path) |
770 | return 0; | 763 | return 0; |
764 | path->search_commit_root = 1; | ||
765 | path->skip_locking = 1; | ||
771 | 766 | ||
772 | inode = lookup_free_space_inode(root, block_group, path); | 767 | inode = lookup_free_space_inode(root, block_group, path); |
773 | if (IS_ERR(inode)) { | 768 | if (IS_ERR(inode)) { |
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index 90acc82046c3..bc015f77f3ea 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c | |||
@@ -1044,6 +1044,8 @@ static int scrub_recheck_block(struct btrfs_fs_info *fs_info, | |||
1044 | 1044 | ||
1045 | BUG_ON(!page->page); | 1045 | BUG_ON(!page->page); |
1046 | bio = bio_alloc(GFP_NOFS, 1); | 1046 | bio = bio_alloc(GFP_NOFS, 1); |
1047 | if (!bio) | ||
1048 | return -EIO; | ||
1047 | bio->bi_bdev = page->bdev; | 1049 | bio->bi_bdev = page->bdev; |
1048 | bio->bi_sector = page->physical >> 9; | 1050 | bio->bi_sector = page->physical >> 9; |
1049 | bio->bi_end_io = scrub_complete_bio_end_io; | 1051 | bio->bi_end_io = scrub_complete_bio_end_io; |
@@ -1171,6 +1173,8 @@ static int scrub_repair_page_from_good_copy(struct scrub_block *sblock_bad, | |||
1171 | DECLARE_COMPLETION_ONSTACK(complete); | 1173 | DECLARE_COMPLETION_ONSTACK(complete); |
1172 | 1174 | ||
1173 | bio = bio_alloc(GFP_NOFS, 1); | 1175 | bio = bio_alloc(GFP_NOFS, 1); |
1176 | if (!bio) | ||
1177 | return -EIO; | ||
1174 | bio->bi_bdev = page_bad->bdev; | 1178 | bio->bi_bdev = page_bad->bdev; |
1175 | bio->bi_sector = page_bad->physical >> 9; | 1179 | bio->bi_sector = page_bad->physical >> 9; |
1176 | bio->bi_end_io = scrub_complete_bio_end_io; | 1180 | bio->bi_end_io = scrub_complete_bio_end_io; |
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 8da29e8e4de1..11b77a59db62 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
@@ -480,6 +480,7 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans, | |||
480 | struct btrfs_transaction *cur_trans = trans->transaction; | 480 | struct btrfs_transaction *cur_trans = trans->transaction; |
481 | struct btrfs_fs_info *info = root->fs_info; | 481 | struct btrfs_fs_info *info = root->fs_info; |
482 | int count = 0; | 482 | int count = 0; |
483 | int err = 0; | ||
483 | 484 | ||
484 | if (--trans->use_count) { | 485 | if (--trans->use_count) { |
485 | trans->block_rsv = trans->orig_rsv; | 486 | trans->block_rsv = trans->orig_rsv; |
@@ -532,18 +533,18 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans, | |||
532 | 533 | ||
533 | if (current->journal_info == trans) | 534 | if (current->journal_info == trans) |
534 | current->journal_info = NULL; | 535 | current->journal_info = NULL; |
535 | memset(trans, 0, sizeof(*trans)); | ||
536 | kmem_cache_free(btrfs_trans_handle_cachep, trans); | ||
537 | 536 | ||
538 | if (throttle) | 537 | if (throttle) |
539 | btrfs_run_delayed_iputs(root); | 538 | btrfs_run_delayed_iputs(root); |
540 | 539 | ||
541 | if (trans->aborted || | 540 | if (trans->aborted || |
542 | root->fs_info->fs_state & BTRFS_SUPER_FLAG_ERROR) { | 541 | root->fs_info->fs_state & BTRFS_SUPER_FLAG_ERROR) { |
543 | return -EIO; | 542 | err = -EIO; |
544 | } | 543 | } |
545 | 544 | ||
546 | return 0; | 545 | memset(trans, 0, sizeof(*trans)); |
546 | kmem_cache_free(btrfs_trans_handle_cachep, trans); | ||
547 | return err; | ||
547 | } | 548 | } |
548 | 549 | ||
549 | int btrfs_end_transaction(struct btrfs_trans_handle *trans, | 550 | int btrfs_end_transaction(struct btrfs_trans_handle *trans, |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index a872b48be0ae..759d02486d7c 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -3833,6 +3833,7 @@ static int __btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw, | |||
3833 | int sub_stripes = 0; | 3833 | int sub_stripes = 0; |
3834 | u64 stripes_per_dev = 0; | 3834 | u64 stripes_per_dev = 0; |
3835 | u32 remaining_stripes = 0; | 3835 | u32 remaining_stripes = 0; |
3836 | u32 last_stripe = 0; | ||
3836 | 3837 | ||
3837 | if (map->type & | 3838 | if (map->type & |
3838 | (BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID10)) { | 3839 | (BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID10)) { |
@@ -3846,6 +3847,8 @@ static int __btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw, | |||
3846 | stripe_nr_orig, | 3847 | stripe_nr_orig, |
3847 | factor, | 3848 | factor, |
3848 | &remaining_stripes); | 3849 | &remaining_stripes); |
3850 | div_u64_rem(stripe_nr_end - 1, factor, &last_stripe); | ||
3851 | last_stripe *= sub_stripes; | ||
3849 | } | 3852 | } |
3850 | 3853 | ||
3851 | for (i = 0; i < num_stripes; i++) { | 3854 | for (i = 0; i < num_stripes; i++) { |
@@ -3858,16 +3861,29 @@ static int __btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw, | |||
3858 | BTRFS_BLOCK_GROUP_RAID10)) { | 3861 | BTRFS_BLOCK_GROUP_RAID10)) { |
3859 | bbio->stripes[i].length = stripes_per_dev * | 3862 | bbio->stripes[i].length = stripes_per_dev * |
3860 | map->stripe_len; | 3863 | map->stripe_len; |
3864 | |||
3861 | if (i / sub_stripes < remaining_stripes) | 3865 | if (i / sub_stripes < remaining_stripes) |
3862 | bbio->stripes[i].length += | 3866 | bbio->stripes[i].length += |
3863 | map->stripe_len; | 3867 | map->stripe_len; |
3868 | |||
3869 | /* | ||
3870 | * Special for the first stripe and | ||
3871 | * the last stripe: | ||
3872 | * | ||
3873 | * |-------|...|-------| | ||
3874 | * |----------| | ||
3875 | * off end_off | ||
3876 | */ | ||
3864 | if (i < sub_stripes) | 3877 | if (i < sub_stripes) |
3865 | bbio->stripes[i].length -= | 3878 | bbio->stripes[i].length -= |
3866 | stripe_offset; | 3879 | stripe_offset; |
3867 | if ((i / sub_stripes + 1) % | 3880 | |
3868 | sub_stripes == remaining_stripes) | 3881 | if (stripe_index >= last_stripe && |
3882 | stripe_index <= (last_stripe + | ||
3883 | sub_stripes - 1)) | ||
3869 | bbio->stripes[i].length -= | 3884 | bbio->stripes[i].length -= |
3870 | stripe_end_offset; | 3885 | stripe_end_offset; |
3886 | |||
3871 | if (i == sub_stripes - 1) | 3887 | if (i == sub_stripes - 1) |
3872 | stripe_offset = 0; | 3888 | stripe_offset = 0; |
3873 | } else | 3889 | } else |