aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorZhao Lei <zhaolei@cn.fujitsu.com>2015-02-25 01:17:20 -0500
committerChris Mason <clm@fb.com>2015-04-13 10:27:29 -0400
commitc30666d466c70a30491e45dd8d068360f9dd7693 (patch)
tree87036911f332a8c7e62edee9ae46c25c97d951e6 /fs/btrfs
parent264ca0f60becac34395f3b42171ad0cc2e53ea6e (diff)
btrfs: Set relative data on clear btrfs_block_group_cache->pinned
Bug1: space_info->bytes_readonly was set to very large(negative) value in btrfs_remove_block_group(). Reason: Current code set block_group_cache->pinned = 0 in btrfs_delete_unused_bgs(), but above space was not counted to space_info->bytes_readonly. Then in btrfs_remove_block_group(): block_group->space_info->bytes_readonly -= block_group->key.offset; We can see following value in trace: btrfs_remove_block_group: pid=2677 comm=btrfs-cleaner WARNING: bytes_readonly=12582912, key.offset=134217728 Bug2: space_info->total_bytes_pinned grow to value larger than fs size. In a 1.2G fs, we can get following trace log: at first: ZL_DEBUG: add_pinned_bytes: pid=2710 comm=sync change total_bytes_pinned flags=1 869793792 + 95944704 = 965738496 after some op: ZL_DEBUG: add_pinned_bytes: pid=2770 comm=sync change total_bytes_pinned flags=1 1780178944 + 95944704 = 1876123648 after some op: ZL_DEBUG: add_pinned_bytes: pid=3193 comm=sync change total_bytes_pinned flags=1 2924568576 + 95551488 = 3020120064 ... Reason: Similar to bug1, we also need to adjust space_info->total_bytes_pinned in above code block. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/extent-tree.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 01f4db6554a1..7a14a4aa50a7 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -9922,8 +9922,18 @@ void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info)
9922 mutex_unlock(&fs_info->unused_bg_unpin_mutex); 9922 mutex_unlock(&fs_info->unused_bg_unpin_mutex);
9923 9923
9924 /* Reset pinned so btrfs_put_block_group doesn't complain */ 9924 /* Reset pinned so btrfs_put_block_group doesn't complain */
9925 spin_lock(&space_info->lock);
9926 spin_lock(&block_group->lock);
9927
9928 space_info->bytes_pinned -= block_group->pinned;
9929 space_info->bytes_readonly += block_group->pinned;
9930 percpu_counter_add(&space_info->total_bytes_pinned,
9931 -block_group->pinned);
9925 block_group->pinned = 0; 9932 block_group->pinned = 0;
9926 9933
9934 spin_unlock(&block_group->lock);
9935 spin_unlock(&space_info->lock);
9936
9927 /* 9937 /*
9928 * Btrfs_remove_chunk will abort the transaction if things go 9938 * Btrfs_remove_chunk will abort the transaction if things go
9929 * horribly wrong. 9939 * horribly wrong.