Btrfs: fix unprotected device's variants on 32bits machine

->total_bytes,->disk_total_bytes,->bytes_used is protected by chunk
lock when we change them, but sometimes we read them without any lock,
and we might get unexpected value. We fix this problem like inode's
i_size.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Chris Mason <clm@fb.com>
This commit is contained in:
Miao Xie
2014-09-03 21:35:38 +08:00
committed by Chris Mason
parent 1c1161870c
commit 7cc8e58d53
4 changed files with 124 additions and 29 deletions

View File

@@ -1553,7 +1553,7 @@ static noinline int btrfs_ioctl_resize(struct file *file,
goto out_free;
}
old_size = device->total_bytes;
old_size = btrfs_device_get_total_bytes(device);
if (mod < 0) {
if (new_size > old_size) {
@@ -2740,8 +2740,8 @@ static long btrfs_ioctl_dev_info(struct btrfs_root *root, void __user *arg)
}
di_args->devid = dev->devid;
di_args->bytes_used = dev->bytes_used;
di_args->total_bytes = dev->total_bytes;
di_args->bytes_used = btrfs_device_get_bytes_used(dev);
di_args->total_bytes = btrfs_device_get_total_bytes(dev);
memcpy(di_args->uuid, dev->uuid, sizeof(di_args->uuid));
if (dev->name) {
struct rcu_string *name;