2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Oracle, Inc. All Rights Reserved.
7 # Test for races or FS corruption when trying to hit ENOSPC while writing
8 # to a file that's also the source of a reflink operation.
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 7 15
22 rm -rf $tmp.* $finished_file $abort_file
26 # get standard environment, filters and checks
31 # real QA test starts here
32 _require_scratch_reflink
35 echo "Format and mount"
36 _scratch_mkfs_sized $((400 * 1048576)) > $seqres.full 2>&1
37 _scratch_mount >> $seqres.full 2>&1
39 testdir=$SCRATCH_MNT/test-$seq
40 finished_file=/tmp/finished
47 nr_loops=$((loops - 1))
50 echo "Initialize file"
52 _pwrite_byte 0x61 0 $((loops * blksz)) $testdir/file1 >> $seqres.full
58 while [ ! -e $finished_file ]; do
59 out="$(_cp_reflink $testdir/file1 $testdir/snap_$n 2>&1)"
61 echo $out | grep -q "No space left" && break
62 test -n "$out" && echo $out
63 test $res -ne 0 && break
69 echo "Snapshot a file undergoing buffered rewrite"
71 seq 1 1000 | while read j; do
72 seq $nr_loops -1 0 | while read i; do
73 out="$(_pwrite_byte 0x63 $((i * blksz)) $blksz $testdir/file1 2>&1)"
74 echo $out >> $seqres.full
75 echo $out | grep -q "No space left" && touch $abort_file
76 echo $out | grep -qi "error" && touch $abort_file
77 test -e $abort_file && break
79 test -e $abort_file && break