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 temporarily fails but the userspace
8 # program writes again.
11 _begin_fstest auto quick clone eio
13 # Override the default cleanup function.
21 # Import common functions.
26 # real QA test starts here
27 _require_scratch_reflink
29 _require_dm_target error
31 echo "Format and mount"
32 _scratch_mkfs > $seqres.full 2>&1
34 _dmerror_mount >> $seqres.full 2>&1
36 testdir=$SCRATCH_MNT/test-$seq
42 filesize=$((blksz * nr))
43 bufsize=$((blksz * bufnr))
45 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
47 echo "Create the original files"
48 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $bufsize 0 $filesize" $testdir/file1 >> $seqres.full
49 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
54 md5sum $testdir/file1 | _filter_scratch
55 md5sum $testdir/file2 | _filter_scratch
57 echo "CoW and unmount"
59 _dmerror_load_error_table
60 urk=$($XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" \
61 -c "fdatasync" $testdir/file2 2>&1)
62 echo $urk >> $seqres.full
63 echo "$urk" | grep -q "error" || _fail "pwrite did not fail"
64 _dmerror_load_working_table
67 $XFS_IO_PROG -f -c "pwrite -S 0x64 -b $bufsize 0 $filesize" -c "fdatasync" $testdir/file2 >> $seqres.full 2>&1
72 md5sum $testdir/file1 | _filter_scratch
74 echo "Check for damage"
77 _repair_scratch_fs >> $seqres.full