2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
7 # Test CoW behavior when the write permanently fails.
10 _begin_fstest auto quick clone eio
12 # Override the default cleanup function.
20 # Import common functions.
25 # real QA test starts here
26 _require_scratch_reflink
28 _require_dm_target error
30 echo "Format and mount"
31 _scratch_mkfs > $seqres.full 2>&1
33 _dmerror_mount >> $seqres.full 2>&1
35 testdir=$SCRATCH_MNT/test-$seq
41 filesize=$((blksz * nr))
42 bufsize=$((blksz * bufnr))
44 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
46 echo "Create the original files"
47 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $bufsize 0 $filesize" $testdir/file1 >> $seqres.full
48 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
53 md5sum $testdir/file1 | _filter_scratch
54 md5sum $testdir/file2 | _filter_scratch
56 echo "CoW and unmount"
58 _dmerror_load_error_table
59 urk=$($XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" \
60 -c "fdatasync" $testdir/file2 2>&1)
61 echo $urk >> $seqres.full
62 echo "$urk" | grep -q "error" || _fail "pwrite did not fail"
64 echo "Clean up the mess"
67 _repair_scratch_fs >> $seqres.full
68 _scratch_mount >> $seqres.full 2>&1
71 md5sum $testdir/file1 | _filter_scratch