summaryrefslogtreecommitdiff
path: root/tests/btrfs/118
blob: 0bb50b101d1ff1964374e10c040f5a3dead06a69 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2016 SUSE Linux Products GmbH. All Rights Reserved.
#
# FSQA Test No. 118
#
# Test that if we fsync a directory that had a snapshot entry in it that was
# deleted and crash, the next time we mount the filesystem, the log replay
# procedure will not fail and the snapshot is not present anymore.
#
. ./common/preamble
_begin_fstest auto quick snapshot metadata log

# Override the default cleanup function.
_cleanup()
{
	_cleanup_flakey
	cd /
	rm -f $tmp.*
}

. ./common/filter
. ./common/dmflakey

_supported_fs btrfs
_require_scratch
_require_dm_target flakey

_scratch_mkfs >>$seqres.full 2>&1
_require_metadata_journaling $SCRATCH_DEV
_init_flakey
_mount_flakey

# Create a snapshot at the root of our filesystem (mount point path), delete it,
# fsync the mount point path, crash and mount to replay the log. This should
# succeed and after the filesystem is mounted the snapshot should not be visible
# anymore.
_btrfs subvolume snapshot $SCRATCH_MNT $SCRATCH_MNT/snap1
_btrfs subvolume delete $SCRATCH_MNT/snap1
$XFS_IO_PROG -c "fsync" $SCRATCH_MNT
_flakey_drop_and_remount
[ -e $SCRATCH_MNT/snap1 ] && echo "Snapshot snap1 still exists after log replay"

# Similar scenario as above, but this time the snapshot is created inside a
# directory and not directly under the root (mount point path).
mkdir $SCRATCH_MNT/testdir
_btrfs subvolume snapshot $SCRATCH_MNT $SCRATCH_MNT/testdir/snap2
_btrfs subvolume delete $SCRATCH_MNT/testdir/snap2
$XFS_IO_PROG -c "fsync" $SCRATCH_MNT/testdir
_flakey_drop_and_remount
[ -e $SCRATCH_MNT/testdir/snap2 ] && \
	echo "Snapshot snap2 still exists after log replay"

_unmount_flakey

echo "Silence is golden"

status=0
exit