summaryrefslogtreecommitdiff
path: root/tests/fsck-tests
diff options
context:
space:
mode:
authorDimitri John Ledkov <xnox@ubuntu.com>2017-07-31 14:54:24 +0100
committerDimitri John Ledkov <xnox@ubuntu.com>2017-07-31 14:54:24 +0100
commit6a0440391da7a99ffab94ccc66264af9b5f3ce34 (patch)
tree1c7cf4f07b08c4965ab19819ebce367be16fb980 /tests/fsck-tests
parent5f2e2384443a09e3f1fec71940e9e32b70789102 (diff)
New upstream release.
Diffstat (limited to 'tests/fsck-tests')
-rwxr-xr-xtests/fsck-tests/006-bad-root-items/test.sh6
-rwxr-xr-xtests/fsck-tests/012-leaf-corruption/test.sh24
-rwxr-xr-xtests/fsck-tests/013-extent-tree-rebuild/test.sh22
-rw-r--r--tests/fsck-tests/015-check-bad-memory-access/bko-97171-btrfs-image.raw.txt254
-rw-r--r--tests/fsck-tests/015-check-bad-memory-access/bko-97171-btrfs-image.raw.xzbin6748 -> 0 bytes
-rwxr-xr-xtests/fsck-tests/018-leaf-crossing-stripes/test.sh4
-rwxr-xr-xtests/fsck-tests/019-non-skinny-false-alert/test.sh4
-rw-r--r--tests/fsck-tests/020-extent-ref-cases/block_group_item_false_alert.raw.xzbin0 -> 47792 bytes
-rw-r--r--tests/fsck-tests/020-extent-ref-cases/shared_data_ref_only.imgbin0 -> 7168 bytes
-rwxr-xr-xtests/fsck-tests/020-extent-ref-cases/test.sh19
-rwxr-xr-xtests/fsck-tests/021-partially-dropped-snapshot-case/test.sh6
-rwxr-xr-xtests/fsck-tests/022-qgroup-rescan-halfway/test.sh4
-rwxr-xr-xtests/fsck-tests/023-qgroup-stack-overflow/test.sh4
-rwxr-xr-xtests/fsck-tests/024-clear-space-cache/test.sh16
-rwxr-xr-xtests/fsck-tests/025-file-extents/test.sh60
15 files changed, 118 insertions, 305 deletions
diff --git a/tests/fsck-tests/006-bad-root-items/test.sh b/tests/fsck-tests/006-bad-root-items/test.sh
index 84332348..bf3ef781 100755
--- a/tests/fsck-tests/006-bad-root-items/test.sh
+++ b/tests/fsck-tests/006-bad-root-items/test.sh
@@ -1,15 +1,15 @@
#!/bin/bash
-source $TOP/tests/common
+source "$TOP/tests/common"
check_prereq btrfs
-echo "extracting image default_case.tar.xz" >> $RESULTS
+echo "extracting image default_case.tar.xz" >> "$RESULTS"
tar --no-same-owner -xJf default_case.tar.xz || \
_fail "failed to extract default_case.tar.xz"
check_image test.img
-echo "extracting image skinny_case.tar.xz" >> $RESULTS
+echo "extracting image skinny_case.tar.xz" >> "$RESULTS"
tar --no-same-owner -xJf skinny_case.tar.xz || \
_fail "failed to extract skinny_case.tar.xz"
check_image test.img
diff --git a/tests/fsck-tests/012-leaf-corruption/test.sh b/tests/fsck-tests/012-leaf-corruption/test.sh
index a308727d..fc10a4ff 100755
--- a/tests/fsck-tests/012-leaf-corruption/test.sh
+++ b/tests/fsck-tests/012-leaf-corruption/test.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-source $TOP/tests/common
+source "$TOP/tests/common"
check_prereq btrfs-image
@@ -37,16 +37,16 @@ leaf_no_data_ext_list=(
generate_leaf_corrupt_no_data_ext()
{
dest=$1
- echo "generating leaf_corrupt_no_data_ext.btrfs-image" >> $RESULTS
+ echo "generating leaf_corrupt_no_data_ext.btrfs-image" >> "$RESULTS"
tar --no-same-owner -xJf ./no_data_extent.tar.xz || \
_fail "failed to extract leaf_corrupt_no_data_ext.btrfs-image"
- $TOP/btrfs-image -r test.img.btrfs-image $dest || \
+ "$TOP/btrfs-image" -r test.img.btrfs-image "$dest" || \
_fail "failed to extract leaf_corrupt_no_data_ext.btrfs-image"
# leaf at 4206592 and 20905984 contains no regular data
# extent, clear its csum to corrupt the leaf.
for x in 4206592 20905984; do
- dd if=/dev/zero of=$dest bs=1 count=32 conv=notrunc seek=$x \
+ dd if=/dev/zero of="$dest" bs=1 count=32 conv=notrunc seek="$x" \
1>/dev/null 2>&1
done
}
@@ -60,21 +60,21 @@ check_inode()
name=$5
# Check whether the inode exists
- exists=$($SUDO_HELPER find $path -inum $ino)
+ exists=$($SUDO_HELPER find "$path" -inum "$ino")
if [ -z "$exists" ]; then
_fail "inode $ino not recovered correctly"
fi
# Check inode type
- found_mode=$(printf "%o" 0x$($SUDO_HELPER stat $exists -c %f))
- if [ $found_mode -ne $mode ]; then
+ found_mode=$(printf "%o" 0x$($SUDO_HELPER stat "$exists" -c %f))
+ if [ "$found_mode" -ne "$mode" ]; then
echo "$found_mode"
_fail "inode $ino modes not recovered"
fi
# Check inode size
- found_size=$($SUDO_HELPER stat $exists -c %s)
- if [ $mode -ne 41700 -a $found_size -ne $size ]; then
+ found_size=$($SUDO_HELPER stat "$exists" -c %s)
+ if [ $mode -ne 41700 -a "$found_size" -ne "$size" ]; then
_fail "inode $ino size not recovered correctly"
fi
@@ -90,11 +90,11 @@ check_inode()
check_leaf_corrupt_no_data_ext()
{
image=$1
- $SUDO_HELPER mount -o loop $image -o ro $TEST_MNT
+ $SUDO_HELPER mount -o loop -t btrfs "$image" -o ro "$TEST_MNT"
i=0
while [ $i -lt ${#leaf_no_data_ext_list[@]} ]; do
- check_inode $TEST_MNT/lost+found \
+ check_inode "$TEST_MNT/lost+found" \
${leaf_no_data_ext_list[i]} \
${leaf_no_data_ext_list[i + 1]} \
${leaf_no_data_ext_list[i + 2]} \
@@ -102,7 +102,7 @@ check_leaf_corrupt_no_data_ext()
${leaf_no_data_ext_list[i + 4]}
((i+=4))
done
- $SUDO_HELPER umount $TEST_MNT
+ $SUDO_HELPER umount "$TEST_MNT"
}
setup_root_helper
diff --git a/tests/fsck-tests/013-extent-tree-rebuild/test.sh b/tests/fsck-tests/013-extent-tree-rebuild/test.sh
index 37bdcd9c..90fe2e83 100755
--- a/tests/fsck-tests/013-extent-tree-rebuild/test.sh
+++ b/tests/fsck-tests/013-extent-tree-rebuild/test.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-source $TOP/tests/common
+source "$TOP/tests/common"
check_prereq btrfs-corrupt-block
check_prereq mkfs.btrfs
@@ -12,32 +12,32 @@ prepare_test_dev 1G
# test whether fsck can rebuild a corrupted extent tree
test_extent_tree_rebuild()
{
- run_check $SUDO_HELPER $TOP/mkfs.btrfs -f $TEST_DEV
+ run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$TEST_DEV"
run_check_mount_test_dev
generate_dataset small
for i in `seq 1 100`;do
- run_check $SUDO_HELPER $TOP/btrfs sub snapshot $TEST_MNT \
- $TEST_MNT/snapaaaaaaa_$i
+ run_check $SUDO_HELPER "$TOP/btrfs" sub snapshot "$TEST_MNT" \
+ "$TEST_MNT/snapaaaaaaa_$i"
done
run_check_umount_test_dev
# get extent root bytenr
- extent_root_bytenr=`$SUDO_HELPER $TOP/btrfs inspect-internal dump-tree -r $TEST_DEV | \
+ extent_root_bytenr=`$SUDO_HELPER "$TOP/btrfs" inspect-internal dump-tree -r "$TEST_DEV" | \
grep extent | awk '{print $7}'`
- if [ -z $extent_root_bytenr ];then
+ if [ -z "$extent_root_bytenr" ];then
_fail "fail to get extent root bytenr"
fi
# corrupt extent root node block
- run_check $SUDO_HELPER $TOP/btrfs-corrupt-block -l $extent_root_bytenr \
- -b 4096 $TEST_DEV
+ run_check $SUDO_HELPER "$TOP/btrfs-corrupt-block" -l "$extent_root_bytenr" \
+ -b 4096 "$TEST_DEV"
- $SUDO_HELPER $TOP/btrfs check $TEST_DEV >& /dev/null && \
+ $SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV" >& /dev/null && \
_fail "btrfs check should detect failure"
- run_check $SUDO_HELPER $TOP/btrfs check --init-extent-tree $TEST_DEV
- run_check $SUDO_HELPER $TOP/btrfs check $TEST_DEV
+ run_check $SUDO_HELPER "$TOP/btrfs" check --repair --init-extent-tree "$TEST_DEV"
+ run_check $SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV"
}
test_extent_tree_rebuild
diff --git a/tests/fsck-tests/015-check-bad-memory-access/bko-97171-btrfs-image.raw.txt b/tests/fsck-tests/015-check-bad-memory-access/bko-97171-btrfs-image.raw.txt
deleted file mode 100644
index 9685ed46..00000000
--- a/tests/fsck-tests/015-check-bad-memory-access/bko-97171-btrfs-image.raw.txt
+++ /dev/null
@@ -1,254 +0,0 @@
-URL: https://bugzilla.kernel.org/show_bug.cgi?id=97171
-
-The btrfs-image attached to this bug causes the btrfs-userland tool to use
-uninitialized memory and ultimately overwrite what seems to be arbitrary memory
-locations, dying in the process. Reproduced on x86-64 and i686.
-
-The kernel seems to be less affected and fails to mount the image. If
-/usr/sbin/btrfs is not setuid (which it probably never is), things should be
-safe. I didn't investigate further though.
-
-gdb output:
-
-GNU gdb (GDB) Fedora 7.8.2-38.fc21
-[... lots of other errors...]
-Ignoring transid failure
-root 5 inode 260 errors 1000, some csum missing
- unresolved ref dir 256 index 7 namelen 5 name b.bin filetype 1 errors 2, no dir index
- unresolved ref dir 256 index 7 namelen 5 name b.fin filetype 1 errors 5, no dir item, no inode ref
-root 5 inode 261 errors 200, dir isize wrong
-
-Program received signal SIGSEGV, Segmentation fault.
-0x000000000089bb70 in ?? ()
-(gdb) bt
-#0 0x000000000089bb70 in ?? ()
-#1 0x00007fffffffdb50 in ?? ()
-#2 0x0000000000894b20 in ?? ()
-#3 0x00000032629b88e0 in _IO_2_1_stdout_ () from /lib64/libc.so.6
-#4 0x000000000088c010 in ?? ()
-#5 0x0000000000000000 in ?? ()
-
-
-valgrind output:
-
-[...lots of errors...]
-==12638== Conditional jump or move depends on uninitialised value(s)
-==12638== at 0x436E77: check_block.part.14 (ctree.c:548)
-==12638== by 0x438954: UnknownInlinedFun (kerncompat.h:91)
-==12638== by 0x438954: btrfs_search_slot (ctree.c:1120)
-==12638== by 0x40DD1F: count_csum_range (cmds-check.c:1419)
-==12638== by 0x40DD1F: process_file_extent (cmds-check.c:1551)
-==12638== by 0x40DD1F: process_one_leaf (cmds-check.c:1617)
-==12638== by 0x40DD1F: walk_down_tree (cmds-check.c:1742)
-==12638== by 0x40DD1F: check_fs_root (cmds-check.c:3380)
-==12638== by 0x40DD1F: check_fs_roots.isra.51 (cmds-check.c:3516)
-==12638== by 0x4C64B0F: ???
-==12638== by 0x4C30A2F: ???
-==12638== by 0x4C468CF: ???
-==12638== by 0x32629B88DF: ??? (in /usr/lib64/libc-2.20.so)
-==12638== by 0x4C3657F: ???
-==12638==
-==12638== Conditional jump or move depends on uninitialised value(s)
-==12638== at 0x4A0B0E7: memcpy@@GLIBC_2.14 (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
-==12638== by 0x436E99: UnknownInlinedFun (ctree.h:1613)
-==12638== by 0x436E99: check_block.part.14 (ctree.c:550)
-==12638== by 0x438954: UnknownInlinedFun (kerncompat.h:91)
-==12638== by 0x438954: btrfs_search_slot (ctree.c:1120)
-==12638== by 0x40DD1F: count_csum_range (cmds-check.c:1419)
-==12638== by 0x40DD1F: process_file_extent (cmds-check.c:1551)
-==12638== by 0x40DD1F: process_one_leaf (cmds-check.c:1617)
-==12638== by 0x40DD1F: walk_down_tree (cmds-check.c:1742)
-==12638== by 0x40DD1F: check_fs_root (cmds-check.c:3380)
-==12638== by 0x40DD1F: check_fs_roots.isra.51 (cmds-check.c:3516)
-==12638== by 0x4C64B0F: ???
-==12638== by 0x4C30A2F: ???
-==12638== by 0x4C468CF: ???
-==12638== by 0x32629B88DF: ??? (in /usr/lib64/libc-2.20.so)
-==12638== by 0x4C3657F: ???
-==12638==
-==12638== Conditional jump or move depends on uninitialised value(s)
-==12638== at 0x4A0B2AC: memcpy@@GLIBC_2.14 (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
-==12638== by 0x436E99: UnknownInlinedFun (ctree.h:1613)
-==12638== by 0x436E99: check_block.part.14 (ctree.c:550)
-==12638== by 0x438954: UnknownInlinedFun (kerncompat.h:91)
-==12638== by 0x438954: btrfs_search_slot (ctree.c:1120)
-==12638== by 0x40DD1F: count_csum_range (cmds-check.c:1419)
-==12638== by 0x40DD1F: process_file_extent (cmds-check.c:1551)
-==12638== by 0x40DD1F: process_one_leaf (cmds-check.c:1617)
-==12638== by 0x40DD1F: walk_down_tree (cmds-check.c:1742)
-==12638== by 0x40DD1F: check_fs_root (cmds-check.c:3380)
-==12638== by 0x40DD1F: check_fs_roots.isra.51 (cmds-check.c:3516)
-==12638== by 0x4C64B0F: ???
-==12638== by 0x4C30A2F: ???
-==12638== by 0x4C468CF: ???
-==12638== by 0x32629B88DF: ??? (in /usr/lib64/libc-2.20.so)
-==12638== by 0x4C3657F: ???
-==12638==
-==12638== Conditional jump or move depends on uninitialised value(s)
-==12638== at 0x4A0B151: memcpy@@GLIBC_2.14 (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
-==12638== by 0x436E99: UnknownInlinedFun (ctree.h:1613)
-==12638== by 0x436E99: check_block.part.14 (ctree.c:550)
-==12638== by 0x438954: UnknownInlinedFun (kerncompat.h:91)
-==12638== by 0x438954: btrfs_search_slot (ctree.c:1120)
-==12638== by 0x40DD1F: count_csum_range (cmds-check.c:1419)
-==12638== by 0x40DD1F: process_file_extent (cmds-check.c:1551)
-==12638== by 0x40DD1F: process_one_leaf (cmds-check.c:1617)
-==12638== by 0x40DD1F: walk_down_tree (cmds-check.c:1742)
-==12638== by 0x40DD1F: check_fs_root (cmds-check.c:3380)
-==12638== by 0x40DD1F: check_fs_roots.isra.51 (cmds-check.c:3516)
-==12638== by 0x4C64B0F: ???
-==12638== by 0x4C30A2F: ???
-==12638== by 0x4C468CF: ???
-==12638== by 0x32629B88DF: ??? (in /usr/lib64/libc-2.20.so)
-==12638== by 0x4C3657F: ???
-==12638==
-==12638== Conditional jump or move depends on uninitialised value(s)
-==12638== at 0x4A0B162: memcpy@@GLIBC_2.14 (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
-==12638== by 0x436E99: UnknownInlinedFun (ctree.h:1613)
-==12638== by 0x436E99: check_block.part.14 (ctree.c:550)
-==12638== by 0x438954: UnknownInlinedFun (kerncompat.h:91)
-==12638== by 0x438954: btrfs_search_slot (ctree.c:1120)
-==12638== by 0x40DD1F: count_csum_range (cmds-check.c:1419)
-==12638== by 0x40DD1F: process_file_extent (cmds-check.c:1551)
-==12638== by 0x40DD1F: process_one_leaf (cmds-check.c:1617)
-==12638== by 0x40DD1F: walk_down_tree (cmds-check.c:1742)
-==12638== by 0x40DD1F: check_fs_root (cmds-check.c:3380)
-==12638== by 0x40DD1F: check_fs_roots.isra.51 (cmds-check.c:3516)
-==12638== by 0x4C64B0F: ???
-==12638== by 0x4C30A2F: ???
-==12638== by 0x4C468CF: ???
-==12638== by 0x32629B88DF: ??? (in /usr/lib64/libc-2.20.so)
-==12638== by 0x4C3657F: ???
-==12638==
-==12638== Conditional jump or move depends on uninitialised value(s)
-==12638== at 0x4A0B176: memcpy@@GLIBC_2.14 (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
-==12638== by 0x436E99: UnknownInlinedFun (ctree.h:1613)
-==12638== by 0x436E99: check_block.part.14 (ctree.c:550)
-==12638== by 0x438954: UnknownInlinedFun (kerncompat.h:91)
-==12638== by 0x438954: btrfs_search_slot (ctree.c:1120)
-==12638== by 0x40DD1F: count_csum_range (cmds-check.c:1419)
-==12638== by 0x40DD1F: process_file_extent (cmds-check.c:1551)
-==12638== by 0x40DD1F: process_one_leaf (cmds-check.c:1617)
-==12638== by 0x40DD1F: walk_down_tree (cmds-check.c:1742)
-==12638== by 0x40DD1F: check_fs_root (cmds-check.c:3380)
-==12638== by 0x40DD1F: check_fs_roots.isra.51 (cmds-check.c:3516)
-==12638== by 0x4C64B0F: ???
-==12638== by 0x4C30A2F: ???
-==12638== by 0x4C468CF: ???
-==12638== by 0x32629B88DF: ??? (in /usr/lib64/libc-2.20.so)
-==12638== by 0x4C3657F: ???
-==12638==
-==12638== Conditional jump or move depends on uninitialised value(s)
-==12638== at 0x4A0B2CE: memcpy@@GLIBC_2.14 (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
-==12638== by 0x436E99: UnknownInlinedFun (ctree.h:1613)
-==12638== by 0x436E99: check_block.part.14 (ctree.c:550)
-==12638== by 0x438954: UnknownInlinedFun (kerncompat.h:91)
-==12638== by 0x438954: btrfs_search_slot (ctree.c:1120)
-==12638== by 0x40DD1F: count_csum_range (cmds-check.c:1419)
-==12638== by 0x40DD1F: process_file_extent (cmds-check.c:1551)
-==12638== by 0x40DD1F: process_one_leaf (cmds-check.c:1617)
-==12638== by 0x40DD1F: walk_down_tree (cmds-check.c:1742)
-==12638== by 0x40DD1F: check_fs_root (cmds-check.c:3380)
-==12638== by 0x40DD1F: check_fs_roots.isra.51 (cmds-check.c:3516)
-==12638== by 0x4C64B0F: ???
-==12638== by 0x4C30A2F: ???
-==12638== by 0x4C468CF: ???
-==12638== by 0x32629B88DF: ??? (in /usr/lib64/libc-2.20.so)
-==12638== by 0x4C3657F: ???
-==12638==
-==12638== Conditional jump or move depends on uninitialised value(s)
-==12638== at 0x4A0B34A: memcpy@@GLIBC_2.14 (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
-==12638== by 0x436E99: UnknownInlinedFun (ctree.h:1613)
-==12638== by 0x436E99: check_block.part.14 (ctree.c:550)
-==12638== by 0x438954: UnknownInlinedFun (kerncompat.h:91)
-==12638== by 0x438954: btrfs_search_slot (ctree.c:1120)
-==12638== by 0x40DD1F: count_csum_range (cmds-check.c:1419)
-==12638== by 0x40DD1F: process_file_extent (cmds-check.c:1551)
-==12638== by 0x40DD1F: process_one_leaf (cmds-check.c:1617)
-==12638== by 0x40DD1F: walk_down_tree (cmds-check.c:1742)
-==12638== by 0x40DD1F: check_fs_root (cmds-check.c:3380)
-==12638== by 0x40DD1F: check_fs_roots.isra.51 (cmds-check.c:3516)
-==12638== by 0x4C64B0F: ???
-==12638== by 0x4C30A2F: ???
-==12638== by 0x4C468CF: ???
-==12638== by 0x32629B88DF: ??? (in /usr/lib64/libc-2.20.so)
-==12638== by 0x4C3657F: ???
-==12638==
-==12638== Use of uninitialised value of size 8
-==12638== at 0x4A0B3A0: memcpy@@GLIBC_2.14 (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
-==12638== by 0x436E99: UnknownInlinedFun (ctree.h:1613)
-==12638== by 0x436E99: check_block.part.14 (ctree.c:550)
-==12638== by 0x438954: UnknownInlinedFun (kerncompat.h:91)
-==12638== by 0x438954: btrfs_search_slot (ctree.c:1120)
-==12638== by 0x40DD1F: count_csum_range (cmds-check.c:1419)
-==12638== by 0x40DD1F: process_file_extent (cmds-check.c:1551)
-==12638== by 0x40DD1F: process_one_leaf (cmds-check.c:1617)
-==12638== by 0x40DD1F: walk_down_tree (cmds-check.c:1742)
-==12638== by 0x40DD1F: check_fs_root (cmds-check.c:3380)
-==12638== by 0x40DD1F: check_fs_roots.isra.51 (cmds-check.c:3516)
-==12638== by 0x4C64B0F: ???
-==12638== by 0x4C30A2F: ???
-==12638== by 0x4C468CF: ???
-==12638== by 0x32629B88DF: ??? (in /usr/lib64/libc-2.20.so)
-==12638== by 0x4C3657F: ???
-==12638==
-==12638== Invalid read of size 1
-==12638== at 0x4A0B3A0: memcpy@@GLIBC_2.14 (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
-==12638== by 0x436E99: UnknownInlinedFun (ctree.h:1613)
-==12638== by 0x436E99: check_block.part.14 (ctree.c:550)
-==12638== by 0x438954: UnknownInlinedFun (kerncompat.h:91)
-==12638== by 0x438954: btrfs_search_slot (ctree.c:1120)
-==12638== by 0x40DD1F: count_csum_range (cmds-check.c:1419)
-==12638== by 0x40DD1F: process_file_extent (cmds-check.c:1551)
-==12638== by 0x40DD1F: process_one_leaf (cmds-check.c:1617)
-==12638== by 0x40DD1F: walk_down_tree (cmds-check.c:1742)
-==12638== by 0x40DD1F: check_fs_root (cmds-check.c:3380)
-==12638== by 0x40DD1F: check_fs_roots.isra.51 (cmds-check.c:3516)
-==12638== by 0x4C64B0F: ???
-==12638== by 0x4C30A2F: ???
-==12638== by 0x4C468CF: ???
-==12638== by 0x32629B88DF: ??? (in /usr/lib64/libc-2.20.so)
-==12638== by 0x4C3657F: ???
-==12638== Address 0xa25c9de9 is not stack'd, malloc'd or (recently) free'd
-==12638==
-==12638==
-==12638== Process terminating with default action of signal 11 (SIGSEGV)
-==12638== Access not within mapped region at address 0xA25C9DE9
-==12638== at 0x4A0B3A0: memcpy@@GLIBC_2.14 (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
-==12638== by 0x436E99: UnknownInlinedFun (ctree.h:1613)
-==12638== by 0x436E99: check_block.part.14 (ctree.c:550)
-==12638== by 0x438954: UnknownInlinedFun (kerncompat.h:91)
-==12638== by 0x438954: btrfs_search_slot (ctree.c:1120)
-==12638== by 0x40DD1F: count_csum_range (cmds-check.c:1419)
-==12638== by 0x40DD1F: process_file_extent (cmds-check.c:1551)
-==12638== by 0x40DD1F: process_one_leaf (cmds-check.c:1617)
-==12638== by 0x40DD1F: walk_down_tree (cmds-check.c:1742)
-==12638== by 0x40DD1F: check_fs_root (cmds-check.c:3380)
-==12638== by 0x40DD1F: check_fs_roots.isra.51 (cmds-check.c:3516)
-==12638== by 0x4C64B0F: ???
-==12638== by 0x4C30A2F: ???
-==12638== by 0x4C468CF: ???
-==12638== by 0x32629B88DF: ??? (in /usr/lib64/libc-2.20.so)
-==12638== by 0x4C3657F: ???
-==12638== If you believe this happened as a result of a stack
-==12638== overflow in your program's main thread (unlikely but
-==12638== possible), you can try to increase the size of the
-==12638== main thread stack using the --main-stacksize= flag.
-==12638== The main thread stack size used in this run was 8388608.
-==12638==
-==12638== HEAP SUMMARY:
-==12638== in use at exit: 46,260 bytes in 56 blocks
-==12638== total heap usage: 380 allocs, 324 frees, 218,054 bytes allocated
-==12638==
-==12638== LEAK SUMMARY:
-==12638== definitely lost: 272 bytes in 2 blocks
-==12638== indirectly lost: 800 bytes in 8 blocks
-==12638== possibly lost: 88 bytes in 1 blocks
-==12638== still reachable: 45,100 bytes in 45 blocks
-==12638== suppressed: 0 bytes in 0 blocks
-==12638== Rerun with --leak-check=full to see details of leaked memory
-==12638==
-==12638== For counts of detected and suppressed errors, rerun with: -v
-==12638== Use --track-origins=yes to see where uninitialised values come from
-==12638== ERROR SUMMARY: 10 errors from 10 contexts (suppressed: 0 from 0)
-[1] 12638 segmentation fault valgrind btrfs check btrfs_fukked_memorycorruption.bin
diff --git a/tests/fsck-tests/015-check-bad-memory-access/bko-97171-btrfs-image.raw.xz b/tests/fsck-tests/015-check-bad-memory-access/bko-97171-btrfs-image.raw.xz
deleted file mode 100644
index f3f0944d..00000000
--- a/tests/fsck-tests/015-check-bad-memory-access/bko-97171-btrfs-image.raw.xz
+++ /dev/null
Binary files differ
diff --git a/tests/fsck-tests/018-leaf-crossing-stripes/test.sh b/tests/fsck-tests/018-leaf-crossing-stripes/test.sh
index c453ab5c..29eb20b5 100755
--- a/tests/fsck-tests/018-leaf-crossing-stripes/test.sh
+++ b/tests/fsck-tests/018-leaf-crossing-stripes/test.sh
@@ -1,11 +1,11 @@
#!/bin/bash
-source $TOP/tests/common
+source "$TOP/tests/common"
check_prereq btrfs
image=$(extract_image "./default_case.raw.xz")
-run_check_stdout $TOP/btrfs check "$image" 2>&1 |
+run_check_stdout "$TOP/btrfs" check "$image" 2>&1 |
grep -q "crossing stripe boundary" ||
_fail "no expected error message in the output"
diff --git a/tests/fsck-tests/019-non-skinny-false-alert/test.sh b/tests/fsck-tests/019-non-skinny-false-alert/test.sh
index a7f8e862..550f2947 100755
--- a/tests/fsck-tests/019-non-skinny-false-alert/test.sh
+++ b/tests/fsck-tests/019-non-skinny-false-alert/test.sh
@@ -11,12 +11,12 @@
#
# a buggy check leads to the above messages
-source $TOP/tests/common
+source "$TOP/tests/common"
check_prereq btrfs
image=$(extract_image "./default_case.img.xz")
-run_check_stdout $TOP/btrfs check "$image" 2>&1 |
+run_check_stdout "$TOP/btrfs" check "$image" 2>&1 |
grep -q "type mismatch with chunk" &&
_fail "unexpected error message in the output"
diff --git a/tests/fsck-tests/020-extent-ref-cases/block_group_item_false_alert.raw.xz b/tests/fsck-tests/020-extent-ref-cases/block_group_item_false_alert.raw.xz
new file mode 100644
index 00000000..559c3fa9
--- /dev/null
+++ b/tests/fsck-tests/020-extent-ref-cases/block_group_item_false_alert.raw.xz
Binary files differ
diff --git a/tests/fsck-tests/020-extent-ref-cases/shared_data_ref_only.img b/tests/fsck-tests/020-extent-ref-cases/shared_data_ref_only.img
new file mode 100644
index 00000000..6d2b95e4
--- /dev/null
+++ b/tests/fsck-tests/020-extent-ref-cases/shared_data_ref_only.img
Binary files differ
diff --git a/tests/fsck-tests/020-extent-ref-cases/test.sh b/tests/fsck-tests/020-extent-ref-cases/test.sh
index c2b6a006..1e1e4e23 100755
--- a/tests/fsck-tests/020-extent-ref-cases/test.sh
+++ b/tests/fsck-tests/020-extent-ref-cases/test.sh
@@ -8,16 +8,23 @@
# * shared_data_ref
# * no_inline_ref (a extent item without inline ref)
# * no_skinny_ref
+#
+# Special check for lowmem regression
+# * block_group_item_false_alert
+# Containing a block group and its first extent at
+# the beginning of leaf.
+# Which caused false alert for lowmem mode.
-source $TOP/tests/common
+source "$TOP/tests/common"
check_prereq btrfs
-for img in *.img
+for img in *.img *.raw.xz
do
- image=$(extract_image $img)
- run_check_stdout $TOP/btrfs check "$image" 2>&1 |
- grep -q "Errors found in extent allocation tree or chunk allocation" &&
- _fail "unexpected error occurred when checking $img"
+ image=$(extract_image "$img")
+
+ # Since the return value bug is already fixed, we don't need
+ # the old grep hack to detect bug.
+ run_check "$TOP/btrfs" check "$image"
rm -f "$image"
done
diff --git a/tests/fsck-tests/021-partially-dropped-snapshot-case/test.sh b/tests/fsck-tests/021-partially-dropped-snapshot-case/test.sh
index eb8d8849..44a33a63 100755
--- a/tests/fsck-tests/021-partially-dropped-snapshot-case/test.sh
+++ b/tests/fsck-tests/021-partially-dropped-snapshot-case/test.sh
@@ -1,14 +1,14 @@
#!/bin/bash
# confirm whether btrfsck supports to check a partially dropped snapshot
-source $TOP/tests/common
+source "$TOP/tests/common"
check_prereq btrfs
for img in *.img
do
- image=$(extract_image $img)
- run_check_stdout $TOP/btrfs check "$image" 2>&1 |
+ image=$(extract_image "$img")
+ run_check_stdout "$TOP/btrfs" check "$image" 2>&1 |
grep -q "Errors found in extent allocation tree or chunk allocation"
if [ $? -eq 0 ]; then
rm -f "$image"
diff --git a/tests/fsck-tests/022-qgroup-rescan-halfway/test.sh b/tests/fsck-tests/022-qgroup-rescan-halfway/test.sh
index 1dc8f8fc..dcdc1b42 100755
--- a/tests/fsck-tests/022-qgroup-rescan-halfway/test.sh
+++ b/tests/fsck-tests/022-qgroup-rescan-halfway/test.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# check whether btrfsck can detect running qgroup rescan
-source $TOP/tests/common
+source "$TOP/tests/common"
check_prereq btrfs
@@ -9,7 +9,7 @@ check_image() {
local image
image=$1
- run_check_stdout $TOP/btrfs check "$image" 2>&1 | \
+ run_check_stdout "$TOP/btrfs" check "$image" 2>&1 | \
grep -q "Counts for qgroup id"
if [ $? -eq 0 ]; then
_fail "Btrfs check doesn't detect rescan correctly"
diff --git a/tests/fsck-tests/023-qgroup-stack-overflow/test.sh b/tests/fsck-tests/023-qgroup-stack-overflow/test.sh
index a304eac5..ebb07f36 100755
--- a/tests/fsck-tests/023-qgroup-stack-overflow/test.sh
+++ b/tests/fsck-tests/023-qgroup-stack-overflow/test.sh
@@ -5,13 +5,13 @@
# Fixed by patch:
# btrfs-progs: Fix stack overflow for checking qgroup on tree reloc tree
-source $TOP/tests/common
+source "$TOP/tests/common"
check_prereq btrfs
check_image()
{
- run_check $TOP/btrfs check "$1"
+ run_check "$TOP/btrfs" check "$1"
}
check_all_images
diff --git a/tests/fsck-tests/024-clear-space-cache/test.sh b/tests/fsck-tests/024-clear-space-cache/test.sh
index 2945ae87..6cf8440b 100755
--- a/tests/fsck-tests/024-clear-space-cache/test.sh
+++ b/tests/fsck-tests/024-clear-space-cache/test.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# confirm that clearing space cache works
-source $TOP/tests/common
+source "$TOP/tests/common"
check_prereq btrfs
check_prereq mkfs.btrfs
@@ -9,21 +9,21 @@ check_prereq mkfs.btrfs
setup_root_helper
prepare_test_dev 1G
-run_check $SUDO_HELPER $TOP/mkfs.btrfs -f $TEST_DEV
+run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$TEST_DEV"
run_check_mount_test_dev
# Create files that takes at least 3 data chunks, while
# can still be removed to create free space inside one chunk.
for i in $(seq 0 6); do
- run_check $SUDO_HELPER dd if=/dev/zero of=$TEST_MNT/file_${i} bs=1M \
+ run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT/file_${i}" bs=1M \
count=64 > /dev/null 2>&1
done
sync
# Remove file 1 3 5 to create holes
for i in 1 3 5; do
- run_check $SUDO_HELPER rm $TEST_MNT/file_${i}
+ run_check $SUDO_HELPER rm "$TEST_MNT/file_${i}"
done
sync
@@ -31,17 +31,17 @@ sync
run_check_umount_test_dev
# Clear space cache and re-check fs
-run_check $TOP/btrfs check --clear-space-cache v1 $TEST_DEV
-run_check $TOP/btrfs check $TEST_DEV
+run_check "$TOP/btrfs" check --clear-space-cache v1 "$TEST_DEV"
+run_check "$TOP/btrfs" check "$TEST_DEV"
# Manually recheck space cache and super space cache generation
-run_check_stdout $TOP/btrfs inspect-internal dump-tree -t root $TEST_DEV | \
+run_check_stdout "$TOP/btrfs" inspect-internal dump-tree -t root "$TEST_DEV" | \
grep -q FREE_SPACE
if [ $? -eq 0 ]; then
_fail "clear space cache doesn't clear all space cache"
fi
-run_check_stdout $TOP/btrfs inspect-internal dump-super $TEST_DEV |
+run_check_stdout $TOP/btrfs inspect-internal dump-super "$TEST_DEV" |
grep -q 'cache_generation.*18446744073709551615'
if [ $? -ne 0 ]; then
_fail "clear space cache doesn't set cache_generation correctly"
diff --git a/tests/fsck-tests/025-file-extents/test.sh b/tests/fsck-tests/025-file-extents/test.sh
new file mode 100755
index 00000000..ebe8a305
--- /dev/null
+++ b/tests/fsck-tests/025-file-extents/test.sh
@@ -0,0 +1,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