fstests: check for filesystem FS_IOC_FSSETXATTR support
[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 _supported_os Linux
37 _require_scratch
38 _require_dm_target error
39 _require_fs_sysfs error/fail_at_unmount
40
41 _scratch_mkfs > $seqres.full 2>&1
42 _dmerror_init
43 _dmerror_mount
44
45 # Make sure all error handling attributes are original status
46 _reset_xfs_sysfs_error_handling $DMERROR_DEV
47
48 # Make sure fail_at_unmount is enabled, so XFS stops retrying on
49 # errors at unmount time. _fail the test if we fail to set it to 1,
50 # because the test probably will hang in such case and block
51 # subsequent tests.
52 attr=`_get_fs_sysfs_attr $DMERROR_DEV error/fail_at_unmount`
53 if [ "$attr" != "1" ]; then
54         _fail "Failed to set error/fail_at_unmount: $attr"
55 fi
56
57 # start a metadata-intensive workload, but no data allocation operation.
58 # Because uncompleted new space allocation I/Os may cause XFS to shutdown
59 # after loading error table.
60 $FSSTRESS_PROG -z -n 5000 -p 10 \
61                -f creat=10 \
62                -f resvsp=1 \
63                -f truncate=1 \
64                -f punch=1 \
65                -f chown=5 \
66                -f mkdir=5 \
67                -f rmdir=1 \
68                -f mknod=1 \
69                -f unlink=1 \
70                -f symlink=1 \
71                -f rename=1 \
72                -d $SCRATCH_MNT/fsstress >> $seqres.full 2>&1
73
74 # Loading error table without "--nolockfs" option. Because "--nolockfs"
75 # won't freeze fs, then some running I/Os may cause XFS to shutdown
76 # prematurely. That's not what we want to test.
77 _dmerror_load_error_table lockfs
78 _dmerror_unmount
79
80 # Mount again to replay log after loading working table, so we have a
81 # consistent XFS after test.
82 _dmerror_load_working_table
83 _dmerror_mount
84 _dmerror_unmount
85
86 # success, all done
87 status=0
88 exit