generic/402: Drop useless fail message
[xfstests-dev.git] / tests / generic / 298
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 298
6 #
7 # See how well reflink handles SIGKILL in the middle of a slow reflink.
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1    # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20     cd /
21     rm -rf $tmp.* $TEST_DIR/before $TEST_DIR/after
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27 . ./common/attr
28 . ./common/reflink
29
30 # real QA test starts here
31 _require_scratch_reflink
32 _require_cp_reflink
33 _require_command "$TIMEOUT_PROG" "timeout"
34
35 test $FSTYP == "nfs"  && _notrun "NFS can't interrupt clone operations"
36
37 rm -f $seqres.full
38
39 echo "Format and mount"
40 _scratch_mkfs > $seqres.full 2>&1
41 _scratch_mount >> $seqres.full 2>&1
42
43 testdir=$SCRATCH_MNT/test-$seq
44 mkdir $testdir
45
46 echo "Create a one block file"
47 blksz="$(_get_block_size $testdir)"
48 _pwrite_byte 0x61 0 $blksz $testdir/file1 >> $seqres.full
49
50 fnr=26          # 2^26 reflink extents should be enough to find a slow op?
51 timeout=8       # guarantee a good long run...
52 echo "Find a reflink size that takes a long time"
53 truncate -s $(( (2 ** i) * blksz)) $testdir/file1
54 for i in $(seq 0 $fnr); do
55         echo " ++ Reflink size $i, $((2 ** i)) blocks" >> $seqres.full
56         n=$(( (2 ** i) * blksz))
57         touch $TEST_DIR/before
58         $XFS_IO_PROG -f -c "reflink $testdir/file1 0 $n $n" $testdir/file1 >> $seqres.full 2>&1
59         touch $TEST_DIR/after
60         before=$(stat -c '%Y' $TEST_DIR/before)
61         after=$(stat -c '%Y' $TEST_DIR/after)
62         delta=$((after - before))
63         test $delta -gt $timeout && break
64 done
65
66 echo "Try to kill reflink after a shorter period of time"
67 kill_after=2    # give us a shorter time to die
68 n=$(_get_filesize $testdir/file1)
69 echo "performing kill test on $n bytes..." >> $seqres.full
70 touch $TEST_DIR/before
71 urk=$($TIMEOUT_PROG -s KILL ${kill_after}s $XFS_IO_PROG -f -c "reflink $testdir/file1 0 $n $n" $testdir/file1 >> $seqres.full 2>&1)
72 touch $TEST_DIR/after
73 before=$(stat -c '%Y' $TEST_DIR/before)
74 after=$(stat -c '%Y' $TEST_DIR/after)
75 delta=$((after - before))
76 echo "reflink of $n bytes took $delta seconds" >> $seqres.full
77 test $delta -gt $timeout && _fail "reflink didn't stop in time, n=$n t=$delta"
78
79 echo "Check scratch fs"
80 sleep 2         # give it a few seconds to actually die...
81
82 # success, all done
83 status=0
84 exit