xfs: fix old fuzz test invocations of xfs_repair
[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 _require_scratch
44 _require_block_device $SCRATCH_DEV
45 _require_dm_target linear
46 _require_freeze
47
48 setup_dmdev()
49 {
50         table="0 $size_in_sector linear $SCRATCH_DEV 0"
51         _dmsetup_create $node --table "$table" || \
52                 _fail "setup dm device failed"
53 }
54
55 rm -f $seqres.full
56 echo "Silence is golden"
57
58 size=$((256 * 1024 * 1024))
59 size_in_sector=$((size / 512))
60 _scratch_mkfs_sized $size >>$seqres.full 2>&1
61
62 node=$seq-test
63 lvdev=/dev/mapper/$node
64 setup_dmdev
65
66 # take use of dmsetup suspend to freeze the fs.
67 # xfs_freeze/fsfreeze cannot be used in this test, because it can possibly
68 # freeze the root fs of the host when SCRATCH_MNT is not mounted
69 #
70 # And the results of the racing commands (suspend/resume, mount/umount) are not
71 # important, as long as they're racing with each other. So just throw away the
72 # outputs and ignore the results.
73 for ((i=0; i<100; i++)); do
74         $DMSETUP_PROG suspend $lvdev >/dev/null 2>&1
75         $DMSETUP_PROG resume $lvdev >/dev/null 2>&1
76 done &
77 pid=$!
78 for ((i=0; i<100; i++)); do
79         $MOUNT_PROG $lvdev $SCRATCH_MNT >/dev/null 2>&1
80         $UMOUNT_PROG $lvdev >/dev/null 2>&1
81 done &
82 pid="$pid $!"
83
84 wait $pid
85
86 status=0
87 exit