2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
7 # Reflink a file, use up the rest of the space, then try to observe ENOSPC
8 # while copy-on-writing the file via direct-io.
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.* $testdir1
25 # get standard environment, filters and checks
32 # real QA test starts here
34 _require_scratch_reflink
40 echo "Format and mount"
41 _scratch_mkfs > $seqres.full 2>&1
42 _scratch_mount >> $seqres.full 2>&1
44 testdir=$SCRATCH_MNT/test-$seq
47 echo "Reformat with appropriate size"
48 blksz="$(_get_block_size $testdir)"
51 sz_bytes=$((nr_blks * 8 * blksz))
52 if [ $sz_bytes -lt $((32 * 1048576)) ]; then
53 sz_bytes=$((32 * 1048576))
55 _scratch_mkfs_sized $sz_bytes >> $seqres.full 2>&1
56 _scratch_mount >> $seqres.full 2>&1
60 echo "Create a big file and reflink it"
61 _pwrite_byte 0x61 0 $((blksz * nr_blks)) $testdir/bigfile >> $seqres.full 2>&1
62 _cp_reflink $testdir/bigfile $testdir/clonefile
65 echo "Allocate the rest of the space"
66 nr_free=$(stat -f -c '%f' $testdir)
67 _fill_fs $((blksz * nr_free)) $testdir/space $blksz 0 >> $seqres.full 2>&1
70 echo "CoW the big file"
71 out="$(_pwrite_byte 0x62 0 $((blksz * nr_blks)) $testdir/bigfile -d 2>&1 | \
72 _filter_xfs_io_error)"
73 echo ${out} | grep -q "No space left on device" || echo "CoW should have failed with ENOSPC"
74 echo ${out} >> $seqres.full 2>&1
77 echo "Remount and try CoW again"
80 out="$(_pwrite_byte 0x62 0 $((blksz * nr_blks)) $testdir/bigfile -d 2>&1 | \
81 _filter_xfs_io_error)"
82 echo ${out} | grep -q "No space left on device" || echo "CoW should have failed with ENOSPC"
83 echo ${out} >> $seqres.full 2>&1