Merge tag 'hisi-fixes-for-4.14' of git://github.com/hisilicon/linux-hisi into next...
[sfrench/cifs-2.6.git] / fs / btrfs / volumes.c
index 5eb7217738edbba5a49237736c3263b9b044d46f..e8b9a269fddec78fdf42adec32eabaffdf9c3636 100644 (file)
@@ -2702,7 +2702,7 @@ int btrfs_grow_device(struct btrfs_trans_handle *trans,
 
        mutex_lock(&fs_info->chunk_mutex);
        old_total = btrfs_super_total_bytes(super_copy);
-       diff = new_size - device->total_bytes;
+       diff = round_down(new_size - device->total_bytes, fs_info->sectorsize);
 
        if (new_size <= device->total_bytes ||
            device->is_tgtdev_for_dev_replace) {
@@ -4406,7 +4406,7 @@ int btrfs_shrink_device(struct btrfs_device *device, u64 new_size)
        u64 diff;
 
        new_size = round_down(new_size, fs_info->sectorsize);
-       diff = old_size - new_size;
+       diff = round_down(old_size - new_size, fs_info->sectorsize);
 
        if (device->is_tgtdev_for_dev_replace)
                return -EINVAL;