generic: test for non-zero used blocks while writing into a file
[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 _require_scratch_reflink
32 _require_cp_reflink
33
34 rm -f "$seqres.full"
35
36 echo "Format and mount"
37 _scratch_mkfs > "$seqres.full" 2>&1
38 _scratch_mount >> "$seqres.full" 2>&1
39
40 testdir="$SCRATCH_MNT/test-$seq"
41 mkdir "$testdir"
42
43 echo "Create a one block file"
44 blksz="$(_get_block_size $testdir)"
45 _pwrite_byte 0x61 0 $blksz "$testdir/file1" >> "$seqres.full"
46
47 fnr=19
48 echo "Create extents"
49 truncate -s $(( (2 ** i) * blksz)) "$testdir/file1"
50 for i in $(seq 0 $fnr); do
51         echo " ++ Reflink size $i, $((2 ** i)) blocks" >> "$seqres.full"
52         n=$(( (2 ** i) * blksz))
53         _reflink_range "$testdir/file1" 0 "$testdir/file1" $n $n >> "$seqres.full"
54 done
55 _scratch_cycle_mount
56
57 echo "Reflink the big file"
58 blks=$((2 ** (fnr + 1) ))
59 bytes=$((blks * blksz))
60 echo "reflinking $blks blocks, $bytes bytes" >> "$seqres.full"
61 _reflink_range "$testdir/file1" 0 "$testdir/file2" 0 $bytes >> "$seqres.full"
62
63 # success, all done
64 status=0
65 exit