generic: shutdown fs after log recovery
[xfstests-dev.git] / tests / generic / 361
1 #! /bin/bash
2 # FS QA Test 361
3 #
4 # Test remount on I/O errors.
5 #
6 # XFS had a bug to hang on remount in this case, this kernel commit fix
7 # the issue.
8 # 5cb13dc cancel the setfilesize transation when io error happen
9 #
10 #-----------------------------------------------------------------------
11 # Copyright (c) 2016 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         $UMOUNT_PROG $fs_mnt
40         _destroy_loop_device $loop_dev
41         cd /
42         rm -f $tmp.*
43 }
44
45 # get standard environment, filters and checks
46 . ./common/rc
47 . ./common/filter
48
49 rm -f $seqres.full
50
51 # real QA test starts here
52 _supported_fs generic
53 _supported_os Linux
54 _require_scratch
55 _require_block_device $SCRATCH_DEV
56
57 # create a small filesystem to hold another filesystem image
58 _scratch_mkfs_sized $((512 * 1024 * 1024)) >>$seqres.full 2>&1
59 _scratch_mount
60
61 # create the sparse fs image and mount point
62 fs_img=$SCRATCH_MNT/fs.img
63 fs_mnt=$SCRATCH_MNT/mnt
64 $XFS_IO_PROG -fc "truncate 1g" $fs_img >>$seqres.full 2>&1
65 mkdir -p $fs_mnt
66
67 # mount loop device and create a larger file to hit I/O errors on loop device
68 loop_dev=$(_create_loop_device $fs_img)
69 _mkfs_dev $loop_dev
70 _mount $loop_dev $fs_mnt
71 $XFS_IO_PROG -fc "pwrite 0 520m" $fs_mnt/testfile >>$seqres.full 2>&1
72
73 # remount should not hang
74 $MOUNT_PROG -o remount,ro $fs_mnt >>$seqres.full 2>&1
75
76 # success, all done
77 echo "Silence is golden"
78 status=0
79 exit