xfs: convert tests to SPDX license tags
[xfstests-dev.git] / tests / xfs / 318
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. 318
6 #
7 # Simulate free extent errors with a file write and a file remove.
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         _scratch_unmount > /dev/null 2>&1
22         rm -rf $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28 . ./common/inject
29
30 # real QA test starts here
31 _supported_os Linux
32 _supported_fs xfs
33 _require_scratch
34 _require_error_injection
35 _require_xfs_io_error_injection "rmap_finish_one"
36
37 rm -f $seqres.full
38
39 blksz=65536
40 blks=64
41 sz=$((blksz * blks))
42 echo "Format filesystem"
43 _scratch_mkfs >/dev/null 2>&1
44 _scratch_mount >> $seqres.full
45
46 echo "Create files"
47 touch $SCRATCH_MNT/file1
48
49 echo "Write files"
50 $XFS_IO_PROG -c "pwrite -S 0x67 0 $sz" $SCRATCH_MNT/file1 >> $seqres.full
51 sync
52
53 echo "Check files"
54 md5sum $SCRATCH_MNT/file1 2>&1 | _filter_scratch
55
56 echo "Inject error"
57 _scratch_inject_error "free_extent"
58
59 echo "Remove files"
60 rm -rf $SCRATCH_MNT/file1
61 sync
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 2>&1 | _filter_scratch
71
72 echo "FS should be online, touch should succeed"
73 touch $SCRATCH_MNT/goodfs
74
75 echo "Done"
76
77 # success, all done
78 status=0
79 exit