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 _begin_fstest auto quick clone
13 # Override the default cleanup function.
17 rm -rf $tmp.* $testdir1
20 # Import common functions.
26 # real QA test starts here
27 _require_scratch_reflink
30 echo "Format and mount"
31 _scratch_mkfs > $seqres.full 2>&1
32 _scratch_mount >> $seqres.full 2>&1
34 testdir=$SCRATCH_MNT/test-$seq
37 echo "Reformat with appropriate size"
38 blksz="$(_get_block_size $testdir)"
41 file_size=$((768 * 1024 * 1024))
42 fs_size=$((1024 * 1024 * 1024))
43 _scratch_mkfs_sized $fs_size >> $seqres.full 2>&1
44 _scratch_mount >> $seqres.full 2>&1
48 echo "Create a big file and reflink it"
49 _pwrite_byte 0x61 0 $file_size $testdir/bigfile >> $seqres.full 2>&1
50 _cp_reflink $testdir/bigfile $testdir/clonefile
53 echo "Allocate the rest of the space"
54 _fill_fs $fs_size $testdir/space $blksz 0 >> $seqres.full 2>&1
57 echo "CoW the big file"
58 out="$(_pwrite_byte 0x62 0 $file_size $testdir/bigfile 2>&1 | \
59 _filter_xfs_io_error)"
60 echo ${out} | grep -q "No space left on device" || echo "CoW should have failed with ENOSPC"
61 echo ${out} >> $seqres.full 2>&1
64 echo "Remount and try CoW again"
67 out="$(_pwrite_byte 0x62 0 $file_size $testdir/bigfile 2>&1 | \
68 _filter_xfs_io_error)"
69 echo ${out} | grep -q "No space left on device" || echo "CoW should have failed with ENOSPC"
70 echo ${out} >> $seqres.full 2>&1