generic: test MADV_POPULATE_READ with IO errors
[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 . ./common/preamble
10 _begin_fstest auto quick rw
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_error_injection
28 _require_xfs_io_error_injection "rmap_finish_one"
29
30 blksz=65536
31 blks=64
32 sz=$((blksz * blks))
33 echo "Format filesystem"
34 _scratch_mkfs >/dev/null 2>&1
35 _scratch_mount >> $seqres.full
36
37 # This test depends on specific behaviors of the data device, so create all
38 # files on it.
39 _xfs_force_bdev data $SCRATCH_MNT
40
41 echo "Create files"
42 touch $SCRATCH_MNT/file1
43
44 echo "Write files"
45 $XFS_IO_PROG -c "pwrite -S 0x67 0 $sz" $SCRATCH_MNT/file1 >> $seqres.full
46 sync
47
48 echo "Check files"
49 md5sum $SCRATCH_MNT/file1 2>&1 | _filter_scratch
50
51 echo "Inject error"
52 _scratch_inject_error "free_extent"
53
54 echo "Remove files"
55 rm -rf $SCRATCH_MNT/file1
56 sync
57 $XFS_IO_PROG -x -c 'freeze' -c 'thaw' $SCRATCH_MNT >> $seqres.full 2>&1
58
59 echo "FS should be shut down, touch will fail"
60 touch $SCRATCH_MNT/badfs 2>&1 | _filter_scratch
61
62 echo "Remount to replay log"
63 _scratch_remount_dump_log >> $seqres.full
64
65 echo "Check files"
66 md5sum $SCRATCH_MNT/file1 2>&1 | _filter_scratch
67
68 echo "FS should be online, touch should succeed"
69 touch $SCRATCH_MNT/goodfs
70
71 echo "Done"
72
73 # success, all done
74 status=0
75 exit