mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-26 02:39:48 +00:00
Btrfs: Fix wrong device size when we are resizing the device
total_bytes of device is just a in-memory variant which is used to record the size of the device, and it might be changed before we resize a device, if the resize operation fails, it will be fallbacked. But some code used it to update on-disk metadata of the device, it would cause the problem that on-disk metadata of the devices was not consistent. We should use the other variant named disk_total_bytes to update the on-disk metadata of device, because that variant is updated only when the resize operation is successful. Fix it. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Chris Mason <clm@fb.com>
This commit is contained in:
parent
5d68da3b8e
commit
7df69d3e94
2 changed files with 3 additions and 2 deletions
|
@ -3450,7 +3450,8 @@ static int write_all_supers(struct btrfs_root *root, int max_mirrors)
|
|||
btrfs_set_stack_device_generation(dev_item, 0);
|
||||
btrfs_set_stack_device_type(dev_item, dev->type);
|
||||
btrfs_set_stack_device_id(dev_item, dev->devid);
|
||||
btrfs_set_stack_device_total_bytes(dev_item, dev->total_bytes);
|
||||
btrfs_set_stack_device_total_bytes(dev_item,
|
||||
dev->disk_total_bytes);
|
||||
btrfs_set_stack_device_bytes_used(dev_item, dev->bytes_used);
|
||||
btrfs_set_stack_device_io_align(dev_item, dev->io_align);
|
||||
btrfs_set_stack_device_io_width(dev_item, dev->io_width);
|
||||
|
|
|
@ -1483,7 +1483,7 @@ static int btrfs_add_device(struct btrfs_trans_handle *trans,
|
|||
btrfs_set_device_io_align(leaf, dev_item, device->io_align);
|
||||
btrfs_set_device_io_width(leaf, dev_item, device->io_width);
|
||||
btrfs_set_device_sector_size(leaf, dev_item, device->sector_size);
|
||||
btrfs_set_device_total_bytes(leaf, dev_item, device->total_bytes);
|
||||
btrfs_set_device_total_bytes(leaf, dev_item, device->disk_total_bytes);
|
||||
btrfs_set_device_bytes_used(leaf, dev_item, device->bytes_used);
|
||||
btrfs_set_device_group(leaf, dev_item, 0);
|
||||
btrfs_set_device_seek_speed(leaf, dev_item, 0);
|
||||
|
|
Loading…
Reference in a new issue