summaryrefslogtreecommitdiff
path: root/tests/fsck-tests
Commit message (Collapse)AuthorAge
* btrfs-progs: tests: add fallback to current directory for check_all_imagesDavid Sterba2016-11-23
| | | | | Reported-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: switch to dump- commands from inspectDavid Sterba2016-11-09
| | | | | | | The dump-super and debug-tree commands are replacements for the standalone tools. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fsck-tests: Check if clear space cache worksQu Wenruo2016-11-09
| | | | | | | Add test case to check the basic function of --clear-space-cache. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: test: Add image for quota verify stack overflowQu Wenruo2016-10-24
| | | | | | | | | | | | | For image with tree reloc tree, if its height is over level 2, the root node's backref will point to itself. It's valid for kernel, but quota verify code can't handle it and cause a infinite call, overflowing the stack. Add minimal image to reproduce the bug, as regression test. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> [ minor cleanups in test.sh ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: test: Add test image for btrfsck qgroup rescan detectionQu Wenruo2016-10-24
| | | | | | | | | | | Fixed by commit 7c646c538e74 btrfs-progs: qgroup: Fix regression leads to corrupted qgroup status. Add minimal test image for that fix. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> [ minor cleanups in test.sh ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: add 021-partially-dropped-snapshot-caseWang Xiaoguang2016-09-21
| | | | | Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: add 020-extent-ref-casesLu Fengqi2016-06-01
| | | | | | | | | | | | | | | In order to confirm that btrfsck supports to check a variety of refs, add the following cases: * keyed_block_ref * keyed_data_ref * shared_block_ref * shared_data_ref * no_inline_ref (a extent item without inline ref) * no_skinny_ref Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: add missing prerequisitesDavid Sterba2016-01-12
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: test multiple-linked file corruptionNaohiro Aota2016-01-12
| | | | | | | | | This commit extends the leaf corruption test to try to repair a file linked from multiple directory. It stresses a case that some links to a file is broken but others kept valid. Signed-off-by: Naohiro Aota <naota@elisp.net> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: add 019-non-skinny-false-alertDavid Sterba2015-11-26
| | | | | | | Catch a buggy condition fixed by "btrfs-progs: fsck: Fix a false alert where extent record has wrong metadata flag" Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Introduce fsck-tests/018-leaf-crossing-stripesZhao Lei2015-10-19
| | | | | | | | | | | To test if fsck can check detec "leaf crossing stripes". This function was introduced from patch titled: btrfs-progs: fsck: Check if a metadata tree block crossing stripe boundary Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> [renamed and other minor changes] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Fix mount fail of 013-extent-tree-rebuildZhao Lei2015-09-01
| | | | | | | | | | | | | | | | | | | mount command in old system can not add "-o loop" option automatically for loop device, and make following test failed: # ./fsck-tests.sh ... [TEST] 013-extent-tree-rebuild failed: mount /data/btrfsprogs/tests/test.img /data/btrfsprogs/tests/mnt test failed for case 013-extent-tree-rebuild Considering that $TEST_DEV can be block or loop device, we need determine our mount option in a condition for both case. This patch create a wrapper function for above request, to solve current problem in 013-extent-tree-rebuild, and support similar request in future. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Use --no-same-owner option for tarZhao Lei2015-09-01
| | | | | | | | | | | | | | | | | | | | | | Some test failed in my nfs dir: ... [TEST] 006-bad-root-items tar: test.img: Cannot change ownership to uid 1000, gid 1000: Invalid argument tar: Exiting with failure status due to previous errors failed to extract default_case.tar.xz test failed for case 006-bad-root-items It is because the image file's owner is: # tar tvf default_case.tar.xz -rw-r--r-- fdmanana/fdmanana 2147483648 2014-10-17 17:59 test.img And make tar failed in chown in nfs. It is not a big issue because we don't use nfs commonly, but extract the image file with ownership of current user will be a better choice. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Introduce init_env to initialize common env variantZhao Lei2015-09-01
| | | | | | | | | | | | | | | | | | | | | | | For example, $TEST_DIR is common used in severial tests, and have duplicated code for initialize. These duplicated code not only benifits harddisk vendor, but have inconsistent details, as: convert-tests.sh: lack of mkdir fsck-tests/012-leaf-corruption/test.sh: unnecessary mkdir fsck-tests/013-extent-tree-rebuild/test.sh: unnecessary init misc-tests/XXX ... And severial error message: _fail "unable to create mount point on $TEST_MNT" _fail "failed to create mount point" ... This patch move initizlizaton of $TEST_DIR to common init_env(), to avoid above problem, and init_env() can be used to add more things in future. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fsck-tests: add case for inode losing all its extentsQu Wenruo2015-08-31
| | | | | | | | Add test case for inode with no file extents, but still non-zero size. To test whether fsck will infinite loop. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Move code to create loop device to commonZhao Lei2015-08-31
| | | | | | | | This code block is used several tests, move it to ./common and add a helper. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Add -o loop to fsck-tests/012-leaf-corruptionZhao Lei2015-08-31
| | | | | | | | | To avoid following mount error in test: mount: /root/btrfs/progs/tests/fsck-tests/012-leaf-corruption/test.img is not a block device (maybe try `-o loop'?) Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Add test case for I_ERR_FILE_WRONG_NBYTES repairQu Wenruo2015-07-03
| | | | | | | | Add a new test case for I_ERR_FILE_WRONG_NBYTES. The new btrfs-image dump image contains a file in 12K size. But nbytes in its inode item is a random number. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
* btrfs-progs: test: 015-check-bad-memory-accessDavid Sterba2015-05-25
| | | | | | | | | | | | | Crafted images may trigger out-of-bounds access during check, fixed by "btrfs-progs: Enhance read_tree_block to avoid memory corruption" Now adding image for the first one, the other need enhancements in the testing framework. Reference: https://bugzilla.kernel.org/show_bug.cgi?id=97171 Reference: https://bugzilla.kernel.org/show_bug.cgi?id=97191 Reference: https://bugzilla.kernel.org/show_bug.cgi?id=97271 Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: use local btrfs-image in leaf corruption testWorMzy Tykashi2015-04-09
| | | | | | | | | | Currently this test uses the system btrfs-image. If there isn't a btrfs-image on $PATH, the test fails. The test should be using the locally compiled btrfs-image, not the system one. Signed-off-by: WorMzy Tykashi <wormzy.tykashi@gmail.com> Reviewed-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: tests: remove duplicate output for fsck test 013David Sterba2015-04-07
| | | | | | The test name is logged since it lives in it's own directory. Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: tests: split make rule for fsck and convert tests, fix ↵David Sterba2015-04-07
| | | | | | | | | | prerequisities We'd like to run each class of tests separately. There were some missing prerequisities that should be/are verified by the tests, makefile rules have been synced. Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: fsck-tests: Add fallback TEST_DEV for test case 013Qu Wenruo2015-04-07
| | | | | | | | | | Add fallback TEST_DEV for test case 013. Fallback to $TOP/tests/test.img. Now all test cases of btrfs-progs need no extra setting except sudo. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: fsck-tests: Update 013-extent-tree-rebuild to use more test ↵Qu Wenruo2015-04-07
| | | | | | | | | | | | | framework infrastructure. Update 013-extent-tree-rebuild to use more framework infrastructure, including: 1) Use run_check other than open-coded redirect 2) Add root privillege 3) Add dependency on 'btrfs-debug-tree' command Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: fsck-tests: Remove duplicatesd TEST_MNT setup.Qu Wenruo2015-04-07
| | | | | | | | Since we have already had TEST_MNT fallback setup to $TOP/tests/mnt, just remove duplicated setting in 012-leaf-corruption/test.sh Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: test-frame: Update variant namesQu Wenruo2015-04-07
| | | | | | | | | | | | Use upper case variant name for the following variants: 1) top -> TOP 2) script_dir -> SCRIPT_DIR And change the following variant name: 1) RESULT -> RESULTS Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: tests, clean up scriptsDavid Sterba2015-03-09
| | | | | | | Rename variables, use caps, call true by full path, add quotation to variables and a few wording fixes. Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: fsck-test: Add check_sudo to check valid root/sudo privilegeQu Wenruo2015-03-09
| | | | | | | | | | | | | | | | | | | | | | Although fsck-test/012 uses sudo, it uses 'sudo -n', which won't prompt user to input password and will return 1 if no valid credential is found. And this makes test result quite annoying since it fails to mount and still continue, which will always fail. This patch will check 'sudo -v -n' and 'sudo -n true' to determine whether sudo works fine in different version/settings, since in some setting/version, 'sudo -v -n' will fail even the user is set NOPASSWD. Also, remove the 'have_root_helper' variant, since there is a possibility that sudo credential will timeout during the test and 'have_root_helper' won't help to detect such problem. New '_sudo' command will do credential check if needed to avoid such problem. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: deal with no extent infoJosef Bacik2015-02-09
| | | | | | | | | | Previously we used to just set FULL_BACKREF if we couldn't lookup an extent info for an extent. Now we just bail out if we can't lookup the extent info, which is less than good since fsck is supposed to fix these very problems. So instead figure out the flag we are supposed to use and pass that along instead. This patch also provides a test image to test this functionality. Thanks, Signed-off-by: Josef Bacik <jbacik@fb.com>
* btrfs-progs: tests, adjust alignment of the pretty command nameDavid Sterba2015-01-14
| | | | Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: tests, use the root helper in 012David Sterba2015-01-14
| | | | | | We need it to mount/umount, to traverse lost+found and stat the results. Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Move extent tree rebuild test to its dirQu Wenruo2015-01-14
| | | | | | | Move extent tree rebuild teset to its dir. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Move leaf-corruption no extent data case and add verification ↵Qu Wenruo2015-01-14
| | | | | | | | | | | | | | | script Move leaf-corruption type no extent data case to its dir, and add verification script in test.sh The verification script is based on manual btrfs-debug-tree check. The image can also be reused to other leaf-corruption type, like corrupted leaf contains regular file extent data case. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Move bad root items test cases to its corresponding dirQu Wenruo2015-01-14
| | | | | | | | Now 006-bad-root-items has two cases, one for default case, and one for skinny metadata case. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Move btrfs-image dump to corresponding dirQu Wenruo2015-01-14
| | | | | | | | Move these obvious btrfs-image to its corresponding dir to use the new infrastructure. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Add testcase for leaf-corrupted btrfsck repairing.Qu Wenruo2014-12-18
| | | | | | | Add testcase for leaf-corrupted btrfsck repairing using the new generate_image.sh method. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
* Btrfs-progs: add two new test imagesJosef Bacik2014-12-18
| | | | | | | | | | | | | | | | This adds two new test images 1) 008-bad-offset-snapshots. This has a corrupt item with multiple snapshots pointing to it, to make sure the bad block repair stuff doesn't loop and actually repairs stuff. It also requires the dir index repair stuff to pass our built in tests which is why it's not tied to the same commit. 2) 009-bad-dir-index-name.img. This has a corrupt name in a dir index to make sure our dir index repair stuff is working properly. Thanks, Signed-off-by: Josef Bacik <jbacik@fb.com>
* Btrfs-progs: test images for new btrfsck functionalityJosef Bacik2014-11-14
| | | | | | | These test the recreating of missing dir item/dir index pairs, fixing the no rootdir inode item and no inode item for normal files. Thanks, Signed-off-by: Josef Bacik <jbacik@fb.com>
* Btrfs-progs: check, ability to detect and fix outdated snapshot root itemsFilipe Manana2014-10-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change adds code to detect and fix the issue introduced in the kernel release 3.17, where creation of read-only snapshots lead to a corrupted filesystem if they were created at a moment when the source subvolume/snapshot had orphan items. The issue was that the on-disk root items became incorrect, referring to the pre orphan cleanup root node instead of the post orphan cleanup root node. A test filesystem can be generated with the test case recently submitted for xfstests/fstests, which is essencially the following (bash script): workout() { ops=$1 procs=$2 num_snapshots=$3 _scratch_mkfs >> $seqres.full 2>&1 _scratch_mount snapshot_cmd="$BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT" snapshot_cmd="$snapshot_cmd $SCRATCH_MNT/snap_\`date +'%H_%M_%S_%N'\`" run_check $FSSTRESS_PROG -p $procs \ -x "$snapshot_cmd" -X $num_snapshots -d $SCRATCH_MNT -n $ops } ops=10000 procs=4 snapshots=500 workout $ops $procs $snapshots Example of btrfsck's (btrfs check) behaviour against such filesystem: $ btrfsck /dev/loop0 root item for root 311, current bytenr 44630016, current gen 60, current level 1, new bytenr 44957696, new gen 61, new level 1 root item for root 1480, current bytenr 1003569152, current gen 1271, current level 1, new bytenr 1004175360, new gen 1272, new level 1 root item for root 1509, current bytenr 1037434880, current gen 1300, current level 1, new bytenr 1038467072, new gen 1301, new level 1 root item for root 1562, current bytenr 33636352, current gen 1354, current level 1, new bytenr 34455552, new gen 1355, new level 1 root item for root 3094, current bytenr 1011712000, current gen 2935, current level 1, new bytenr 1008484352, new gen 2936, new level 1 root item for root 3716, current bytenr 80805888, current gen 3578, current level 1, new bytenr 73515008, new gen 3579, new level 1 root item for root 4085, current bytenr 714031104, current gen 3958, current level 1, new bytenr 716816384, new gen 3959, new level 1 Found 7 roots with an outdated root item. Please run a filesystem check with the option --repair to fix them. $ echo $? 1 $ btrfsck --repair /dev/loop0 enabling repair mode fixing root item for root 311, current bytenr 44630016, current gen 60, current level 1, new bytenr 44957696, new gen 61, new level 1 fixing root item for root 1480, current bytenr 1003569152, current gen 1271, current level 1, new bytenr 1004175360, new gen 1272, new level 1 fixing root item for root 1509, current bytenr 1037434880, current gen 1300, current level 1, new bytenr 1038467072, new gen 1301, new level 1 fixing root item for root 1562, current bytenr 33636352, current gen 1354, current level 1, new bytenr 34455552, new gen 1355, new level 1 fixing root item for root 3094, current bytenr 1011712000, current gen 2935, current level 1, new bytenr 1008484352, new gen 2936, new level 1 fixing root item for root 3716, current bytenr 80805888, current gen 3578, current level 1, new bytenr 73515008, new gen 3579, new level 1 fixing root item for root 4085, current bytenr 714031104, current gen 3958, current level 1, new bytenr 716816384, new gen 3959, new level 1 Fixed 7 roots. Checking filesystem on /dev/loop0 UUID: 2186e9b9-c977-4a35-9c7b-69c6609d4620 checking extents checking free space cache cache and super generation don't match, space cache will be invalidated checking fs roots checking csums checking root refs found 618537000 bytes used err is 0 total csum bytes: 130824 total tree bytes: 601620480 total fs tree bytes: 580288512 total extent tree bytes: 18464768 btree space waste bytes: 136939144 file data blocks allocated: 34150318080 referenced 27815415808 Btrfs v3.17-rc3-2-gbbe1dd8 $ echo $? 0 Signed-off-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: make fsck deal with bogus itemsJosef Bacik2014-10-14
| | | | | | | | | | We can deal with corrupt items by deleting them in a few cases. Fsck can easily recover from a missing extent item or a dir index item. So if we notice a item is completely bogus and it is of a key that we know we can repair then just delete it and carry on. Thanks, Signed-off-by: Josef Bacik <jbacik@fb.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: add the ability to fix shifted item offsetsJosef Bacik2014-10-14
| | | | | | | | | | | A user had a corrupted fs where the items had been shifted improperly. This patch adds the ability to fix this sort of problem within fsck. We will simply shift the item over to the proper offset and update the offsets to make sure they are correct. I tested this with a hand crafted fs that was broken in the same way as the user, and I've included the file as a new test. Thanks, Signed-off-by: Josef Bacik <jbacik@fb.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* Btrfs-progs: repair missing dir indexJosef Bacik2014-10-13
| | | | | | | | | | | If we have an inode backref entry then we know enough to add back a missing dir index. When messing with the inode backrefs we need to do all of that first before we process the inode recs themselves as we may clear errors on the inode recs as we fix the directory indexes. This adds the framework for fixing backref errors and fixes missing dir index issues. Thanks, Signed-off-by: Josef Bacik <jbacik@fb.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* Btrfs-progs: add a test image for the transid fixer in btrfsckJosef Bacik2013-10-16
| | | | | | | | | | This is a verification test for the transid recow functionality of btrfsck. I've also adjusted the test script to spit out which image it's testing so I can be sure the image was getting tested. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: add make test frameworkJosef Bacik2013-10-16
We need to start adding some sanity tests to btrfs-progs to make sure we aren't breaking things with our patches. The most important of these tools is btrfsck. This patch gets things started by adding a basic btrfsck test that makes sure we can fix a corruption problem we know we can fix. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>