xfs/029: filter out "extended-header: cycle: 1" from output
[xfstests-dev.git] / tests / xfs / 320
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. 320
6 #
7 # Reflink a file.
8 # Inject an error during block remap to test log recovery.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1    # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         _scratch_unmount > /dev/null 2>&1
23         rm -rf $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29 . ./common/reflink
30 . ./common/inject
31
32 # real QA test starts here
33 _supported_os Linux
34 _supported_fs xfs
35 _require_cp_reflink
36 _require_scratch_reflink
37 _require_xfs_io_error_injection "bmap_finish_one"
38
39 rm -f $seqres.full
40
41 blksz=65536
42 blks=64
43 sz=$((blksz * blks - 17))
44 echo "Format filesystem"
45 _scratch_mkfs >/dev/null 2>&1
46 _scratch_mount >> $seqres.full
47
48 echo "Create files"
49 _pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
50 _cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2
51 sync
52
53 echo "Check files"
54 md5sum $SCRATCH_MNT/file1 | _filter_scratch
55 md5sum $SCRATCH_MNT/file2 | _filter_scratch
56
57 echo "Inject error"
58 _scratch_inject_error "bmap_finish_one"
59
60 echo "Try to reflink"
61 _cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file3 2>&1 | _filter_scratch
62
63 echo "FS should be shut down, touch will fail"
64 touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
65
66 echo "Remount to replay log"
67 _scratch_inject_logprint >> $seqres.full
68
69 echo "Check files"
70 md5sum $SCRATCH_MNT/file1 | _filter_scratch
71 md5sum $SCRATCH_MNT/file2 | _filter_scratch
72 md5sum $SCRATCH_MNT/file3 | _filter_scratch
73
74 echo "FS should be online, touch should succeed"
75 touch $SCRATCH_MNT/goodfs
76
77 echo "Done"
78
79 # success, all done
80 status=0
81 exit