btrfs-progs: tests: add test case for ram_bytes detection and repair

The new test case would contain a file system image, with the following
file:

	item 4 key (257 INODE_ITEM 0) itemoff 15883 itemsize 160
		generation 7 transid 8 size 16384 nbytes 16384
		block group 0 mode 100600 links 1 uid 0 gid 0 rdev 0
		sequence 258 flags 0x0(none)
		atime 1714635006.328482575 (2024-05-02 17:00:06)
		ctime 1714635013.394980640 (2024-05-02 17:00:13)
		mtime 1714635013.394980640 (2024-05-02 17:00:13)
		otime 1714635006.328482575 (2024-05-02 17:00:06)
	item 5 key (257 INODE_REF 256) itemoff 15869 itemsize 14
		index 2 namelen 4 name: file
	item 6 key (257 EXTENT_DATA 0) itemoff 15816 itemsize 53
		generation 7 type 1 (regular)
		extent data disk byte 13631488 nr 1048576
		extent data offset 0 nr 16384 ram 16384
		extent compression 0 (none)

Note the ram bytes, which should be 1048576.

Furthermore, the inode size is truncated to 16K (originally 1M), so that
offset + num_bytes would still be no larger than ram_bytes.
So the only error is the mismatch between ram_bytes and disk_num_bytes
for the non-compressed data extent.

The image is hand crafted for now, as btrfs-corrupt-block doesn't not yet
support corrupting the ram_bytes field.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Qu Wenruo 2024-05-02 18:37:55 +09:30 committed by David Sterba
parent 7313573c19
commit d0cc40d23a