btrfs-progs: mkfs: Round device size down to sectorsize
authorZhao Lei <zhaolei@cn.fujitsu.com>
Tue, 3 Nov 2015 03:23:36 +0000 (11:23 +0800)
committerDavid Sterba <dsterba@suse.com>
Tue, 3 Nov 2015 12:16:05 +0000 (13:16 +0100)
commitfa2dcf14063bd280c5d6b30309fe54cda3c29e30
tree0513b44a77d0f1dbaa3b370410be827e76347927
parenta40b0ff048385bde41935c4353154cdfc234ee64
btrfs-progs: mkfs: Round device size down to sectorsize

When do following command in a vm, whose disks are created by
qemu-img create -f raw 11 2.6G:
 # mkfs.btrfs -f /dev/vdd /dev/vde /dev/vdf
 # btrfs-show-super /dev/vdd /dev/vde /dev/vdf | grep dev_item.total_bytes
 dev_item.total_bytes    2791727104
 dev_item.total_bytes    2791729152
 dev_item.total_bytes    2791729152
We can see that the first device's size is little smaller.

And it fails xfstests btrfs/011.

Reason:
 First device's size is rounded down to sectorsize in make_btrfs(),
 but other devices are not.

Fix:
 Round down remain devices' size in btrfs_add_to_fsid().

Reported-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
utils.c