btrfs/139: require 2GB scratch dev
[xfstests-dev.git] / tests / btrfs / 089
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Omar Sandoval.  All Rights Reserved.
4 #
5 # FS QA Test 089
6 #
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".
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 _cleanup()
21 {
22         cd /
23         rm -f $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29 . ./common/filter.btrfs
30
31 # real QA test starts here
32
33 # Modify as appropriate.
34 _supported_fs btrfs
35 _supported_os Linux
36 _require_scratch
37
38 rm -f $seqres.full
39
40 _scratch_mkfs >>$seqres.full 2>&1
41 _scratch_mount
42
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"
49
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"
54
55 # Now attempt to delete the default subvolume.
56 $BTRFS_UTIL_PROG subvolume delete "$SCRATCH_MNT/testvol" >>$seqres.full 2>&1
57
58 # Unmount the bind mount, which should still be alive.
59 $UMOUNT_PROG "$SCRATCH_MNT/testvol/mnt"
60
61 echo "Silence is golden"
62 status=0
63 exit