common/rc: add _scratch_{u}mount_idmapped() helpers
[xfstests-dev.git] / tests / generic / 417
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test 417
6 #
7 # Test orphan inode / unlinked list processing on RO mount & RW transition
8 #
9 # A filesystem that crashes with open but unlinked inodes should
10 # be consistent after a ro, ro->rw, or rw mount cycle.
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1        # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
20
21 _cleanup()
22 {
23         cd /
24         rm -f $tmp.*
25 }
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30
31 # remove previous $seqres.full before test
32 rm -f $seqres.full
33
34 # real QA test starts here
35 _supported_fs generic
36 _require_scratch
37 _require_scratch_shutdown
38 _require_metadata_journaling $SCRATCH_DEV
39 _require_test_program "multi_open_unlink"
40
41
42 function create_dirty_orphans() {
43
44         _scratch_mount
45
46         num_files=200
47         num_eas=1
48         ea_val_size=512
49
50         # sleep for ages and we will kill this pid when we are ready
51         delay=100
52
53         echo "open and unlink $num_files files with EAs"
54         $here/src/multi_open_unlink -f $SCRATCH_MNT/test_file \
55                 -n $num_files -s $delay -e $num_eas -v $ea_val_size &
56         pid=$!
57
58         # time to create and unlink all the files
59         sleep 3
60
61         echo "godown"
62         _scratch_shutdown -v -f >> $seqres.full
63
64         # kill the multi_open_unlink
65         kill $pid 2>/dev/null
66         wait $pid 2>/dev/null
67         pid=""
68
69         _scratch_unmount
70 }
71
72 # Does a regular rw mount handle the orphan list?
73 echo "mount dirty orphans rw, then unmount"
74 create_dirty_orphans
75 _scratch_mount
76 _scratch_unmount
77 # We should be clean at this point
78 echo "check fs consistency"
79 _check_scratch_fs
80
81 # Does a ro mount handle the orphan list?
82 echo "mount dirty orphans ro, then unmount"
83 create_dirty_orphans
84 _scratch_mount -o ro
85 _scratch_unmount
86 # We should be clean at this point
87 echo "check fs consistency"
88 _check_scratch_fs
89
90 # Does a mount with ro->rw transition handle orphan list?
91 echo "mount dirty orphans ro and remount rw, then unmount"
92 create_dirty_orphans
93 _scratch_mount -o ro
94 _scratch_remount rw
95 _scratch_unmount
96 # We should be clean at this point
97 echo "check fs consistency"
98 _check_scratch_fs
99
100 # success, all done
101 status=0
102 exit