blob: d6077853af22eb1fc72a12ae35e8434de73d315f (
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
|
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# FS QA Test 201
#
# Regression test for fix "btrfs: fix invalid removal of root ref"
#
. ./common/preamble
_begin_fstest auto quick subvol snapshot
. ./common/filter
_supported_fs btrfs
_require_scratch
_scratch_mkfs >> $seqres.full 2>&1
_scratch_mount
# Create a subvol b under a and then snapshot a into c. This create's a stub
# entry in c for b because c doesn't have a reference for b.
#
# But when we rename b c/foo it creates a ref for b in c. However if we go to
# remove c/b btrfs used to depend on not finding the root ref to handle the
# unlink properly, but we now have a ref for that root. We also had a bug that
# would allow us to remove mis-matched refs if the keys matched, so we'd end up
# removing too many entries which would cause a transaction abort.
$BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/a | _filter_scratch
$BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/a/b | _filter_scratch
_btrfs subvolume snapshot $SCRATCH_MNT/a $SCRATCH_MNT/c
# Need the dummy entry created so that we get the invalid removal when we rmdir
ls $SCRATCH_MNT/c/b
mkdir $SCRATCH_MNT/c/foo
mv $SCRATCH_MNT/a/b $SCRATCH_MNT/c/foo
rm -rf $SCRATCH_MNT/*
touch $SCRATCH_MNT/blah
status=0
exit
|