2 # FS QA Test No. xfs/013
4 # Exercise the free inode btree (finobt). XFS allocates physical inodes in
5 # chunks of 64. Inode records with at least one free inode are stored in the
6 # finobt to optimize free inode lookup. This test runs a workload that creates
7 # and modifies a sparsely allocated set of inodes in combination with an
10 #-----------------------------------------------------------------------
11 # Copyright (c) 2014 Red Hat, Inc. All Rights Reserved.
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 #-----------------------------------------------------------------------
30 seqres=$RESULT_DIR/$seq
31 echo "QA output created by $seq"
35 status=1 # failure is the default!
37 # get standard environment, filters and checks
43 $KILLALL_PROG -9 fsstress 2>/dev/null
46 _scratch_unmount 2>/dev/null
49 trap "_cleanup; exit \$status" 0 1 2 3 15
57 for i in $(seq 0 $count)
68 # replace 5% of the dataset
69 for i in $(seq 0 $((count / 20)))
71 file=$((RANDOM % count))
83 iters=$((iters - mindirs))
85 for i in $(seq 1 $iters)
87 need=$dir/dir$((i + mindirs))
91 if ! pgrep fsstress > /dev/null 2>&1; then
101 # real QA test starts here
106 _require_xfs_mkfs_finobt
108 _require_command "$KILLALL_PROG" killall
112 _scratch_mkfs_xfs "-m crc=1,finobt=1 -d agcount=2" | \
113 _filter_mkfs 2>> $seqres.full
116 COUNT=20000 # number of files per directory
117 LOOPS=15 # last loop iteration
118 MINDIRS=2 # number of dirs for the cleaner to leave trailing behind the
119 # most recent (no less than 2 to prevent an rm from trampling a
122 # create initial directory
123 _create $SCRATCH_MNT/dir1 $COUNT
125 # start background cleaner to remove old directories as new ones are created
126 _cleaner $SCRATCH_MNT $LOOPS $MINDIRS &
128 # start a background stress workload on the fs
129 $FSSTRESS_PROG -d $SCRATCH_MNT/fsstress -n 9999999 -p 2 -S t \
130 >> $seqres.full 2>&1 &
132 # Each cycle clones the current directory and makes a random file replacement
133 # pass on the new directory. The directory is copied to the next using hard
134 # links. The replacement pass then randomly removes and replaces ~5% of the
135 # content in the directory. Files replaced as such are effectively marked to be
136 # freed by the background cleaner as it moves forward and removes all of the
137 # previous hard links to the inode. Over several iterations, this workload
138 # creates a sparsely located set of a free inodes across the set and uses the
139 # finobt to allocate new inodes for replacement.
141 for i in $(seq 1 $LOOPS)
143 # hard link the content of the current directory to the next
144 cp -Rl $SCRATCH_MNT/dir$i $SCRATCH_MNT/dir$((i+1))
146 # do a random replacement of files in the new directory
147 _rand_replace $SCRATCH_MNT/dir$((i+1)) $COUNT
150 $KILLALL_PROG fsstress
153 # clean out the competing fsstress allocations, then everything else
154 rm -rf $SCRATCH_MNT/fsstress
155 rm -rf $SCRATCH_MNT/dir*