btrfs/012: check free size of scratch device before copying files
[xfstests-dev.git] / tests / generic / 226
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2009 Eric Sandeen.  All Rights Reserved.
4 #
5 # FS QA Test No. 226
6 #
7 # Test for prealloc space leaks by rewriting the same file in a loop
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
17
18 # get standard environment, filters and checks
19 . ./common/rc
20
21 _supported_fs generic
22 _require_scratch
23 _require_odirect
24
25 # real QA test starts here
26 rm -f $seqres.full
27
28 _scratch_unmount 2>/dev/null
29 echo "--> mkfs 256m filesystem"
30 _scratch_mkfs_sized `expr 256 \* 1024 \* 1024` >> $seqres.full 2>&1
31 _scratch_mount
32
33 loops=16
34
35 # Buffer size argument supplied to xfs_io "pwrite" command
36 buffer="-b $(expr 512 \* 1024)"
37
38 echo "--> $loops buffered 64m writes in a loop"
39 for I in `seq 1 $loops`; do
40         echo -n "$I "
41         $XFS_IO_PROG -f \
42                 -c "pwrite ${buffer} 0 64m" $SCRATCH_MNT/test >> $seqres.full
43         rm -f $SCRATCH_MNT/test
44 done
45
46 echo
47 _scratch_cycle_mount
48
49 echo "--> $loops direct 64m writes in a loop"
50 for I in `seq 1 $loops`; do
51         echo -n "$I "
52         $XFS_IO_PROG -f -d \
53                 -c "pwrite ${buffer} 0 64m" $SCRATCH_MNT/test >> $seqres.full
54         rm -f $SCRATCH_MNT/test 
55 done
56
57 echo
58 _scratch_unmount
59
60 status=0
61 exit