generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / xfs / 169
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. 169
6 #
7 # Ensure that we can create enough distinct reflink entries to force creation
8 # of a multi-level refcount btree.  Delete and recreate a few times to
9 # exercise the refcount btree grow/shrink functions.
10 #
11 . ./common/preamble
12 _begin_fstest auto clone
13
14 # Override the default cleanup function.
15 _cleanup()
16 {
17     cd /
18     umount $SCRATCH_MNT > /dev/null 2>&1
19     rm -rf $tmp.*
20 }
21
22 # Import common functions.
23 . ./common/filter
24 . ./common/reflink
25
26 # real QA test starts here
27 _supported_fs xfs
28 _require_scratch_reflink
29
30 _scratch_mkfs >/dev/null 2>&1
31 _scratch_mount
32
33 testdir=$SCRATCH_MNT/test-$seq
34 mkdir $testdir
35
36 echo "Create the original file blocks"
37 blksz="$(_get_file_block_size $testdir)"
38 nr_blks=$((8 * blksz / 12))
39
40 for i in 1 2 x; do
41         _pwrite_byte 0x61 0 $((blksz * nr_blks)) $testdir/file1 >> $seqres.full
42
43         echo "$i: Reflink every other block"
44         seq 1 2 $((nr_blks - 1)) | while read nr; do
45                 _reflink_range  $testdir/file1 $((nr * blksz)) \
46                                 $testdir/file2 $((nr * blksz)) $blksz >> $seqres.full
47         done
48         umount $SCRATCH_MNT
49         _check_scratch_fs
50         _scratch_mount
51
52         test $i = "x" && break
53
54         echo "$i: Delete both files"
55         rm -rf $testdir/file1 $testdir/file2
56         umount $SCRATCH_MNT
57         _check_scratch_fs
58         _scratch_mount
59 done
60
61 # success, all done
62 status=0
63 exit