2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2016 SUSE Linux Products GmbH. All Rights Reserved.
7 # Test that if we fsync a directory that had a snapshot entry in it that was
8 # deleted and crash, the next time we mount the filesystem, the log replay
9 # procedure will not fail and the snapshot is not present anymore.
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
25 # get standard environment, filters and checks
30 # real QA test starts here
33 _require_dm_target flakey
37 _scratch_mkfs >>$seqres.full 2>&1
38 _require_metadata_journaling $SCRATCH_DEV
42 # Create a snapshot at the root of our filesystem (mount point path), delete it,
43 # fsync the mount point path, crash and mount to replay the log. This should
44 # succeed and after the filesystem is mounted the snapshot should not be visible
46 _run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT $SCRATCH_MNT/snap1
47 _run_btrfs_util_prog subvolume delete $SCRATCH_MNT/snap1
48 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT
49 _flakey_drop_and_remount
50 [ -e $SCRATCH_MNT/snap1 ] && echo "Snapshot snap1 still exists after log replay"
52 # Similar scenario as above, but this time the snapshot is created inside a
53 # directory and not directly under the root (mount point path).
54 mkdir $SCRATCH_MNT/testdir
55 _run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT $SCRATCH_MNT/testdir/snap2
56 _run_btrfs_util_prog subvolume delete $SCRATCH_MNT/testdir/snap2
57 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/testdir
58 _flakey_drop_and_remount
59 [ -e $SCRATCH_MNT/testdir/snap2 ] && \
60 echo "Snapshot snap2 still exists after log replay"
64 echo "Silence is golden"