0a348d3c81
[BUG] There is a bug report that, one btrfs got its underlying device shrunk accidentally. Fortunately the user has no data at the truncated range. However kernel will reject such filesystem, while btrfs-check reports nothing wrong with it. This can be easily reproduced by: # truncate -s 1G test.img # mkfs.btrfs test.img # truncate -s 996M test.img # btrfs check test.img Opening filesystem to check... Checking filesystem on test.img UUID: dbf0a16d-f158-4383-9025-29d7f4c43f17 [1/7] checking root items [2/7] checking extents [3/7] checking free space tree [4/7] checking fs roots [5/7] checking only csums items (without verifying data) [6/7] checking root refs [7/7] checking quota groups skipped (not enabled on this FS) found 16527360 bytes used, no error found ^^^^^^^^^^^^^^ total csum bytes: 13836 total tree bytes: 2359296 total fs tree bytes: 2162688 total extent tree bytes: 65536 btree space waste bytes: 503569 file data blocks allocated: 14168064 referenced 14168064 [CAUSE] Btrfs check really only checks the metadata cross references, not really bothering if the underlying device has correct size. Thus we completely ignored such size mismatch. [FIX] For both regular and lowmem mode, add extra check against the underlying block device size. If the block device size is smaller than its total_bytes, gives a error message and error out. Now the check looks like this for both modes: ... [2/7] checking extents ERROR: block device size is smaller than total_bytes in device item, has 1046478848 expect >= 1073741824 ERROR: errors found in extent allocation tree or chunk allocation [3/7] checking free space tree ... found 16527360 bytes used, error(s) found Issue: #504 Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com> |
||
---|---|---|
.. | ||
common.h | ||
main.c | ||
mode-common.c | ||
mode-common.h | ||
mode-lowmem.c | ||
mode-lowmem.h | ||
mode-original.h | ||
qgroup-verify.c | ||
qgroup-verify.h |