linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Ensure size values are rounded down
@ 2017-06-15 12:52 Nikolay Borisov
  2017-06-15 12:52 ` [PATCH 1/2] btrfs: Manually implement device_total_bytes getter/setter Nikolay Borisov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Nikolay Borisov @ 2017-06-15 12:52 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba, jeffm, Nikolay Borisov

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

Substracting 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_balanace
as well as when adding a new device. 

The first patch in the series re-implements the btrfs_device_total_bytes
getter/setters manually so that we can add a WARN_ON to catch future offenders. 
I haven't implemented all 4 function that the macros do since we only ever use
the getter and setter. 

The second patch ensures that all the values passed to the setter are rounded 
down to a multiple of sectorsize. I also have an xfstest patch which passes
after this series is applied. 


Nikolay Borisov (2):
  btrfs: Manually implement device_total_bytes getter/setter
  btrfs: Round up values which are written for total_bytes_size

 fs/btrfs/ctree.h   | 19 ++++++++++++++++++-
 fs/btrfs/volumes.c | 18 +++++++++++++-----
 2 files changed, 31 insertions(+), 6 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-06-15 16:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-15 12:52 [PATCH 0/2] Ensure size values are rounded down Nikolay Borisov
2017-06-15 12:52 ` [PATCH 1/2] btrfs: Manually implement device_total_bytes getter/setter Nikolay Borisov
2017-06-15 12:52 ` [PATCH 2/2] btrfs: Round up values which are written for total_bytes_size Nikolay Borisov
2017-06-15 16:09 ` [PATCH 0/2] Ensure size values are rounded down David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).