Skip to content

Commit 63fbdc2

Browse files
committed
btrfs-progs: fsck-test: add a test case for unexpected file extent items
The image is created using btrfs-corrupt-block, the fs tree leaf looks like this: item 0 key (256 INODE_ITEM 0) itemoff 16123 itemsize 160 generation 3 transid 9 size 12 nbytes 16384 block group 0 mode 40755 links 1 uid 0 gid 0 rdev 0 sequence 1 flags 0x0(none) item 1 key (256 INODE_REF 256) itemoff 16111 itemsize 12 index 0 namelen 2 name: .. item 2 key (256 DIR_ITEM 496027801) itemoff 16075 itemsize 36 location key (257 INODE_ITEM 0) type BLKDEV <<< transid 9 data_len 0 name_len 6 name: foobar item 3 key (256 DIR_INDEX 2) itemoff 16039 itemsize 36 location key (257 INODE_ITEM 0) type BLKDEV <<< transid 9 data_len 0 name_len 6 name: foobar item 4 key (257 INODE_ITEM 0) itemoff 15879 itemsize 160 generation 9 transid 9 size 8192 nbytes 8192 block group 0 mode 60660 links 1 uid 0 gid 0 rdev 0 <<< sequence 2 flags 0x0(none) item 5 key (257 INODE_REF 256) itemoff 15863 itemsize 16 index 2 namelen 6 name: foobar item 6 key (257 EXTENT_DATA 0) itemoff 15810 itemsize 53 generation 9 type 1 (regular) extent data disk byte 13631488 nr 8192 extent data offset 0 nr 8192 ram 8192 extent compression 0 (none) The image is generated by the following steps: # mkfs.btrfs -f $dev # mount $dev $mnt # xfs_io -f -c "pwrite 0 4k" $mnt/foobar # umount $mnt ## Change the inode's mode from REG to BLK # btrfs-corrupt-block -i 257 -f mode --value 25008 $dev ## Change the dir item's flag from REG to BLK # btrfs-corrupt-block -D 256,84,496027801 -f flags --value 4 $dev ## Change the dir index's flag from REG to BLK # btrfs-corrupt-block -D 256,96,2 -f flags --value 4 $dev The inode's mode and dir flags all match, but there is one unexpected file extent item there. Both lowmem and original mode should detect such problem. Signed-off-by: Qu Wenruo <wqu@suse.com>
1 parent b377efb commit 63fbdc2

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

2.05 KB
Binary file not shown.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
#
3+
# Verify that check can detect unexpected file extent items for special inodes
4+
# which should not have any file extent.
5+
6+
source "$TEST_TOP/common" || exit
7+
8+
check_prereq btrfs
9+
10+
check_image() {
11+
# The image contains an BLK inode, with a file extent.
12+
# The check should report an error.
13+
run_mustfail "unexpected file extent not detected" "$TOP/btrfs" check "$1"
14+
}
15+
16+
check_all_images

0 commit comments

Comments
 (0)