2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2013 Oracle. All Rights Reserved.
7 # A regression test of running btrfs balance and defrag concurrently.
9 # The test aims to trigger snapshot-aware defrag path in endio by
10 # running balance, which is not expected and leads to a crash.
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
27 # get standard environment, filters and checks
31 # real QA test starts here
34 _run_btrfs_balance_start $SCRATCH_MNT >> $seqres.full &
38 find $SCRATCH_MNT -type f -print0 | xargs -0 \
39 $BTRFS_UTIL_PROG filesystem defrag -f
50 _scratch_mkfs > /dev/null 2>&1
53 # This is going to reproduce a race senario between balance and the writeback
54 # of snapshot-aware defragment.
56 # we first create a few files to get higher btree height.
57 for j in `seq 0 100`; do
58 touch $SCRATCH_MNT/padding-$j
61 # Get 50 files with fragments by using backwards writes.
62 for j in `seq 0 50`; do
63 for i in `seq 20 -1 1`; do
64 $XFS_IO_PROG -f -d -c "pwrite $(($i * 4096)) 4096" \
65 $SCRATCH_MNT/foo-$j >> $seqres.full | _filter_xfs_io
69 # Make sure that our metadata makes it self on disk.
75 echo "Silence is golden"