Commit 43530c46 authored by Miao Xie's avatar Miao Xie Committed by Chris Mason

Btrfs: fix unprotected device->bytes_used update

We should update device->bytes_used in the lock context of
chunk_mutex, or we would get wrong data.
Signed-off-by: default avatarMiao Xie <miaox@cn.fujitsu.com>
Signed-off-by: default avatarChris Mason <clm@fb.com>
parent 5d778aae
......@@ -4429,6 +4429,9 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
if (ret)
goto error_del_extent;
for (i = 0; i < map->num_stripes; i++)
map->stripes[i].dev->bytes_used += stripe_size;
free_extent_map(em);
check_raid56_incompat_flag(extent_root->fs_info, type);
......@@ -4500,7 +4503,6 @@ int btrfs_finish_chunk_alloc(struct btrfs_trans_handle *trans,
device = map->stripes[i].dev;
dev_offset = map->stripes[i].physical;
device->bytes_used += stripe_size;
ret = btrfs_update_device(trans, device);
if (ret)
goto out;
......
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