fstests: Add path $here before src/<file>
[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 _supported_os Linux
37 _require_scratch
38 _require_scratch_shutdown
39 _require_metadata_journaling $SCRATCH_DEV
40 _require_test_program "multi_open_unlink"
41
42
43 function create_dirty_orphans() {
44
45         _scratch_mount
46
47         num_files=200
48         num_eas=1
49         ea_val_size=512
50
51         # sleep for ages and we will kill this pid when we are ready
52         delay=100
53
54         echo "open and unlink $num_files files with EAs"
55         $here/src/multi_open_unlink -f $SCRATCH_MNT/test_file \
56                 -n $num_files -s $delay -e $num_eas -v $ea_val_size &
57         pid=$!
58
59         # time to create and unlink all the files
60         sleep 3
61
62         echo "godown"
63         _scratch_shutdown -v -f >> $seqres.full
64
65         # kill the multi_open_unlink
66         kill $pid 2>/dev/null
67         wait $pid 2>/dev/null
68         pid=""
69
70         _scratch_unmount
71 }
72
73 # Does a regular rw mount handle the orphan list?
74 echo "mount dirty orphans rw, then unmount"
75 create_dirty_orphans
76 _scratch_mount
77 _scratch_unmount
78 # We should be clean at this point
79 echo "check fs consistency"
80 _check_scratch_fs
81
82 # Does a ro mount handle the orphan list?
83 echo "mount dirty orphans ro, then unmount"
84 create_dirty_orphans
85 _scratch_mount -o ro
86 _scratch_unmount
87 # We should be clean at this point
88 echo "check fs consistency"
89 _check_scratch_fs
90
91 # Does a mount with ro->rw transition handle orphan list?
92 echo "mount dirty orphans ro and remount rw, then unmount"
93 create_dirty_orphans
94 _scratch_mount -o ro
95 _scratch_remount rw
96 _scratch_unmount
97 # We should be clean at this point
98 echo "check fs consistency"
99 _check_scratch_fs
100
101 # success, all done
102 status=0
103 exit