generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / generic / 054
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 054
6 #
7 # To test log replay with version 2 logs
8 # Initially keep this simple with just creates.
9 # In another qa test we can do more e.g. use fsstress.
10 #
11 . ./common/preamble
12 _begin_fstest shutdown log v2log auto
13
14 # Import common functions.
15 . ./common/filter
16 . ./common/log
17
18 # real QA test starts here
19 _supported_fs generic
20
21 _require_scratch
22 _require_scratch_shutdown
23 _require_logstate
24
25 echo "*** init FS"
26 _scratch_unmount >/dev/null 2>&1
27
28 _scratch_mkfs >/dev/null 2>&1
29 _require_metadata_journaling $SCRATCH_DEV
30
31 _get_log_configs > $tmp.seq.params
32
33 # Do the work for various log params which
34 # should not effect the data content of the log
35 # Try with and without sync'ing - sync'ing will mean that
36 # the log will be written out unfilled and thus the log
37 # stripe can have an effect.
38 #
39 for s in sync nosync ; do
40     cat $tmp.seq.params \
41     | while read mkfs mnt restofline
42     do
43         if [ "$mkfs" = "#" ]; then
44             continue
45         fi
46
47         echo "--- mkfs=$mkfs, mnt=$mnt, sync=$s ---" >>$seqres.full
48         export MKFS_OPTIONS="-l $mkfs"
49         export MOUNT_OPTIONS="-o $mnt"
50
51         # mkfs the FS
52         _echofull "mkfs"
53         _scratch_mkfs >>$seqres.full 2>&1
54         if [ $? -ne 0 ] ; then
55             _echofull "mkfs failed: $MKFS_OPTIONS"
56             continue
57         fi
58
59         # mount the FS
60         _echofull "mount"
61         if ! _try_scratch_mount >>$seqres.full 2>&1; then
62             _echofull "mount failed: $MOUNT_OPTIONS"
63             continue
64         fi
65
66         # create the metadata
67         if [ $s = "sync" ]; then
68             # generate some log traffic - but not too much
69             # add some syncs to get the log flushed to disk
70             for file in $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}; do
71                 touch $file
72                 sync
73             done
74         else
75             # generate some log traffic - but not too much - life gets a little
76             # more complicated if the log wraps around. This traffic is
77             # pretty much arbitary, but could probably be made better than this.
78             touch $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}
79         fi
80
81         # check before on what FS should look like
82         _echofull "ls SCRATCH_MNT"
83         ls $SCRATCH_MNT | _filter_lostfound
84
85         _echofull "godown"
86         _scratch_shutdown -v -f >> $seqres.full
87
88         _echofull "unmount"
89         _scratch_unmount >>$seqres.full 2>&1 \
90             || _fail "umount failed"
91
92         _echofull "logprint after going down..."
93         _print_logstate
94
95         _echofull "mount with replay"
96         _try_scratch_mount >>$seqres.full 2>&1 \
97             || _fail "mount failed: $MOUNT_OPTIONS"
98
99         # check on what FS looks like after log recovery
100         _echofull "ls SCRATCH_MNT"
101         ls $SCRATCH_MNT | _filter_lostfound
102
103         _echofull "unmount"
104         _scratch_unmount
105
106         _echofull "logprint after mount and replay..."
107         _print_logstate
108
109         if _check_scratch_fs; then
110             _echofull "filesystem is checked ok"
111         else
112             _echofull "filesystem is NOT ok"
113         fi
114     done
115 done
116
117 status=0
118 exit