fstests: use _require_symlinks on all necessary tests
[xfstests-dev.git] / tests / generic / 085
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Red Hat Inc. All Rights Reserved.
4 #
5 # FS QA Test No. 085
6 #
7 # Exercise fs freeze/unfreeze and mount/umount race, which could lead to
8 # use-after-free oops.
9 #
10 # This commit fixed the issue:
11 # 1494583 fix get_active_super()/umount() race
12 #
13 seq=`basename $0`
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
16
17 here=`pwd`
18 tmp=/tmp/$$
19 status=1        # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
21
22 _cleanup()
23 {
24         cd /
25         rm -f $tmp.*
26         cleanup_dmdev
27 }
28
29 cleanup_dmdev()
30 {
31         # in case it's still suspended and/or mounted
32         $DMSETUP_PROG resume $lvdev >/dev/null 2>&1
33         $UMOUNT_PROG $lvdev >/dev/null 2>&1
34         _dmsetup_remove $node
35 }
36
37 # get standard environment, filters and checks
38 . ./common/rc
39 . ./common/filter
40
41 # real QA test starts here
42 _supported_fs generic
43 _supported_os Linux
44 _require_scratch
45 _require_block_device $SCRATCH_DEV
46 _require_dm_target linear
47 _require_freeze
48
49 setup_dmdev()
50 {
51         table="0 $size_in_sector linear $SCRATCH_DEV 0"
52         _dmsetup_create $node --table "$table" || \
53                 _fail "setup dm device failed"
54 }
55
56 rm -f $seqres.full
57 echo "Silence is golden"
58
59 size=$((256 * 1024 * 1024))
60 size_in_sector=$((size / 512))
61 _scratch_mkfs_sized $size >>$seqres.full 2>&1
62
63 node=$seq-test
64 lvdev=/dev/mapper/$node
65 setup_dmdev
66
67 # take use of dmsetup suspend to freeze the fs.
68 # xfs_freeze/fsfreeze cannot be used in this test, because it can possibly
69 # freeze the root fs of the host when SCRATCH_MNT is not mounted
70 #
71 # And the results of the racing commands (suspend/resume, mount/umount) are not
72 # important, as long as they're racing with each other. So just throw away the
73 # outputs and ignore the results.
74 for ((i=0; i<100; i++)); do
75         $DMSETUP_PROG suspend $lvdev >/dev/null 2>&1
76         $DMSETUP_PROG resume $lvdev >/dev/null 2>&1
77 done &
78 pid=$!
79 for ((i=0; i<100; i++)); do
80         $MOUNT_PROG $lvdev $SCRATCH_MNT >/dev/null 2>&1
81         $UMOUNT_PROG $lvdev >/dev/null 2>&1
82 done &
83 pid="$pid $!"
84
85 wait $pid
86
87 status=0
88 exit