2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
7 # Try to ENOSPC while expanding the refcntbt by CoWing every other block
8 # of a file that eats the whole AG.
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
16 status=1 # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
22 rm -rf $tmp.* $testdir
25 # get standard environment, filters and checks
30 # real QA test starts here
31 # Below agsize is too small for a large fs, and it's not necessary to test on
33 _require_no_large_scratch_dev
34 _require_scratch_reflink
39 _scratch_mkfs >/dev/null 2>&1
41 blksz=$(_get_file_block_size $SCRATCH_MNT)
44 agsize=$((8192 * $blksz))
45 if [[ $agsize -lt $((16 * 1024 * 1024)) ]]; then
46 agsize=$((16 * 1024 * 1024))
48 sz=$((4096 * $blksz + $agsize))
51 echo "Format and mount"
52 _scratch_mkfs -d agsize=$agsize > $seqres.full 2>&1
53 _scratch_mount >> $seqres.full 2>&1
55 testdir=$SCRATCH_MNT/test-$seq
58 echo "Create the original files"
59 _pwrite_byte 0x61 0 $sz $testdir/file1 >> $seqres.full
60 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
61 _pwrite_byte 0x61 0 $sz $testdir/file2.chk >> $seqres.full
65 cmp -s $testdir/file1 $testdir/file2 || echo "file1 and file2 do not match"
66 cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk do not match"
68 echo "CoW every other block"
69 seq 1 2 $((nr - 1)) | while read f; do
70 _pwrite_byte 0x62 $((f * blksz)) $blksz $testdir/file2 >> $seqres.full
71 _pwrite_byte 0x62 $((f * blksz)) $blksz $testdir/file2.chk >> $seqres.full
76 ! cmp -s $testdir/file1 $testdir/file2 || echo "file1 and file2 must not match"
77 cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk do not match"