xfs: Check for extent overflow when trivally adding a new extent
[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 _require_scratch
34 _require_dm_target flakey
35
36 rm -f $seqres.full
37
38 populate_testdir()
39 {
40         _run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT \
41                 $SCRATCH_MNT/testdir/snap
42         _run_btrfs_util_prog subvolume delete $SCRATCH_MNT/testdir/snap
43         rmdir $SCRATCH_MNT/testdir
44         mkdir $SCRATCH_MNT/testdir
45 }
46
47 _scratch_mkfs >>$seqres.full 2>&1
48 _require_metadata_journaling $SCRATCH_DEV
49 _init_flakey
50 _mount_flakey
51
52 mkdir $SCRATCH_MNT/testdir
53 populate_testdir
54 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/testdir
55 _flakey_drop_and_remount
56
57 echo "Filesystem contents after the first log replay:"
58 ls -R $SCRATCH_MNT | _filter_scratch
59
60 # Now do the same as before but instead of doing an fsync against the directory,
61 # do an fsync against a file inside the directory.
62
63 populate_testdir
64 touch $SCRATCH_MNT/testdir/foobar
65 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/testdir/foobar
66 _flakey_drop_and_remount
67
68 echo "Filesystem contents after the second log replay:"
69 ls -R $SCRATCH_MNT | _filter_scratch
70
71 _unmount_flakey
72 status=0
73 exit