2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2020 SUSE Linux Products GmbH. All Rights Reserved.
7 # Test subvolume deletion using the subvolume id, even when the subvolume in
8 # question is in a different mount space.
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
14 status=1 # failure is the default!
16 # get standard environment, filters and checks
19 . ./common/filter.btrfs
21 # real QA test starts here
25 _require_btrfs_command subvolume delete --subvolid
27 _scratch_mkfs > /dev/null 2>&1
32 local subvol_name="$1"
35 SUBVOLID=$(_btrfs_get_subvolid $SCRATCH_MNT "$subvol_name")
36 $BTRFS_UTIL_PROG subvolume delete --subvolid $SUBVOLID $SCRATCH_MNT | _filter_scratch
39 $BTRFS_UTIL_PROG subvolume list $SCRATCH_MNT | $AWK_PROG '{ print $NF }'
42 # Test creating a normal subvolumes
43 $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/subvol1 | _filter_scratch
44 $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/subvol2 | _filter_scratch
45 $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/subvol3 | _filter_scratch
47 echo "Current subvolume ids:"
48 $BTRFS_UTIL_PROG subvolume list $SCRATCH_MNT | $AWK_PROG '{ print $NF }'
50 # Delete the subvolume subvol1, and list the remaining two subvolumes
51 _delete_and_list subvol1 "After deleting one subvolume:"
54 # Now we mount the subvol2, which makes subvol3 not accessible for this mount
55 # point, but we should be able to delete it using it's subvolume id
56 $MOUNT_PROG -o subvol=subvol2 $SCRATCH_DEV $SCRATCH_MNT
57 _delete_and_list subvol3 "Last remaining subvolume:"
60 # now mount the rootfs
63 _delete_and_list subvol2 "All subvolumes removed."