summaryrefslogtreecommitdiff
path: root/tests/btrfs/089
blob: 9460d4e8bf6b73ef7984a77d1ca106c35080453e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2015 Omar Sandoval.  All Rights Reserved.
#
# FS QA Test 089
#
# Test deleting the default subvolume, making sure that submounts under it are
# not unmounted prematurely. This is a regression test for Linux commit "Btrfs:
# don't invalidate root dentry when subvolume deletion fails".
#
. ./common/preamble
_begin_fstest auto quick subvol

. ./common/filter
. ./common/filter.btrfs

_supported_fs btrfs
_require_scratch

_scratch_mkfs >>$seqres.full 2>&1
_scratch_mount

# Create a new subvolume and make it the default subvolume.
$BTRFS_UTIL_PROG subvolume create "$SCRATCH_MNT/testvol" >>$seqres.full 2>&1 \
	|| _fail "couldn't create subvol"
testvol_id=$(_btrfs_get_subvolid "$SCRATCH_MNT" testvol)
$BTRFS_UTIL_PROG subvolume set-default $testvol_id "$SCRATCH_MNT" >>$seqres.full 2>&1 \
	|| _fail "couldn't set default"

# Bind-mount a directory under the default subvolume.
mkdir "$SCRATCH_MNT/testvol/testdir"
mkdir "$SCRATCH_MNT/testvol/mnt"
mount --bind "$SCRATCH_MNT/testvol/testdir" "$SCRATCH_MNT/testvol/mnt"

# Now attempt to delete the default subvolume.
$BTRFS_UTIL_PROG subvolume delete "$SCRATCH_MNT/testvol" >>$seqres.full 2>&1

# Unmount the bind mount, which should still be alive.
$UMOUNT_PROG "$SCRATCH_MNT/testvol/mnt"

echo "Silence is golden"
status=0
exit