diff options
author | Miao Xie <miaox@cn.fujitsu.com> | 2014-09-03 09:35:36 -0400 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2014-09-17 16:38:36 -0400 |
commit | 43530c46cc55cf5a381e788276a93c83cbc95e46 (patch) | |
tree | ecce232a9383ebf44df78e5e677a1861acd3a4fc | |
parent | 5d778aaeb013bf819d00e33de7c673c04b5c4886 (diff) |
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: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Chris Mason <clm@fb.com>
-rw-r--r-- | fs/btrfs/volumes.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 1524b3f44036..45e0b5d0f6dd 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -4429,6 +4429,9 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans, | |||
4429 | if (ret) | 4429 | if (ret) |
4430 | goto error_del_extent; | 4430 | goto error_del_extent; |
4431 | 4431 | ||
4432 | for (i = 0; i < map->num_stripes; i++) | ||
4433 | map->stripes[i].dev->bytes_used += stripe_size; | ||
4434 | |||
4432 | free_extent_map(em); | 4435 | free_extent_map(em); |
4433 | check_raid56_incompat_flag(extent_root->fs_info, type); | 4436 | check_raid56_incompat_flag(extent_root->fs_info, type); |
4434 | 4437 | ||
@@ -4500,7 +4503,6 @@ int btrfs_finish_chunk_alloc(struct btrfs_trans_handle *trans, | |||
4500 | device = map->stripes[i].dev; | 4503 | device = map->stripes[i].dev; |
4501 | dev_offset = map->stripes[i].physical; | 4504 | dev_offset = map->stripes[i].physical; |
4502 | 4505 | ||
4503 | device->bytes_used += stripe_size; | ||
4504 | ret = btrfs_update_device(trans, device); | 4506 | ret = btrfs_update_device(trans, device); |
4505 | if (ret) | 4507 | if (ret) |
4506 | goto out; | 4508 | goto out; |