xfs: skip tests that rely on allocation behaviors of the data device
[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 _require_no_rtinherit
37
38 rm -f $seqres.full
39
40 blksz=65536
41 blks=64
42 sz=$((blksz * blks))
43 echo "Format filesystem"
44 _scratch_mkfs >/dev/null 2>&1
45 _scratch_mount >> $seqres.full
46
47 echo "Create files"
48 touch $SCRATCH_MNT/file1
49
50 echo "Write files"
51 $XFS_IO_PROG -c "pwrite -S 0x67 0 $sz" $SCRATCH_MNT/file1 >> $seqres.full
52 sync
53
54 echo "Check files"
55 md5sum $SCRATCH_MNT/file1 2>&1 | _filter_scratch
56
57 echo "Inject error"
58 _scratch_inject_error "free_extent"
59
60 echo "Remove files"
61 rm -rf $SCRATCH_MNT/file1
62 sync
63 $XFS_IO_PROG -x -c 'freeze' -c 'thaw' $SCRATCH_MNT >> $seqres.full 2>&1
64
65 echo "FS should be shut down, touch will fail"
66 touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
67
68 echo "Remount to replay log"
69 _scratch_inject_logprint >> $seqres.full
70
71 echo "Check files"
72 md5sum $SCRATCH_MNT/file1 2>&1 | _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