generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / xfs / 006
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test 006
6 #
7 # Test xfs' "fail at unmount" error handling configuration. Stop
8 # XFS from retrying to writeback forever at unmount.
9 #
10 . ./common/preamble
11 _begin_fstest auto quick mount eio
12
13 # Override the default cleanup function.
14 _cleanup()
15 {
16         cd /
17         rm -f $tmp.*
18         _dmerror_cleanup
19 }
20
21 # Import common functions.
22 . ./common/filter
23 . ./common/dmerror
24
25 # real QA test starts here
26 _supported_fs xfs
27 _require_scratch
28 _require_dm_target error
29 _require_fs_sysfs error/fail_at_unmount
30
31 _scratch_mkfs > $seqres.full 2>&1
32 _dmerror_init
33 _dmerror_mount
34
35 # Make sure all error handling attributes are original status
36 _reset_xfs_sysfs_error_handling $DMERROR_DEV
37
38 # Make sure fail_at_unmount is enabled, so XFS stops retrying on
39 # errors at unmount time. _fail the test if we fail to set it to 1,
40 # because the test probably will hang in such case and block
41 # subsequent tests.
42 attr=`_get_fs_sysfs_attr $DMERROR_DEV error/fail_at_unmount`
43 if [ "$attr" != "1" ]; then
44         _fail "Failed to set error/fail_at_unmount: $attr"
45 fi
46
47 # start a metadata-intensive workload, but no data allocation operation.
48 # Because uncompleted new space allocation I/Os may cause XFS to shutdown
49 # after loading error table.
50 $FSSTRESS_PROG -z -n 5000 -p 10 \
51                -f creat=10 \
52                -f resvsp=1 \
53                -f truncate=1 \
54                -f punch=1 \
55                -f chown=5 \
56                -f mkdir=5 \
57                -f rmdir=1 \
58                -f mknod=1 \
59                -f unlink=1 \
60                -f symlink=1 \
61                -f rename=1 \
62                -d $SCRATCH_MNT/fsstress >> $seqres.full 2>&1
63
64 # Loading error table without "--nolockfs" option. Because "--nolockfs"
65 # won't freeze fs, then some running I/Os may cause XFS to shutdown
66 # prematurely. That's not what we want to test.
67 _dmerror_load_error_table lockfs
68 _dmerror_unmount
69
70 # Mount again to replay log after loading working table, so we have a
71 # consistent XFS after test.
72 _dmerror_load_working_table
73 _dmerror_mount
74 _dmerror_unmount
75
76 # success, all done
77 status=0
78 exit