generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / generic / 150
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 150
6 #
7 # Ensure that reflinking a file N times doesn't eat a lot of blocks
8 #   - Create a file and record fs block usage
9 #   - Create some reflink copies
10 #   - Compare fs block usage to before
11 #
12 . ./common/preamble
13 _begin_fstest auto quick clone
14
15 # Override the default cleanup function.
16 _cleanup()
17 {
18     cd /
19     rm -rf $tmp.* $testdir
20 }
21
22 # Import common functions.
23 . ./common/filter
24 . ./common/reflink
25
26 # real QA test starts here
27 _require_test_reflink
28 _require_cp_reflink
29
30 testdir=$TEST_DIR/test-$seq
31 rm -rf $testdir
32 mkdir $testdir
33
34 echo "Create the original file blocks"
35 blksz="$(_get_block_size $testdir)"
36 blks=2000
37 margin='15%'
38 sz=$((blksz * blks))
39 nr=7
40 filesize=$((blksz * nr))
41 _pwrite_byte 0x61 0 $sz $testdir/file1 >> $seqres.full
42 sync
43 free_blocks0=$(stat -f $testdir -c '%f')
44
45 echo "Create the reflink copies"
46 for i in `seq 2 $nr`; do
47         _cp_reflink $testdir/file1 $testdir/file.$i
48 done
49 _test_cycle_mount
50 free_blocks1=$(stat -f $testdir -c '%f')
51
52 _within_tolerance "free blocks after reflink" $free_blocks1 $free_blocks0 $margin -v
53
54 # success, all done
55 status=0
56 exit