]> git.ipfire.org Git - people/ms/linux.git/commit - fs/btrfs/ctree.h
btrfs: Round down values which are written for total_bytes_size
authorNikolay Borisov <nborisov@suse.com>
Fri, 16 Jun 2017 11:39:20 +0000 (14:39 +0300)
committerDavid Sterba <dsterba@suse.com>
Tue, 20 Jun 2017 12:22:48 +0000 (14:22 +0200)
commit7dfb8be11b5d1db4325414ce16b8c164e08f52d8
tree8c9a616a9730750aa21daedb558e742450b78f67
parenteca152edf57e04f61d5a79e404d8e6c147278fdf
btrfs: Round down values which are written for total_bytes_size

We got an internal report about a file system not wanting to mount
following 99e3ecfcb9f4 ("Btrfs: add more validation checks for
superblock").

BTRFS error (device sdb1): super_total_bytes 1000203816960 mismatch with
fs_devices total_rw_bytes 1000203820544

Subtracting the numbers we get a difference of less than a 4kb. Upon
closer inspection it became apparent that mkfs actually rounds down the
size of the device to a multiple of sector size. However, the same
cannot be said for various functions which modify the total size and are
called from btrfs_balance as well as when adding a new device. So this
patch ensures that values being saved into on-disk data structures are
always rounded down to a multiple of sectorsize.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.h
fs/btrfs/volumes.c