blob: 5090435976c83b916a52e9b137ec275ee86ddf14 (
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (c) 2021 Oracle. All Rights Reserved.
#
# FS QA Test No. 146
#
# This is a regression test for commit 2a6ca4baed62 ("xfs: make sure the rt
# allocator doesn't run off the end") which fixes an overflow error in the
# _near realtime allocator. If the rt bitmap ends exactly at the end of a
# block and the number of rt extents is large enough to allow an allocation
# request larger than the maximum extent size, it's possible that during a
# large allocation request, the allocator will fail to constrain maxlen on the
# second run through the loop, and the rt bitmap range check will run right off
# the end of the rtbitmap file. When this happens, xfs triggers a verifier
# error and returns EFSCORRUPTED.
. ./common/preamble
_begin_fstest auto quick rw realtime prealloc
# Import common functions.
. ./common/filter
# real QA test starts here
_supported_fs xfs
_require_scratch
_require_realtime
_require_xfs_io_command "falloc"
_require_test_program "punch-alternating"
# Format filesystem to get the block size
_scratch_mkfs > $seqres.full
_scratch_mount >> $seqres.full
blksz=$(_get_block_size $SCRATCH_MNT)
rextsize=$(_xfs_get_rtextsize "$SCRATCH_MNT")
rextblks=$((rextsize / blksz))
echo "blksz $blksz rextsize $rextsize rextblks $rextblks" >> $seqres.full
_scratch_unmount
# Format filesystem with a realtime volume whose size fits the following:
# 1. Longer than (XFS MAXEXTLEN * blocksize) bytes so that a large fallocate
# request can create a maximally sized data fork extent mapping and then
# ask the allocator for even more blocks.
# 2. Exactly a multiple of (NBBY * blksz * rextsize) bytes.
rtsize1=$((2097151 * blksz))
rtsize2=$((8 * blksz * rextsize))
rtsize=$(( $(blockdev --getsz $SCRATCH_RTDEV) * 512 ))
echo "rtsize1 $rtsize1 rtsize2 $rtsize2 rtsize $rtsize" >> $seqres.full
test $rtsize -gt $rtsize1 || \
_notrun "scratch rt device too small, need $rtsize1 bytes"
test $rtsize -gt $rtsize2 || \
_notrun "scratch rt device too small, need $rtsize2 bytes"
rtsize=$((rtsize - (rtsize % rtsize2)))
echo "rt size will be $rtsize" >> $seqres.full
_scratch_mkfs -r size=$rtsize >> $seqres.full
_scratch_mount >> $seqres.full
# Make sure the root directory has rtinherit set so our test file will too
_xfs_force_bdev realtime $SCRATCH_MNT
# Allocate some stuff at the start, to force the first falloc of the ouch file
# to happen somewhere in the middle of the rt volume
$XFS_IO_PROG -f -c 'falloc 0 64m' "$SCRATCH_MNT/b"
$here/src/punch-alternating -i $((rextblks * 2)) -s $((rextblks)) "$SCRATCH_MNT/b"
avail="$(df -P "$SCRATCH_MNT" | awk 'END {print $4}')"1
toobig="$((avail * 2))"
# falloc the ouch file in the middle of the rt extent to exercise the near
# allocator in the last step.
$XFS_IO_PROG -f -c 'falloc 0 1g' "$SCRATCH_MNT/ouch"
# Try to get the near allocator to overflow on an allocation that matches
# exactly one of the rtsummary size levels. This should return ENOSPC and
# not EFSCORRUPTED.
$XFS_IO_PROG -f -c "falloc 0 ${toobig}k" "$SCRATCH_MNT/ouch"
# success, all done
status=0
exit
|