summaryrefslogtreecommitdiff
path: root/tests/fsck-tests/025-file-extents/test.sh
blob: ebe8a30560daa02575c4020bb892a6ad1de4207f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
# Confirm btrfs check can check file extents without causing false alert

source "$TOP/tests/common"

check_prereq btrfs
check_prereq mkfs.btrfs
check_prereq btrfstune
check_global_prereq dd
check_global_prereq fallocate
check_global_prereq truncate

setup_root_helper
prepare_test_dev 128M

# Do some write into a large prealloc range
# Lowmem mode can report missing csum due to wrong csum range
test_paritical_write_into_prealloc()
{
	run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$TEST_DEV"
	run_check_mount_test_dev

	run_check $SUDO_HELPER fallocate -l 128K "$TEST_MNT/file"
	sync
	run_check $SUDO_HELPER dd conv=notrunc if=/dev/zero of="$TEST_MNT/file" bs=1K count=64
	run_check_umount_test_dev
	run_check "$TOP/btrfs" check "$TEST_DEV"
}

# Inline compressed file extent
# Lowmem mode can cause silent error without any error message
# due to too restrict check on inline extent size
test_compressed_inline_extent()
{
	run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$TEST_DEV"
	run_check_mount_test_dev -o compress=lzo,max_inline=2048

	run_check $SUDO_HELPER dd conv=notrunc if=/dev/null of="$TEST_MNT/file" bs=1K count=1
	run_check_umount_test_dev
	run_check "$TOP/btrfs" check "$TEST_DEV"
}

# File extent hole with NO_HOLES incompat feature set.
# Lowmem mode will cause a false alert as it doesn't allow any file hole
# extents, while we can set NO_HOLES at anytime we want, it's definitely a
# false alert
test_hole_extent_with_no_holes_flag()
{
	run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$TEST_DEV"
	run_check_mount_test_dev

	run_check $SUDO_HELPER truncate -s 16K "$TEST_MNT/tmp"
	run_check_umount_test_dev
	run_check $SUDO_HELPER "$TOP/btrfstune" -n "$TEST_DEV"
	run_check "$TOP/btrfs" check "$TEST_DEV"
}

test_paritical_write_into_prealloc
test_compressed_inline_extent
test_hole_extent_with_no_holes_flag