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:
@@ -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;
|
||||
|
Reference in New Issue
Block a user