4 # Exercise fs freeze/unfreeze and mount/umount race, which could lead to
7 # This commit fixed the issue:
8 # 1494583 fix get_active_super()/umount() race
10 #-----------------------------------------------------------------------
11 # Copyright (c) 2015 Red Hat Inc. All Rights Reserved.
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.
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.
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 #-----------------------------------------------------------------------
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
34 status=1 # failure is the default!
35 trap "_cleanup; exit \$status" 0 1 2 3 15
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
50 $DMSETUP_PROG remove $node >>$seqres.full 2>&1
51 $DMSETUP_PROG mknodes >/dev/null 2>&1
54 # get standard environment, filters and checks
58 # real QA test starts here
62 _require_block_device $SCRATCH_DEV
63 _require_dm_target linear
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
75 echo "Silence is golden"
77 size=$((256 * 1024 * 1024))
78 size_in_sector=$((size / 512))
79 _scratch_mkfs_sized $size >>$seqres.full 2>&1
82 lvdev=/dev/mapper/$node
83 setup_dmdev || _fail "setup dm device failed"
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
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
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