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 _begin_fstest auto clone
13 # Override the default cleanup function.
17 rm -rf $tmp.* $testdir
20 # Import common functions.
24 # real QA test starts here
25 # Below agsize is too small for a large fs, and it's not necessary to test on
27 _require_no_large_scratch_dev
28 _require_scratch_reflink
31 _scratch_mkfs >/dev/null 2>&1
33 blksz=$(_get_file_block_size $SCRATCH_MNT)
36 agsize=$((8192 * $blksz))
37 if [[ $agsize -lt $((16 * 1024 * 1024)) ]]; then
38 agsize=$((16 * 1024 * 1024))
40 sz=$((4096 * $blksz + $agsize))
43 echo "Format and mount"
44 _scratch_mkfs -d agsize=$agsize > $seqres.full 2>&1
45 _scratch_mount >> $seqres.full 2>&1
47 testdir=$SCRATCH_MNT/test-$seq
50 echo "Create the original files"
51 _pwrite_byte 0x61 0 $sz $testdir/file1 >> $seqres.full
52 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
53 _pwrite_byte 0x61 0 $sz $testdir/file2.chk >> $seqres.full
57 cmp -s $testdir/file1 $testdir/file2 || echo "file1 and file2 do not match"
58 cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk do not match"
60 echo "CoW every other block"
61 seq 1 2 $((nr - 1)) | while read f; do
62 _pwrite_byte 0x62 $((f * blksz)) $blksz $testdir/file2 >> $seqres.full
63 _pwrite_byte 0x62 $((f * blksz)) $blksz $testdir/file2.chk >> $seqres.full
68 ! cmp -s $testdir/file1 $testdir/file2 || echo "file1 and file2 must not match"
69 cmp -s $testdir/file2 $testdir/file2.chk || echo "file2 and file2.chk do not match"