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' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs

Pull more btrfs updates from Chris Mason:
"This is part two of our merge window patches.

These are all from Filipe, and fix some really hard to find races that
can cause corruptions. Most of them involved block group removal
(balance) or discard"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs:
Btrfs: remove non-sense btrfs_error_discard_extent() function
Btrfs: fix fs corruption on transaction abort if device supports discard
Btrfs: always clear a block group node when removing it from the tree
Btrfs: ensure deletion from pinned_chunks list is protected

+20 -25
+2 -2
fs/btrfs/ctree.h
··· 3481 3481 u64 btrfs_account_ro_block_groups_free_space(struct btrfs_space_info *sinfo); 3482 3482 int btrfs_error_unpin_extent_range(struct btrfs_root *root, 3483 3483 u64 start, u64 end); 3484 - int btrfs_error_discard_extent(struct btrfs_root *root, u64 bytenr, 3485 - u64 num_bytes, u64 *actual_bytes); 3484 + int btrfs_discard_extent(struct btrfs_root *root, u64 bytenr, 3485 + u64 num_bytes, u64 *actual_bytes); 3486 3486 int btrfs_force_chunk_alloc(struct btrfs_trans_handle *trans, 3487 3487 struct btrfs_root *root, u64 type); 3488 3488 int btrfs_trim_fs(struct btrfs_root *root, struct fstrim_range *range);
-6
fs/btrfs/disk-io.c
··· 4121 4121 if (ret) 4122 4122 break; 4123 4123 4124 - /* opt_discard */ 4125 - if (btrfs_test_opt(root, DISCARD)) 4126 - ret = btrfs_error_discard_extent(root, start, 4127 - end + 1 - start, 4128 - NULL); 4129 - 4130 4124 clear_extent_dirty(unpin, start, end, GFP_NOFS); 4131 4125 btrfs_error_unpin_extent_range(root, start, end); 4132 4126 cond_resched();
+11 -12
fs/btrfs/extent-tree.c
··· 1889 1889 return blkdev_issue_discard(bdev, start >> 9, len >> 9, GFP_NOFS, 0); 1890 1890 } 1891 1891 1892 - static int btrfs_discard_extent(struct btrfs_root *root, u64 bytenr, 1893 - u64 num_bytes, u64 *actual_bytes) 1892 + int btrfs_discard_extent(struct btrfs_root *root, u64 bytenr, 1893 + u64 num_bytes, u64 *actual_bytes) 1894 1894 { 1895 1895 int ret; 1896 1896 u64 discarded_bytes = 0; ··· 5727 5727 update_global_block_rsv(fs_info); 5728 5728 } 5729 5729 5730 - static int unpin_extent_range(struct btrfs_root *root, u64 start, u64 end) 5730 + static int unpin_extent_range(struct btrfs_root *root, u64 start, u64 end, 5731 + const bool return_free_space) 5731 5732 { 5732 5733 struct btrfs_fs_info *fs_info = root->fs_info; 5733 5734 struct btrfs_block_group_cache *cache = NULL; ··· 5752 5751 5753 5752 if (start < cache->last_byte_to_unpin) { 5754 5753 len = min(len, cache->last_byte_to_unpin - start); 5755 - btrfs_add_free_space(cache, start, len); 5754 + if (return_free_space) 5755 + btrfs_add_free_space(cache, start, len); 5756 5756 } 5757 5757 5758 5758 start += len; ··· 5817 5815 end + 1 - start, NULL); 5818 5816 5819 5817 clear_extent_dirty(unpin, start, end, GFP_NOFS); 5820 - unpin_extent_range(root, start, end); 5818 + unpin_extent_range(root, start, end, true); 5821 5819 cond_resched(); 5822 5820 } 5823 5821 ··· 8874 8872 cache_node); 8875 8873 rb_erase(&block_group->cache_node, 8876 8874 &info->block_group_cache_tree); 8875 + RB_CLEAR_NODE(&block_group->cache_node); 8877 8876 spin_unlock(&info->block_group_cache_lock); 8878 8877 8879 8878 down_write(&block_group->space_info->groups_sem); ··· 9133 9130 spin_lock(&info->block_group_cache_lock); 9134 9131 rb_erase(&cache->cache_node, 9135 9132 &info->block_group_cache_tree); 9133 + RB_CLEAR_NODE(&cache->cache_node); 9136 9134 spin_unlock(&info->block_group_cache_lock); 9137 9135 btrfs_put_block_group(cache); 9138 9136 goto error; ··· 9275 9271 spin_lock(&root->fs_info->block_group_cache_lock); 9276 9272 rb_erase(&cache->cache_node, 9277 9273 &root->fs_info->block_group_cache_tree); 9274 + RB_CLEAR_NODE(&cache->cache_node); 9278 9275 spin_unlock(&root->fs_info->block_group_cache_lock); 9279 9276 btrfs_put_block_group(cache); 9280 9277 return ret; ··· 9695 9690 9696 9691 int btrfs_error_unpin_extent_range(struct btrfs_root *root, u64 start, u64 end) 9697 9692 { 9698 - return unpin_extent_range(root, start, end); 9699 - } 9700 - 9701 - int btrfs_error_discard_extent(struct btrfs_root *root, u64 bytenr, 9702 - u64 num_bytes, u64 *actual_bytes) 9703 - { 9704 - return btrfs_discard_extent(root, bytenr, num_bytes, actual_bytes); 9693 + return unpin_extent_range(root, start, end, false); 9705 9694 } 9706 9695 9707 9696 int btrfs_trim_fs(struct btrfs_root *root, struct fstrim_range *range)
+7 -5
fs/btrfs/free-space-cache.c
··· 2966 2966 spin_unlock(&block_group->lock); 2967 2967 spin_unlock(&space_info->lock); 2968 2968 2969 - ret = btrfs_error_discard_extent(fs_info->extent_root, 2970 - start, bytes, &trimmed); 2969 + ret = btrfs_discard_extent(fs_info->extent_root, 2970 + start, bytes, &trimmed); 2971 2971 if (!ret) 2972 2972 *total_trimmed += trimmed; 2973 2973 ··· 3185 3185 3186 3186 spin_unlock(&block_group->lock); 3187 3187 3188 + lock_chunks(block_group->fs_info->chunk_root); 3188 3189 em_tree = &block_group->fs_info->mapping_tree.map_tree; 3189 3190 write_lock(&em_tree->lock); 3190 3191 em = lookup_extent_mapping(em_tree, block_group->key.objectid, 3191 3192 1); 3192 3193 BUG_ON(!em); /* logic error, can't happen */ 3194 + /* 3195 + * remove_extent_mapping() will delete us from the pinned_chunks 3196 + * list, which is protected by the chunk mutex. 3197 + */ 3193 3198 remove_extent_mapping(em_tree, em); 3194 3199 write_unlock(&em_tree->lock); 3195 - 3196 - lock_chunks(block_group->fs_info->chunk_root); 3197 - list_del_init(&em->list); 3198 3200 unlock_chunks(block_group->fs_info->chunk_root); 3199 3201 3200 3202 /* once for us and once for the tree */