blob: 3896ce1c3325454b14a3c7ba72d4050f416dee7e (
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
|
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2014 Red Hat Inc. All Rights Reserved.
#
# FS QA Test No. xfs/015
#
# Make sure inodes can be allocated in new space added by xfs_growfs
#
# Regression test for
# xfs: allow inode allocations in post-growfs disk space
#
. ./common/preamble
_begin_fstest auto enospc growfs
create_file()
{
local dir=$1
local i=0
local in_growfs=false
# keep running until failed after growfs
while true; do
[ -f $tmp.growfs ] && in_growfs=true
while echo -n >$dir/testfile_$i; do
let i=$i+1
done
$in_growfs && break
usleep 1000
done
}
# Import common functions.
. ./common/filter
# real QA test starts here
_supported_fs xfs
_require_scratch
# need 128M space, don't make any assumption
_scratch_mkfs >/dev/null 2>&1
_scratch_mount
_require_fs_space $SCRATCH_MNT 196608
_scratch_unmount
_scratch_mkfs_sized $((96 * 1024 * 1024)) > $tmp.mkfs.raw
cat $tmp.mkfs.raw | _filter_mkfs >$seqres.full 2>$tmp.mkfs
# get original data blocks number and agcount
. $tmp.mkfs
_scratch_mount
nr_worker=$((agcount * 2))
echo "Fork $nr_worker workers to consume free inodes in background" >>$seqres.full
(
i=0
while [ $i -lt $nr_worker ]; do
mkdir $SCRATCH_MNT/testdir_$i
create_file $SCRATCH_MNT/testdir_$i &
let i=$i+1
done
wait
) >/dev/null 2>&1 &
# Grow fs at the same time, at least x4
# doubling or tripling the size couldn't reproduce
echo "Grow fs to $((dblocks * 4)) blocks" >>$seqres.full
$XFS_GROWFS_PROG -D $((dblocks * 4)) $SCRATCH_MNT >>$seqres.full
# mark xfs_growfs finished to create_file
touch $tmp.growfs
# Wait for background create_file to hit ENOSPC
wait
# log inode status in $seqres.full for debug purpose
echo "Inode status after growing fs" >>$seqres.full
$DF_PROG -i $SCRATCH_MNT >>$seqres.full
# inode should be at least 99% used
total_inode=`_get_total_inode $SCRATCH_MNT`
used_inode=`_get_used_inode $SCRATCH_MNT`
_within_tolerance "used inodes" $used_inode $total_inode %1 -v
status=$?
exit
|