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

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for-linus-min' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs

Pull the minimal btrfs branch from Chris Mason:
"We have a use-after-free in there, along with errors when mount -o
discard is enabled, and a BUG_ON(we should compile with UP more
often)."

* 'for-linus-min' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs:
Btrfs: use commit root when loading free space cache
Btrfs: fix use-after-free in __btrfs_end_transaction
Btrfs: check return value of bio_alloc() properly
Btrfs: remove lock assert from get_restripe_target()
Btrfs: fix eof while discarding extents
Btrfs: fix uninit variable in repair_eb_io_failure
Revert "Btrfs: increase the global block reserve estimates"

+40 -21
+2
fs/btrfs/compression.c
··· 405 405 bio_put(bio); 406 406 407 407 bio = compressed_bio_alloc(bdev, first_byte, GFP_NOFS); 408 + BUG_ON(!bio); 408 409 bio->bi_private = cb; 409 410 bio->bi_end_io = end_compressed_bio_write; 410 411 bio_add_page(bio, page, PAGE_CACHE_SIZE, 0); ··· 688 687 689 688 comp_bio = compressed_bio_alloc(bdev, cur_disk_byte, 690 689 GFP_NOFS); 690 + BUG_ON(!comp_bio); 691 691 comp_bio->bi_private = cb; 692 692 comp_bio->bi_end_io = end_compressed_bio_read; 693 693
+4 -7
fs/btrfs/extent-tree.c
··· 529 529 * allocate blocks for the tree root we can't do the fast caching since 530 530 * we likely hold important locks. 531 531 */ 532 - if (trans && (!trans->transaction->in_commit) && 533 - (root && root != root->fs_info->tree_root) && 534 - btrfs_test_opt(root, SPACE_CACHE)) { 532 + if (fs_info->mount_opt & BTRFS_MOUNT_SPACE_CACHE) { 535 533 ret = load_free_space_cache(fs_info, cache); 536 534 537 535 spin_lock(&cache->lock); ··· 3150 3152 /* 3151 3153 * returns target flags in extended format or 0 if restripe for this 3152 3154 * chunk_type is not in progress 3155 + * 3156 + * should be called with either volume_mutex or balance_lock held 3153 3157 */ 3154 3158 static u64 get_restripe_target(struct btrfs_fs_info *fs_info, u64 flags) 3155 3159 { 3156 3160 struct btrfs_balance_control *bctl = fs_info->balance_ctl; 3157 3161 u64 target = 0; 3158 - 3159 - BUG_ON(!mutex_is_locked(&fs_info->volume_mutex) && 3160 - !spin_is_locked(&fs_info->balance_lock)); 3161 3162 3162 3163 if (!bctl) 3163 3164 return 0; ··· 4202 4205 num_bytes += div64_u64(data_used + meta_used, 50); 4203 4206 4204 4207 if (num_bytes * 3 > meta_used) 4205 - num_bytes = div64_u64(meta_used, 3) * 2; 4208 + num_bytes = div64_u64(meta_used, 3); 4206 4209 4207 4210 return ALIGN(num_bytes, fs_info->extent_root->leafsize << 10); 4208 4211 }
+5 -1
fs/btrfs/extent_io.c
··· 1937 1937 struct btrfs_mapping_tree *map_tree = &root->fs_info->mapping_tree; 1938 1938 u64 start = eb->start; 1939 1939 unsigned long i, num_pages = num_extent_pages(eb->start, eb->len); 1940 - int ret; 1940 + int ret = 0; 1941 1941 1942 1942 for (i = 0; i < num_pages; i++) { 1943 1943 struct page *p = extent_buffer_page(eb, i); ··· 2180 2180 } 2181 2181 2182 2182 bio = bio_alloc(GFP_NOFS, 1); 2183 + if (!bio) { 2184 + free_io_failure(inode, failrec, 0); 2185 + return -EIO; 2186 + } 2183 2187 bio->bi_private = state; 2184 2188 bio->bi_end_io = failed_bio->bi_end_io; 2185 2189 bio->bi_sector = failrec->logical >> 9;
+2 -7
fs/btrfs/free-space-cache.c
··· 748 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 751 * If this block group has been marked to be cleared for one reason or 759 752 * another then we can't trust the on disk cache, so just return. 760 753 */ ··· 761 768 path = btrfs_alloc_path(); 762 769 if (!path) 763 770 return 0; 771 + path->search_commit_root = 1; 772 + path->skip_locking = 1; 764 773 765 774 inode = lookup_free_space_inode(root, block_group, path); 766 775 if (IS_ERR(inode)) {
+4
fs/btrfs/scrub.c
··· 1044 1044 1045 1045 BUG_ON(!page->page); 1046 1046 bio = bio_alloc(GFP_NOFS, 1); 1047 + if (!bio) 1048 + return -EIO; 1047 1049 bio->bi_bdev = page->bdev; 1048 1050 bio->bi_sector = page->physical >> 9; 1049 1051 bio->bi_end_io = scrub_complete_bio_end_io; ··· 1173 1171 DECLARE_COMPLETION_ONSTACK(complete); 1174 1172 1175 1173 bio = bio_alloc(GFP_NOFS, 1); 1174 + if (!bio) 1175 + return -EIO; 1176 1176 bio->bi_bdev = page_bad->bdev; 1177 1177 bio->bi_sector = page_bad->physical >> 9; 1178 1178 bio->bi_end_io = scrub_complete_bio_end_io;
+5 -4
fs/btrfs/transaction.c
··· 480 480 struct btrfs_transaction *cur_trans = trans->transaction; 481 481 struct btrfs_fs_info *info = root->fs_info; 482 482 int count = 0; 483 + int err = 0; 483 484 484 485 if (--trans->use_count) { 485 486 trans->block_rsv = trans->orig_rsv; ··· 533 532 534 533 if (current->journal_info == trans) 535 534 current->journal_info = NULL; 536 - memset(trans, 0, sizeof(*trans)); 537 - kmem_cache_free(btrfs_trans_handle_cachep, trans); 538 535 539 536 if (throttle) 540 537 btrfs_run_delayed_iputs(root); 541 538 542 539 if (trans->aborted || 543 540 root->fs_info->fs_state & BTRFS_SUPER_FLAG_ERROR) { 544 - return -EIO; 541 + err = -EIO; 545 542 } 546 543 547 - return 0; 544 + memset(trans, 0, sizeof(*trans)); 545 + kmem_cache_free(btrfs_trans_handle_cachep, trans); 546 + return err; 548 547 } 549 548 550 549 int btrfs_end_transaction(struct btrfs_trans_handle *trans,
+18 -2
fs/btrfs/volumes.c
··· 3833 3833 int sub_stripes = 0; 3834 3834 u64 stripes_per_dev = 0; 3835 3835 u32 remaining_stripes = 0; 3836 + u32 last_stripe = 0; 3836 3837 3837 3838 if (map->type & 3838 3839 (BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID10)) { ··· 3847 3846 stripe_nr_orig, 3848 3847 factor, 3849 3848 &remaining_stripes); 3849 + div_u64_rem(stripe_nr_end - 1, factor, &last_stripe); 3850 + last_stripe *= sub_stripes; 3850 3851 } 3851 3852 3852 3853 for (i = 0; i < num_stripes; i++) { ··· 3861 3858 BTRFS_BLOCK_GROUP_RAID10)) { 3862 3859 bbio->stripes[i].length = stripes_per_dev * 3863 3860 map->stripe_len; 3861 + 3864 3862 if (i / sub_stripes < remaining_stripes) 3865 3863 bbio->stripes[i].length += 3866 3864 map->stripe_len; 3865 + 3866 + /* 3867 + * Special for the first stripe and 3868 + * the last stripe: 3869 + * 3870 + * |-------|...|-------| 3871 + * |----------| 3872 + * off end_off 3873 + */ 3867 3874 if (i < sub_stripes) 3868 3875 bbio->stripes[i].length -= 3869 3876 stripe_offset; 3870 - if ((i / sub_stripes + 1) % 3871 - sub_stripes == remaining_stripes) 3877 + 3878 + if (stripe_index >= last_stripe && 3879 + stripe_index <= (last_stripe + 3880 + sub_stripes - 1)) 3872 3881 bbio->stripes[i].length -= 3873 3882 stripe_end_offset; 3883 + 3874 3884 if (i == sub_stripes - 1) 3875 3885 stripe_offset = 0; 3876 3886 } else