common: kill _supported_os
[xfstests-dev.git] / tests / generic / 411
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 411
6 #
7 # This test cover linux commit 7ae8fd0, kernel two mnt_group_id == 0
8 # (no peer)vfsmount as peers. It case kernel dereference a NULL
9 # address.
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 _cleanup()
21 {
22         cd /
23         rm -f $tmp.*
24         _clear_mount_stack
25         # make sure there's no bug cause dentry isn't be freed
26         rm -rf $MNTHEAD
27 }
28
29 # get standard environment, filters and checks
30 . ./common/rc
31 . ./common/filter
32
33 # remove previous $seqres.full before test
34 rm -f $seqres.full
35
36 # real QA test starts here
37 _supported_fs generic
38 _require_test
39 _require_scratch
40 _require_local_device $SCRATCH_DEV
41
42 fs_stress()
43 {
44         local target=$1
45
46         $FSSTRESS_PROG -z -n 500 -p 5 \
47                        -f creat=5 \
48                        -f mkdir=5 \
49                        -f dwrite=1 \
50                        -f dread=1 \
51                        -f link=2 \
52                        -f rename=1 \
53                        -f rmdir=2 \
54                        -f unlink=1 \
55                        -f symlink=1 \
56                        -f write=1 \
57                        -f read=1 \
58                        -f chown=1 \
59                        -f getdents=1 \
60                        -f fiemap=1 \
61                        -d $target >/dev/null
62         sync
63 }
64
65 # prepare some mountpoint dir
66 MNTHEAD=$TEST_DIR/$seq
67 rm -rf $MNTHEAD
68 mkdir $MNTHEAD 2>>$seqres.full
69 mpA=$MNTHEAD/"$$"_mpA
70 mpB=$MNTHEAD/"$$"_mpB
71 mpC=$MNTHEAD/"$$"_mpC
72
73 find_mnt()
74 {
75         echo "------"
76         findmnt -n -o TARGET,SOURCE $SCRATCH_DEV | \
77                 sed -e "s;$mpA;mpA;g" \
78                     -e "s;$mpB;mpB;g" \
79                     -e "s;$mpC;mpC;g" | \
80                 _filter_spaces | _filter_testdir_and_scratch | sort
81         echo "======"
82 }
83
84 start_test()
85 {
86         local type=$1
87
88         _scratch_mkfs >$seqres.full 2>&1
89         _get_mount -t $FSTYP $SCRATCH_DEV $MNTHEAD
90         $MOUNT_PROG --make-"${type}" $MNTHEAD
91         mkdir $mpA $mpB $mpC
92 }
93
94 end_test()
95 {
96         _clear_mount_stack
97         rm -rf $mpA $mpB $mpC
98 }
99
100 #
101 #            shared            New FS           shared
102 #      -----------------------[A/mnt1]----------------------
103 #     |                           |                         |
104 #     |                bind       |    bind                 |       New FS
105 # [C/mnt1]--[slave C]<------[shared A]------>[slave B]--[B/mnt1]--[B/mnt1/mnt2]
106 #
107 crash_test()
108 {
109         start_test shared
110
111         _get_mount -t $FSTYP $SCRATCH_DEV $mpA
112         mkdir $mpA/mnt1
113         $MOUNT_PROG --make-shared $mpA
114         _get_mount --bind $mpA $mpB
115         _get_mount --bind $mpA $mpC
116         $MOUNT_PROG --make-slave $mpB
117         $MOUNT_PROG --make-slave $mpC
118         _get_mount -t $FSTYP $SCRATCH_DEV $mpA/mnt1
119         mkdir $mpA/mnt1/mnt2
120
121         _get_mount -t $FSTYP $SCRATCH_DEV $mpB/mnt1/mnt2
122         find_mnt
123         fs_stress $mpB/mnt1/mnt2
124
125         end_test
126         echo "crash test passed"
127 }
128
129 crash_test
130
131 # success, all done
132 status=0
133 exit