btrfs-progs: tests: add a test to check orphaned directories

When adding the GC support I noticed we were failing fsck when we had a
directory that hadn't been cleaned up yet because of rm -rf.  However
this isn't limited to extent-tree-v2, we'll actually fail in the same
way if we were unable to do the evict portion of the deletion and left
the orphan items around for everybody.

This is a valid file system, it'll be cleaned up properly at mount time,
so fsck shouldn't fail in this case.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Josef Bacik 2022-02-22 17:24:31 -05:00 committed by David Sterba
parent c9703d8726
commit babbfa8ac2
2 changed files with 20 additions and 0 deletions

Binary file not shown.

View File

@ -0,0 +1,20 @@
#!/bin/bash
# We could potentially have a directory and it's children with ORPHAN items left
# for them without having been cleaned up.
#
# fsck shouldn't complain about this or attempt to do anything about it, the
# orphan cleanup will do the correct thing.
#
# To create this image I simply modified the kernel to skip doing the
# btrfs_truncate_inode_items() and removing the orphan item at evict time, and
# then rm -rf'ed a directory.
source "$TEST_TOP/common"
check_prereq btrfs
check_image() {
run_check "$TOP/btrfs" check "$1"
}
check_all_images