generic: test deadlock on O_DIRECT|O_DSYNC
[xfstests-dev.git] / tests / generic / 512
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2018 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test No. 512
6 #
7 # Test that if we have a very small file, with a size smaller than the block
8 # size, then fallocate a very small range within the block size but past the
9 # file's current size, fsync the file and then power fail, after mounting the
10 # filesystem all the file data is there and the file size is correct.
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 generic
33 _supported_os Linux
34 _require_scratch
35 _require_xfs_io_command "falloc"
36 _require_dm_target flakey
37
38 rm -f $seqres.full
39
40 _scratch_mkfs >>$seqres.full 2>&1
41 _require_metadata_journaling $SCRATCH_DEV
42 _init_flakey
43 _mount_flakey
44
45 $XFS_IO_PROG -f \
46              -c "pwrite -S 0xb6 0 21" \
47              -c "falloc 40 40" \
48              -c "fsync" \
49              $SCRATCH_MNT/foobar | _filter_xfs_io
50
51 # Simulate a power failure and mount the filesystem. We expect no data loss
52 # and a correct file size.
53 _flakey_drop_and_remount
54
55 echo "File content after power failure:"
56 od -t x1 -A d $SCRATCH_MNT/foobar
57
58 _unmount_flakey
59
60 status=0
61 exit