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 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
26 # get standard environment, filters and checks
32 # real QA test starts here
33 _require_scratch_reflink
35 _require_dm_target error
40 echo "Format and mount"
41 _scratch_mkfs > $seqres.full 2>&1
43 _dmerror_mount >> $seqres.full 2>&1
45 testdir=$SCRATCH_MNT/test-$seq
51 filesize=$((blksz * nr))
52 bufsize=$((blksz * bufnr))
54 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
56 echo "Create the original files"
57 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $bufsize 0 $filesize" $testdir/file1 >> $seqres.full
58 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
63 md5sum $testdir/file1 | _filter_scratch
64 md5sum $testdir/file2 | _filter_scratch
66 echo "CoW and unmount"
68 _dmerror_load_error_table
69 urk=$($XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" \
70 -c "fdatasync" $testdir/file2 2>&1)
71 echo $urk >> $seqres.full
72 echo "$urk" | grep -q "error" || _fail "pwrite did not fail"
73 _dmerror_load_working_table
76 $XFS_IO_PROG -f -c "pwrite -S 0x64 -b $bufsize 0 $filesize" -c "fdatasync" $testdir/file2 >> $seqres.full 2>&1
81 md5sum $testdir/file1 | _filter_scratch
83 echo "Check for damage"
86 _repair_scratch_fs >> $seqres.full