generic: convert tests to SPDX license tags
[xfstests-dev.git] / tests / generic / 175
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. 175
6 #
7 # See how well reflink handles reflinking the same block a million times.
8 #
9 seq=`basename "$0"`
10 seqres="$RESULT_DIR/$seq"
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1    # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20     cd /
21     rm -rf "$tmp".*
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27 . ./common/attr
28 . ./common/reflink
29
30 # real QA test starts here
31 _supported_os Linux
32 _require_scratch_reflink
33 _require_cp_reflink
34
35 rm -f "$seqres.full"
36
37 echo "Format and mount"
38 _scratch_mkfs > "$seqres.full" 2>&1
39 _scratch_mount >> "$seqres.full" 2>&1
40
41 testdir="$SCRATCH_MNT/test-$seq"
42 mkdir "$testdir"
43
44 echo "Create a one block file"
45 blksz="$(_get_block_size $testdir)"
46 _pwrite_byte 0x61 0 $blksz "$testdir/file1" >> "$seqres.full"
47
48 fnr=19
49 echo "Create extents"
50 truncate -s $(( (2 ** i) * blksz)) "$testdir/file1"
51 for i in $(seq 0 $fnr); do
52         echo " ++ Reflink size $i, $((2 ** i)) blocks" >> "$seqres.full"
53         n=$(( (2 ** i) * blksz))
54         _reflink_range "$testdir/file1" 0 "$testdir/file1" $n $n >> "$seqres.full"
55 done
56 _scratch_cycle_mount
57
58 echo "Reflink the big file"
59 blks=$((2 ** (fnr + 1) ))
60 bytes=$((blks * blksz))
61 echo "reflinking $blks blocks, $bytes bytes" >> "$seqres.full"
62 _reflink_range "$testdir/file1" 0 "$testdir/file2" 0 $bytes >> "$seqres.full"
63
64 # success, all done
65 status=0
66 exit