Commit 18d018ad authored by Zhao Lei's avatar Zhao Lei Committed by Chris Mason

btrfs: add WARN_ON() to check is space_info op current

space_info's value calculation is some complex and easy to cause
bug, add WARN_ON() to help debug.

Changelog v1->v2:
 Put WARN_ON()s under the ENOSPC_DEBUG mount option.
 Suggested by: David Sterba <dsterba@suse.cz>
Signed-off-by: default avatarZhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: default avatarChris Mason <clm@fb.com>
parent c30666d4
...@@ -9732,9 +9732,19 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans, ...@@ -9732,9 +9732,19 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans,
spin_lock(&block_group->space_info->lock); spin_lock(&block_group->space_info->lock);
list_del_init(&block_group->ro_list); list_del_init(&block_group->ro_list);
if (btrfs_test_opt(root, ENOSPC_DEBUG)) {
WARN_ON(block_group->space_info->total_bytes
< block_group->key.offset);
WARN_ON(block_group->space_info->bytes_readonly
< block_group->key.offset);
WARN_ON(block_group->space_info->disk_total
< block_group->key.offset * factor);
}
block_group->space_info->total_bytes -= block_group->key.offset; block_group->space_info->total_bytes -= block_group->key.offset;
block_group->space_info->bytes_readonly -= block_group->key.offset; block_group->space_info->bytes_readonly -= block_group->key.offset;
block_group->space_info->disk_total -= block_group->key.offset * factor; block_group->space_info->disk_total -= block_group->key.offset * factor;
spin_unlock(&block_group->space_info->lock); spin_unlock(&block_group->space_info->lock);
memcpy(&key, &block_group->key, sizeof(key)); memcpy(&key, &block_group->key, sizeof(key));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment