xfs: force file creation to the data device for certain layout tests
[xfstests-dev.git] / tests / xfs / 317
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. 317
6 #
7 # Simulate rmap update 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_xfs_scratch_rmapbt
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 _pwrite_byte 0x67 0 $sz $SCRATCH_MNT/file0 >> $seqres.full
49 sync
50
51 echo "Check files"
52 md5sum $SCRATCH_MNT/file0 | _filter_scratch
53 md5sum $SCRATCH_MNT/file1 | _filter_scratch
54
55 echo "Inject error"
56 _scratch_inject_error "rmap_finish_one"
57
58 echo "Write files"
59 $XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz 0 $sz" $SCRATCH_MNT/file1 >> $seqres.full 2>&1
60
61 echo "FS should be shut down, touch will fail"
62 touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
63
64 echo "Remount to replay log"
65 _scratch_inject_logprint >> $seqres.full
66
67 echo "Check files"
68 md5sum $SCRATCH_MNT/file0 | _filter_scratch
69 md5sum $SCRATCH_MNT/file1 | _filter_scratch
70
71 echo "FS should be online, touch should succeed"
72 touch $SCRATCH_MNT/goodfs
73
74 echo "Done"
75
76 # success, all done
77 status=0
78 exit