common: kill _supported_os
[xfstests-dev.git] / tests / xfs / 057
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 No. 057
6 #
7 # Attempt to reproduce log recovery failure by writing corrupt log records over
8 # the last good tail in the log. The tail is force pinned while a workload runs
9 # the head as close as possible behind the tail. Once the head is pinned,
10 # corrupted log records are written to the log and the filesystem shuts down.
11 #
12 # While log recovery should handle the corrupted log records, it has historical
13 # problems dealing with the situation where the corrupted log records may have
14 # overwritten the tail of the previous good record in the log. If this occurs,
15 # log recovery may fail.
16 #
17 # This can be reproduced more reliably under non-default conditions such as with
18 # the smallest supported FSB sizes and/or largest supported log buffer sizes and
19 # counts (logbufs and logbsize mount options).
20 #
21 # Note that this test requires a DEBUG mode kernel.
22 #
23 seq=`basename $0`
24 seqres=$RESULT_DIR/$seq
25 echo "QA output created by $seq"
26
27 here=`pwd`
28 tmp=/tmp/$$
29 status=1        # failure is the default!
30 trap "_cleanup; exit \$status" 0 1 2 3 15
31
32 _cleanup()
33 {
34         cd /
35         rm -f $tmp.*
36         $KILLALL_PROG -9 fsstress > /dev/null 2>&1
37         [ -e /sys/fs/xfs/$sdev/errortag/log_item_pin ] &&
38                 echo 0 > /sys/fs/xfs/$sdev/errortag/log_item_pin
39         wait > /dev/null 2>&1
40 }
41
42 rm -f $seqres.full
43
44 # get standard environment, filters and checks
45 . ./common/rc
46 . ./common/inject
47
48 # real QA test starts here
49
50 # Modify as appropriate.
51 _supported_fs xfs
52 _require_xfs_io_error_injection log_item_pin
53 _require_xfs_io_error_injection log_bad_crc
54 _require_scratch
55 _require_command "$KILLALL_PROG" killall
56
57 echo "Silence is golden."
58
59 sdev=$(_short_dev $SCRATCH_DEV)
60
61 # use a small log fs
62 _scratch_mkfs_sized $((1024 * 1024 * 500)) >> $seqres.full 2>&1 ||
63                 _fail "mkfs failed"
64 _scratch_mount
65
66 # populate the fs with some data and cycle the mount to reset the log head/tail
67 $FSSTRESS_PROG -d $SCRATCH_MNT -z -fcreat=1 -p 4 -n 100000 > /dev/null 2>&1
68 _scratch_cycle_mount || _fail "cycle mount failed"
69
70 # Pin the tail and start a file removal workload. File removal tends to
71 # reproduce the corruption more reliably.
72 _scratch_inject_error log_item_pin 1
73
74 rm -rf $SCRATCH_MNT/* > /dev/null 2>&1 &
75 workpid=$!
76
77 # wait for the head to stop pushing forward
78 prevhead=-1
79 head=`cat /sys/fs/xfs/$sdev/log/log_head_lsn`
80 while [ "$head" != "$prevhead" ]; do
81         sleep 5
82         prevhead=$head
83         head=`cat /sys/fs/xfs/$sdev/log/log_head_lsn`
84 done
85
86 # Once the head is pinned behind the tail, enable log record corruption and
87 # unpin the tail. All subsequent log buffer writes end up corrupted on-disk and
88 # result in log I/O errors.
89 _scratch_inject_error log_bad_crc 1
90 _scratch_inject_error log_item_pin 0
91
92 # wait for fs shutdown to kill the workload
93 wait $workpid
94
95 # cycle mount to test log recovery
96 _scratch_cycle_mount
97
98 # success, all done
99 status=0
100 exit