4 # Test that if we fsync a directory that had a snapshot entry in it that was
5 # deleted and crash, the next time we mount the filesystem, the log replay
6 # procedure will not fail and the snapshot is not present anymore.
8 #-----------------------------------------------------------------------
10 # Copyright (C) 2016 SUSE Linux Products GmbH. All Rights Reserved.
11 # Author: Filipe Manana <fdmanana@suse.com>
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #-----------------------------------------------------------------------
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
32 status=1 # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
42 # get standard environment, filters and checks
47 # real QA test starts here
51 _require_dm_target flakey
52 _require_metadata_journaling $SCRATCH_DEV
56 _scratch_mkfs >>$seqres.full 2>&1
60 # Create a snapshot at the root of our filesystem (mount point path), delete it,
61 # fsync the mount point path, crash and mount to replay the log. This should
62 # succeed and after the filesystem is mounted the snapshot should not be visible
64 _run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT $SCRATCH_MNT/snap1
65 _run_btrfs_util_prog subvolume delete $SCRATCH_MNT/snap1
66 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT
67 _flakey_drop_and_remount
68 [ -e $SCRATCH_MNT/snap1 ] && echo "Snapshot snap1 still exists after log replay"
70 # Similar scenario as above, but this time the snapshot is created inside a
71 # directory and not directly under the root (mount point path).
72 mkdir $SCRATCH_MNT/testdir
73 _run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT $SCRATCH_MNT/testdir/snap2
74 _run_btrfs_util_prog subvolume delete $SCRATCH_MNT/testdir/snap2
75 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/testdir
76 _flakey_drop_and_remount
77 [ -e $SCRATCH_MNT/testdir/snap2 ] && \
78 echo "Snapshot snap2 still exists after log replay"
82 echo "Silence is golden"