5 # Preallocate space to a file, and fill the rest of the fs to 100%.
6 # Then test a write into that preallocated space, which should succeed.
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2011-2012 Fujitsu, Inc. All Rights Reserved.
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #-----------------------------------------------------------------------
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
34 status=0 # success is the default!
35 trap "_cleanup; exit \$status" 0 1 2 3 15
47 # real QA test starts here
49 _supported_os IRIX Linux
51 _require_xfs_io_command "falloc"
53 echo "------------------------------"
54 echo "preallocation test"
55 echo "------------------------------"
59 umount $SCRATCH_DEV 2>/dev/null
60 _scratch_mkfs_sized $((2 * 1024 * 1024 * 1024)) >>$seqres.full 2>&1
63 # Create a 4k file and Allocate 4M past EOF on that file
64 $XFS_IO_PROG -f -c "pwrite 0 4k" -c "falloc -k 4k 4m" $SCRATCH_MNT/test \
65 >>$seqres.full 2>&1 || _fail "failed to create test file"
67 # Fill the rest of the fs completely
68 # Note, this will show ENOSPC errors in $seqres.full, that's ok.
69 echo "Fill fs with 1M IOs; ENOSPC expected" >> $seqres.full
70 dd if=/dev/zero of=$SCRATCH_MNT/tmp1 bs=1M >>$seqres.full 2>&1
71 echo "Fill fs with 4K IOs; ENOSPC expected" >> $seqres.full
72 dd if=/dev/zero of=$SCRATCH_MNT/tmp2 bs=4K >>$seqres.full 2>&1
74 # Last effort, use O_SYNC
75 echo "Fill fs with 4K DIOs; ENOSPC expected" >> $seqres.full
76 dd if=/dev/zero of=$SCRATCH_MNT/tmp3 bs=4K oflag=sync >>$seqres.full 2>&1
77 # Save space usage info
78 echo "Post-fill space:" >> $seqres.full
79 df $SCRATCH_MNT >>$seqres.full 2>&1
81 # Now attempt a write into all of the preallocated space -
82 # in a very nasty way, badly fragmenting it and then filling it in.
83 echo "Fill in prealloc space; fragment at offsets:" >> $seqres.full
84 for i in `seq 1 2 1023`; do
85 echo -n "$i " >> $seqres.full
86 dd if=/dev/zero of=$SCRATCH_MNT/test seek=$i bs=4K count=1 conv=notrunc \
87 >>$seqres.full 2>/dev/null || _fail "failed to write to test file"
91 echo "Fill in prealloc space; fill holes at offsets:" >> $seqres.full
92 for i in `seq 2 2 1023`; do
93 echo -n "$i " >> $seqres.full
94 dd if=/dev/zero of=$SCRATCH_MNT/test seek=$i bs=4K count=1 conv=notrunc \
95 >>$seqres.full 2>/dev/null || _fail "failed to fill test file"