2017-02-21 08:34:36 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Confirm btrfs check can check file extents without causing false alert
|
|
|
|
|
2018-02-08 06:34:19 +00:00
|
|
|
source "$TEST_TOP/common"
|
2017-02-21 08:34:36 +00:00
|
|
|
|
|
|
|
check_prereq btrfs
|
|
|
|
check_prereq mkfs.btrfs
|
2017-06-16 01:43:23 +00:00
|
|
|
check_prereq btrfstune
|
2017-03-01 16:16:46 +00:00
|
|
|
check_global_prereq dd
|
2017-02-21 08:34:36 +00:00
|
|
|
check_global_prereq fallocate
|
2017-06-16 01:43:23 +00:00
|
|
|
check_global_prereq truncate
|
2017-02-21 08:34:36 +00:00
|
|
|
|
|
|
|
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
|
2018-11-26 16:54:19 +00:00
|
|
|
test_partial_write_into_prealloc()
|
2017-02-21 08:34:36 +00:00
|
|
|
{
|
2019-06-05 17:09:38 +00:00
|
|
|
run_check_mkfs_test_dev
|
2017-02-21 08:34:36 +00:00
|
|
|
run_check_mount_test_dev
|
|
|
|
|
2017-03-01 16:10:44 +00:00
|
|
|
run_check $SUDO_HELPER fallocate -l 128K "$TEST_MNT/file"
|
2017-02-21 08:34:36 +00:00
|
|
|
sync
|
2017-03-01 16:16:46 +00:00
|
|
|
run_check $SUDO_HELPER dd conv=notrunc if=/dev/zero of="$TEST_MNT/file" bs=1K count=64
|
2017-02-21 08:34:36 +00:00
|
|
|
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()
|
|
|
|
{
|
2019-06-05 17:09:38 +00:00
|
|
|
run_check_mkfs_test_dev
|
2017-02-21 08:34:36 +00:00
|
|
|
run_check_mount_test_dev -o compress=lzo,max_inline=2048
|
|
|
|
|
2017-03-01 16:16:46 +00:00
|
|
|
run_check $SUDO_HELPER dd conv=notrunc if=/dev/null of="$TEST_MNT/file" bs=1K count=1
|
2017-02-21 08:34:36 +00:00
|
|
|
run_check_umount_test_dev
|
|
|
|
run_check "$TOP/btrfs" check "$TEST_DEV"
|
|
|
|
}
|
|
|
|
|
2017-06-16 01:43:23 +00:00
|
|
|
# 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()
|
|
|
|
{
|
2019-06-05 17:09:38 +00:00
|
|
|
run_check_mkfs_test_dev
|
2017-06-16 01:43:23 +00:00
|
|
|
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"
|
|
|
|
}
|
|
|
|
|
2018-11-26 16:54:19 +00:00
|
|
|
test_partial_write_into_prealloc
|
2017-02-21 08:34:36 +00:00
|
|
|
test_compressed_inline_extent
|
2017-06-16 01:43:23 +00:00
|
|
|
test_hole_extent_with_no_holes_flag
|