2014-05-13 15:28:35 +10:00
|
|
|
#!/bin/bash
|
2018-06-09 11:35:45 +10:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
# Copyright (c) 2014 Red Hat, Inc. All Rights Reserved.
|
|
|
|
|
#
|
2014-05-13 15:28:35 +10:00
|
|
|
# FS QA Test No. xfs/013
|
|
|
|
|
#
|
|
|
|
|
# Exercise the free inode btree (finobt). XFS allocates physical inodes in
|
|
|
|
|
# chunks of 64. Inode records with at least one free inode are stored in the
|
|
|
|
|
# finobt to optimize free inode lookup. This test runs a workload that creates
|
|
|
|
|
# and modifies a sparsely allocated set of inodes in combination with an
|
|
|
|
|
# fsstress workload.
|
|
|
|
|
#
|
|
|
|
|
seq=`basename $0`
|
|
|
|
|
seqres=$RESULT_DIR/$seq
|
|
|
|
|
echo "QA output created by $seq"
|
|
|
|
|
|
|
|
|
|
here=`pwd`
|
|
|
|
|
tmp=/tmp/$$
|
|
|
|
|
status=1 # failure is the default!
|
|
|
|
|
|
|
|
|
|
# get standard environment, filters and checks
|
|
|
|
|
. ./common/rc
|
|
|
|
|
. ./common/filter
|
|
|
|
|
|
|
|
|
|
_cleanup()
|
|
|
|
|
{
|
2016-06-13 11:58:01 +09:00
|
|
|
$KILLALL_PROG -9 fsstress 2>/dev/null
|
2014-05-15 11:37:49 +10:00
|
|
|
wait
|
2014-05-13 15:28:35 +10:00
|
|
|
cd /
|
2015-12-21 18:07:43 +11:00
|
|
|
_scratch_unmount 2>/dev/null
|
2014-05-13 15:28:35 +10:00
|
|
|
rm -f $tmp.*
|
|
|
|
|
}
|
|
|
|
|
trap "_cleanup; exit \$status" 0 1 2 3 15
|
|
|
|
|
|
2017-11-01 14:47:48 -07:00
|
|
|
filter_enospc() {
|
|
|
|
|
sed -e '/^.*No space left on device.*/d'
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-13 15:28:35 +10:00
|
|
|
_create()
|
|
|
|
|
{
|
|
|
|
|
dir=$1
|
|
|
|
|
count=$2
|
|
|
|
|
|
|
|
|
|
mkdir -p $dir
|
|
|
|
|
for i in $(seq 0 $count)
|
|
|
|
|
do
|
2017-11-01 14:47:48 -07:00
|
|
|
touch $dir/$i 2>&1 | filter_enospc
|
2014-05-13 15:28:35 +10:00
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_rand_replace()
|
|
|
|
|
{
|
|
|
|
|
dir=$1
|
|
|
|
|
count=$2
|
|
|
|
|
|
|
|
|
|
# replace 5% of the dataset
|
|
|
|
|
for i in $(seq 0 $((count / 20)))
|
|
|
|
|
do
|
|
|
|
|
file=$((RANDOM % count))
|
|
|
|
|
rm -f $dir/$file
|
2017-11-01 14:47:48 -07:00
|
|
|
touch $dir/$file 2>&1 | filter_enospc
|
2014-05-13 15:28:35 +10:00
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_cleaner()
|
|
|
|
|
{
|
|
|
|
|
dir=$1
|
|
|
|
|
iters=$2
|
|
|
|
|
mindirs=$3
|
|
|
|
|
|
|
|
|
|
iters=$((iters - mindirs))
|
|
|
|
|
|
|
|
|
|
for i in $(seq 1 $iters)
|
|
|
|
|
do
|
|
|
|
|
need=$dir/dir$((i + mindirs))
|
|
|
|
|
while [ ! -e $need ]
|
|
|
|
|
do
|
|
|
|
|
sleep 3
|
2017-08-29 21:40:56 -07:00
|
|
|
if ! pgrep fsstress > /dev/null 2>&1; then
|
|
|
|
|
echo "fsstress died?"
|
|
|
|
|
return
|
|
|
|
|
fi
|
2014-05-13 15:28:35 +10:00
|
|
|
done
|
|
|
|
|
|
|
|
|
|
rm -rf $dir/dir$i
|
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# real QA test starts here
|
|
|
|
|
_supported_fs xfs
|
|
|
|
|
|
|
|
|
|
_require_scratch
|
|
|
|
|
_require_xfs_mkfs_finobt
|
|
|
|
|
_require_xfs_finobt
|
2016-06-13 11:58:01 +09:00
|
|
|
_require_command "$KILLALL_PROG" killall
|
2014-05-13 15:28:35 +10:00
|
|
|
|
|
|
|
|
rm -f $seqres.full
|
|
|
|
|
|
|
|
|
|
_scratch_mkfs_xfs "-m crc=1,finobt=1 -d agcount=2" | \
|
|
|
|
|
_filter_mkfs 2>> $seqres.full
|
|
|
|
|
_scratch_mount
|
|
|
|
|
|
|
|
|
|
COUNT=20000 # number of files per directory
|
|
|
|
|
LOOPS=15 # last loop iteration
|
|
|
|
|
MINDIRS=2 # number of dirs for the cleaner to leave trailing behind the
|
|
|
|
|
# most recent (no less than 2 to prevent an rm from trampling a
|
|
|
|
|
# clone)
|
|
|
|
|
|
|
|
|
|
# create initial directory
|
|
|
|
|
_create $SCRATCH_MNT/dir1 $COUNT
|
|
|
|
|
|
|
|
|
|
# start background cleaner to remove old directories as new ones are created
|
|
|
|
|
_cleaner $SCRATCH_MNT $LOOPS $MINDIRS &
|
|
|
|
|
|
|
|
|
|
# start a background stress workload on the fs
|
2014-06-18 09:29:22 +10:00
|
|
|
$FSSTRESS_PROG -d $SCRATCH_MNT/fsstress -n 9999999 -p 2 -S t \
|
2014-05-13 15:28:35 +10:00
|
|
|
>> $seqres.full 2>&1 &
|
|
|
|
|
|
|
|
|
|
# Each cycle clones the current directory and makes a random file replacement
|
|
|
|
|
# pass on the new directory. The directory is copied to the next using hard
|
|
|
|
|
# links. The replacement pass then randomly removes and replaces ~5% of the
|
|
|
|
|
# content in the directory. Files replaced as such are effectively marked to be
|
|
|
|
|
# freed by the background cleaner as it moves forward and removes all of the
|
|
|
|
|
# previous hard links to the inode. Over several iterations, this workload
|
|
|
|
|
# creates a sparsely located set of a free inodes across the set and uses the
|
|
|
|
|
# finobt to allocate new inodes for replacement.
|
|
|
|
|
|
|
|
|
|
for i in $(seq 1 $LOOPS)
|
|
|
|
|
do
|
|
|
|
|
# hard link the content of the current directory to the next
|
2017-12-13 14:45:01 -08:00
|
|
|
while ! test -d $SCRATCH_MNT/dir$((i+1)); do
|
|
|
|
|
cp -Rl $SCRATCH_MNT/dir$i $SCRATCH_MNT/dir$((i+1)) 2>&1 | \
|
|
|
|
|
filter_enospc
|
|
|
|
|
done
|
2014-05-13 15:28:35 +10:00
|
|
|
|
|
|
|
|
# do a random replacement of files in the new directory
|
|
|
|
|
_rand_replace $SCRATCH_MNT/dir$((i+1)) $COUNT
|
|
|
|
|
done
|
|
|
|
|
|
2016-06-13 11:58:01 +09:00
|
|
|
$KILLALL_PROG fsstress
|
2014-05-13 15:28:35 +10:00
|
|
|
wait
|
|
|
|
|
|
|
|
|
|
# clean out the competing fsstress allocations, then everything else
|
|
|
|
|
rm -rf $SCRATCH_MNT/fsstress
|
|
|
|
|
rm -rf $SCRATCH_MNT/dir*
|
|
|
|
|
|
2015-12-21 18:07:43 +11:00
|
|
|
_scratch_unmount
|
2014-05-13 15:28:35 +10:00
|
|
|
|
|
|
|
|
status=0
|
|
|
|
|
exit
|