blob: 548c94905f5b03452ee7a10aece853181bf18101 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (c) 2021 Oracle. All Rights Reserved.
#
# FS QA Test No. 154
#
# Make sure that the kernel won't mount a filesystem if repair forcibly sets
# NEEDSREPAIR while fixing metadata. Corrupt a directory in such a way as
# to force repair to write an invalid dirent value as a sentinel to trigger a
# repair activity in a later phase. Use a debug knob in xfs_repair to abort
# the repair immediately after forcing the flag on.
. ./common/preamble
_begin_fstest auto quick repair
# Import common functions.
. ./common/filter
# real QA test starts here
_supported_fs xfs
_require_scratch_nocheck
_require_scratch_xfs_crc # needsrepair only exists for v5
_require_libxfs_debug_flag LIBXFS_DEBUG_WRITE_CRASH
# Set up a real filesystem for our actual test
_scratch_mkfs >> $seqres.full
# Create a directory large enough to have a dir data block. 2k worth of
# dirent names ought to do it.
_scratch_mount
mkdir -p $SCRATCH_MNT/fubar
for i in $(seq 0 256 2048); do
fname=$(printf "%0255d" $i)
ln -s -f urk $SCRATCH_MNT/fubar/$fname
done
inum=$(stat -c '%i' $SCRATCH_MNT/fubar)
_scratch_unmount
# Fuzz the directory
_scratch_xfs_db -x -c "inode $inum" -c "dblock 0" \
-c "fuzz -d bu[2].inumber add" >> $seqres.full
# Try to repair the directory, force it to crash after setting needsrepair
LIBXFS_DEBUG_WRITE_CRASH=ddev=2 _scratch_xfs_repair 2>> $seqres.full
test $? -eq 137 || echo "repair should have been killed??"
# We can't mount, right?
_check_scratch_xfs_features NEEDSREPAIR
_try_scratch_mount &> $tmp.mount
res=$?
_filter_error_mount < $tmp.mount
if [ $res -eq 0 ]; then
echo "Should not be able to mount after needsrepair crash"
_scratch_unmount
fi
# Repair properly this time and retry the mount
_scratch_xfs_repair 2>> $seqres.full
_check_scratch_xfs_features NEEDSREPAIR
_scratch_mount
# success, all done
status=0
exit
|