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.
40 _scratch_mkfs >>$seqres.full 2>&1
43 # Create a new subvolume and make it the default subvolume.
44 $BTRFS_UTIL_PROG subvolume create "$SCRATCH_MNT/testvol" >>$seqres.full 2>&1 \
45 || _fail "couldn't create subvol"
46 testvol_id=$(_btrfs_get_subvolid "$SCRATCH_MNT" testvol)
47 $BTRFS_UTIL_PROG subvolume set-default $testvol_id "$SCRATCH_MNT" >>$seqres.full 2>&1 \
48 || _fail "couldn't set default"
50 # Bind-mount a directory under the default subvolume.
51 mkdir "$SCRATCH_MNT/testvol/testdir"
52 mkdir "$SCRATCH_MNT/testvol/mnt"
53 mount --bind "$SCRATCH_MNT/testvol/testdir" "$SCRATCH_MNT/testvol/mnt"
55 # Now attempt to delete the default subvolume.
56 $BTRFS_UTIL_PROG subvolume delete "$SCRATCH_MNT/testvol" >>$seqres.full 2>&1
58 # Unmount the bind mount, which should still be alive.
59 $UMOUNT_PROG "$SCRATCH_MNT/testvol/mnt"
61 echo "Silence is golden"