generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / xfs / 331
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 331
6 #
7 # Create a big enough rmapbt that we tickle a fdblocks accounting bug.
8 #
9 . ./common/preamble
10 _begin_fstest auto quick rmap clone prealloc
11
12 # Import common functions.
13 . ./common/filter
14 . ./common/reflink
15
16 # real QA test starts here
17 _supported_fs xfs
18 _require_scratch
19 _require_xfs_scratch_rmapbt
20 _require_scratch_reflink
21 _require_xfs_io_command "falloc"
22 _require_test_program "punch-alternating"
23 _require_xfs_io_command "falloc"
24
25 rm -f "$seqres.full"
26
27 echo "+ create scratch fs"
28 _scratch_mkfs > "$seqres.full" 2>&1
29
30 echo "+ mount fs image"
31 _scratch_mount
32 blksz="$(_get_block_size $SCRATCH_MNT)"
33
34 # btree header is 56 bytes; an rmapbt record is 24 bytes; and
35 # a rmapbt key/pointer pair is 44 bytes.
36 bt_ptrs=$(( (blksz - 56) / 44 ))
37 bt_recs=$(( (blksz - 56) / 24 ))
38
39 blocks=$((bt_ptrs * bt_recs + 1))
40 # Need (2 * blocks * blksz) bytes for files, and 20% for metadata
41 _require_fs_space $SCRATCH_MNT $(( (2 * blocks * blksz) * 5 / 4096 ))
42 len=$((blocks * blksz))
43
44 echo "+ make some files"
45 $XFS_IO_PROG -f -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f1 >> $seqres.full
46 $XFS_IO_PROG -f -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f2 >> $seqres.full
47 $here/src/punch-alternating $SCRATCH_MNT/f1 >> "$seqres.full"
48 $here/src/punch-alternating $SCRATCH_MNT/f2 >> "$seqres.full"
49
50 # success, all done
51 status=0
52 exit