2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Omar Sandoval. All Rights Reserved.
7 # Test deleting the default subvolume, making sure that submounts under it are
8 # not unmounted prematurely. This is a regression test for Linux commit "Btrfs:
9 # don't invalidate root dentry when subvolume deletion fails".
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
17 status=1 # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
26 # get standard environment, filters and checks
29 . ./common/filter.btrfs
31 # real QA test starts here
33 # Modify as appropriate.
39 _scratch_mkfs >>$seqres.full 2>&1
42 # Create a new subvolume and make it the default subvolume.
43 $BTRFS_UTIL_PROG subvolume create "$SCRATCH_MNT/testvol" >>$seqres.full 2>&1 \
44 || _fail "couldn't create subvol"
45 testvol_id=$(_btrfs_get_subvolid "$SCRATCH_MNT" testvol)
46 $BTRFS_UTIL_PROG subvolume set-default $testvol_id "$SCRATCH_MNT" >>$seqres.full 2>&1 \
47 || _fail "couldn't set default"
49 # Bind-mount a directory under the default subvolume.
50 mkdir "$SCRATCH_MNT/testvol/testdir"
51 mkdir "$SCRATCH_MNT/testvol/mnt"
52 mount --bind "$SCRATCH_MNT/testvol/testdir" "$SCRATCH_MNT/testvol/mnt"
54 # Now attempt to delete the default subvolume.
55 $BTRFS_UTIL_PROG subvolume delete "$SCRATCH_MNT/testvol" >>$seqres.full 2>&1
57 # Unmount the bind mount, which should still be alive.
58 $UMOUNT_PROG "$SCRATCH_MNT/testvol/mnt"
60 echo "Silence is golden"