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
34 _require_dm_target flakey
38 _scratch_mkfs >>$seqres.full 2>&1
39 _require_metadata_journaling $SCRATCH_DEV
43 # Create a snapshot at the root of our filesystem (mount point path), delete it,
44 # fsync the mount point path, crash and mount to replay the log. This should
45 # succeed and after the filesystem is mounted the snapshot should not be visible
47 _run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT $SCRATCH_MNT/snap1
48 _run_btrfs_util_prog subvolume delete $SCRATCH_MNT/snap1
49 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT
50 _flakey_drop_and_remount
51 [ -e $SCRATCH_MNT/snap1 ] && echo "Snapshot snap1 still exists after log replay"
53 # Similar scenario as above, but this time the snapshot is created inside a
54 # directory and not directly under the root (mount point path).
55 mkdir $SCRATCH_MNT/testdir
56 _run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT $SCRATCH_MNT/testdir/snap2
57 _run_btrfs_util_prog subvolume delete $SCRATCH_MNT/testdir/snap2
58 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/testdir
59 _flakey_drop_and_remount
60 [ -e $SCRATCH_MNT/testdir/snap2 ] && \
61 echo "Snapshot snap2 still exists after log replay"
65 echo "Silence is golden"