generic: add _require_odirect to generic/113 and generic/214
[xfstests-dev.git] / tests / generic / 085
1 #! /bin/bash
2 # FS QA Test No. 085
3 #
4 # Exercise fs freeze/unfreeze and mount/umount race, which could lead to
5 # use-after-free oops.
6 #
7 # This commit fixed the issue:
8 # 1494583 fix get_active_super()/umount() race
9 #
10 #-----------------------------------------------------------------------
11 # Copyright (c) 2015 Red Hat Inc. All Rights Reserved.
12 #
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
16 #
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
25 #-----------------------------------------------------------------------
26 #
27
28 seq=`basename $0`
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
31
32 here=`pwd`
33 tmp=/tmp/$$
34 status=1        # failure is the default!
35 trap "_cleanup; exit \$status" 0 1 2 3 15
36
37 _cleanup()
38 {
39         cd /
40         rm -f $tmp.*
41         cleanup_dmdev
42 }
43
44 cleanup_dmdev()
45 {
46         # in case it's still suspended and/or mounted
47         $DMSETUP_PROG resume $lvdev >/dev/null 2>&1
48         $UMOUNT_PROG $lvdev >/dev/null 2>&1
49
50         $DMSETUP_PROG remove $node >>$seqres.full 2>&1
51         $DMSETUP_PROG mknodes >/dev/null 2>&1
52 }
53
54 # get standard environment, filters and checks
55 . ./common/rc
56 . ./common/filter
57
58 # real QA test starts here
59 _supported_fs generic
60 _supported_os Linux
61 _require_scratch
62 _require_block_device $SCRATCH_DEV
63 _require_dm_target linear
64 _require_freeze
65
66 setup_dmdev()
67 {
68         table="0 $size_in_sector linear $SCRATCH_DEV 0"
69         $DMSETUP_PROG create $node --table "$table" >>$seqres.full 2>&1 && \
70         $DMSETUP_PROG mknodes >/dev/null 2>&1
71         return $?
72 }
73
74 rm -f $seqres.full
75 echo "Silence is golden"
76
77 size=$((256 * 1024 * 1024))
78 size_in_sector=$((size / 512))
79 _scratch_mkfs_sized $size >>$seqres.full 2>&1
80
81 node=$seq-test
82 lvdev=/dev/mapper/$node
83 setup_dmdev || _fail "setup dm device failed"
84
85 # take use of dmsetup suspend to freeze the fs.
86 # xfs_freeze/fsfreeze cannot be used in this test, because it can possibly
87 # freeze the root fs of the host when SCRATCH_MNT is not mounted
88 #
89 # And the results of the racing commands (suspend/resume, mount/umount) are not
90 # important, as long as they're racing with each other. So just throw away the
91 # outputs and ignore the results.
92 for ((i=0; i<100; i++)); do
93         $DMSETUP_PROG suspend $lvdev >/dev/null 2>&1
94         $DMSETUP_PROG resume $lvdev >/dev/null 2>&1
95 done &
96 pid=$!
97 for ((i=0; i<100; i++)); do
98         $MOUNT_PROG $lvdev $SCRATCH_MNT >/dev/null 2>&1
99         $UMOUNT_PROG $lvdev >/dev/null 2>&1
100 done &
101 pid="$pid $!"
102
103 wait $pid
104
105 status=0
106 exit