generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / generic / 358
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Oracle, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 358
6 #
7 # Share an extent amongst a bunch of files such that the refcount
8 # stays the same while the rate of change of the set of owners is
9 # steadily increasing.  For example, an extent of 32 blocks is owned
10 # by 32 files.  At block 1, change one of the owners.  At block 2,
11 # change 2 of the owners, and so on.
12 #
13 . ./common/preamble
14 _begin_fstest auto quick clone
15
16 _register_cleanup "_cleanup" BUS
17
18 # Override the default cleanup function.
19 _cleanup()
20 {
21         cd /
22         rm -rf $tmp.*
23         wait
24 }
25
26 # Import common functions.
27 . ./common/filter
28 . ./common/reflink
29
30 # real QA test starts here
31 _require_scratch_reflink
32
33 echo "Format and mount"
34 _scratch_mkfs > $seqres.full 2>&1
35 _scratch_mount >> $seqres.full 2>&1
36
37 testdir=$SCRATCH_MNT/test-$seq
38 mkdir $testdir
39
40 blocks=64
41 blksz=65536
42
43 echo "Initialize file"
44 _pwrite_byte 0x61 0 $((blocks * blksz)) $testdir/file >> $seqres.full
45
46 echo "Share the file n-ways"
47 seq 1 $((blocks - 1)) | while read nr; do
48         _reflink_range $testdir/file 0 $testdir/file$nr.0 0 $((nr * blksz)) >> $seqres.full
49         seq $nr $((blocks - 1)) | while read nnr; do
50                 _reflink_range $testdir/file $((nnr * blksz)) $testdir/file$nr.$nnr $((nnr * blksz)) $blksz >> $seqres.full
51         done
52 done
53 _scratch_cycle_mount
54
55 echo "Check output"
56 md5sum $testdir/file $testdir/file*.0 | _filter_scratch
57
58 # success, all done
59 status=0
60 exit