2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014 Red Hat Inc. All Rights Reserved.
5 # FS QA Test No. xfs/015
7 # Make sure inodes can be allocated in new space added by xfs_growfs
10 # xfs: allow inode allocations in post-growfs disk space
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
18 status=1 # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
33 # keep running until failed after growfs
35 [ -f $tmp.growfs ] && in_growfs=true
36 while echo -n >$dir/testfile_$i; do
44 # get standard environment, filters and checks
48 # real QA test starts here
53 # need 128M space, don't make any assumption
54 _scratch_mkfs >/dev/null 2>&1
56 _require_fs_space $SCRATCH_MNT 131072
61 _scratch_mkfs_sized $((32 * 1024 * 1024)) > $tmp.mkfs.raw
62 cat $tmp.mkfs.raw | _filter_mkfs >$seqres.full 2>$tmp.mkfs
63 # get original data blocks number and agcount
67 nr_worker=$((agcount * 2))
68 echo "Fork $nr_worker workers to consume free inodes in background" >>$seqres.full
71 while [ $i -lt $nr_worker ]; do
72 mkdir $SCRATCH_MNT/testdir_$i
73 create_file $SCRATCH_MNT/testdir_$i &
79 # Grow fs at the same time, at least x4
80 # doubling or tripling the size couldn't reproduce
81 echo "Grow fs to $((dblocks * 4)) blocks" >>$seqres.full
82 $XFS_GROWFS_PROG -D $((dblocks * 4)) $SCRATCH_MNT >>$seqres.full
84 # mark xfs_growfs finished to create_file
87 # Wait for background create_file to hit ENOSPC
90 # log inode status in $seqres.full for debug purpose
91 echo "Inode status after growing fs" >>$seqres.full
92 $DF_PROG -i $SCRATCH_MNT >>$seqres.full
94 # inode should be at least 99% used
95 total_inode=`_get_total_inode $SCRATCH_MNT`
96 used_inode=`_get_used_inode $SCRATCH_MNT`
97 _within_tolerance "used inodes" $used_inode $total_inode %1 -v