2 # SPDX-License-Identifier: GPL-2.0
6 # Regression test for fix "btrfs: fix invalid removal of root ref"
9 seqres=$RESULT_DIR/$seq
10 echo "QA output created by $seq"
14 status=1 # failure is the default!
15 trap "_cleanup; exit \$status" 0 1 2 3 15
30 _scratch_mkfs >> $seqres.full 2>&1
33 # Create a subvol b under a and then snapshot a into c. This create's a stub
34 # entry in c for b because c doesn't have a reference for b.
36 # But when we rename b c/foo it creates a ref for b in c. However if we go to
37 # remove c/b btrfs used to depend on not finding the root ref to handle the
38 # unlink properly, but we now have a ref for that root. We also had a bug that
39 # would allow us to remove mis-matched refs if the keys matched, so we'd end up
40 # removing too many entries which would cause a transaction abort.
42 $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/a | _filter_scratch
43 $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/a/b | _filter_scratch
44 $BTRFS_UTIL_PROG subvolume snapshot $SCRATCH_MNT/a $SCRATCH_MNT/c \
47 # Need the dummy entry created so that we get the invalid removal when we rmdir
50 mkdir $SCRATCH_MNT/c/foo
51 mv $SCRATCH_MNT/a/b $SCRATCH_MNT/c/foo
53 touch $SCRATCH_MNT/blah