summaryrefslogtreecommitdiff
path: root/tests/fsck-tests
Commit message (Collapse)AuthorAge
* New upstream releaseDimitri John Ledkov2019-01-26
|
* btrfs-progs: tests: fsck/025, fix typo in helpre nameJosh Soref2018-11-26
| | | | | | | | Generated by https://github.com/jsoref/spelling Issue: #154 Author: Josh Soref <jsoref@users.noreply.github.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: fix typos in test commentsJosh Soref2018-11-26
| | | | | | | | Generated by https://github.com/jsoref/spelling Issue: #154 Author: Josh Soref <jsoref@users.noreply.github.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: add runtime check for free-space-treeDavid Sterba2018-10-25
| | | | | | | The CI hosts have old kernel that does not support the FST, make the test fail gracefully. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Test for FST corruption detection/repairNikolay Borisov2018-10-25
| | | | | | | | Simple test case which preps a filesystem, then corrupts the FST and finally repairs it. Tests both extent based and bitmap based FSTs. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: renumber last fsck test to 036-rescan-not-kicked-inDavid Sterba2018-10-23
| | | | | | | | The commit d99615284a83452c019f5bed05a882f93a4ef19a ("btrfs-progs: fsck-tests: Add test image to check if btrfs check reports uninitialized rescan as error") added test 035, should have been 036. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fsck-tests: Add test image to check if btrfs check reports ↵Qu Wenruo2018-08-06
| | | | | | | uninitialized rescan as error Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fsck-tests: add test case with keyed data backref with reloc ↵Su Yue2018-08-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | tree blocks For trees have been balanced, leaves are with flag BTRFS_HEADER_FLAG_RELOC and extent data backrefs are shared. Like: ===================== item 0 key (11927552 EXTENT_ITEM 524288) itemoff 3932 itemsize 63 refs 129 gen 7 flags DATA shared data backref parent 35897344 count 41 shared data backref parent 35426304 count 37 shared data backref parent 35422208 count 51 ===================== Then make the leaf which owns the extent data cowed. The shared data backref was to transferred to keyed data ref, but remaining backrefs are still shared. Like: ===================== item 0 key (11927552 EXTENT_ITEM 524288) itemoff 3887 itemsize 108 refs 129 gen 7 flags DATA extent data backref root 5 objectid 258 offset 0 count 40 extent data backref root 5 objectid 257 offset 0 count 1 shared data backref parent 35426304 count 37 shared data backref parent 35422208 count 51 ===================== However lowmem mode used to iterate the whole inode to find all references, and doesn't care if a reference is already counted by the shared tree block. Add the test case to check it. Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fsck-tests: Add test case for corrupted inline ram_bytesQu Wenruo2018-08-06
| | | | | Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: fix fsck-tests/031 when on NFSDavid Sterba2018-06-07
| | | | | | | | The restore target file does not exist and creating by root does not work on NFS, so precreating will make that work. Also fix the image name to be deleted. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fsck-tests: add test case to check symlinks with bad flagsSu Yue2018-06-07
| | | | | | | | There are two bad symlinks in the test case. One is with immutable attribute. Another one is with append attribute. Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Add test for collision DIR_ITEM handlingNikolay Borisov2018-06-07
| | | | | | | | | | | | | | Verify that if we have an otherwise clean filesystem, containging collided DIR_ITEM, btrfs check lowmem's mode can correctly handle those and not produce any false positives. This if fixed by commit titled: "btrfs-progs: check: fix DIR_ITEM checking in lowmem" Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Add test case to ensure btrfs check returns error for ↵Qu Wenruo2018-06-07
| | | | | | | | | | | | corrupted qgroups Since the test case uses run_mustfail(), which is pretty easy pass due to other unexpected problems, so here an extra run_check() is added to ensure we don't only report qgroup error, but also fix it without problem. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: add image with no extent with normal device sizeSu Yue2018-06-07
| | | | | | | | | | | | | | This new image misses one extent which leads lowmem mode to allocate new chunks in repair. Rename original image to no_extent_bad_dev.img. Because of its bad used bytes, it should let lowmem mode exclude blocks in repair. Due to problems of btrfs-image, choose xz as compression tool. Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests/fsck: Add test case to check if btrfs check can skip data ↵Qu Wenruo2018-04-24
| | | | | | | csum verfication for metadata dump Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: remove trivial use of local variablesDavid Sterba2018-03-30
| | | | | | | No need to use a temporary variable if the parameter usage is obvious from the context. Signed-off-by: David Sterba <dsterba@suse.com>
* Btrfs-progs: add fsck test for filesystem with shared prealloc extentsFilipe Manana2018-03-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 This scenario is fixed by the following patch for the filesystem checker: "Btrfs-progs: check, fix false error reports for shared prealloc extents" Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: fix source path for testsuiteDavid Sterba2018-03-30
| | | | | | | | The commit cebf3b37228cbde730a5 ("btrfs-progs: introduce TEST_TOP and INTERNAL_BIN for tests") did not convert all test paths. This would break the exported testsutie. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Add test case with valid orphan inodeQu Wenruo2018-03-30
| | | | | | | | Regression test for false alerts in lowmem mode. Signed-off-by: Qu Wenruo <wqu@suse.com> [ update test ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fsck-tests: Introduce test case with keyed data backref with ↵Lu Fengqi2018-03-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the extent offset Add the testcase for false alert of data extent backref lost with the extent offset. The image can be reproduced by the following commands: ------ dev=~/test.img mnt=/mnt/btrfs umount $mnt &> /dev/null fallocate -l 128M $dev mkfs.btrfs $dev mount $dev $mnt for i in `seq 1 10`; do xfs_io -f -c "pwrite 0 2K" $mnt/file$i done xfs_io -f -c "falloc 0 64K" $mnt/file11 for i in `seq 1 32`; do xfs_io -f -c "reflink $mnt/file11 0 $(($i * 64))K 64K" $mnt/file11 done xfs_io -f -c "reflink $mnt/file11 32K $((33 * 64))K 32K" $mnt/file11 btrfs subvolume snapshot $mnt $mnt/snap1 umount $mnt btrfs-image -c9 $dev extent_data_ref.img ------ Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: introduce TEST_TOP and INTERNAL_BIN for testsGu Jinxiang2018-02-13
| | | | | | | | | | | | Use TEST_TOP as base for tests to reference any files, this will be used for git and external testsuite. INTERNAL_BIN is needed for referencing binaries that could reside in different paths in git vs external testsuite. Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com> [ add quotes around sourced files, update changelog ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fsck-tests: Cleanup the restored image for 028Qu Wenruo2018-02-06
| | | | | Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: chang tree-reloc-tree test number from 027 to 015Qu Wenruo2018-02-02
| | | | | | | | | | | | There are 2 fsck tests with the same number 027: tree-reloc-tree bad-extent-inline-ref-type And we also have a hole in 015, so just rename tree-reloc-tree to 015, to get rid of the duplicated test number and fill in the hole. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: fixup mount tests of fsck/028-unaligned-super-dev-sizesDavid Sterba2018-01-31
| | | | | | | This test was broken because it tried to mount a different image than what it had repaired. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: 029-super-recovery: cleanup the testDavid Sterba2018-01-31
| | | | | | | Transform the test to the common helpers and don't manage the loop devices here. The test category changes from check to misc. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Add test for super block recoveryNikolay Borisov2018-01-31
| | | | | | | | | This functionality regressed some time ago and it was never caught. Seems no one complained of that, but to be sure add a regression test to prevent future regressions. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: test/fsck/021: Cleanup custom check by overriding check_imageQu Wenruo2018-01-03
| | | | | | Signed-off-by: Qu Wenruo <wqu@suse.com> [ update comment ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: test/fsck/020: Cleanup custom check function by overriding ↵Qu Wenruo2018-01-03
| | | | | | | check_image function Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: test/fsck: Introduce test images containing tree reloc treeQu Wenruo2018-01-03
| | | | | | | | | | | | | Reloc tree is a special tree with very short life span. It acts as a special snapshot for any tree, with related nodes/leaves or EXTENT_DATA modified to point to new position. Considering the short life span and its special purpose, it should be quite reasonable to keep them as both corner case for fsck and educational dump for anyone interested in relocation. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fsck-tests: Introduce test case with keyed data backref with ↵Qu Wenruo2018-01-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | shared tree blocks For snapshot shared tree blocks with source subvolume, the keyed backref counter only counts the exclusive owned references. In the following case, 258 is a snapshot of 257, which inherits all the reference to this data extent. ------ item 4 key (12582912 EXTENT_ITEM 524288) itemoff 3741 itemsize 140 refs 179 gen 9 flags DATA extent data backref root 257 objectid 258 offset 0 count 49 extent data backref root 257 objectid 257 offset 0 count 1 extent data backref root 256 objectid 258 offset 0 count 128 extent data backref root 256 objectid 257 offset 0 count 1 ------ However lowmem mode used to iterate the whole inode to find all references, and doesn't care if a reference is already counted by the shared tree block. Add the test case to check it. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fsck-test: Add new image with shared block ref only metadata ↵Qu Wenruo2018-01-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | backref The image is dumped by modifying kernel to sleep long enough before merging relocation trees, so we can just copy the whole image to other place before kernel begins to merge reloc trees. And the base image is created by the following script to bump metadata size: ------ dev=~/test.img mnt=/mnt/btrfs umount $mnt &> /dev/null fallocate -l 128M $dev mkfs.btrfs -f -n 4k -m single -d single $dev mount $dev $mnt -o nospace_cache,max_inline=2048 btrfs subvolume create $mnt/src for i in $(seq -w 0 128); do xfs_io -f -c "pwrite 0 2k" $mnt/src/file_$i > /dev/null done for i in $(seq -w 0 64); do btrfs subvolume snapshot $mnt/src/ $mnt/snapshot_$i touch $mnt/snapshot_$i/new done sync ------ The image triggers several corner cases that the old lowmem mode didn't consider. Like metadata backref with FULL_BACKREF flag and only SHARED_BLOCK_REF backrefs for metadata. And several tree reloc trees with shared leaves/nodes to confuse old lowmem mode. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fsck-test: Introduce test case for false data extent backref lostQu Wenruo2018-01-03
| | | | | | | | | | | Introduce a new test image, which has an extent item with no inlined extent data ref, but all keyed extent data ref. Only in this case we can trigger fase data extent backref lost bug in lowmem mode. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: test: Add test image for lowmem mode referencer count mismatch ↵Lu Fengqi2017-11-14
| | | | | | | | | | | false alert Add a image which can reproduce the extent item referencer count mismatch false alert for lowmem mode. Reported-by: Marc MERLIN <marc@merlins.org> Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: test: Add test image for lowmem mode file extent interruptLu Fengqi2017-11-14
| | | | | | | | Add a image that the inlined extent coexist with the regular extent. Reported-by: Marc MERLIN <marc@merlins.org> Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: extend fsck/028 to test fix-device-size and mountDavid Sterba2017-11-14
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests/fsck: Add test case image for 'rescue fix-dev-size'Qu Wenruo2017-11-14
| | | | | | | | | | | | | | | | The image has 2 problems mixed: 1) Too small super total_bytes This super total_bytes is manually modified to create such problem. 2) Unaligned dev item total_bytes This is created by v4.12 kernel, with 128M + 2K device added, and original device removed. Then we can create such image with unaligned dev item total_bytes. Signed-off-by: Qu Wenruo <quwenruo.btrfs@gmx.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: don't pass size to prepare_test_dev if not necessaryDavid Sterba2017-11-14
| | | | | | | Most tests don't need a specific size of the test device, the default 2GiB should be fine. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fsck-tests: 027/bad_extent_inline_ref_typeSu Yue2017-11-14
| | | | | | | | This case is for avoiding crash in lowmem check mode. Field type of extent_inline_ref in an extent is corrupted. Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Allow check test to repair in lowmem mode for certain errorsQu Wenruo2017-10-16
| | | | | | | | | | | | | | Since lowmem mode can repair certain corruptions (mostly in fs tree), insert a beacon into each fsck test cases to allow some of them be tested in lowmem mode. With this patch, fsck option override will check the beacon file ".lowmem_repairable" in the same directory of the test image, and if the beacon exists, then it will also run lowmem mode repair to repair the image. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fsck-test: case for corrupted dir item nameSu Yue2017-08-24
| | | | | | | | | | In this test case, all name in dir_item, dir_index, inode_ref are corrupted to another one. btrfs check should report errors about the corrupted dir_item but btrfs can't repair the case now. Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Use '-t btrfs' mount option in testsAdam Buchbinder2017-07-20
| | | | | | | | Without it, mount (at least from util-linux 2.20.1) tries (and fails) to mount some filesystems as NTFS. Signed-off-by: Adam Buchbinder <abuchbinder@google.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Add test case to check file hole extents with NO_HOLES flagQu Wenruo2017-06-26
| | | | | | | | | | | | Add test case which we have NO_HOLES incompat flag while still have hole file extent. This can be created by enabling NO_HOLES feature on an existing filesystem, which lowmem mode would cause false alert for it. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> [ minor adjustments ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: add variable quotation to fsck-testsLakshmipathi.G2017-05-02
| | | | | Signed-off-by: Lakshmipathi.G <Lakshmipathi.G@giis.co.in> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Add SHARED_DATA_REF test image for check lowmem modeQu Wenruo2017-03-31
| | | | | | | | | | | | | | Introduce a new image, which contains external SHARED_DATA_REF items to trigger a lowmem mode false alert. The image only contains external SHARED_DATA_REF and no inlined data backref. Before the image, we only have inlined shared data ref, which is not enough to trigger lowmem mode false alert. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: use dd in 025-file-extents for creating filesDavid Sterba2017-03-08
| | | | | | | Drop the dependency on xfs_io as it's not a standard tool, though it provides convenience. We use a simple write here so dd can manage. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: fix permissions of temporary files in 025-file-extentsDavid Sterba2017-03-08
| | | | | | | | If the tests are started from non-root user, the fallocate and xfs_io fail. Use the root helper as a workaround, we'd should fix the perms instead. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Add new test case for file extent false alertsQu Wenruo2017-03-08
| | | | | | | | | | | | | | | | | | Lowmem mode exposed several false alerts, all related to file extents check. 1) Partly written prealloc extent Cause lowmem mode to report missing csum or prealloc extent should not have csum 2) Compressed inline extent Cause lowmem mode to find mismatch on inline len and item len. While no error message is output but exit silently. Reported-by: Chris Murphy <chris@colorremedies.com> Reported-by: Christoph Anton Mitterer <calestyo@scientia.net> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Make fsck-test/013 compatible with lowmem modeQu Wenruo2017-03-08
| | | | | | | | | | | | | fsck-tests/013-extent-tree-rebuild uses "--init-extent-tree", which implies "--repair". But the test script doesn't specify "--repair" for lowmem mode test to detect it. Add it so lowmem mode test can be happy with it. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Add test image for lowmem mode block group false alertQu Wenruo2017-03-08
| | | | | | | | | Add a minimal image which can reproduce the block group used space false alert for lowmem mode fsck. Reported-by: Christoph Anton Mitterer <calestyo@scientia.net> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Move fsck-tests/015 to fuzz testsQu Wenruo2017-03-08
| | | | | | | | | | | The test case fsck-tests/015-check-bad-memory-access can't be repair by btrfs check, and it's a fortunate bug makes original mode to forget the error code from extent tree, making original mode pass it. So fuzz-tests is more suitable for it. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>