summaryrefslogtreecommitdiff
path: root/tests/fsck-tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests/fsck-tests')
-rw-r--r--tests/fsck-tests/020-extent-ref-cases/keyed_data_ref_with_reloc_leaf.imgbin0 -> 16384 bytes
-rwxr-xr-xtests/fsck-tests/025-file-extents/test.sh4
-rwxr-xr-xtests/fsck-tests/031-metadatadump-check-data-csum/test.sh4
-rw-r--r--tests/fsck-tests/035-inline-bad-ram-bytes/offset_by_one.imgbin0 -> 3072 bytes
-rwxr-xr-xtests/fsck-tests/035-inline-bad-ram-bytes/test.sh11
-rw-r--r--tests/fsck-tests/036-rescan-not-kicked-in/no_rescan_kicked_in.imgbin0 -> 3072 bytes
-rwxr-xr-xtests/fsck-tests/036-rescan-not-kicked-in/test.sh17
-rwxr-xr-xtests/fsck-tests/037-freespacetree-repair/test.sh81
8 files changed, 113 insertions, 4 deletions
diff --git a/tests/fsck-tests/020-extent-ref-cases/keyed_data_ref_with_reloc_leaf.img b/tests/fsck-tests/020-extent-ref-cases/keyed_data_ref_with_reloc_leaf.img
new file mode 100644
index 00000000..80345cf9
--- /dev/null
+++ b/tests/fsck-tests/020-extent-ref-cases/keyed_data_ref_with_reloc_leaf.img
Binary files differ
diff --git a/tests/fsck-tests/025-file-extents/test.sh b/tests/fsck-tests/025-file-extents/test.sh
index 95707596..db066ee1 100755
--- a/tests/fsck-tests/025-file-extents/test.sh
+++ b/tests/fsck-tests/025-file-extents/test.sh
@@ -15,7 +15,7 @@ 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()
+test_partial_write_into_prealloc()
{
run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$TEST_DEV"
run_check_mount_test_dev
@@ -55,6 +55,6 @@ test_hole_extent_with_no_holes_flag()
run_check "$TOP/btrfs" check "$TEST_DEV"
}
-test_paritical_write_into_prealloc
+test_partial_write_into_prealloc
test_compressed_inline_extent
test_hole_extent_with_no_holes_flag
diff --git a/tests/fsck-tests/031-metadatadump-check-data-csum/test.sh b/tests/fsck-tests/031-metadatadump-check-data-csum/test.sh
index e9b2d5c6..7f3872e6 100755
--- a/tests/fsck-tests/031-metadatadump-check-data-csum/test.sh
+++ b/tests/fsck-tests/031-metadatadump-check-data-csum/test.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# To check if "btrfs check" can detect metadata dump (restored by btrfs-iamge)
+# To check if "btrfs check" can detect metadata dump (restored by btrfs-image)
# and ignore --check-data-csum option
source "$TEST_TOP/common"
@@ -21,7 +21,7 @@ chmod a+w restored_image
run_check $SUDO_HELPER "$TOP/btrfs-image" "$TEST_DEV" "restored_image"
# use prepare_test_dev() to wipe all existing data on $TEST_DEV
-# so there is no way that restored image could have mathcing data csum
+# so there is no way that restored image could have matching data csum
prepare_test_dev
run_check $SUDO_HELPER "$TOP/btrfs-image" -r "restored_image" "$TEST_DEV"
diff --git a/tests/fsck-tests/035-inline-bad-ram-bytes/offset_by_one.img b/tests/fsck-tests/035-inline-bad-ram-bytes/offset_by_one.img
new file mode 100644
index 00000000..2f58208e
--- /dev/null
+++ b/tests/fsck-tests/035-inline-bad-ram-bytes/offset_by_one.img
Binary files differ
diff --git a/tests/fsck-tests/035-inline-bad-ram-bytes/test.sh b/tests/fsck-tests/035-inline-bad-ram-bytes/test.sh
new file mode 100755
index 00000000..6f6e2a5e
--- /dev/null
+++ b/tests/fsck-tests/035-inline-bad-ram-bytes/test.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+# Around 2014, btrfs kernel has a regression that create inline extent
+# with ram_bytes offset by one.
+# This old regression could be caught by tree-check code.
+# This test case will check if btrfs check could detect and repair it.
+
+source "$TEST_TOP/common"
+
+check_prereq btrfs
+
+check_all_images
diff --git a/tests/fsck-tests/036-rescan-not-kicked-in/no_rescan_kicked_in.img b/tests/fsck-tests/036-rescan-not-kicked-in/no_rescan_kicked_in.img
new file mode 100644
index 00000000..b855a72f
--- /dev/null
+++ b/tests/fsck-tests/036-rescan-not-kicked-in/no_rescan_kicked_in.img
Binary files differ
diff --git a/tests/fsck-tests/036-rescan-not-kicked-in/test.sh b/tests/fsck-tests/036-rescan-not-kicked-in/test.sh
new file mode 100755
index 00000000..eafd599d
--- /dev/null
+++ b/tests/fsck-tests/036-rescan-not-kicked-in/test.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+# Under certain power loss case, btrfs quota tree can be initialized but
+# rescan not kicked in. Can be also reproduced by fstests/btrfs/166 but with
+# low probability.
+#
+# This test case verifies a special case when 'btrfs check' does not report
+# qgroup accounting difference as an error, thus no false alert for btrfs/166.
+
+source "$TEST_TOP/common"
+
+check_prereq btrfs
+
+check_image() {
+ run_check "$TOP/btrfs" check "$1"
+}
+
+check_all_images
diff --git a/tests/fsck-tests/037-freespacetree-repair/test.sh b/tests/fsck-tests/037-freespacetree-repair/test.sh
new file mode 100755
index 00000000..261d7ccb
--- /dev/null
+++ b/tests/fsck-tests/037-freespacetree-repair/test.sh
@@ -0,0 +1,81 @@
+#!/bin/bash
+# Corrupt a filesystem that is using freespace tree and then ensure that
+# btrfs check is able to repair it. This tests correct detection/repair of
+# both a FREE_SPACE_EXTENT based FST and a FREE_SPACE_BITMAP based FST.
+
+source "$TEST_TOP/common"
+
+setup_root_helper
+prepare_test_dev 256M
+
+check_prereq btrfs
+check_prereq mkfs.btrfs
+check_global_prereq grep
+check_global_prereq tail
+check_global_prereq head
+check_global_prereq cut
+
+# wrapper for btrfs-corrupt-item
+# $1: Type of item we want to corrupt - extent or bitmap
+corrupt_fst_item()
+{
+ local type
+ local objectid
+ local offset
+ type="$1"
+
+ if [[ $type == "bitmap" ]]; then
+ type=200
+ objectid=$("$TOP/btrfs" inspect-internal dump-tree -t 10 "$TEST_DEV" | \
+ grep -o "[[:digit:]]* FREE_SPACE_BITMAP [[:digit:]]*" | \
+ cut -d' ' -f1 | tail -2 | head -1)
+ offset=$("$TOP/btrfs" inspect-internal dump-tree -t 10 "$TEST_DEV" | \
+ grep -o "[[:digit:]]* FREE_SPACE_BITMAP [[:digit:]]*" | \
+ cut -d' ' -f3 | tail -2 | head -1)
+ echo "Corrupting $objectid,FREE_SPACE_BITMAP,$offset" >> "$RESULTS"
+ elif [[ $type == "extent" ]]; then
+ type=199
+ objectid=$("$TOP/btrfs" inspect-internal dump-tree -t 10 "$TEST_DEV" | \
+ grep -o "[[:digit:]]* FREE_SPACE_EXTENT [[:digit:]]*" | \
+ cut -d' ' -f1 | tail -2 | head -1)
+ offset=$("$TOP/btrfs" inspect-internal dump-tree -t 10 "$TEST_DEV" | \
+ grep -o "[[:digit:]]* FREE_SPACE_EXTENT [[:digit:]]*" | \
+ cut -d' ' -f3 | tail -2 | head -1)
+ echo "Corrupting $objectid,FREE_SPACE_EXTENT,$offset" >> "$RESULTS"
+ else
+ _fail "Unknown item type for corruption"
+ fi
+
+ run_check "$TOP/btrfs-corrupt-block" -r 10 -K "$objectid,$type,$offset" \
+ -f offset "$TEST_DEV"
+}
+
+if ! [ -f "/sys/fs/btrfs/features/free_space_tree" ]; then
+ _not_run "kernel does not support free-space-tree feature"
+ exit
+fi
+
+run_check "$TOP/mkfs.btrfs" -n 4k -f "$TEST_DEV"
+run_check_mount_test_dev -oclear_cache,space_cache=v2
+
+# create files which will populate the FST
+for i in {1..3000}; do
+ run_check $SUDO_HELPER fallocate -l 4k "$TEST_MNT/file.$i"
+done
+
+run_check_umount_test_dev
+
+# now corrupt one of the bitmap items
+corrupt_fst_item "bitmap"
+check_image "$TEST_DEV"
+
+# change the freespace such that we now have at least one free_space_extent
+# object
+run_check_mount_test_dev
+rm -rf "$TEST_MNT/file.*"
+run_check $SUDO_HELPER fallocate -l 50m "$TEST_MNT/file"
+run_check_umount_test_dev
+
+# now corrupt an extent
+corrupt_fst_item "extent"
+check_image "$TEST_DEV"