generic: test for file loss after mix of rename, fsync and inode eviction
[xfstests-dev.git] / tests / generic / 456
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2017 CTERA Networks. All Rights Reserved.
4 #
5 # FS QA Test No. 456
6 #
7 # This test is motivated by a bug found in ext4 during random crash
8 # consistency tests.
9 #
10 # Fixed by commit 51e3ae81ec58 ("ext4: fix interaction between i_size,
11 # fallocate, and delalloc after a crash")
12 #
13 # This is also a regression test for ext4 bug that zero range can beyond
14 # i_disksize and fixed by commit 801674f34ecf ("ext4: do not zeroout extents
15 # beyond i_disksize").
16 #
17 . ./common/preamble
18 _begin_fstest auto quick metadata collapse zero prealloc
19
20 # Override the default cleanup function.
21 _cleanup()
22 {
23         _cleanup_flakey
24         cd /
25         rm -f $tmp.*
26 }
27
28 # Import common functions.
29 . ./common/filter
30 . ./common/dmflakey
31
32 # real QA test starts here
33 _supported_fs generic
34 _require_scratch
35 _require_xfs_io_command "falloc"
36 _require_dm_target flakey
37 _require_xfs_io_command "falloc" "-k"
38 _require_xfs_io_command "fzero"
39 _require_xfs_io_command "fcollapse"
40
41 _scratch_mkfs >> $seqres.full 2>&1
42 _require_metadata_journaling $SCRATCH_DEV
43
44 _init_flakey
45 _mount_flakey
46
47 # See this post for reverse engineering of this auto generated test:
48 # https://marc.info/?l=linux-ext4&m=151137380830381&w=2
49 fsxops=$tmp.fsxops
50 cat <<EOF > $fsxops
51 write 0x137dd 0xdc69 0x0
52 fallocate 0xb531 0xb5ad 0x21446
53 collapse_range 0x1c000 0x4000 0x21446
54 write 0x3e5ec 0x1a14 0x21446
55 zero_range 0x20fac 0x6d9c 0x40000 keep_size
56 mapwrite 0x216ad 0x274f 0x40000
57 EOF
58 run_check $here/ltp/fsx -d --replay-ops $fsxops $SCRATCH_MNT/testfile
59
60 _flakey_drop_and_remount
61 _unmount_flakey
62 _cleanup_flakey
63 _check_scratch_fs
64
65 echo "Silence is golden"
66
67 status=0
68 exit