generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / xfs / 234
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. 234
6 #
7 # Ensure that we can create enough distinct rmap entries to force creation
8 # of a multi-level rmap btree, and that metadump will successfully copy
9 # said block.
10 #
11 . ./common/preamble
12 _begin_fstest auto quick rmap punch
13
14 # Override the default cleanup function.
15 _cleanup()
16 {
17     cd /
18     _scratch_unmount > /dev/null 2>&1
19     rm -rf $tmp.* $metadump_file $TEST_DIR/image
20 }
21
22 # Import common functions.
23 . ./common/filter
24
25 # real QA test starts here
26 _supported_fs xfs
27 _require_loop
28 _require_xfs_scratch_rmapbt
29 _require_xfs_io_command "fpunch"
30
31 _scratch_mkfs >/dev/null 2>&1
32 _scratch_mount
33
34 testdir=$SCRATCH_MNT/test-$seq
35 mkdir $testdir
36 metadump_file=$TEST_DIR/${seq}_metadump
37
38 echo "Create the original file blocks"
39 blksz="$(_get_block_size $testdir)"
40 nr_blks=$((4 * blksz / 12))
41 _pwrite_byte 0x61 0 $((blksz * nr_blks)) $testdir/file1 >> $seqres.full
42 sync
43
44 echo "Punch every other block"
45 seq 1 2 $((nr_blks - 1)) | while read nr; do
46         $XFS_IO_PROG -c "fpunch $((nr * blksz)) $blksz" $testdir/file1 >> $seqres.full
47 done
48
49 echo "Create metadump file"
50 _scratch_unmount
51 _scratch_xfs_metadump $metadump_file
52
53 # Now restore the obfuscated one back and take a look around
54 echo "Restore metadump"
55 xfs_mdrestore $metadump_file $TEST_DIR/image
56 SCRATCH_DEV=$TEST_DIR/image _scratch_mount
57 SCRATCH_DEV=$TEST_DIR/image _scratch_unmount
58
59 echo "Check restored fs"
60 _check_generic_filesystem $metadump_file
61
62 # success, all done
63 status=0
64 exit