generic: test MADV_POPULATE_READ with IO errors
[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 . ./common/preamble
10 _begin_fstest auto quick rmap
11
12 # Override the default cleanup function.
13 _cleanup()
14 {
15         cd /
16         _scratch_unmount > /dev/null 2>&1
17         rm -rf $tmp.*
18 }
19
20 # Import common functions.
21 . ./common/filter
22 . ./common/inject
23
24 # real QA test starts here
25 _supported_fs xfs
26 _require_scratch
27 _require_xfs_scratch_rmapbt
28 _require_error_injection
29 _require_xfs_io_error_injection "rmap_finish_one"
30
31 blksz=65536
32 blks=64
33 sz=$((blksz * blks))
34 echo "Format filesystem"
35 _scratch_mkfs >/dev/null 2>&1
36 _scratch_mount >> $seqres.full
37
38 echo "Create files"
39 touch $SCRATCH_MNT/file1
40 _pwrite_byte 0x67 0 $sz $SCRATCH_MNT/file0 >> $seqres.full
41 sync
42
43 echo "Check files"
44 md5sum $SCRATCH_MNT/file0 | _filter_scratch
45 md5sum $SCRATCH_MNT/file1 | _filter_scratch
46
47 echo "Inject error"
48 _scratch_inject_error "rmap_finish_one"
49
50 echo "Write files"
51 $XFS_IO_PROG -c "pwrite -W -S 0x67 -b $sz 0 $sz" $SCRATCH_MNT/file1 >> $seqres.full 2>&1
52
53 echo "FS should be shut down, touch will fail"
54 touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
55
56 echo "Remount to replay log"
57 _scratch_remount_dump_log >> $seqres.full
58
59 echo "Check files"
60 md5sum $SCRATCH_MNT/file0 | _filter_scratch
61 md5sum $SCRATCH_MNT/file1 | _filter_scratch
62
63 echo "FS should be online, touch should succeed"
64 touch $SCRATCH_MNT/goodfs
65
66 echo "Done"
67
68 # success, all done
69 status=0
70 exit