2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017, Oracle and/or its affiliates. All Rights Reserved.
7 # See how well we handle deleting a file with a million refcount extents.
10 seqres="$RESULT_DIR/$seq"
11 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
21 rm -f "$tmp".* $testdir/file1
24 # get standard environment, filters and checks
30 # real QA test starts here
32 _require_scratch_reflink
34 _require_test_program "punch-alternating"
35 _require_xfs_io_command "fpunch"
39 echo "Format and mount"
40 _scratch_mkfs > "$seqres.full" 2>&1
41 _scratch_mount >> "$seqres.full" 2>&1
43 testdir="$SCRATCH_MNT/test-$seq"
46 # Setup for one million blocks, but we'll accept stress testing down to
47 # 2^17 blocks... that should be plenty for anyone.
49 free_blocks=$(stat -f -c '%a' "$testdir")
50 blksz=$(_get_block_size "$testdir")
51 space_avail=$((free_blocks * blksz))
53 blocks_needed=$(( 2 ** (fnr + 1) ))
54 space_needed=$((blocks_needed * blksz * 5 / 4))
57 while test $space_needed -gt $space_avail; do
61 test $fnr -lt 17 && _notrun "Insufficient space for stress test; would only create $blocks_needed extents ($space_needed/$space_avail blocks)."
63 echo "Create a many-block file"
64 echo "creating $blocks_needed blocks..." >> "$seqres.full"
65 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b 4194304 0 $((2 ** (fnr + 1) * blksz))" "$testdir/file1" >> "$seqres.full"
67 echo "Reflinking file"
68 _cp_reflink $testdir/file1 $testdir/file2
71 echo "Punching file2..." >> "$seqres.full"
72 "$here/src/punch-alternating" "$testdir/file2" >> "$seqres.full"
73 echo "...done" >> "$seqres.full"