common/rc: add scratch shutdown support for overlayfs
[xfstests-dev.git] / tests / generic / 417
1 #! /bin/bash
2 # FS QA Test 417
3 #
4 # Test orphan inode / unlinked list processing on RO mount & RW transition
5 #
6 # A filesystem that crashes with open but unlinked inodes should
7 # be consistent after a ro, ro->rw, or rw mount cycle.
8 #
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2017 Red Hat, Inc.  All Rights Reserved.
11 #
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
15 #
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24 #-----------------------------------------------------------------------
25 #
26
27 seq=`basename $0`
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=1        # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
35
36 _cleanup()
37 {
38         cd /
39         rm -f $tmp.*
40 }
41
42 # get standard environment, filters and checks
43 . ./common/rc
44 . ./common/filter
45
46 # remove previous $seqres.full before test
47 rm -f $seqres.full
48
49 # real QA test starts here
50 _supported_fs generic
51 _supported_os Linux
52 _require_scratch
53 _require_scratch_shutdown
54 _require_metadata_journaling $SCRATCH_DEV
55 _require_test_program "multi_open_unlink"
56
57
58 function create_dirty_orphans() {
59
60         _scratch_mount
61
62         num_files=200
63         num_eas=1
64         ea_val_size=512
65
66         # sleep for ages and we will kill this pid when we are ready
67         delay=100
68
69         echo "open and unlink $num_files files with EAs"
70         src/multi_open_unlink -f $SCRATCH_MNT/test_file \
71                 -n $num_files -s $delay -e $num_eas -v $ea_val_size &
72         pid=$!
73
74         # time to create and unlink all the files
75         sleep 3
76
77         echo "godown"
78         _scratch_shutdown -v -f >> $seqres.full
79
80         # kill the multi_open_unlink
81         kill $pid 2>/dev/null
82         wait $pid 2>/dev/null
83         pid=""
84
85         _scratch_unmount
86 }
87
88 # Does a regular rw mount handle the orphan list?
89 echo "mount dirty orphans rw, then unmount"
90 create_dirty_orphans
91 _scratch_mount
92 _scratch_unmount
93 # We should be clean at this point
94 echo "check fs consistency"
95 _check_scratch_fs
96
97 # Does a ro mount handle the orphan list?
98 echo "mount dirty orphans ro, then unmount"
99 create_dirty_orphans
100 _scratch_mount -o ro
101 _scratch_unmount
102 # We should be clean at this point
103 echo "check fs consistency"
104 _check_scratch_fs
105
106 # Does a mount with ro->rw transition handle orphan list?
107 echo "mount dirty orphans ro and remount rw, then unmount"
108 create_dirty_orphans
109 _scratch_mount -o ro
110 _scratch_remount rw
111 _scratch_unmount
112 # We should be clean at this point
113 echo "check fs consistency"
114 _check_scratch_fs
115
116 # success, all done
117 status=0
118 exit