diff options
author | Miao Xie <miaox@cn.fujitsu.com> | 2014-07-24 11:37:13 +0800 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2014-08-19 08:52:18 -0700 |
commit | 7df69d3e94d6de537fd1afb574c760d8dc83ab60 (patch) | |
tree | 045b628d8ac40f125bd62e4228516b9a191b87c1 /fs/btrfs/disk-io.c | |
parent | 5d68da3b8ee6eb2257aa4b8d885581782278ae93 (diff) | |
download | lwn-7df69d3e94d6de537fd1afb574c760d8dc83ab60.tar.gz lwn-7df69d3e94d6de537fd1afb574c760d8dc83ab60.zip |
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>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r-- | fs/btrfs/disk-io.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index d0ed9e664f7d..c99a414813c1 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -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); |