diff options
author | Nikolay Borisov <nborisov@suse.com> | 2017-06-16 14:39:20 +0300 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2017-06-20 14:22:48 +0200 |
commit | 7dfb8be11b5d1db4325414ce16b8c164e08f52d8 (patch) | |
tree | 8c9a616a9730750aa21daedb558e742450b78f67 /fs/btrfs/ctree.h | |
parent | eca152edf57e04f61d5a79e404d8e6c147278fdf (diff) | |
download | linux-7dfb8be11b5d1db4325414ce16b8c164e08f52d8.tar.gz linux-7dfb8be11b5d1db4325414ce16b8c164e08f52d8.tar.bz2 linux-7dfb8be11b5d1db4325414ce16b8c164e08f52d8.zip |
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>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r-- | fs/btrfs/ctree.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index b31515a2ef71..15a77e64dc20 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -1556,6 +1556,7 @@ static inline void btrfs_set_device_total_bytes(struct extent_buffer *eb, { BUILD_BUG_ON(sizeof(u64) != sizeof(((struct btrfs_dev_item *)0))->total_bytes); + WARN_ON(!IS_ALIGNED(val, eb->fs_info->sectorsize)); btrfs_set_64(eb, s, offsetof(struct btrfs_dev_item, total_bytes), val); } |