4 # A regression test of running btrfs balance and defrag concurrently.
6 # The test aims to trigger snapshot-aware defrag path in endio by
7 # running balance, which is not expected and leads to a crash.
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2013 Oracle. All Rights Reserved.
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #-----------------------------------------------------------------------
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
33 status=1 # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
42 # get standard environment, filters and checks
46 # real QA test starts here
49 $BTRFS_UTIL_PROG balance start $SCRATCH_MNT >> $seqres.full &
53 find $SCRATCH_MNT -type f -print0 | xargs -0 \
54 $BTRFS_UTIL_PROG filesystem defrag -f
66 _scratch_mkfs > /dev/null 2>&1
69 # This is going to reproduce a race senario between balance and the writeback
70 # of snapshot-aware defragment.
72 # we first create a few files to get higher btree height.
73 for j in `seq 0 100`; do
74 touch $SCRATCH_MNT/padding-$j
77 # Get 50 files with fragments by using backwards writes.
78 for j in `seq 0 50`; do
79 for i in `seq 20 -1 1`; do
80 $XFS_IO_PROG -f -d -c "pwrite $(($i * 4096)) 4096" \
81 $SCRATCH_MNT/foo-$j >> $seqres.full | _filter_xfs_io
85 # Make sure that our metadata makes it self on disk.
91 echo "Silence is golden"