common/rc: add _scratch_{u}mount_idmapped() helpers
[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 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         rm -f $tmp.*
23         _dmerror_cleanup
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29 . ./common/dmerror
30
31 # remove previous $seqres.full before test
32 rm -f $seqres.full
33
34 # real QA test starts here
35 _supported_fs xfs
36 _require_scratch
37 _require_dm_target error
38 _require_fs_sysfs error/fail_at_unmount
39
40 _scratch_mkfs > $seqres.full 2>&1
41 _dmerror_init
42 _dmerror_mount
43
44 # Make sure all error handling attributes are original status
45 _reset_xfs_sysfs_error_handling $DMERROR_DEV
46
47 # Make sure fail_at_unmount is enabled, so XFS stops retrying on
48 # errors at unmount time. _fail the test if we fail to set it to 1,
49 # because the test probably will hang in such case and block
50 # subsequent tests.
51 attr=`_get_fs_sysfs_attr $DMERROR_DEV error/fail_at_unmount`
52 if [ "$attr" != "1" ]; then
53         _fail "Failed to set error/fail_at_unmount: $attr"
54 fi
55
56 # start a metadata-intensive workload, but no data allocation operation.
57 # Because uncompleted new space allocation I/Os may cause XFS to shutdown
58 # after loading error table.
59 $FSSTRESS_PROG -z -n 5000 -p 10 \
60                -f creat=10 \
61                -f resvsp=1 \
62                -f truncate=1 \
63                -f punch=1 \
64                -f chown=5 \
65                -f mkdir=5 \
66                -f rmdir=1 \
67                -f mknod=1 \
68                -f unlink=1 \
69                -f symlink=1 \
70                -f rename=1 \
71                -d $SCRATCH_MNT/fsstress >> $seqres.full 2>&1
72
73 # Loading error table without "--nolockfs" option. Because "--nolockfs"
74 # won't freeze fs, then some running I/Os may cause XFS to shutdown
75 # prematurely. That's not what we want to test.
76 _dmerror_load_error_table lockfs
77 _dmerror_unmount
78
79 # Mount again to replay log after loading working table, so we have a
80 # consistent XFS after test.
81 _dmerror_load_working_table
82 _dmerror_mount
83 _dmerror_unmount
84
85 # success, all done
86 status=0
87 exit