07375b1f80de21479324b5ee581f4c8153f3b5af
[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_fs xfs
32 _require_scratch
33 _require_error_injection
34 _require_xfs_io_error_injection "rmap_finish_one"
35
36 rm -f $seqres.full
37
38 blksz=65536
39 blks=64
40 sz=$((blksz * blks))
41 echo "Format filesystem"
42 _scratch_mkfs >/dev/null 2>&1
43 _scratch_mount >> $seqres.full
44
45 # This test depends on specific behaviors of the data device, so create all
46 # files on it.
47 $XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
48
49 echo "Create files"
50 touch $SCRATCH_MNT/file1
51
52 echo "Write files"
53 $XFS_IO_PROG -c "pwrite -S 0x67 0 $sz" $SCRATCH_MNT/file1 >> $seqres.full
54 sync
55
56 echo "Check files"
57 md5sum $SCRATCH_MNT/file1 2>&1 | _filter_scratch
58
59 echo "Inject error"
60 _scratch_inject_error "free_extent"
61
62 echo "Remove files"
63 rm -rf $SCRATCH_MNT/file1
64 sync
65 $XFS_IO_PROG -x -c 'freeze' -c 'thaw' $SCRATCH_MNT >> $seqres.full 2>&1
66
67 echo "FS should be shut down, touch will fail"
68 touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
69
70 echo "Remount to replay log"
71 _scratch_inject_logprint >> $seqres.full
72
73 echo "Check files"
74 md5sum $SCRATCH_MNT/file1 2>&1 | _filter_scratch
75
76 echo "FS should be online, touch should succeed"
77 touch $SCRATCH_MNT/goodfs
78
79 echo "Done"
80
81 # success, all done
82 status=0
83 exit