generic: Add check for required keep_size/punch_hole/zero_range/collapse_range
[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 seq=`basename $0`
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
16
17 here=`pwd`
18 tmp=/tmp/$$
19 status=1        # failure is the default!
20
21 _cleanup()
22 {
23         _cleanup_flakey
24         cd /
25         rm -f $tmp.*
26 }
27 trap "_cleanup; exit \$status" 0 1 2 3 15
28
29 # get standard environment, filters and checks
30 . ./common/rc
31 . ./common/filter
32 . ./common/dmflakey
33
34 # real QA test starts here
35 _supported_fs generic
36 _supported_os Linux
37 _require_scratch
38 _require_dm_target flakey
39 _require_xfs_io_command "falloc" "-k"
40 _require_xfs_io_command "fzero"
41 _require_xfs_io_command "fcollapse"
42
43 rm -f $seqres.full
44
45 _scratch_mkfs >> $seqres.full 2>&1
46 _require_metadata_journaling $SCRATCH_DEV
47
48 _init_flakey
49 _mount_flakey
50
51 # See this post for reverse engineering of this auto generated test:
52 # https://marc.info/?l=linux-ext4&m=151137380830381&w=2
53 fsxops=$tmp.fsxops
54 cat <<EOF > $fsxops
55 write 0x137dd 0xdc69 0x0
56 fallocate 0xb531 0xb5ad 0x21446
57 collapse_range 0x1c000 0x4000 0x21446
58 write 0x3e5ec 0x1a14 0x21446
59 zero_range 0x20fac 0x6d9c 0x40000 keep_size
60 mapwrite 0x216ad 0x274f 0x40000
61 EOF
62 run_check $here/ltp/fsx -d --replay-ops $fsxops $SCRATCH_MNT/testfile
63
64 _flakey_drop_and_remount
65 _unmount_flakey
66 _cleanup_flakey
67 _check_scratch_fs
68
69 echo "Silence is golden"
70
71 status=0
72 exit