2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
7 # Reflink a file that uses more than half of the space, then try to observe
8 # ENOSPC while copy-on-writing the file via the page cache.
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
33 _require_scratch_reflink
38 echo "Format and mount"
39 _scratch_mkfs > $seqres.full 2>&1
40 _scratch_mount >> $seqres.full 2>&1
42 testdir=$SCRATCH_MNT/test-$seq
45 echo "Reformat with appropriate size"
46 blksz="$(_get_block_size $testdir)"
49 file_size=$((768 * 1024 * 1024))
50 fs_size=$((1024 * 1024 * 1024))
51 _scratch_mkfs_sized $fs_size >> $seqres.full 2>&1
52 _scratch_mount >> $seqres.full 2>&1
56 echo "Create a big file and reflink it"
57 _pwrite_byte 0x61 0 $file_size $testdir/bigfile >> $seqres.full 2>&1
58 _cp_reflink $testdir/bigfile $testdir/clonefile
61 echo "Allocate the rest of the space"
62 _fill_fs $fs_size $testdir/space $blksz 0 >> $seqres.full 2>&1
65 echo "CoW the big file"
66 out="$(_pwrite_byte 0x62 0 $file_size $testdir/bigfile 2>&1 | \
67 _filter_xfs_io_error)"
68 echo ${out} | grep -q "No space left on device" || echo "CoW should have failed with ENOSPC"
69 echo ${out} >> $seqres.full 2>&1
72 echo "Remount and try CoW again"
75 out="$(_pwrite_byte 0x62 0 $file_size $testdir/bigfile 2>&1 | \
76 _filter_xfs_io_error)"
77 echo ${out} | grep -q "No space left on device" || echo "CoW should have failed with ENOSPC"
78 echo ${out} >> $seqres.full 2>&1