btrfs/139: require 2GB scratch dev
[xfstests-dev.git] / tests / btrfs / 120
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2016 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FSQA Test No. 120
6 #
7 # Test that if we delete a snapshot, delete its parent directory, create
8 # another directory with the same name as that parent and then fsync either
9 # the new directory or a file inside the new directory, the fsync succeeds,
10 # the fsync log is replayable and produces a correct result.
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         _cleanup_flakey
22         cd /
23         rm -f $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29 . ./common/dmflakey
30
31 # real QA test starts here
32 _supported_fs btrfs
33 _supported_os Linux
34 _require_scratch
35 _require_dm_target flakey
36
37 rm -f $seqres.full
38
39 populate_testdir()
40 {
41         _run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT \
42                 $SCRATCH_MNT/testdir/snap
43         _run_btrfs_util_prog subvolume delete $SCRATCH_MNT/testdir/snap
44         rmdir $SCRATCH_MNT/testdir
45         mkdir $SCRATCH_MNT/testdir
46 }
47
48 _scratch_mkfs >>$seqres.full 2>&1
49 _require_metadata_journaling $SCRATCH_DEV
50 _init_flakey
51 _mount_flakey
52
53 mkdir $SCRATCH_MNT/testdir
54 populate_testdir
55 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/testdir
56 _flakey_drop_and_remount
57
58 echo "Filesystem contents after the first log replay:"
59 ls -R $SCRATCH_MNT | _filter_scratch
60
61 # Now do the same as before but instead of doing an fsync against the directory,
62 # do an fsync against a file inside the directory.
63
64 populate_testdir
65 touch $SCRATCH_MNT/testdir/foobar
66 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/testdir/foobar
67 _flakey_drop_and_remount
68
69 echo "Filesystem contents after the second log replay:"
70 ls -R $SCRATCH_MNT | _filter_scratch
71
72 _unmount_flakey
73 status=0
74 exit