diff options
Diffstat (limited to 'tests/fsck-tests')
-rwxr-xr-x | tests/fsck-tests/015-tree-reloc-tree/test.sh | 7 | ||||
-rw-r--r-- | tests/fsck-tests/020-extent-ref-cases/extent_data_ref.img | bin | 0 -> 6144 bytes | |||
-rwxr-xr-x | tests/fsck-tests/020-extent-ref-cases/test.sh | 5 | ||||
-rw-r--r-- | tests/fsck-tests/029-valid-orphan-item/orphan_inode.img.xz | bin | 0 -> 1620 bytes | |||
-rwxr-xr-x | tests/fsck-tests/029-valid-orphan-item/test.sh | 15 | ||||
-rw-r--r-- | tests/fsck-tests/030-reflinked-prealloc-extents/reflinked-prealloc-extents.img.xz | bin | 0 -> 3244 bytes | |||
-rwxr-xr-x | tests/fsck-tests/030-reflinked-prealloc-extents/test.sh | 42 | ||||
-rwxr-xr-x | tests/fsck-tests/031-metadatadump-check-data-csum/test.sh | 30 |
8 files changed, 90 insertions, 9 deletions
diff --git a/tests/fsck-tests/015-tree-reloc-tree/test.sh b/tests/fsck-tests/015-tree-reloc-tree/test.sh index afad1e8d..5d9d5122 100755 --- a/tests/fsck-tests/015-tree-reloc-tree/test.sh +++ b/tests/fsck-tests/015-tree-reloc-tree/test.sh @@ -5,15 +5,12 @@ # Also due to the short life span of reloc tree, save the as dump example for # later usage. -source "$TOP/tests/common" +source "$TEST_TOP/common" check_prereq btrfs check_image() { - local image - - image=$1 - run_check "$TOP/btrfs" check "$image" + run_check "$TOP/btrfs" check "$1" } check_all_images diff --git a/tests/fsck-tests/020-extent-ref-cases/extent_data_ref.img b/tests/fsck-tests/020-extent-ref-cases/extent_data_ref.img Binary files differnew file mode 100644 index 00000000..3ab2396b --- /dev/null +++ b/tests/fsck-tests/020-extent-ref-cases/extent_data_ref.img diff --git a/tests/fsck-tests/020-extent-ref-cases/test.sh b/tests/fsck-tests/020-extent-ref-cases/test.sh index 9cf99a51..a1bf75b1 100755 --- a/tests/fsck-tests/020-extent-ref-cases/test.sh +++ b/tests/fsck-tests/020-extent-ref-cases/test.sh @@ -20,10 +20,7 @@ source "$TEST_TOP/common" check_prereq btrfs check_image() { - local image - - image=$1 - run_check "$TOP/btrfs" check "$image" + run_check "$TOP/btrfs" check "$1" } check_all_images diff --git a/tests/fsck-tests/029-valid-orphan-item/orphan_inode.img.xz b/tests/fsck-tests/029-valid-orphan-item/orphan_inode.img.xz Binary files differnew file mode 100644 index 00000000..26e4cf8a --- /dev/null +++ b/tests/fsck-tests/029-valid-orphan-item/orphan_inode.img.xz diff --git a/tests/fsck-tests/029-valid-orphan-item/test.sh b/tests/fsck-tests/029-valid-orphan-item/test.sh new file mode 100755 index 00000000..d8068f63 --- /dev/null +++ b/tests/fsck-tests/029-valid-orphan-item/test.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# To check if btrfs check can handle valid orphan items. +# Orphan item is a marker for deleted inodes that were open at the time of +# deletion. # Orphan inode/root will is not referenced and will have an orphan +# item, which should not be reported as error. + +source "$TEST_TOP/common" + +check_prereq btrfs + +check_image() { + run_check "$TOP/btrfs" check "$1" +} + +check_all_images diff --git a/tests/fsck-tests/030-reflinked-prealloc-extents/reflinked-prealloc-extents.img.xz b/tests/fsck-tests/030-reflinked-prealloc-extents/reflinked-prealloc-extents.img.xz Binary files differnew file mode 100644 index 00000000..8adf0071 --- /dev/null +++ b/tests/fsck-tests/030-reflinked-prealloc-extents/reflinked-prealloc-extents.img.xz diff --git a/tests/fsck-tests/030-reflinked-prealloc-extents/test.sh b/tests/fsck-tests/030-reflinked-prealloc-extents/test.sh new file mode 100755 index 00000000..63f692bc --- /dev/null +++ b/tests/fsck-tests/030-reflinked-prealloc-extents/test.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# +# Verify that a filesystem check operation (fsck) does not report the following +# scenario as an error: +# +# An extent is shared between two inodes, as a result of clone/reflink operation, +# and for one of the inodes, lets call it inode A, the extent is referenced +# through a file extent item as a prealloc extent, while for the other inode, +# call it inode B, the extent is referenced through a regular file extent item, +# that is, it was written to. The goal of this test is to make sure a filesystem +# check operation will not report "odd csum items" errors for the prealloc +# extent at inode A, because this scenario is valid since the extent was written +# through inode B and therefore it is expected to have checksum items in the +# filesystem's checksum btree for that shared extent. +# +# Such scenario can be created with the following steps for example: +# +# mkfs.btrfs -f /dev/sdb +# mount /dev/sdb /mnt +# +# touch /mnt/foo +# xfs_io -c "falloc 0 256K" /mnt/foo +# sync +# +# xfs_io -c "pwrite -S 0xab 0 256K" /mnt/foo +# touch /mnt/bar +# xfs_io -c "reflink /mnt/foo 0 0 256K" /mnt/bar +# xfs_io -c "fsync" /mnt/bar +# +# <power fail> +# mount /dev/sdb /mnt +# umount /mnt + +source "$TEST_TOP/common" + +check_prereq btrfs + +check_image() { + run_check "$TOP/btrfs" check "$1" +} + +check_all_images diff --git a/tests/fsck-tests/031-metadatadump-check-data-csum/test.sh b/tests/fsck-tests/031-metadatadump-check-data-csum/test.sh new file mode 100755 index 00000000..30b0b7a3 --- /dev/null +++ b/tests/fsck-tests/031-metadatadump-check-data-csum/test.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# To check if "btrfs check" can detect metadata dump (restored by btrfs-iamge) +# and ignore --check-data-csum option + +source "$TEST_TOP/common" + +check_prereq btrfs +check_prereq mkfs.btrfs +check_prereq btrfs-image +setup_root_helper +prepare_test_dev + +run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$TEST_DEV" +run_check_mount_test_dev + +run_check $SUDO_HELPER dd if=/dev/urandom of="$TEST_MNT/file" bs=4k count=16 +run_check_umount_test_dev + +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 +prepare_test_dev + +run_check $SUDO_HELPER "$TOP/btrfs-image" -r "restored_image" "$TEST_DEV" + +# Should not report any error +run_check "$TOP/btrfs" check --check-data-csum "$TEST_DEV" + +rm -rf -- "restored_image*" |